From 4265df51e9f9ff0ff57524105b712d1081e56598 Mon Sep 17 00:00:00 2001 From: Sergei Dorogin Date: Thu, 22 Jun 2017 13:36:30 +0300 Subject: [PATCH] jquery.notify: new typings for https://github.com/ehynds/jquery-notify --- types/jquery.notify/index.d.ts | 31 ++++++++++++++++++++++ types/jquery.notify/jquery.notify-tests.ts | 21 +++++++++++++++ types/jquery.notify/tsconfig.json | 23 ++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 types/jquery.notify/index.d.ts create mode 100644 types/jquery.notify/jquery.notify-tests.ts create mode 100644 types/jquery.notify/tsconfig.json diff --git a/types/jquery.notify/index.d.ts b/types/jquery.notify/index.d.ts new file mode 100644 index 0000000000..8846a66eac --- /dev/null +++ b/types/jquery.notify/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for jQuery Notify UI Widget 1.5 by Eric Hynds +// Project: https://github.com/ehynds/jquery-notify +// Definitions by: Sergei Dorogin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +interface JQueryNotifyOptions { + close?: () => void; + open?: () => void; + custom?: boolean; + disabled?: boolean; + expires?: number; + queue?: boolean; + speed?: number; + stack?: "below" | "above"; +} +interface JQuery { + notify (options?: JQueryNotifyOptions): JQueryNotifyWidget; + notify (method: string, template: number, params?: Object, opts?: JQueryNotifyOptions): JQueryNotifyInstance; + notify (method: string, params?: Object, opts?: JQueryNotifyOptions): JQueryNotifyInstance; +} +interface JQueryNotifyInstance extends JQuery { + element: JQuery; + isOpen: boolean; + options: JQueryNotifyOptions; + close (): void; + open (): void; +} +interface JQueryNotifyWidget extends JQuery { +} diff --git a/types/jquery.notify/jquery.notify-tests.ts b/types/jquery.notify/jquery.notify-tests.ts new file mode 100644 index 0000000000..1af31996a1 --- /dev/null +++ b/types/jquery.notify/jquery.notify-tests.ts @@ -0,0 +1,21 @@ +let $container: JQueryNotifyWidget = $("").appendTo(document.body).notify(); + +let notification: JQueryNotifyInstance = $container.notify( + "create", + {}, // empty parameters + { + close: () => { + console.log("closed"); + }, + open: () => { + console.log("opened"); + }, + expires: 1000, + speed: 100 + } +); +notification.element.html("text"); + +notification.element.click(() => { + notification.close(); +}); diff --git a/types/jquery.notify/tsconfig.json b/types/jquery.notify/tsconfig.json new file mode 100644 index 0000000000..affc04b4ab --- /dev/null +++ b/types/jquery.notify/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": false, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery.notify-tests.ts" + ] +} \ No newline at end of file