diff --git a/Definitions/angular-1.0.d.ts b/angularjs/angular-1.0.d.ts
similarity index 100%
rename from Definitions/angular-1.0.d.ts
rename to angularjs/angular-1.0.d.ts
diff --git a/Definitions/angular-cookies-1.0.d.ts b/angularjs/angular-cookies-1.0.d.ts
similarity index 100%
rename from Definitions/angular-cookies-1.0.d.ts
rename to angularjs/angular-cookies-1.0.d.ts
diff --git a/Definitions/angular-mocks-1.0.d.ts b/angularjs/angular-mocks-1.0.d.ts
similarity index 100%
rename from Definitions/angular-mocks-1.0.d.ts
rename to angularjs/angular-mocks-1.0.d.ts
diff --git a/Definitions/angular-resource-1.0.d.ts b/angularjs/angular-resource-1.0.d.ts
similarity index 100%
rename from Definitions/angular-resource-1.0.d.ts
rename to angularjs/angular-resource-1.0.d.ts
diff --git a/Definitions/angular-sanitize-1.0.d.ts b/angularjs/angular-sanitize-1.0.d.ts
similarity index 100%
rename from Definitions/angular-sanitize-1.0.d.ts
rename to angularjs/angular-sanitize-1.0.d.ts
diff --git a/Definitions/async-0.1.d.ts b/async/async-0.1.d.ts
similarity index 100%
rename from Definitions/async-0.1.d.ts
rename to async/async-0.1.d.ts
diff --git a/Tests/async-tests.ts b/async/async-tests.ts
similarity index 100%
rename from Tests/async-tests.ts
rename to async/async-tests.ts
diff --git a/Definitions/backbone-0.9.d.ts b/backbone/backbone-0.9.d.ts
similarity index 100%
rename from Definitions/backbone-0.9.d.ts
rename to backbone/backbone-0.9.d.ts
diff --git a/Tests/backbone-tests.ts b/backbone/backbone-tests.ts
similarity index 100%
rename from Tests/backbone-tests.ts
rename to backbone/backbone-tests.ts
diff --git a/Definitions/bootstrap-2.1.d.ts b/bootstrap/bootstrap-2.1.d.ts
similarity index 100%
rename from Definitions/bootstrap-2.1.d.ts
rename to bootstrap/bootstrap-2.1.d.ts
diff --git a/Tests/bootstrap-tests.ts b/bootstrap/bootstrap-tests.ts
similarity index 100%
rename from Tests/bootstrap-tests.ts
rename to bootstrap/bootstrap-tests.ts
diff --git a/Definitions/breeze-0.65.d.ts b/breeze/breeze-0.65.d.ts
similarity index 100%
rename from Definitions/breeze-0.65.d.ts
rename to breeze/breeze-0.65.d.ts
diff --git a/Tests/breeze-tests.ts b/breeze/breeze-tests.ts
similarity index 100%
rename from Tests/breeze-tests.ts
rename to breeze/breeze-tests.ts
diff --git a/Definitions/chosen-0.9.d.ts b/chosen/chosen-0.9.d.ts
similarity index 100%
rename from Definitions/chosen-0.9.d.ts
rename to chosen/chosen-0.9.d.ts
diff --git a/Tests/chosen-tests.ts b/chosen/chosen-tests.ts
similarity index 100%
rename from Tests/chosen-tests.ts
rename to chosen/chosen-tests.ts
diff --git a/Definitions/codemirror-3.0.d.ts b/codemirror/codemirror-3.0.d.ts
similarity index 100%
rename from Definitions/codemirror-3.0.d.ts
rename to codemirror/codemirror-3.0.d.ts
diff --git a/Tests/codemirror-tests.ts b/codemirror/codemirror-tests.ts
similarity index 100%
rename from Tests/codemirror-tests.ts
rename to codemirror/codemirror-tests.ts
diff --git a/Definitions/easeljs-0.5.d.ts b/easeljs/easeljs-0.5.d.ts
similarity index 100%
rename from Definitions/easeljs-0.5.d.ts
rename to easeljs/easeljs-0.5.d.ts
diff --git a/Tests/easeljs-tests.ts b/easeljs/easeljs-tests.ts
similarity index 100%
rename from Tests/easeljs-tests.ts
rename to easeljs/easeljs-tests.ts
diff --git a/Definitions/ember-1.0.d.ts b/ember/ember-1.0.d.ts
similarity index 100%
rename from Definitions/ember-1.0.d.ts
rename to ember/ember-1.0.d.ts
diff --git a/Tests/ember-tests.ts b/ember/ember-tests.ts
similarity index 100%
rename from Tests/ember-tests.ts
rename to ember/ember-tests.ts
diff --git a/Definitions/express-3.0.d.ts b/express/express-3.0.d.ts
similarity index 100%
rename from Definitions/express-3.0.d.ts
rename to express/express-3.0.d.ts
diff --git a/Tests/express-tests.ts b/express/express-tests.ts
similarity index 100%
rename from Tests/express-tests.ts
rename to express/express-tests.ts
diff --git a/Definitions/fancybox-2.1.d.ts b/fancybox/fancybox-2.1.d.ts
similarity index 100%
rename from Definitions/fancybox-2.1.d.ts
rename to fancybox/fancybox-2.1.d.ts
diff --git a/Tests/fancybox-tests.ts b/fancybox/fancybox-tests.ts
similarity index 100%
rename from Tests/fancybox-tests.ts
rename to fancybox/fancybox-tests.ts
diff --git a/Tests/globalize-tests.ts b/globalize/globalize-tests.ts
similarity index 100%
rename from Tests/globalize-tests.ts
rename to globalize/globalize-tests.ts
diff --git a/Definitions/globalize.d.ts b/globalize/globalize.d.ts
similarity index 100%
rename from Definitions/globalize.d.ts
rename to globalize/globalize.d.ts
diff --git a/Definitions/google.maps.d.ts b/googlemaps/google.maps.d.ts
similarity index 100%
rename from Definitions/google.maps.d.ts
rename to googlemaps/google.maps.d.ts
diff --git a/Definitions/handlebars-1.0.d.ts b/handlebars/handlebars-1.0.d.ts
similarity index 100%
rename from Definitions/handlebars-1.0.d.ts
rename to handlebars/handlebars-1.0.d.ts
diff --git a/Tests/handlebars-tests.ts b/handlebars/handlebars-tests.ts
similarity index 100%
rename from Tests/handlebars-tests.ts
rename to handlebars/handlebars-tests.ts
diff --git a/Definitions/history-1.7.d.ts b/history/history-1.7.d.ts
similarity index 100%
rename from Definitions/history-1.7.d.ts
rename to history/history-1.7.d.ts
diff --git a/Tests/history-tests.ts b/history/history-tests.ts
similarity index 100%
rename from Tests/history-tests.ts
rename to history/history-tests.ts
diff --git a/Definitions/humane-3.0.d.ts b/humane/humane-3.0.d.ts
similarity index 100%
rename from Definitions/humane-3.0.d.ts
rename to humane/humane-3.0.d.ts
diff --git a/Tests/humane-tests.ts b/humane/humane-tests.ts
similarity index 100%
rename from Tests/humane-tests.ts
rename to humane/humane-tests.ts
diff --git a/Definitions/impress-0.5.d.ts b/impress/impress-0.5.d.ts
similarity index 100%
rename from Definitions/impress-0.5.d.ts
rename to impress/impress-0.5.d.ts
diff --git a/Tests/impress-tests.ts b/impress/impress-tests.ts
similarity index 100%
rename from Tests/impress-tests.ts
rename to impress/impress-tests.ts
diff --git a/Definitions/jasmine-1.2.d.ts b/jasmine/jasmine-1.2.d.ts
similarity index 100%
rename from Definitions/jasmine-1.2.d.ts
rename to jasmine/jasmine-1.2.d.ts
diff --git a/Tests/jasmine-tests.ts b/jasmine/jasmine-tests.ts
similarity index 100%
rename from Tests/jasmine-tests.ts
rename to jasmine/jasmine-tests.ts
diff --git a/Definitions/jquery.bbq-1.2.d.ts b/jquery.bbq/jquery.bbq-1.2.d.ts
similarity index 100%
rename from Definitions/jquery.bbq-1.2.d.ts
rename to jquery.bbq/jquery.bbq-1.2.d.ts
diff --git a/Definitions/jquery.dynatree-1.2.d.ts b/jquery.dynatree/jquery.dynatree-1.2.d.ts
similarity index 100%
rename from Definitions/jquery.dynatree-1.2.d.ts
rename to jquery.dynatree/jquery.dynatree-1.2.d.ts
diff --git a/Definitions/jquery.validation-1.10.d.ts b/jquery.validation/jquery.validation-1.10.d.ts
similarity index 100%
rename from Definitions/jquery.validation-1.10.d.ts
rename to jquery.validation/jquery.validation-1.10.d.ts
diff --git a/Tests/jquery.validation-tests.ts b/jquery.validation/jquery.validation-tests.ts
similarity index 100%
rename from Tests/jquery.validation-tests.ts
rename to jquery.validation/jquery.validation-tests.ts
diff --git a/Definitions/jquery-1.8.d.ts b/jquery/jquery-1.8.d.ts
similarity index 100%
rename from Definitions/jquery-1.8.d.ts
rename to jquery/jquery-1.8.d.ts
diff --git a/Tests/jquery-tests.ts b/jquery/jquery-tests.ts
similarity index 100%
rename from Tests/jquery-tests.ts
rename to jquery/jquery-tests.ts
diff --git a/Definitions/jquerymobile-1.2.d.ts b/jquerymobile/jquerymobile-1.2.d.ts
similarity index 100%
rename from Definitions/jquerymobile-1.2.d.ts
rename to jquerymobile/jquerymobile-1.2.d.ts
diff --git a/Tests/jquerymobile-tests.ts b/jquerymobile/jquerymobile-tests.ts
similarity index 100%
rename from Tests/jquerymobile-tests.ts
rename to jquerymobile/jquerymobile-tests.ts
diff --git a/Definitions/jqueryui-1.9.d.ts b/jqueryui/jqueryui-1.9.d.ts
similarity index 100%
rename from Definitions/jqueryui-1.9.d.ts
rename to jqueryui/jqueryui-1.9.d.ts
diff --git a/Tests/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts
similarity index 100%
rename from Tests/jqueryui-tests.ts
rename to jqueryui/jqueryui-tests.ts
diff --git a/Definitions/knockback-0.16.d.ts b/knockback/knockback-0.16.d.ts
similarity index 100%
rename from Definitions/knockback-0.16.d.ts
rename to knockback/knockback-0.16.d.ts
diff --git a/Definitions/knockout-2.2.d.ts b/knockout/knockout-2.2.d.ts
similarity index 96%
rename from Definitions/knockout-2.2.d.ts
rename to knockout/knockout-2.2.d.ts
index f5d77ecf9d..0afaf12530 100644
--- a/Definitions/knockout-2.2.d.ts
+++ b/knockout/knockout-2.2.d.ts
@@ -1,294 +1,294 @@
-// Type definitions for Knockout 2.2
-// Project: http://knockoutjs.com
-// Definitions by: Boris Yankov
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-interface KnockoutSubscribableFunctions {
- extend(source);
- dispose(): void;
- peek(): any;
- valueHasMutated(): void;
-
- valueWillMutate(): void;
-}
-
-interface KnockoutComputedFunctions extends KnockoutSubscribableFunctions {
- getDependenciesCount(): number;
- hasWriteFunction(): bool;
-}
-
-interface KnockoutObservableFunctions extends KnockoutSubscribableFunctions {
-}
-
-interface KnockoutObservableArrayFunctions extends KnockoutObservableFunctions {
- // General Array functions
- indexOf(searchElement, fromIndex?: number): number;
- slice(start: number, end?: number): any[];
- splice(start: number): any[];
- splice(start: number, deleteCount: number, ...items: any[]): any[];
- pop();
- push(...items: any[]): void;
- shift();
- unshift(...items: any[]): number;
- reverse(): any[];
- sort(): void;
- sort(compareFunction): void;
-
- // Ko specific
- remove(item): any[];
- removeAll(items: any[]): any[];
- removeAll(): any[];
-
- destroy(item): void;
- destroyAll(items: any[]): void;
- destroyAll(): void;
-}
-
-interface KnockoutSubscribableStatic {
- fn: KnockoutSubscribableFunctions;
-
- new (): KnockoutSubscription;
-}
-
-interface KnockoutSubscription extends KnockoutSubscribableFunctions {
- subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
- notifySubscribers(valueToWrite, topic?: string);
-}
-
-interface KnockoutComputedStatic {
- fn: KnockoutComputedFunctions;
-
- (): KnockoutComputed;
- (func: Function, context?: any): KnockoutComputed;
- (def: KnockoutComputedDefine): KnockoutComputed;
- (options?: any): KnockoutComputed;
-}
-
-interface KnockoutComputed extends KnockoutComputedFunctions {
- (): any;
- (value: any): void;
-
- subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
- notifySubscribers(valueToWrite, topic?: string);
-}
-
-interface KnockoutObservableArrayStatic {
-
- fn: KnockoutObservableArrayFunctions;
-
- (): KnockoutObservableArray;
- (value: any[]): KnockoutObservableArray;
-}
-
-interface KnockoutObservableArray extends KnockoutObservableArrayFunctions {
- (): any[];
- (value: any[]): void;
-
- subscribe(callback: (newValue: any[]) => void, target?:any, topic?: string): KnockoutSubscription;
- notifySubscribers(valueToWrite: any[], topic?: string);
-}
-
-interface KnockoutObservableStatic {
- fn: KnockoutObservableFunctions;
-
- (value: string): KnockoutObservableString;
- (value: Date): KnockoutObservableDate;
- (value: number): KnockoutObservableNumber;
- (value: bool): KnockoutObservableBool;
- (value?: any): KnockoutObservableAny;
-}
-
-interface KnockoutObservableBase extends KnockoutObservableFunctions {
-}
-
-interface KnockoutObservableAny extends KnockoutObservableBase {
-
- (): any;
- (value): void;
-
- subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
- notifySubscribers(valueToWrite, topic?: string);
-}
-
-interface KnockoutObservableString extends KnockoutObservableBase {
- (): string;
- (value: string): void;
-
- subscribe(callback: (newValue: string) => void, target?:any, topic?: string): KnockoutSubscription;
- notifySubscribers(valueToWrite: string, topic?: string);
-}
-
-
-interface KnockoutObservableNumber extends KnockoutObservableBase {
- (): number;
- (value: number): void;
-
- subscribe(callback: (newValue: number) => void, target?:any, topic?: string): KnockoutSubscription;
- notifySubscribers(valueToWrite: number, topic?: string);
-}
-
-interface KnockoutObservableBool extends KnockoutObservableBase {
- (): bool;
- (value: bool): void;
-
- subscribe(callback: (newValue: bool) => void, target?:any, topic?: string): KnockoutSubscription;
- notifySubscribers(valueToWrite: bool, topic?: string);
-}
-
-interface KnockoutObservableDate extends KnockoutObservableBase {
- (): Date;
- (value: Date): void;
-
- subscribe(callback: (newValue: Date) => void, target?:any, topic?: string): KnockoutSubscription;
- notifySubscribers(valueToWrite: Date, topic?: string);
-}
-
-interface KnockoutComputedDefine {
- read(): any;
- write(any);
-}
-
-interface KnockoutBindingContext {
- $parent: any;
- $parents: any[];
- $root: any;
- $data: any;
- $index?: number;
- $parentContext?: KnockoutBindingContext;
-
- extend(any): any;
- createChildContext(any): any;
-}
-
-interface KnockoutBindingHandler {
- init?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
- update?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
- options?: any;
-}
-
-interface KnockoutBindingHandlers {
- // Controlling text and appearance
- visible: KnockoutBindingHandler;
- text: KnockoutBindingHandler;
- html: KnockoutBindingHandler;
- css: KnockoutBindingHandler;
- style: KnockoutBindingHandler;
- attr: KnockoutBindingHandler;
-
- // Control Flow
- foreach: KnockoutBindingHandler;
- if: KnockoutBindingHandler;
- ifnot: KnockoutBindingHandler;
- with: KnockoutBindingHandler;
-
- // Working with form fields
- click: KnockoutBindingHandler;
- event: KnockoutBindingHandler;
- submit: KnockoutBindingHandler;
- enable: KnockoutBindingHandler;
- disable: KnockoutBindingHandler;
- value: KnockoutBindingHandler;
- hasfocus: KnockoutBindingHandler;
- checked: KnockoutBindingHandler;
- options: KnockoutBindingHandler;
- selectedOptions: KnockoutBindingHandler;
- uniqueName: KnockoutBindingHandler;
-
- // Rendering templates
- template: KnockoutBindingHandler;
-}
-
-interface KnockoutMemoization {
- memoize(callback);
- unmemoize(memoId, callbackParams);
- unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray);
- parseMemoText(memoText);
-}
-
-interface KnockoutVirtualElements {
- allowedBindings;
- emptyNode;
- firstChild;
- insertAfter;
- nextSibling;
- prepend;
- setDomNodeChildren;
-}
-
-interface KnockoutExtenders {
- throttle(target: any, timeout: number): KnockoutComputed;
- notify(target: any, notifyWhen: string): any;
-}
-
-interface KnockoutUtils {
-
- fieldsIncludedWithJsonPost: any[];
-
- arrayForEach(array: any[], action: (any) => void ): void;
- arrayIndexOf(array: any[], item: any): number;
- arrayFirst(array: any[], predicate: (item) => bool, predicateOwner?: any): any;
- arrayRemoveItem(array: any[], itemToRemove: any): void;
- arrayGetDistinctValues(array: any[]): any[];
- arrayMap(array: any[], mapping: (item) => any): any[];
- arrayFilter(array: any[], predicate: (item) => bool): any[];
- arrayPushAll(array: any[], valuesToPush: any[]): any[];
-
- extend(target, source);
-
- emptyDomNode(domNode): void;
- moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
- cloneNodes(nodesArray: any[], shouldCleanNodes: bool): any[];
- setDomNodeChildren(domNode: any, childNodes: any[]): void;
- replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
- setOptionNodeSelectionState(optionNode: any, isSelected: bool): void;
- stringTrim(str: string): string;
- stringTokenize(str: string, delimiter: string): string;
- stringStartsWith(str: string, startsWith: string): string;
- domNodeIsContainedBy(node: any, containedByNode: any): bool;
- domNodeIsAttachedToDocument(node: any): bool;
- tagNameLower(element: any): string;
- registerEventHandler(element: any, eventType: any, handler: Function): void;
- triggerEvent(element: any, eventType: any): void;
- unwrapObservable(value: any): any;
- toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: bool): void;
- setTextContent(element: any, textContent: string): void;
- setElementName(element: any, name: string): void;
- ensureSelectElementIsRenderedCorrectly(selectElement);
- forceRefresh(node: any): void;
- ensureSelectElementIsRenderedCorrectly(selectElement: any): void;
- range(min: any, max: any): any;
- makeArray(arrayLikeObject: any): any[];
- getFormFields(form: any, fieldName: string): any[];
- parseJson(jsonString: string): any;
- stringifyJson(data: any, replacer: Function, space: string): string;
- postJson(urlOrForm: any, data: any, options: any): void;
-
- domNodeDisposal;
-}
-
-
-interface KnockoutStatic {
- utils: KnockoutUtils;
- memoization: KnockoutMemoization;
- bindingHandlers: KnockoutBindingHandlers;
- virtualElements: KnockoutVirtualElements;
- extenders: KnockoutExtenders;
-
- applyBindings(viewModel: any, rootNode?: any): void;
- applyBindingsToDescendants(viewModel: any, rootNode: any): void;
-
- subscribable: KnockoutSubscribableStatic;
- observable: KnockoutObservableStatic;
- computed: KnockoutComputedStatic;
- observableArray: KnockoutObservableArrayStatic;
-
- contextFor(node: any): any;
- isSubscribable(instance: any): bool;
- toJSON(viewModel: any, replacer?: Function, space?: any): string;
- toJS(viewModel: any): any;
- isObservable(instance: any): bool;
- dataFor(node: any): any;
- removeNode(node: Element);
-}
-
+// Type definitions for Knockout 2.2
+// Project: http://knockoutjs.com
+// Definitions by: Boris Yankov
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+interface KnockoutSubscribableFunctions {
+ extend(source);
+ dispose(): void;
+ peek(): any;
+ valueHasMutated(): void;
+
+ valueWillMutate(): void;
+}
+
+interface KnockoutComputedFunctions extends KnockoutSubscribableFunctions {
+ getDependenciesCount(): number;
+ hasWriteFunction(): bool;
+}
+
+interface KnockoutObservableFunctions extends KnockoutSubscribableFunctions {
+}
+
+interface KnockoutObservableArrayFunctions extends KnockoutObservableFunctions {
+ // General Array functions
+ indexOf(searchElement, fromIndex?: number): number;
+ slice(start: number, end?: number): any[];
+ splice(start: number): any[];
+ splice(start: number, deleteCount: number, ...items: any[]): any[];
+ pop();
+ push(...items: any[]): void;
+ shift();
+ unshift(...items: any[]): number;
+ reverse(): any[];
+ sort(): void;
+ sort(compareFunction): void;
+
+ // Ko specific
+ remove(item): any[];
+ removeAll(items: any[]): any[];
+ removeAll(): any[];
+
+ destroy(item): void;
+ destroyAll(items: any[]): void;
+ destroyAll(): void;
+}
+
+interface KnockoutSubscribableStatic {
+ fn: KnockoutSubscribableFunctions;
+
+ new (): KnockoutSubscription;
+}
+
+interface KnockoutSubscription extends KnockoutSubscribableFunctions {
+ subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
+ notifySubscribers(valueToWrite, topic?: string);
+}
+
+interface KnockoutComputedStatic {
+ fn: KnockoutComputedFunctions;
+
+ (): KnockoutComputed;
+ (func: Function, context?: any): KnockoutComputed;
+ (def: KnockoutComputedDefine): KnockoutComputed;
+ (options?: any): KnockoutComputed;
+}
+
+interface KnockoutComputed extends KnockoutComputedFunctions {
+ (): any;
+ (value: any): void;
+
+ subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
+ notifySubscribers(valueToWrite, topic?: string);
+}
+
+interface KnockoutObservableArrayStatic {
+
+ fn: KnockoutObservableArrayFunctions;
+
+ (): KnockoutObservableArray;
+ (value: any[]): KnockoutObservableArray;
+}
+
+interface KnockoutObservableArray extends KnockoutObservableArrayFunctions {
+ (): any[];
+ (value: any[]): void;
+
+ subscribe(callback: (newValue: any[]) => void, target?:any, topic?: string): KnockoutSubscription;
+ notifySubscribers(valueToWrite: any[], topic?: string);
+}
+
+interface KnockoutObservableStatic {
+ fn: KnockoutObservableFunctions;
+
+ (value: string): KnockoutObservableString;
+ (value: Date): KnockoutObservableDate;
+ (value: number): KnockoutObservableNumber;
+ (value: bool): KnockoutObservableBool;
+ (value?: any): KnockoutObservableAny;
+}
+
+interface KnockoutObservableBase extends KnockoutObservableFunctions {
+}
+
+interface KnockoutObservableAny extends KnockoutObservableBase {
+
+ (): any;
+ (value): void;
+
+ subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
+ notifySubscribers(valueToWrite, topic?: string);
+}
+
+interface KnockoutObservableString extends KnockoutObservableBase {
+ (): string;
+ (value: string): void;
+
+ subscribe(callback: (newValue: string) => void, target?:any, topic?: string): KnockoutSubscription;
+ notifySubscribers(valueToWrite: string, topic?: string);
+}
+
+
+interface KnockoutObservableNumber extends KnockoutObservableBase {
+ (): number;
+ (value: number): void;
+
+ subscribe(callback: (newValue: number) => void, target?:any, topic?: string): KnockoutSubscription;
+ notifySubscribers(valueToWrite: number, topic?: string);
+}
+
+interface KnockoutObservableBool extends KnockoutObservableBase {
+ (): bool;
+ (value: bool): void;
+
+ subscribe(callback: (newValue: bool) => void, target?:any, topic?: string): KnockoutSubscription;
+ notifySubscribers(valueToWrite: bool, topic?: string);
+}
+
+interface KnockoutObservableDate extends KnockoutObservableBase {
+ (): Date;
+ (value: Date): void;
+
+ subscribe(callback: (newValue: Date) => void, target?:any, topic?: string): KnockoutSubscription;
+ notifySubscribers(valueToWrite: Date, topic?: string);
+}
+
+interface KnockoutComputedDefine {
+ read(): any;
+ write(any);
+}
+
+interface KnockoutBindingContext {
+ $parent: any;
+ $parents: any[];
+ $root: any;
+ $data: any;
+ $index?: number;
+ $parentContext?: KnockoutBindingContext;
+
+ extend(any): any;
+ createChildContext(any): any;
+}
+
+interface KnockoutBindingHandler {
+ init?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
+ update?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
+ options?: any;
+}
+
+interface KnockoutBindingHandlers {
+ // Controlling text and appearance
+ visible: KnockoutBindingHandler;
+ text: KnockoutBindingHandler;
+ html: KnockoutBindingHandler;
+ css: KnockoutBindingHandler;
+ style: KnockoutBindingHandler;
+ attr: KnockoutBindingHandler;
+
+ // Control Flow
+ foreach: KnockoutBindingHandler;
+ if: KnockoutBindingHandler;
+ ifnot: KnockoutBindingHandler;
+ with: KnockoutBindingHandler;
+
+ // Working with form fields
+ click: KnockoutBindingHandler;
+ event: KnockoutBindingHandler;
+ submit: KnockoutBindingHandler;
+ enable: KnockoutBindingHandler;
+ disable: KnockoutBindingHandler;
+ value: KnockoutBindingHandler;
+ hasfocus: KnockoutBindingHandler;
+ checked: KnockoutBindingHandler;
+ options: KnockoutBindingHandler;
+ selectedOptions: KnockoutBindingHandler;
+ uniqueName: KnockoutBindingHandler;
+
+ // Rendering templates
+ template: KnockoutBindingHandler;
+}
+
+interface KnockoutMemoization {
+ memoize(callback);
+ unmemoize(memoId, callbackParams);
+ unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray);
+ parseMemoText(memoText);
+}
+
+interface KnockoutVirtualElements {
+ allowedBindings;
+ emptyNode;
+ firstChild;
+ insertAfter;
+ nextSibling;
+ prepend;
+ setDomNodeChildren;
+}
+
+interface KnockoutExtenders {
+ throttle(target: any, timeout: number): KnockoutComputed;
+ notify(target: any, notifyWhen: string): any;
+}
+
+interface KnockoutUtils {
+
+ fieldsIncludedWithJsonPost: any[];
+
+ arrayForEach(array: any[], action: (any) => void ): void;
+ arrayIndexOf(array: any[], item: any): number;
+ arrayFirst(array: any[], predicate: (item) => bool, predicateOwner?: any): any;
+ arrayRemoveItem(array: any[], itemToRemove: any): void;
+ arrayGetDistinctValues(array: any[]): any[];
+ arrayMap(array: any[], mapping: (item) => any): any[];
+ arrayFilter(array: any[], predicate: (item) => bool): any[];
+ arrayPushAll(array: any[], valuesToPush: any[]): any[];
+
+ extend(target, source);
+
+ emptyDomNode(domNode): void;
+ moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
+ cloneNodes(nodesArray: any[], shouldCleanNodes: bool): any[];
+ setDomNodeChildren(domNode: any, childNodes: any[]): void;
+ replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
+ setOptionNodeSelectionState(optionNode: any, isSelected: bool): void;
+ stringTrim(str: string): string;
+ stringTokenize(str: string, delimiter: string): string;
+ stringStartsWith(str: string, startsWith: string): string;
+ domNodeIsContainedBy(node: any, containedByNode: any): bool;
+ domNodeIsAttachedToDocument(node: any): bool;
+ tagNameLower(element: any): string;
+ registerEventHandler(element: any, eventType: any, handler: Function): void;
+ triggerEvent(element: any, eventType: any): void;
+ unwrapObservable(value: any): any;
+ toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: bool): void;
+ setTextContent(element: any, textContent: string): void;
+ setElementName(element: any, name: string): void;
+ ensureSelectElementIsRenderedCorrectly(selectElement);
+ forceRefresh(node: any): void;
+ ensureSelectElementIsRenderedCorrectly(selectElement: any): void;
+ range(min: any, max: any): any;
+ makeArray(arrayLikeObject: any): any[];
+ getFormFields(form: any, fieldName: string): any[];
+ parseJson(jsonString: string): any;
+ stringifyJson(data: any, replacer: Function, space: string): string;
+ postJson(urlOrForm: any, data: any, options: any): void;
+
+ domNodeDisposal;
+}
+
+
+interface KnockoutStatic {
+ utils: KnockoutUtils;
+ memoization: KnockoutMemoization;
+ bindingHandlers: KnockoutBindingHandlers;
+ virtualElements: KnockoutVirtualElements;
+ extenders: KnockoutExtenders;
+
+ applyBindings(viewModel: any, rootNode?: any): void;
+ applyBindingsToDescendants(viewModel: any, rootNode: any): void;
+
+ subscribable: KnockoutSubscribableStatic;
+ observable: KnockoutObservableStatic;
+ computed: KnockoutComputedStatic;
+ observableArray: KnockoutObservableArrayStatic;
+
+ contextFor(node: any): any;
+ isSubscribable(instance: any): bool;
+ toJSON(viewModel: any, replacer?: Function, space?: any): string;
+ toJS(viewModel: any): any;
+ isObservable(instance: any): bool;
+ dataFor(node: any): any;
+ removeNode(node: Element);
+}
+
declare var ko: KnockoutStatic;
\ No newline at end of file
diff --git a/Tests/knockout-tests.ts b/knockout/knockout-tests.ts
similarity index 97%
rename from Tests/knockout-tests.ts
rename to knockout/knockout-tests.ts
index f5be6de5b6..664e005454 100644
--- a/Tests/knockout-tests.ts
+++ b/knockout/knockout-tests.ts
@@ -1,576 +1,576 @@
-///
-///
-
-declare var $;
-
-function test_creatingVMs() {
- var myViewModel = {
- personName: ko.observable('Bob'),
- personAge: ko.observable(123)
- };
- ko.applyBindings(myViewModel);
- ko.applyBindings(myViewModel, document.getElementById('someElementId'));
-
- myViewModel.personName();
- myViewModel.personName('Mary');
- myViewModel.personAge(50);
-
- myViewModel.personName.subscribe(function (newValue) {
- alert("The person's new name is " + newValue);
- });
-
- var subscription = myViewModel.personName.subscribe(function (newValue) { });
- subscription.dispose();
-}
-
-function test_computed() {
- function AppViewModel() {
- var self = this;
-
- self.firstName = ko.observable('Bob');
- self.lastName = ko.observable('Smith');
- self.fullName = ko.computed(function () {
- return self.firstName() + " " + self.lastName();
- });
- }
-
- function MyViewModel() {
- this.firstName = ko.observable('Planet');
- this.lastName = ko.observable('Earth');
-
- this.fullName = ko.computed({
- read: function () {
- return this.firstName() + " " + this.lastName();
- },
- write: function (value) {
- var lastSpacePos = value.lastIndexOf(" ");
- if (lastSpacePos > 0) {
- this.firstName(value.substring(0, lastSpacePos));
- this.lastName(value.substring(lastSpacePos + 1));
- }
- },
- owner: this
- });
- }
-
- function MyViewModel() {
- this.price = ko.observable(25.99);
-
- this.formattedPrice = ko.computed({
- read: function () {
- return '$' + this.price().toFixed(2);
- },
- write: function (value) {
- value = parseFloat(value.replace(/[^\.\d]/g, ""));
- this.price(isNaN(value) ? 0 : value);
- },
- owner: this
- });
- }
-
- function MyViewModel() {
- this.acceptedNumericValue = ko.observable(123);
- this.lastInputWasValid = ko.observable(true);
-
- this.attemptedValue = ko.computed({
- read: this.acceptedNumericValue,
- write: function (value) {
- if (isNaN(value))
- this.lastInputWasValid(false);
- else {
- this.lastInputWasValid(true);
- this.acceptedNumericValue(value);
- }
- },
- owner: this
- });
- }
-
- ko.applyBindings(new MyViewModel());
-}
-
-class GetterViewModel {
- private _selectedRange: KnockoutObservableAny;
-
- constructor() {
- this._selectedRange = ko.observable();
- }
-
- public get range() : KnockoutObservableAny {
- return this._selectedRange;
- }
-}
-
-function testGetter() {
- var model = new GetterViewModel();
-
- model.range.subscribe((range: number) => {
- });
-}
-
-function test_observableArrays() {
- var myObservableArray = ko.observableArray();
- myObservableArray.push('Some value');
- var anotherObservableArray = ko.observableArray([
- { name: "Bungle", type: "Bear" },
- { name: "George", type: "Hippo" },
- { name: "Zippy", type: "Unknown" }
- ]);
-
- myObservableArray().length;
- myObservableArray()[0];
-
- myObservableArray.indexOf('Blah');
- myObservableArray.push('Some new value');
- myObservableArray.pop();
- myObservableArray.unshift('Some new value');
- myObservableArray.shift();
- myObservableArray.reverse();
- myObservableArray.sort(function (left, right) { return left.lastName == right.lastName ? 0 : (left.lastName < right.lastName ? -1 : 1) });
- myObservableArray.splice(1, 3);
-
- myObservableArray.remove('Blah');
- myObservableArray.remove(function (item) { return item.age < 18 });
- myObservableArray.removeAll(['Chad', 132, undefined]);
- myObservableArray.removeAll();
- myObservableArray.destroy('Blah');
- myObservableArray.destroy(function (someItem) { return someItem.age < 18 });
- myObservableArray.destroyAll(['Chad', 132, undefined]);
- myObservableArray.destroyAll();
-
- ko.utils.arrayForEach(myObservableArray(), function (item) { });
-}
-
-// You have to extend knockout for your own handlers
-interface KnockoutBindingHandlers {
- yourBindingName: KnockoutBindingHandler;
- slideVisible: KnockoutBindingHandler;
- hasFocus: KnockoutBindingHandler;
- allowBindings: KnockoutBindingHandler;
- withProperties: KnockoutBindingHandler;
- randomOrder: KnockoutBindingHandler;
-}
-
-function test_bindings() {
- var currentProfit = ko.observable(150000);
- ko.applyBindings({
- people: [
- { firstName: 'Bert', lastName: 'Bertington' },
- { firstName: 'Charles', lastName: 'Charlesforth' },
- { firstName: 'Denise', lastName: 'Dentiste' }
- ]
- });
- var viewModel = { availableCountries: ko.observableArray(['France', 'Germany', 'Spain']) };
- viewModel.availableCountries.push('China');
-
- ko.bindingHandlers.yourBindingName = {
- init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
- },
- update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
- }
- };
- ko.bindingHandlers.slideVisible = {
- update: function (element, valueAccessor, allBindingsAccessor) {
- var value = valueAccessor(), allBindings = allBindingsAccessor();
- var valueUnwrapped = ko.utils.unwrapObservable(value);
- var duration = allBindings.slideDuration || 400;
- if (valueUnwrapped == true)
- $(element).slideDown(duration);
- else
- $(element).slideUp(duration);
- },
- init: function (element, valueAccessor) {
- var value = ko.utils.unwrapObservable(valueAccessor());
- $(element).toggle(value);
- },
- update: function (element, valueAccessor, allBindingsAccessor) {
- }
- };
- ko.bindingHandlers.hasFocus = {
- init: function (element, valueAccessor) {
- $(element).focus(function () {
- var value = valueAccessor();
- value(true);
- });
- $(element).blur(function () {
- var value = valueAccessor();
- value(false);
- });
- },
- update: function (element, valueAccessor) {
- var value = valueAccessor();
- if (ko.utils.unwrapObservable(value))
- element.focus();
- else
- element.blur();
- }
- };
- ko.bindingHandlers.allowBindings = {
- init: function (elem, valueAccessor) {
- var shouldAllowBindings = ko.utils.unwrapObservable(valueAccessor());
- return { controlsDescendantBindings: !shouldAllowBindings };
- }
- };
- ko.bindingHandlers.withProperties = {
- init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
- var newProperties = valueAccessor(),
- innerBindingContext = bindingContext.extend(newProperties);
- ko.applyBindingsToDescendants(innerBindingContext, element);
- return { controlsDescendantBindings: true };
- }
- };
- ko.bindingHandlers.withProperties = {
- init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
- var newProperties = valueAccessor(),
- childBindingContext = bindingContext.createChildContext(viewModel);
- ko.utils.extend(childBindingContext, newProperties);
- ko.applyBindingsToDescendants(childBindingContext, element);
- return { controlsDescendantBindings: true };
- }
- };
- ko.bindingHandlers.randomOrder = {
- init: function (elem, valueAccessor) {
- var child = ko.virtualElements.firstChild(elem),
- childElems = [];
- while (child) {
- childElems.push(child);
- child = ko.virtualElements.nextSibling(child);
- }
- ko.virtualElements.emptyNode(elem);
- while (childElems.length) {
- var randomIndex = Math.floor(Math.random() * childElems.length),
- chosenChild = childElems.splice(randomIndex, 1);
- ko.virtualElements.prepend(elem, chosenChild[0]);
- }
- }
- };
-
- var node, containerElem, nodeToInsert, insertAfter, nodeToPrepend, arrayOfNodes;
- ko.virtualElements.allowedBindings.mySuperBinding = true;
- ko.virtualElements.emptyNode(containerElem);
- ko.virtualElements.firstChild(containerElem);
- ko.virtualElements.insertAfter(containerElem, nodeToInsert, insertAfter);
- ko.virtualElements.nextSibling(node);
- ko.virtualElements.prepend(containerElem, nodeToPrepend);
- ko.virtualElements.setDomNodeChildren(containerElem, arrayOfNodes);
-}
-
-// Have to define your own extenders
-interface KnockoutExtenders {
- logChange(target, option);
- numeric(target, precision);
- required(target, overrideMessage);
-}
-
-interface KnockoutObservableArrayFunctions {
- filterByProperty(propName, matchValue): KnockoutComputed;
-}
-
-declare var validate;
-
-function test_more() {
- var viewModel = {
- firstName: ko.observable("Bert"),
- lastName: ko.observable("Smith"),
- pets: ko.observableArray(["Cat", "Dog", "Fish"]),
- type: "Customer",
- hasALotOfPets: null
- };
- viewModel.hasALotOfPets = ko.computed(function () {
- return this.pets().length > 2
- }, viewModel);
- var plainJs = ko.toJS(viewModel);
-
- ko.extenders.logChange = function (target, option) {
- target.subscribe(function (newValue) {
- console.log(option + ": " + newValue);
- });
- return target;
- };
-
- ko.extenders.numeric = function (target, precision) {
- var result = ko.computed({
- read: target,
- write: function (newValue) {
- var current = target(),
- roundingMultiplier = Math.pow(10, precision),
- newValueAsNum = isNaN(newValue) ? 0 : parseFloat(newValue),
- valueToWrite = Math.round(newValueAsNum * roundingMultiplier) / roundingMultiplier;
-
- if (valueToWrite !== current) {
- target(valueToWrite);
- } else {
- if (newValue !== current) {
- target.notifySubscribers(valueToWrite);
- }
- }
- }
- });
-
- result(target());
-
- return result;
- };
-
- function AppViewModel(one, two) {
- this.myNumberOne = ko.observable(one).extend({ numeric: 0 });
- this.myNumberTwo = ko.observable(two).extend({ numeric: 2 });
- }
-
- ko.applyBindings(new AppViewModel(221.2234, 123.4525));
-
- ko.extenders.required = function (target, overrideMessage) {
-
- target.hasError = ko.observable();
- target.validationMessage = ko.observable();
-
- function validate(newValue) {
- target.hasError(newValue ? false : true);
- target.validationMessage(newValue ? "" : overrideMessage || "This field is required");
- }
-
- validate(target());
-
- target.subscribe(validate);
-
- return target;
- };
-
- function AppViewModel(first, last) {
- this.firstName = ko.observable(first).extend({ required: "Please enter a first name" });
- this.lastName = ko.observable(last).extend({ required: "" });
- }
-
- ko.applyBindings(new AppViewModel("Bob", "Smith"));
-
- var first;
- this.firstName = ko.observable(first).extend({ required: "Please enter a first name", logChange: "first name" });
-
- var upperCaseName = ko.computed(function () {
- return name.toUpperCase();
- }).extend({ throttle: 500 });
-
- function AppViewModel() {
- this.instantaneousValue = ko.observable();
- this.throttledValue = ko.computed(this.instantaneousValue)
- .extend({ throttle: 400 });
-
- this.loggedValues = ko.observableArray([]);
- this.throttledValue.subscribe(function (val) {
- if (val !== '')
- this.loggedValues.push(val);
- }, this);
- }
-
- function GridViewModel() {
- this.pageSize = ko.observable(20);
- this.pageIndex = ko.observable(1);
- this.currentPageData = ko.observableArray();
-
- ko.computed(function () {
- var params = { page: this.pageIndex(), size: this.pageSize() };
- $.getJSON('/Some/Json/Service', params, this.currentPageData);
- }, this);
- }
- this.setPageSize = function (newPageSize) {
- this.pageSize(newPageSize);
- this.pageIndex(1);
- }
-
- ko.computed(function () {
- var params = { page: this.pageIndex(), size: this.pageSize() };
- $.getJSON('/Some/Json/Service', params, this.currentPageData);
- }, this).extend({ throttle: 1 });
-
- $(".remove").click(function () {
- viewModel.pets.remove(ko.dataFor(this));
- });
- $(".remove").live("click", function () {
- viewModel.pets.remove(ko.dataFor(this));
- });
-
- $("#people").delegate(".remove", "click", function () {
-
- var context = ko.contextFor(this),
- parentArray = context.$parent.people || context.$parent.children;
-
- parentArray.remove(context.$data);
-
- return false;
- });
- $("#people").delegate(".add", "click", function () {
- var context = ko.contextFor(this),
- childName = context.$data.name() + " child",
- parentArray = context.$data.people || context.$data.children;
-
- context.$root.addChild(childName, parentArray);
-
- return false;
- });
- ko.observableArray.fn.filterByProperty = function (propName, matchValue) {
- return ko.computed(function () {
- var allItems = this(), matchingItems = [];
- for (var i = 0; i < allItems.length; i++) {
- var current = allItems[i];
- if (ko.utils.unwrapObservable(current[propName]) === matchValue)
- matchingItems.push(current);
- }
- return matchingItems;
- }, this);
- }
- function Task(title, done) {
- this.title = ko.observable(title);
- this.done = ko.observable(done);
- }
-
- function AppViewModel() {
- this.tasks = ko.observableArray([
- new Task('Find new desktop background', true),
- new Task('Put shiny stickers on laptop', false),
- new Task('Request more reggae music in the office', true)
- ]);
-
- this.doneTasks = this.tasks.filterByProperty("done", true);
- }
-
- ko.applyBindings(new AppViewModel());
- this.doneTasks = ko.computed(function () {
- var all = this.tasks(), done = [];
- for (var i = 0; i < all.length; i++)
- if (all[i].done())
- done.push(all[i]);
- return done;
- }, this);
-}
-
-function test_mappingplugin() {
- var viewModel = {
- serverTime: ko.observable(),
- numUsers: ko.observable()
- }
- var data = {
- serverTime: '2010-01-07',
- numUsers: 3
- };
- viewModel.serverTime(data.serverTime);
- viewModel.numUsers(data.numUsers);
-
- var viewModel = ko.mapping.fromJS(data);
- ko.mapping.fromJS(data, viewModel);
- var unmapped = ko.mapping.toJS(viewModel);
-
- var viewModel = ko.mapping.fromJS(data);
- ko.mapping.fromJS(data, viewModel);
-
- var myChildModel = function (data) {
- ko.mapping.fromJS(data, {}, this);
-
- this.nameLength = ko.computed(function () {
- return this.name().length;
- }, this);
- }
-
- var oldOptions = ko.mapping.defaultOptions().include;
- ko.mapping.defaultOptions().include = ["alwaysIncludeThis"];
-
- var oldOptions = ko.mapping.defaultOptions().copy;
- ko.mapping.defaultOptions().copy = ["alwaysCopyThis"];
-
- var someObject;
- ko.mapping.fromJS(data, {}, someObject);
- ko.mapping.fromJS(data, {}, this);
-
- var alice, aliceMappingOptions, bob, bobMappingOptions;
- var viewModel = ko.mapping.fromJS(alice, aliceMappingOptions);
- ko.mapping.fromJS(bob, bobMappingOptions, viewModel);
-
- var obj;
- var result = ko.mapping.fromJS(obj, {
- key: function (item) {
- return ko.utils.unwrapObservable(item.id);
- }
- });
-
- result.mappedRemove({ id: 2 });
- var newItem = result.mappedCreate({ id: 3 });
-}
-
-// Define your own functions
-interface KnockoutSubscribableFunctions {
- publishOn(topic: string): any;
- subscribeTo(topic: string): any;
-}
-
-interface KnockoutBindingHandlers {
- isolatedOptions: KnockoutBindingHandler;
-}
-
-function test_misc() {
- // define dummy vars
- var callback: any;
- var target: any;
- var topic: any;
- var vm: any;
- var value: any;
-
- var postbox = new ko.subscribable();
- postbox.subscribe(callback, target, topic);
-
- postbox.subscribe(function (newValue) {
- this.latestTopic(newValue);
- }, vm, "mytopic");
- postbox.notifySubscribers(value, "mytopic");
-
- ko.subscribable.fn.publishOn = function (topic) {
- this.subscribe(function (newValue) {
- postbox.notifySubscribers(newValue, topic);
- });
-
- return this;
- };
-
- this.myObservable = ko.observable("myValue").publishOn("myTopic");
-
- ko.subscribable.fn.subscribeTo = function (topic) {
- postbox.subscribe(this, null, topic);
-
- return this;
- };
-
- this.observableFromAnotherVM = ko.observable().subscribeTo("myTopic");
-
- postbox.subscribe(function (newValue) {
- this(newValue);
- }, this, topic);
-
- ko.bindingHandlers.isolatedOptions = {
- init: function (element, valueAccessor) {
- var args = arguments;
- ko.computed({
- read: function () {
- ko.utils.unwrapObservable(valueAccessor());
- ko.bindingHandlers.options.update.apply(this, args);
- },
- owner: this,
- disposeWhenNodeIsRemoved: element
- });
- }
- };
-
- ko.subscribable.fn.publishOn = function (topic) {
- this.subscribe(function (newValue) {
- postbox.notifySubscribers(newValue, topic);
- });
-
- return this;
- };
-
- this.myObservable = ko.observable("myValue").publishOn("myTopic");
-
- var x = ko.observableArray([1, 2, 3]);
-
- var element;
- ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
- $(element).datepicker("destroy");
- });
+///
+///
+
+declare var $;
+
+function test_creatingVMs() {
+ var myViewModel = {
+ personName: ko.observable('Bob'),
+ personAge: ko.observable(123)
+ };
+ ko.applyBindings(myViewModel);
+ ko.applyBindings(myViewModel, document.getElementById('someElementId'));
+
+ myViewModel.personName();
+ myViewModel.personName('Mary');
+ myViewModel.personAge(50);
+
+ myViewModel.personName.subscribe(function (newValue) {
+ alert("The person's new name is " + newValue);
+ });
+
+ var subscription = myViewModel.personName.subscribe(function (newValue) { });
+ subscription.dispose();
+}
+
+function test_computed() {
+ function AppViewModel() {
+ var self = this;
+
+ self.firstName = ko.observable('Bob');
+ self.lastName = ko.observable('Smith');
+ self.fullName = ko.computed(function () {
+ return self.firstName() + " " + self.lastName();
+ });
+ }
+
+ function MyViewModel() {
+ this.firstName = ko.observable('Planet');
+ this.lastName = ko.observable('Earth');
+
+ this.fullName = ko.computed({
+ read: function () {
+ return this.firstName() + " " + this.lastName();
+ },
+ write: function (value) {
+ var lastSpacePos = value.lastIndexOf(" ");
+ if (lastSpacePos > 0) {
+ this.firstName(value.substring(0, lastSpacePos));
+ this.lastName(value.substring(lastSpacePos + 1));
+ }
+ },
+ owner: this
+ });
+ }
+
+ function MyViewModel() {
+ this.price = ko.observable(25.99);
+
+ this.formattedPrice = ko.computed({
+ read: function () {
+ return '$' + this.price().toFixed(2);
+ },
+ write: function (value) {
+ value = parseFloat(value.replace(/[^\.\d]/g, ""));
+ this.price(isNaN(value) ? 0 : value);
+ },
+ owner: this
+ });
+ }
+
+ function MyViewModel() {
+ this.acceptedNumericValue = ko.observable(123);
+ this.lastInputWasValid = ko.observable(true);
+
+ this.attemptedValue = ko.computed({
+ read: this.acceptedNumericValue,
+ write: function (value) {
+ if (isNaN(value))
+ this.lastInputWasValid(false);
+ else {
+ this.lastInputWasValid(true);
+ this.acceptedNumericValue(value);
+ }
+ },
+ owner: this
+ });
+ }
+
+ ko.applyBindings(new MyViewModel());
+}
+
+class GetterViewModel {
+ private _selectedRange: KnockoutObservableAny;
+
+ constructor() {
+ this._selectedRange = ko.observable();
+ }
+
+ public get range() : KnockoutObservableAny {
+ return this._selectedRange;
+ }
+}
+
+function testGetter() {
+ var model = new GetterViewModel();
+
+ model.range.subscribe((range: number) => {
+ });
+}
+
+function test_observableArrays() {
+ var myObservableArray = ko.observableArray();
+ myObservableArray.push('Some value');
+ var anotherObservableArray = ko.observableArray([
+ { name: "Bungle", type: "Bear" },
+ { name: "George", type: "Hippo" },
+ { name: "Zippy", type: "Unknown" }
+ ]);
+
+ myObservableArray().length;
+ myObservableArray()[0];
+
+ myObservableArray.indexOf('Blah');
+ myObservableArray.push('Some new value');
+ myObservableArray.pop();
+ myObservableArray.unshift('Some new value');
+ myObservableArray.shift();
+ myObservableArray.reverse();
+ myObservableArray.sort(function (left, right) { return left.lastName == right.lastName ? 0 : (left.lastName < right.lastName ? -1 : 1) });
+ myObservableArray.splice(1, 3);
+
+ myObservableArray.remove('Blah');
+ myObservableArray.remove(function (item) { return item.age < 18 });
+ myObservableArray.removeAll(['Chad', 132, undefined]);
+ myObservableArray.removeAll();
+ myObservableArray.destroy('Blah');
+ myObservableArray.destroy(function (someItem) { return someItem.age < 18 });
+ myObservableArray.destroyAll(['Chad', 132, undefined]);
+ myObservableArray.destroyAll();
+
+ ko.utils.arrayForEach(myObservableArray(), function (item) { });
+}
+
+// You have to extend knockout for your own handlers
+interface KnockoutBindingHandlers {
+ yourBindingName: KnockoutBindingHandler;
+ slideVisible: KnockoutBindingHandler;
+ hasFocus: KnockoutBindingHandler;
+ allowBindings: KnockoutBindingHandler;
+ withProperties: KnockoutBindingHandler;
+ randomOrder: KnockoutBindingHandler;
+}
+
+function test_bindings() {
+ var currentProfit = ko.observable(150000);
+ ko.applyBindings({
+ people: [
+ { firstName: 'Bert', lastName: 'Bertington' },
+ { firstName: 'Charles', lastName: 'Charlesforth' },
+ { firstName: 'Denise', lastName: 'Dentiste' }
+ ]
+ });
+ var viewModel = { availableCountries: ko.observableArray(['France', 'Germany', 'Spain']) };
+ viewModel.availableCountries.push('China');
+
+ ko.bindingHandlers.yourBindingName = {
+ init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
+ },
+ update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
+ }
+ };
+ ko.bindingHandlers.slideVisible = {
+ update: function (element, valueAccessor, allBindingsAccessor) {
+ var value = valueAccessor(), allBindings = allBindingsAccessor();
+ var valueUnwrapped = ko.utils.unwrapObservable(value);
+ var duration = allBindings.slideDuration || 400;
+ if (valueUnwrapped == true)
+ $(element).slideDown(duration);
+ else
+ $(element).slideUp(duration);
+ },
+ init: function (element, valueAccessor) {
+ var value = ko.utils.unwrapObservable(valueAccessor());
+ $(element).toggle(value);
+ },
+ update: function (element, valueAccessor, allBindingsAccessor) {
+ }
+ };
+ ko.bindingHandlers.hasFocus = {
+ init: function (element, valueAccessor) {
+ $(element).focus(function () {
+ var value = valueAccessor();
+ value(true);
+ });
+ $(element).blur(function () {
+ var value = valueAccessor();
+ value(false);
+ });
+ },
+ update: function (element, valueAccessor) {
+ var value = valueAccessor();
+ if (ko.utils.unwrapObservable(value))
+ element.focus();
+ else
+ element.blur();
+ }
+ };
+ ko.bindingHandlers.allowBindings = {
+ init: function (elem, valueAccessor) {
+ var shouldAllowBindings = ko.utils.unwrapObservable(valueAccessor());
+ return { controlsDescendantBindings: !shouldAllowBindings };
+ }
+ };
+ ko.bindingHandlers.withProperties = {
+ init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
+ var newProperties = valueAccessor(),
+ innerBindingContext = bindingContext.extend(newProperties);
+ ko.applyBindingsToDescendants(innerBindingContext, element);
+ return { controlsDescendantBindings: true };
+ }
+ };
+ ko.bindingHandlers.withProperties = {
+ init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
+ var newProperties = valueAccessor(),
+ childBindingContext = bindingContext.createChildContext(viewModel);
+ ko.utils.extend(childBindingContext, newProperties);
+ ko.applyBindingsToDescendants(childBindingContext, element);
+ return { controlsDescendantBindings: true };
+ }
+ };
+ ko.bindingHandlers.randomOrder = {
+ init: function (elem, valueAccessor) {
+ var child = ko.virtualElements.firstChild(elem),
+ childElems = [];
+ while (child) {
+ childElems.push(child);
+ child = ko.virtualElements.nextSibling(child);
+ }
+ ko.virtualElements.emptyNode(elem);
+ while (childElems.length) {
+ var randomIndex = Math.floor(Math.random() * childElems.length),
+ chosenChild = childElems.splice(randomIndex, 1);
+ ko.virtualElements.prepend(elem, chosenChild[0]);
+ }
+ }
+ };
+
+ var node, containerElem, nodeToInsert, insertAfter, nodeToPrepend, arrayOfNodes;
+ ko.virtualElements.allowedBindings.mySuperBinding = true;
+ ko.virtualElements.emptyNode(containerElem);
+ ko.virtualElements.firstChild(containerElem);
+ ko.virtualElements.insertAfter(containerElem, nodeToInsert, insertAfter);
+ ko.virtualElements.nextSibling(node);
+ ko.virtualElements.prepend(containerElem, nodeToPrepend);
+ ko.virtualElements.setDomNodeChildren(containerElem, arrayOfNodes);
+}
+
+// Have to define your own extenders
+interface KnockoutExtenders {
+ logChange(target, option);
+ numeric(target, precision);
+ required(target, overrideMessage);
+}
+
+interface KnockoutObservableArrayFunctions {
+ filterByProperty(propName, matchValue): KnockoutComputed;
+}
+
+declare var validate;
+
+function test_more() {
+ var viewModel = {
+ firstName: ko.observable("Bert"),
+ lastName: ko.observable("Smith"),
+ pets: ko.observableArray(["Cat", "Dog", "Fish"]),
+ type: "Customer",
+ hasALotOfPets: null
+ };
+ viewModel.hasALotOfPets = ko.computed(function () {
+ return this.pets().length > 2
+ }, viewModel);
+ var plainJs = ko.toJS(viewModel);
+
+ ko.extenders.logChange = function (target, option) {
+ target.subscribe(function (newValue) {
+ console.log(option + ": " + newValue);
+ });
+ return target;
+ };
+
+ ko.extenders.numeric = function (target, precision) {
+ var result = ko.computed({
+ read: target,
+ write: function (newValue) {
+ var current = target(),
+ roundingMultiplier = Math.pow(10, precision),
+ newValueAsNum = isNaN(newValue) ? 0 : parseFloat(newValue),
+ valueToWrite = Math.round(newValueAsNum * roundingMultiplier) / roundingMultiplier;
+
+ if (valueToWrite !== current) {
+ target(valueToWrite);
+ } else {
+ if (newValue !== current) {
+ target.notifySubscribers(valueToWrite);
+ }
+ }
+ }
+ });
+
+ result(target());
+
+ return result;
+ };
+
+ function AppViewModel(one, two) {
+ this.myNumberOne = ko.observable(one).extend({ numeric: 0 });
+ this.myNumberTwo = ko.observable(two).extend({ numeric: 2 });
+ }
+
+ ko.applyBindings(new AppViewModel(221.2234, 123.4525));
+
+ ko.extenders.required = function (target, overrideMessage) {
+
+ target.hasError = ko.observable();
+ target.validationMessage = ko.observable();
+
+ function validate(newValue) {
+ target.hasError(newValue ? false : true);
+ target.validationMessage(newValue ? "" : overrideMessage || "This field is required");
+ }
+
+ validate(target());
+
+ target.subscribe(validate);
+
+ return target;
+ };
+
+ function AppViewModel(first, last) {
+ this.firstName = ko.observable(first).extend({ required: "Please enter a first name" });
+ this.lastName = ko.observable(last).extend({ required: "" });
+ }
+
+ ko.applyBindings(new AppViewModel("Bob", "Smith"));
+
+ var first;
+ this.firstName = ko.observable(first).extend({ required: "Please enter a first name", logChange: "first name" });
+
+ var upperCaseName = ko.computed(function () {
+ return name.toUpperCase();
+ }).extend({ throttle: 500 });
+
+ function AppViewModel() {
+ this.instantaneousValue = ko.observable();
+ this.throttledValue = ko.computed(this.instantaneousValue)
+ .extend({ throttle: 400 });
+
+ this.loggedValues = ko.observableArray([]);
+ this.throttledValue.subscribe(function (val) {
+ if (val !== '')
+ this.loggedValues.push(val);
+ }, this);
+ }
+
+ function GridViewModel() {
+ this.pageSize = ko.observable(20);
+ this.pageIndex = ko.observable(1);
+ this.currentPageData = ko.observableArray();
+
+ ko.computed(function () {
+ var params = { page: this.pageIndex(), size: this.pageSize() };
+ $.getJSON('/Some/Json/Service', params, this.currentPageData);
+ }, this);
+ }
+ this.setPageSize = function (newPageSize) {
+ this.pageSize(newPageSize);
+ this.pageIndex(1);
+ }
+
+ ko.computed(function () {
+ var params = { page: this.pageIndex(), size: this.pageSize() };
+ $.getJSON('/Some/Json/Service', params, this.currentPageData);
+ }, this).extend({ throttle: 1 });
+
+ $(".remove").click(function () {
+ viewModel.pets.remove(ko.dataFor(this));
+ });
+ $(".remove").live("click", function () {
+ viewModel.pets.remove(ko.dataFor(this));
+ });
+
+ $("#people").delegate(".remove", "click", function () {
+
+ var context = ko.contextFor(this),
+ parentArray = context.$parent.people || context.$parent.children;
+
+ parentArray.remove(context.$data);
+
+ return false;
+ });
+ $("#people").delegate(".add", "click", function () {
+ var context = ko.contextFor(this),
+ childName = context.$data.name() + " child",
+ parentArray = context.$data.people || context.$data.children;
+
+ context.$root.addChild(childName, parentArray);
+
+ return false;
+ });
+ ko.observableArray.fn.filterByProperty = function (propName, matchValue) {
+ return ko.computed(function () {
+ var allItems = this(), matchingItems = [];
+ for (var i = 0; i < allItems.length; i++) {
+ var current = allItems[i];
+ if (ko.utils.unwrapObservable(current[propName]) === matchValue)
+ matchingItems.push(current);
+ }
+ return matchingItems;
+ }, this);
+ }
+ function Task(title, done) {
+ this.title = ko.observable(title);
+ this.done = ko.observable(done);
+ }
+
+ function AppViewModel() {
+ this.tasks = ko.observableArray([
+ new Task('Find new desktop background', true),
+ new Task('Put shiny stickers on laptop', false),
+ new Task('Request more reggae music in the office', true)
+ ]);
+
+ this.doneTasks = this.tasks.filterByProperty("done", true);
+ }
+
+ ko.applyBindings(new AppViewModel());
+ this.doneTasks = ko.computed(function () {
+ var all = this.tasks(), done = [];
+ for (var i = 0; i < all.length; i++)
+ if (all[i].done())
+ done.push(all[i]);
+ return done;
+ }, this);
+}
+
+function test_mappingplugin() {
+ var viewModel = {
+ serverTime: ko.observable(),
+ numUsers: ko.observable()
+ }
+ var data = {
+ serverTime: '2010-01-07',
+ numUsers: 3
+ };
+ viewModel.serverTime(data.serverTime);
+ viewModel.numUsers(data.numUsers);
+
+ var viewModel = ko.mapping.fromJS(data);
+ ko.mapping.fromJS(data, viewModel);
+ var unmapped = ko.mapping.toJS(viewModel);
+
+ var viewModel = ko.mapping.fromJS(data);
+ ko.mapping.fromJS(data, viewModel);
+
+ var myChildModel = function (data) {
+ ko.mapping.fromJS(data, {}, this);
+
+ this.nameLength = ko.computed(function () {
+ return this.name().length;
+ }, this);
+ }
+
+ var oldOptions = ko.mapping.defaultOptions().include;
+ ko.mapping.defaultOptions().include = ["alwaysIncludeThis"];
+
+ var oldOptions = ko.mapping.defaultOptions().copy;
+ ko.mapping.defaultOptions().copy = ["alwaysCopyThis"];
+
+ var someObject;
+ ko.mapping.fromJS(data, {}, someObject);
+ ko.mapping.fromJS(data, {}, this);
+
+ var alice, aliceMappingOptions, bob, bobMappingOptions;
+ var viewModel = ko.mapping.fromJS(alice, aliceMappingOptions);
+ ko.mapping.fromJS(bob, bobMappingOptions, viewModel);
+
+ var obj;
+ var result = ko.mapping.fromJS(obj, {
+ key: function (item) {
+ return ko.utils.unwrapObservable(item.id);
+ }
+ });
+
+ result.mappedRemove({ id: 2 });
+ var newItem = result.mappedCreate({ id: 3 });
+}
+
+// Define your own functions
+interface KnockoutSubscribableFunctions {
+ publishOn(topic: string): any;
+ subscribeTo(topic: string): any;
+}
+
+interface KnockoutBindingHandlers {
+ isolatedOptions: KnockoutBindingHandler;
+}
+
+function test_misc() {
+ // define dummy vars
+ var callback: any;
+ var target: any;
+ var topic: any;
+ var vm: any;
+ var value: any;
+
+ var postbox = new ko.subscribable();
+ postbox.subscribe(callback, target, topic);
+
+ postbox.subscribe(function (newValue) {
+ this.latestTopic(newValue);
+ }, vm, "mytopic");
+ postbox.notifySubscribers(value, "mytopic");
+
+ ko.subscribable.fn.publishOn = function (topic) {
+ this.subscribe(function (newValue) {
+ postbox.notifySubscribers(newValue, topic);
+ });
+
+ return this;
+ };
+
+ this.myObservable = ko.observable("myValue").publishOn("myTopic");
+
+ ko.subscribable.fn.subscribeTo = function (topic) {
+ postbox.subscribe(this, null, topic);
+
+ return this;
+ };
+
+ this.observableFromAnotherVM = ko.observable().subscribeTo("myTopic");
+
+ postbox.subscribe(function (newValue) {
+ this(newValue);
+ }, this, topic);
+
+ ko.bindingHandlers.isolatedOptions = {
+ init: function (element, valueAccessor) {
+ var args = arguments;
+ ko.computed({
+ read: function () {
+ ko.utils.unwrapObservable(valueAccessor());
+ ko.bindingHandlers.options.update.apply(this, args);
+ },
+ owner: this,
+ disposeWhenNodeIsRemoved: element
+ });
+ }
+ };
+
+ ko.subscribable.fn.publishOn = function (topic) {
+ this.subscribe(function (newValue) {
+ postbox.notifySubscribers(newValue, topic);
+ });
+
+ return this;
+ };
+
+ this.myObservable = ko.observable("myValue").publishOn("myTopic");
+
+ var x = ko.observableArray([1, 2, 3]);
+
+ var element;
+ ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
+ $(element).datepicker("destroy");
+ });
}
\ No newline at end of file
diff --git a/Definitions/knockoutmapping-2.0.d.ts b/knockoutmapping/knockoutmapping-2.0.d.ts
similarity index 100%
rename from Definitions/knockoutmapping-2.0.d.ts
rename to knockoutmapping/knockoutmapping-2.0.d.ts
diff --git a/Definitions/linq-2.2.d.ts b/linq/linq-2.2.d.ts
similarity index 100%
rename from Definitions/linq-2.2.d.ts
rename to linq/linq-2.2.d.ts
diff --git a/Tests/linq-tests.ts b/linq/linq-tests.ts
similarity index 100%
rename from Tests/linq-tests.ts
rename to linq/linq-tests.ts
diff --git a/Definitions/modernizr-2.6.d.ts b/modernizr/modernizr-2.6.d.ts
similarity index 100%
rename from Definitions/modernizr-2.6.d.ts
rename to modernizr/modernizr-2.6.d.ts
diff --git a/Tests/modernizr-tests.ts b/modernizr/modernizr-tests.ts
similarity index 100%
rename from Tests/modernizr-tests.ts
rename to modernizr/modernizr-tests.ts
diff --git a/Definitions/moment-1.7.d.ts b/moment/moment-1.7.d.ts
similarity index 100%
rename from Definitions/moment-1.7.d.ts
rename to moment/moment-1.7.d.ts
diff --git a/Tests/moment-tests.ts b/moment/moment-tests.ts
similarity index 100%
rename from Tests/moment-tests.ts
rename to moment/moment-tests.ts
diff --git a/Definitions/msnodesql-0.2.d.ts b/msnodesql/msnodesql-0.2.d.ts
similarity index 100%
rename from Definitions/msnodesql-0.2.d.ts
rename to msnodesql/msnodesql-0.2.d.ts
diff --git a/Tests/msnodesql-tests.ts b/msnodesql/msnodesql-tests.ts
similarity index 100%
rename from Tests/msnodesql-tests.ts
rename to msnodesql/msnodesql-tests.ts
diff --git a/Definitions/mustache-0.7.d.ts b/mustache/mustache-0.7.d.ts
similarity index 100%
rename from Definitions/mustache-0.7.d.ts
rename to mustache/mustache-0.7.d.ts
diff --git a/Tests/mustache-tests.ts b/mustache/mustache-tests.ts
similarity index 100%
rename from Tests/mustache-tests.ts
rename to mustache/mustache-tests.ts
diff --git a/Definitions/node-0.8.d.ts b/node/node-0.8.d.ts
similarity index 100%
rename from Definitions/node-0.8.d.ts
rename to node/node-0.8.d.ts
diff --git a/Definitions/node_redis-0.8.d.ts b/node_redis/node_redis-0.8.d.ts
similarity index 100%
rename from Definitions/node_redis-0.8.d.ts
rename to node_redis/node_redis-0.8.d.ts
diff --git a/Definitions/phonegap-2.2.d.ts b/phonegap/phonegap-2.2.d.ts
similarity index 100%
rename from Definitions/phonegap-2.2.d.ts
rename to phonegap/phonegap-2.2.d.ts
diff --git a/Tests/phonegap-tests.ts b/phonegap/phonegap-tests.ts
similarity index 100%
rename from Tests/phonegap-tests.ts
rename to phonegap/phonegap-tests.ts
diff --git a/Definitions/preloadjs-0.2.d.ts b/preloadjs/preloadjs-0.2.d.ts
similarity index 100%
rename from Definitions/preloadjs-0.2.d.ts
rename to preloadjs/preloadjs-0.2.d.ts
diff --git a/Definitions/qunit-1.10.d.ts b/qunit/qunit-1.10.d.ts
similarity index 100%
rename from Definitions/qunit-1.10.d.ts
rename to qunit/qunit-1.10.d.ts
diff --git a/Tests/qunit-tests.ts b/qunit/qunit-tests.ts
similarity index 100%
rename from Tests/qunit-tests.ts
rename to qunit/qunit-tests.ts
diff --git a/Definitions/raphael-2.1.d.ts b/raphael/raphael-2.1.d.ts
similarity index 100%
rename from Definitions/raphael-2.1.d.ts
rename to raphael/raphael-2.1.d.ts
diff --git a/Tests/raphael-tests.ts b/raphael/raphael-tests.ts
similarity index 100%
rename from Tests/raphael-tests.ts
rename to raphael/raphael-tests.ts
diff --git a/Tests/redis_node-tests.ts b/redis_node/redis_node-tests.ts
similarity index 100%
rename from Tests/redis_node-tests.ts
rename to redis_node/redis_node-tests.ts
diff --git a/Definitions/require-2.1.d.ts b/requirejs/require-2.1.d.ts
similarity index 96%
rename from Definitions/require-2.1.d.ts
rename to requirejs/require-2.1.d.ts
index ae291a7d6e..bae2ad8372 100644
--- a/Definitions/require-2.1.d.ts
+++ b/requirejs/require-2.1.d.ts
@@ -1,197 +1,197 @@
-// require-2.1.1.d.ts
-// (c) 2012 Josh Baldwin
-// require.d.ts may be freely distributed under the MIT license.
-// For all details and documentation:
-// https://github.com/jbaldwin/require.d.ts
-
-interface RequireShim {
-
- // List of dependencies.
- deps?: string[];
-
- // Name the module will be exported as.
- exports?: string;
-
- // Initialize function with all dependcies passed in,
- // if the function returns a value then that value is used
- // as the module export value instead of the object
- // found via the 'exports' string.
- init?: (...dependencies: any[]) => any;
-}
-
-interface RequireConfig {
-
- // The root path to use for all module lookups.
- baseUrl?: string;
-
- // Path mappings for module names not found directly under
- // baseUrl.
- paths?: { [key: string]: string; };
-
- // Dictionary of Shim's.
- // does not cover case of key->string[]
- shim?: { [key: string]: RequireShim; };
-
- /**
- * For the given module prefix, instead of loading the
- * module with the given ID, substitude a different
- * module ID.
- *
- * @example
- * requirejs.config({
- * map: {
- * 'some/newmodule': {
- * 'foo': 'foo1.2'
- * },
- * 'some/oldmodule': {
- * 'foo': 'foo1.0'
- * }
- * }
- * });
- **/
- map?: {
- [id: string]: {
- [id: string]: string;
- };
- };
-
- // AMD configurations, use module.config() to access in
- // define() functions
- config?: { [id: string]: { }; };
-
- // Configures loading modules from CommonJS packages.
- packages?: { };
-
- // The number of seconds to wait before giving up on loading
- // a script. The default is 7 seconds.
- waitSeconds?: number;
-
- // A name to give to a loading context. This allows require.js
- // to load multiple versions of modules in a page, as long as
- // each top-level require call specifies a unique context string.
- context?: string;
-
- // An array of dependencies to load.
- deps?: string[];
-
- // A function to pass to require that should be require after
- // deps have been loaded.
- callback?: (...modules: any[]) => void;
-
- // If set to true, an error will be thrown if a script loads
- // that does not call define() or have shim exports string
- // value that can be checked.
- enforceDefine?: bool;
-
- // If set to true, document.createElementNS() will be used
- // to create script elements.
- xhtml?: bool;
-
- /**
- * Extra query string arguments appended to URLs that RequireJS
- * uses to fetch resources. Most useful to cachce bust when
- * the browser or server is not configured correcty.
- *
- * @example
- * urlArgs: "bust= + (new Date()).getTime()
- **/
- urlArgs?: string;
-
- /**
- * Specify the value for the type="" attribute used for script
- * tags inserted into the document by RequireJS. Default is
- * "text/javascript". To use Firefox's JavasScript 1.8
- * features, use "text/javascript;version=1.8".
- **/
- scriptType?: string;
-
-}
-
-// not sure what to do with this guy
-interface RequireModule {
-
-
- config(): { };
-
-}
-
-interface RequireMap {
- prefix: string;
- name: string;
- parentMap: RequireMap;
- url: string;
- originalName: string;
- fullName: string;
-}
-
-interface Require {
-
- // Configure require.js
- config(config: RequireConfig): void;
-
- // Start the main app logic.
- // Callback is optional.
- // Can alternatively use deps and callback.
- (modules: string[]): void;
- (modules: string[], ready: (...modules: any[]) => void): void;
-
- // Generate URLs from require module
- toUrl(module: string): string;
-
- // On Error override
- onError(): void;
-
- // Undefine a module
- undef(module: string): void;
-
- // Semi-private function, overload in special instance of undef()
- onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
-}
-
-interface RequireDefine {
-
- /**
- * Define Simple Name/Value Pairs
- * @config Dictionary of Named/Value pairs for the config.
- **/
- (config: { [key: string]: any; }): void;
-
- /**
- * Define function.
- * @func: The function module.
- **/
- (func: () => any): void;
-
- /**
- * Define function with dependencies.
- * @deps List of dependencies module IDs.
- * @ready Callback function when the dependencies are loaded.
- * @deps module dependencies
- * @return module definition
- **/
- (deps: string[], ready: (...deps: any[]) => any): void;
-
- /**
- * Define module with simplified CommonJS wrapper.
- * @ready
- * @require requirejs instance
- * @exports exports object
- * @module module
- * @return module definition
- **/
- (ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void;
-
- /**
- * Define a module with a name and dependencies.
- * @name The name of the module.
- * @deps List of dependencies module IDs.
- * @ready Callback function when the dependencies are loaded.
- * @deps module dependencies
- * @return module definition
- **/
- (name: string, deps: string[], ready: (...deps: any[]) => any): void;
-}
-
-// Ambient declarations for 'require' and 'define'
-var require: Require;
+// require-2.1.1.d.ts
+// (c) 2012 Josh Baldwin
+// require.d.ts may be freely distributed under the MIT license.
+// For all details and documentation:
+// https://github.com/jbaldwin/require.d.ts
+
+interface RequireShim {
+
+ // List of dependencies.
+ deps?: string[];
+
+ // Name the module will be exported as.
+ exports?: string;
+
+ // Initialize function with all dependcies passed in,
+ // if the function returns a value then that value is used
+ // as the module export value instead of the object
+ // found via the 'exports' string.
+ init?: (...dependencies: any[]) => any;
+}
+
+interface RequireConfig {
+
+ // The root path to use for all module lookups.
+ baseUrl?: string;
+
+ // Path mappings for module names not found directly under
+ // baseUrl.
+ paths?: { [key: string]: string; };
+
+ // Dictionary of Shim's.
+ // does not cover case of key->string[]
+ shim?: { [key: string]: RequireShim; };
+
+ /**
+ * For the given module prefix, instead of loading the
+ * module with the given ID, substitude a different
+ * module ID.
+ *
+ * @example
+ * requirejs.config({
+ * map: {
+ * 'some/newmodule': {
+ * 'foo': 'foo1.2'
+ * },
+ * 'some/oldmodule': {
+ * 'foo': 'foo1.0'
+ * }
+ * }
+ * });
+ **/
+ map?: {
+ [id: string]: {
+ [id: string]: string;
+ };
+ };
+
+ // AMD configurations, use module.config() to access in
+ // define() functions
+ config?: { [id: string]: { }; };
+
+ // Configures loading modules from CommonJS packages.
+ packages?: { };
+
+ // The number of seconds to wait before giving up on loading
+ // a script. The default is 7 seconds.
+ waitSeconds?: number;
+
+ // A name to give to a loading context. This allows require.js
+ // to load multiple versions of modules in a page, as long as
+ // each top-level require call specifies a unique context string.
+ context?: string;
+
+ // An array of dependencies to load.
+ deps?: string[];
+
+ // A function to pass to require that should be require after
+ // deps have been loaded.
+ callback?: (...modules: any[]) => void;
+
+ // If set to true, an error will be thrown if a script loads
+ // that does not call define() or have shim exports string
+ // value that can be checked.
+ enforceDefine?: bool;
+
+ // If set to true, document.createElementNS() will be used
+ // to create script elements.
+ xhtml?: bool;
+
+ /**
+ * Extra query string arguments appended to URLs that RequireJS
+ * uses to fetch resources. Most useful to cachce bust when
+ * the browser or server is not configured correcty.
+ *
+ * @example
+ * urlArgs: "bust= + (new Date()).getTime()
+ **/
+ urlArgs?: string;
+
+ /**
+ * Specify the value for the type="" attribute used for script
+ * tags inserted into the document by RequireJS. Default is
+ * "text/javascript". To use Firefox's JavasScript 1.8
+ * features, use "text/javascript;version=1.8".
+ **/
+ scriptType?: string;
+
+}
+
+// not sure what to do with this guy
+interface RequireModule {
+
+
+ config(): { };
+
+}
+
+interface RequireMap {
+ prefix: string;
+ name: string;
+ parentMap: RequireMap;
+ url: string;
+ originalName: string;
+ fullName: string;
+}
+
+interface Require {
+
+ // Configure require.js
+ config(config: RequireConfig): void;
+
+ // Start the main app logic.
+ // Callback is optional.
+ // Can alternatively use deps and callback.
+ (modules: string[]): void;
+ (modules: string[], ready: (...modules: any[]) => void): void;
+
+ // Generate URLs from require module
+ toUrl(module: string): string;
+
+ // On Error override
+ onError(): void;
+
+ // Undefine a module
+ undef(module: string): void;
+
+ // Semi-private function, overload in special instance of undef()
+ onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
+}
+
+interface RequireDefine {
+
+ /**
+ * Define Simple Name/Value Pairs
+ * @config Dictionary of Named/Value pairs for the config.
+ **/
+ (config: { [key: string]: any; }): void;
+
+ /**
+ * Define function.
+ * @func: The function module.
+ **/
+ (func: () => any): void;
+
+ /**
+ * Define function with dependencies.
+ * @deps List of dependencies module IDs.
+ * @ready Callback function when the dependencies are loaded.
+ * @deps module dependencies
+ * @return module definition
+ **/
+ (deps: string[], ready: (...deps: any[]) => any): void;
+
+ /**
+ * Define module with simplified CommonJS wrapper.
+ * @ready
+ * @require requirejs instance
+ * @exports exports object
+ * @module module
+ * @return module definition
+ **/
+ (ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void;
+
+ /**
+ * Define a module with a name and dependencies.
+ * @name The name of the module.
+ * @deps List of dependencies module IDs.
+ * @ready Callback function when the dependencies are loaded.
+ * @deps module dependencies
+ * @return module definition
+ **/
+ (name: string, deps: string[], ready: (...deps: any[]) => any): void;
+}
+
+// Ambient declarations for 'require' and 'define'
+var require: Require;
var define: RequireDefine;
\ No newline at end of file
diff --git a/Tests/require-tests.ts b/requirejs/require-tests.ts
similarity index 94%
rename from Tests/require-tests.ts
rename to requirejs/require-tests.ts
index 91998bf891..3c5877eefa 100644
--- a/Tests/require-tests.ts
+++ b/requirejs/require-tests.ts
@@ -1,39 +1,39 @@
-///
-
-// this test does not actually reference amd module 'main.ts', create one yourself.
-
-require.config({
- baseUrl: '../Definitions',
-
- // Requires versions afaik
- paths: {
- 'jquery': '../Definitions/jquery',
- 'underscore': '../Definitions/underscore',
- 'backbone': '../Definitions/backbone'
- },
-
- shim: {
- jquery: {
- exports: '$'
- },
-
- underscore: {
- exports: '_'
- },
-
- backbone: {
- deps: ['underscore', 'jquery'],
- exports: 'Backbone'
- }
- }
-});
-
-// load AMD module main.ts (compiled to main.js)
-// and include shims $, _, Backbone
-
-require(['main'], (main, $, _, Backbone) => {
-
- var app = main.AppMain();
- app.run();
-
+///
+
+// this test does not actually reference amd module 'main.ts', create one yourself.
+
+require.config({
+ baseUrl: '../Definitions',
+
+ // Requires versions afaik
+ paths: {
+ 'jquery': '../Definitions/jquery',
+ 'underscore': '../Definitions/underscore',
+ 'backbone': '../Definitions/backbone'
+ },
+
+ shim: {
+ jquery: {
+ exports: '$'
+ },
+
+ underscore: {
+ exports: '_'
+ },
+
+ backbone: {
+ deps: ['underscore', 'jquery'],
+ exports: 'Backbone'
+ }
+ }
+});
+
+// load AMD module main.ts (compiled to main.js)
+// and include shims $, _, Backbone
+
+require(['main'], (main, $, _, Backbone) => {
+
+ var app = main.AppMain();
+ app.run();
+
});
\ No newline at end of file
diff --git a/Definitions/sammyjs-0.7.d.ts b/sammyjs/sammyjs-0.7.d.ts
similarity index 100%
rename from Definitions/sammyjs-0.7.d.ts
rename to sammyjs/sammyjs-0.7.d.ts
diff --git a/Tests/sammyjs-tests.ts b/sammyjs/sammyjs-tests.ts
similarity index 100%
rename from Tests/sammyjs-tests.ts
rename to sammyjs/sammyjs-tests.ts
diff --git a/Definitions/signalr-1.0.d.ts b/signalr/signalr-1.0.d.ts
similarity index 100%
rename from Definitions/signalr-1.0.d.ts
rename to signalr/signalr-1.0.d.ts
diff --git a/Tests/signalr-tests.ts b/signalr/signalr-tests.ts
similarity index 100%
rename from Tests/signalr-tests.ts
rename to signalr/signalr-tests.ts
diff --git a/Definitions/soundjs-0.3.d.ts b/soundjs/soundjs-0.3.d.ts
similarity index 100%
rename from Definitions/soundjs-0.3.d.ts
rename to soundjs/soundjs-0.3.d.ts
diff --git a/Definitions/spin-1.2.d.ts b/spin/spin-1.2.d.ts
similarity index 100%
rename from Definitions/spin-1.2.d.ts
rename to spin/spin-1.2.d.ts
diff --git a/Tests/spin-tests.ts b/spin/spin-tests.ts
similarity index 100%
rename from Tests/spin-tests.ts
rename to spin/spin-tests.ts
diff --git a/Definitions/sugar-1.3.d.ts b/sugar/sugar-1.3.d.ts
similarity index 100%
rename from Definitions/sugar-1.3.d.ts
rename to sugar/sugar-1.3.d.ts
diff --git a/Definitions/teechart-1.3.d.ts b/teechart/teechart-1.3.d.ts
similarity index 100%
rename from Definitions/teechart-1.3.d.ts
rename to teechart/teechart-1.3.d.ts
diff --git a/Definitions/toastr-1.0.d.ts b/toastr/toastr-1.0.d.ts
similarity index 100%
rename from Definitions/toastr-1.0.d.ts
rename to toastr/toastr-1.0.d.ts
diff --git a/Tests/toastr-tests.ts b/toastr/toastr-tests.ts
similarity index 100%
rename from Tests/toastr-tests.ts
rename to toastr/toastr-tests.ts
diff --git a/Definitions/tween.js-r7.d.ts b/tween.js/tween.js-r7.d.ts
similarity index 96%
rename from Definitions/tween.js-r7.d.ts
rename to tween.js/tween.js-r7.d.ts
index 64f7460c53..348adf3c14 100644
--- a/Definitions/tween.js-r7.d.ts
+++ b/tween.js/tween.js-r7.d.ts
@@ -1,98 +1,98 @@
-// Type definitions for tween.js r7
-// Project: https://github.com/sole/tween.js/
-// Definitions by: https://github.com/sunetos
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-module TWEEN {
- export var REVISION: string;
- export function getAll(): Tween[];
- export function removeAll(): void;
- export function add(tween:Tween): void;
- export function remove(tween:Tween): void;
- export function update(time:number): bool;
-
- export class Tween {
- constructor(object?:any);
- to(properties:any, duration:number): Tween;
- start(time?:number): Tween;
- stop(): Tween;
- delay(amount:number): Tween;
- easing(easing): Tween;
- interpolation(interpolation:Function): Tween;
- chain(...tweens:Tween[]): Tween;
- onStart(callback:Function): Tween;
- onUpdate(callback:Function): Tween;
- onComplete(callback:Function): Tween;
- update(time:number): bool;
- };
- export var Easing: TweenEasing;
- export var Interpolation: TweenInterpolation;
-}
-
-interface TweenEasing {
- Linear: {
- None(k:number): number;
- };
- Quadratic: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
- Cubic: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
- Quartic: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
- Quintic: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
- Sinusoidal: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
- Exponential: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
- Circular: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
- Elastic: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
- Back: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
- Bounce: {
- In(k:number): number;
- Out(k:number): number;
- InOut(k:number): number;
- };
-}
-
-interface TweenInterpolation {
- Linear(v:number[], k:number): number;
- Bezier(v:number[], k:number): number;
- CatmullRom(v:number[], k:number): number;
-
- Utils: {
- Linear(p0:number, p1:number, t:number): number;
- Bernstein(n:number, i:number): number;
- Factorial(n): number;
- };
-}
+// Type definitions for tween.js r7
+// Project: https://github.com/sole/tween.js/
+// Definitions by: https://github.com/sunetos
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+module TWEEN {
+ export var REVISION: string;
+ export function getAll(): Tween[];
+ export function removeAll(): void;
+ export function add(tween:Tween): void;
+ export function remove(tween:Tween): void;
+ export function update(time:number): bool;
+
+ export class Tween {
+ constructor(object?:any);
+ to(properties:any, duration:number): Tween;
+ start(time?:number): Tween;
+ stop(): Tween;
+ delay(amount:number): Tween;
+ easing(easing): Tween;
+ interpolation(interpolation:Function): Tween;
+ chain(...tweens:Tween[]): Tween;
+ onStart(callback:Function): Tween;
+ onUpdate(callback:Function): Tween;
+ onComplete(callback:Function): Tween;
+ update(time:number): bool;
+ };
+ export var Easing: TweenEasing;
+ export var Interpolation: TweenInterpolation;
+}
+
+interface TweenEasing {
+ Linear: {
+ None(k:number): number;
+ };
+ Quadratic: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+ Cubic: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+ Quartic: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+ Quintic: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+ Sinusoidal: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+ Exponential: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+ Circular: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+ Elastic: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+ Back: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+ Bounce: {
+ In(k:number): number;
+ Out(k:number): number;
+ InOut(k:number): number;
+ };
+}
+
+interface TweenInterpolation {
+ Linear(v:number[], k:number): number;
+ Bezier(v:number[], k:number): number;
+ CatmullRom(v:number[], k:number): number;
+
+ Utils: {
+ Linear(p0:number, p1:number, t:number): number;
+ Bernstein(n:number, i:number): number;
+ Factorial(n): number;
+ };
+}
diff --git a/Definitions/tweenjs-0.3.d.ts b/tweenjs/tweenjs-0.3.d.ts
similarity index 100%
rename from Definitions/tweenjs-0.3.d.ts
rename to tweenjs/tweenjs-0.3.d.ts
diff --git a/Definitions/underscore-1.4.d.ts b/underscore/underscore-1.4.d.ts
similarity index 100%
rename from Definitions/underscore-1.4.d.ts
rename to underscore/underscore-1.4.d.ts
diff --git a/Tests/underscore-tests.ts b/underscore/underscore-tests.ts
similarity index 100%
rename from Tests/underscore-tests.ts
rename to underscore/underscore-tests.ts
diff --git a/Definitions/underscore-typed-1.4.d.ts b/underscore/underscore-typed-1.4.d.ts
similarity index 100%
rename from Definitions/underscore-typed-1.4.d.ts
rename to underscore/underscore-typed-1.4.d.ts
diff --git a/Definitions/unity-webapi-1.0.d.ts b/unity-webapi/unity-webapi-1.0.d.ts
similarity index 95%
rename from Definitions/unity-webapi-1.0.d.ts
rename to unity-webapi/unity-webapi-1.0.d.ts
index 902962c719..4195049717 100644
--- a/Definitions/unity-webapi-1.0.d.ts
+++ b/unity-webapi/unity-webapi-1.0.d.ts
@@ -1,97 +1,97 @@
-// Type definitions for Ubuntu Unity Web API 1.0
-// Project: https://launchpad.net/libunity-webapps
-// Definitions by: John Vrbanac | https://github.com/jmvrbanac
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-declare class UnitySettings {
- public name:String;
- public iconUrl:String;
- public onInit:Function;
-}
-
-enum UnityPlaybackState {
- Playing,
- Paused
-}
-
-declare class UnityTrackMetadata {
- title:String;
-
- // Optionals
- album:String;
- artist:String;
- artLocation:String;
-}
-
-interface UnityMediaPlayer {
- setTrack(trackMetadata:UnityTrackMetadata);
-
- onPrevious(onPreviousCallback:Function);
- onNext(onNextCallback:Function);
- onPlayPause(onPlayPauseCallback:Function);
-
- getPlaybackstate(response:Function);
- setPlaybackstate(state:UnityPlaybackState);
-
- setCanGoNext(cangonext:Boolean);
- setCanGoPrev(cangoprev:Boolean);
- setCanPlay(canplay:Boolean);
- setCanPause(canpause:Boolean);
-}
-
-interface UnityNotification {
- showNotification (summary:String, body:String, iconUrl?:String);
-}
-
-declare class UnityIndicatorProperties {
- public count:Number;
- public time:Date;
- public iconURI:String;
- public onIndicatorActivated:Function;
-}
-
-interface UnityMessagingIndicator {
- showIndicator(name:String, indicatorProperties:UnityIndicatorProperties);
- clearIndicator(name:String);
- clearIndicators();
-
- addAction(name:String, onActionInvoked:Function);
- removeAction(name:String);
- removeActions();
- onPresenceChanged(onPresenceChanged:Function);
-
- // This is suppose to be readonly, but i'm not sure how to do this
- // in a definition file.
- presence:String;
-}
-
- interface UnityLauncher {
- setCount(count:number);
- clearCount();
-
- setProgress(progress:number);
- clearProgress();
-
- setUrgent(urgent:Boolean);
-
- addAction(name:String, onActionInvoked:Function);
- removeAction(name:String);
- removeActions();
-}
-
-interface Unity {
- init(settings:UnitySettings);
- addAction(name:String, callback:Function);
- removeAction(actionName:String);
- removeActions();
-
- Notification:UnityNotification;
- MediaPlayer:UnityMediaPlayer;
- MessagingIndicator:UnityMessagingIndicator;
- Launcher:UnityLauncher;
-}
-
-interface BrowserPublic {
- getUnityObject(version:number):Unity;
-}
-
+// Type definitions for Ubuntu Unity Web API 1.0
+// Project: https://launchpad.net/libunity-webapps
+// Definitions by: John Vrbanac | https://github.com/jmvrbanac
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare class UnitySettings {
+ public name:String;
+ public iconUrl:String;
+ public onInit:Function;
+}
+
+enum UnityPlaybackState {
+ Playing,
+ Paused
+}
+
+declare class UnityTrackMetadata {
+ title:String;
+
+ // Optionals
+ album:String;
+ artist:String;
+ artLocation:String;
+}
+
+interface UnityMediaPlayer {
+ setTrack(trackMetadata:UnityTrackMetadata);
+
+ onPrevious(onPreviousCallback:Function);
+ onNext(onNextCallback:Function);
+ onPlayPause(onPlayPauseCallback:Function);
+
+ getPlaybackstate(response:Function);
+ setPlaybackstate(state:UnityPlaybackState);
+
+ setCanGoNext(cangonext:Boolean);
+ setCanGoPrev(cangoprev:Boolean);
+ setCanPlay(canplay:Boolean);
+ setCanPause(canpause:Boolean);
+}
+
+interface UnityNotification {
+ showNotification (summary:String, body:String, iconUrl?:String);
+}
+
+declare class UnityIndicatorProperties {
+ public count:Number;
+ public time:Date;
+ public iconURI:String;
+ public onIndicatorActivated:Function;
+}
+
+interface UnityMessagingIndicator {
+ showIndicator(name:String, indicatorProperties:UnityIndicatorProperties);
+ clearIndicator(name:String);
+ clearIndicators();
+
+ addAction(name:String, onActionInvoked:Function);
+ removeAction(name:String);
+ removeActions();
+ onPresenceChanged(onPresenceChanged:Function);
+
+ // This is suppose to be readonly, but i'm not sure how to do this
+ // in a definition file.
+ presence:String;
+}
+
+ interface UnityLauncher {
+ setCount(count:number);
+ clearCount();
+
+ setProgress(progress:number);
+ clearProgress();
+
+ setUrgent(urgent:Boolean);
+
+ addAction(name:String, onActionInvoked:Function);
+ removeAction(name:String);
+ removeActions();
+}
+
+interface Unity {
+ init(settings:UnitySettings);
+ addAction(name:String, callback:Function);
+ removeAction(actionName:String);
+ removeActions();
+
+ Notification:UnityNotification;
+ MediaPlayer:UnityMediaPlayer;
+ MessagingIndicator:UnityMessagingIndicator;
+ Launcher:UnityLauncher;
+}
+
+interface BrowserPublic {
+ getUnityObject(version:number):Unity;
+}
+
diff --git a/Tests/unity-webapi-tests.ts b/unity-webapi/unity-webapi-tests.ts
similarity index 96%
rename from Tests/unity-webapi-tests.ts
rename to unity-webapi/unity-webapi-tests.ts
index 8dbd692acc..5de89e3bac 100644
--- a/Tests/unity-webapi-tests.ts
+++ b/unity-webapi/unity-webapi-tests.ts
@@ -1,58 +1,58 @@
-///
-
-var Unity = external.getUnityObject(1.0);
-var settings = new UnitySettings();
-Unity.init(settings);
-
-// Actions
-Unity.addAction("boom", function() {});
-Unity.removeAction("boom");
-Unity.removeActions();
-
-// Notification
-Unity.Notification.showNotification("sum", "body");
-Unity.Notification.showNotification("sum", "body", "optional");
-
-// Messaging
-var props = new UnityIndicatorProperties();
-props.count = 0;
-props.time = new Date();
-
-Unity.MessagingIndicator.showIndicator("boom", props);
-Unity.MessagingIndicator.clearIndicator("boom");
-Unity.MessagingIndicator.clearIndicators();
-
-Unity.MessagingIndicator.addAction("boom", function() {});
-Unity.MessagingIndicator.removeAction("boom");
-Unity.MessagingIndicator.removeActions();
-Unity.MessagingIndicator.onPresenceChanged(function() {});
-
-// Launcher
-Unity.Launcher.setCount(1);
-Unity.Launcher.clearCount();
-
-Unity.Launcher.setProgress(100);
-Unity.Launcher.clearProgress();
-
-Unity.Launcher.setUrgent(true);
-
-Unity.Launcher.addAction("boom", function(){});
-Unity.Launcher.removeAction("boom");
-Unity.Launcher.removeActions();
-
-
-// MediaPlayer
-var metadata = new UnityTrackMetadata();
-Unity.MediaPlayer.setTrack(metadata);
-
-Unity.MediaPlayer.onPrevious(function(){});
-Unity.MediaPlayer.onNext(function(){});
-Unity.MediaPlayer.onPlayPause(function(){});
-
-Unity.MediaPlayer.getPlaybackstate(function(){});
-Unity.MediaPlayer.setPlaybackstate(UnityPlaybackState.Playing);
-
-Unity.MediaPlayer.setCanGoNext(true);
-Unity.MediaPlayer.setCanGoPrev(true);
-Unity.MediaPlayer.setCanPlay(true);
+///
+
+var Unity = external.getUnityObject(1.0);
+var settings = new UnitySettings();
+Unity.init(settings);
+
+// Actions
+Unity.addAction("boom", function() {});
+Unity.removeAction("boom");
+Unity.removeActions();
+
+// Notification
+Unity.Notification.showNotification("sum", "body");
+Unity.Notification.showNotification("sum", "body", "optional");
+
+// Messaging
+var props = new UnityIndicatorProperties();
+props.count = 0;
+props.time = new Date();
+
+Unity.MessagingIndicator.showIndicator("boom", props);
+Unity.MessagingIndicator.clearIndicator("boom");
+Unity.MessagingIndicator.clearIndicators();
+
+Unity.MessagingIndicator.addAction("boom", function() {});
+Unity.MessagingIndicator.removeAction("boom");
+Unity.MessagingIndicator.removeActions();
+Unity.MessagingIndicator.onPresenceChanged(function() {});
+
+// Launcher
+Unity.Launcher.setCount(1);
+Unity.Launcher.clearCount();
+
+Unity.Launcher.setProgress(100);
+Unity.Launcher.clearProgress();
+
+Unity.Launcher.setUrgent(true);
+
+Unity.Launcher.addAction("boom", function(){});
+Unity.Launcher.removeAction("boom");
+Unity.Launcher.removeActions();
+
+
+// MediaPlayer
+var metadata = new UnityTrackMetadata();
+Unity.MediaPlayer.setTrack(metadata);
+
+Unity.MediaPlayer.onPrevious(function(){});
+Unity.MediaPlayer.onNext(function(){});
+Unity.MediaPlayer.onPlayPause(function(){});
+
+Unity.MediaPlayer.getPlaybackstate(function(){});
+Unity.MediaPlayer.setPlaybackstate(UnityPlaybackState.Playing);
+
+Unity.MediaPlayer.setCanGoNext(true);
+Unity.MediaPlayer.setCanGoPrev(true);
+Unity.MediaPlayer.setCanPlay(true);
Unity.MediaPlayer.setCanPause(true);
\ No newline at end of file