forked from jbaroudi/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notify.d.ts
171 lines (142 loc) · 5.27 KB
/
notify.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// Type definitions for Notify.js
// Project: https://github.com/jpillora/notifyjs
// Definitions by: Xiaohan Zhang <https://github.com/hellochar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped/
/// <reference path="../jquery/jquery.d.ts" />
declare module Notify {
interface Options {
/**
* Whether to hide the notification on click. Default is true.
*/
clickToHide?: boolean;
/**
* Whether to auto-hide the notification (after autoHideDelay milliseconds). Default is true.
*/
autoHide?: boolean;
/**
* If autoHide, hide after milliseconds. Default is 5000.
*/
autoHideDelay?: number;
/**
* Show the arrow pointing at the element. Default is true.
*/
arrowShow?: boolean;
/**
* Arrow size in pixels. Default is 5.
*/
arrowSize?: number;
/**
* Position of the notification when created relative to an element. Default is 'bottom left'.
*/
elementPosition?: string;
/**
* Position of the notification when created globally. Default is 'top right'.
*/
globalPosition?: string;
/**
* Style of the notification. Default is 'bootstrap'.
*
* For more information on styles, refer to Notify.StyleDefinition.
*/
style?: string;
/**
* Class of the notification (string or [string]). Default is 'error'.
*
* Notify looks through the classes defined in the given style and will apply the CSS
* attributes of that style. Additionally, a CSS class of "notifyjs-<style name>-<class name>"
* will be applied.
*/
className?: string;
/**
* Animation when notification is shown. Default is 'slideDown'.
*/
showAnimation?: string;
/**
* Duration show animation, in milliseconds. Default is 400.
*/
showDuration?: number;
/**
* Animation when notification is hidden. Default is 'slideUp'.
*/
hideAnimation?: string;
/**
* Duration for hide animation, in milliseconds. Default is 200.
*/
hideDuration?: number;
/**
* Padding in px between element and notification. Deafult is 2.
*/
gap?: number;
}
/**
* Notifications created with a specified class will have CSS properties applied to that
* notification. This interface defines what properties and their values to apply for a given class.
* Keys should be CSS property names, and values their values.
*/
interface ClassCSS {
[propertyName: string]: string;
}
interface StyleDefinition {
/**
* Defines the HTML wrapping the notification.
*
* If you only have HTML element that you need to modify per notification then you should give
* this element an attribute of data-notify-text or data-notify-html. Use data-notify-html if
* you wish to display arbitrary HTML inside the notification, otherwise, use data-notify-text
* as it is more secure.
* For more complex notifications, you may give a value to the data-notify-text/data-notify-html
* attribute on an element, such as <div data-notify-html="propertyName"></div>. You may then
* pass a javasript Object with a "propertyName" key to the notify method, whose value will be
* the text/html that the element is populated with.
*/
html: string;
/**
* Defines the available classes in this style. The "base" property will be applied to every
* notification with this style.
*/
classes?: {
[className: string]: ClassCSS;
base?: ClassCSS;
};
/**
* All notifications will have this CSS applied to it.
*/
css?: string;
}
interface JQueryStatic {
/**
* Create a global notification.
*/
(text: string, className?: string): void;
(text: string, options?: Options): void;
(data: any, className?: string): void;
(data: any, options?: Options): void;
/**
* Create a notification positioned relative to the given element.
*/
(element: JQuery, text: string, className?: string): void;
(element: JQuery, text: string, options?: Options): void;
(element: JQuery, data: any, className?: string): void;
(element: JQuery, data: any, options?: Options): void;
/**
* Define a style for Notify to use.
*/
addStyle(styleName: string, styleDefinition: StyleDefinition): void;
/**
* Specify the default options for all notifications.
*/
defaults(options: Options): void;
}
}
interface JQueryStatic {
notify: Notify.JQueryStatic;
}
interface JQuery {
/**
* Create a notification positioned relative to the currently selected element.
*/
notify(text: string, className?: string): void;
notify(text: string, options?: Notify.Options): void;
notify(data: any, className?: string): void;
notify(data: any, options?: Notify.Options): void;
}