Merge pull request #5313 from DeCareSystemsIreland/umbracoApiTypings

Umbraco api typings
This commit is contained in:
Masahiro Wakame
2015-08-14 00:12:29 +09:00
4 changed files with 4246 additions and 0 deletions
+1739
View File
File diff suppressed because it is too large Load Diff
+2394
View File
File diff suppressed because it is too large Load Diff
+93
View File
@@ -0,0 +1,93 @@
/// <reference path="umbraco.d.ts" />
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../underscore/underscore.d.ts" />
var navigationService: umb.services.INavigationService;
var notificationsService: umb.services.INotificationsService;
var dialogService: umb.services.IDialogService;
var editorState: umb.services.IEditorState;
var appState: umb.services.IAppState;
/**
* Sync tree for specific path
*/
navigationService.syncTree({ tree: "content", path: "", forceReload: true, activate: false })
.then(() => {
//do something
});
/**
* Open Modal
*/
dialogService.open({
// set the location of the view
template: "",
iframe: true,
// function called when dialog is closed
callback: () => {
// close all
dialogService.closeAll();
}
});
/**
* Hide/show navigation in custom sections so we have full screen for complex dashboards
*/
var toggleNavigation = () => {
var isNavigationShown = appState.getGlobalState("showNavigation");
if (isNavigationShown) {
appState.setGlobalState("showNavigation", false);
$("#contentwrapper").css("left", "80px");
} else {
appState.setGlobalState("showNavigation", true);
$("#contentwrapper").css("left", "440px");
}
}
/**
* Get current node
*/
var getCurrentNode = () => {
return appState.getMenuState("currentNode");
}
/**
* Check if a node is published
*/
var isPublishedNode = () => {
// check that we have an active node
if (_.isUndefined(editorState.current)) {
return false;
}
return editorState.current.published;
};
/**
* Gets the "active" node id to use for any api request
* Note that this retrieves the parent node id if the current node is in an unpublished state
* Note also that in Umbraco 7 the right click custom menu may be brought up without changing the editorState to the node that we right clicked on.
* So the editorState still gives the active node id not the right clicked node is
*/
var getActiveNodeId = () => {
// check that we have an active node
if (_.isUndefined(editorState.current)) {
return 0;
}
// get the parent id of the current node - we get parent because if we create a new module then the current node will be unpublished and this "id" will be 0
return editorState.current.id > 0 ? editorState.current.id : editorState.current.parentId;
}
/**
* Display error notification
*/
notificationsService.error("Error", "An unknown error has occured.");
/**
* Display success notification
*/
notificationsService.success("Success", "Operation completed.");
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for Umbraco v7.2.8
// Project: https://github.com/umbraco
// Definitions by: DeCareSystemsIreland <https://github.com/DeCareSystemsIreland>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="umbraco-services.d.ts" />
/// <reference path="umbraco-resources.d.ts" />
// Collapse umbraco into umb
import umb = umbraco;
// Support AMD require
declare module 'umbraco' {
export = umbraco;
}
declare module umbraco {
}