From 2daf450b8f86f09f6b0de1b5f86fce3cf185c687 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Aug 2015 14:21:19 +0200 Subject: [PATCH 1/4] updated enabled as per angular changes (after 1.3.14 > 1.4.0) --- angularjs/angular-animate.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index 1ecc3d0d7..35fe10ca9 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -30,11 +30,11 @@ declare module angular.animate { /** * Globally enables / disables animations. * - * @param value If provided then set the animation on or off. * @param element If provided then the element will be used to represent the enable/disable operation. + * @param value If provided then set the animation on or off. * @returns current animation state */ - enabled(value?: boolean, element?: JQuery): boolean; + enabled(element?: JQuery, value?: boolean): boolean; /** * Performs an inline animation on the element. From e92a40e67093ec09d8e7ad807144d237d8330028 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Sep 2015 14:13:04 +0200 Subject: [PATCH 2/4] implemented type definitions for ng-dialog --- ng-dialog/ng-dialog-tests.ts | 52 +++++++++++++++++ ng-dialog/ng-dialog.d.ts | 105 +++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 ng-dialog/ng-dialog-tests.ts create mode 100644 ng-dialog/ng-dialog.d.ts diff --git a/ng-dialog/ng-dialog-tests.ts b/ng-dialog/ng-dialog-tests.ts new file mode 100644 index 000000000..52b33212a --- /dev/null +++ b/ng-dialog/ng-dialog-tests.ts @@ -0,0 +1,52 @@ +/// +/// + +var app = angular.module('testModule', ['ngDialog']); + +class DialogTestController { + + constructor(ngDialog: angular.dialog.IDialogService) { + + ngDialog.close("login-popup", "bye"); + ngDialog.closeAll("bye"); + + var defaults = ngDialog.getDefaults(); + + var dialogs = ngDialog.getOpenDialogs(); + + ngDialog.isOpen("bye"); + + var loginDialog = ngDialog.open({ + template: "login.html", + className: "default flat-ui", + closeByEscape: false, + name: "login-popup" + }); + + if (loginDialog.id === "login-popup") { + loginDialog.close("closing"); + } + + var deleteConfirm = ngDialog.openConfirm({ + template: "confirm.html" + }); + } +} + +class LoginDialogController { + + constructor($scope: angular.dialog.IDialogScope) { + + $scope.closeThisDialog("bye"); + } +} + +app.controller('TestController', DialogTestController); + +app.config((ngDialogProvider: angular.dialog.IDialogProvider) => { + + ngDialogProvider.setDefaults({ + className: "flat-ui" + }) + +}); \ No newline at end of file diff --git a/ng-dialog/ng-dialog.d.ts b/ng-dialog/ng-dialog.d.ts new file mode 100644 index 000000000..a167aee47 --- /dev/null +++ b/ng-dialog/ng-dialog.d.ts @@ -0,0 +1,105 @@ +// Type definitions for ngDialog +// Project: https://github.com/likeastore/ngDialog +// Definitions by: Stephen Lautier +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module angular.dialog { + + interface IDialogService { + getDefaults(): IDialogOptions; + open(options: IDialogOpenOptions): IDialogOpenResult; + openConfirm(options: IDialogOpenOptions): IPromise; + + /** + * Determine whether the specified dialog is open or not. + * @param id Dialog id to check for. + * @returns {boolean} Indicating whether it exists or not. + */ + isOpen(id: string): boolean; + close(id: string, value: any); + closeAll(value: any); + getOpenDialogs(); + } + + interface IDialogOpenResult { + id: string; + close: Function; + closePromise: IPromise; + } + + interface IDialogProvider extends angular.IServiceProvider { + /** + * Default options for the dialogs. + * @param defaultOptions + * @returns {} + */ + setDefaults(defaultOptions: IDialogOptions): void; + } + + /** + * Dialog Scope which extends the $scope. + */ + interface IDialogScope extends angular.IScope { + /** + * This allows you to close dialog straight from handler in a popup element. + * @param value Any value passed to this function will be attached to the object which resolves on the close promise for this dialog. + * For dialogs opened with the openConfirm() method the value is used as the reject reason. + */ + closeThisDialog(value: any): void; + } + + interface IDialogOptions { + /** + * This option allows you to control the dialog's look, you can use built-in themes or create your own styled modals. + * It will be appended with the "ngdialog" class e.g. className is "default-theme flat-ui" it will be class="ngdialog default-theme flat-ui". + */ + className?: string; + /** + * If false it allows to hide overlay div behind the modals, default true. + */ + overlay?: boolean; + + /** + * If false it allows to hide close button on modals, default true. + */ + showClose?: boolean; + + /** + * It allows to close modals by clicking Esc button, default true. + * This will close all open modals if there several of them open at the same time. + */ + closeByEscape?: boolean; + + /** + * It allows to close modals by clicking on overlay background, default true. If @see Hammer.js is loaded, it will listen for tap instead of click. + */ + closeByDocument?: boolean; + + /** + * If true allows to use plain string as template, default false. + */ + plain?: boolean; + + /** + * Give a name for a dialog instance. It is useful for identifying specific dialog if there are multiple dialog boxes opened. + */ + name?: string | number; + + preCloseCallback?: string|Function; + } + + /** + * Options which are provided to open a dialog. + */ + interface IDialogOpenOptions extends IDialogOptions { + template: string; + controller?: string|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; + } +} \ No newline at end of file From 705f6ab7c494db614134a58f53028f8bb157f85e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Sep 2015 18:00:53 +0200 Subject: [PATCH 3/4] reverted ng-animate stuff --- angularjs/angular-animate.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index 35fe10ca9..1ecc3d0d7 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -30,11 +30,11 @@ declare module angular.animate { /** * Globally enables / disables animations. * - * @param element If provided then the element will be used to represent the enable/disable operation. * @param value If provided then set the animation on or off. + * @param element If provided then the element will be used to represent the enable/disable operation. * @returns current animation state */ - enabled(element?: JQuery, value?: boolean): boolean; + enabled(value?: boolean, element?: JQuery): boolean; /** * Performs an inline animation on the element. From 3e2eb03db273fa6c3f8df7cfd025a6aa8874639a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Sep 2015 18:14:58 +0200 Subject: [PATCH 4/4] several improvements in typings --- ng-dialog/ng-dialog.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ng-dialog/ng-dialog.d.ts b/ng-dialog/ng-dialog.d.ts index a167aee47..3f045a8e1 100644 --- a/ng-dialog/ng-dialog.d.ts +++ b/ng-dialog/ng-dialog.d.ts @@ -18,14 +18,14 @@ declare module angular.dialog { * @returns {boolean} Indicating whether it exists or not. */ isOpen(id: string): boolean; - close(id: string, value: any); - closeAll(value: any); - getOpenDialogs(); + close(id: string, value?: any): void; + closeAll(value?: any): void; + getOpenDialogs(): string[]; } interface IDialogOpenResult { id: string; - close: Function; + close: (value?: string) => void; closePromise: IPromise; } @@ -47,7 +47,7 @@ declare module angular.dialog { * @param value Any value passed to this function will be attached to the object which resolves on the close promise for this dialog. * For dialogs opened with the openConfirm() method the value is used as the reject reason. */ - closeThisDialog(value: any): void; + closeThisDialog(value?: any): void; } interface IDialogOptions {