From b9d128f1c8ea2fee8360b5c96d5d6f72aa1f9758 Mon Sep 17 00:00:00 2001 From: jodonoghue-avoca Date: Fri, 25 Jan 2013 15:26:45 +0000 Subject: [PATCH 1/8] 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 2/8] 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 3/8] 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 4/8] 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 2df1c73b6d6b98697fadd5e0bdcf6314ae178304 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Fri, 25 Jan 2013 18:20:46 -0500 Subject: [PATCH 5/8] 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 dd54130b8e4cb18768da0c2f00ed96b4296bbed6 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Sun, 27 Jan 2013 17:30:56 -0500 Subject: [PATCH 6/8] 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 7/8] 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 372fa585c263eb221d932e5940dc10a30ef438b4 Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Thu, 31 Jan 2013 00:37:41 -0500 Subject: [PATCH 8/8] 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