This commit is contained in:
Sergei Dorogin
2017-06-22 13:36:30 +03:00
parent 755b23622a
commit 4265df51e9
3 changed files with 75 additions and 0 deletions

31
types/jquery.notify/index.d.ts vendored Normal file
View File

@@ -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 <https://github.com/evil-shrike>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery"/>
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 {
}

View File

@@ -0,0 +1,21 @@
let $container: JQueryNotifyWidget = $("<div style='display:none' class='noprint'><div></div></div>").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("<strong>text</strong>");
notification.element.click(() => {
notification.close();
});

View File

@@ -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"
]
}