From 68ae7bb60d3c1ef6dc1c458ffa0bcfda8d50240c Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Wed, 4 Mar 2015 20:56:23 -0500 Subject: [PATCH] Add tether typings --- tether/tether-tests.ts | 53 ++++++++++++++++++++++++++++++++++++++++++ tether/tether.d.ts | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 tether/tether-tests.ts create mode 100644 tether/tether.d.ts 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; +