diff --git a/drop/drop-tests.ts b/drop/drop-tests.ts new file mode 100644 index 0000000000..b5ae47456c --- /dev/null +++ b/drop/drop-tests.ts @@ -0,0 +1,28 @@ +/// +/// + +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"); + diff --git a/drop/drop.d.ts b/drop/drop.d.ts new file mode 100644 index 0000000000..18568afdd6 --- /dev/null +++ b/drop/drop.d.ts @@ -0,0 +1,48 @@ +// Type definitions for Drop v0.5 +// Project: http://github.hubspot.com/drop/ +// Definitions by: Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +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; + diff --git a/tether/tether-tests.ts b/tether/tether-tests.ts new file mode 100644 index 0000000000..4d3295b509 --- /dev/null +++ b/tether/tether-tests.ts @@ -0,0 +1,53 @@ +/// +/// + +var yellowBox = document.querySelector(".yellow"); +var greenBox = document.querySelector(".green"); + +new Tether({ + attachment: "bottom middle", + targetAttachment: "top middle", + targetModifier: "visible", + offset: "-15px 0", + targetOffset: "0 0" +}); + +new Tether({ + element: yellowBox, + target: greenBox, + attachment: "top left", + optimizations: { + gpu: false + } +}); + +new Tether({ + element: yellowBox, + target: greenBox, + attachment: "top left", + targetAttachment: "bottom left", + constraints: [ + { + to: "scrollParent", + pin: true + }, + { + to: "window", + attachment: "together" + } + ] +}); + +new Tether({ + element: yellowBox, + target: greenBox, + attachment: "middle left", + targetAttachment: "middle left", + constraints: [ + { + to: "scrollParent", + pin: ["top"] + } + ] +}); + diff --git a/tether/tether.d.ts b/tether/tether.d.ts new file mode 100644 index 0000000000..be1200f28e --- /dev/null +++ b/tether/tether.d.ts @@ -0,0 +1,50 @@ +// Type definitions for Tether v0.6 +// Project: http://github.hubspot.com/tether/ +// Definitions by: Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module tether { + + interface TetherStatic { + new(options: ITetherOptions): Tether; + } + + interface ITetherOptions { + attachment?: string; + classes?: {[className: string]: boolean}; + classPrefix?: string; + constraints?: ITetherConstraint[]; + element?: Element | string | any /* JQuery */; + enabled?: boolean; + offset?: string; + optimizations?: any; + target?: Element | string | any /* JQuery */; + targetAttachment?: string; + targetOffset?: string; + targetModifier?: string; + } + + interface ITetherConstraint { + attachment?: string; + outOfBoundsClass?: string; + pin?: boolean | string[]; + pinnedClass?: string; + to?: string | Element | number[]; + } + + interface Tether { + setOptions(options: ITetherOptions): void; + disable(): void; + enable(): void; + destroy(): void; + position(): void; + } + +} + +declare module "tether" { + export = tether; +} + +declare var Tether: tether.TetherStatic; +