From fa7b9cfa56c6c077dc402b1f1f407a192bf74b34 Mon Sep 17 00:00:00 2001 From: Bahman Nikkhahan Date: Fri, 26 Aug 2016 12:50:47 +1000 Subject: [PATCH 1/4] Typing for notify.js --- notify.js/notify.js.d.ts | 124 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 notify.js/notify.js.d.ts diff --git a/notify.js/notify.js.d.ts b/notify.js/notify.js.d.ts new file mode 100644 index 0000000000..dc50230b5b --- /dev/null +++ b/notify.js/notify.js.d.ts @@ -0,0 +1,124 @@ +//Created by Bahman Nikkhahan https://github.com/bahman616 +interface NotificationOptions { + // whether to hide the notification on click + clickToHide: boolean; + // whether to auto-hide the notification + autoHide: boolean; + // if autoHide, hide after milliseconds + autoHideDelay: number; + // show the arrow pointing at the element + arrowShow: boolean; + // arrow size in pixels + arrowSize: number; + // position defines the notification position though uses the defaults below + position: string; + // default positions + elementPosition: string; + globalPosition: string; + // default style + style: string; + // default class (string or [string]) + className: string; + // show animation + showAnimation: string; + // show animation duration + showDuration: number; + // hide animation + hideAnimation: string; + // hide animation duration + hideDuration: number; + // padding between element and notification + gap: number; +} + +interface JQueryStaticNotify { + /** + * notify user + * @param element a jquery element + * @param notificationdata global notification data + * @param options notification options + */ + (element?: any, notificationdata?: any, options?: NotificationOptions): JQueryStatic; + + /** + * notify user + * @param styleName style name + * @param styleDefinition style definition object + */ + addStyle(styleName: string, styleDefinition: any); + + /** + * notify user + * @param styleName style name + */ + removeStyle(styleName: string); + + /** + * notify user + * @param styleName style name + */ + getStyle(styleName: string); + + /** + * notify user + * @param cssText css text to insert + */ + insertCSS(cssText: string); + + /** + * notify user + * @param options notification iptions + */ + defaults(options: NotificationOptions) +} + +interface JQueryStatic { + notify: JQueryStaticNotify; +} + +interface JQueryNotify { + /** + * notify user + * @param element a jquery element + * @param notificationdata global notification data + * @param options notification options + */ + (element?: any, notificationdata?: any, options?: NotificationOptions): JQuery; + + /** + * notify user + * @param styleName style name + * @param styleDefinition style definition object + */ + addStyle(styleName: string, styleDefinition: any); + + /** + * notify user + * @param styleName style name + */ + removeStyle(styleName: string); + + /** + * notify user + * @param styleName style name + */ + getStyle(styleName: string); + + /** + * notify user + * @param cssText css text to insert + */ + insertCSS(cssText: string); + + /** + * notify user + * @param options notification iptions + */ + defaults(options: NotificationOptions) + +} + +interface JQuery { + notify: JQueryStaticNotify; +} + From ac9b18d504cb3d38f808251bddb9a2e0e9c6f760 Mon Sep 17 00:00:00 2001 From: Bahman Nikkhahan Date: Tue, 30 Aug 2016 10:45:49 +1000 Subject: [PATCH 2/4] Typing for notify.js --- notify.js/notify.js.d.ts | 253 ++++++++++++++++++----------------- notify.js/notify.js.tests.ts | 53 ++++++++ 2 files changed, 183 insertions(+), 123 deletions(-) create mode 100644 notify.js/notify.js.tests.ts diff --git a/notify.js/notify.js.d.ts b/notify.js/notify.js.d.ts index dc50230b5b..0f8745fd33 100644 --- a/notify.js/notify.js.d.ts +++ b/notify.js/notify.js.d.ts @@ -1,124 +1,131 @@ -//Created by Bahman Nikkhahan https://github.com/bahman616 -interface NotificationOptions { - // whether to hide the notification on click - clickToHide: boolean; - // whether to auto-hide the notification - autoHide: boolean; - // if autoHide, hide after milliseconds - autoHideDelay: number; - // show the arrow pointing at the element - arrowShow: boolean; - // arrow size in pixels - arrowSize: number; - // position defines the notification position though uses the defaults below - position: string; - // default positions - elementPosition: string; - globalPosition: string; - // default style - style: string; - // default class (string or [string]) - className: string; - // show animation - showAnimation: string; - // show animation duration - showDuration: number; - // hide animation - hideAnimation: string; - // hide animation duration - hideDuration: number; - // padding between element and notification - gap: number; +// Type definitions for notify.js +// Project: https://github.com/notifyjs/notifyjs +// Definitions by: Bahman Nikkhahan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace NotifyJS { + interface NotificationOptions { + // whether to hide the notification on click + clickToHide: boolean; + // whether to auto-hide the notification + autoHide: boolean; + // if autoHide, hide after milliseconds + autoHideDelay: number; + // show the arrow pointing at the element + arrowShow: boolean; + // arrow size in pixels + arrowSize: number; + // position defines the notification position though uses the defaults below + position: string; + // default positions + elementPosition: string; + globalPosition: string; + // default style + style: string; + // default class (string or [string]) + className: string; + // show animation + showAnimation: string; + // show animation duration + showDuration: number; + // hide animation + hideAnimation: string; + // hide animation duration + hideDuration: number; + // padding between element and notification + gap: number; + } + + interface JQueryStaticNotify { + /** + * notify user + * @param element a jquery element + * @param notificationdata global notification data + * @param options notification options + */ + (element?: any, notificationdata?: any, options?: NotificationOptions): JQueryStatic; + + /** + * notify user + * @param styleName style name + * @param styleDefinition style definition object + */ + addStyle(styleName: string, styleDefinition: any); + + /** + * notify user + * @param styleName style name + */ + removeStyle(styleName: string); + + /** + * notify user + * @param styleName style name + */ + getStyle(styleName: string); + + /** + * notify user + * @param cssText css text to insert + */ + insertCSS(cssText: string); + + /** + * notify user + * @param options notification iptions + */ + defaults(options: NotificationOptions) + } + + interface JQueryStatic { + notify: JQueryStaticNotify; + } + + interface JQueryNotify { + /** + * notify user + * @param element a jquery element + * @param notificationdata global notification data + * @param options notification options + */ + (element?: any, notificationdata?: any, options?: NotificationOptions): JQuery; + + /** + * notify user + * @param styleName style name + * @param styleDefinition style definition object + */ + addStyle(styleName: string, styleDefinition: any); + + /** + * notify user + * @param styleName style name + */ + removeStyle(styleName: string); + + /** + * notify user + * @param styleName style name + */ + getStyle(styleName: string); + + /** + * notify user + * @param cssText css text to insert + */ + insertCSS(cssText: string); + + /** + * notify user + * @param options notification iptions + */ + defaults(options: NotificationOptions) + + } + + interface JQuery { + notify: JQueryStaticNotify; + } } - -interface JQueryStaticNotify { - /** - * notify user - * @param element a jquery element - * @param notificationdata global notification data - * @param options notification options - */ - (element?: any, notificationdata?: any, options?: NotificationOptions): JQueryStatic; - - /** - * notify user - * @param styleName style name - * @param styleDefinition style definition object - */ - addStyle(styleName: string, styleDefinition: any); - - /** - * notify user - * @param styleName style name - */ - removeStyle(styleName: string); - - /** - * notify user - * @param styleName style name - */ - getStyle(styleName: string); - - /** - * notify user - * @param cssText css text to insert - */ - insertCSS(cssText: string); - - /** - * notify user - * @param options notification iptions - */ - defaults(options: NotificationOptions) -} - -interface JQueryStatic { - notify: JQueryStaticNotify; -} - -interface JQueryNotify { - /** - * notify user - * @param element a jquery element - * @param notificationdata global notification data - * @param options notification options - */ - (element?: any, notificationdata?: any, options?: NotificationOptions): JQuery; - - /** - * notify user - * @param styleName style name - * @param styleDefinition style definition object - */ - addStyle(styleName: string, styleDefinition: any); - - /** - * notify user - * @param styleName style name - */ - removeStyle(styleName: string); - - /** - * notify user - * @param styleName style name - */ - getStyle(styleName: string); - - /** - * notify user - * @param cssText css text to insert - */ - insertCSS(cssText: string); - - /** - * notify user - * @param options notification iptions - */ - defaults(options: NotificationOptions) - -} - -interface JQuery { - notify: JQueryStaticNotify; -} - diff --git a/notify.js/notify.js.tests.ts b/notify.js/notify.js.tests.ts new file mode 100644 index 0000000000..f533b47288 --- /dev/null +++ b/notify.js/notify.js.tests.ts @@ -0,0 +1,53 @@ +/// +/// + +// setting defaults for notification plugin +$.notify.defaults({ + clickToHide: true, + autoHide: false, + autoHideDelay: 5000, + arrowShow: true, + arrowSize: 5, + position: 'top center', + elementPosition: 'bottom left', + globalPosition: 'top center', + style: 'bootstrap', + className: 'error', + showAnimation: 'slideDown', + showDuration: 400, + hideAnimation: 'slideUp', + hideDuration: 200, + gap: 2 +}); + +$(".elem-demo").notify("Hello Box"); +$.notify("Access granted", "success"); +$.notify("Do not press this button", "info"); +$.notify('hello !!', { + style: 'happyblue' +}); +$.notify('hello !!', { + style: 'happyblue' +}); +//add a new style 'foo' +$.notify.addStyle('foo', { + html: + "
" + + "
" + + "
" + + "
" + + "" + + "" + + "
" + + "
" + + "
" +}); + +$.notify({ + title: 'Would you like some Foo ?', + button: 'Confirm' +}, { + style: 'foo', + autoHide: false, + clickToHide: false + }); \ No newline at end of file From cd11328ffca13d561d7a743d62ab8ae1153a4c9f Mon Sep 17 00:00:00 2001 From: Bahman Nikkhahan Date: Tue, 30 Aug 2016 10:51:34 +1000 Subject: [PATCH 3/4] Typing for notify.js - Update some comments --- notify.js/notify.js.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/notify.js/notify.js.d.ts b/notify.js/notify.js.d.ts index 0f8745fd33..ed845777d2 100644 --- a/notify.js/notify.js.d.ts +++ b/notify.js/notify.js.d.ts @@ -48,32 +48,32 @@ declare namespace NotifyJS { (element?: any, notificationdata?: any, options?: NotificationOptions): JQueryStatic; /** - * notify user + * Add style * @param styleName style name * @param styleDefinition style definition object */ addStyle(styleName: string, styleDefinition: any); /** - * notify user + * Remove style * @param styleName style name */ removeStyle(styleName: string); /** - * notify user + * Get style * @param styleName style name */ getStyle(styleName: string); /** - * notify user + * Insert css * @param cssText css text to insert */ insertCSS(cssText: string); /** - * notify user + * Set defaults for notifications * @param options notification iptions */ defaults(options: NotificationOptions) @@ -93,32 +93,32 @@ declare namespace NotifyJS { (element?: any, notificationdata?: any, options?: NotificationOptions): JQuery; /** - * notify user + * Add style * @param styleName style name * @param styleDefinition style definition object */ addStyle(styleName: string, styleDefinition: any); /** - * notify user + * Remove style * @param styleName style name */ removeStyle(styleName: string); /** - * notify user + * Get style * @param styleName style name */ getStyle(styleName: string); /** - * notify user + * Insert css * @param cssText css text to insert */ insertCSS(cssText: string); /** - * notify user + * Set defaults for notifications * @param options notification iptions */ defaults(options: NotificationOptions) From 4f508f62ffa2d27648ba8f70a1498ce319262363 Mon Sep 17 00:00:00 2001 From: Bahman Nikkhahan Date: Wed, 31 Aug 2016 13:39:45 +1000 Subject: [PATCH 4/4] Typing for notify.js fixed some bugs --- notify.js/notify.js.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/notify.js/notify.js.d.ts b/notify.js/notify.js.d.ts index ed845777d2..ae31ea6317 100644 --- a/notify.js/notify.js.d.ts +++ b/notify.js/notify.js.d.ts @@ -52,31 +52,31 @@ declare namespace NotifyJS { * @param styleName style name * @param styleDefinition style definition object */ - addStyle(styleName: string, styleDefinition: any); + addStyle(styleName: string, styleDefinition: any): any; /** * Remove style * @param styleName style name */ - removeStyle(styleName: string); + removeStyle(styleName: string): any; /** * Get style * @param styleName style name */ - getStyle(styleName: string); + getStyle(styleName: string): any; /** * Insert css * @param cssText css text to insert */ - insertCSS(cssText: string); + insertCSS(cssText: string): any; /** * Set defaults for notifications * @param options notification iptions */ - defaults(options: NotificationOptions) + defaults(options: NotificationOptions): any; } interface JQueryStatic { @@ -97,31 +97,31 @@ declare namespace NotifyJS { * @param styleName style name * @param styleDefinition style definition object */ - addStyle(styleName: string, styleDefinition: any); + addStyle(styleName: string, styleDefinition: any): any; /** * Remove style * @param styleName style name */ - removeStyle(styleName: string); + removeStyle(styleName: string): any; /** * Get style * @param styleName style name */ - getStyle(styleName: string); + getStyle(styleName: string): any; /** * Insert css * @param cssText css text to insert */ - insertCSS(cssText: string); + insertCSS(cssText: string): any; /** * Set defaults for notifications * @param options notification iptions */ - defaults(options: NotificationOptions) + defaults(options: NotificationOptions): any; }