diff --git a/ng-dialog/ng-dialog-tests.ts b/ng-dialog/ng-dialog-tests.ts index 27f50f89c..2fe90fe22 100644 --- a/ng-dialog/ng-dialog-tests.ts +++ b/ng-dialog/ng-dialog-tests.ts @@ -41,7 +41,7 @@ class DialogTestController { class LoginDialogController { - constructor($scope: angular.dialog.IDialogScope) { + constructor($scope:angular.dialog.IDialogScope) { $scope.closeThisDialog("bye"); } diff --git a/ng-dialog/ng-dialog.d.ts b/ng-dialog/ng-dialog.d.ts index 95f02af63..a89abd929 100644 --- a/ng-dialog/ng-dialog.d.ts +++ b/ng-dialog/ng-dialog.d.ts @@ -10,7 +10,7 @@ declare module angular.dialog { interface IDialogService { getDefaults(): IDialogOptions; open(options: IDialogOpenOptions): IDialogOpenResult; - openConfirm(options: IDialogOpenOptions): IPromise; + openConfirm(options: IDialogOpenConfirmOptions): IPromise; /** * Determine whether the specified dialog is open or not. @@ -25,7 +25,7 @@ declare module angular.dialog { interface IDialogOpenResult { id: string; - close: (value?: string) => void; + close: (value?: any) => void; closePromise: IPromise; } @@ -41,6 +41,21 @@ declare module angular.dialog { * @returns {} */ setDefaults(defaultOptions: IDialogOptions): void; + + /** + * Adds an additional listener on every $locationChangeSuccess event and gets update version of html into dialog. + * May be useful in some rare cases when you're dependant on DOM changes, defaults to false. + * @param {boolean} force + */ + setForceHtmlReload(force: boolean) : void; + + /** + * Adds additional listener on every $locationChangeSuccess event and gets updated version of body into dialog. + * Maybe useful in some rare cases when you're dependant on DOM changes, defaults to false. Use it in module's + * config as provider instance: + * @param {boolean} force + */ + setForceBodyReload(force: boolean) : void; } /** @@ -53,6 +68,27 @@ declare module angular.dialog { * For dialogs opened with the openConfirm() method the value is used as the reject reason. */ closeThisDialog(value?: any): void; + + /** + * Any serializable data that you want to be stored in the controller's dialog scope. + * From version 0.3.6 $scope.ngDialogData keeps references to the objects instead of copying them. + */ + ngDialogData : string | {} | any[]; + + /** + * The id of the dialog. If you you ngDialogData, it'll be also available under ngDialogData.ngDialogId + */ + ngDialogId : string; + } + + interface IDialogConfirmScope extends IDialogScope { + /** + * Use this method to close the dialog and resolve the promise that was returned when opening the modal. + * + * The function accepts a single optional parameter which is used as the value of the resolved promise. + * @param {any} [value] - The value with which the promise will resolve + */ + confirm(value?:any) : void; } interface IDialogOptions { @@ -63,7 +99,7 @@ declare module angular.dialog { className?: string; /** - * If true then animation for the dialog will be disabled, default false. + * If true then animation for the dialog will be disabled, default false. */ disableAnimation?: boolean; @@ -88,6 +124,12 @@ declare module angular.dialog { */ closeByDocument?: boolean; + /** + * Listens for $locationChangeSuccess event and closes open dialogs if true (also handles the ui.router $stateChangeSuccess event if ui.router is used) + * default : false + */ + closeByNavigation?: boolean; + /** * If true allows to use plain string as template, default false. */ @@ -98,7 +140,76 @@ declare module angular.dialog { */ name?: string | number; + /** + * Provide either the name of a function or a function to be called before the dialog is closed. + * If the callback function specified in the option returns false then the dialog will not be closed. + * Alternatively, if the callback function returns a promise that gets resolved the dialog will be closed. + * + * more: https://github.com/likeastore/ngDialog#preclosecallback-string--function + */ preCloseCallback?: string|Function; + + /** + * Pass false to disable template caching. Useful for developing purposes, default is true. + */ + cache?: boolean; + + /** + * Specify your element where to append dialog instance, accepts selector string (e.g. #yourId, .yourClass). + * If not specified appends dialog to body as default behavior. + */ + appendTo?: string; + + /** + * When true, ensures that the focused element remains within the dialog to conform to accessibility recommendations. + * Default value is true + */ + trapFocus?: boolean; + + /** + * When true, closing the dialog restores focus to the element that launched it. Designed to improve keyboard + * accessibility. Default value is true + */ + preserveFocus?: boolean; + + /** + * When true, automatically selects appropriate values for any unspecified accessibility attributes. Default value is true + */ + ariaAuto? : boolean; + + /** + * Specifies the value for the role attribute that should be applied to the dialog element. Default value is null (unspecified) + */ + ariaRole?: string; + + /** + * Specifies the value for the aria-labelledby attribute that should be applied to the dialog element. + * Default value is null (unspecified) + * + * If specified, the value is not validated against the DOM + */ + ariaLabelledById?: string; + + /** + * Specifies the CSS selector for the element to be referenced by the aria-labelledby attribute on the dialog element. Default value is null (unspecified) + * + * If specified, the first matching element is used. + */ + ariaLabelledBySelector?: string; + + /** + * Specifies the value for the aria-describedby attribute that should be applied to the dialog element. Default value is null (unspecified) + * + * If specified, the value is not validated against the DOM. + */ + ariaDescribedById?: string; + + /** + * Specifies the CSS selector for the element to be referenced by the aria-describedby attribute on the dialog element. Default value is null (unspecified) + * + * If specified, the first matching element is used. + */ + ariaDescribedBySelector?: string; } /** @@ -106,15 +217,29 @@ declare module angular.dialog { */ interface IDialogOpenOptions extends IDialogOptions { template: string; - controller?: string|any; + controller?: string| any[] | any; controllerAs?: string; + /** * Scope object that will be passed to dialog. If you use controller with separate $scope service this object will be passed to $scope.$parent param. */ - scope?: ng.IScope; + scope?: IDialogScope; + /** - * Any serializable data that you want to be stored in the controller's dialog scope. + * An optional map of dependencies which should be injected into the controller. If any of these dependencies + * are promises, ngDialog will wait for them all to be resolved or one to be rejected before the controller + * is instantiated. */ - data?: string|Object|any[]; + resolve?: {[key : string] : string | Function}; + + /** + * Any serializable data that you want to be stored in the controller's dialog scope. ($scope.ngDialogData). + * From version 0.3.6 $scope.ngDialogData keeps references to the objects instead of copying them. + */ + data?: string | {} | any[]; + } + + interface IDialogOpenConfirmOptions extends IDialogOpenOptions { + scope?: IDialogConfirmScope; } }