mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
Add drop typings
This commit is contained in:
28
drop/drop-tests.ts
Normal file
28
drop/drop-tests.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
///<reference path="../tether/tether.d.ts" />
|
||||
///<reference path="drop.d.ts" />
|
||||
|
||||
var yellowBox = document.querySelector(".yellow");
|
||||
var greenBox = document.querySelector(".green");
|
||||
|
||||
var d = new Drop({
|
||||
position: "bottom left",
|
||||
openOn: "click",
|
||||
constrainToWindow: true,
|
||||
constrainToScrollParent: true,
|
||||
classes: "",
|
||||
tetherOptions: {}
|
||||
});
|
||||
|
||||
d.open();
|
||||
d.close();
|
||||
d.remove();
|
||||
d.toggle();
|
||||
d.position();
|
||||
d.destroy();
|
||||
|
||||
d.on("open", () => null);
|
||||
d.on("close", () => null);
|
||||
d.once("close", () => null);
|
||||
d.off("close", () => null);
|
||||
d.off("open");
|
||||
|
||||
48
drop/drop.d.ts
vendored
Normal file
48
drop/drop.d.ts
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Type definitions for Drop v0.5
|
||||
// Project: http://github.hubspot.com/drop/
|
||||
// Definitions by: Adi Dahiya <https://github.com/adidahiya>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path="../tether/tether.d.ts" />
|
||||
|
||||
declare module drop {
|
||||
|
||||
interface DropStatic {
|
||||
new(options: IDropOptions): Drop;
|
||||
}
|
||||
|
||||
interface IDropOptions {
|
||||
target?: Element;
|
||||
content?: Element | string | (() => string);
|
||||
position?: string;
|
||||
openOn?: string;
|
||||
constrainToWindow?: boolean;
|
||||
constrainToScrollParent?: boolean;
|
||||
remove?: boolean;
|
||||
tetherOptions?: tether.ITetherOptions;
|
||||
}
|
||||
|
||||
interface Drop {
|
||||
content: HTMLElement;
|
||||
open(): void;
|
||||
close(): void;
|
||||
remove(): void;
|
||||
toggle(): void;
|
||||
position(): void;
|
||||
destroy(): void;
|
||||
/*
|
||||
* Drop instances fire "open" and "close" events.
|
||||
*/
|
||||
on(event: string, handler: Function, context?: any): void;
|
||||
once(event: string, handler: Function, context?: any): void;
|
||||
off(event: string, handler?: Function): void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module "drop" {
|
||||
export = drop;
|
||||
}
|
||||
|
||||
declare var Drop: drop.DropStatic;
|
||||
|
||||
Reference in New Issue
Block a user