From 4889743ea8f8f06266de73e8da2430f02aed82b2 Mon Sep 17 00:00:00 2001 From: Tomasz Ducin Date: Fri, 31 Jul 2015 09:27:34 +0200 Subject: [PATCH 1/5] new types for angular-notifications (angular plugin) --- .../angular-notifications-tests.ts | 12 +++ .../angular-notifications.d.ts | 82 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 angular-notifications/angular-notifications-tests.ts create mode 100644 angular-notifications/angular-notifications.d.ts diff --git a/angular-notifications/angular-notifications-tests.ts b/angular-notifications/angular-notifications-tests.ts new file mode 100644 index 000000000..bbfc3e90e --- /dev/null +++ b/angular-notifications/angular-notifications-tests.ts @@ -0,0 +1,12 @@ +/// + +var myapp = angular.module("myapp", ["notifications"]); + +myapp.controller("MyController", ["$scope", "notifications", + function ($scope:ng.IScope, $notifications:angular.notifications.INotificationFactory) { // <-- Inject notifications + + var userData = {'some': 'data', 'optional': true}; + $notification.info("Something happened", "here is the content of what happened", userData); + + } +]); \ No newline at end of file diff --git a/angular-notifications/angular-notifications.d.ts b/angular-notifications/angular-notifications.d.ts new file mode 100644 index 000000000..e4f3d852c --- /dev/null +++ b/angular-notifications/angular-notifications.d.ts @@ -0,0 +1,82 @@ +// Type definitions for angular-notifications +// Project: https://github.com/DerekRies/angular-notifications +// Definitions by: Tomasz Ducin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module angular.notifications { + + interface IAnimation { + duration: number; + enabled: boolean; + } + + interface ISettings { + info: IAnimation; + warning: IAnimation; + error: IAnimation; + success: IAnimation; + progress: IAnimation; + custom: IAnimation; + details: boolean; + localStorage: boolean; + html5Mode: boolean; + html5DefaultIcon: string; + } + + interface INotification { + type: string; + image: string; + icon: string; + title: string; + content: string; + timestamp: string; + userData: string; + } + + interface INotificationFactory extends angular.IModule { + + /* ========== SETTINGS RELATED METHODS =============*/ + + disableHtml5Mode(): void; + disableType(notificationType: string): void; + enableHtml5Mode(): void; + enableType(notificationType: string): void; + getSettings(): ISettings; + toggleType(notificationType: string): void; + toggleHtml5Mode(): void; + requestHtml5ModePermissions(): boolean; + + /* ============ QUERYING RELATED METHODS ============*/ + + getAll(): Array; + getQueue(): Array; + + /* ============== NOTIFICATION METHODS ==============*/ + + info(title): INotification; + info(title, content): INotification; + info(title, content, userData): INotification; + error(title): INotification; + error(title, content): INotification; + error(title, content, userData): INotification; + success(title): INotification; + success(title, content): INotification; + success(title, content, userData): INotification; + warning(title): INotification; + warning(title, content): INotification; + warning(title, content, userData): INotification; + awesomeNotify(type, icon, title, content, userData): INotification; + notify(image, title, content, userData): INotification; + makeNotification(type: string, image: string, icon: string, title: string, content: string, userData: string): INotification; + + /* ============ PERSISTENCE METHODS ============ */ + + save(): void; + restore(): void; + clear(): void; + } + +} + From efc6bfe2ec4d7d55236001c44d3858b4b91a9edf Mon Sep 17 00:00:00 2001 From: Tomasz Ducin Date: Fri, 31 Jul 2015 09:40:07 +0200 Subject: [PATCH 2/5] typo fix --- angular-notifications/angular-notifications-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-notifications/angular-notifications-tests.ts b/angular-notifications/angular-notifications-tests.ts index bbfc3e90e..f71a2e689 100644 --- a/angular-notifications/angular-notifications-tests.ts +++ b/angular-notifications/angular-notifications-tests.ts @@ -3,10 +3,10 @@ var myapp = angular.module("myapp", ["notifications"]); myapp.controller("MyController", ["$scope", "notifications", - function ($scope:ng.IScope, $notifications:angular.notifications.INotificationFactory) { // <-- Inject notifications + function ($scope:ng.IScope, notifications:angular.notifications.INotificationFactory) { // <-- Inject notifications var userData = {'some': 'data', 'optional': true}; $notification.info("Something happened", "here is the content of what happened", userData); } -]); \ No newline at end of file +]); From 2d6ebeb1a906ac8c7ee960f9c0f1d2857ab40006 Mon Sep 17 00:00:00 2001 From: Tomasz Ducin Date: Fri, 31 Jul 2015 09:43:34 +0200 Subject: [PATCH 3/5] method parameter types --- .../angular-notifications.d.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/angular-notifications/angular-notifications.d.ts b/angular-notifications/angular-notifications.d.ts index e4f3d852c..49883efb3 100644 --- a/angular-notifications/angular-notifications.d.ts +++ b/angular-notifications/angular-notifications.d.ts @@ -55,21 +55,21 @@ declare module angular.notifications { /* ============== NOTIFICATION METHODS ==============*/ - info(title): INotification; - info(title, content): INotification; - info(title, content, userData): INotification; - error(title): INotification; - error(title, content): INotification; - error(title, content, userData): INotification; - success(title): INotification; - success(title, content): INotification; - success(title, content, userData): INotification; - warning(title): INotification; - warning(title, content): INotification; - warning(title, content, userData): INotification; - awesomeNotify(type, icon, title, content, userData): INotification; - notify(image, title, content, userData): INotification; - makeNotification(type: string, image: string, icon: string, title: string, content: string, userData: string): INotification; + info(title: string): INotification; + info(title: string, content: string): INotification; + info(title: string, content: string, userData: any): INotification; + error(title: string): INotification; + error(title: string, content: string): INotification; + error(title: string, content: string, userData: any): INotification; + success(title: string): INotification; + success(title: string, content: string): INotification; + success(title: string, content: string, userData: any): INotification; + warning(title: string): INotification; + warning(title: string, content: string): INotification; + warning(title: string, content: string, userData: any): INotification; + awesomeNotify(type: string, icon: string, title: string, content: string, userData: any): INotification; + notify(image: string, title: string, content: string, userData: any): INotification; + makeNotification(type: string, image: string, icon: string, title: string, content: string, userData: any): INotification; /* ============ PERSISTENCE METHODS ============ */ From a315ac7f88d1dc754a21cf5511818216cbae67a5 Mon Sep 17 00:00:00 2001 From: Tomasz Ducin Date: Fri, 31 Jul 2015 09:47:12 +0200 Subject: [PATCH 4/5] typo fix --- angular-notifications/angular-notifications-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-notifications/angular-notifications-tests.ts b/angular-notifications/angular-notifications-tests.ts index f71a2e689..b6aaf99cf 100644 --- a/angular-notifications/angular-notifications-tests.ts +++ b/angular-notifications/angular-notifications-tests.ts @@ -6,7 +6,7 @@ myapp.controller("MyController", ["$scope", "notifications", function ($scope:ng.IScope, notifications:angular.notifications.INotificationFactory) { // <-- Inject notifications var userData = {'some': 'data', 'optional': true}; - $notification.info("Something happened", "here is the content of what happened", userData); + notification.info("Something happened", "here is the content of what happened", userData); } ]); From 25dd3de39c4f6f508cf775836707df8f3c920859 Mon Sep 17 00:00:00 2001 From: Tomasz Ducin Date: Fri, 31 Jul 2015 09:49:57 +0200 Subject: [PATCH 5/5] typo fix --- angular-notifications/angular-notifications-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-notifications/angular-notifications-tests.ts b/angular-notifications/angular-notifications-tests.ts index b6aaf99cf..1632ff1e7 100644 --- a/angular-notifications/angular-notifications-tests.ts +++ b/angular-notifications/angular-notifications-tests.ts @@ -6,7 +6,7 @@ myapp.controller("MyController", ["$scope", "notifications", function ($scope:ng.IScope, notifications:angular.notifications.INotificationFactory) { // <-- Inject notifications var userData = {'some': 'data', 'optional': true}; - notification.info("Something happened", "here is the content of what happened", userData); + notifications.info("Something happened", "here is the content of what happened", userData); } ]);