Skip to content

Commit 0eaa2e3

Browse files
committedDec 11, 2015
[ngNotify] create Type Definition for Angular JS ngNotify library
ngNotify is a simple, lightweight and elegant notification service for AngularJS applications. This commit/pull request contains a type definition for the latest version of this library
1 parent 5a8fc5e commit 0eaa2e3

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed
 

‎ng-notify/ng-notify-tests.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path='../angularjs/angular.d.ts'/>
2+
/// <reference path="ng-notify.d.ts" />
3+
4+
class NgNotifyTestController {
5+
6+
static $inject = ['$scope', 'ngNotify'];
7+
8+
constructor($scope:ng.IScope, ngNotify:ngNotify.INotifyService) {
9+
ngNotify.set('Your error message goes here!', 'error');
10+
}
11+
};

‎ng-notify/ng-notify.d.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Type definitions for ng-notify 0.7.1
2+
// Project: https://github.com/matowens/ng-notify
3+
// Definitions by: Nick Zamosenchuk <https://github.com/nzamosenchuk>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
/// <reference path='../angularjs/angular.d.ts'/>
6+
7+
declare module ngNotify {
8+
9+
/**
10+
* Contains the options used to configure notification.
11+
*/
12+
interface IUserOptions{
13+
type?: string;
14+
theme?: string;
15+
position?: string;
16+
duration?: number;
17+
sticky?: boolean;
18+
button?: boolean;
19+
html?: boolean;
20+
}
21+
22+
/**
23+
* Simply and lightweight notification service for AngularJS
24+
*/
25+
interface INotifyService {
26+
27+
/**
28+
* Allows to create a whole new set of styles for each notification type.
29+
* @param themeName The name used when setting the theme in the config object.
30+
* @param className The class used to target this theme in the stylesheet.
31+
*/
32+
addTheme(themeName:string, className:string):void;
33+
34+
/**
35+
* Allows to create a new type of notification to use in their app.
36+
* @param typeName The name used to trigger this notification type in the set method.
37+
* @param className The class used to target this type in the stylesheet.
38+
*/
39+
addType(typeName:string, className:string):void;
40+
41+
/**
42+
* Sets default settings for all notifications to take into account when displaying.
43+
* @param userOptions Notification configuration object
44+
*/
45+
config(userOptions: IUserOptions):void;
46+
47+
/**
48+
* Manually dismisses any sticky notifications that may still be set.
49+
*/
50+
dismiss():void;
51+
52+
/**
53+
* Displays a notification message.
54+
* @param message A message text to display.
55+
*/
56+
set(message: string):void;
57+
58+
/**
59+
* Displays a notification message and sets the type for this one notification.
60+
* @param message A message text to display.
61+
* @param type The type of the notification.
62+
*/
63+
set(message: string, type: string):void;
64+
65+
/**
66+
* displays a notification message and sets the formatting/behavioral options for this one notification.
67+
* @param message A message text to display.
68+
* @param userOptions Notification configuration object.
69+
*/
70+
set(message: string, userOptions: IUserOptions):void;
71+
}
72+
}

0 commit comments

Comments
 (0)
Please sign in to comment.