From 4889743ea8f8f06266de73e8da2430f02aed82b2 Mon Sep 17 00:00:00 2001 From: Tomasz Ducin Date: Fri, 31 Jul 2015 09:27:34 +0200 Subject: [PATCH] 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 0000000000..bbfc3e90ec --- /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 0000000000..e4f3d852ca --- /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; + } + +} +