declarations
Version:
[](https://www.npmjs.com/package/declarations)
1,456 lines (1,306 loc) • 81.4 kB
TypeScript
// Type definitions for Umbraco v7.2.8
// Project: https://github.com/umbraco
// Definitions by: DeCareSystemsIreland <https://github.com/DeCareSystemsIreland>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="umbraco.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
declare namespace umbraco.services {
/**
* @ngdoc service
* @name umbraco.services.angularHelper
* @function
*
* @description
* Some angular helper/extension methods
*/
interface IAngularHelper {
/**
* @ngdoc function
* @name umbraco.services.angularHelper#rejectedPromise
* @methodOf umbraco.services.angularHelper
* @function
*
* @description
* In some situations we need to return a promise as a rejection, normally based on invalid data. This
* is a wrapper to do that so we can save on writing a bit of code.
*
* @param {object} objReject The object to send back with the promise rejection
*/
rejectedPromise(objReject: Object): void;
/**
* @ngdoc function
* @name safeApply
* @methodOf umbraco.services.angularHelper
* @function
*
* @description
* This checks if a digest/apply is already occuring, if not it will force an apply call
*/
safeApply(scope: ng.IScope, fn: Function): void;
/**
* @ngdoc function
* @name getCurrentForm
* @methodOf umbraco.services.angularHelper
* @function
*
* @description
* Returns the current form object applied to the scope or null if one is not found
*/
getCurrentForm(scope: ng.IScope): any;
/**
* @ngdoc function
* @name validateHasForm
* @methodOf umbraco.services.angularHelper
* @function
*
* @description
* This will validate that the current scope has an assigned form object, if it doesn't an exception is thrown, if
* it does we return the form object.
*/
getRequiredCurrentForm(scope: ng.IScope): Object;
/**
* @ngdoc function
* @name getNullForm
* @methodOf umbraco.services.angularHelper
* @function
*
* @description
* Returns a null angular FormController, mostly for use in unit tests
* NOTE: This is actually the same construct as angular uses internally for creating a null form but they don't expose
* any of this publicly to us, so we need to create our own.
*
* @param {string} formName The form name to assign
*/
getNullForm(formName: string): ng.IFormController;
}
/**
* Global State
*/
interface IGlobalState {
showNavigation: boolean;
touchDevice: boolean;
showTray: boolean;
stickyNavigation: any;
navMode: any;
isReady: boolean;
}
/**
* Section State
*/
interface ISectionState {
//The currently active section
currentSection: any;
showSearchResults: boolean;
}
/**
* Tree State
*/
interface ITreeState {
//The currently selected node
selectedNode: any;
//The currently loaded root node reference - depending on the section loaded this could be a section root or a normal root.
//We keep this reference so we can lookup nodes to interact with in the UI via the tree service
currentRootNode: any;
}
/**
* Menu State
*/
interface IMenuState {
//this list of menu items to display
menuActions: any;
//the title to display in the context menu dialog
dialogTitle: string;
//The tree node that the ctx menu is launched for
currentNode: any;
//Whether the menu's dialog is being shown or not
showMenuDialog: boolean;
//Whether the context menu is being shown or not
showMenu: boolean;
}
/**
* State Object
*/
interface IStateObject {
id: number;
parentId: number;
name: string;
}
/**
* @ngdoc service
* @name umbraco.services.appState
* @function
*
* @description
* Tracks the various application state variables when working in the back office, raises events when state changes.
*/
interface IAppState {
/** function to validate and set the state on a state object */
setState(stateObj: IStateObject, key: string, value: any, stateObjName: string): void;
/** function to validate and set the state on a state object */
getState(stateObj: IStateObject, key: string, stateObjName: string): IStateObject;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#getGlobalState
* @methodOf umbraco.services.appState
* @function
*
* @description
* Returns the current global state value by key - we do not return an object reference here - we do NOT want this
* to be publicly mutable and allow setting arbitrary values
*/
getGlobalState(key: string): IGlobalState;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#setGlobalState
* @methodOf umbraco.services.appState
* @function
*
* @description
* Sets a global state value by key
*/
setGlobalState(key: string, value: boolean): void;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#getSectionState
* @methodOf umbraco.services.appState
* @function
*
* @description
* Returns the current section state value by key - we do not return an object here - we do NOT want this
* to be publicly mutable and allow setting arbitrary values
*/
getSectionState(key: string): ISectionState;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#setSectionState
* @methodOf umbraco.services.appState
* @function
*
* @description
* Sets a section state value by key
*/
setSectionState(key: string, value: ISectionState): void;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#getTreeState
* @methodOf umbraco.services.appState
* @function
*
* @description
* Returns the current tree state value by key - we do not return an object here - we do NOT want this
* to be publicly mutable and allow setting arbitrary values
*/
getTreeState(key: string): ITreeState;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#setTreeState
* @methodOf umbraco.services.appState
* @function
*
* @description
* Sets a section state value by key
*/
setTreeState(key: string, value: ITreeState): void;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#getMenuState
* @methodOf umbraco.services.appState
* @function
*
* @description
* Returns the current menu state value by key - we do not return an object here - we do NOT want this
* to be publicly mutable and allow setting arbitrary values
*/
getMenuState(key: string): IStateObject;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#setMenuState
* @methodOf umbraco.services.appState
* @function
*
* @description
* Sets a section state value by key
*/
setMenuState(key: string, value: IMenuState): void;
}
/*Tracks the parent object for complex editors by exposing it as an object reference via editorState.current.entity
* it is possible to modify this object, so should be used with care */
interface IState {
/**
* @ngdoc function
* @name umbraco.services.angularHelper#set
* @methodOf umbraco.services.editorState
* @function
*
* @description
* Sets the current entity object for the currently active editor
* This is only used when implementing an editor with a complex model
* like the content editor, where the model is modified by several
* child controllers.
*/
set(entity: Object): void;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#reset
* @methodOf umbraco.services.editorState
* @function
*
* @description
* Since the editorstate entity is read-only, you cannot set it to null
* only through the reset() method
*/
reset(): void;
/**
* @ngdoc function
* @name umbraco.services.angularHelper#getCurrent
* @methodOf umbraco.services.editorState
* @function
*
* @description
* Returns an object reference to the current editor entity.
* the entity is the root object of the editor.
* EditorState is used by property/parameter editors that need
* access to the entire entity being edited, not just the property/parameter
*
* editorState.current can not be overwritten, you should only read values from it
* since modifying individual properties should be handled by the property editors
*/
getCurrent(): any;
}
/**
* @ngdoc service
* @name umbraco.services.assetsService
*
* @requires $q
* @requires angularHelper
*
* @description
* Promise-based utillity service to lazy-load client-side dependencies inside angular controllers.
*/
interface IAssetsService {
/**
* @ngdoc method
* @name umbraco.services.assetsService#loadCss
* @methodOf umbraco.services.assetsService
*
* @description
* Injects a file as a stylesheet into the document head
*
* @param {String} path path to the css file to load
* @param {Scope} scope optional scope to pass into the loader
* @param {Object} keyvalue collection of attributes to pass to the stylesheet element
* @param {Number} timeout in milliseconds
* @returns {Promise} Promise object which resolves when the file has loaded
*/
loadCss(path: string, scope: ng.IScope, attributes: Object, timeout: number): ng.IPromise<any>;
/**
* @ngdoc method
* @name umbraco.services.assetsService#loadJs
* @methodOf umbraco.services.assetsService
*
* @description
* Injects a file as a javascript into the document
*
* @param {String} path path to the js file to load
* @param {Scope} scope optional scope to pass into the loader
* @param {Object} keyvalue collection of attributes to pass to the script element
* @param {Number} timeout in milliseconds
* @returns {Promise} Promise object which resolves when the file has loaded
*/
loadJs(path: string, scope: ng.IScope, attributes: Object, timeout: number): ng.IPromise<any>;
/**
* @ngdoc method
* @name umbraco.services.assetsService#load
* @methodOf umbraco.services.assetsService
*
* @description
* Injects a collection of files, this can be ONLY js files
*
*
* @param {Array} pathArray string array of paths to the files to load
* @param {Scope} scope optional scope to pass into the loader
* @returns {Promise} Promise object which resolves when all the files has loaded
*/
load(pathArray: string[], scope: ng.IScope): ng.IPromise<any>;
}
/**
* @ngdoc service
* @name umbraco.services.contentEditingHelper
* @description A helper service for most editors, some methods are specific to content/media/member model types but most are used by
* all editors to share logic and reduce the amount of replicated code among editors.
*/
interface IContentEditingHelper {
/**
* @ngdoc method
* @name umbraco.services.contentEditingHelper#getAllProps
* @methodOf umbraco.services.contentEditingHelper
* @function
*
* @description
* Returns all propertes contained for the content item (since the normal model has properties contained inside of tabs)
*/
getAllProps(content: any): any;
/**
* @ngdoc method
* @name umbraco.services.contentEditingHelper#configureButtons
* @methodOf umbraco.services.contentEditingHelper
* @function
*
* @description
* Returns a letter array for buttons, with the primary one first based on content model, permissions and editor state
*/
getAllowedActions(content: any, creating: any): string[];
/**
* @ngdoc method
* @name umbraco.services.contentEditingHelper#getButtonFromAction
* @methodOf umbraco.services.contentEditingHelper
* @function
*
* @description
* Returns a button object to render a button for the tabbed editor
* currently only returns built in system buttons for content and media actions
* returns label, alias, action char and hot-key
*/
getButtonFromAction(ch: string): any;
/**
* @ngdoc method
* @name umbraco.services.contentEditingHelper#reBindChangedProperties
* @methodOf umbraco.services.contentEditingHelper
* @function
*
* @description
* re-binds all changed property values to the origContent object from the savedContent object and returns an array of changed properties.
*/
reBindChangedProperties(origContent: any, savedContent: any): void;
/**
* @ngdoc function
* @name umbraco.services.contentEditingHelper#handleSaveError
* @methodOf umbraco.services.contentEditingHelper
* @function
*
* @description
* A function to handle what happens when we have validation issues from the server side
*/
handleSaveError(...args: any[]): void;
/**
* @ngdoc function
* @name umbraco.services.contentEditingHelper#handleSuccessfulSave
* @methodOf umbraco.services.contentEditingHelper
* @function
*
* @description
* A function to handle when saving a content item is successful. This will rebind the values of the model that have changed
* ensure the notifications are displayed and that the appropriate events are fired. This will also check if we need to redirect
* when we're creating new content.
*/
handleSuccessfulSave(...args: any[]): void;
/**
* @ngdoc function
* @name umbraco.services.contentEditingHelper#redirectToCreatedContent
* @methodOf umbraco.services.contentEditingHelper
* @function
*
* @description
* Changes the location to be editing the newly created content after create was successful.
* We need to decide if we need to redirect to edito mode or if we will remain in create mode.
* We will only need to maintain create mode if we have not fulfilled the basic requirements for creating an entity which is at least having a name.
*/
redirectToCreatedContent(id: number, modelState: any): void;
}
/**
* @ngdoc service
* @name umbraco.services.cropperHelper
* @description A helper object used for dealing with image cropper data
*/
interface ICropperHelper {
/**
* @ngdoc method
* @name umbraco.services.cropperHelper#configuration
* @methodOf umbraco.services.cropperHelper
*
* @description
* Returns a collection of plugins available to the tinyMCE editor
*
*/
configuration(mediaTypeAlias: string): any;
}
/**
* Rendering options
*/
interface IDialogRenderingOptions {
/*the DOM element to inject the modal into, by default set to body*/
container?: HTMLElement;
/*function called when the modal is submitted*/
callback: Function;
/*the url of the template*/
template: string;
/*animation css class, by default set to "fade"*/
animation?: string;
/*modal css class, by default "umb-modal"*/
modalClass?: string;
/*show the modal instantly*/
show?: boolean;
/*load template in an iframe, only needed for serverside templates*/
iframe: boolean;
/*set a width on the modal, only needed for iframes*/
width?: number;
/*strips the modal from any animation and wrappers, used when you want to inject a dialog into an existing container*/
inline?: boolean;
/**
* It will set this value as a property on the dialog controller's scope as $scope.dialogData
*/
dialogData?: any;
}
/**
* Modal
*/
interface IModal {
}
/**
* Mediapicker dialog options object
*/
interface IMediaPickerOptions {
/*Only display files that have an image file-extension*/
onlyImages: boolean;
/*callback function*/
callback: Function;
}
/**
* Content picker dialog options object
*/
interface IContentPickerOptions {
/*should the picker return one or multiple items*/
multipicker: boolean;
/*callback function*/
callback: Function;
}
/**
* Iconpicker dialog options object
*/
interface IIconPickerOptions {
/*callback function*/
callback: Function;
}
/**
* Linkpicker dialog options object
*/
interface ILinkPickerOptions {
/*callback function*/
callback: Function;
}
/**
* Macropicker dialog options object
*/
interface IMacroPickerOptions {
/*callback function*/
callback: Function;
}
/**
* Member group picker dialog options object
*/
interface IMemberGroupPickerOptions {
/*should the tree pick one or multiple members before returning*/
multiPicker: boolean;
/*callback function*/
callback: Function;
}
/**
* Member picker dialog options object
*/
interface IMemberPickerOptions {
/*should the tree pick one or multiple members before returning*/
multiPicker: boolean;
/*callback function*/
callback: Function;
}
/**
* Property dialog options object
*/
interface IPropertyDialogOptions {
/*callback function*/
callback: Function;
/*editor to use to edit a given value and return on callback*/
editor: string;
/*value sent to the property editor*/
value: Object;
}
/**
* Iconpicker dialog options object
*/
interface ITreePickerOptions {
/*tree section to display*/
section: string;
/*specific tree to display*/
treeAlias: string;
/*should the tree pick one or multiple items before returning*/
multiPicker: boolean;
/*callback function*/
callback: Function;
}
/**
* Dialog options object
*/
interface IDialog {
}
/*
* Application-wide service for handling modals, overlays and dialogs By default it
* injects the passed template url into a div to body of the document And renders it,
* but does also support rendering items in an iframe, incase serverside processing is needed, or its a non-angular page
*/
interface IDialogService {
dialogs?: any[];
/** Internal method that removes all dialogs */
removeAllDialogs(...args: any[]): void;
/** Internal method that closes the dialog properly and cleans up resources */
closeDialog(dialog: IDialog): void;
/** Internal method that handles opening all dialogs */
openDialog(options: IDialogRenderingOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#open
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a modal rendering a given template url.
*
* @param {Object} options rendering options
* @param {DomElement} options.container the DOM element to inject the modal into, by default set to body
* @param {Function} options.callback function called when the modal is submitted
* @param {String} options.template the url of the template
* @param {String} options.animation animation csss class, by default set to "fade"
* @param {String} options.modalClass modal css class, by default "umb-modal"
* @param {Bool} options.show show the modal instantly
* @param {Bool} options.iframe load template in an iframe, only needed for serverside templates
* @param {Int} options.width set a width on the modal, only needed for iframes
* @param {Bool} options.inline strips the modal from any animation and wrappers, used when you want to inject a dialog into an existing container
* @returns {Object} modal object
*/
open(options: IDialogRenderingOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#close
* @methodOf umbraco.services.dialogService
*
* @description
* Closes a specific dialog
* @param {Object} dialog the dialog object to close
* @param {Object} args if specified this object will be sent to any callbacks registered on the dialogs.
*/
close(dialog: IDialog, ...args: any[]): void;
/**
* @ngdoc method
* @name umbraco.services.dialogService#closeAll
* @methodOf umbraco.services.dialogService
*
* @description
* Closes all dialogs
* @param {Object} args if specified this object will be sent to any callbacks registered on the dialogs.
*/
closeAll(...args: any[]): void;
/**
* @ngdoc method
* @name umbraco.services.dialogService#mediaPicker
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a media picker in a modal, the callback returns an array of selected media items
* @param {Object} options mediapicker dialog options object
* @param {Boolean} options.onlyImages Only display files that have an image file-extension
* @param {Function} options.callback callback function
* @returns {Object} modal object
*/
mediaPicker(options: IMediaPickerOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#contentPicker
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a content picker tree in a modal, the callback returns an array of selected documents
* @param {Object} options content picker dialog options object
* @param {Boolean} options.multipicker should the picker return one or multiple items
* @param {Function} options.callback callback function
* @returns {Object} modal object
*/
contentPicker(options: IContentPickerOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#linkPicker
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a link picker tree in a modal, the callback returns a single link
* @param {Object} options content picker dialog options object
* @param {Function} options.callback callback function
* @returns {Object} modal object
*/
linkPicker(options: ILinkPickerOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#macroPicker
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a mcaro picker in a modal, the callback returns a object representing the macro and it's parameters
* @param {Object} options macropicker dialog options object
* @param {Function} options.callback callback function
* @returns {Object} modal object
*/
macroPicker(options: IMacroPickerOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#memberPicker
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a member picker in a modal, the callback returns a object representing the selected member
* @param {Object} options member picker dialog options object
* @param {Boolean} options.multiPicker should the tree pick one or multiple members before returning
* @param {Function} options.callback callback function
* @returns {Object} modal object
*/
memberPicker(options: IMemberPickerOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#memberGroupPicker
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a member group picker in a modal, the callback returns a object representing the selected member
* @param {Object} options member group picker dialog options object
* @param {Boolean} options.multiPicker should the tree pick one or multiple members before returning
* @param {Function} options.callback callback function
* @returns {Object} modal object
*/
memberGroupPicker(options: IMemberGroupPickerOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#iconPicker
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a icon picker in a modal, the callback returns a object representing the selected icon
* @param {Object} options iconpicker dialog options object
* @param {Function} options.callback callback function
* @returns {Object} modal object
*/
iconPicker(options: IIconPickerOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#treePicker
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a tree picker in a modal, the callback returns a object representing the selected tree item
* @param {Object} options iconpicker dialog options object
* @param {String} options.section tree section to display
* @param {String} options.treeAlias specific tree to display
* @param {Boolean} options.multiPicker should the tree pick one or multiple items before returning
* @param {Function} options.callback callback function
* @returns {Object} modal object
*/
treePicker(options: ITreePickerOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#propertyDialog
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a dialog with a chosen property editor in, a value can be passed to the modal, and this value is returned in the callback
* @param {Object} options mediapicker dialog options object
* @param {Function} options.callback callback function
* @param {String} editor editor to use to edit a given value and return on callback
* @param {Object} value value sent to the property editor
* @returns {Object} modal object
*/
propertyDialog(options: IPropertyDialogOptions): IModal;
/**
* @ngdoc method
* @name umbraco.services.dialogService#ysodDialog
* @methodOf umbraco.services.dialogService
* @description
* Opens a dialog to an embed dialog
*/
embedDialog(options: any): void;
/**
* @ngdoc method
* @name umbraco.services.dialogService#ysodDialog
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a dialog to show a custom YSOD
*/
ysodDialog(ysodError: any): void;
}
/** Used to broadcast and listen for global events and allow the ability to add async listeners to the callbacks */
/**
Core app events:
app.ready
app.authenticated
app.notAuthenticated
app.closeDialogs
*/
interface IEventService {
}
/**
* File
*/
interface IFile {
}
/**
* @ngdoc service
* @name umbraco.services.fileManager
* @function
*
* @description
* Used by editors to manage any files that require uploading with the posted data, normally called by property editors
* that need to attach files.
* When a route changes successfully, we ensure that the collection is cleared.
*/
interface IFileManager {
/**
* @ngdoc function
* @name umbraco.services.fileManager#addFiles
* @methodOf umbraco.services.fileManager
* @function
*
* @description
* Attaches files to the current manager for the current editor for a particular property, if an empty array is set
* for the files collection that effectively clears the files for the specified editor.
*/
setFiles(propertyAlias: string, files: IFile[]): void;
/**
* @ngdoc function
* @name umbraco.services.fileManager#getFiles
* @methodOf umbraco.services.fileManager
* @function
*
* @description
* Returns all of the files attached to the file manager
*/
getFiles(): IFile[];
/**
* @ngdoc function
* @name umbraco.services.fileManager#clearFiles
* @methodOf umbraco.services.fileManager
* @function
*
* @description
* Removes all files from the manager
*/
clearFiles(): void;
}
/**
* Model state
*/
interface IModelState {
}
/**
* @ngdoc service
* @name umbraco.services.formHelper
* @function
*
* @description
* A utility class used to streamline how forms are developed, to ensure that validation is check and displayed consistently and to ensure that the correct events
* fire when they need to.
*/
interface IFormHelper {
/**
* @ngdoc function
* @name umbraco.services.formHelper#submitForm
* @methodOf umbraco.services.formHelper
* @function
*
* @description
* Called by controllers when submitting a form - this ensures that all client validation is checked,
* server validation is cleared, that the correct events execute and status messages are displayed.
* This returns true if the form is valid, otherwise false if form submission cannot continue.
*
* @param {object} args An object containing arguments for form submission
*/
submitForm(...args: any[]): void;
/**
* @ngdoc function
* @name umbraco.services.formHelper#submitForm
* @methodOf umbraco.services.formHelper
* @function
*
* @description
* Called by controllers when a form has been successfully submitted. the correct events execute
* and that the notifications are displayed if there are any.
*
* @param {object} args An object containing arguments for form submission
*/
resetForm(...args: any[]): void;
/**
* @ngdoc function
* @name umbraco.services.formHelper#handleError
* @methodOf umbraco.services.formHelper
* @function
*
* @description
* Needs to be called when a form submission fails, this will wire up all server validation errors in ModelState and
* add the correct messages to the notifications. If a server error has occurred this will show a ysod.
*
* @param {object} err The error object returned from the http promise
*/
handleError(err: Object): void;
/**
* @ngdoc function
* @name umbraco.services.formHelper#handleServerValidation
* @methodOf umbraco.services.formHelper
* @function
*
* @description
* This wires up all of the server validation model state so that valServer and valServerField directives work
*
* @param {object} err The error object returned from the http promise
*/
handleServerValidation(modelState: IModelState): void;
}
/**
* History item
*/
interface IHistoryItem {
//css class for the list, ex: "icon-image", "icon-doc"
icon: string;
//route to the editor, ex: "/content/edit/1234"
link: string;
//friendly name for the history listing
name: string;
}
/**
* @ngdoc service
* @name umbraco.services.historyService
*
* @requires $rootScope
* @requires $timeout
* @requires angularHelper
*
* @description
* Service to handle the main application navigation history. Responsible for keeping track
* of where a user navigates to, stores an icon, url and name in a collection, to make it easy
* for the user to go back to a previous editor / action
*
* **Note:** only works with new angular-based editors, not legacy ones
*
* ##usage
* To use, simply inject the historyService into any controller that needs it, and make
* sure the umbraco.services module is accesible - which it should be by default.
*/
interface IHistoryService {
/**
* @ngdoc method
* @name umbraco.services.historyService#add
* @methodOf umbraco.services.historyService
*
* @description
* Adds a given history item to the users history collection.
*
* @param {Object} item the history item
* @param {String} item.icon icon css class for the list, ex: "icon-image", "icon-doc"
* @param {String} item.link route to the editor, ex: "/content/edit/1234"
* @param {String} item.name friendly name for the history listing
* @returns {Object} history item object
*/
add(item: IHistoryItem): IHistoryItem;
/**
* @ngdoc method
* @name umbraco.services.historyService#remove
* @methodOf umbraco.services.historyService
*
* @description
* Removes a history item from the users history collection, given an index to remove from.
*
* @param {Int} index index to remove item from
*/
remove(index: number): void;
/**
* @ngdoc method
* @name umbraco.services.historyService#removeAll
* @methodOf umbraco.services.historyService
*
* @description
* Removes all history items from the users history collection
*/
removeAll(): void;
/**
* @ngdoc method
* @name umbraco.services.historyService#getCurrent
* @methodOf umbraco.services.historyService
*
* @description
* Method to return the current history collection.
*/
getCurrent(): IHistoryItem[];
}
/**
* @ngdoc service
* @name umbraco.services.macroService
*
*
* @description
* A service to return macro information such as generating syntax to insert a macro into an editor
*/
interface IMacroService {
/**
* @ngdoc function
* @name umbraco.services.macroService#generateWebFormsSyntax
* @methodOf umbraco.services.macroService
* @function
*
* @description
* generates the syntax for inserting a macro into a rich text editor - this is the very old umbraco style syntax
*
* @param {object} args an object containing the macro alias and it's parameter values
*/
generateMacroSyntax(...args: any[]): void;
/**
* @ngdoc function
* @name umbraco.services.macroService#generateWebFormsSyntax
* @methodOf umbraco.services.macroService
* @function
*
* @description
* generates the syntax for inserting a macro into a webforms templates
*
* @param {object} args an object containing the macro alias and it's parameter values
*/
generateWebFormsSyntax(...args: any[]): void;
/**
* @ngdoc function
* @name umbraco.services.macroService#generateMvcSyntax
* @methodOf umbraco.services.macroService
* @function
*
* @description
* generates the syntax for inserting a macro into an mvc template
*
* @param {object} args an object containing the macro alias and it's parameter values
*/
generateMvcSyntax(...args: any[]): void;
}
/**
* Media model
*/
interface IMediaModel {
}
/**
* Media options
*/
interface IMediaOptions {
mediaModel: IMediaModel;
imageOnly: boolean;
}
/**
* Media entity
*/
interface IMediaEntity {
}
/**
* @ngdoc service
* @name umbraco.services.mediaHelper
* @description A helper object used for dealing with media items
*/
interface IMediaHelper {
/**
* @ngdoc function
* @name umbraco.services.mediaHelper#getImagePropertyValue
* @methodOf umbraco.services.mediaHelper
* @function
*
* @description
* Returns the file path associated with the media property if there is one
*
* @param {object} options Options object
* @param {object} options.mediaModel The media object to retrieve the image path from
* @param {object} options.imageOnly Optional, if true then will only return a path if the media item is an image
*/
getMediaPropertyValue(options: IMediaOptions): string;
/**
* @ngdoc function
* @name umbraco.services.mediaHelper#getImagePropertyValue
* @methodOf umbraco.services.mediaHelper
* @function
*
* @description
* Returns the actual image path associated with the image property if there is one
*
* @param {object} options Options object
* @param {object} options.imageModel The media object to retrieve the image path from
*/
getImagePropertyValue(options: IMediaOptions): string;
/**
* @ngdoc function
* @name umbraco.services.mediaHelper#getThumbnail
* @methodOf umbraco.services.mediaHelper
* @function
*
* @description
* formats the display model used to display the content to the model used to save the content
*
* @param {object} options Options object
* @param {object} options.imageModel The media object to retrieve the image path from
*/
getThumbnail(options: IMediaOptions): string;
/**
* @ngdoc function
* @name umbraco.services.mediaHelper#resolveFileFromEntity
* @methodOf umbraco.services.mediaHelper
* @function
*
* @description
* Gets the media file url for a media entity returned with the entityResource
*
* @param {object} mediaEntity A media Entity returned from the entityResource
* @param {boolean} thumbnail Whether to return the thumbnail url or normal url
*/
resolveFileFromEntity(mediaEntity: IMediaEntity, thumbnail: boolean): string;
/**
* @ngdoc function
* @name umbraco.services.mediaHelper#resolveFile
* @methodOf umbraco.services.mediaHelper
* @function
*
* @description
* Gets the media file url for a media object returned with the mediaResource
*
* @param {object} mediaEntity A media Entity returned from the entityResource
* @param {boolean} thumbnail Whether to return the thumbnail url or normal url
*/
resolveFile(mediaItem: IMediaEntity, thumbnail: boolean): string;
/**
* @ngdoc function
* @name umbraco.services.mediaHelper#scaleToMaxSize
* @methodOf umbraco.services.mediaHelper
* @function
*
* @description
* Finds the corrct max width and max height, given maximum dimensions and keeping aspect ratios
*
* @param {number} maxSize Maximum width & height
* @param {number} width Current width
* @param {number} height Current height
*/
scaleToMaxSize(maxSize: number, width: number, height: number): any;
/**
* @ngdoc function
* @name umbraco.services.mediaHelper#getThumbnailFromPath
* @methodOf umbraco.services.mediaHelper
* @function
*
* @description
* Returns the path to the thumbnail version of a given media library image path
*
* @param {string} imagePath Image path, ex: /media/1234/my-image.jpg
*/
getThumbnailFromPath(imagePath: string): string;
/**
* @ngdoc function
* @name umbraco.services.mediaHelper#detectIfImageByExtension
* @methodOf umbraco.services.mediaHelper
* @function
*
* @description
* Returns true/false, indicating if the given path has an allowed image extension
*
* @param {string} imagePath Image path, ex: /media/1234/my-image.jpg
*/
detectIfImageByExtension(imagePath: string): boolean;
}
/**
* Tracks the parent object for complex editors by exposing it as an object reference via editorState.current.entity
* it is possible to modify this object, so should be used with care
*/
interface IEditorState {
current: any;
state: IState;
}
/**
* Sync tree args
*/
interface ISyncTreeArgs {
/*the tree alias to sync to*/
tree: string;
/*the path to sync the tree to*/
path: string;
/* optional, specifies whether to force reload the node data from the server even if it already exists in the tree currently*/
forceReload: boolean;
/* optional, specifies whether to set the synced node to be the active node, this will default to true if not specified*/
activate: boolean;
}
/**
* Show dialog action
*/
interface IShowDialogAction {
name: string;
alias: string;
}
/**
* Show dialog args
*/
interface IShowDialogArgs {
scope: ng.IScope;
action: IShowDialogAction;
}
/**
* @ngdoc service
* @name umbraco.services.navigationService
*
* @requires $rootScope
* @requires $routeParams
* @requires $log
* @requires $location
* @requires dialogService
* @requires treeService
* @requires sectionResource
*
* @description
* Service to handle the main application navigation. Responsible for invoking the tree
* Section navigation and search, and maintain their state for the entire application lifetime
*
*/
interface INavigationService {
/**
* @ngdoc method
* @name umbraco.services.navigationService#load
* @methodOf umbraco.services.navigationService
*
* @description
* Shows the legacy iframe and loads in the content based on the source url
* @param {String} source The URL to load into the iframe
*/
loadLegacyIFrame(source: string): void;
/**
* @ngdoc method
* @name umbraco.services.navigationService#changeSection
* @methodOf umbraco.services.navigationService
*
* @description
* Changes the active section to a given section alias
* If the navigation is 'sticky' this will load the associated tree
* and load the dashboard related to the section
* @param {string} sectionAlias The alias of the section
*/
changeSection(sectionAlias: string, force: boolean): void;
/**
* @ngdoc method
* @name umbraco.services.navigationService#showTree
* @methodOf umbraco.services.navigationService
*
* @description
* Displays the tree for a given section alias but turning on the containing dom element
* only changes if the section is different from the current one
* @param {string} sectionAlias The alias of the section to load
* @param {Object} syncArgs Optional object of arguments for syncing the tree for the section being shown
*/
showTree(sectionAlias: string, syncArgs: ISyncTreeArgs): void;
showTray(): void;
hideTray(): void;
/**
Called to assign the main tree event handler - this is called by the navigation controller.
TODO: Potentially another dev could call this which would kind of mung the whole app so potentially there's a better way.
*/
setupTreeEvents(treeEventHandler: any): void;
/**
* @ngdoc method
* @name umbraco.services.navigationService#syncTree
* @methodOf umbraco.services.navigationService
*
* @description
* Syncs a tree with a given path, returns a promise
* The path format is: ["itemId","itemId"], and so on
* so to sync to a specific document type node do:
* <pre>
* navigationService.syncTree({tree: 'content', path: ["-1","123d"], forceReload: true});
* </pre>
* @param {Object} args arguments passed to the function
* @param {String} args.tree the tree alias to sync to
* @param {Array} args.path the path to sync the tree to
* @param {Boolean} args.forceReload optional, specifies whether to force reload the node data from the server even if it already exists in the tree currently
* @param {Boolean} args.activate optional, specifies whether to set the synced node to be the active node, this will default to true if not specified
*/
syncTree(args: ISyncTreeArgs): any;
/**
Internal method that should ONLY be used by the legacy API wrapper, the legacy API used to
have to set an active tree and then sync, the new API does this in one method by using syncTree
*/
_syncPath(path: string[], forceReload: boolean): void;
//TODO: This should return a promise
reloadNode(node: any): void;
//TODO: This should return a promise
reloadSection(sectionAlias: string): void;
/**
Internal method that should ONLY be used by the legacy API wrapper, the legacy API used to
have to set an active tree and then sync, the new API does this in one method by using syncTreePath
*/
_setActiveTreeType(treeAlias: string, loadChildren: boolean): void;
/**
* @ngdoc method
* @name umbraco.services.navigationService#hideTree
* @methodOf umbraco.services.navigationService
*
* @description
* Hides the tree by hiding the containing dom element
*/
hideTree(): void;
/**
* @ngdoc method
* @name umbraco.services.navigationService#showMenu
* @methodOf umbraco.services.navigationService
*
* @description
* Hides the tree by hiding the containing dom element.
* This always returns a promise!
*
* @param {Event} event the click event triggering the method, passed from the DOM element
*/
showMenu(event: Event, ...args: any[]): void;
/**
* @ngdoc method
* @name umbraco.services.navigationService#hideMenu
* @methodOf umbraco.services.navigationService
*
* @description
* Hides the menu by hiding the containing dom element
*/
hideMenu(): void;
/** Executes a given menu action */
executeMenuAction(action: any, node: any, section: any): void;
/**
* @ngdoc method
* @name umbraco.services.navigationService#showUserDialog
* @methodOf umbraco.services.navigationService
*
* @description
* Opens the user dialog, next to the sections navigation
* template is located in views/common/dialogs/user.html
*/
showUserDialog(): void;
/**
* @ngdoc method
* @name umbraco.services.navigationService#showUserDialog
* @methodOf umbraco.services.navigationService
*
* @description
* Opens the user dialog, next to the sections navigation
* template is located in views/common/dialogs/user.html
*/
showHelpDialog(): void;
/**
* @ngdoc method
* @name umbraco.services.navigationService#showDialog
* @methodOf umbraco.services.navigationService
*
* @description
* Opens a dialog, for a given action on a given tree node
* uses the dialogService to inject the selected action dialog
* into #dialog div.umb-panel-body
* the path to the dialog view is determined by:
* "views/" + current tree + "/" + action alias + ".html"
* The dialog controller will get passed a scope object that is created here with the properties:
* scope.currentNode = the selected tree node
* scope.currentAction = the selected menu item
* so that the dialog controllers can use these properties
*
* @par