From 7dd2af62affa78d6dafa26aee9a529f23334540d Mon Sep 17 00:00:00 2001 From: Greg Cohan Date: Wed, 25 Mar 2015 16:47:48 -0400 Subject: [PATCH] add vex typings --- vex-js/vex-js.d.ts | 45 +++++++++++++++++++++++++++++++++++++++++++++ vex-js/vex-tests.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 vex-js/vex-js.d.ts create mode 100644 vex-js/vex-tests.ts diff --git a/vex-js/vex-js.d.ts b/vex-js/vex-js.d.ts new file mode 100644 index 0000000000..118c618672 --- /dev/null +++ b/vex-js/vex-js.d.ts @@ -0,0 +1,45 @@ +// Type definitions for Vex v2.3.2 +// Project: https://github.com/HubSpot/vex +// Definitions by: Greg Cohan +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module vex { + + interface ICSSAttributes { + [property: string]: string | number; + } + + interface IVexOptions { + afterClose?: (() => void); + afterOpen?: ((vexContent: JQuery) => void); + content?: string; + showCloseButton?: boolean; + escapeButtonCloses?: boolean; + overlayClosesOnClick?: boolean; + appendLocation?: HTMLElement | JQuery | string; + className?: string; + css?: ICSSAttributes; + overlayClassName?: string; + overlayCSS?: ICSSAttributes; + contentClassName?: string; + contentCSS?: ICSSAttributes; + closeClassName?: string; + closeCSS?: ICSSAttributes; + } + + interface Vex { + open(options: IVexOptions): JQuery; + close(id?: number): boolean; + closeAll(): boolean; + closeByID(id: number): boolean; + } + +} + +declare module "vex" { + export = vex; +} + +declare var vex: vex.Vex; diff --git a/vex-js/vex-tests.ts b/vex-js/vex-tests.ts new file mode 100644 index 0000000000..ea1778d610 --- /dev/null +++ b/vex-js/vex-tests.ts @@ -0,0 +1,26 @@ +/// +/// + +var vexContent = vex.open({ + afterClose: (() => null), + afterOpen: ((vexContent: JQuery) => null), + content: "

Modal

", + showCloseButton: false, + escapeButtonCloses: true, + overlayClosesOnClick: false, + appendLocation: "body", + className: "vex-dialog", + css: {background: "blue"}, + overlayClassName: "vex-overlay", + overlayCSS: {border: 0}, + contentClassName: "vex-content", + contentCSS: {margin: "0 auto"}, + closeClassName: "vex-close", + closeCSS: {margin: 0} +}); + +var id = vexContent.data().vex.id; + +vex.close(id); +vex.closeByID(id); +vex.closeAll();