From e2ee972a2363f48cdb3dc6403e809d1323d56986 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Fri, 25 Jan 2013 02:51:07 +0200 Subject: [PATCH 001/248] Update readme and metadata for Cheerio --- README.md | 1 + cheerio/cheerio.d.ts | 156 ++++++++++++++++++++++--------------------- 2 files changed, 82 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index f3fa36b019..ffadd0136e 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ List of Definitions * [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) (by [Boris Yankov](https://github.com/borisyankov)) * [Box2DWeb](http://code.google.com/p/box2dweb/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle)) * [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) * [Chrome](http://developer.chrome.com/extensions/) (by [Matthew Kimber](https://github.com/matthewkimber)) * [CodeMirror](http://codemirror.net) (by [Franois de Campredon](https://github.com/fdecampredon)) diff --git a/cheerio/cheerio.d.ts b/cheerio/cheerio.d.ts index d3416a74f8..cbf9e12daf 100644 --- a/cheerio/cheerio.d.ts +++ b/cheerio/cheerio.d.ts @@ -1,75 +1,81 @@ -declare interface Cheerio { - - addClass(classNames: string): Cheerio; - hasClass(className: string): bool; - removeClass(className?: any): Cheerio; - - attr(attributeName: string, value: any): Cheerio; - attr(attributeName: string): string; - removeAttr(attributeName: any): Cheerio; - - find(selector: string): Cheerio; - - parent(): Cheerio; - - next(): Cheerio; - prev(): Cheerio; - - siblings(): Cheerio; - - children(selector?: any): Cheerio; - - each(func: (index: any, elem: any) => Cheerio); - - map(callback: (index: any, domElement: Element) =>any): Cheerio; - - filter(selector: string): Cheerio; - filter(func: (index: any) =>any): Cheerio; - - first(): Cheerio; - last(): Cheerio; - - eq(index: number): Cheerio; - - append(...content: any[]): Cheerio; - prepend(...content: any[]): Cheerio; - after(...content: any[]): Cheerio; - before(...content: any[]): Cheerio; - remove(selector: string): Cheerio; - replaceWith(content: string): Cheerio; - empty(): Cheerio; - - html(htmlString: string): Cheerio; - html(): string; - - text(textString: string): Cheerio; - text(): string; - - toArray(): any[]; - - clone() : Cheerio; - root() : Cheerio; - dom(): any; - - contains(container: Element, contained: Element): bool; - isArray(obj: any): bool; - inArray(value: any, array: any[], fromIndex?: number): number; - merge(first: any[], second: any[]): any[]; - - -} - -declare interface CheerioOptionsInterface { - ignoreWhitespace?: bool; - xmlMode?: bool; - lowerCaseTags?: bool; -} - -declare interface CheerioStatic { - (...selectors: any[]): Cheerio; - (): Cheerio; -} - -declare module "cheerio" { - export function load (html : string, options?: CheerioOptionsInterface) : CheerioStatic; -} +// Type definitions for Cheerio +// Project: https://github.com/MatthewMueller/cheerio +// Definitions by: Bret Little +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare interface Cheerio { + + addClass(classNames: string): Cheerio; + hasClass(className: string): bool; + removeClass(className?: any): Cheerio; + + attr(attributeName: string, value: any): Cheerio; + attr(attributeName: string): string; + removeAttr(attributeName: any): Cheerio; + + find(selector: string): Cheerio; + + parent(): Cheerio; + + next(): Cheerio; + prev(): Cheerio; + + siblings(): Cheerio; + + children(selector?: any): Cheerio; + + each(func: (index: any, elem: any) => Cheerio); + + map(callback: (index: any, domElement: Element) =>any): Cheerio; + + filter(selector: string): Cheerio; + filter(func: (index: any) =>any): Cheerio; + + first(): Cheerio; + last(): Cheerio; + + eq(index: number): Cheerio; + + append(...content: any[]): Cheerio; + prepend(...content: any[]): Cheerio; + after(...content: any[]): Cheerio; + before(...content: any[]): Cheerio; + remove(selector: string): Cheerio; + replaceWith(content: string): Cheerio; + empty(): Cheerio; + + html(htmlString: string): Cheerio; + html(): string; + + text(textString: string): Cheerio; + text(): string; + + toArray(): any[]; + + clone() : Cheerio; + root() : Cheerio; + dom(): any; + + contains(container: Element, contained: Element): bool; + isArray(obj: any): bool; + inArray(value: any, array: any[], fromIndex?: number): number; + merge(first: any[], second: any[]): any[]; + + +} + +declare interface CheerioOptionsInterface { + ignoreWhitespace?: bool; + xmlMode?: bool; + lowerCaseTags?: bool; +} + +declare interface CheerioStatic { + (...selectors: any[]): Cheerio; + (): Cheerio; +} + +declare module "cheerio" { + export function load (html : string, options?: CheerioOptionsInterface) : CheerioStatic; +} From a17c41099923a8ed23ba0683ef2c040b3b3dcbae Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Fri, 25 Jan 2013 02:23:03 -0500 Subject: [PATCH 002/248] Creation of store.js type definition and test files --- storejs/storejs-tests.ts | 1 + storejs/storejs.d.ts | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 storejs/storejs-tests.ts create mode 100644 storejs/storejs.d.ts diff --git a/storejs/storejs-tests.ts b/storejs/storejs-tests.ts new file mode 100644 index 0000000000..9ef1b0f178 --- /dev/null +++ b/storejs/storejs-tests.ts @@ -0,0 +1 @@ +// Tests for storagejs.d.ts \ No newline at end of file diff --git a/storejs/storejs.d.ts b/storejs/storejs.d.ts new file mode 100644 index 0000000000..bb84cd646a --- /dev/null +++ b/storejs/storejs.d.ts @@ -0,0 +1,5 @@ +// Type definitions for store.js +// store.js exposes a simple API for cross browser local storage +// Project: https://github.com/marcuswestin/store.js/ +// Definitions by: Vincent Bortone +// Definitions: https://github.com/borisyankov/DefinitelyTyped \ No newline at end of file From 77b48303843916511b6b993686df81e2f438efae Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Fri, 25 Jan 2013 02:53:31 -0500 Subject: [PATCH 003/248] Finish code and tests. --- storejs/storejs-tests.ts | 24 +++++++++++++++++++++++- storejs/storejs.d.ts | 17 ++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/storejs/storejs-tests.ts b/storejs/storejs-tests.ts index 9ef1b0f178..06387a728d 100644 --- a/storejs/storejs-tests.ts +++ b/storejs/storejs-tests.ts @@ -1 +1,23 @@ -// Tests for storagejs.d.ts \ No newline at end of file +// Tests for storagejs.d.ts +/// + +// Store 'marcus' at 'username' +store.set('username', 'marcus'); + +// Get 'username' +var userName:any = store.get('username'); + +var all: Object = store.getAll(); + +// Remove 'username' +store.remove('username'); + +// Clear all keys +store.clear(); + +// Store an object literal - store.js uses JSON.stringify under the hood +store.set('user', { name: 'marcus', likes: 'javascript' }); + +// Get the stored object - store.js uses JSON.parse under the hood +var user: any = store.get('user'); +alert(user.name + ' likes ' + user.likes); \ No newline at end of file diff --git a/storejs/storejs.d.ts b/storejs/storejs.d.ts index bb84cd646a..3c14a99ca5 100644 --- a/storejs/storejs.d.ts +++ b/storejs/storejs.d.ts @@ -2,4 +2,19 @@ // store.js exposes a simple API for cross browser local storage // Project: https://github.com/marcuswestin/store.js/ // Definitions by: Vincent Bortone -// Definitions: https://github.com/borisyankov/DefinitelyTyped \ No newline at end of file +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface StoreJSStatic { + set(key: string, value: any): any; + get(key: string): any; + remove(key: string): void; + clear(): void; + enabled: bool; + disabled: bool; + transact(key: string, defaultValue: any, transactionFn?: (val: any) => void): void; + getAll(): any; + serialize(value: any): string; + deserialize(value: string): any; +} + +declare var store: StoreJSStatic; \ No newline at end of file From 1fe5ed10e5db1d91847938e7290077ddc527c2a7 Mon Sep 17 00:00:00 2001 From: jodonoghue-avoca Date: Fri, 25 Jan 2013 15:26:45 +0000 Subject: [PATCH 004/248] Update globalize/globalize.d.ts cultureSelector in the localize function is an optional parameter --- globalize/globalize.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/globalize/globalize.d.ts b/globalize/globalize.d.ts index 902236ced0..8b4a1ce97a 100644 --- a/globalize/globalize.d.ts +++ b/globalize/globalize.d.ts @@ -110,11 +110,11 @@ class GlobalizeStatic { addCultureInfo(cultureName, baseCultureName, info? ); findClosestCulture(cultureSelector: string); format(value, format, cultureSelector? ); - localize(key, cultureSelector); + localize(key, cultureSelector?); parseDate(value: string, formats? , cultureSelector?: string): Date; parseInt(value: string, radix? , cultureSelector?: string): number; parseFloat(value: string, radix? , cultureSelector?: string): number; } -declare var Globalize: GlobalizeStatic; \ No newline at end of file +declare var Globalize: GlobalizeStatic; From aa97ce4ffc868b4bb595d1b91cf4b78595577cda Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Fri, 25 Jan 2013 18:00:51 +0200 Subject: [PATCH 005/248] Update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ffadd0136e..fb05eb5622 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ List of Definitions * [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev)) * [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Store.js](https://github.com/marcuswestin/store.js/) (by [Vincent Bortone](https://github.com/vbortone/)) * [Sugar](http://sugarjs.com/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [SwipeView](http://cubiq.org/swipeview) (by [Boris Yankov](https://github.com/borisyankov)) * [Teechart](http://www.steema.com) (by [Steema](http://www.steema.com)) From 472995d0c82170b08a53222a2aa31f8ebf592c71 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 Jan 2013 08:36:31 -0800 Subject: [PATCH 006/248] More type safety for transitions plus updates to support events. --- state-machine/state-machine-tests.ts | 16 ++++++++-- state-machine/state-machine.d.ts | 46 ++++++++++++++++++---------- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/state-machine/state-machine-tests.ts b/state-machine/state-machine-tests.ts index c82259050e..98b6ccf7c5 100644 --- a/state-machine/state-machine-tests.ts +++ b/state-machine/state-machine-tests.ts @@ -1,6 +1,13 @@ /// -var fsm = StateMachine.create({ +interface StateMachineTest extends StateMachine { + warn?: StateMachineEvent; + panic?: StateMachineEvent; + calm?: StateMachineEvent; + clear?: StateMachineEvent; +} + +var fsm: StateMachineTest = StateMachine.create({ initial: 'green', events: [ { name: 'warn', from: 'green', to: 'yellow' }, @@ -15,4 +22,9 @@ var fsm = StateMachine.create({ onyellow: function (event, from, to) { document.body.className = 'yellow'; }, onred: function (event, from, to) { document.body.className = 'red'; }, } -}); \ No newline at end of file +}); + +//fsm.warn(); // transition from green to yellow +//fsm.panic("ERROR ALERT"); // transition from yellow to red +//fsm.calm(); // transition from red to yellow +//fsm.clear("All clear"); // transition from yellow to green diff --git a/state-machine/state-machine.d.ts b/state-machine/state-machine.d.ts index 0a0967c834..d083d71e66 100644 --- a/state-machine/state-machine.d.ts +++ b/state-machine/state-machine.d.ts @@ -3,26 +3,30 @@ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped // Updated: 2013/01/22 by Maarten Docter +// Updated: 2013/01/25 by William Sears - -interface ErrorCallback { +interface StateMachineErrorCallback { (eventName?: string, from?: string, to?: string, args?: any[], errorCode?: number, errorMessage?: string, ex?: Error): void; // NB. errorCode? See: StateMachine.Error } -interface StateMachineEvent { +interface StateMachineEventDef { name: string; from: string; to: string; } +interface StateMachineEvent { + (...args: any[]): void; +} + interface StateMachineConfig { initial?: any; // string or { state: 'foo', event: 'setup', defer: true|false } - events?: StateMachineEvent[]; + events?: StateMachineEventDef[]; callbacks?: { [s: string]: (event?: string, from?: string, to?: string, ...args: any[]) => any; }; - target?: any; - error?: ErrorCallback; + target?: StateMachine; + error?: StateMachineErrorCallback; } interface StateMachineStatic { @@ -44,24 +48,34 @@ interface StateMachineStatic { INVALID_CALLBACK: number; // = 300, caller provided callback function threw an exception }; - create(config: StateMachineConfig, target?: any): StateMachine; + create(config: StateMachineConfig, target?: StateMachine): StateMachine; +} + +interface StateMachineTransition { + (): void; + cancel(): void; +} + +interface StateMachineIs { + (state: string): bool; +} + +interface StateMachineCan { + (evt: string): bool; } interface StateMachine { current: string; - is(state: string): bool; - can(event: StateMachineEvent): bool; - cannot(event: StateMachineEvent): bool; - error: ErrorCallback; + is: StateMachineIs; + can: StateMachineCan; + cannot: StateMachineCan; + error: StateMachineErrorCallback; /* transition - only available when performing async state transitions; otherwise null. Can be a: - [1] function without arguments (see: https://github.com/jakesgordon/javascript-state-machine#asynchronous-state-transitions) - [2] property with a cancel function to cancel the ASYNC event. Example usages: - - [1] fsm.transition(); // called form async callback + [1] fsm.transition(); // called from async callback [2] fsm.transition.cancel(); */ - transition?: any; + transition: StateMachineTransition; } declare var StateMachine: StateMachineStatic; \ No newline at end of file From b9d128f1c8ea2fee8360b5c96d5d6f72aa1f9758 Mon Sep 17 00:00:00 2001 From: jodonoghue-avoca Date: Fri, 25 Jan 2013 15:26:45 +0000 Subject: [PATCH 007/248] Update globalize/globalize.d.ts cultureSelector in the localize function is an optional parameter --- globalize/globalize.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/globalize/globalize.d.ts b/globalize/globalize.d.ts index 902236ced0..8b4a1ce97a 100644 --- a/globalize/globalize.d.ts +++ b/globalize/globalize.d.ts @@ -110,11 +110,11 @@ class GlobalizeStatic { addCultureInfo(cultureName, baseCultureName, info? ); findClosestCulture(cultureSelector: string); format(value, format, cultureSelector? ); - localize(key, cultureSelector); + localize(key, cultureSelector?); parseDate(value: string, formats? , cultureSelector?: string): Date; parseInt(value: string, radix? , cultureSelector?: string): number; parseFloat(value: string, radix? , cultureSelector?: string): number; } -declare var Globalize: GlobalizeStatic; \ No newline at end of file +declare var Globalize: GlobalizeStatic; From d412e0129fe1561cf4631d42c594c8e2504c6988 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Fri, 25 Jan 2013 18:00:51 +0200 Subject: [PATCH 008/248] Update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ffadd0136e..fb05eb5622 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ List of Definitions * [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev)) * [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Store.js](https://github.com/marcuswestin/store.js/) (by [Vincent Bortone](https://github.com/vbortone/)) * [Sugar](http://sugarjs.com/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [SwipeView](http://cubiq.org/swipeview) (by [Boris Yankov](https://github.com/borisyankov)) * [Teechart](http://www.steema.com) (by [Steema](http://www.steema.com)) From aaab0e11c15cb9b4382d80159ad1e96a5f1f750c Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Fri, 25 Jan 2013 12:39:20 -0500 Subject: [PATCH 009/248] JSONEditorOnline type definitions and tests Initial commit of JSONEditorOnline type definitions and tests. --- jsoneditoronline/jsoneditoronline-tests.ts | 19 +++++++++++++ jsoneditoronline/jsoneditoronline.d.ts | 32 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 jsoneditoronline/jsoneditoronline-tests.ts create mode 100644 jsoneditoronline/jsoneditoronline.d.ts diff --git a/jsoneditoronline/jsoneditoronline-tests.ts b/jsoneditoronline/jsoneditoronline-tests.ts new file mode 100644 index 0000000000..ca5d614de1 --- /dev/null +++ b/jsoneditoronline/jsoneditoronline-tests.ts @@ -0,0 +1,19 @@ +// Tests for JSONEditorOnline type definitions +/// + +var options:JSONEditorOptions = { + "search": true +}; +var editor:JSONEditor = new JSONEditor(container, options); +var json:JSON = { + "Array": [1, 2, 3], + "Boolean": true, + "Null": null, + "Number": 123, + "Object": {"a": "b", "c": "d"}, + "String": "Hello World" +}; +editor.set(json); +editor.expandAll(); + +var json2:JSON = editor.get(json); \ No newline at end of file diff --git a/jsoneditoronline/jsoneditoronline.d.ts b/jsoneditoronline/jsoneditoronline.d.ts new file mode 100644 index 0000000000..1fffc1afb3 --- /dev/null +++ b/jsoneditoronline/jsoneditoronline.d.ts @@ -0,0 +1,32 @@ +// Type definitions for JSONEditorOnline +// JSON Editor Online is a tool to easily edit and format JSON online. JSON is displayed in a clear, editable treeview and in formatted plain text. +// Project: https://github.com/josdejong/jsoneditoronline +// Definitions by: Vincent Bortone +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface JSONEditorOptions { + change?: () => void; + history?: bool; + mode?: string; + name?: string; + search?: bool; +} + +interface JSONEditor { + (container:HTMLElement, options?: JSONEditorOptions, json?: JSON): JSONEditor; + set(json: JSON, name?: string): void; + setName(name?: string): void; + get(): JSON; + getName(): string; + expandAll(): void; + collapseAll(): void; +} + +interface JSONFormatterOptions { + change?: () => void; + indentation?: number; +} + +interface JSONFormatter { + (container:HTMLElement, options?: JSONFormatterOptions, json?: JSON): JSONEditor; +} \ No newline at end of file From b29239b019d13a193e8f1e1135bfee00d81ab8b0 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Fri, 25 Jan 2013 12:49:33 -0500 Subject: [PATCH 010/248] Added JSONFormatter interface and tests --- jsoneditoronline/jsoneditoronline-tests.ts | 18 +++++++++++++++++- jsoneditoronline/jsoneditoronline.d.ts | 5 +++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/jsoneditoronline/jsoneditoronline-tests.ts b/jsoneditoronline/jsoneditoronline-tests.ts index ca5d614de1..ea97d9f445 100644 --- a/jsoneditoronline/jsoneditoronline-tests.ts +++ b/jsoneditoronline/jsoneditoronline-tests.ts @@ -16,4 +16,20 @@ var json:JSON = { editor.set(json); editor.expandAll(); -var json2:JSON = editor.get(json); \ No newline at end of file +var jsonResult:JSON = editor.get(json); + +var options2: JSONformatterOptions = { + "indentation": 2 +}; +var formatter:JSONFormatter = new JSONFormatter(container, options); +var json2:JSON = { + "Array": [1, 2, 3], + "Boolean": true, + "Null": null, + "Number": 123, + "Object": {"a": "b", "c": "d"}, + "String": "Hello World" +}; +formatter.set(json2); + +var jsonResult2:JSON = formatter.get(json2); \ No newline at end of file diff --git a/jsoneditoronline/jsoneditoronline.d.ts b/jsoneditoronline/jsoneditoronline.d.ts index 1fffc1afb3..0a69fd0f8e 100644 --- a/jsoneditoronline/jsoneditoronline.d.ts +++ b/jsoneditoronline/jsoneditoronline.d.ts @@ -29,4 +29,9 @@ interface JSONFormatterOptions { interface JSONFormatter { (container:HTMLElement, options?: JSONFormatterOptions, json?: JSON): JSONEditor; + (container:HTMLElement, options?: JSONFormatterOptions, json?: string): JSONEditor; + set(json: JSON); + get(): JSON; + setText(jsonString: string); + getText(): string; } \ No newline at end of file From 4fe137ae7d782e317e269e47a57fde591fe0a353 Mon Sep 17 00:00:00 2001 From: William Sears Date: Fri, 25 Jan 2013 11:31:28 -0800 Subject: [PATCH 011/248] Definitions and unit tests for sinon.js --- sinon/sinon-1.5.d.ts | 381 +++++++++++++++++++++++++++++++++++++++++++ sinon/sinon-tests.ts | 77 +++++++++ 2 files changed, 458 insertions(+) create mode 100644 sinon/sinon-1.5.d.ts create mode 100644 sinon/sinon-tests.ts diff --git a/sinon/sinon-1.5.d.ts b/sinon/sinon-1.5.d.ts new file mode 100644 index 0000000000..7c3cb9a86d --- /dev/null +++ b/sinon/sinon-1.5.d.ts @@ -0,0 +1,381 @@ +// Type definitions for Sinon 1.5 +// Project: http://sinonjs.org/ +// Definitions by: William Sears +// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped + +interface SinonSpyCall { + // Properties + thisValue: any; + args: any[]; + exception: any; + returnValue: any; + + // Methods + calledOn(obj: any): bool; + calledWith(...args: any[]); + calledWithExactly(...args: any[]): bool; + calledWithMatch(...args: any[]): bool; + notCalledWith(...args: any[]); + notCalledWithMatch(...args: any[]): bool; + threw(): bool; + threw(type: string); + threw(obj: any); +} + +interface SinonSpyApi { + // Properties + callCount: number; + called: bool; + calledOnce: bool; + calledTwice: bool; + calledThrice: bool; + firstCall: SinonSpyCall; + secondCall: SinonSpyCall; + thirdCall: SinonSpyCall; + lastCall: SinonSpyCall; + thisValues: any[]; + args: any[][]; + exceptions: any[]; + returnValues: any[]; + + //Methods + withArgs(...args: any[]): void; + calledBefore(anotherSpy: SinonSpy): bool; + calledAfter(anotherSpy: SinonSpy): bool; + calledOn(obj: any); + alwaysCalledOn(obj: any); + calledWith(...args: any[]); + alwaysCalledWith(...args: any[]); + calledWithExactly(...args: any[]); + alwaysCalledWithExactly(...args: any[]); + calledWithMatch(...args: any[]); + alwaysCalledWithMatch(...args: any[]); + calledWithNew(): bool; + notCalledWith(...args: any[]); + neverCalledWith(...args: any[]); + notCalledWithMatch(...args: any[]); + neverCalledWithMatch(...args: any[]); + threw(): bool; + threw(type: string); + threw(obj: any); + alwaysThrew(): bool; + alwaysThrew(type: string); + alwaysThrew(obj: any); + returned(): bool; + alwaysReturned(): bool; + yield(...args: any[]): void; + invokeCallback(...args: any[]): void; + yieldTo(property: string, ...args: any[]): void; + callArg(index: number): void; + callArgWith(index: number, ...args: any[]): void; + getCall(n: number): SinonSpyCall; + reset(): void; + printf(format: string, ...args: any[]); + restore(): void; +} + +interface SinonSpy { + (): SinonSpyApi; + (func: any): SinonSpyApi; + (obj: any, method: string): SinonSpyApi; +} + +interface SinonApi { + spy: SinonSpy; +} + +interface SinonStubApi extends SinonSpyApi { + returns(obj: any): SinonStubApi; + returnsArg(index: number): SinonStubApi; + throws(type?: string): SinonStubApi; + throws(obj: any): SinonStubApi; + callsArg(index: number): SinonStubApi; + callsArgOn(index: number, context: any): SinonStubApi; + callsArgWith(index: number, ...args: any[]): SinonStubApi; + callsArgOnWith(index: number, context: any, ...args: any[]): SinonStubApi; + yields(...args: any[]): SinonStubApi; + yieldsOn(context: any, ...args: any[]): SinonStubApi; + yieldsTo(property: string, ...args: any[]): SinonStubApi; + yieldsToOn(property: string, context: any, ...args: any[]): SinonStubApi; +} + +interface SinonStub { + (): SinonStubApi; + (obj: any): SinonStubApi; + (obj: any, method: string): SinonStubApi; + (obj: any, method: string, func: any): SinonStubApi; +} + +interface SinonApi { + stub: SinonStub; +} + +interface SinonExpectationApi { + atLeast(n: number): SinonExpectation; + atMost(n: number): SinonExpectation; + never(): SinonExpectation; + once(): SinonExpectation; + twice(): SinonExpectation; + thrice(): SinonExpectation; + exactly(n: number): SinonExpectation; + withArgs(...args: any[]): SinonExpectation; + withExactArgs(...args: any[]): SinonExpectation; + on(obj: any): SinonExpectation; + verify(): SinonExpectation; + restore(): void; +} + +interface SinonExpectation { + create(methodName?: string): SinonExpectationApi; +} + +interface SinonMockApi { + expects(method: string): SinonExpectationApi; + restore(): void; + verify(): void; +} + +interface SinonMock { + (): SinonExpectationApi; + (obj: any): SinonMockApi; +} + +interface SinonApi { + expectation: SinonExpectation; + mock: SinonMock; +} + +interface SinonFakeTimersApi { + now: number; + create(now: number): SinonFakeTimers; + setTimeout(callback: (...args: any[]) => void , timeout: number, ...args: any[]): number; + clearTimeout(id: number): void; + setInterval(callback: (...args: any[]) => void , timeout: number, ...args: any[]): number; + clearInterval(id: number): void; + tick(ms: number): number; + reset(): void; + Date(): Date; + Date(year: number): Date; + Date(year: number, month: number): Date; + Date(year: number, month: number, day: number): Date; + Date(year: number, month: number, day: number, hour: number): Date; + Date(year: number, month: number, day: number, hour: number, minute: number): Date; + Date(year: number, month: number, day: number, hour: number, minute: number, second: number): Date; + Date(year: number, month: number, day: number, hour: number, minute: number, second: number, ms: number): Date; + restore(): void; +} + +interface SinonFakeTimers { + (): SinonFakeTimersApi; + (...timers: string[]): SinonFakeTimersApi; + (now: number, ...timers: string[]): SinonFakeTimersApi; +} + +interface SinonApi { + useFakeTimers: SinonFakeTimers; + clock: SinonFakeTimers; +} + +interface SinonFakeXMLHttpRequestApi { + // Properties + onCreate: (xhr: SinonFakeXMLHttpRequest) => void; + url: string; + method: string; + requestHeaders: any; + requestBody: string; + status: number; + statusText: string; + async: bool; + username: string; + password: string; + responseXML: Document; + getResponseHeader(header: string): string; + getAllResponseHeaders(): any; + + // Methods + restore(): void; + useFilters: bool; + addFilter(filter: (method, url, async, username, password) => bool): void; + setResponseHeaders(headers: any): void; + setResponseBody(body: string): void; + respond(status: number, headers: any, body: string): void; + autoRespond(ms: number): void; +} + +interface SinonFakeXMLHttpRequest { + (): SinonFakeXMLHttpRequestApi; +} + +interface SinonApi { + useFakeXMLHttpRequest: SinonFakeXMLHttpRequest; + FakeXMLHttpRequest: SinonFakeXMLHttpRequestApi; +} + +interface SinonFakeServerApi { + // Properties + autoRespond: bool; + autoRespondAfter: number; + fakeHTTPMethods: bool; + getHTTPMethod: (request: SinonFakeXMLHttpRequest) => string; + + // Methods + respondWith(body: string): void; + respondWith(response: any[]): void; + respondWith(fn: (SinonFakeXMLHttpRequest) => void ): void; + respondWith(url: string, body: string): void; + respondWith(url: string, response: any[]): void; + respondWith(url: string, fn: (SinonFakeXMLHttpRequest) => void ): void; + respondWith(method: string, url: string, body: string): void; + respondWith(method: string, url: string, response: any[]): void; + respondWith(method: string, url: string, fn: (SinonFakeXMLHttpRequest) => void ): void; + respondWith(url: RegExp, body: string): void; + respondWith(url: RegExp, response: any[]): void; + respondWith(url: RegExp, fn: (SinonFakeXMLHttpRequest) => void ): void; + respondWith(method: string, url: RegExp, body: string): void; + respondWith(method: string, url: RegExp, response: any[]): void; + respondWith(method: string, url: RegExp, fn: (SinonFakeXMLHttpRequest) => void ): void; + respond(): void; + restore(): void; +} + +interface SinonFakeServer { + create(): SinonFakeServerApi; +} + +interface SinonApi { + fakeServer: SinonFakeServer; + fakeServerWithClock: SinonFakeServer; +} + +interface SinonExposeOptions { + prefix?: string; + includeFail?: bool; +} + +interface SinonAssertApi { + // Properties + failException: string; + fail: (message?: string) => void; // Overridable + pass: (assertion: any) => void; // Overridable + + // Methods + notCalled(spy: SinonSpy): void; + called(spy: SinonSpy): void; + calledOnce(spy: SinonSpy): void; + calledTwice(spy: SinonSpy): void; + calledThrice(spy: SinonSpy): void; + callCount(spy: SinonSpy, count: number): void; + callOrder(...spies: SinonSpy[]): void; + calledOn(spy: SinonSpy, obj: any): void; + alwaysCalledOn(spy: SinonSpy, obj: any): void; + calledWith(spy: SinonSpy, ...args: any[]): void; + alwaysCalledWith(spy: SinonSpy, ...args: any[]): void; + neverCalledWith(spy: SinonSpy, ...args: any[]): void; + calledWithExactly(spy: SinonSpy, ...args: any[]): void; + alwaysCalledWithExactly(spy: SinonSpy, ...args: any[]): void; + calledWithMatch(spy: SinonSpy, ...args: any[]): void; + alwaysCalledWithMatch(spy: SinonSpy, ...args: any[]): void; + neverCalledWithMatch(spy: SinonSpy, ...args: any[]): void; + threw(spy: SinonSpy): void; + threw(spy: SinonSpy, exception: string): void; + threw(spy: SinonSpy, exception: any): void; + alwaysThrew(spy: SinonSpy): void; + alwaysThrew(spy: SinonSpy, exception: string): void; + alwaysThrew(spy: SinonSpy, exception: any): void; + expose(obj: any, options?: SinonExposeOptions): void; +} + +interface SinonApi { + assert: SinonAssertApi; +} + +interface SinonMatcherTerm { + and(expr: SinonMatcherTerm): SinonMatcherTerm; + or(expr: SinonMatcherTerm): SinonMatcherTerm; +} + +interface SinonMatcherApi { + any: SinonMatcherTerm; + defined: SinonMatcherTerm; + truthy: SinonMatcherTerm; + falsy: SinonMatcherTerm; + bool: SinonMatcherTerm; + number: SinonMatcherTerm; + string: SinonMatcherTerm; + object: SinonMatcherTerm; + func: SinonMatcherTerm; + array: SinonMatcherTerm; + regexp: SinonMatcherTerm; + date: SinonMatcherTerm; + same(obj: any): SinonMatcherTerm; + typeOf(type: string): SinonMatcherTerm; + instanceOf(type: any): SinonMatcherTerm; + has(property: string, expect?: any): SinonMatcherTerm; + hasOwn(property: string, expect?: any): SinonMatcherTerm; +} + +interface SinonMatcher { + (value: number): SinonMatcherApi; + (value: string): SinonMatcherApi; + (expr: RegExp): SinonMatcherApi; + (obj: any): SinonMatcherApi; + (callback: (value: any) => bool): SinonMatcherApi; +} + +interface SinonApi { + match: SinonMatcher; +} + +interface SinonSandboxConfig { + injectInto?: any; + properties?: string[]; + useFakeTimers?: any; + useFakeServer?: any; +} + +interface SinonSandboxApi { + clock: SinonFakeTimers; + requests: SinonFakeXMLHttpRequest; + server: SinonFakeServer; + spy(): SinonSpyApi; + stub(): SinonStubApi; + mock(): SinonMockApi; + useFakeTimers: SinonFakeTimers; + useFakeXMLHttpRequest: SinonFakeXMLHttpRequest; + restore(): void; +} + +interface SinonSandbox { + create(): SinonSandboxApi; + create(config: SinonSandboxConfig): SinonSandboxApi; +} + +interface SinonApi { + sandbox: SinonSandbox; +} + +interface SinonTestConfig { + injectIntoThis?: bool; + injectInto?: any; + properties?: string[]; + useFakeTimers?: bool; + useFakeServer?: bool; +} + +interface SinonTestWrapper extends SinonSandboxApi{ + (...args: any[]): any; +} + +interface SinonApi { + config: SinonTestConfig; + test(fn: (...args: any[]) => any): SinonTestWrapper; + testCase(tests: any): any; +} + +// Utility overridables +interface SinonApi { + format: (obj: any) => string; + log: (message: string) => void; +} + +var sinon: SinonApi; diff --git a/sinon/sinon-tests.ts b/sinon/sinon-tests.ts new file mode 100644 index 0000000000..a9db8360d5 --- /dev/null +++ b/sinon/sinon-tests.ts @@ -0,0 +1,77 @@ +/// + +function once(fn) { + var returnValue, called = false; + return function () { + if (!called) { + called = true; + returnValue = fn.apply(this, arguments); + } + return returnValue; + }; +} + +function testOne() { + var callback = sinon.spy(); + var proxy = once(callback); + proxy(); + if (callback.calledOnce) { console.log("test1 calledOnce success"); } else { console.log("test1 calledOnce failure"); } +} + +function testTwo() { + var callback = sinon.spy(); + var proxy = once(callback); + proxy(); + proxy(); + if (callback.calledOnce) { console.log("test2 calledOnce success"); } else { console.log("test2 calledOnce failure"); } +} + +function testThree() { + var obj = { thisObj: true }; + var callback = sinon.spy(); + var proxy = once(callback); + proxy.call(obj, callback, 1, 2, 3); + if (callback.calledOn(obj)) { console.log("test3 calledOn success"); } else { console.log("test3 calledOn failure"); } + if (callback.calledWith(callback, 1, 2, 3)) { console.log("test3 calledWith success"); } else { console.log("test3 calledWith failure"); } +} + +function testFour() { + var obj = { thisObj: true }; + var callback = sinon.stub().returns(42); + var proxy = once(callback); + var val = proxy.apply(callback, [1, 2, 3]); + if (val == 42) { console.log("test4 returns success"); } else { console.log("test4 returns failure"); } +} + +function testFive() { + var obj = { thisObj: true }; + var callback = sinon.stub().returnsArg(1); + var proxy = once(callback); + var val = proxy.apply(callback, [1, 2, 3]); + if (val == 2) { console.log("test5 returnsArg success"); } else { console.log("test5 returnsArg failure"); } +} + +var objectUnderTest: any = { + process: function (obj) { + // It doesn't really matter what's here because the stub is going to replace this function + var dummy = true; + if (dummy) { return obj.success(99); } else { obj.failure(99); } + } +}; + +function testSix() { + var obj = { thisObj: true }; + var stub = sinon.stub(objectUnderTest, "process").yieldsTo("success"); + var val = objectUnderTest.process({ + success: function () { console.log("test6 yieldsTo success"); }, + failure: function () { console.log("test6 yieldsTo failure"); } + }); + stub.restore(); +} + +testOne(); +testTwo(); +testThree(); +testFour(); +testFive(); +testSix(); \ No newline at end of file From bed706805d0111c26cf598a4c269c5d1b6c3589d Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Fri, 25 Jan 2013 23:27:17 +0200 Subject: [PATCH 012/248] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb05eb5622..307fa2d836 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ List of Definitions * [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov)) * [SignalR](http://www.asp.net/signalr) (by [Boris Yankov](https://github.com/borisyankov)) +* [Sinon](http://sinonjs.org/) (by [William Sears](https://github.com/mrbigdog2u)) * [socket.io](http://socket.io) (by [William Orr](https://github.com/worr)) * [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev)) * [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) @@ -134,7 +135,6 @@ Requested Definitions * [Rickshaw](https://github.com/shutterstock/rickshaw) * [Crossfilter](https://github.com/square/crossfilter) * [dc.js](https://github.com/NickQiZhu/dc.js) -* [store.js](https://github.com/marcuswestin/store.js) * [google.visualizations](https://developers.google.com/chart/) * [Tags Manager](http://welldonethings.com/tags/manager) * [jsoneditoronline](https://github.com/wjosdejong/jsoneditoronline) From 2df1c73b6d6b98697fadd5e0bdcf6314ae178304 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Fri, 25 Jan 2013 18:20:46 -0500 Subject: [PATCH 013/248] Updates to JSONEditorNode --- jsoneditoronline/jsoneditoronline-tests.ts | 12 ++-- jsoneditoronline/jsoneditoronline.d.ts | 65 +++++++++++++++++++--- 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/jsoneditoronline/jsoneditoronline-tests.ts b/jsoneditoronline/jsoneditoronline-tests.ts index ea97d9f445..37cf0d2cab 100644 --- a/jsoneditoronline/jsoneditoronline-tests.ts +++ b/jsoneditoronline/jsoneditoronline-tests.ts @@ -1,11 +1,13 @@ // Tests for JSONEditorOnline type definitions /// +var container: HTMLElement; + var options:JSONEditorOptions = { "search": true }; var editor:JSONEditor = new JSONEditor(container, options); -var json:JSON = { +var json = { "Array": [1, 2, 3], "Boolean": true, "Null": null, @@ -16,13 +18,13 @@ var json:JSON = { editor.set(json); editor.expandAll(); -var jsonResult:JSON = editor.get(json); +var jsonResult:JSON = editor.get(); -var options2: JSONformatterOptions = { +var options2: JSONFormatterOptions = { "indentation": 2 }; -var formatter:JSONFormatter = new JSONFormatter(container, options); -var json2:JSON = { +var formatter: JSONFormatter = new JSONFormatter(container, options); +var json2 = { "Array": [1, 2, 3], "Boolean": true, "Null": null, diff --git a/jsoneditoronline/jsoneditoronline.d.ts b/jsoneditoronline/jsoneditoronline.d.ts index 0a69fd0f8e..9bbb71440e 100644 --- a/jsoneditoronline/jsoneditoronline.d.ts +++ b/jsoneditoronline/jsoneditoronline.d.ts @@ -9,17 +9,66 @@ interface JSONEditorOptions { history?: bool; mode?: string; name?: string; - search?: bool; + search?: bool; } -interface JSONEditor { - (container:HTMLElement, options?: JSONEditorOptions, json?: JSON): JSONEditor; - set(json: JSON, name?: string): void; +class JSONEditorHistory { + constructor(editor: JSONEditor); + onChange(): void; + add(action: string, params: Object); + clear(): void; + canUndo(): bool; + canRedo(): bool; + undo(): void; + redo(): void; +} + +class JSONEditorNode { + constructor(editor: JSONEditor, params: Object); + setParent(parent: JSONEditorNode): void; + getParent(): JSONEditorNode; + setField(field: string, fieldEditable: bool): void; + getField(): string; + setValue(value: any): void; + getValue(): any; + getLevel(): number; + clone(): JSONEditorNode; + expand(recurse: bool): void; + collapse(recurse: bool): void; + showChilds(): void; + hide(): void; + hideChilds(): void; + appendChild(node: JSONEditorNode): void; + moveBefore(node: JSONEditorNode, beforeNode: JSONEditorNode): void; + moveTo(node: JSONEditorNode, index: number): void; + insertBefore(node: JSONEditorNode, beforeNode: JSONEditorNode): void; + search(text: string): JSONEditorNode[]; + scrollTo(): void; + focus(): void; + blur(): void; + containsNode(node: JSONEditorNode): bool; + removeChild(node: JSONEditorNode): JSONEditorNode; + changeType(newType: string): void; + clearDom(): void; + getDom(): HTMLElement; + setHighlight(highlight: bool): void; + updateValue(value: any): void; +} + +class JSONEditor { + constructor(container: HTMLElement, options?: JSONEditorOptions, json?: Object); + set(json: Object, name?: string): void; setName(name?: string): void; - get(): JSON; + get(): Object; getName(): string; + clear(): void; + search(text: string): any[]; expandAll(): void; collapseAll(): void; + onAction(action: string, params: Object); + focus(): void; + scrollTo(top: number): void; + History: JSONEditorHistory; } interface JSONFormatterOptions { @@ -27,9 +76,9 @@ interface JSONFormatterOptions { indentation?: number; } -interface JSONFormatter { - (container:HTMLElement, options?: JSONFormatterOptions, json?: JSON): JSONEditor; - (container:HTMLElement, options?: JSONFormatterOptions, json?: string): JSONEditor; +class JSONFormatter { + constructor(container: HTMLElement, options?: JSONFormatterOptions, json?: Object); + constructor(container: HTMLElement, options?: JSONFormatterOptions, json?: string); set(json: JSON); get(): JSON; setText(jsonString: string); From b657ec01eed00a1b3d2781391b2a73ad479743ea Mon Sep 17 00:00:00 2001 From: "Omid K. Rad" Date: Fri, 25 Jan 2013 17:46:07 -0800 Subject: [PATCH 014/248] Allow Underscore to accept both jQuery objects and Arrays Related issue: https://github.com/borisyankov/DefinitelyTyped/issues/193 --- underscore/underscore.d.ts | 376 +++++++++++++++++++------------------ 1 file changed, 191 insertions(+), 185 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index bbc848a06c..7a754a1692 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1,186 +1,192 @@ -// Type definitions for Underscore 1.4 -// Project: http://underscorejs.org/ -// Definitions by: Boris Yankov -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - -interface UnderscoreWrappedObject { - value () : any; -} - -interface TemplateSettings { - evaluate?: RegExp; - interpolate?: RegExp; - escape?: RegExp; -} - -interface ListIterator { - (value, key, list?): void; -} - -interface ObjectIterator { - (element, index, list?): void; -} - -interface UnderscoreStatic { - - /**** - Collections - *****/ - each(list: any[], iterator: ListIterator, context?: any): any[]; - each(object: any, iterator: ObjectIterator, context?: any): any[]; - forEach(list: any[], iterator: ObjectIterator, context?: any): any[]; - forEach(object: any, iterator: ListIterator, context?: any): any[]; - - map(list: any[], iterator: ListIterator, context?: any): any[]; - map(object: any, iterator: ObjectIterator, context?: any): any[]; - collect(list: any[], iterator: ListIterator, context?: any): any[]; - collect(object: any, iterator: ObjectIterator, context?: any): any[]; - - reduce(list: any[], iterator: any, memo: any, context?: any): any[]; - inject(list: any[], iterator: any, memo: any, context?: any): any[]; - foldl(list: any[], iterator: any, memo: any, context?: any): any[]; - - reduceRight(list: any[], iterator: any, memo: any, context?: any): any[]; - foldr(list: any[], iterator: any, memo: any, context?: any): any[]; - - find(list: any[], iterator: any, context?: any): any; - detect(list: any[], iterator: any, context?: any): any; - - filter(list: any[], iterator: any, context?: any): any[]; - select(list: any[], iterator: any, context?: any): any[]; - - where(list: any[], properties: any): any[]; - - reject(list: any[], iterator: any, context?: any): any[]; - - all(list: any[], iterator: any, context?: any): bool; - every(list: any[], iterator: any, context?: any): bool; - - any(list: any[], iterator?: any, context?: any): bool; - some(list: any[], iterator?: any, context?: any): bool; - - contains(list: any, value: any): bool; - contains(list: any[], value: any): bool; - include(list: any, value: any): bool; - include(list: any[], value: any): bool; - - invoke(list: any[], methodName: string, arguments: any[]): any; - invoke(object: any, methodName: string, ...arguments: any[]): any; - - pluck(list: any[], propertyName: string): string[]; - max(list: any[], iterator?: any, context?: any): any; - min(list: any[], iterator?: any, context?: any): any; - sortBy(list: any[], iterator?: any, context?: any): any; - groupBy(list: any[], iterator: any): any; - countBy(list: any[], iterator: any): any; - shuffle(list: any[]): any[]; - toArray(list: any): any[]; - size(list: any): number; - - /**** - Arrays - *****/ - first(array: any[], n?: number): any; - head(array: any[], n?: number): any; - take(array: any[], n?: number): any; - - initial(array: any[], n?: number): any[]; - - last(array: any[], n?: number): any; - - rest(array: any[], n?: number): any[]; - tail(array: any[], n?: number): any[]; - drop(array: any[], n?: number): any[]; - - compact(array: any[]): any[]; - flatten(array: any[], shallow?: bool): any[]; - without(array: any[], ...values: any[]): any[]; - union(...arrays: any[][]): any[]; - intersection(...arrays: any[][]): any[]; - difference(array: any[], ...others: any[][]): any[]; - - uniq(array: any[], isSorted?: bool, iterator?: any): any[]; - unique(array: any[], isSorted?: bool, iterator?: any): any[]; - - zip(...arrays: any[]): any[]; - object(list: any[], values: any[]): any; - indexOf(array: any[], value: any, isSorted?: bool): number; - lastIndexOf(array: any[], value: any, fromIndex?: number): number; - sortedIndex(list: any[], valueL: any, iterator?: any): number; - range(stop: number): any[]; - range(start: number, stop: number, step?: number): any[]; - - /**** - Functions - *****/ - bind(func: (...as : any[]) => any, context: any, ...arguments: any[]): () => any; - bindAll(object: any, ...methodNames: string[]): any; - memoize(func: any, hashFunction?: any): any; - defer(func: () => any); - delay(func: any, wait: number, ...arguments: any[]): any; - delay(func: any, ...arguments: any[]): any; - throttle(func: any, wait: number): any; - debounce(func: any, wait: number, immediate?: bool): any; - once(func: any): any; - after(count: number, func: any): any; - wrap(func: (...as : any[]) => any, wrapper: any): () => any; - compose(...functions: any[]): any; - - /**** - Objects - *****/ - keys(object: any): any[]; - values(object: any): any[]; - pairs(object: any): any[]; - invert(object: any): any; - - functions(object: any): string[]; - methods(object: any): string[]; - - extend(destination: any, ...sources: any[]): any; - pick(object: any, ...keys: string[]): any; - omit(object: any, ...keys: string[]): any; - defaults(object: any, ...defaults: any[]): any; - clone(object: any): any; - tap(object: any, interceptor: (...as : any[]) => any): any; - has(object: any, key: string): bool; - isEqual(object: any, other: any): bool; - isEmpty(object: any): bool; - isElement(object: any): bool; - isArray(object: any): bool; - isObject(value: any): bool; - isArguments(object: any): bool; - isFunction(object: any): bool; - isString(object: any): bool; - isNumber(object: any): bool; - isFinite(object: any): bool; - isBoolean(object: any): bool; - isDate(object: any): bool; - isRegExp(object: any): bool; - isNaN(object: any): bool; - isNull(object: any): bool; - isUndefined(value: any): bool; - - /**** - Utility - *****/ - noConflict(): any; - identity(value: any): any; - times(n: number, iterator: (index : number) => void, context?: any): void; - random(min: number, max: number): number; - mixin(object: any): void; - uniqueId(prefix: string): string; - uniqueId(): number; - escape(str: string): string; - result(object: any, property: string): any; - templateSettings: TemplateSettings; - template(templateString: string, data?: any, settings?: any): (...data: any[]) => string; - - /**** - Chaining - *****/ - chain(object: any): UnderscoreWrappedObject; -} - +// Type definitions for Underscore 1.4 +// Project: http://underscorejs.org/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface UnderscoreWrappedObject { + value () : any; +} + +interface TemplateSettings { + evaluate?: RegExp; + interpolate?: RegExp; + escape?: RegExp; +} + +interface ListIterator { + (value, key, list?): void; +} + +interface ObjectIterator { + (element, index, list?): void; +} + +// Used as common interface between Arrays and jQuery objects +interface IList { + [index: number]: any; + length: number; +} + +interface UnderscoreStatic { + + /**** + Collections + *****/ + each(list: IList, iterator: ListIterator, context?: any): any[]; + each(object: any, iterator: ObjectIterator, context?: any): any[]; + forEach(list: IList, iterator: ObjectIterator, context?: any): any[]; + forEach(object: any, iterator: ListIterator, context?: any): any[]; + + map(list: IList, iterator: ListIterator, context?: any): any[]; + map(object: any, iterator: ObjectIterator, context?: any): any[]; + collect(list: IList, iterator: ListIterator, context?: any): any[]; + collect(object: any, iterator: ObjectIterator, context?: any): any[]; + + reduce(list: IList, iterator: any, memo: any, context?: any): any[]; + inject(list: IList, iterator: any, memo: any, context?: any): any[]; + foldl(list: IList, iterator: any, memo: any, context?: any): any[]; + + reduceRight(list: IList, iterator: any, memo: any, context?: any): any[]; + foldr(list: IList, iterator: any, memo: any, context?: any): any[]; + + find(list: IList, iterator: any, context?: any): any; + detect(list: IList, iterator: any, context?: any): any; + + filter(list: IList, iterator: any, context?: any): any[]; + select(list: IList, iterator: any, context?: any): any[]; + + where(list: IList, properties: any): any[]; + + reject(list: IList, iterator: any, context?: any): any[]; + + all(list: IList, iterator: any, context?: any): bool; + every(list: IList, iterator: any, context?: any): bool; + + any(list: IList, iterator?: any, context?: any): bool; + some(list: IList, iterator?: any, context?: any): bool; + + contains(list: any, value: any): bool; + contains(list: IList, value: any): bool; + include(list: any, value: any): bool; + include(list: IList, value: any): bool; + + invoke(list: IList, methodName: string, arguments: any[]): any; + invoke(object: any, methodName: string, ...arguments: any[]): any; + + pluck(list: IList, propertyName: string): string[]; + max(list: IList, iterator?: any, context?: any): any; + min(list: IList, iterator?: any, context?: any): any; + sortBy(list: IList, iterator?: any, context?: any): any; + groupBy(list: IList, iterator: any): any; + countBy(list: IList, iterator: any): any; + shuffle(list: any[]): any[]; + toArray(list: any): any[]; + size(list: any): number; + + /**** + Arrays + *****/ + first(array: IList, n?: number): any; + head(array: IList, n?: number): any; + take(array: IList, n?: number): any; + + initial(array: IList, n?: number): any[]; + + last(array: IList, n?: number): any; + + rest(array: IList, n?: number): any[]; + tail(array: IList, n?: number): any[]; + drop(array: IList, n?: number): any[]; + + compact(array: any[]): any[]; + flatten(array: IList, shallow?: bool): any[]; + without(array: IList, ...values: any[]): any[]; + union(...arrays: any[][]): any[]; + intersection(...arrays: any[][]): any[]; + difference(array: IList, ...others: any[][]): any[]; + + uniq(array: IList, isSorted?: bool, iterator?: any): any[]; + unique(array: IList, isSorted?: bool, iterator?: any): any[]; + + zip(...arrays: any[]): any[]; + object(list: IList, values: any[]): any; + indexOf(array: IList, value: any, isSorted?: bool): number; + lastIndexOf(array: IList, value: any, fromIndex?: number): number; + sortedIndex(list: IList, valueL: any, iterator?: any): number; + range(stop: number): any[]; + range(start: number, stop: number, step?: number): any[]; + + /**** + Functions + *****/ + bind(func: (...as : any[]) => any, context: any, ...arguments: any[]): () => any; + bindAll(object: any, ...methodNames: string[]): any; + memoize(func: any, hashFunction?: any): any; + defer(func: () => any); + delay(func: any, wait: number, ...arguments: any[]): any; + delay(func: any, ...arguments: any[]): any; + throttle(func: any, wait: number): any; + debounce(func: any, wait: number, immediate?: bool): any; + once(func: any): any; + after(count: number, func: any): any; + wrap(func: (...as : any[]) => any, wrapper: any): () => any; + compose(...functions: any[]): any; + + /**** + Objects + *****/ + keys(object: any): any[]; + values(object: any): any[]; + pairs(object: any): any[]; + invert(object: any): any; + + functions(object: any): string[]; + methods(object: any): string[]; + + extend(destination: any, ...sources: any[]): any; + pick(object: any, ...keys: string[]): any; + omit(object: any, ...keys: string[]): any; + defaults(object: any, ...defaults: any[]): any; + clone(object: any): any; + tap(object: any, interceptor: (...as : any[]) => any): any; + has(object: any, key: string): bool; + isEqual(object: any, other: any): bool; + isEmpty(object: any): bool; + isElement(object: any): bool; + isArray(object: any): bool; + isObject(value: any): bool; + isArguments(object: any): bool; + isFunction(object: any): bool; + isString(object: any): bool; + isNumber(object: any): bool; + isFinite(object: any): bool; + isBoolean(object: any): bool; + isDate(object: any): bool; + isRegExp(object: any): bool; + isNaN(object: any): bool; + isNull(object: any): bool; + isUndefined(value: any): bool; + + /**** + Utility + *****/ + noConflict(): any; + identity(value: any): any; + times(n: number, iterator: (index : number) => void, context?: any): void; + random(min: number, max: number): number; + mixin(object: any): void; + uniqueId(prefix: string): string; + uniqueId(): number; + escape(str: string): string; + result(object: any, property: string): any; + templateSettings: TemplateSettings; + template(templateString: string, data?: any, settings?: any): (...data: any[]) => string; + + /**** + Chaining + *****/ + chain(object: any): UnderscoreWrappedObject; +} + declare var _: UnderscoreStatic; \ No newline at end of file From d43bec3268d03792ab4aeaa03083c2d3fb3c383e Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Sat, 26 Jan 2013 04:24:14 +0200 Subject: [PATCH 015/248] Remove I from IList interface name --- underscore/underscore.d.ts | 382 ++++++++++++++++++------------------- 1 file changed, 191 insertions(+), 191 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 7a754a1692..1c725f019a 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1,192 +1,192 @@ -// Type definitions for Underscore 1.4 -// Project: http://underscorejs.org/ -// Definitions by: Boris Yankov -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - -interface UnderscoreWrappedObject { - value () : any; -} - -interface TemplateSettings { - evaluate?: RegExp; - interpolate?: RegExp; - escape?: RegExp; -} - -interface ListIterator { - (value, key, list?): void; -} - -interface ObjectIterator { - (element, index, list?): void; -} - -// Used as common interface between Arrays and jQuery objects -interface IList { - [index: number]: any; - length: number; -} - -interface UnderscoreStatic { - - /**** - Collections - *****/ - each(list: IList, iterator: ListIterator, context?: any): any[]; - each(object: any, iterator: ObjectIterator, context?: any): any[]; - forEach(list: IList, iterator: ObjectIterator, context?: any): any[]; - forEach(object: any, iterator: ListIterator, context?: any): any[]; - - map(list: IList, iterator: ListIterator, context?: any): any[]; - map(object: any, iterator: ObjectIterator, context?: any): any[]; - collect(list: IList, iterator: ListIterator, context?: any): any[]; - collect(object: any, iterator: ObjectIterator, context?: any): any[]; - - reduce(list: IList, iterator: any, memo: any, context?: any): any[]; - inject(list: IList, iterator: any, memo: any, context?: any): any[]; - foldl(list: IList, iterator: any, memo: any, context?: any): any[]; - - reduceRight(list: IList, iterator: any, memo: any, context?: any): any[]; - foldr(list: IList, iterator: any, memo: any, context?: any): any[]; - - find(list: IList, iterator: any, context?: any): any; - detect(list: IList, iterator: any, context?: any): any; - - filter(list: IList, iterator: any, context?: any): any[]; - select(list: IList, iterator: any, context?: any): any[]; - - where(list: IList, properties: any): any[]; - - reject(list: IList, iterator: any, context?: any): any[]; - - all(list: IList, iterator: any, context?: any): bool; - every(list: IList, iterator: any, context?: any): bool; - - any(list: IList, iterator?: any, context?: any): bool; - some(list: IList, iterator?: any, context?: any): bool; - - contains(list: any, value: any): bool; - contains(list: IList, value: any): bool; - include(list: any, value: any): bool; - include(list: IList, value: any): bool; - - invoke(list: IList, methodName: string, arguments: any[]): any; - invoke(object: any, methodName: string, ...arguments: any[]): any; - - pluck(list: IList, propertyName: string): string[]; - max(list: IList, iterator?: any, context?: any): any; - min(list: IList, iterator?: any, context?: any): any; - sortBy(list: IList, iterator?: any, context?: any): any; - groupBy(list: IList, iterator: any): any; - countBy(list: IList, iterator: any): any; - shuffle(list: any[]): any[]; - toArray(list: any): any[]; - size(list: any): number; - - /**** - Arrays - *****/ - first(array: IList, n?: number): any; - head(array: IList, n?: number): any; - take(array: IList, n?: number): any; - - initial(array: IList, n?: number): any[]; - - last(array: IList, n?: number): any; - - rest(array: IList, n?: number): any[]; - tail(array: IList, n?: number): any[]; - drop(array: IList, n?: number): any[]; - - compact(array: any[]): any[]; - flatten(array: IList, shallow?: bool): any[]; - without(array: IList, ...values: any[]): any[]; - union(...arrays: any[][]): any[]; - intersection(...arrays: any[][]): any[]; - difference(array: IList, ...others: any[][]): any[]; - - uniq(array: IList, isSorted?: bool, iterator?: any): any[]; - unique(array: IList, isSorted?: bool, iterator?: any): any[]; - - zip(...arrays: any[]): any[]; - object(list: IList, values: any[]): any; - indexOf(array: IList, value: any, isSorted?: bool): number; - lastIndexOf(array: IList, value: any, fromIndex?: number): number; - sortedIndex(list: IList, valueL: any, iterator?: any): number; - range(stop: number): any[]; - range(start: number, stop: number, step?: number): any[]; - - /**** - Functions - *****/ - bind(func: (...as : any[]) => any, context: any, ...arguments: any[]): () => any; - bindAll(object: any, ...methodNames: string[]): any; - memoize(func: any, hashFunction?: any): any; - defer(func: () => any); - delay(func: any, wait: number, ...arguments: any[]): any; - delay(func: any, ...arguments: any[]): any; - throttle(func: any, wait: number): any; - debounce(func: any, wait: number, immediate?: bool): any; - once(func: any): any; - after(count: number, func: any): any; - wrap(func: (...as : any[]) => any, wrapper: any): () => any; - compose(...functions: any[]): any; - - /**** - Objects - *****/ - keys(object: any): any[]; - values(object: any): any[]; - pairs(object: any): any[]; - invert(object: any): any; - - functions(object: any): string[]; - methods(object: any): string[]; - - extend(destination: any, ...sources: any[]): any; - pick(object: any, ...keys: string[]): any; - omit(object: any, ...keys: string[]): any; - defaults(object: any, ...defaults: any[]): any; - clone(object: any): any; - tap(object: any, interceptor: (...as : any[]) => any): any; - has(object: any, key: string): bool; - isEqual(object: any, other: any): bool; - isEmpty(object: any): bool; - isElement(object: any): bool; - isArray(object: any): bool; - isObject(value: any): bool; - isArguments(object: any): bool; - isFunction(object: any): bool; - isString(object: any): bool; - isNumber(object: any): bool; - isFinite(object: any): bool; - isBoolean(object: any): bool; - isDate(object: any): bool; - isRegExp(object: any): bool; - isNaN(object: any): bool; - isNull(object: any): bool; - isUndefined(value: any): bool; - - /**** - Utility - *****/ - noConflict(): any; - identity(value: any): any; - times(n: number, iterator: (index : number) => void, context?: any): void; - random(min: number, max: number): number; - mixin(object: any): void; - uniqueId(prefix: string): string; - uniqueId(): number; - escape(str: string): string; - result(object: any, property: string): any; - templateSettings: TemplateSettings; - template(templateString: string, data?: any, settings?: any): (...data: any[]) => string; - - /**** - Chaining - *****/ - chain(object: any): UnderscoreWrappedObject; -} - +// Type definitions for Underscore 1.4 +// Project: http://underscorejs.org/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface UnderscoreWrappedObject { + value () : any; +} + +interface TemplateSettings { + evaluate?: RegExp; + interpolate?: RegExp; + escape?: RegExp; +} + +interface ListIterator { + (value, key, list?): void; +} + +interface ObjectIterator { + (element, index, list?): void; +} + +// Common interface between Arrays and jQuery objects +interface List { + [index: number]: any; + length: number; +} + +interface UnderscoreStatic { + + /**** + Collections + *****/ + each(list: List, iterator: ListIterator, context?: any): any[]; + each(object: any, iterator: ObjectIterator, context?: any): any[]; + forEach(list: List, iterator: ObjectIterator, context?: any): any[]; + forEach(object: any, iterator: ListIterator, context?: any): any[]; + + map(list: List, iterator: ListIterator, context?: any): any[]; + map(object: any, iterator: ObjectIterator, context?: any): any[]; + collect(list: List, iterator: ListIterator, context?: any): any[]; + collect(object: any, iterator: ObjectIterator, context?: any): any[]; + + reduce(list: List, iterator: any, memo: any, context?: any): any[]; + inject(list: List, iterator: any, memo: any, context?: any): any[]; + foldl(list: List, iterator: any, memo: any, context?: any): any[]; + + reduceRight(list: List, iterator: any, memo: any, context?: any): any[]; + foldr(list: List, iterator: any, memo: any, context?: any): any[]; + + find(list: List, iterator: any, context?: any): any; + detect(list: List, iterator: any, context?: any): any; + + filter(list: List, iterator: any, context?: any): any[]; + select(list: List, iterator: any, context?: any): any[]; + + where(list: List, properties: any): any[]; + + reject(list: List, iterator: any, context?: any): any[]; + + all(list: List, iterator: any, context?: any): bool; + every(list: List, iterator: any, context?: any): bool; + + any(list: List, iterator?: any, context?: any): bool; + some(list: List, iterator?: any, context?: any): bool; + + contains(list: any, value: any): bool; + contains(list: List, value: any): bool; + include(list: any, value: any): bool; + include(list: List, value: any): bool; + + invoke(list: List, methodName: string, arguments: any[]): any; + invoke(object: any, methodName: string, ...arguments: any[]): any; + + pluck(list: List, propertyName: string): string[]; + max(list: List, iterator?: any, context?: any): any; + min(list: List, iterator?: any, context?: any): any; + sortBy(list: List, iterator?: any, context?: any): any; + groupBy(list: List, iterator: any): any; + countBy(list: List, iterator: any): any; + shuffle(list: any[]): any[]; + toArray(list: any): any[]; + size(list: any): number; + + /**** + Arrays + *****/ + first(array: List, n?: number): any; + head(array: List, n?: number): any; + take(array: List, n?: number): any; + + initial(array: List, n?: number): any[]; + + last(array: List, n?: number): any; + + rest(array: List, n?: number): any[]; + tail(array: List, n?: number): any[]; + drop(array: List, n?: number): any[]; + + compact(array: any[]): any[]; + flatten(array: List, shallow?: bool): any[]; + without(array: List, ...values: any[]): any[]; + union(...arrays: any[][]): any[]; + intersection(...arrays: any[][]): any[]; + difference(array: List, ...others: any[][]): any[]; + + uniq(array: List, isSorted?: bool, iterator?: any): any[]; + unique(array: List, isSorted?: bool, iterator?: any): any[]; + + zip(...arrays: any[]): any[]; + object(list: List, values: any[]): any; + indexOf(array: List, value: any, isSorted?: bool): number; + lastIndexOf(array: List, value: any, fromIndex?: number): number; + sortedIndex(list: List, valueL: any, iterator?: any): number; + range(stop: number): any[]; + range(start: number, stop: number, step?: number): any[]; + + /**** + Functions + *****/ + bind(func: (...as : any[]) => any, context: any, ...arguments: any[]): () => any; + bindAll(object: any, ...methodNames: string[]): any; + memoize(func: any, hashFunction?: any): any; + defer(func: () => any); + delay(func: any, wait: number, ...arguments: any[]): any; + delay(func: any, ...arguments: any[]): any; + throttle(func: any, wait: number): any; + debounce(func: any, wait: number, immediate?: bool): any; + once(func: any): any; + after(count: number, func: any): any; + wrap(func: (...as : any[]) => any, wrapper: any): () => any; + compose(...functions: any[]): any; + + /**** + Objects + *****/ + keys(object: any): any[]; + values(object: any): any[]; + pairs(object: any): any[]; + invert(object: any): any; + + functions(object: any): string[]; + methods(object: any): string[]; + + extend(destination: any, ...sources: any[]): any; + pick(object: any, ...keys: string[]): any; + omit(object: any, ...keys: string[]): any; + defaults(object: any, ...defaults: any[]): any; + clone(object: any): any; + tap(object: any, interceptor: (...as : any[]) => any): any; + has(object: any, key: string): bool; + isEqual(object: any, other: any): bool; + isEmpty(object: any): bool; + isElement(object: any): bool; + isArray(object: any): bool; + isObject(value: any): bool; + isArguments(object: any): bool; + isFunction(object: any): bool; + isString(object: any): bool; + isNumber(object: any): bool; + isFinite(object: any): bool; + isBoolean(object: any): bool; + isDate(object: any): bool; + isRegExp(object: any): bool; + isNaN(object: any): bool; + isNull(object: any): bool; + isUndefined(value: any): bool; + + /**** + Utility + *****/ + noConflict(): any; + identity(value: any): any; + times(n: number, iterator: (index : number) => void, context?: any): void; + random(min: number, max: number): number; + mixin(object: any): void; + uniqueId(prefix: string): string; + uniqueId(): number; + escape(str: string): string; + result(object: any, property: string): any; + templateSettings: TemplateSettings; + template(templateString: string, data?: any, settings?: any): (...data: any[]) => string; + + /**** + Chaining + *****/ + chain(object: any): UnderscoreWrappedObject; +} + declare var _: UnderscoreStatic; \ No newline at end of file From 725600bda76e41d0179022869f9f8987d63da5bc Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Sat, 26 Jan 2013 17:29:07 +0000 Subject: [PATCH 016/248] Update d3 definition --- d3/d3-tests.ts | 102 ++++++++++++++++++++++++++++++++++++++++++++++++- d3/d3.d.ts | 84 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 184 insertions(+), 2 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 5990b92d8a..36ac355fe8 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -26,4 +26,104 @@ d3.select("body").transition() d3.selectAll("circle").transition() .duration(750) .delay(function (d, i) { return i * 10; }) - .attr("r", function (d) { return Math.sqrt(d * scale); }); \ No newline at end of file + .attr("r", function (d) { return Math.sqrt(d * scale); }); + +function testOrdinalScale() { + var x = d3.scale.ordinal().range(["foo", "bar"]); + x.domain([0, 1]); + var result = x(0); + + var x = d3.scale.ordinal().domain(["a", "b", "c"]).rangePoints([120, 0]); + var x = d3.scale.ordinal().domain(["a", "b", "c"]).rangePoints([120, 0], 1); + + var x = d3.scale.ordinal().domain(["a", "b", "c"]).rangeBands([120, 0]); + var x = d3.scale.ordinal().domain(["a", "b", "c"]).rangeBands([120, 0], .2); + var x = d3.scale.ordinal().domain(["a", "b", "c"]).rangeBands([120, 0], .2, .1); + + var x = d3.scale.ordinal().domain(["a", "b", "c"]).rangeRoundBands([0, 100]); + var x = d3.scale.ordinal().domain(["a", "b", "c"]).rangeRoundBands([0, 100], .2); + var x = d3.scale.ordinal().domain(["a", "b", "c"]).rangeRoundBands([120, 0], .2, .1); +} + + +function testKeys() { + var x = d3.keys({ a: 1, b: 1 }); + + function abc() { + this.a = 1; + this.b = 2; + } + var x = d3.keys(new abc()); +} + +function testSVGArc() { + var a = d3.svg.arc().innerRadius(100).outerRadius(200); + var a = d3.svg.arc().outerRadius(100).startAngle(0).endAngle(Math.PI); + + var f = function () => { + return 42; + } + var a = d3.svg.arc().innerRadius(0).outerRadius(f).startAngle(f).endAngle(f() * 2) + + var str = a(); + var str = a({ outerRadius: 50 }); + var str = a.outerRadius(100)(); + var str = a.endAngle(Math.PI / 2)() + var str = a({ startAngle: Math.PI / 2 }); + + var c = d3.svg.arc().innerRadius(0).outerRadius(100).startAngle(0).endAngle(2 * Math.PI).centroid(); + var num = c[0]; +} + +function testPieLayout() { + var p = d3.layout.pie().sort(null).value(function (d) { return d.value; }); + var data = [1, 2, 3, 4]; + var arcs = p(data); +} + +//Example from http://bl.ocks.org/3887235 +function testPieChart() { + var width = 960, + height = 500, + radius = Math.min(width, height) / 2; + + var color = d3.scale.ordinal() + .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); + + var arc = d3.svg.arc() + .outerRadius(radius - 10) + .innerRadius(0); + + var pie = d3.layout.pie() + .sort(null) + .value(function (d) { return d.population; }); + + var svg = d3.select("body").append("svg") + .attr("width", width) + .attr("height", height) + .append("g") + .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); + + d3.csv("data.csv", function (error, data) { + + data.forEach(function (d) { + d.population = +d.population; + }); + + var g = svg.selectAll(".arc") + .data(pie(data)) + .enter().append("g") + .attr("class", "arc"); + + g.append("path") + .attr("d", arc) + .style("fill", function (d) { return color(d.data.age); }); + + g.append("text") + .attr("transform", function (d) { return "translate(" + arc.centroid(d) + ")"; }) + .attr("dy", ".35em") + .style("text-anchor", "middle") + .text(function (d) { return d.data.age; }); + + }); +} diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 081ae2d511..10b084d8c6 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -53,7 +53,7 @@ interface ID3Base extends ID3Selectors { }; html: (url: string, callback: (response: DocumentFragment) => void) => void; csv: { - (url: string, callback: (response: any[]) => void); + (url: string, callback: (error: any, response: any[]) => void); parse(string: string): any[]; parseRows(string: string, accessor: (row: any[], index: number) => any): any; format(rows: any[]): string; @@ -62,6 +62,11 @@ interface ID3Base extends ID3Selectors { time: ID3Time; scale: { linear(): ID3LinearScale; + ordinal(): ID3OrdinalScale; + category10(): ID3OrdinalScale; + category20(): ID3OrdinalScale; + category20b(): ID3OrdinalScale; + category20c(): ID3OrdinalScale; }; interpolate: ID3BaseInterpolate; interpolateNumber: ID3BaseInterpolate; @@ -75,6 +80,7 @@ interface ID3Base extends ID3Selectors { layout: ID3Layout; svg: ID3Svg; random: ID3Random; + keys(map: Object): any[]; } interface ID3Selection extends ID3Selectors { @@ -220,6 +226,21 @@ interface ID3LinearScale { copy: ID3LinearScale; } +interface ID3OrdinalScale { + (value: any): any; + domain(values: any[]): ID3OrdinalScale; + range: { + (values: any[]): ID3OrdinalScale; + (): any[]; + }; + rangePoints(interval: any[], padding?: number): ID3OrdinalScale; + rangeBands(interval: any[], padding?: number, outerPadding?: number): ID3OrdinalScale; + rangeRoundBands(interval: any[], padding?: number, outerPadding?: number): ID3OrdinalScale; + rangeBand(): any[]; + rangeExtent(): any[]; + copy: ID3OrdinalScale; +} + interface ID3TimeScale { (value: Date): number; invert(value: number): Date; @@ -255,6 +276,7 @@ interface ID3Interpolate { interface ID3Layout { stack(): ID3StackLayout; + pie(): ID3PieLayout; } interface ID3StackLayout { @@ -263,7 +285,34 @@ interface ID3StackLayout { offset(offset: string): ID3StackLayout; } +interface ID3PieLayout { + (values: any[], index?: number): ID3ArcDescriptor[]; + value: { + (): (d: any, index: number) => number; + (accessor: (d: any, index: number) => number): ID3PieLayout; + }; + sort: { + (): (d1: any, d2: any) => number; + (comparator: (d1: any, d2: any) => number): ID3PieLayout; + }; + startAngle: { + (): number; + (angle: number): ID3SvgArc; + (angle: () => number): ID3SvgArc; + }; + endAngle: { + (): number; + (angle: number): ID3SvgArc; + (angle: () => number): ID3SvgArc; + }; +} +interface ID3ArcDescriptor { + value: any; + data: any; + startAngle: number; + endAngle: number; +} interface ID3SVGSymbol { @@ -274,6 +323,7 @@ interface ID3SVGSymbol interface ID3Svg { symbol: ()=> ID3SVGSymbol; axis(): ID3SvgAxis; + arc(): ID3SvgArc; } interface ID3SvgAxis { @@ -298,6 +348,38 @@ interface ID3SvgAxis { tickFormat(formatter: (value: any) => string): ID3SvgAxis; } +interface ID3SvgArc { + (options?: ID3SvgArcOptions): string; + innerRadius: { + (): number; + (radius: number): ID3SvgArc; + (radius: () => number): ID3SvgArc; + }; + outerRadius: { + (): number; + (radius: number): ID3SvgArc; + (radius: () => number): ID3SvgArc; + }; + startAngle: { + (): number; + (angle: number): ID3SvgArc; + (angle: () => number): ID3SvgArc; + }; + endAngle: { + (): number; + (angle: number): ID3SvgArc; + (angle: () => number): ID3SvgArc; + }; + centroid(options?: ID3SvgArcOptions): number[]; +} + +interface ID3SvgArcOptions { + innerRadius?: number; + outerRadius?: number; + startAngle?: number; + endAngle?: number; +} + interface ID3Random { normal(mean?: number, deviation?: number): () => number; } From 026932eeab40ba582e80e0879d2422f460a18be7 Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Sat, 26 Jan 2013 19:44:41 -0200 Subject: [PATCH 017/248] Definitions for jquery.clientSideLogging #218 --- README.md | 1 + .../jquery.clientSideLogging-tests.ts | 24 +++++++++++++++++++ .../jquery.clientSideLogging.d.ts | 24 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 jquery.clientSideLogging/jquery.clientSideLogging-tests.ts create mode 100644 jquery.clientSideLogging/jquery.clientSideLogging.d.ts diff --git a/README.md b/README.md index 307fa2d836..d177de5abf 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ List of Definitions * [jQuery UI](http://jqueryui.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [jQuery.BBQ](http://benalman.com/projects/jquery-bbq-plugin/) (by [Adam R. Smith](https://github.com/sunetos)) * [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/)) +* [jQuery.clientSideLogging](https://github.com/remybach/jQuery.clientSideLogging/) (by [Diullei Gomes](https://github.com/diullei/)) * [jQuery.Cookie](https://github.com/carhartl/jquery-cookie) (by [Roy Goode](https://github.com/RoyGoode)) * [jQuery.dynatree](http://code.google.com/p/dynatree/) (by [Franois de Campredon](https://github.com/fdecampredon)) * [jQuery.Flot](http://www.flotcharts.org/) (by [Matt Burland](https://github.com/burlandm)) diff --git a/jquery.clientSideLogging/jquery.clientSideLogging-tests.ts b/jquery.clientSideLogging/jquery.clientSideLogging-tests.ts new file mode 100644 index 0000000000..a4abf87bba --- /dev/null +++ b/jquery.clientSideLogging/jquery.clientSideLogging-tests.ts @@ -0,0 +1,24 @@ +/// + +interface JQueryStatic { + info: (what?: any) => any; + error: (what?: any) => any; + log: (what?: any) => any; + clientSideLogging: (options: ClientSideLoggingObject) => any; +} + +$.clientSideLogging({ + log_level: 3, + client_info: { + location:true, + screen_size:true, + user_agent:true, + window_size:false + } +}); + +$.info({msg:$(this).parents('li').find('input:text').val()}); +$.error({msg:$(this).parents('li').find('input:text').val()}); +$.log($(this).parents('li').find('input:text').val()); + +$.post('/log?type=error&msg=YOUR_ERROR_MESSAGE'); \ No newline at end of file diff --git a/jquery.clientSideLogging/jquery.clientSideLogging.d.ts b/jquery.clientSideLogging/jquery.clientSideLogging.d.ts new file mode 100644 index 0000000000..6ea97ef106 --- /dev/null +++ b/jquery.clientSideLogging/jquery.clientSideLogging.d.ts @@ -0,0 +1,24 @@ +// Type definitions for jquery.clientSideLogging. +// Project: https://github.com/remybach/jQuery.clientSideLogging +// Definitions by: Diullei Gomes +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface ClientSideLoggingClientInfoObject { + location?: bool; // The url to the page on which the error occurred. + screen_size?: bool; // The size of the user's screen (different to the window size because the window might not be maximized) + user_agent?: bool; // The user agent string. + window_size?: bool; // The window size. +} + +interface ClientSideLoggingObject { + error_url?: string; // The url to which errors logs are sent + info_url?: string; // The url to which info logs are sent + log_url?: string; // The url to which standard logs are sent + log_level?: number; // The level at which to log. This allows you to keep the calls to the logging in your code and just change this variable to log varying degrees. 1 = only error, 2 = error & log, 3 = error, log & info + native_error?: bool; // Whether or not to send native js errors as well (using window.onerror). + hijack_console?: bool; // Hijacks the default console functionality (ie: all your console.error/info/log are belong to us). + query_var?: string; // The variable to send the log message through as. + client_info?: ClientSideLoggingClientInfoObject; // Configuration for what info about the client's browser is logged. +} From 14aa278bad06d54f1a5cd4a17d3582b325c03693 Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Sat, 26 Jan 2013 19:46:12 -0200 Subject: [PATCH 018/248] Definitions for jquery.clientSideLogging #218 --- jquery.clientSideLogging/jquery.clientSideLogging-tests.ts | 7 ------- jquery.clientSideLogging/jquery.clientSideLogging.d.ts | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jquery.clientSideLogging/jquery.clientSideLogging-tests.ts b/jquery.clientSideLogging/jquery.clientSideLogging-tests.ts index a4abf87bba..35974af26a 100644 --- a/jquery.clientSideLogging/jquery.clientSideLogging-tests.ts +++ b/jquery.clientSideLogging/jquery.clientSideLogging-tests.ts @@ -1,12 +1,5 @@ /// -interface JQueryStatic { - info: (what?: any) => any; - error: (what?: any) => any; - log: (what?: any) => any; - clientSideLogging: (options: ClientSideLoggingObject) => any; -} - $.clientSideLogging({ log_level: 3, client_info: { diff --git a/jquery.clientSideLogging/jquery.clientSideLogging.d.ts b/jquery.clientSideLogging/jquery.clientSideLogging.d.ts index 6ea97ef106..d2031029e4 100644 --- a/jquery.clientSideLogging/jquery.clientSideLogging.d.ts +++ b/jquery.clientSideLogging/jquery.clientSideLogging.d.ts @@ -22,3 +22,10 @@ interface ClientSideLoggingObject { query_var?: string; // The variable to send the log message through as. client_info?: ClientSideLoggingClientInfoObject; // Configuration for what info about the client's browser is logged. } + +interface JQueryStatic { + info: (what?: any) => any; + error: (what?: any) => any; + log: (what?: any) => any; + clientSideLogging: (options: ClientSideLoggingObject) => any; +} From dd54130b8e4cb18768da0c2f00ed96b4296bbed6 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Sun, 27 Jan 2013 17:30:56 -0500 Subject: [PATCH 019/248] Update definitions. --- jsoneditoronline/jsoneditoronline.d.ts | 65 +++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/jsoneditoronline/jsoneditoronline.d.ts b/jsoneditoronline/jsoneditoronline.d.ts index 9bbb71440e..0b441bdf15 100644 --- a/jsoneditoronline/jsoneditoronline.d.ts +++ b/jsoneditoronline/jsoneditoronline.d.ts @@ -23,6 +23,17 @@ class JSONEditorHistory { redo(): void; } +interface JSONEditorNodeUpdateDomOptions { + recurse?: bool; + updateIndexes?: bool; +} + +interface JSONEditorNodeType { + value: string; + className: string; + title: string; +} + class JSONEditorNode { constructor(editor: JSONEditor, params: Object); setParent(parent: JSONEditorNode): void; @@ -53,10 +64,44 @@ class JSONEditorNode { getDom(): HTMLElement; setHighlight(highlight: bool): void; updateValue(value: any): void; + updateField(field: string): void; + updateDom(options): void; + onEvent(event: Event): void; + types: JSONEditorNodeType[]; + getAppend(): HTMLElement; +} + +class JSONEditorAppendNode extends JSONEditorNode { + constructor(editor: JSONEditor); +} + +interface JSONEditorShowDropDownListParams { + x: number; + y: number; + node: JSONEditorNode; + value: string; + values: Object[]; + optionSelectedClassName: string; + optionClassName: string; + callback: (value: any) => void; +} + +class JSONEditorSearchBox { + constructor(editor: JSONEditor, container: HTMLElement); + next(): void; + previous: void; + setActiveResult(index: number): void; + focusActiveResult(): void; + clearDelay(): void; + onDelayedSearch(event: Event): void; + onSearch(event: Event, forcedSearch: bool): void; + onKeyDown(event: Event): void; + onKeyUp(event: Event): void; + } class JSONEditor { - constructor(container: HTMLElement, options?: JSONEditorOptions, json?: Object); + constructor(container: HTMLElement, options?: JSONEditorOptions, json?: any); set(json: Object, name?: string): void; setName(name?: string): void; get(): Object; @@ -69,6 +114,14 @@ class JSONEditor { focus(): void; scrollTo(top: number): void; History: JSONEditorHistory; + Node: JSONEditorNode; + SearchBox: JSONEditorSearchBox; + showDropDownList(): void; + getNodeFromTarget(target: HTMLElement): JSONEditorNode; + Events: { + addEventListener(element: HTMLElement, action: string, ) + }; + } interface JSONFormatterOptions { @@ -77,10 +130,10 @@ interface JSONFormatterOptions { } class JSONFormatter { - constructor(container: HTMLElement, options?: JSONFormatterOptions, json?: Object); - constructor(container: HTMLElement, options?: JSONFormatterOptions, json?: string); - set(json: JSON); - get(): JSON; - setText(jsonString: string); + constructor(container: HTMLElement, options?: JSONFormatterOptions, json?: any); + set(json: Object); + get(): Object; + setText(jsonString: string): void; getText(): string; + onError(err: string): void; } \ No newline at end of file From 79ae0efebf40a2d02d5954ad8eca51bd4a7412d3 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Mon, 28 Jan 2013 01:55:24 -0500 Subject: [PATCH 020/248] Finish initial creation --- jsoneditoronline/jsoneditoronline-tests.ts | 4 +- jsoneditoronline/jsoneditoronline.d.ts | 55 +++++++++++++++++++--- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/jsoneditoronline/jsoneditoronline-tests.ts b/jsoneditoronline/jsoneditoronline-tests.ts index 37cf0d2cab..a5afd2c6cc 100644 --- a/jsoneditoronline/jsoneditoronline-tests.ts +++ b/jsoneditoronline/jsoneditoronline-tests.ts @@ -18,7 +18,7 @@ var json = { editor.set(json); editor.expandAll(); -var jsonResult:JSON = editor.get(); +var jsonResult:any = editor.get(); var options2: JSONFormatterOptions = { "indentation": 2 @@ -34,4 +34,4 @@ var json2 = { }; formatter.set(json2); -var jsonResult2:JSON = formatter.get(json2); \ No newline at end of file +var jsonResult2:any = formatter.get(json2); \ No newline at end of file diff --git a/jsoneditoronline/jsoneditoronline.d.ts b/jsoneditoronline/jsoneditoronline.d.ts index 0b441bdf15..7bdacf0ac7 100644 --- a/jsoneditoronline/jsoneditoronline.d.ts +++ b/jsoneditoronline/jsoneditoronline.d.ts @@ -34,8 +34,14 @@ interface JSONEditorNodeType { title: string; } +interface JSONEditorConstructorParams { + field?: string; + fieldEditable?: bool; + value?: any; +} + class JSONEditorNode { - constructor(editor: JSONEditor, params: Object); + constructor(editor: JSONEditor, params: JSONEditorConstructorParams); setParent(parent: JSONEditorNode): void; getParent(): JSONEditorNode; setField(field: string, fieldEditable: bool): void; @@ -89,7 +95,7 @@ interface JSONEditorShowDropDownListParams { class JSONEditorSearchBox { constructor(editor: JSONEditor, container: HTMLElement); next(): void; - previous: void; + previous(): void; setActiveResult(index: number): void; focusActiveResult(): void; clearDelay(): void; @@ -97,7 +103,27 @@ class JSONEditorSearchBox { onSearch(event: Event, forcedSearch: bool): void; onKeyDown(event: Event): void; onKeyUp(event: Event): void; +} +interface JSONEditorBuffer { + text: string; + flush(): string; + set(text: string): void; +} + +interface JSONEditorActionParams { + node?: JSONEditorNode; + oldValue?: string; + newValue?: string; + startParent?: JSONEditorNode; + endParent?: JSONEditorNode; + startIndex?: number; + endIndex?: number; + clone?: JSONEditorNode; + parent?: JSONEditorNode; + index?: number; + oldType?: JSONEditorNodeType; + newType?: JSONEditorNodeType; } class JSONEditor { @@ -110,18 +136,33 @@ class JSONEditor { search(text: string): any[]; expandAll(): void; collapseAll(): void; - onAction(action: string, params: Object); + onAction(action: string, params: JSONEditorActionParams); focus(): void; scrollTo(top: number): void; History: JSONEditorHistory; Node: JSONEditorNode; SearchBox: JSONEditorSearchBox; - showDropDownList(): void; - getNodeFromTarget(target: HTMLElement): JSONEditorNode; + static focusNode: JSONEditorNode; + static freezeHighlight: bool; + static showDropDownList(params): void; + static getNodeFromTarget(target: HTMLElement): JSONEditorNode; + static getAbsoluteLeft(elem: HTMLElement): number; + static getAbsoluteTop(elem: HTMLElement); number; + static addClassName(elem: HTMLElement, className: string): void; + static removeClassName(elem: HTMLElement, className: string): void; + static stripFormatting(divElement: HTMLElement): void; + static setEndOfContentEditable(contentEditableElement: HTMLElement): void; + static getInnerText(element: HTMLElement, buffer: JSONEditorBuffer): string; + static getInternetExplorerVersion(): number; Events: { - addEventListener(element: HTMLElement, action: string, ) - }; + addEventListener(element: HTMLElement, action: string, listener:(event?: Event) => void, useCapture:bool): (event?: Event) => void; + removeEventListener(element: HTMLElement, action: string, listener:(event?: Event) => void, useCapture:bool): void; + stopPropagation(event: Event): void; + preventDefault(event:Event): void; + }; + static parse(jsonString: string): Object; + static validate(jsonString: string): string; } interface JSONFormatterOptions { From c21d25465296fd97e6b9cbacd359d48b70c0e997 Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Tue, 29 Jan 2013 15:25:30 -0200 Subject: [PATCH 021/248] fix undesrscorejs test errors --- underscore/underscore-tests.ts | 15 +++++++++--- underscore/underscore.d.ts | 42 +++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 9a6769d1bf..c3ec6243fc 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -11,6 +11,7 @@ _.map({ one: 1, two: 2, three: 3 }, (num, key) => num * 3); var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0); var list = [[0, 1], [2, 3], [4, 5]]; + var flat = _.reduceRight(list, (a, b) => a.concat(b), []); var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); @@ -79,7 +80,7 @@ _.range(0); /////////////////////////////////////////////////////////////////////////////////////// -var func = function (greeting) { return greeting + ': ' + this.name }; +var func = function (greeting?) { return greeting + ': ' + this.name }; func = _.bind(func, { name: 'moe' }, 'hi'); func(); @@ -118,7 +119,7 @@ var render = () => alert("rendering..."); var renderNotes = _.after(notes.length, render); _.each(notes, (note) => note.asyncSave({ success: renderNotes })); -var hello = function (name) { return "hello: " + name; }; +var hello = function (name?) { return "hello: " + name; }; hello = _.wrap(hello, (func) => { return "before, " + func("moe") + ", after"; }); hello(); @@ -194,7 +195,7 @@ _.isNaN(undefined); _.isNull(null); _.isNull(undefined); -_.isUndefined(window.missingVariable); +_.isUndefined((window).missingVariable); /////////////////////////////////////////////////////////////////////////////////////// @@ -238,3 +239,11 @@ _.templateSettings = { var template2 = _.template("Hello {{ name }}!"); template2({ name: "Mustache" }); _.template("Using 'with': <%= data.answer %>", { answer: 'no' }, { variable: 'data' }); + +// fix: http://stackoverflow.com/questions/14585324/how-to-use-underscore-lib-from-definitelytyped-with-typescript +// fix: https://github.com/borisyankov/DefinitelyTyped/issues/225 +declare var _: UnderscoreStatic; + +_.countBy([1,2,3], function(item) { + return item%2; +}); \ No newline at end of file diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 1c725f019a..8119139580 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -6,6 +6,7 @@ interface UnderscoreWrappedObject { value () : any; + filter(arg?) : any; } interface TemplateSettings { @@ -29,6 +30,7 @@ interface List { } interface UnderscoreStatic { + (arg?:any) : any; /**** Collections @@ -44,27 +46,42 @@ interface UnderscoreStatic { collect(object: any, iterator: ObjectIterator, context?: any): any[]; reduce(list: List, iterator: any, memo: any, context?: any): any[]; + reduce(list: any[], iterator: any, memo: any, context?: any): any[]; inject(list: List, iterator: any, memo: any, context?: any): any[]; + inject(list: any[], iterator: any, memo: any, context?: any): any[]; foldl(list: List, iterator: any, memo: any, context?: any): any[]; + foldl(list: any[], iterator: any, memo: any, context?: any): any[]; reduceRight(list: List, iterator: any, memo: any, context?: any): any[]; + reduceRight(list: any[], iterator: any, memo: any, context?: any): any[]; foldr(list: List, iterator: any, memo: any, context?: any): any[]; + foldr(list: any[], iterator: any, memo: any, context?: any): any[]; find(list: List, iterator: any, context?: any): any; + find(list: any[], iterator: any, context?: any): any; detect(list: List, iterator: any, context?: any): any; + detect(list: any[], iterator: any, context?: any): any; filter(list: List, iterator: any, context?: any): any[]; + filter(list: any[], iterator: any, context?: any): any[]; select(list: List, iterator: any, context?: any): any[]; + select(list: any[], iterator: any, context?: any): any[]; where(list: List, properties: any): any[]; + where(list: any[], properties: any): any[]; reject(list: List, iterator: any, context?: any): any[]; + reject(list: any[], iterator: any, context?: any): any[]; all(list: List, iterator: any, context?: any): bool; + all(list: any[], iterator: any, context?: any): bool; every(list: List, iterator: any, context?: any): bool; + every(list: any[], iterator: any, context?: any): bool; any(list: List, iterator?: any, context?: any): bool; + any(list: any[], iterator?: any, context?: any): bool; some(list: List, iterator?: any, context?: any): bool; + some(list: any[], iterator?: any, context?: any): bool; contains(list: any, value: any): bool; contains(list: List, value: any): bool; @@ -75,11 +92,17 @@ interface UnderscoreStatic { invoke(object: any, methodName: string, ...arguments: any[]): any; pluck(list: List, propertyName: string): string[]; + pluck(list: any[], propertyName: string): string[]; max(list: List, iterator?: any, context?: any): any; + max(list: any[], iterator?: any, context?: any): any; min(list: List, iterator?: any, context?: any): any; + min(list: any[], iterator?: any, context?: any): any; sortBy(list: List, iterator?: any, context?: any): any; + sortBy(list: any[], iterator?: any, context?: any): any; groupBy(list: List, iterator: any): any; + groupBy(list: any[], iterator: any): any; countBy(list: List, iterator: any): any; + countBy(list: any[], iterator: any): any; shuffle(list: any[]): any[]; toArray(list: any): any[]; size(list: any): number; @@ -88,32 +111,49 @@ interface UnderscoreStatic { Arrays *****/ first(array: List, n?: number): any; + first(array: any[], n?: number): any; head(array: List, n?: number): any; + head(array: any[], n?: number): any; take(array: List, n?: number): any; + take(array: any[], n?: number): any; initial(array: List, n?: number): any[]; + initial(array: any[], n?: number): any[]; last(array: List, n?: number): any; + last(array: any[], n?: number): any; rest(array: List, n?: number): any[]; + rest(array: any[], n?: number): any[]; tail(array: List, n?: number): any[]; + tail(array: any[], n?: number): any[]; drop(array: List, n?: number): any[]; + drop(array: any[], n?: number): any[]; compact(array: any[]): any[]; flatten(array: List, shallow?: bool): any[]; + flatten(array: any[], shallow?: bool): any[]; without(array: List, ...values: any[]): any[]; + without(array: any[], ...values: any[]): any[]; union(...arrays: any[][]): any[]; intersection(...arrays: any[][]): any[]; difference(array: List, ...others: any[][]): any[]; + difference(array: any[], ...others: any[][]): any[]; uniq(array: List, isSorted?: bool, iterator?: any): any[]; + uniq(array: any[], isSorted?: bool, iterator?: any): any[]; unique(array: List, isSorted?: bool, iterator?: any): any[]; + unique(array: any[], isSorted?: bool, iterator?: any): any[]; zip(...arrays: any[]): any[]; - object(list: List, values: any[]): any; + object(list: List, values?: any[]): any; + object(list: any[], values?: any[]): any; indexOf(array: List, value: any, isSorted?: bool): number; + indexOf(array: any[], value: any, isSorted?: bool): number; lastIndexOf(array: List, value: any, fromIndex?: number): number; + lastIndexOf(array: any[], value: any, fromIndex?: number): number; sortedIndex(list: List, valueL: any, iterator?: any): number; + sortedIndex(list: any[], valueL: any, iterator?: any): number; range(stop: number): any[]; range(start: number, stop: number, step?: number): any[]; From 2d5a41f4d8c6fb8d160fb4ac5633977d600efa4a Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Wed, 30 Jan 2013 03:59:15 +0200 Subject: [PATCH 022/248] Add defintions and tests for EpicEditor --- README.md | 1 + epiceditor/epiceditor-tests.ts | 79 ++++++++++++++++++++++++++++++++++ epiceditor/epiceditor.d.ts | 61 ++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 epiceditor/epiceditor-tests.ts create mode 100644 epiceditor/epiceditor.d.ts diff --git a/README.md b/README.md index d177de5abf..cf41e9acd2 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ List of Definitions * [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton)) * [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [Express](http://expressjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [Fabric.js](http://fabricjs.com/) (by [Oliver Klemencic](https://github.com/oklemencic/)) * [Fancybox](http://fancybox.net/) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/epiceditor/epiceditor-tests.ts b/epiceditor/epiceditor-tests.ts new file mode 100644 index 0000000000..ed02371fab --- /dev/null +++ b/epiceditor/epiceditor-tests.ts @@ -0,0 +1,79 @@ +/// + +var editor = new EpicEditor().load(); + +editor.load(function () { + console.log("Editor loaded.") +}); + +editor.unload(function () { + console.log("Editor unloaded.") +}); + +editor.getElement('editor').body.innerHTML; + +if (editor.is('loaded')) + editor.enterFullscreen(); + +editor.open('some-file'); +editor.importFile('some-file', "#Imported markdown\nFancy, huh?"); +var theContent = editor.exportFile(); + +var newName = prompt('What do you want to rename this file to?'); +editor.rename('old-filename.md', newName); + +editor.save(); +editor.remove('example.md'); +var files = editor.getFiles(); + +editor.on('unload', function () { + console.log('Editor was removed'); +}); + +editor.emit('unload'); + +editor.removeListener('unload'); + +editor.preview(); + +editor.edit(); + +editor.enterFullscreen(); + +editor.exitFullscreen(); + +editor.reflow(); +editor.reflow('height'); + +var marked; +var opts = { + container: 'epiceditor', + textarea: null, + basePath: 'epiceditor', + clientSideStorage: true, + localStorageName: 'epiceditor', + useNativeFullsreen: true, + parser: marked, + file: { + name: 'epiceditor', + defaultContent: '', + autoSave: 100 + }, + theme: { + base: '/themes/base/epiceditor.css', + preview: '/themes/preview/preview-dark.css', + editor: '/themes/editor/epic-dark.css' + }, + focusOnLoad: false, + shortcut: { + modifier: 18, + fullscreen: 70, + preview: 80 + }, + string: { + togglePreview: 'Toggle Preview Mode', + toggleEdit: 'Toggle Edit Mode', + toggleFullscreen: 'Enter Fullscreen' + } +} +var editor2 = new EpicEditor(opts); diff --git a/epiceditor/epiceditor.d.ts b/epiceditor/epiceditor.d.ts new file mode 100644 index 0000000000..7030923f2e --- /dev/null +++ b/epiceditor/epiceditor.d.ts @@ -0,0 +1,61 @@ +// Type definitions for EpicEditor 0.2 +// Project: http://epiceditor.com/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface EpicEditorOptions { + container?: any; + textarea?: any; + basePath?: string; + clientSideStorage?: bool; + localStorageName?: string; + useNativeFullsreen?: bool; + parser?: any; + file?: { + name: string; + defaultContent: string; + autoSave: any; + }; + theme?: { + base: string; + preview: string; + editor: string; + }; + focusOnLoad?: bool; + shortcut?: { + modifier: number; + fullscreen: number; + preview: number; + }; + string?: { + togglePreview: string; + toggleEdit: string; + toggleFullscreen: string; + }; +} + +class EpicEditor { + constructor(); + constructor(options: EpicEditorOptions); + + load(callback?: Function): EpicEditor; + unload(callback?: Function): EpicEditor; + getElement(element: string): any; + is(state: string): bool; + open(filename: string); + importFile(filename?: string, content?: string): void; + exportFile(filename?: string, type?: string): any; + rename(oldName: string, newName: string): void; + save(): void; + remove(filename: string): void; + getFiles(filename?: string): any; + on(event: string, handler: Function): void; + emit(event: string): void; + removeListener(event: string, handler?: Function): void; + preview(): void; + edit(): void; + enterFullscreen(): void; + exitFullscreen(): void; + reflow(type?: string): void; +} \ No newline at end of file From a00fd86b8df267fe4b3beb12bee6a783f18c970d Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Wed, 30 Jan 2013 00:48:16 -0200 Subject: [PATCH 023/248] Qunit definitions. I changed variable declarations for function declarations to allow overloading --- qunit/qunit.d.ts | 55 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/qunit/qunit.d.ts b/qunit/qunit.d.ts index a57d945f56..8fbb9ee667 100644 --- a/qunit/qunit.d.ts +++ b/qunit/qunit.d.ts @@ -114,43 +114,44 @@ interface QUnitStatic extends QUnitAssert{ } /* ASSERT */ -declare var deepEqual: (actual: any, expected: any, message?: string) => any; -declare var equal: (actual: any, expected: any, message?: string) => any; -declare var notDeepEqual: (actual: any, expected: any, message?: string) => any; -declare var notEqual: (actual: any, expected: any, message?: string) => any; -declare var notStrictEqual: (actual: any, expected: any, message?: string) => any; -declare var ok: (state: any, message?: string) => any; -declare var strictEqual: (actual: any, expected: any, message?: string) => any; -// ** I Can't make overload here! :(s -//declare var throws: (block: () => void, expected: Object, message: string) => any; -declare var throws: (block: () => void, expected?: any, message?: string) => any; +declare function deepEqual(actual: any, expected: any, message?: string); +declare function equal(actual: any, expected: any, message?: string); +declare function notDeepEqual(actual: any, expected: any, message?: string); +declare function notEqual(actual: any, expected: any, message?: string); +declare function notStrictEqual(actual: any, expected: any, message?: string); +declare function ok(state: any, message?: string); +declare function strictEqual(actual: any, expected: any, message?: string); +declare function throws(block: () => any, expected: any, message?: string); +declare function throws(block: () => any, message?: string); /* ASYNC CONTROL */ -declare var start: (decrement?: number) => any; -declare var stop: (increment? : number) => any; +declare function start(decrement?: number); +declare function stop(increment? : number); /* CALLBACKS */ -declare var begin: (callback: () => any) => any; -declare var done: (callback: (details: DoneCallbackObject) => any) => any; -declare var log: (callback: (details: LogCallbackObject) => any) => any; -declare var moduleDone: (callback: (details: ModuleDoneCallbackObject) => any) => any; -declare var moduleStart: (callback: (name: string) => any) => any; -declare var testDone: (callback: (details: TestDoneCallbackObject) => any) => any; -declare var testStart: (callback: (details: TestStartCallbackObject) => any) => any; +declare function begin(callback: () => any); +declare function done(callback: (details: DoneCallbackObject) => any); +declare function log(callback: (details: LogCallbackObject) => any); +declare function moduleDone(callback: (details: ModuleDoneCallbackObject) => any); +declare function moduleStart(callback: (name: string) => any); +declare function testDone(callback: (details: TestDoneCallbackObject) => any); +declare function testStart(callback: (details: TestStartCallbackObject) => any); /* TEST */ -declare var asyncTest: (name: string, expected?: any, test?: () => any) => any; -declare var expect: (amount: number) => any; +declare function asyncTest(name: string, expected?: any, test?: () => any); +declare function expect(amount: number); + // ** conflict with TypeScript module keyword. Must be used on QUnit namespace //declare var module: (name: string, lifecycle?: LifecycleObject) => any; -// ** I can't make an overload here! :( -//declare var test: (title: string, expected?: any, test?: (assert?: any) => any) => any; -declare var test: (title: string, test: (assert?: QUnitAssert) => any) => any; -declare var notPropEqual: (actual: any, expected: any, message?: string) => any; -declare var propEqual: (actual: any, expected: any, message?: string) => any; + +declare function test(title: string, expected: number, test: (assert?: QUnitAssert) => any); +declare function test(title: string, test: (assert?: QUnitAssert) => any); + +declare function notPropEqual(actual: any, expected: any, message?: string); +declare function propEqual(actual: any, expected: any, message?: string); // https://github.com/jquery/qunit/blob/master/qunit/qunit.js#L1568 -declare var equiv: (a: any, b: any) => any; +declare function equiv(a: any, b: any); // https://github.com/jquery/qunit/blob/master/qunit/qunit.js#L661 declare var raises: any; From f0ebef1bab3978d474049dc22c95e17f9164918c Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Wed, 30 Jan 2013 08:45:07 +0200 Subject: [PATCH 024/248] Fix for Jquery each method definition --- jquery/jquery.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 4f566454ac..3d5f8df14a 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -676,7 +676,7 @@ interface JQuery { /************* MISCELLANEOUS **************/ - each(func: (index: any, elem: Element) => any); + each(func: (index: any, elem: Element) => any): JQuery; get(index?: number): any; From 4dca98aadd2fb910d384d8b3ead843d4b9de32c3 Mon Sep 17 00:00:00 2001 From: Steve Fenton Date: Wed, 30 Jan 2013 09:22:53 +0000 Subject: [PATCH 025/248] Update phonegap/phonegap.d.ts Geolocation is now part of lib.d.ts and the duplicate declaration causes an error. --- phonegap/phonegap.d.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/phonegap/phonegap.d.ts b/phonegap/phonegap.d.ts index a3794dc3bc..30df15d079 100644 --- a/phonegap/phonegap.d.ts +++ b/phonegap/phonegap.d.ts @@ -288,12 +288,6 @@ interface GeolocationOptions { maximumAge?: number; } -interface Geolocation { - getCurrentPosition(geolocationSuccess: (position: Position) => void , geolocationError?: PositionErrorCallback, geolocationOptions?: GeolocationOptions): void; - watchPosition(geolocationSuccess: (position: Position) => void , geolocationError?: PositionErrorCallback, geolocationOptions?: GeolocationOptions): void; - clearWatch(watchID: number): void; -} - interface GlobalizationError { code: number; message: string; @@ -391,4 +385,4 @@ interface Navigator { interface Window { openDatabase(database_name: string, database_version: string, database_displayname: string, database_size: number): Database; -} \ No newline at end of file +} From e30d9760d6ae27ee802e3166e351dfe8e44527aa Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Wed, 30 Jan 2013 16:01:35 +0200 Subject: [PATCH 026/248] Update phonegap to 2.3 --- phonegap/phonegap-tests.ts | 15 ++++++++++++--- phonegap/phonegap.d.ts | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/phonegap/phonegap-tests.ts b/phonegap/phonegap-tests.ts index 1dafd8d797..2316c56460 100644 --- a/phonegap/phonegap-tests.ts +++ b/phonegap/phonegap-tests.ts @@ -111,7 +111,7 @@ function test_capture() { var options = { limit: 3, duration: 10 }; navigator.device.capture.captureAudio(captureSuccess, captureError, options); var captureSuccess = function (mediaFiles) { - var i, path, len; + var i, path, len; for (i = 0, len = mediaFiles.length; i < len; i += 1) { path = mediaFiles[i].fullPath; } @@ -150,7 +150,7 @@ function test_capture() { { fileName: name }); } function captureSuccess(mediaFiles) { - var i, len; + var i, len; for (i = 0, len = mediaFiles.length; i < len; i += 1) { uploadFile(mediaFiles[i]); } @@ -333,11 +333,13 @@ function test_contacts() { } function test_device() { + var element = document.getElementById('deviceProperties'); element.innerHTML = 'Device Name: ' + device.name + '
' + 'Device Cordova: ' + device.cordova + '
' + 'Device Platform: ' + device.platform + '
' + 'Device UUID: ' + device.uuid + '
' + - 'Device Version: ' + device.version + '
'; + 'Device Model: ' + device.model + '
' + + 'Device Version: ' + device.version + '
'; } function test_file() { @@ -590,6 +592,13 @@ function test_globalization() { ); } +function test_inAppBrowser() { + var ref = window.open('http://apache.org', '_blank', 'location=yes'); + ref.addEventListener('loadstart', function () { alert(event.url); }); + ref.removeEventListener('loadstart', null); + ref.close(); +} + function test_media() { var my_media = new Media(src, onSuccess, onError); var mediaTimer = setInterval(function () { diff --git a/phonegap/phonegap.d.ts b/phonegap/phonegap.d.ts index a3794dc3bc..b7125e227b 100644 --- a/phonegap/phonegap.d.ts +++ b/phonegap/phonegap.d.ts @@ -1,4 +1,4 @@ -// Type definitions for PhoneGap 2.2 +// Type definitions for PhoneGap 2.3 // Project: http://phonegap.com // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -170,6 +170,7 @@ interface Device { platform: string; uuid: string; version: string; + model: string; } /* Defined in lib.d.ts @@ -314,6 +315,15 @@ interface Globalization { getCurrencyPattern(currencyCode, successCB, errorCB): void; } +/* +interface InAppBrowser { + addEventListener(eventname: string, callback): void; + removeEventListener(eventname: string, callback): void; + open(url?: string, target?: string, features?: string, replace?: bool): Window; + close(): void; +} +*/ + interface Media { new (src: string, mediaSuccess: Function, mediaError?: MediaError, mediaStatus?: Function); getCurrentPosition(mediaSuccess: Function, mediaError?: MediaError): void; @@ -375,7 +385,7 @@ interface LocalStorage { } */ -interface Navigator { +interface Navigator extends Navigator { accelerometer: Accelerometer; camera: Camera; capture: Capture; @@ -391,4 +401,6 @@ interface Navigator { interface Window { openDatabase(database_name: string, database_version: string, database_displayname: string, database_size: number): Database; -} \ No newline at end of file +} + +declare var device: Device; \ No newline at end of file From 60e2bdc916fc3faa592e566d821f8edf77054e6c Mon Sep 17 00:00:00 2001 From: William Sears Date: Wed, 30 Jan 2013 13:59:31 -0800 Subject: [PATCH 027/248] Restructure to existing standards and update to more closely reflect the actual implementation of the JavaScript library. --- sinon/sinon-1.5.d.ts | 275 ++++++++++++++++++++++--------------------- 1 file changed, 141 insertions(+), 134 deletions(-) diff --git a/sinon/sinon-1.5.d.ts b/sinon/sinon-1.5.d.ts index 7c3cb9a86d..10ce89359d 100644 --- a/sinon/sinon-1.5.d.ts +++ b/sinon/sinon-1.5.d.ts @@ -3,7 +3,7 @@ // Definitions by: William Sears // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped -interface SinonSpyCall { +interface SinonSpyCallApi { // Properties thisValue: any; args: any[]; @@ -12,20 +12,36 @@ interface SinonSpyCall { // Methods calledOn(obj: any): bool; - calledWith(...args: any[]); + calledWith(...args: any[]): bool; calledWithExactly(...args: any[]): bool; - calledWithMatch(...args: any[]): bool; - notCalledWith(...args: any[]); - notCalledWithMatch(...args: any[]): bool; + calledWithMatch(...args: SinonMatcher[]): bool; + notCalledWith(...args: any[]): bool; + notCalledWithMatch(...args: SinonMatcher[]): bool; + returned(value: any): bool; threw(): bool; - threw(type: string); - threw(obj: any); + threw(type: string): bool; + threw(obj: any): bool; + callArg(pos: number): void; + // Future API - callArgOn(pos: number, obj: any, ...args: any[]): void; + callArgWith(pos: number, ...args: any[]): void; + // Future API - callArgOnWith(pos: number, obj: any, ...args: any[]): void; + yield(...args: any[]): void; + // Future API - yieldOn(obj: any, ...args: any[]): void; + yieldTo(property: string, ...args: any[]): void; + // Future API - yieldToOn(property: string, obj: any, ...args: any[]): void; } -interface SinonSpyApi { +interface SinonSpyCall extends SinonSpyCallApi { + calledBefore(call: SinonSpyCall): bool; + calledAfter(call: SinonSpyCall): bool; + calledWithNew(call: SinonSpyCall): bool; +} + +interface SinonSpy extends SinonSpyCallApi { // Properties callCount: number; called: bool; + notCalled: bool; calledOnce: bool; calledTwice: bool; calledThrice: bool; @@ -38,79 +54,73 @@ interface SinonSpyApi { exceptions: any[]; returnValues: any[]; - //Methods - withArgs(...args: any[]): void; + // Methods calledBefore(anotherSpy: SinonSpy): bool; calledAfter(anotherSpy: SinonSpy): bool; - calledOn(obj: any); + calledWithNew(spy: SinonSpy): bool; + withArgs(...args: any[]): void; alwaysCalledOn(obj: any); - calledWith(...args: any[]); alwaysCalledWith(...args: any[]); - calledWithExactly(...args: any[]); alwaysCalledWithExactly(...args: any[]); - calledWithMatch(...args: any[]); - alwaysCalledWithMatch(...args: any[]); - calledWithNew(): bool; - notCalledWith(...args: any[]); + alwaysCalledWithMatch(...args: SinonMatcher[]); neverCalledWith(...args: any[]); - notCalledWithMatch(...args: any[]); - neverCalledWithMatch(...args: any[]); - threw(): bool; - threw(type: string); - threw(obj: any); + neverCalledWithMatch(...args: SinonMatcher[]); alwaysThrew(): bool; alwaysThrew(type: string); alwaysThrew(obj: any); - returned(): bool; alwaysReturned(): bool; - yield(...args: any[]): void; invokeCallback(...args: any[]): void; - yieldTo(property: string, ...args: any[]): void; - callArg(index: number): void; - callArgWith(index: number, ...args: any[]): void; getCall(n: number): SinonSpyCall; reset(): void; printf(format: string, ...args: any[]); restore(): void; } -interface SinonSpy { - (): SinonSpyApi; - (func: any): SinonSpyApi; - (obj: any, method: string): SinonSpyApi; +interface SinonSpyStatic { + (): SinonSpy; + (func: any): SinonSpy; + (obj: any, method: string): SinonSpy; } -interface SinonApi { - spy: SinonSpy; +interface SinonStatic { + spy: SinonSpyStatic; } -interface SinonStubApi extends SinonSpyApi { - returns(obj: any): SinonStubApi; - returnsArg(index: number): SinonStubApi; - throws(type?: string): SinonStubApi; - throws(obj: any): SinonStubApi; - callsArg(index: number): SinonStubApi; - callsArgOn(index: number, context: any): SinonStubApi; - callsArgWith(index: number, ...args: any[]): SinonStubApi; - callsArgOnWith(index: number, context: any, ...args: any[]): SinonStubApi; - yields(...args: any[]): SinonStubApi; - yieldsOn(context: any, ...args: any[]): SinonStubApi; - yieldsTo(property: string, ...args: any[]): SinonStubApi; - yieldsToOn(property: string, context: any, ...args: any[]): SinonStubApi; +interface SinonStub extends SinonSpy { + returns(obj: any): SinonStub; + returnsArg(index: number): SinonStub; + throws(type?: string): SinonStub; + throws(obj: any): SinonStub; + callsArg(index: number): SinonStub; + callsArgOn(index: number, context: any): SinonStub; + callsArgWith(index: number, ...args: any[]): SinonStub; + callsArgOnWith(index: number, context: any, ...args: any[]): SinonStub; + callsArgAsync(index: number): SinonStub; + callsArgOnAsync(index: number, context: any): SinonStub; + callsArgWithAsync(index: number, ...args: any[]): SinonStub; + callsArgOnWithAsync(index: number, context: any, ...args: any[]): SinonStub; + yields(...args: any[]): SinonStub; + yieldsOn(context: any, ...args: any[]): SinonStub; + yieldsTo(property: string, ...args: any[]): SinonStub; + yieldsToOn(property: string, context: any, ...args: any[]): SinonStub; + yieldsAsync(...args: any[]): SinonStub; + yieldsOnAsync(context: any, ...args: any[]): SinonStub; + yieldsToAsync(property: string, ...args: any[]): SinonStub; + yieldsToOnAsync(property: string, context: any, ...args: any[]): SinonStub; } -interface SinonStub { - (): SinonStubApi; - (obj: any): SinonStubApi; - (obj: any, method: string): SinonStubApi; - (obj: any, method: string, func: any): SinonStubApi; +interface SinonStubStatic { + (): SinonStub; + (obj: any): SinonStub; + (obj: any, method: string): SinonStub; + (obj: any, method: string, func: any): SinonStub; } -interface SinonApi { - stub: SinonStub; +interface SinonStatic { + stub: SinonStubStatic; } -interface SinonExpectationApi { +interface SinonExpectation { atLeast(n: number): SinonExpectation; atMost(n: number): SinonExpectation; never(): SinonExpectation; @@ -125,27 +135,27 @@ interface SinonExpectationApi { restore(): void; } -interface SinonExpectation { - create(methodName?: string): SinonExpectationApi; +interface SinonExpectationStatic { + create(methodName?: string): SinonExpectation; } -interface SinonMockApi { - expects(method: string): SinonExpectationApi; +interface SinonMock { + expects(method: string): SinonExpectationStatic; restore(): void; verify(): void; } -interface SinonMock { - (): SinonExpectationApi; - (obj: any): SinonMockApi; +interface SinonMockStatic { + (): SinonExpectation; + (obj: any): SinonMock; } -interface SinonApi { - expectation: SinonExpectation; - mock: SinonMock; +interface SinonStatic { + expectation: SinonExpectationStatic; + mock: SinonMockStatic; } -interface SinonFakeTimersApi { +interface SinonFakeTimers { now: number; create(now: number): SinonFakeTimers; setTimeout(callback: (...args: any[]) => void , timeout: number, ...args: any[]): number; @@ -165,18 +175,18 @@ interface SinonFakeTimersApi { restore(): void; } -interface SinonFakeTimers { - (): SinonFakeTimersApi; - (...timers: string[]): SinonFakeTimersApi; - (now: number, ...timers: string[]): SinonFakeTimersApi; +interface SinonFakeTimersStatic { + (): SinonFakeTimers; + (...timers: string[]): SinonFakeTimers; + (now: number, ...timers: string[]): SinonFakeTimers; } -interface SinonApi { - useFakeTimers: SinonFakeTimers; +interface SinonStatic { + useFakeTimers: SinonFakeTimersStatic; clock: SinonFakeTimers; } -interface SinonFakeXMLHttpRequestApi { +interface SinonFakeXMLHttpRequest { // Properties onCreate: (xhr: SinonFakeXMLHttpRequest) => void; url: string; @@ -202,16 +212,16 @@ interface SinonFakeXMLHttpRequestApi { autoRespond(ms: number): void; } -interface SinonFakeXMLHttpRequest { - (): SinonFakeXMLHttpRequestApi; +interface SinonFakeXMLHttpRequestStatic { + (): SinonFakeXMLHttpRequest; } -interface SinonApi { - useFakeXMLHttpRequest: SinonFakeXMLHttpRequest; - FakeXMLHttpRequest: SinonFakeXMLHttpRequestApi; +interface SinonStatic { + useFakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic; + FakeXMLHttpRequest: SinonFakeXMLHttpRequest; } -interface SinonFakeServerApi { +interface SinonFakeServer { // Properties autoRespond: bool; autoRespondAfter: number; @@ -238,13 +248,13 @@ interface SinonFakeServerApi { restore(): void; } -interface SinonFakeServer { - create(): SinonFakeServerApi; +interface SinonFakeServerStatic { + create(): SinonFakeServer; } -interface SinonApi { - fakeServer: SinonFakeServer; - fakeServerWithClock: SinonFakeServer; +interface SinonStatic { + fakeServer: SinonFakeServerStatic; + fakeServerWithClock: SinonFakeServerStatic; } interface SinonExposeOptions { @@ -252,7 +262,7 @@ interface SinonExposeOptions { includeFail?: bool; } -interface SinonAssertApi { +interface SinonAssert { // Properties failException: string; fail: (message?: string) => void; // Overridable @@ -273,9 +283,9 @@ interface SinonAssertApi { neverCalledWith(spy: SinonSpy, ...args: any[]): void; calledWithExactly(spy: SinonSpy, ...args: any[]): void; alwaysCalledWithExactly(spy: SinonSpy, ...args: any[]): void; - calledWithMatch(spy: SinonSpy, ...args: any[]): void; - alwaysCalledWithMatch(spy: SinonSpy, ...args: any[]): void; - neverCalledWithMatch(spy: SinonSpy, ...args: any[]): void; + calledWithMatch(spy: SinonSpy, ...args: SinonMatcher[]): void; + alwaysCalledWithMatch(spy: SinonSpy, ...args: SinonMatcher[]): void; + neverCalledWithMatch(spy: SinonSpy, ...args: SinonMatcher[]): void; threw(spy: SinonSpy): void; threw(spy: SinonSpy, exception: string): void; threw(spy: SinonSpy, exception: any): void; @@ -285,45 +295,42 @@ interface SinonAssertApi { expose(obj: any, options?: SinonExposeOptions): void; } -interface SinonApi { - assert: SinonAssertApi; -} - -interface SinonMatcherTerm { - and(expr: SinonMatcherTerm): SinonMatcherTerm; - or(expr: SinonMatcherTerm): SinonMatcherTerm; -} - -interface SinonMatcherApi { - any: SinonMatcherTerm; - defined: SinonMatcherTerm; - truthy: SinonMatcherTerm; - falsy: SinonMatcherTerm; - bool: SinonMatcherTerm; - number: SinonMatcherTerm; - string: SinonMatcherTerm; - object: SinonMatcherTerm; - func: SinonMatcherTerm; - array: SinonMatcherTerm; - regexp: SinonMatcherTerm; - date: SinonMatcherTerm; - same(obj: any): SinonMatcherTerm; - typeOf(type: string): SinonMatcherTerm; - instanceOf(type: any): SinonMatcherTerm; - has(property: string, expect?: any): SinonMatcherTerm; - hasOwn(property: string, expect?: any): SinonMatcherTerm; +interface SinonStatic { + assert: SinonAssert; } interface SinonMatcher { - (value: number): SinonMatcherApi; - (value: string): SinonMatcherApi; - (expr: RegExp): SinonMatcherApi; - (obj: any): SinonMatcherApi; - (callback: (value: any) => bool): SinonMatcherApi; + and(expr: SinonMatch): SinonMatcher; + or(expr: SinonMatch): SinonMatcher; } -interface SinonApi { - match: SinonMatcher; +interface SinonMatch { + (value: number): SinonMatcher; + (value: string): SinonMatcher; + (expr: RegExp): SinonMatcher; + (obj: any): SinonMatcher; + (callback: (value: any) => bool): SinonMatcher; + any: SinonMatcher; + defined: SinonMatcher; + truthy: SinonMatcher; + falsy: SinonMatcher; + bool: SinonMatcher; + number: SinonMatcher; + string: SinonMatcher; + object: SinonMatcher; + func: SinonMatcher; + array: SinonMatcher; + regexp: SinonMatcher; + date: SinonMatcher; + same(obj: any): SinonMatcher; + typeOf(type: string): SinonMatcher; + instanceOf(type: any): SinonMatcher; + has(property: string, expect?: any): SinonMatcher; + hasOwn(property: string, expect?: any): SinonMatcher; +} + +interface SinonStatic { + match: SinonMatch; } interface SinonSandboxConfig { @@ -333,25 +340,25 @@ interface SinonSandboxConfig { useFakeServer?: any; } -interface SinonSandboxApi { +interface SinonSandbox { clock: SinonFakeTimers; requests: SinonFakeXMLHttpRequest; server: SinonFakeServer; - spy(): SinonSpyApi; - stub(): SinonStubApi; - mock(): SinonMockApi; + spy(): SinonSpy; + stub(): SinonStub; + mock(): SinonMock; useFakeTimers: SinonFakeTimers; useFakeXMLHttpRequest: SinonFakeXMLHttpRequest; restore(): void; } -interface SinonSandbox { - create(): SinonSandboxApi; - create(config: SinonSandboxConfig): SinonSandboxApi; +interface SinonSandboxStatic { + create(): SinonSandbox; + create(config: SinonSandboxConfig): SinonSandbox; } -interface SinonApi { - sandbox: SinonSandbox; +interface SinonStatic { + sandbox: SinonSandboxStatic; } interface SinonTestConfig { @@ -362,20 +369,20 @@ interface SinonTestConfig { useFakeServer?: bool; } -interface SinonTestWrapper extends SinonSandboxApi{ +interface SinonTestWrapper extends SinonSandbox { (...args: any[]): any; } -interface SinonApi { +interface SinonStatic { config: SinonTestConfig; test(fn: (...args: any[]) => any): SinonTestWrapper; testCase(tests: any): any; } // Utility overridables -interface SinonApi { +interface SinonStatic { format: (obj: any) => string; log: (message: string) => void; } -var sinon: SinonApi; +var sinon: SinonStatic; From 1ed31d3eb9b87e98f9a627eb7c91bcb534afbe3e Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Wed, 30 Jan 2013 20:28:30 -0200 Subject: [PATCH 028/248] Definitions for FlexSlider #231 --- README.md | 1 + flexSlider/flexSlider-tests.ts | 84 +++++++++++++++++++++++++++++++ flexSlider/flexSlider.d.ts | 90 ++++++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 flexSlider/flexSlider-tests.ts create mode 100644 flexSlider/flexSlider.d.ts diff --git a/README.md b/README.md index cf41e9acd2..4fe19fa324 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ List of Definitions * [Fabric.js](http://fabricjs.com/) (by [Oliver Klemencic](https://github.com/oklemencic/)) * [Fancybox](http://fancybox.net/) (by [Boris Yankov](https://github.com/borisyankov)) * [Finite State Machine](https://github.com/jakesgordon/javascript-state-machine) (by [Boris Yankov](https://github.com/borisyankov)) +* [FlexSlider](http://www.woothemes.com/flexslider/) (by [Diullei Gomes](https://github.com/Diullei)) * [Foundation](http://foundation.zurb.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dniel Tar](https://github.com/qcz)) * [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt)) diff --git a/flexSlider/flexSlider-tests.ts b/flexSlider/flexSlider-tests.ts new file mode 100644 index 0000000000..8651102422 --- /dev/null +++ b/flexSlider/flexSlider-tests.ts @@ -0,0 +1,84 @@ +/// + +// Can also be used with $(document).ready() +$(window).load(function() { + $('.flexslider').flexslider({ + animation: "slide" + }); +}); + +// Can also be used with $(document).ready() +$(window).load(function() { + $('.flexslider').flexslider({ + animation: "slide", + controlNav: "thumbnails" + }); +}); + +$(window).load(function() { + // The slider being synced must be initialized first + $('#carousel').flexslider({ + animation: "slide", + controlNav: false, + animationLoop: false, + slideshow: false, + itemWidth: 210, + itemMargin: 5, + asNavFor: '#slider' + }); + + $('#slider').flexslider({ + animation: "slide", + controlNav: false, + animationLoop: false, + slideshow: false, + sync: "#carousel" + }); +}); + +$(window).load(function() { + $('.flexslider').flexslider({ + animation: "slide", + animationLoop: false, + itemWidth: 210, + itemMargin: 5 + }); +}); + +// Can also be used with $(document).ready() +$(window).load(function() { + $('.flexslider').flexslider({ + animation: "slide", + animationLoop: false, + itemWidth: 210, + itemMargin: 5, + minItems: 2, + maxItems: 4 + }); +}); + +// Can also be used with $(document).ready() +$(window).load(function() { + + // Vimeo API nonsense + var player = document.getElementById('player_1'); + $(player).on('ready', ready); + + function addEvent(element, eventName, callback) { + if (element.addEventListener) { + element.addEventListener(eventName, callback, false) + } else { + element.attachEvent(eventName, callback, false); + } + } + + function ready(player_id) { + var froogaloop = $(player_id); + froogaloop.on('play', function(data) { + $('.flexslider').flexslider("pause"); + }); + froogaloop.on('pause', function(data) { + $('.flexslider').flexslider("play"); + }); + } +}); \ No newline at end of file diff --git a/flexSlider/flexSlider.d.ts b/flexSlider/flexSlider.d.ts new file mode 100644 index 0000000000..290cc1c459 --- /dev/null +++ b/flexSlider/flexSlider.d.ts @@ -0,0 +1,90 @@ +// Type definitions for FlexSlider 2 jquery plugin +// Project: https://github.com/woothemes/FlexSlider +// Definitions by: Diullei Gomes +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface SliderObject { //Object: The slider element itself + container: Object; //Object: The ul.slides within the slider + slides: Object; //Object: The slides of the slider + count: number; //Int: The total number of slides in the slider + currentSlide: number; //Int: The slide currently being shown + animatingTo: number; //Int: Useful in .before(), the slide currently animating to + animating: bool; //Boolean: is slider animating? + atEnd: bool; //Boolean: is the slider at either end? + manualPause: bool; //Boolean: force slider to stay paused during pauseOnHover event + controlNav: Object; //Object: The slider controlNav + directionNav: Object; //Object: The slider directionNav + controlsContainer: Object; //Object: The controlsContainer element of the slider + manualControls: Object; //Object: The manualControls element of the slider + flexAnimate(target, pause?); //Function: Move slider - (target, pause) parameters + pause(); //Function: Pause slider slideshow interval + resume(); //Function: Resume slider slideshow interval + canAdvance(target); //Function: returns boolean if slider can advance - (target) parameter + getTarget(dir); //Function: get target given a direction - "next" or "prev" parameter +} + +interface FlexSliderOptions { + namespace?: string; //{NEW} String: Prefix string attached to the class of every element generated by the plugin + selector?: string; //{NEW} Selector: Must match a simple pattern. '{container} > {slide}' -- Ignore pattern at your own peril + animation?: string; //String: Select your animation type, "fade" or "slide" + easing?: string; //{NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported! + direction?: string; //String: Select the sliding direction, "horizontal" or "vertical" + reverse?: bool; //{NEW} Boolean: Reverse the animation direction + animationLoop?: bool; //Boolean: Should the animation loop? If bool; directionNav will received "disable" classes at either end + smoothHeight?: bool; //{NEW} Boolean: Allow height of the slider to animate smoothly in horizontal mode + startAt?: number; //Integer: The slide that the slider should start on. Array notation (0 = first slide) + slideshow?: bool; //Boolean: Animate slider automatically + slideshowSpeed?: number; //Integer: Set the speed of the slideshow cycling, in milliseconds + animationSpeed?: number; //Integer: Set the speed of animations, in milliseconds + initDelay?: number; //{NEW} Integer: Set an initialization delay, in milliseconds + randomize?: bool; //Boolean: Randomize slide order + + // Usability features + pauseOnAction?: bool; //Boolean: Pause the slideshow when interacting with control elements, highly recommended. + pauseOnHover?: bool; //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering + useCSS?: bool; //{NEW} Boolean: Slider will use CSS3 transitions if available + touch?: bool; //{NEW} Boolean: Allow touch swipe navigation of the slider on touch-enabled devices + video?: bool; //{NEW} Boolean: If using video in the slider, will prevent CSS3 3D Transforms to avoid graphical glitches + + // Primary Controls + controlNav?: any; //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage + directionNav?: bool; //Boolean: Create navigation for previous/next navigation? (true/false) + prevText?: string; //String: Set the text for the "previous" directionNav item + nextText?: string; //String: Set the text for the "next" directionNav item + + // Secondary Navigation + keyboard?: bool; //Boolean: Allow slider navigating via keyboard left/right keys + multipleKeyboard?: bool; //{NEW} Boolean: Allow keyboard navigation to affect multiple sliders. Default behavior cuts out keyboard navigation with more than one slider present. + mousewheel?: bool; //{UPDATED} Boolean: Requires jquery.mousewheel.js (https://github.com/brandonaaron/jquery-mousewheel) - Allows slider navigating via mousewheel + pausePlay?: bool; //Boolean: Create pause/play dynamic element + pauseText?: string; //String: Set the text for the "pause" pausePlay item + playText?: string; //String: Set the text for the "play" pausePlay item + + // Special properties + controlsContainer?: string; //{UPDATED} Selector: USE CLASS SELECTOR. Declare which container the navigation elements should be appended too. Default container is the FlexSlider element. Example use would be ".flexslider-container". Property is ignored if given element is not found. + manualControls?: string; //Selector: Declare custom control navigation. Examples would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs. + sync?: string; //{NEW} Selector: Mirror the actions performed on this slider with another slider. Use with care. + asNavFor?: string; //{NEW} Selector: Internal property exposed for turning the slider into a thumbnail navigation for another slider + + // Carousel Options + itemWidth?: number; //{NEW} Integer: Box-model width of individual carousel items, including horizontal borders and padding. + itemMargin?: number; //{NEW} Integer: Margin between carousel items. + minItems?: number; //{NEW} Integer: Minimum number of carousel items that should be visible. Items will resize fluidly when below this. + maxItems?: number; //{NEW} Integer: Maxmimum number of carousel items that should be visible. Items will resize fluidly when above this limit. + move?: number; //{NEW} Integer: Number of carousel items that should move on animation. If number; slider will move all visible items. + + // Callback API + start?: (slider: SliderObject) => any; //Callback: function(slider) - Fires when the slider loads the first slide + before?: (slider: SliderObject) => any; //Callback: function(slider) - Fires asynchronously with each slider animation + after?: () => any; //Callback: function(slider) - Fires after each slider animation completes + end?: () => any; //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous) + added?: () => any; //{NEW} Callback: function(slider) - Fires after a slide is added + removed?: () => any; +} + + +interface JQuery { + flexslider(options?: FlexSliderOptions); +} From 372fa585c263eb221d932e5940dc10a30ef438b4 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Thu, 31 Jan 2013 00:37:41 -0500 Subject: [PATCH 029/248] Add more tests of static methods. --- jsoneditoronline/jsoneditoronline-tests.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jsoneditoronline/jsoneditoronline-tests.ts b/jsoneditoronline/jsoneditoronline-tests.ts index a5afd2c6cc..d2196e1bcd 100644 --- a/jsoneditoronline/jsoneditoronline-tests.ts +++ b/jsoneditoronline/jsoneditoronline-tests.ts @@ -17,11 +17,12 @@ var json = { }; editor.set(json); editor.expandAll(); +console.log(JSONEditor.getInternetExplorerVersion()); var jsonResult:any = editor.get(); var options2: JSONFormatterOptions = { - "indentation": 2 + indentation: 2 }; var formatter: JSONFormatter = new JSONFormatter(container, options); var json2 = { @@ -34,4 +35,4 @@ var json2 = { }; formatter.set(json2); -var jsonResult2:any = formatter.get(json2); \ No newline at end of file +var jsonResult2:any = formatter.get(); \ No newline at end of file From 7a764f1e245c1d85a79768add23fff7603cb992e Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Thu, 31 Jan 2013 09:05:12 +0200 Subject: [PATCH 030/248] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fe19fa324..fd98931770 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ List of Definitions * [jQuery.Transit](http://ricostacruz.com/jquery.transit/) (by [MrBigDog2U](https://github.com/MrBigDog2U)) * [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) * [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved)) +* [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) (by [Vincent Bortone](https://github.com/vbortone/)) * [KeyboardJS](https://github.com/RobertWHurst/KeyboardJS) (by [Vincent Bortone](https://github.com/vbortone/)) * [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit)) * [Knockout.js](http://knockoutjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) @@ -140,7 +141,6 @@ Requested Definitions * [dc.js](https://github.com/NickQiZhu/dc.js) * [google.visualizations](https://developers.google.com/chart/) * [Tags Manager](http://welldonethings.com/tags/manager) -* [jsoneditoronline](https://github.com/wjosdejong/jsoneditoronline) * [Tags Manager](http://welldonethings.com/tags/manager) * [Prelude.ls](http://gkz.github.com/prelude-ls/) * [MooTools](http://mootools.net/) From 71fb1d4a12aabd8c7376e6eb639f2b8d90a18428 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Thu, 31 Jan 2013 02:59:19 -0500 Subject: [PATCH 031/248] Initial commit of Nodemailer type definitions and tests --- nodemailer/nodemailer-tests.ts | 33 ++++++++++++++++++++++++++ nodemailer/nodemailer.d.ts | 42 ++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 nodemailer/nodemailer-tests.ts create mode 100644 nodemailer/nodemailer.d.ts diff --git a/nodemailer/nodemailer-tests.ts b/nodemailer/nodemailer-tests.ts new file mode 100644 index 0000000000..f1f3bcfef4 --- /dev/null +++ b/nodemailer/nodemailer-tests.ts @@ -0,0 +1,33 @@ +//Nodemailer test +/// +var nodemailer:NodemailerStatic; + +// create reusable transport method (opens pool of SMTP connections) +var smtpTransport = nodemailer.createTransport("SMTP",{ + service: "Gmail", + auth: { + user: "gmail.user@gmail.com", + pass: "userpass" + } +}); + +// setup e-mail data with unicode symbols +var mailOptions = { + from: "Fred Foo ✔ ", // sender address + to: "bar@blurdybloop.com, baz@blurdybloop.com", // list of receivers + subject: "Hello ✔", // Subject line + text: "Hello world ✔", // plaintext body + html: "Hello world ✔" // html body +} + +// send mail with defined transport object +smtpTransport.sendMail(mailOptions, function(error, response){ + if(error){ + console.log(error); + }else{ + console.log("Message sent: " + response.message); + } + + // if you don't want to use this transport object anymore, uncomment following line + //smtpTransport.close(); // shut down the connection pool, no more messages +}); \ No newline at end of file diff --git a/nodemailer/nodemailer.d.ts b/nodemailer/nodemailer.d.ts new file mode 100644 index 0000000000..4ab4a09afb --- /dev/null +++ b/nodemailer/nodemailer.d.ts @@ -0,0 +1,42 @@ +// Type definitions for Nodemailer +// JNodemailer is an easy to use module to send e-mails with Node.JS (using SMTP or sendmail or Amazon SES) and is unicode friendly . +// Project: https://github.com/andris9/Nodemailer +// Definitions by: Vincent Bortone +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Transport {} + +interface MailComposer {} + +interface XOAuthGenerator {} + +interface NodemailerTransportOptions { + service: string; + +} + +interface NodeMailerMessageOptions {} + +interface NodemailerStatic { + X_MAILER_NAME: string; + X_MAILER_HOMEPAGE: string; + createTransport(type: string, options: NodeMailerTransportOptions): Transport; + sendMail(options: NodeMailerMessageOptions, callback?: (err: Error) => any): any; + send_mail(options: NodeMailerMessageOptions, callback?: (err: Error) => any): any; +} + +interface Nodemailer { + (options: NodeMailerMessageOptions): void; + transport: Transport; + options: NodeMailerMessageOptions; + mailcomposer: MailComposer; + generateUserAgentString(): string; + getGlobalTransport(): Transport; + validateSettings(callback: (err: Error) => any): void; + sendMail(callback: () => any): void; + generateMailObject(): void; + setGeneralOptions(): void; + setUserHeaders(): void; + setModuleHeaders(): void; + setAttachments(): void; +} \ No newline at end of file From 761af95d45eed63234abe75bdb240d085740894d Mon Sep 17 00:00:00 2001 From: ProVega Date: Thu, 31 Jan 2013 23:31:53 -0800 Subject: [PATCH 032/248] Update backbone/backbone.d.ts Removing getByCid which was removed 0.9.9 --- backbone/backbone.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index b9fcc33800..f49d3663de 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Backbone 0.9 +// Type definitions for Backbone 0.9.10 // Project: http://backbonejs.org/ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -109,7 +109,6 @@ declare module Backbone { add(models: Model[], options?: AddOptions); at(index: number): Model; get(id: any): Model; - getByCid(cid): Model; create(attributes: any, options?: CreateOptions): Model; pluck(attribute: string): any[]; push(model: Model, options?: AddOptions); From 1b298ca0d6c1e9c90da5882c383ba89bf39efcb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Guillot?= Date: Fri, 1 Feb 2013 10:32:18 +0100 Subject: [PATCH 033/248] jQuery.cycle definitions file. --- jquery.cycle/jquery.cycle-tests.ts | 324 +++++++++++++++++++++++++++++ jquery.cycle/jquery.cycle.d.ts | 93 +++++++++ 2 files changed, 417 insertions(+) create mode 100644 jquery.cycle/jquery.cycle-tests.ts create mode 100644 jquery.cycle/jquery.cycle.d.ts diff --git a/jquery.cycle/jquery.cycle-tests.ts b/jquery.cycle/jquery.cycle-tests.ts new file mode 100644 index 0000000000..2b5bd668e5 --- /dev/null +++ b/jquery.cycle/jquery.cycle-tests.ts @@ -0,0 +1,324 @@ +/// +/// + +// As basic as it can be +$('#element').cycle(); + +/* Beginner Demos */ + +$('#s1').cycle('fade'); + +$('#s2').cycle({ + fx: 'scrollDown' +}); + +$('#s3').cycle({ + fx: 'fade', + speed: 2500 +}); + +$('#s4').cycle({ + fx: 'scrollDown', + speed: 300, + timeout: 2000 +}); + +$('#s5').cycle({ + fx: 'fade', + pause: true +}); + +$('#s6').cycle({ + fx: 'scrollDown', + random: true +}); + +/* Intermediate Demos (Part 1) */ +$('#s1').cycle({ + fx: 'zoom', + easing: 'easeInBounce', + delay: -4000 +}); + +$('#s2').cycle({ + fx: 'scrollDown', + easing: 'easeOutBounce', + delay: -2000 +}); + +$('#s3').cycle({ + fx: 'zoom', + sync: false, + delay: -4000 +}); + +$('#s4').cycle({ + fx: 'scrollDown', + sync: false, + delay: -2000 +}); + +$('#s5').cycle({ + fx: 'shuffle', + delay: -4000 +}); + +$('#s6').cycle({ + fx: 'shuffle', + shuffle: { + top: -230, + left: 230 + }, + easing: 'easeInOutBack', + delay: -2000 +}); + +/* Intermediate Demos (Part 2) */ + +$('#s1').cycle({ + fx: 'slideY', + speed: 300, + next: '#s1', + timeout: 0 +}); + +$('#s2').cycle({ + fx: 'fade', + speed: 'fast', + timeout: 0, + next: '#next2', + prev: '#prev2' +}); + +$('#s3').cycle({ + fx: 'fade', + speed: 300, + timeout: 3000, + next: '#s3', + pause: true +}); + +$('#s4') +.before('