add vex typings

This commit is contained in:
Greg Cohan 2015-03-25 16:47:48 -04:00
parent 0c2ee8583c
commit 7dd2af62af
2 changed files with 71 additions and 0 deletions

45
vex-js/vex-js.d.ts vendored Normal file
View File

@ -0,0 +1,45 @@
// Type definitions for Vex v2.3.2
// Project: https://github.com/HubSpot/vex
// Definitions by: Greg Cohan <https://github.com/gdcohan>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../jquery/jquery.d.ts" />
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;

26
vex-js/vex-tests.ts Normal file
View File

@ -0,0 +1,26 @@
///<reference path="../jquery/jquery.d.ts" />
///<reference path="vex-js.d.ts" />
var vexContent = vex.open({
afterClose: (() => null),
afterOpen: ((vexContent: JQuery) => null),
content: "<div><p>Modal</p></div>",
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();