From aaab0e11c15cb9b4382d80159ad1e96a5f1f750c Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Fri, 25 Jan 2013 12:39:20 -0500 Subject: [PATCH] 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 000000000..ca5d614de --- /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 000000000..1fffc1afb --- /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