From 6b892eacd86cff794048433214cd7d3babfa500e Mon Sep 17 00:00:00 2001 From: Xiaohan Zhang Date: Tue, 21 Oct 2014 18:00:50 -0700 Subject: [PATCH] Add typings for notify http://notifyjs.com/ - Notify.js is a jQuery plugin to provide simple yet fully customisable notifications. Not to be confused with "notifyjs" at https://github.com/alexgibson/notify.js --- notify/notify-tests.ts | 60 +++++++++++++++ notify/notify.d.ts | 171 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 notify/notify-tests.ts create mode 100644 notify/notify.d.ts diff --git a/notify/notify-tests.ts b/notify/notify-tests.ts new file mode 100644 index 0000000000..3395345bfe --- /dev/null +++ b/notify/notify-tests.ts @@ -0,0 +1,60 @@ +/// + +$.notify.addStyle("bootstrap", { + html: "
\n\n
", + classes: { + base: { + "font-weight": "bold", + "padding": "8px 15px 8px 14px", + }, + error: { + "color": "#B94A48", + }, + info: { + "color": "#3A87AD", + "background-color": "#D9EDF7", + "border-color": "#BCE8F1", + } + } +}); + +$.notify.addStyle('foo', { + html: + "
" + + "
" + + "
" + + "
" + + "" + + "" + + "
" + + "
" + + "
" +}); + +$.notify.defaults({ + style: "bootstrap", + className: "info" +}); + +$.notify("Hello world!"); + +$.notify("Error text", "error"); + +$(".my-element").notify("Hello Box", { + arrowSize: 25, + autoHide: false, + elementPosition: "top center", + showAnimation: "slideDown", + showDuration: 100, + hideAnimation: "slideUp", + hideDuration: 5000, + gap: 20 +}); + +$.notify({ + title: 'Would you like some Foo ?', + button: 'Confirm' + }, { + style: 'foo', + clickToHide: false +}); diff --git a/notify/notify.d.ts b/notify/notify.d.ts new file mode 100644 index 0000000000..630b06f3c7 --- /dev/null +++ b/notify/notify.d.ts @@ -0,0 +1,171 @@ +// Type definitions for Notify.js +// Project: https://github.com/jpillora/notifyjs +// Definitions by: Xiaohan Zhang +// Definitions: https://github.com/borisyankov/DefinitelyTyped/ + +/// + +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-