diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 532e0404e2..801a1d07ac 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -270,6 +270,7 @@ All definitions files include a header with the author and editors, so at some p * [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall)) * [Restangular](https://github.com/mgonto/restangular/) (by [Boris Yankov](https://github.com/borisyankov)) * [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) +* [rtree.js] (https://github.com/leaflet-extras/RTree) (by [Omede Firouz](https://github.com/oefirouz)) * [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov)) * [Selenium WebDriverJS](https://code.google.com/p/selenium/) (by [Bill Armstrong](https://github.com/BillArmstrong)) diff --git a/amplifyjs/amplifyjs-tests.ts b/amplifyjs/amplifyjs-tests.ts index c26955348b..a104d4a7cc 100644 --- a/amplifyjs/amplifyjs-tests.ts +++ b/amplifyjs/amplifyjs-tests.ts @@ -176,8 +176,7 @@ amplify.request("twitter-mentions", { user: "amplifyjs" }); //Example: -amplify.request.decoders.appEnvelope = -function (data, status, xhr, success, error) { +var appEnvelopeDecoder: amplifyDecoder = function (data, status, xhr, success, error) { if (data.status === "success") { success(data.data); } else if (data.status === "fail" || data.status === "error") { @@ -187,6 +186,17 @@ function (data, status, xhr, success, error) { } }; +//a new decoder can be added to the amplifyDecoders interface +interface amplifyDecoders { + appEnvelope: amplifyDecoder; +} + +amplify.request.decoders.appEnvelope = appEnvelopeDecoder; + +//but you can also just add it via an index +amplify.request.decoders['appEnvelopeStr'] = appEnvelopeDecoder; + + amplify.request.define("decoderExample", "ajax", { url: "/myAjaxUrl", type: "POST", diff --git a/amplifyjs/amplifyjs.d.ts b/amplifyjs/amplifyjs.d.ts index c8de7260ae..a918b7c73f 100644 --- a/amplifyjs/amplifyjs.d.ts +++ b/amplifyjs/amplifyjs.d.ts @@ -1,3 +1,5 @@ +/// + // Type definitions for AmplifyJs 1.1.0 // Project: http://amplifyjs.com/ // Definitions by: Jonas Eriksson @@ -6,8 +8,28 @@ interface amplifyRequestSettings { resourceId: string; data?: any; - success?: Function; - error?: Function; + success?: (...args: any[]) => void; + error?: (...args: any[]) => void; +} + +interface amplifyDecoder { + ( + data?: any, + status?: string, + xhr?: JQueryXHR, + success?: (...args: any[]) => void, + error?: (...args: any[]) => void + ): void +} + +interface amplifyDecoders { + [decoderName: string]: amplifyDecoder; + jsSend: amplifyDecoder; +} + +interface amplifyAjaxSettings extends JQueryAjaxSettings { + cache?: any; + decoder?: any /* string or amplifyDecoder */; } interface amplifyRequest { @@ -39,7 +61,7 @@ interface amplifyRequest { * cache: See the cache section for more details. * decoder: See the decoder section for more details. */ - define(resourceId: string, requestType: string, settings?: any): void; + define(resourceId: string, requestType: string, settings?: amplifyAjaxSettings): void; /*** * Define a custom request. @@ -50,9 +72,9 @@ interface amplifyRequest { * success: Callback to invoke on success. * error: Callback to invoke on error. */ - define(resourceId: string, resource: Function): void; - - decoders: any; + define(resourceId: string, resource: (settings: amplifyRequestSettings) => void): void; + + decoders: amplifyDecoders; cache: any; } diff --git a/angular-ui/angular-ui-router-tests.ts b/angular-ui/angular-ui-router-tests.ts index 4804ad297a..5b0dec0ffb 100644 --- a/angular-ui/angular-ui-router-tests.ts +++ b/angular-ui/angular-ui-router-tests.ts @@ -78,12 +78,13 @@ interface IUrlLocatorTestService { // Service for determining who the currently logged on user is. class UrlLocatorTestService implements IUrlLocatorTestService { - static $inject = ["$http", "$rootScope", "$urlRouter"]; + static $inject = ["$http", "$rootScope", "$urlRouter", "$state"]; constructor( private $http: ng.IHttpService, private $rootScope: ng.IRootScopeService, - private $urlRouter: ng.ui.IUrlRouterService + private $urlRouter: ng.ui.IUrlRouterService, + private $state: ng.ui.IStateService ) { $rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event)); } @@ -107,6 +108,23 @@ class UrlLocatorTestService implements IUrlLocatorTestService { }); } } + + private stateServiceTest() { + this.$state.go("myState"); + this.$state.transitionTo("myState"); + if (this.$state.includes("myState") === true) { + // + } + if (this.$state.is("myState") === true) { + // + } + if (this.$state.href("myState") === "/myState") { + // + } + this.$state.get("myState"); + this.$state.get(); + this.$state.reload(); + } } myApp.service("urlLocatorTest", UrlLocatorTestService); @@ -124,4 +142,3 @@ module UiViewScrollProviderTests { $uiViewScrollProvider.useAnchorScroll(); }]); } - diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 499f1c474a..3b233c86a1 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -86,6 +86,7 @@ declare module ng.ui { get(): IState[]; current: IState; params: IStateParamsService; + reload(): void; } interface IStateParamsService { diff --git a/angularjs/angular-route-tests.ts b/angularjs/angular-route-tests.ts index 2ebe16a21e..3b35a97bbc 100644 --- a/angularjs/angular-route-tests.ts +++ b/angularjs/angular-route-tests.ts @@ -9,6 +9,9 @@ declare var $routeProvider: ng.route.IRouteProvider; $routeProvider .when('/projects/:projectId/dashboard',{ - controller: '' + controller: '', + templateUrl: '', + caseInsensitiveMatch: true, + reloadOnSearch: false }) .otherwise({redirectTo: '/'}); diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts index 025c5da227..4e2aa7607d 100644 --- a/angularjs/angular-route.d.ts +++ b/angularjs/angular-route.d.ts @@ -30,17 +30,73 @@ declare module ng.route { // to a controller that was not initialized as a result of a route maching. current?: ICurrentRoute; } - - // see http://docs.angularjs.org/api/ngRoute.$routeProvider#when for options explanations + + + /** + * see http://docs.angularjs.org/api/ngRoute/provider/$routeProvider#when for API documentation + */ interface IRoute { + /** + * {(string|function()=} + * Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string. + */ controller?: any; - controllerAs?: any; + /** + * A controller alias name. If present the controller will be published to scope under the controllerAs name. + */ + controllerAs?: string; + /** + * Undocumented? + */ name?: string; + /** + * {string=|function()=} + * Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl. + * + * If template is a function, it will be called with the following parameters: + * + * {Array.} - route parameters extracted from the current $location.path() by applying the current route + */ template?: string; + /** + * {string=|function()=} + * Path or function that returns a path to an html template that should be used by ngView. + * + * If templateUrl is a function, it will be called with the following parameters: + * + * {Array.} - route parameters extracted from the current $location.path() by applying the current route + */ templateUrl?: any; + /** + * {Object.=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is: + * + * - key - {string}: a name of a dependency to be injected into the controller. + * - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead. + */ resolve?: any; + /** + * {(string|function())=} + * Value to update $location path with and trigger route redirection. + * + * If redirectTo is a function, it will be called with the following parameters: + * + * - {Object.} - route parameters extracted from the current $location.path() by applying the current route templateUrl. + * - {string} - current $location.path() + * - {Object} - current $location.search() + * - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search(). + */ redirectTo?: any; + /** + * Reload route when only $location.search() or $location.hash() changes. + * + * This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope. + */ reloadOnSearch?: boolean; + /** + * Match routes without being case sensitive + * + * This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive + */ caseInsensitiveMatch?: boolean; } @@ -55,10 +111,24 @@ declare module ng.route { } interface IRouteProvider extends IServiceProvider { + /** + * Sets route definition that will be used on route change when no other route definition is matched. + * + * @params Mapping information to be assigned to $route.current. + */ otherwise(params: IRoute): IRouteProvider; /** - * This is a description + * Adds a new route definition to the $route service. + * + * @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition. + * + * - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches. + * - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches. + * - path can contain optional named groups with a question mark: e.g.:name?. * + * For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes. + * + * @param route Mapping information to be assigned to $route.current on route match. */ when(path: string, route: IRoute): IRouteProvider; } diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 9d50749456..ec8c5cb5bc 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -51,16 +51,21 @@ declare module ng { isString(value: any): boolean; isUndefined(value: any): boolean; lowercase(str: string): string; - /** construct your angular application - official docs: Interface for configuring angular modules. - see: http://docs.angularjs.org/api/angular.Module - */ + + /** + * The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism. + * + * When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved. + * + * @param name The name of the module to create or retrieve. + * @param requires The names of modules this module depends on. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration. + * @param configFn Optional configuration function for the module. + */ module( - /** name of your module you want to create */ name: string, - /** name of modules yours depends on */ requires?: string[], - configFunction?: any): IModule; + configFn?: Function): IModule; + noop(...args: any[]): void; toJson(obj: any, pretty?: boolean): string; uppercase(str: string): string; @@ -81,23 +86,55 @@ declare module ng { animation(name: string, animationFactory: Function): IModule; animation(name: string, inlineAnnotatedFunction: any[]): IModule; animation(object: Object): IModule; - /** configure existing services. - Use this method to register work which needs to be performed on module loading + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param configFn Execute this function on module load. Useful for service configuration. */ config(configFn: Function): IModule; - /** configure existing services. - Use this method to register work which needs to be performed on module loading + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration. */ config(inlineAnnotatedFunction: any[]): IModule; constant(name: string, value: any): IModule; constant(object: Object): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ controller(name: string, controllerConstructor: Function): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ controller(name: string, inlineAnnotatedConstructor: any[]): IModule; controller(object : Object): IModule; directive(name: string, directiveFactory: Function): IModule; directive(name: string, inlineAnnotatedFunction: any[]): IModule; directive(object: Object): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ factory(name: string, serviceFactoryFunction: Function): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ factory(name: string, inlineAnnotatedFunction: any[]): IModule; factory(object: Object): IModule; filter(name: string, filterFactoryFunction: Function): IModule; @@ -241,6 +278,8 @@ declare module ng { $parent: IScope; + $root: IRootScopeService; + $id: string; // Hidden members diff --git a/ansicolors/ansicolors.d.ts b/ansicolors/ansicolors.d.ts new file mode 100644 index 0000000000..0ffc999102 --- /dev/null +++ b/ansicolors/ansicolors.d.ts @@ -0,0 +1,4 @@ +declare module "ansicolors" { + var colors: {[index: string]: (s: string) => string;}; + export = colors; +} diff --git a/async/async-tests.ts b/async/async-tests.ts index ae92bbff98..169bc9cb13 100644 --- a/async/async-tests.ts +++ b/async/async-tests.ts @@ -156,6 +156,22 @@ q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) { console.log('finished processing bar'); }); +// tests for strongly typed tasks +var q2 = async.queue(function (task: string, callback) { + console.log('Task: ' + task); + callback(); +}, 1); + +q2.push('task1'); + +q2.push('task2', function (error, results: string[]) { + console.log('Finished tasks: ' + results.join(', ')); +}); + +q2.push(['task3', 'task4', 'task5'], function (error, results: string[]) { + console.log('Finished tasks: ' + results.join(', ')); +}); + var filename = ''; async.auto({ get_data: function (callback) { }, diff --git a/async/async.d.ts b/async/async.d.ts index b8666febfb..25736941fe 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -3,8 +3,8 @@ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface AsyncMultipleResultsCallback { (err: string, results: T[]): any; } -interface AsyncSingleResultCallback { (err: string, result: T): void; } +interface AsyncMultipleResultsCallback { (err: Error, results: T[]): any; } +interface AsyncSingleResultCallback { (err: Error, result: T): void; } interface AsyncTimesCallback { (n: number, callback: AsyncMultipleResultsCallback): void; } interface AsyncIterator { (item: T, callback: AsyncSingleResultCallback): void; } @@ -16,6 +16,7 @@ interface AsyncQueue { length(): number; concurrency: number; push(task: T, callback?: AsyncMultipleResultsCallback): void; + push(task: T[], callback?: AsyncMultipleResultsCallback): void; saturated: AsyncMultipleResultsCallback; empty: AsyncMultipleResultsCallback; drain: AsyncMultipleResultsCallback; @@ -27,28 +28,28 @@ interface Async { forEach(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void; forEachSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void; forEachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void; - map(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - mapSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - filter(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - select(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - filterSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - selectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - reject(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - rejectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - reduce(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - inject(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - reduceRight(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - foldr(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - detect(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - detectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - sortBy(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - some(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - any(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - every(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any); - all(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any); - concat(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - concatSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); + map(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + mapSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + filter(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + select(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + filterSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + selectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + reject(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + rejectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + reduce(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + inject(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + reduceRight(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + foldr(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + detect(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + detectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + sortBy(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + some(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + any(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + every(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any): any; + all(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any): any; + concat(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + concatSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; // Control Flow series(tasks: T[], callback?: AsyncMultipleResultsCallback): void; diff --git a/bootstrap.v3.datetimepicker/boostrap.v3.datetimepicker-tests.ts b/bootstrap.v3.datetimepicker/boostrap.v3.datetimepicker-tests.ts new file mode 100644 index 0000000000..6abf38f946 --- /dev/null +++ b/bootstrap.v3.datetimepicker/boostrap.v3.datetimepicker-tests.ts @@ -0,0 +1,31 @@ +/// +/// + +function test_cases() { + $('#datetimepicker').datetimepicker(); + $('#datetimepicker').datetimepicker({ + pickDate: false + }); + $('#datetimepicker').datetimepicker({ + pickTime: false + }); + $('#datetimepicker').datetimepicker({ + minDate: '2012-12-31' + }); + + $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); + + var startDate = new Date(2012, 1, 20); + var endDate = new Date(2012, 1, 25); + $('#datetimepicker2') + .datetimepicker() + .on("dp.change", function (ev) { + if (ev.date.valueOf() > endDate.valueOf()) { + $('#alert').show().find('strong').text('The start date must be before the end date.'); + } else { + $('#alert').hide(); + startDate = ev.date; + $('#date-start-display').text($('#date-start').data('date')); + } + }); +} \ No newline at end of file diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts new file mode 100644 index 0000000000..6f1147cc11 --- /dev/null +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts @@ -0,0 +1,100 @@ +// Type definitions for Bootstrap datetimepicker v3 +// Project: http://eonasdan.github.io/bootstrap-datetimepicker +// Definitions by: Jesica N. Fera +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * bootstrap-datetimepicker.js 3.0.0 Copyright (c) 2014 Jonathan Peterson + * Available via the MIT license. + * see: http://eonasdan.github.io/bootstrap-datetimepicker or https://github.com/Eonasdan/bootstrap-datetimepicker for details. + */ + +/// + +declare module BootstrapV3DatetimePicker { + interface DatetimepickerChangeEventObject extends JQueryEventObject { + date: any; + oldDate: any; + } + + interface DatetimepickerEventObject extends JQueryEventObject { + date: any; + } + + interface DatetimepickerIcons { + time?: string; + date?: string; + up?: string; + down?: string; + } + + interface DatetimepickerOptions { + pickDate?: boolean; + pickTime?: boolean; + useMinutes?: boolean; + useSeconds?: boolean; + useCurrent?: boolean; + minuteStepping?: number; + minDate?: any; + maxDate?: any; + showToday?: boolean; + collapse?: boolean; + language?: string; + defaultDate?: string; + disabledDates?: Array; + enabledDates?: Array; + icons?: DatetimepickerIcons; + useStrict?: boolean; + direction?: string; + sideBySide?: boolean; + daysOfWeekDisabled?: Array; + } + + interface Datetimepicker { + setDate(date: any): void; + setMinDate(date: any): void; + setMaxDate(date: any): void; + show(): void; + disable(): void; + enable(): void; + getDate(): void; + } + +} + + +interface JQuery { + + datetimepicker(): JQuery; + datetimepicker(options: BootstrapV3DatetimePicker.DatetimepickerOptions): JQuery; + + off(events: "dp.change", selector?: string, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery; + off(events: "dp.change", handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery; + + on(events: "dp.change", selector: string, data: any, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery; + on(events: "dp.change", selector: string, handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery; + on(events: 'dp.change', handler: (eventObject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery; + + off(events: "dp.show", selector?: string, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + off(events: "dp.show", handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + + on(events: "dp.show", selector: string, data: any, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + on(events: "dp.show", selector: string, handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + on(events: 'dp.show', handler: (eventObject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + + off(events: "dp.hide", selector?: string, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + off(events: "dp.hide", handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + + on(events: "dp.hide", selector: string, data: any, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + on(events: "dp.hide", selector: string, handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + on(events: 'dp.hide', handler: (eventObject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + + off(events: "dp.error", selector?: string, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + off(events: "dp.error", handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + + on(events: "dp.error", selector: string, data: any, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + on(events: "dp.error", selector: string, handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + on(events: 'dp.error', handler: (eventObject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery; + + data(key: 'DateTimePicker'): BootstrapV3DatetimePicker.Datetimepicker; +} \ No newline at end of file diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index e8e0f0639a..d7aee083ed 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -1232,6 +1232,68 @@ declare module chrome.management { var onEnabled: ManagementEnabledEvent; } +//////////////////// +// Notifications +// https://developer.chrome.com/extensions/notifications +//////////////////// +declare module chrome.notifications { + interface ButtonOptions { + title: string; + iconUrl?: string; + } + + interface ItemOptions { + title: string; + message: string; + } + + interface NotificationOptions { + type?: string; + iconUrl?: string; + title?: string; + message?: string; + contextMessage?: string; + priority?: number; + eventTime?: number; + buttons?: Array; + items?: Array; + progress?: number; + isClickable?: boolean; + } + + interface OnClosed { + addListener(callback: (notificationId: string, byUser: boolean) => void): void; + } + + interface OnClicked { + addListener(callback: (notificationId: string) => void): void; + } + + interface OnButtonClicked { + addListener(callback: (notificationId: string, buttonIndex: number) => void): void; + } + + interface OnPermissionLevelChanged { + addListener(callback: (level: string) => void): void; + } + + interface OnShowSettings { + addListener(callback: Function): void; + } + + export var onClosed: OnClosed; + export var onClicked: OnClicked; + export var onButtonClicked: OnButtonClicked; + export var onPermissionLevelChanged: OnPermissionLevelChanged; + export var onShowSettings: OnShowSettings; + + export function create(notificationId: string, options: NotificationOptions, callback: (notificationId: string) => void): void; + export function update(notificationId: string, options: NotificationOptions, callback: (wasUpdated: boolean) => void): void; + export function clear(notificationId: string, callback: (wasCleared: boolean) => void): void; + export function getAll(callback: (notifications: any) => void): void; + export function getPermissionLevel(callback: (level: string) => void): void; +} + //////////////////// // Omnibox //////////////////// diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 2225db5fc6..41fc04dff0 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -2743,7 +2743,7 @@ declare module D3 { clamp(clamp: boolean): TimeScale; ticks: { (count: number): any[]; - (range: Range, count: number): any[]; + (range: D3.Time.Range, count: number): any[]; }; tickFormat(count: number): (n: number) => string; copy(): TimeScale; diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index 6c2013ec71..8250a3325e 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -1,1681 +1,1795 @@ -// Type definitions for Durandal 2.0.1 -// Project: http://durandaljs.com -// Definitions by: Evan Larsen -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/** - * Durandal 2.0.1 Copyright (c) 2012 Blue Spire Consulting, Inc. All Rights Reserved. - * Available via the MIT license. - * see: http://durandaljs.com or https://github.com/BlueSpire/Durandal for details. - */ - -/// -/// - -/** - * The system module encapsulates the most basic features used by other modules. - * @requires require - * @requires jquery - */ -declare module 'durandal/system' { - var theModule: DurandalSystemModule; - export = theModule; -} - -/** - * The viewEngine module provides information to the viewLocator module which is used to locate the view's source file. The viewEngine also transforms a view id into a view instance. - * @requires system - * @requires jquery - */ -declare module 'durandal/viewEngine' { - var theModule: DurandalViewEngineModule; - export = theModule; -} - -/** - * Durandal events originate from backbone.js but also combine some ideas from signals.js as well as some additional improvements. - * Events can be installed into any object and are installed into the `app` module by default for convenient app-wide eventing. - * @requires system - */ -declare module 'durandal/events' { - var theModule: DurandalEventModule; - export = theModule; -} - -/** - * The binder joins an object instance and a DOM element tree by applying databinding and/or invoking binding lifecycle callbacks (binding and bindingComplete). - * @requires system - * @requires knockout - */ -declare module 'durandal/binder' { - interface BindingInstruction { - applyBindings: boolean; - } - - /** - * Called before every binding operation. Does nothing by default. - * @param {object} data The data that is about to be bound. - * @param {DOMElement} view The view that is about to be bound. - * @param {object} instruction The object that carries the binding instructions. - */ - export var binding: (data: any, view: HTMLElement, instruction: BindingInstruction) => void; - - /** - * Called after every binding operation. Does nothing by default. - * @param {object} data The data that has just been bound. - * @param {DOMElement} view The view that has just been bound. - * @param {object} instruction The object that carries the binding instructions. - */ - export var bindingComplete: (data: any, view: HTMLElement, instruction: BindingInstruction) => void; - - /** - * Indicates whether or not the binding system should throw errors or not. - * @default false The binding system will not throw errors by default. Instead it will log them. - */ - export var throwOnErrors: boolean; - - /** - * Gets the binding instruction that was associated with a view when it was bound. - * @param {DOMElement} view The view that was previously bound. - * @returns {object} The object that carries the binding instructions. - */ - export function getBindingInstruction(view: HTMLElement): BindingInstruction; - - /** - * Binds the view, preserving the existing binding context. Optionally, a new context can be created, parented to the previous context. - * @param {KnockoutBindingContext} bindingContext The current binding context. - * @param {DOMElement} view The view to bind. - * @param {object} [obj] The data to bind to, causing the creation of a child binding context if present. - */ - export function bindContext(bindingContext: KnockoutBindingContext, view: HTMLElement, obj?: any): BindingInstruction; - - /** - * Binds the view, preserving the existing binding context. Optionally, a new context can be created, parented to the previous context. - * @param {object} obj The data to bind to. - * @param {DOMElement} view The view to bind. - */ - export function bind(obj: any, view: HTMLElement): BindingInstruction; -} - -/** - * The activator module encapsulates all logic related to screen/component activation. - * An activator is essentially an asynchronous state machine that understands a particular state transition protocol. - * The protocol ensures that the following series of events always occur: `canDeactivate` (previous state), `canActivate` (new state), `deactivate` (previous state), `activate` (new state). - * Each of the _can_ callbacks may return a boolean, affirmative value or promise for one of those. If either of the _can_ functions yields a false result, then activation halts. - * @requires system - * @requires knockout - */ -declare module 'durandal/activator' { - /** - * The default settings used by activators. - * @property {ActivatorSettings} defaults - */ - export var defaults: DurandalActivatorSettings; - - /** - * Creates a new activator. - * @method create - * @param {object} [initialActiveItem] The item which should be immediately activated upon creation of the ativator. - * @param {ActivatorSettings} [settings] Per activator overrides of the default activator settings. - * @returns {Activator} The created activator. - */ - export function create(initialActiveItem?: T, settings?: DurandalActivatorSettings): DurandalActivator; - - /** - * Determines whether or not the provided object is an activator or not. - * @method isActivator - * @param {object} object Any object you wish to verify as an activator or not. - * @returns {boolean} True if the object is an activator; false otherwise. - */ - export function isActivator(object: any): boolean; -} - -/** - * The viewLocator module collaborates with the viewEngine module to provide views (literally dom sub-trees) to other parts of the framework as needed. The primary consumer of the viewLocator is the composition module. - * @requires system - * @requires viewEngine - */ -declare module 'durandal/viewLocator' { - var theModule: DurandalViewLocatorModule; - export = theModule; -} - -/** - * The composition module encapsulates all functionality related to visual composition. - * @requires system - * @requires viewLocator - * @requires binder - * @requires viewEngine - * @requires activator - * @requires jquery - * @requires knockout - */ -declare module 'durandal/composition' { - interface CompositionTransation { - /** - * Registers a callback which will be invoked when the current composition transaction has completed. The transaction includes all parent and children compositions. - * @param {function} callback The callback to be invoked when composition is complete. - */ - complete(callback: Function): void; - } - - interface CompositionContext { - mode: string; - parent: HTMLElement; - activeView: HTMLElement; - triggerAttach(): void; - bindingContext?: KnockoutBindingContext; - cacheViews?: boolean; - viewElements?: HTMLElement[]; - model?: any; - view?: any; - area?: string; - preserveContext?: boolean; - activate?: boolean; - strategy?: (context: CompositionContext) => JQueryPromise; - composingNewView: boolean; - child: HTMLElement; - binding?: (child: HTMLElement, parent: HTMLElement, context: CompositionContext) => void; - attached?: (child: HTMLElement, parent: HTMLElement, context: CompositionContext) => void; - compositionComplete?: (child: HTMLElement, parent: HTMLElement, context: CompositionContext) => void; - tranistion?: string; - } - - /** - * Converts a transition name to its moduleId. - * @param {string} name The name of the transtion. - * @returns {string} The moduleId. - */ - export function convertTransitionToModuleId(name: string): string; - - /** - * The name of the transition to use in all compositions. - * @default null - */ - export var defaultTransitionName: string; - - /** - * Represents the currently executing composition transaction. - */ - export var current: CompositionTransation; - - /** - * Registers a binding handler that will be invoked when the current composition transaction is complete. - * @param {string} name The name of the binding handler. - * @param {object} [config] The binding handler instance. If none is provided, the name will be used to look up an existing handler which will then be converted to a composition handler. - * @param {function} [initOptionsFactory] If the registered binding needs to return options from its init call back to knockout, this function will server as a factory for those options. It will receive the same parameters that the init function does. - */ - export function addBindingHandler(name, config?: KnockoutBindingHandler, initOptionsFactory?: (element?: HTMLElement, valueAccessor?: any, allBindingsAccessor?: any, viewModel?: any, bindingContext?: KnockoutBindingContext) => any); - - /** - * Gets an object keyed with all the elements that are replacable parts, found within the supplied elements. The key will be the part name and the value will be the element itself. - * @param {DOMElement[]} elements The elements to search for parts. - * @returns {object} An object keyed by part. - */ - export function getParts(elements: HTMLElement[]): any; - - /** - * Gets an object keyed with all the elements that are replacable parts, found within the supplied element. The key will be the part name and the value will be the element itself. - * @param {DOMElement} element The element to search for parts. - * @returns {object} An object keyed by part. - */ - export function getParts(element: HTMLElement): any; - - /** - * Eecutes the default view location strategy. - * @param {object} context The composition context containing the model and possibly existing viewElements. - * @returns {promise} A promise for the view. - */ - export var defaultStrategy: (context: CompositionContext) => JQueryPromise; - - /** - * Initiates a composition. - * @param {DOMElement} element The DOMElement or knockout virtual element that serves as the parent for the composition. - * @param {object} settings The composition settings. - * @param {object} [bindingContext] The current binding context. - */ - export function compose(element: HTMLElement, settings: CompositionContext, bindingContext: KnockoutBindingContext): void; -} - -/** - * The app module controls app startup, plugin loading/configuration and root visual display. - * @requires system - * @requires viewEngine - * @requires composition - * @requires events - * @requires jquery - */ -declare module 'durandal/app' { - var theModule: DurandalAppModule; - export = theModule; -} - -/** - * The dialog module enables the display of message boxes, custom modal dialogs and other overlays or slide-out UI abstractions. Dialogs are constructed by the composition system which interacts with a user defined dialog context. The dialog module enforced the activator lifecycle. - * @requires system - * @requires app - * @requires composition - * @requires activator - * @requires viewEngine - * @requires jquery - * @requires knockout - */ -declare module 'plugins/dialog' { - import composition = require('durandal/composition'); - - /** - * Models a message box's message, title and options. - * @class - */ - class Box { - constructor(message: string, title: string, options: string[]); - - /** - * Selects an option and closes the message box, returning the selected option through the dialog system's promise. - * @param {string} dialogResult The result to select. - */ - selectOptions(dialogResult: string): void; - - /** - * Provides the view to the composition system. - * @returns {DOMElement} The view of the message box. - */ - getView(): HTMLElement; - - /** - * The title to be used for the message box if one is not provided. - * @default Application - * @static - */ - static defaultTitle: string; - - /** - * The options to display in the message box of none are specified. - * @default ['Ok'] - * @static - */ - static defaultOptions: string[]; - - /** - * The markup for the message box's view. - * @static - */ - static defaultViewMarkup: string; - - /** - * Configures a custom view to use when displaying message boxes. - * @param {string} viewUrl The view url relative to the base url which the view locator will use to find the message box's view. - * @static - */ - static setViewUrl(url: string): void; - } - - interface DialogContext { - /** - * In this function, you are expected to add a DOM element to the tree which will serve as the "host" for the modal's composed view. You must add a property called host to the modalWindow object which references the dom element. It is this host which is passed to the composition module. - * @param {Dialog} theDialog The dialog model. - */ - addHost(theDialog: Dialog); - - /** - * This function is expected to remove any DOM machinery associated with the specified dialog and do any other necessary cleanup. - * @param {Dialog} theDialog The dialog model. - */ - removeHost(theDialog: Dialog); - - /** - * This function is called after the modal is fully composed into the DOM, allowing your implementation to do any final modifications, such as positioning or animation. You can obtain the original dialog object by using `getDialog` on context.model. - * @param {DOMElement} child The dialog view. - * @param {DOMElement} parent The parent view. - * @param {object} context The composition context. - */ - compositionComplete(child: HTMLElement, parent: HTMLElement, context: composition.CompositionContext); - } - - interface Dialog { - owner: any; - context: DialogContext; - activator: DurandalActivator; - close(): JQueryPromise; - settings: composition.CompositionContext; - } - - /** - * The constructor function used to create message boxes. - */ - export var MessageBox: Box; - - /** - * The css zIndex that the last dialog was displayed at. - */ - export var currentZIndex: number; - - /** - * Gets the next css zIndex at which a dialog should be displayed. - * @returns {number} The next usable zIndex. - */ - export function getNextZIndex(): number; - - /** - * Determines whether or not there are any dialogs open. - * @returns {boolean} True if a dialog is open. false otherwise. - */ - export function isOpen(): boolean; - - /** - * Gets the dialog context by name or returns the default context if no name is specified. - * @param {string} [name] The name of the context to retrieve. - * @returns {DialogContext} True context. - */ - export function getContext(name: string): DialogContext; - - /** - * Adds (or replaces) a dialog context. - * @param {string} name The name of the context to add. - * @param {DialogContext} dialogContext The context to add. - */ - export function addContext(name: string, modalContext: DialogContext): void; - - /** - * Gets the dialog model that is associated with the specified object. - * @param {object} obj The object for whom to retrieve the dialog. - * @returns {Dialog} The dialog model. - */ - export function getDialog(obj: any): Dialog; - - /** - * Closes the dialog associated with the specified object. - * @param {object} obj The object whose dialog should be closed. - * @param {object} results* The results to return back to the dialog caller after closing. - */ - export function close(obj: any, ...results: any[]): void; - - /** - * Shows a dialog. - * @param {object|string} obj The object (or moduleId) to display as a dialog. - * @param {object} [activationData] The data that should be passed to the object upon activation. - * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. - * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. - */ - export function show(obj: any, activationData?: any, context?: string): JQueryPromise; - - /** - * Shows a message box. - * @param {string} message The message to display in the dialog. - * @param {string} [title] The title message. - * @param {string[]} [options] The options to provide to the user. - * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. - */ - export function showMessage(message: string, title?: string, options?: string[]): JQueryPromise; - - /** - * Installs this module into Durandal; called by the framework. Adds `app.showDialog` and `app.showMessage` convenience methods. - * @param {object} [config] Add a `messageBox` property to supply a custom message box constructor. Add a `messageBoxView` property to supply custom view markup for the built-in message box. - */ - export function install(config: Object): void; -} - -/** - * This module is based on Backbone's core history support. It abstracts away the low level details of working with browser history and url changes in order to provide a solid foundation for a router. - * @requires system - * @requires jquery - */ -declare module 'plugins/history' { - /** - * The setTimeout interval used when the browser does not support hash change events. - * @default 50 - */ - export var interval: number; - - /** - * Indicates whether or not the history module is actively tracking history. - */ - export var active: boolean; - - /** - * Gets the true hash value. Cannot use location.hash directly due to a bug in Firefox where location.hash will always be decoded. - * @param {string} [window] The optional window instance - * @returns {string} The hash. - */ - export function getHash(window?: Window): string; - - /** - * Get the cross-browser normalized URL fragment, either from the URL, the hash, or the override. - * @param {string} fragment The fragment. - * @param {boolean} forcePushState Should we force push state? - * @returns {string} he fragment. - */ - export function getFragment(fragment: string, forcePushState: boolean): string; - - /** - * Activate the hash change handling, returning `true` if the current URL matches an existing route, and `false` otherwise. - * @param {HistoryOptions} options. - * @returns {boolean|undefined} Returns true/false from loading the url unless the silent option was selected. - */ - export function activate(options: DurandalHistoryOptions): boolean; - - /** - * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. - */ - export function deactivate(): void; - - /** - * Checks the current URL to see if it has changed, and if it has, calls `loadUrl`, normalizing across the hidden iframe. - * @returns {boolean} Returns true/false from loading the url. - */ - export function checkUrl(): boolean; - - /** - * Attempts to load the current URL fragment. A pass-through to options.routeHandler. - * @returns {boolean} Returns true/false from the route handler. - */ - export function loadUrl(): boolean; - - /** - * Save a fragment into the hash history, or replace the URL state if the - * 'replace' option is passed. You are responsible for properly URL-encoding - * the fragment in advance. - * The options object can contain `trigger: false` if you wish to not have the - * route callback be fired, or `replace: true`, if - * you wish to modify the current URL without adding an entry to the history. - * @param {string} fragment The url fragment to navigate to. - * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. - * @return {boolean} Returns true/false from loading the url. - */ - export function navigate(fragment: string, trigger?: boolean): boolean; - - /** - * Save a fragment into the hash history, or replace the URL state if the - * 'replace' option is passed. You are responsible for properly URL-encoding - * the fragment in advance. - * The options object can contain `trigger: false` if you wish to not have the - * route callback be fired, or `replace: true`, if - * you wish to modify the current URL without adding an entry to the history. - * @param {string} fragment The url fragment to navigate to. - * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. - * @return {boolean} Returns true/false from loading the url. - */ - export function navigate(fragment: string, options: DurandalNavigationOptions): boolean; - - /** - * Navigates back in the browser history. - */ - export function navigateBack(): void; -} - -/** - * Enables common http request scenarios. - * @requires jquery - * @requires knockout - */ -declare module 'plugins/http' { - /** - * The name of the callback parameter to inject into jsonp requests by default. - * @default callback - */ - export var callbackParam: string; - - /** - * Makes an HTTP GET request. - * @param {string} url The url to send the get request to. - * @param {object} [query] An optional key/value object to transform into query string parameters. - * @returns {Promise} A promise of the get response data. - */ - export function get(url: string, query?: Object): JQueryPromise; - - /** - * Makes an JSONP request. - * @param {string} url The url to send the get request to. - * @param {object} [query] An optional key/value object to transform into query string parameters. - * @param {string} [callbackParam] The name of the callback parameter the api expects (overrides the default callbackParam). - * @returns {Promise} A promise of the response data. - */ - export function jsonp(url: string, query?: Object, callbackParam?: string): JQueryPromise; - - /** - * Makes an HTTP POST request. - * @param {string} url The url to send the post request to. - * @param {object} data The data to post. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. - * @returns {Promise} A promise of the response data. - */ - export function post(url: string, data: Object): JQueryPromise; -} - -/** - * Enables automatic observability of plain javascript object for ES5 compatible browsers. Also, converts promise properties into observables that are updated when the promise resolves. - * @requires system - * @requires binder - * @requires knockout - */ -declare module 'plugins/observable' { - function observable(obj: any, property: string): KnockoutObservable; - - module observable { - /** - * Converts an entire object into an observable object by re-writing its attributes using ES5 getters and setters. Attributes beginning with '_' or '$' are ignored. - * @param {object} obj The target object to convert. - */ - export function convertObject(obj: any): void; - - /** - * Converts a normal property into an observable property using ES5 getters and setters. - * @param {object} obj The target object on which the property to convert lives. - * @param {string} propertyName The name of the property to convert. - * @param {object} [original] The original value of the property. If not specified, it will be retrieved from the object. - * @returns {KnockoutObservable} The underlying observable. - */ - export function convertProperty(obj: any, propertyName: string, original?: any): KnockoutObservable; - - /** - * Defines a computed property using ES5 getters and setters. - * @param {object} obj The target object on which to create the property. - * @param {string} propertyName The name of the property to define. - * @param {function|object} evaluatorOrOptions The Knockout computed function or computed options object. - * @returns {KnockoutComputed} The underlying computed observable. - */ - export function defineProperty(obj: any, propertyName: string, evaluatorOrOptions?: KnockoutComputedDefine); - - /** - * Installs the plugin into the view model binder's `beforeBind` hook so that objects are automatically converted before being bound. - */ - export function install(config: Object): void; - } - - export = observable; -} - -/** - * Serializes and deserializes data to/from JSON. - * @requires system - */ -declare module 'plugins/serializer' { - interface SerializerOptions { - /** - * The default replacer function used during serialization. By default properties starting with '_' or '$' are removed from the serialized object. - * @param {string} key The object key to check. - * @param {object} value The object value to check. - * @returns {object} The value to serialize. - */ - replacer?: (key: string, value: any) => any; - - /** - * The amount of space to use for indentation when writing out JSON. - * @default undefined - */ - space: any; - } - - interface DeserializerOptions { - /** - * Gets the type id for an object instance, using the configured `typeAttribute`. - * @param {object} object The object to serialize. - * @returns {string} The type. - */ - getTypeId: (object: any) => string; - - /** - * Gets the constructor based on the type id. - * @param {string} typeId The type id. - * @returns {Function} The constructor. - */ - getConstructor: (typeId: string) => () => any; - - /** - * The default reviver function used during deserialization. By default is detects type properties on objects and uses them to re-construct the correct object using the provided constructor mapping. - * @param {string} key The attribute key. - * @param {object} value The object value associated with the key. - * @returns {object} The value. - */ - reviver: (key: string, value: any) => any; - } - - /** - * The name of the attribute that the serializer should use to identify an object's type. - * @default type - */ - export var typeAttribute: string; - - /** - * The amount of space to use for indentation when writing out JSON. - * @default undefined - */ - export var space: any; - - /** - * The default replacer function used during serialization. By default properties starting with '_' or '$' are removed from the serialized object. - * @param {string} key The object key to check. - * @param {object} value The object value to check. - * @returns {object} The value to serialize. - */ - export function replacer(key: string, value: any): any; - - /** - * Serializes the object. - * @param {object} object The object to serialize. - * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. - * @returns {string} The JSON string. - */ - export function serialize(object: any, settings?: string); - - /** - * Serializes the object. - * @param {object} object The object to serialize. - * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. - * @returns {string} The JSON string. - */ - export function serialize(object: any, settings?: number); - - /** - * Serializes the object. - * @param {object} object The object to serialize. - * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. - * @returns {string} The JSON string. - */ - export function serialize(object: any, settings?: SerializerOptions); - - /** - * Gets the type id for an object instance, using the configured `typeAttribute`. - * @param {object} object The object to serialize. - * @returns {string} The type. - */ - export function getTypeId(object: any): string; - - /** - * Maps type ids to object constructor functions. Keys are type ids and values are functions. - */ - export var typeMap: any; - - /** - * Adds a type id/constructor function mampping to the `typeMap`. - * @param {string} typeId The type id. - * @param {function} constructor The constructor. - */ - export function registerType(typeId: string, constructor: () => any); - - /** - * The default reviver function used during deserialization. By default is detects type properties on objects and uses them to re-construct the correct object using the provided constructor mapping. - * @param {string} key The attribute key. - * @param {object} value The object value associated with the key. - * @param {function} getTypeId A custom function used to get the type id from a value. - * @param {object} getConstructor A custom function used to get the constructor function associated with a type id. - * @returns {object} The value. - */ - export function reviver(key: string, value: any, getTypeId: (value: any) => string, getConstructor: (string) => () => any): any; - - /** - * Deserialize the JSON. - * @param {text} string The JSON string. - * @param {DeserializerOptions} settings Settings can specify a reviver, getTypeId function or getConstructor function. - * @returns {object} The deserialized object. - */ - export function deserialize(text: string, settings?: DeserializerOptions): T; -} - -/** - * Layers the widget sugar on top of the composition system. - * @requires system - * @requires composition - * @requires jquery - * @requires knockout - */ -declare module 'plugins/widget' { - interface WidgetSettings { - kind: string; - model?: any; - view?: any; - } - - /** - * Creates a ko binding handler for the specified kind. - * @param {string} kind The kind to create a custom binding handler for. - */ - export function registerKind(kind: string); - - /** - * Maps views and module to the kind identifier if a non-standard pattern is desired. - * @param {string} kind The kind name. - * @param {string} [viewId] The unconventional view id to map the kind to. - * @param {string} [moduleId] The unconventional module id to map the kind to. - */ - export function mapKind(kind: string, viewId?: string, moduleId?: string); - - /** - * Maps a kind name to it's module id. First it looks up a custom mapped kind, then falls back to `convertKindToModulePath`. - * @param {string} kind The kind name. - * @returns {string} The module id. - */ - export function mapKindToModuleId(kind: string): string; - - /** - * Converts a kind name to it's module path. Used to conventionally map kinds who aren't explicitly mapped through `mapKind`. - * @param {string} kind The kind name. - * @returns {string} The module path. - */ - export function convertKindToModulePath(kind: string): string; - - /** - * Maps a kind name to it's view id. First it looks up a custom mapped kind, then falls back to `convertKindToViewPath`. - * @param {string} kind The kind name. - * @returns {string} The view id. - */ - export function mapKindToViewId(kind: string): string; - - /** - * Converts a kind name to it's view id. Used to conventionally map kinds who aren't explicitly mapped through `mapKind`. - * @param {string} kind The kind name. - * @returns {string} The view id. - */ - export function convertKindToViewPath(kind: string): string; - - /** - * Creates a widget. - * @param {DOMElement} element The DOMElement or knockout virtual element that serves as the target element for the widget. - * @param {object} settings The widget settings. - * @param {object} [bindingContext] The current binding context. - */ - export function create(element: HTMLElement, settings: WidgetSettings, bindingContext?: KnockoutBindingContext); -} - -/** - * Connects the history module's url and history tracking support to Durandal's activation and composition engine allowing you to easily build navigation-style applications. - * @requires system - * @requires app - * @requires activator - * @requires events - * @requires composition - * @requires history - * @requires knockout - * @requires jquery - */ -declare module 'plugins/router' { - var theModule: DurandalRootRouter; - export = theModule; -} - -interface DurandalSystemModule { - /** - * Durandal's version. - */ - version: string; - - /** - * A noop function. - */ - noop: Function; - - /** - * Gets the module id for the specified object. - * @param {object} obj The object whose module id you wish to determine. - * @returns {string} The module id. - */ - getModuleId(obj: any): string; - - /** - * Sets the module id for the specified object. - * @param {object} obj The object whose module id you wish to set. - * @param {string} id The id to set for the specified object. - */ - setModuleId(obj, id: string): void; - - /** - * Resolves the default object instance for a module. If the module is an object, the module is returned. If the module is a function, that function is called with `new` and it's result is returned. - * @param {object} module The module to use to get/create the default object for. - * @returns {object} The default object for the module. - */ - resolveObject(module: any): any; - - /** - * Gets/Sets whether or not Durandal is in debug mode. - * @param {boolean} [enable] Turns on/off debugging. - * @returns {boolean} Whether or not Durandal is current debugging. - */ - debug(enable?: boolean): boolean; - - /** - * Logs data to the console. Pass any number of parameters to be logged. Log output is not processed if the framework is not running in debug mode. - * @param {object} info* The objects to log. - */ - log(...msgs: any[]): void; - - /** - * Logs an error. - * @param {string} obj The error to report. - */ - error(error: string): void; - - /** - * Logs an error. - * @param {Error} obj The error to report. - */ - error(error: Error): void; - - /** - * Asserts a condition by throwing an error if the condition fails. - * @param {boolean} condition The condition to check. - * @param {string} message The message to report in the error if the condition check fails. - */ - assert(condition: boolean, message: string): void; - - /** - * Creates a deferred object which can be used to create a promise. Optionally pass a function action to perform which will be passed an object used in resolving the promise. - * @param {function} [action] The action to defer. You will be passed the deferred object as a paramter. - * @returns {JQueryDeferred} The deferred object. - */ - defer(action?: (dfd: JQueryDeferred) => void): JQueryDeferred; - - /** - * Creates a simple V4 UUID. This should not be used as a PK in your database. It can be used to generate internal, unique ids. For a more robust solution see [node-uuid](https://github.com/broofa/node-uuid). - * @returns {string} The guid. - */ - guid(): string; - - /** - * Uses require.js to obtain a module. This function returns a promise which resolves with the module instance. - * @param {string} moduleId The id of the module to load. - * @returns {JQueryPromise} A promise for the loaded module. - */ - acquire(moduleId: string): JQueryPromise; - - /** - * Uses require.js to obtain an array of modules. This function returns a promise which resolves with the modules instances in an array. - * @param {string[]} moduleIds The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. - */ - acquire(modules: string[]): JQueryPromise; - - /** - * Uses require.js to obtain multiple modules. This function returns a promise which resolves with the module instances in an array. - * @param {string} moduleIds* The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. - */ - acquire(...moduleIds: string[]): JQueryPromise; - - /** - * Extends the first object with the properties of the following objects. - * @param {object} obj The target object to extend. - * @param {object} extension* Uses to extend the target object. - */ - extend(obj: any, ...extensions: any[]): any; - - /** - * Uses a setTimeout to wait the specified milliseconds. - * @param {number} milliseconds The number of milliseconds to wait. - * @returns {JQueryPromise} - */ - wait(milliseconds: number): JQueryPromise; - - /** - * Gets all the owned keys of the specified object. - * @param {object} object The object whose owned keys should be returned. - * @returns {string[]} The keys. - */ - keys(obj: any): string[]; - - /** - * Determines if the specified object is an html element. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isElement(obj: any): boolean; - - /** - * Determines if the specified object is an array. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isArray(obj: any): boolean; - - /** - * Determines if the specified object is a boolean. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isObject(obj: any): boolean; - - /** - * Determines if the specified object is a promise. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isPromise(obj: any): boolean; - - /** - * Determines if the specified object is a function arguments object. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isArguments(obj: any): boolean; - - /** - * Determines if the specified object is a function. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isFunction(obj: any): boolean; - - /** - * Determines if the specified object is a string. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isString(obj: any): boolean; - - /** - * Determines if the specified object is a number. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isNumber(obj: any): boolean; - - /** - * Determines if the specified object is a date. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isDate(obj: any): boolean; - - /** - * Determines if the specified object is a boolean. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - isBoolean(obj: any): boolean; -} - -interface DurandalViewEngineModule { - - /** - * The file extension that view source files are expected to have. - * @default .html - */ - viewExtension: string; - - /** - * The name of the RequireJS loader plugin used by the viewLocator to obtain the view source. (Use requirejs to map the plugin's full path). - * @default text - */ - viewPlugin: string; - - /** - * Determines if the url is a url for a view, according to the view engine. - * @param {string} url The potential view url. - * @returns {boolean} True if the url is a view url, false otherwise. - */ - isViewUrl(url: string): boolean; - - /** - * Converts a view url into a view id. - * @param {string} url The url to convert. - * @returns {string} The view id. - */ - convertViewUrlToViewId(url: string): string; - - /** - * Converts a view id into a full RequireJS path. - * @param {string} viewId The view id to convert. - * @returns {string} The require path. - */ - convertViewIdToRequirePath(viewId: string): string; - - /** - * Parses the view engine recognized markup and returns DOM elements. - * @param {string} markup The markup to parse. - * @returns {HTMLElement[]} The elements. - */ - parseMarkup(markup: string): Node[]; - - /** - * Calls `parseMarkup` and then pipes the results through `ensureSingleElement`. - * @param {string} markup The markup to process. - * @returns {HTMLElement} The view. - */ - processMarkup(markup: string): HTMLElement; - - /** - * Converts an array of elements into a single element. White space and comments are removed. If a single element does not remain, then the elements are wrapped. - * @param {HTMLElement[]} allElements The elements. - * @returns {HTMLElement} A single element. - */ - ensureSingleElement(allElements: Node[]): HTMLElement; - - /** - * Creates the view associated with the view id. - * @param {string} viewId The view id whose view should be created. - * @returns {JQueryPromise} A promise of the view. - */ - createView(viewId: string): JQueryPromise; - - /** - * Called when a view cannot be found to provide the opportunity to locate or generate a fallback view. Mainly used to ease development. - * @param {string} viewId The view id whose view should be created. - * @param {string} requirePath The require path that was attempted. - * @param {Error} requirePath The error that was returned from the attempt to locate the default view. - * @returns {Promise} A promise for the fallback view. - */ - createFallbackView(viewId: string, requirePath: string, err: Error): JQueryPromise; -} - -interface DurandalViewLocatorModule { - - /** - * Allows you to set up a convention for mapping module folders to view folders. It is a convenience method that customizes `convertModuleIdToViewId` and `translateViewIdToArea` under the covers. - * @param {string} [modulesPath] A string to match in the path and replace with the viewsPath. If not specified, the match is 'viewmodels'. - * @param {string} [viewsPath] The replacement for the modulesPath. If not specified, the replacement is 'views'. - * @param {string} [areasPath] Partial views are mapped to the "views" folder if not specified. Use this parameter to change their location. - */ - useConvention(modulesPath?: string, viewsPath?: string, areasPath?: string): void; - - /** - * Maps an object instance to a view instance. - * @param {object} obj The object to locate the view for. - * @param {string} [area] The area to translate the view to. - * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. - * @returns {Promise} A promise of the view. - */ - locateViewForObject(obj: any, area: string, elementsToSearch?: HTMLElement[]): JQueryPromise; - - /** - * Converts a module id into a view id. By default the ids are the same. - * @param {string} moduleId The module id. - * @returns {string} The view id. - */ - convertModuleIdToViewId(moduleId: string): string; - - /** - * If no view id can be determined, this function is called to genreate one. By default it attempts to determine the object's type and use that. - * @param {object} obj The object to determine the fallback id for. - * @returns {string} The view id. - */ - determineFallbackViewId(obj: any): string; - - /** - * Takes a view id and translates it into a particular area. By default, no translation occurs. - * @param {string} viewId The view id. - * @param {string} area The area to translate the view to. - * @returns {string} The translated view id. - */ - translateViewIdToArea(viewId: string, area: string): string; - - /** - * Locates the specified view. - * @param {string|DOMElement} view A view. It will be immediately returned. - * @param {string} [area] The area to translate the view to. - * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. - * @returns {Promise} A promise of the view. - */ - locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; - - /** - * Locates the specified view. - * @param {string|DOMElement} viewUrlOrId A view url or view id to locate. - * @param {string} [area] The area to translate the view to. - * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. - * @returns {Promise} A promise of the view. - */ - locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; -} - -interface DurandalEventSubscription { - /** - * Attaches a callback to the event subscription. - * @param {function} callback The callback function to invoke when the event is triggered. - * @param {object} [context] An object to use as `this` when invoking the `callback`. - * @chainable - */ - then(thenCallback: Function, context?: any): DurandalEventSubscription; - - /** - * Attaches a callback to the event subscription. - * @param {function} [callback] The callback function to invoke when the event is triggered. If `callback` is not provided, the previous callback will be re-activated. - * @param {object} [context] An object to use as `this` when invoking the `callback`. - * @chainable - */ - on(thenCallback: Function, context?: any): DurandalEventSubscription; - - /** - * Cancels the subscription. - * @chainable - */ - off(): DurandalEventSubscription; -} - -interface DurandalEventSupport { - /** - * Creates a subscription or registers a callback for the specified event. - * @param {string} events One or more events, separated by white space. - * @returns {Subscription} A subscription is returned. - */ - on(events: string): DurandalEventSubscription; - - /** - * Creates a subscription or registers a callback for the specified event. - * @param {string} events One or more events, separated by white space. - * @param {function} [callback] The callback function to invoke when the event is triggered. - * @param {object} [context] An object to use as `this` when invoking the `callback`. - * @returns {Events} The events object is returned for chaining. - */ - on(events: string, callback: Function, context?: any): T; - - /** - * Removes the callbacks for the specified events. - * @param {string} [events] One or more events, separated by white space to turn off. If no events are specified, then the callbacks will be removed. - * @param {function} [callback] The callback function to remove. If `callback` is not provided, all callbacks for the specified events will be removed. - * @param {object} [context] The object that was used as `this`. Callbacks with this context will be removed. - * @chainable - */ - off(events: string, callback: Function, context?: any): T; - - /** - * Triggers the specified events. - * @param {string} [events] One or more events, separated by white space to trigger. - * @chainable - */ - trigger(events: string, ...eventArgs: any[]): T; - - /** - * Creates a function that will trigger the specified events when called. Simplifies proxying jQuery (or other) events through to the events object. - * @param {string} events One or more events, separated by white space to trigger by invoking the returned function. - * @returns {function} Calling the function will invoke the previously specified events on the events object. - */ - proxy(events: string): Function; -} - -interface DurandalEventModule { - new (): DurandalEventSupport; - includeIn(targetObject: any): void; -} - -interface DurandalAppModule extends DurandalEventSupport { - /** - * The title of your application. - */ - title: string; - - /** - * Shows a dialog via the dialog plugin. - * @param {object|string} obj The object (or moduleId) to display as a dialog. - * @param {object} [activationData] The data that should be passed to the object upon activation. - * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. - * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. - */ - showDialog(obj: any, activationData?: any, context?: string): JQueryPromise; - - /** - * Shows a message box via the dialog plugin. - * @param {string} message The message to display in the dialog. - * @param {string} [title] The title message. - * @param {string[]} [options] The options to provide to the user. - * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. - */ - showMessage(message: string, title?: string, options?: string[]): JQueryPromise; - - /** - * Configures one or more plugins to be loaded and installed into the application. - * @method configurePlugins - * @param {object} config Keys are plugin names. Values can be truthy, to simply install the plugin, or a configuration object to pass to the plugin. - * @param {string} [baseUrl] The base url to load the plugins from. - */ - configurePlugins(config: Object, baseUrl?: string): void; - - /** - * Starts the application. - * @returns {promise} - */ - start(): JQueryPromise; - - /** - * Sets the root module/view for the application. - * @param {string} root The root view or module. - * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root. - * @param {string} [applicationHost] The application host element id. By default the id 'applicationHost' will be used. - */ - setRoot(root: any, transition?: string, applicationHost?: string): void; - - /** - * Sets the root module/view for the application. - * @param {string} root The root view or module. - * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root. - * @param {string} [applicationHost] The application host element. By default the id 'applicationHost' will be used. - */ - setRoot(root: any, transition?: string, applicationHost?: HTMLElement): void; -} - -interface DurandalActivatorSettings { - /** - * The default value passed to an object's deactivate function as its close parameter. - * @default true - */ - closeOnDeactivate: boolean; - - /** - * Lower-cased words which represent a truthy value. - * @default ['yes', 'ok', 'true'] - */ - affirmations: string[]; - - /** - * Interprets the response of a `canActivate` or `canDeactivate` call using the known affirmative values in the `affirmations` array. - * @param {object} value - * @returns {boolean} - */ - interpretResponse(value: any): boolean; - - /** - * Determines whether or not the current item and the new item are the same. - * @param {object} currentItem - * @param {object} newItem - * @param {object} currentActivationData - * @param {object} newActivationData - * @returns {boolean} - */ - areSameItem(currentItem: any, newItem: any, currentActivationData: any, newActivationData: any): boolean; - - /** - * Called immediately before the new item is activated. - * @param {object} newItem - */ - beforeActivate(newItem: any): any; - - /** - * Called immediately after the old item is deactivated. - * @param {object} oldItem The previous item. - * @param {boolean} close Whether or not the previous item was closed. - * @param {function} setter The activate item setter function. - */ - afterDeactivate(oldItem: any, close: boolean, setter: Function): void; -} - -interface DurandalActivator extends KnockoutComputed { - /** - * The settings for this activator. - */ - settings: DurandalActivatorSettings; - - /** - * An observable which indicates whether or not the activator is currently in the process of activating an instance. - * @returns {boolean} - */ - isActivating: KnockoutObservable; - - /** - * Determines whether or not the specified item can be deactivated. - * @param {object} item The item to check. - * @param {boolean} close Whether or not to check if close is possible. - * @returns {promise} - */ - canDeactivateItem(item: T, close: boolean): JQueryPromise; - - /** - * Deactivates the specified item. - * @param {object} item The item to deactivate. - * @param {boolean} close Whether or not to close the item. - * @returns {promise} - */ - deactivateItem(item: T, close: boolean): JQueryPromise; - - /** - * Determines whether or not the specified item can be activated. - * @param {object} item The item to check. - * @param {object} activationData Data associated with the activation. - * @returns {promise} - */ - canActivateItem(newItem: T, activationData?: any): JQueryPromise; - - /** - * Activates the specified item. - * @param {object} newItem The item to activate. - * @param {object} newActivationData Data associated with the activation. - * @returns {promise} - */ - activateItem(newItem: T, activationData?: any): JQueryPromise; - - /** - * Determines whether or not the activator, in its current state, can be activated. - * @returns {promise} - */ - canActivate(): JQueryPromise; - - /** - * Activates the activator, in its current state. - * @returns {promise} - */ - activate(): JQueryPromise; - - /** - * Determines whether or not the activator, in its current state, can be deactivated. - * @returns {promise} - */ - canDeactivate(close: boolean): JQueryPromise; - - /** - * Deactivates the activator, in its current state. - * @returns {promise} - */ - deactivate(close: boolean): JQueryPromise; - - /** - * Adds canActivate, activate, canDeactivate and deactivate functions to the provided model which pass through to the corresponding functions on the activator. - */ - includeIn(includeIn: any): void; - - /** - * Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them. - */ - forItems(items): DurandalActivator; -} - -interface DurandalHistoryOptions { - /** - * The function that will be called back when the fragment changes. - */ - routeHandler?: (fragment: string) => void; - - /** - * The url root used to extract the fragment when using push state. - */ - root?: string; - - /** - * Use hash change when present. - * @default true - */ - hashChange?: boolean; - - /** - * Use push state when present. - * @default false - */ - pushState?: boolean; - - /** - * Prevents loading of the current url when activating history. - * @default false - */ - silent?: boolean; -} - -interface DurandalNavigationOptions { - trigger: boolean; - replace: boolean; -} - -interface DurandalRouteConfiguration { - title?: string; - moduleId?: string; - hash?: string; - route?: string; - routePattern?: RegExp; - isActive?: KnockoutComputed; - nav: any; -} - -interface DurandalRouteInstruction { - fragment: string; - queryString: string; - config: DurandalRouteConfiguration; - params: any[]; - queryParams: Object; -} - -interface DurandalRelativeRouteSettings { - moduleId?: string; - route?: string; - fromParent?: boolean; -} - -interface DurandalRouterBase extends DurandalEventSupport { - /** - * The route handlers that are registered. Each handler consists of a `routePattern` and a `callback`. - */ - handlers: { routePattern: RegExp; callback: (fragment: string) => void; }[]; - - /** - * The route configs that are registered. - */ - routes: DurandalRouteConfiguration[]; - - /** - * The active item/screen based on the current navigation state. - */ - activeItem: DurandalActivator; - - /** - * The route configurations that have been designated as displayable in a nav ui (nav:true). - */ - navigationModel: KnockoutObservableArray; - - /** - * Indicates that the router (or a child router) is currently in the process of navigating. - */ - isNavigating: KnockoutComputed; - - /** - * An observable surfacing the active routing instruction that is currently being processed or has recently finished processing. - * The instruction object has `config`, `fragment`, `queryString`, `params` and `queryParams` properties. - */ - activeInstruction: KnockoutObservable; - - /** - * Parses a query string into an object. - * @param {string} queryString The query string to parse. - * @returns {object} An object keyed according to the query string parameters. - */ - parseQueryString(queryString: string): Object; - - /** - * Add a route to be tested when the url fragment changes. - * @param {RegEx} routePattern The route pattern to test against. - * @param {function} callback The callback to execute when the route pattern is matched. - */ - route(routePattern: RegExp, callback: (fragment: string) => void): void; - - /** - * Attempt to load the specified URL fragment. If a route succeeds with a match, returns `true`. If no defined routes matches the fragment, returns `false`. - * @param {string} fragment The URL fragment to find a match for. - * @returns {boolean} True if a match was found, false otherwise. - */ - loadUrl(fragment: string): boolean; - - /** - * Updates the document title based on the activated module instance, the routing instruction and the app.title. - * @param {object} instance The activated module. - * @param {object} instruction The routing instruction associated with the action. It has a `config` property that references the original route mapping config. - */ - updateDocumentTitle(instance: Object, instruction: DurandalRouteInstruction): void; - - /** - * Save a fragment into the hash history, or replace the URL state if the - * 'replace' option is passed. You are responsible for properly URL-encoding - * the fragment in advance. - * The options object can contain `trigger: false` if you wish to not have the - * route callback be fired, or `replace: true`, if - * you wish to modify the current URL without adding an entry to the history. - * @param {string} fragment The url fragment to navigate to. - * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. - * @return {boolean} Returns true/false from loading the url. - */ - navigate(fragment: string, trigger?: boolean): boolean; - - /** - * Save a fragment into the hash history, or replace the URL state if the - * 'replace' option is passed. You are responsible for properly URL-encoding - * the fragment in advance. - * The options object can contain `trigger: false` if you wish to not have the - * route callback be fired, or `replace: true`, if - * you wish to modify the current URL without adding an entry to the history. - * @param {string} fragment The url fragment to navigate to. - * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. - * @return {boolean} Returns true/false from loading the url. - */ - navigate(fragment: string, options: DurandalNavigationOptions): boolean; - - /** - * Navigates back in the browser history. - */ - navigateBack(): void; - - /** - * Converts a route to a hash suitable for binding to a link's href. - * @param {string} route - * @returns {string} The hash. - */ - convertRouteToHash(route: string): string; - - /** - * Converts a route to a module id. This is only called if no module id is supplied as part of the route mapping. - * @param {string} route - * @returns {string} The module id. - */ - convertRouteToModuleId(route: string): string; - - /** - * Converts a route to a displayable title. This is only called if no title is specified as part of the route mapping. - * @method convertRouteToTitle - * @param {string} route - * @returns {string} The title. - */ - convertRouteToTitle(route: string): string; - - /** - * Maps route patterns to modules. - * @param {string} route A route. - * @chainable - */ - map(route: string): T; - - /** - * Maps route patterns to modules. - * @param {string} route A route pattern. - * @param {string} moduleId The module id to map the route to. - * @chainable - */ - map(route: string, moduleId: string): T; - - /** - * Maps route patterns to modules. - * @param {RegExp} route A route pattern. - * @param {string} moduleId The module id to map the route to. - * @chainable - */ - map(route: RegExp, moduleId: string): T; - - /** - * Maps route patterns to modules. - * @param {string} route A route pattern. - * @param {RouteConfiguration} config The route's configuration. - * @chainable - */ - map(route: string, config: DurandalRouteConfiguration): T; - - /** - * Maps route patterns to modules. - * @method map - * @param {RegExp} route A route pattern. - * @param {RouteConfiguration} config The route's configuration. - * @chainable - */ - map(route: RegExp, config: DurandalRouteConfiguration): T; - - /** - * Maps route patterns to modules. - * @param {RouteConfiguration} config The route's configuration. - * @chainable - */ - map(config: DurandalRouteConfiguration): T; - - /** - * Maps route patterns to modules. - * @param {RouteConfiguration[]} configs An array of route configurations. - * @chainable - */ - map(configs: DurandalRouteConfiguration[]): T; - - /** - * Builds an observable array designed to bind a navigation UI to. The model will exist in the `navigationModel` property. - * @param {number} defaultOrder The default order to use for navigation visible routes that don't specify an order. The defualt is 100. - * @chainable - */ - buildNavigationModel(defaultOrder?: number): T; - - /** - * Configures the router to map unknown routes to modules at the same path. - * @chainable - */ - mapUnknownRoutes(): T; - - /** - * Configures the router use the specified module id for all unknown routes. - * @param {string} notFoundModuleId Represents the module id to route all unknown routes to. - * @param {string} [replaceRoute] Optionally provide a route to replace the url with. - * @chainable - */ - mapUnknownRoutes(notFoundModuleId: string, replaceRoute?: string): T; - - /** - * Configures how the router will handle unknown routes. - * @param {function} callback Called back with the route instruction containing the route info. The function can then modify the instruction by adding a moduleId and the router will take over from there. - * @chainable - */ - mapUnknownRoutes(callback: (instruction: DurandalRouteInstruction) => void): T; - - /** - * Configures how the router will handle unknown routes. - * @param {RouteConfiguration} config The route configuration to use for unknown routes. - * @chainable - */ - mapUnknownRoutes(config: DurandalRouteConfiguration): T; - - /** - * Resets the router by removing handlers, routes, event handlers and previously configured options. - * @chainable - */ - reset(): T; - - /** - * Makes all configured routes and/or module ids relative to a certain base url. - * @param {string} settings The value is used as the base for routes and module ids. - * @chainable - */ - makeRelative(settings: string): T; - - /** - * Makes all configured routes and/or module ids relative to a certain base url. - * @param {RelativeRouteSettings} settings If an object, you can specify `route` and `moduleId` separately. In place of specifying route, you can set `fromParent:true` to make routes automatically relative to the parent router's active route. - * @chainable - */ - makeRelative(settings: DurandalRelativeRouteSettings): T; - - /** - * Creates a child router. - * @returns {Router} The child router. - */ - createChildRouter(): T; - - /** - * Inspects routes and modules before activation. Can be used to protect access by cancelling navigation or redirecting. - * @param {object} instance The module instance that is about to be activated by the router. - * @param {object} instruction The route instruction. The instruction object has config, fragment, queryString, params and queryParams properties. - * @returns {Promise|Boolean|String} If a boolean, determines whether or not the route should activate or be cancelled. If a string, causes a redirect to the specified route. Can also be a promise for either of these value types. - */ - guardRoute?: (instance: Object, instruction: DurandalRouteInstruction) => any; -} - -interface DurandalRouter extends DurandalRouterBase { } - -interface DurandalRootRouter extends DurandalRouterBase { - /** - * Activates the router and the underlying history tracking mechanism. - * @returns {Promise} A promise that resolves when the router is ready. - */ - activate(options?: DurandalHistoryOptions): JQueryPromise; - - /** - * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. - */ - deactivate(): void; - - /** - * Installs the router's custom ko binding handler. - */ - install(): void; -} +// Type definitions for Durandal 2.1.0 +// Project: http://durandaljs.com +// Definitions by: Blue Spire +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * Durandal 2.1.0 Copyright (c) 2012 Blue Spire Consulting, Inc. All Rights Reserved. + * Available via the MIT license. + * see: http://durandaljs.com or https://github.com/BlueSpire/Durandal for details. + */ + +/// +/// + +/** + * The system module encapsulates the most basic features used by other modules. + * @requires require + * @requires jquery + */ +declare module 'durandal/system' { + var theModule: DurandalSystemModule; + export = theModule; +} + +interface DurandalSystemModule { + /** + * Durandal's version. + */ + version: string; + + /** + * A noop function. + */ + noop: Function; + + /** + * Gets the module id for the specified object. + * @param {object} obj The object whose module id you wish to determine. + * @returns {string} The module id. + */ + getModuleId(obj: any): string; + + /** + * Sets the module id for the specified object. + * @param {object} obj The object whose module id you wish to set. + * @param {string} id The id to set for the specified object. + */ + setModuleId(obj, id: string): void; + + /** + * Resolves the default object instance for a module. If the module is an object, the module is returned. If the module is a function, that function is called with `new` and it's result is returned. + * @param {object} module The module to use to get/create the default object for. + * @returns {object} The default object for the module. + */ + resolveObject(module: any): any; + + /** + * Gets/Sets whether or not Durandal is in debug mode. + * @param {boolean} [enable] Turns on/off debugging. + * @returns {boolean} Whether or not Durandal is current debugging. + */ + debug(enable?: boolean): boolean; + + /** + * Logs data to the console. Pass any number of parameters to be logged. Log output is not processed if the framework is not running in debug mode. + * @param {object} info* The objects to log. + */ + log(...msgs: any[]): void; + + /** + * Logs an error. + * @param {string} obj The error to report. + */ + error(error: string): void; + + /** + * Logs an error. + * @param {Error} obj The error to report. + */ + error(error: Error): void; + + /** + * Asserts a condition by throwing an error if the condition fails. + * @param {boolean} condition The condition to check. + * @param {string} message The message to report in the error if the condition check fails. + */ + assert(condition: boolean, message: string): void; + + /** + * Creates a deferred object which can be used to create a promise. Optionally pass a function action to perform which will be passed an object used in resolving the promise. + * @param {function} [action] The action to defer. You will be passed the deferred object as a paramter. + * @returns {JQueryDeferred} The deferred object. + */ + defer(action?: (dfd: JQueryDeferred) => void): JQueryDeferred; + + /** + * Creates a simple V4 UUID. This should not be used as a PK in your database. It can be used to generate internal, unique ids. For a more robust solution see [node-uuid](https://github.com/broofa/node-uuid). + * @returns {string} The guid. + */ + guid(): string; + + /** + * Uses require.js to obtain a module. This function returns a promise which resolves with the module instance. + * @param {string} moduleId The id of the module to load. + * @returns {JQueryPromise} A promise for the loaded module. + */ + acquire(moduleId: string): JQueryPromise; + + /** + * Uses require.js to obtain an array of modules. This function returns a promise which resolves with the modules instances in an array. + * @param {string[]} moduleIds The ids of the modules to load. + * @returns {JQueryPromise} A promise for the loaded module. + */ + acquire(modules: string[]): JQueryPromise; + + /** + * Uses require.js to obtain multiple modules. This function returns a promise which resolves with the module instances in an array. + * @param {string} moduleIds* The ids of the modules to load. + * @returns {JQueryPromise} A promise for the loaded module. + */ + acquire(...moduleIds: string[]): JQueryPromise; + + /** + * Extends the first object with the properties of the following objects. + * @param {object} obj The target object to extend. + * @param {object} extension* Uses to extend the target object. + */ + extend(obj: any, ...extensions: any[]): any; + + /** + * Uses a setTimeout to wait the specified milliseconds. + * @param {number} milliseconds The number of milliseconds to wait. + * @returns {JQueryPromise} + */ + wait(milliseconds: number): JQueryPromise; + + /** + * Gets all the owned keys of the specified object. + * @param {object} object The object whose owned keys should be returned. + * @returns {string[]} The keys. + */ + keys(obj: any): string[]; + + /** + * Determines if the specified object is an html element. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isElement(obj: any): boolean; + + /** + * Determines if the specified object is an array. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isArray(obj: any): boolean; + + /** + * Determines if the specified object is a boolean. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isObject(obj: any): boolean; + + /** + * Determines if the specified object is a promise. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isPromise(obj: any): boolean; + + /** + * Determines if the specified object is a function arguments object. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isArguments(obj: any): boolean; + + /** + * Determines if the specified object is a function. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isFunction(obj: any): boolean; + + /** + * Determines if the specified object is a string. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isString(obj: any): boolean; + + /** + * Determines if the specified object is a number. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isNumber(obj: any): boolean; + + /** + * Determines if the specified object is a date. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isDate(obj: any): boolean; + + /** + * Determines if the specified object is a boolean. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isBoolean(obj: any): boolean; +} + +/** + * The viewEngine module provides information to the viewLocator module which is used to locate the view's source file. The viewEngine also transforms a view id into a view instance. + * @requires system + * @requires jquery + */ +declare module 'durandal/viewEngine' { + var theModule: DurandalViewEngineModule; + export = theModule; +} + +interface DurandalViewEngineModule { + /** + * The file extension that view source files are expected to have. + * @default .html + */ + viewExtension: string; + + /** + * The name of the RequireJS loader plugin used by the viewLocator to obtain the view source. (Use requirejs to map the plugin's full path). + * @default text + */ + viewPlugin: string; + + /** + * Parameters passed to the RequireJS loader plugin used by the viewLocator to obtain the view source. + * @default The empty string by default. + */ + viewPluginParameters: string; + + /** + * Determines if the url is a url for a view, according to the view engine. + * @param {string} url The potential view url. + * @returns {boolean} True if the url is a view url, false otherwise. + */ + isViewUrl(url: string): boolean; + + /** + * Converts a view url into a view id. + * @param {string} url The url to convert. + * @returns {string} The view id. + */ + convertViewUrlToViewId(url: string): string; + + /** + * Converts a view id into a full RequireJS path. + * @param {string} viewId The view id to convert. + * @returns {string} The require path. + */ + convertViewIdToRequirePath(viewId: string): string; + + /** + * Parses the view engine recognized markup and returns DOM elements. + * @param {string} markup The markup to parse. + * @returns {HTMLElement[]} The elements. + */ + parseMarkup(markup: string): Node[]; + + /** + * Calls `parseMarkup` and then pipes the results through `ensureSingleElement`. + * @param {string} markup The markup to process. + * @returns {HTMLElement} The view. + */ + processMarkup(markup: string): HTMLElement; + + /** + * Converts an array of elements into a single element. White space and comments are removed. If a single element does not remain, then the elements are wrapped. + * @param {HTMLElement[]} allElements The elements. + * @returns {HTMLElement} A single element. + */ + ensureSingleElement(allElements: Node[]): HTMLElement; + + /** + * Gets the view associated with the id from the cache of parsed views. + * @param {string} id The view id to lookup in the cache. + * @return {DOMElement|null} The cached view or null if it's not in the cache. + */ + tryGetViewFromCache(id: string): HTMLElement; + + /** + * Puts the view associated with the id into the cache of parsed views. + * @param {string} id The view id whose view should be cached. + * @param {DOMElement} view The view to cache. + */ + putViewInCache(id:string, view:HTMLElement); + + /** + * Creates the view associated with the view id. + * @param {string} viewId The view id whose view should be created. + * @returns {JQueryPromise} A promise of the view. + */ + createView(viewId: string): JQueryPromise; + + /** + * Called when a view cannot be found to provide the opportunity to locate or generate a fallback view. Mainly used to ease development. + * @param {string} viewId The view id whose view should be created. + * @param {string} requirePath The require path that was attempted. + * @param {Error} requirePath The error that was returned from the attempt to locate the default view. + * @returns {Promise} A promise for the fallback view. + */ + createFallbackView(viewId: string, requirePath: string, err: Error): JQueryPromise; +} + +/** + * Durandal events originate from backbone.js but also combine some ideas from signals.js as well as some additional improvements. + * Events can be installed into any object and are installed into the `app` module by default for convenient app-wide eventing. + * @requires system + */ +declare module 'durandal/events' { + var theModule: DurandalEventModule; + export = theModule; +} + +/** + * The binder joins an object instance and a DOM element tree by applying databinding and/or invoking binding lifecycle callbacks (binding and bindingComplete). + * @requires system + * @requires knockout + */ +declare module 'durandal/binder' { + interface BindingInstruction { + applyBindings: boolean; + } + + /** + * Called before every binding operation. Does nothing by default. + * @param {object} data The data that is about to be bound. + * @param {DOMElement} view The view that is about to be bound. + * @param {object} instruction The object that carries the binding instructions. + */ + export var binding: (data: any, view: HTMLElement, instruction: BindingInstruction) => void; + + /** + * Called after every binding operation. Does nothing by default. + * @param {object} data The data that has just been bound. + * @param {DOMElement} view The view that has just been bound. + * @param {object} instruction The object that carries the binding instructions. + */ + export var bindingComplete: (data: any, view: HTMLElement, instruction: BindingInstruction) => void; + + /** + * Indicates whether or not the binding system should throw errors or not. + * @default false The binding system will not throw errors by default. Instead it will log them. + */ + export var throwOnErrors: boolean; + + /** + * Gets the binding instruction that was associated with a view when it was bound. + * @param {DOMElement} view The view that was previously bound. + * @returns {object} The object that carries the binding instructions. + */ + export function getBindingInstruction(view: HTMLElement): BindingInstruction; + + /** + * Binds the view, preserving the existing binding context. Optionally, a new context can be created, parented to the previous context. + * @param {KnockoutBindingContext} bindingContext The current binding context. + * @param {DOMElement} view The view to bind. + * @param {object} [obj] The data to bind to, causing the creation of a child binding context if present. + * @param {string} [dataAlias] An alias for $data if present. + */ + export function bindContext(bindingContext: KnockoutBindingContext, view: HTMLElement, obj?: any, dataAlias?: string): BindingInstruction; + + /** + * Binds the view, preserving the existing binding context. Optionally, a new context can be created, parented to the previous context. + * @param {object} obj The data to bind to. + * @param {DOMElement} view The view to bind. + */ + export function bind(obj: any, view: HTMLElement): BindingInstruction; +} + +/** + * The activator module encapsulates all logic related to screen/component activation. + * An activator is essentially an asynchronous state machine that understands a particular state transition protocol. + * The protocol ensures that the following series of events always occur: `canDeactivate` (previous state), `canActivate` (new state), `deactivate` (previous state), `activate` (new state). + * Each of the _can_ callbacks may return a boolean, affirmative value or promise for one of those. If either of the _can_ functions yields a false result, then activation halts. + * @requires system + * @requires knockout + */ +declare module 'durandal/activator' { + /** + * The default settings used by activators. + * @property {ActivatorSettings} defaults + */ + export var defaults: DurandalActivatorSettings; + + /** + * Creates a new activator. + * @method create + * @param {object} [initialActiveItem] The item which should be immediately activated upon creation of the ativator. + * @param {ActivatorSettings} [settings] Per activator overrides of the default activator settings. + * @returns {Activator} The created activator. + */ + export function create(initialActiveItem?: T, settings?: DurandalActivatorSettings): DurandalActivator; + + /** + * Determines whether or not the provided object is an activator or not. + * @method isActivator + * @param {object} object Any object you wish to verify as an activator or not. + * @returns {boolean} True if the object is an activator; false otherwise. + */ + export function isActivator(object: any): boolean; +} + +/** + * The viewLocator module collaborates with the viewEngine module to provide views (literally dom sub-trees) to other parts of the framework as needed. The primary consumer of the viewLocator is the composition module. + * @requires system + * @requires viewEngine + */ +declare module 'durandal/viewLocator' { + var theModule: DurandalViewLocatorModule; + export = theModule; +} + +interface DurandalViewLocatorModule { + /** + * Allows you to set up a convention for mapping module folders to view folders. It is a convenience method that customizes `convertModuleIdToViewId` and `translateViewIdToArea` under the covers. + * @param {string} [modulesPath] A string to match in the path and replace with the viewsPath. If not specified, the match is 'viewmodels'. + * @param {string} [viewsPath] The replacement for the modulesPath. If not specified, the replacement is 'views'. + * @param {string} [areasPath] Partial views are mapped to the "views" folder if not specified. Use this parameter to change their location. + */ + useConvention(modulesPath?: string, viewsPath?: string, areasPath?: string): void; + + /** + * Maps an object instance to a view instance. + * @param {object} obj The object to locate the view for. + * @param {string} [area] The area to translate the view to. + * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. + * @returns {Promise} A promise of the view. + */ + locateViewForObject(obj: any, area: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + + /** + * Converts a module id into a view id. By default the ids are the same. + * @param {string} moduleId The module id. + * @returns {string} The view id. + */ + convertModuleIdToViewId(moduleId: string): string; + + /** + * If no view id can be determined, this function is called to genreate one. By default it attempts to determine the object's type and use that. + * @param {object} obj The object to determine the fallback id for. + * @returns {string} The view id. + */ + determineFallbackViewId(obj: any): string; + + /** + * Takes a view id and translates it into a particular area. By default, no translation occurs. + * @param {string} viewId The view id. + * @param {string} area The area to translate the view to. + * @returns {string} The translated view id. + */ + translateViewIdToArea(viewId: string, area: string): string; + + /** + * Locates the specified view. + * @param {string|DOMElement} view A view. It will be immediately returned. + * @param {string} [area] The area to translate the view to. + * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. + * @returns {Promise} A promise of the view. + */ + locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + + /** + * Locates the specified view. + * @param {string|DOMElement} viewUrlOrId A view url or view id to locate. + * @param {string} [area] The area to translate the view to. + * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. + * @returns {Promise} A promise of the view. + */ + locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; +} + +/** + * The composition module encapsulates all functionality related to visual composition. + * @requires system + * @requires viewLocator + * @requires binder + * @requires viewEngine + * @requires activator + * @requires jquery + * @requires knockout + */ +declare module 'durandal/composition' { + interface CompositionTransation { + /** + * Registers a callback which will be invoked when the current composition transaction has completed. The transaction includes all parent and children compositions. + * @param {function} callback The callback to be invoked when composition is complete. + */ + complete(callback: Function): void; + } + + interface CompositionContext { + mode: string; + parent: HTMLElement; + activeView: HTMLElement; + triggerAttach(): void; + bindingContext?: KnockoutBindingContext; + cacheViews?: boolean; + viewElements?: HTMLElement[]; + model?: any; + view?: any; + area?: string; + preserveContext?: boolean; + activate?: boolean; + strategy?: (context: CompositionContext) => JQueryPromise; + composingNewView: boolean; + child: HTMLElement; + binding?: (child: HTMLElement, parent: HTMLElement, context: CompositionContext) => void; + attached?: (child: HTMLElement, parent: HTMLElement, context: CompositionContext) => void; + compositionComplete?: (child: HTMLElement, parent: HTMLElement, context: CompositionContext) => void; + transition?: string; + } + + /** + * Converts a transition name to its moduleId. + * @param {string} name The name of the transtion. + * @returns {string} The moduleId. + */ + export function convertTransitionToModuleId(name: string): string; + + /** + * The name of the transition to use in all compositions. + * @default null + */ + export var defaultTransitionName: string; + + /** + * Represents the currently executing composition transaction. + */ + export var current: CompositionTransation; + + /** + * Registers a binding handler that will be invoked when the current composition transaction is complete. + * @param {string} name The name of the binding handler. + * @param {object} [config] The binding handler instance. If none is provided, the name will be used to look up an existing handler which will then be converted to a composition handler. + * @param {function} [initOptionsFactory] If the registered binding needs to return options from its init call back to knockout, this function will server as a factory for those options. It will receive the same parameters that the init function does. + */ + export function addBindingHandler(name, config?: KnockoutBindingHandler, initOptionsFactory?: (element?: HTMLElement, valueAccessor?: any, allBindingsAccessor?: any, viewModel?: any, bindingContext?: KnockoutBindingContext) => any); + + /** + * Gets an object keyed with all the elements that are replacable parts, found within the supplied elements. The key will be the part name and the value will be the element itself. + * @param {DOMElement[]} elements The elements to search for parts. + * @returns {object} An object keyed by part. + */ + export function getParts(elements: HTMLElement[]): any; + + /** + * Gets an object keyed with all the elements that are replacable parts, found within the supplied element. The key will be the part name and the value will be the element itself. + * @param {DOMElement} element The element to search for parts. + * @returns {object} An object keyed by part. + */ + export function getParts(element: HTMLElement): any; + + /** + * Eecutes the default view location strategy. + * @param {object} context The composition context containing the model and possibly existing viewElements. + * @returns {promise} A promise for the view. + */ + export var defaultStrategy: (context: CompositionContext) => JQueryPromise; + + /** + * Initiates a composition. + * @param {DOMElement} element The DOMElement or knockout virtual element that serves as the parent for the composition. + * @param {object} settings The composition settings. + * @param {object} [bindingContext] The current binding context. + */ + export function compose(element: HTMLElement, settings: CompositionContext, bindingContext: KnockoutBindingContext): void; +} + +/** + * The app module controls app startup, plugin loading/configuration and root visual display. + * @requires system + * @requires viewEngine + * @requires composition + * @requires events + * @requires jquery + */ +declare module 'durandal/app' { + var theModule: DurandalAppModule; + export = theModule; +} + +/** + * The dialog module enables the display of message boxes, custom modal dialogs and other overlays or slide-out UI abstractions. Dialogs are constructed by the composition system which interacts with a user defined dialog context. The dialog module enforced the activator lifecycle. + * @requires system + * @requires app + * @requires composition + * @requires activator + * @requires viewEngine + * @requires jquery + * @requires knockout + */ +declare module 'plugins/dialog' { + import composition = require('durandal/composition'); + + /** + * Models a message box's message, title and options. + * @class + */ + class Box { + constructor(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object); + + /** + * Selects an option and closes the message box, returning the selected option through the dialog system's promise. + * @param {string} dialogResult The result to select. + */ + selectOption(dialogResult: string): void; + + /** + * Provides the view to the composition system. + * @returns {DOMElement} The view of the message box. + */ + getView(): HTMLElement; + + /** + * Configures a custom view to use when displaying message boxes. + * @method setViewUrl + * @param {string} viewUrl The view url relative to the base url which the view locator will use to find the message box's view. + */ + static setViewUrl(viewUrl: string): void; + + /** + * The title to be used for the message box if one is not provided. + * @default Application + * @static + */ + static defaultTitle: string; + + /** + * The options to display in the message box if none are specified. + * @default ['Ok'] + * @static + */ + static defaultOptions: string[]; + + /** + * Sets the classes and styles used throughout the message box markup. + * @method setDefaults + * @param {object} settings A settings object containing the following optional properties: buttonClass, primaryButtonClass, secondaryButtonClass, class, style. + */ + static setDefaults(settings: Object): void; + + /** + * The markup for the message box's view. + */ + static defaultViewMarkup: string; + } + + interface DialogContext { + /** + * In this function, you are expected to add a DOM element to the tree which will serve as the "host" for the modal's composed view. You must add a property called host to the modalWindow object which references the dom element. It is this host which is passed to the composition module. + * @param {Dialog} theDialog The dialog model. + */ + addHost(theDialog: Dialog); + + /** + * This function is expected to remove any DOM machinery associated with the specified dialog and do any other necessary cleanup. + * @param {Dialog} theDialog The dialog model. + */ + removeHost(theDialog: Dialog); + + /** + * This function is called after the modal is fully composed into the DOM, allowing your implementation to do any final modifications, such as positioning or animation. You can obtain the original dialog object by using `getDialog` on context.model. + * @param {DOMElement} child The dialog view. + * @param {DOMElement} parent The parent view. + * @param {object} context The composition context. + */ + compositionComplete(child: HTMLElement, parent: HTMLElement, context: composition.CompositionContext); + } + + interface Dialog { + owner: any; + context: DialogContext; + activator: DurandalActivator; + close(): JQueryPromise; + settings: composition.CompositionContext; + } + + /** + * The constructor function used to create message boxes. + */ + export var MessageBox: Box; + + /** + * The css zIndex that the last dialog was displayed at. + */ + export var currentZIndex: number; + + /** + * Gets the next css zIndex at which a dialog should be displayed. + * @returns {number} The next usable zIndex. + */ + export function getNextZIndex(): number; + + /** + * Determines whether or not there are any dialogs open. + * @returns {boolean} True if a dialog is open. false otherwise. + */ + export function isOpen(): boolean; + + /** + * Gets the dialog context by name or returns the default context if no name is specified. + * @param {string} [name] The name of the context to retrieve. + * @returns {DialogContext} True context. + */ + export function getContext(name: string): DialogContext; + + /** + * Adds (or replaces) a dialog context. + * @param {string} name The name of the context to add. + * @param {DialogContext} dialogContext The context to add. + */ + export function addContext(name: string, modalContext: DialogContext): void; + + /** + * Gets the dialog model that is associated with the specified object. + * @param {object} obj The object for whom to retrieve the dialog. + * @returns {Dialog} The dialog model. + */ + export function getDialog(obj: any): Dialog; + + /** + * Closes the dialog associated with the specified object. + * @param {object} obj The object whose dialog should be closed. + * @param {object} results* The results to return back to the dialog caller after closing. + */ + export function close(obj: any, ...results: any[]): void; + + /** + * Shows a dialog. + * @param {object|string} obj The object (or moduleId) to display as a dialog. + * @param {object} [activationData] The data that should be passed to the object upon activation. + * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. + * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. + */ + export function show(obj: any, activationData?: any, context?: string): JQueryPromise; + + /** + * Shows a message box. + * @param {string} message The message to display in the dialog. + * @param {string} [title] The title message. + * @param {string[]} [options] The options to provide to the user. + * @param {boolean} [autoclose] Automatically close the the message box when clicking outside? + * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. + * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. + */ + export function showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): JQueryPromise; + + /** + * Shows a message box. + * @param {string} message The message to display in the dialog. + * @param {string} [title] The title message. + * @param {DialogButton[]} [options] The options to provide to the user. + * @param {boolean} [autoclose] Automatically close the the message box when clicking outside? + * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. + * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. + */ + export function showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): JQueryPromise; + + /** + * Installs this module into Durandal; called by the framework. Adds `app.showDialog` and `app.showMessage` convenience methods. + * @param {object} [config] Add a `messageBox` property to supply a custom message box constructor. Add a `messageBoxView` property to supply custom view markup for the built-in message box. You can also use messageBoxViewUrl to specify the view url. + */ + export function install(config: Object): void; +} + +/** + * This module is based on Backbone's core history support. It abstracts away the low level details of working with browser history and url changes in order to provide a solid foundation for a router. + * @requires system + * @requires jquery + */ +declare module 'plugins/history' { + /** + * The setTimeout interval used when the browser does not support hash change events. + * @default 50 + */ + export var interval: number; + + /** + * Indicates whether or not the history module is actively tracking history. + */ + export var active: boolean; + + /** + * Gets the true hash value. Cannot use location.hash directly due to a bug in Firefox where location.hash will always be decoded. + * @param {string} [window] The optional window instance + * @returns {string} The hash. + */ + export function getHash(window?: Window): string; + + /** + * Get the cross-browser normalized URL fragment, either from the URL, the hash, or the override. + * @param {string} fragment The fragment. + * @param {boolean} forcePushState Should we force push state? + * @returns {string} he fragment. + */ + export function getFragment(fragment: string, forcePushState: boolean): string; + + /** + * Activate the hash change handling, returning `true` if the current URL matches an existing route, and `false` otherwise. + * @param {HistoryOptions} options. + * @returns {boolean|undefined} Returns true/false from loading the url unless the silent option was selected. + */ + export function activate(options: DurandalHistoryOptions): boolean; + + /** + * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. + */ + export function deactivate(): void; + + /** + * Checks the current URL to see if it has changed, and if it has, calls `loadUrl`, normalizing across the hidden iframe. + * @returns {boolean} Returns true/false from loading the url. + */ + export function checkUrl(): boolean; + + /** + * Attempts to load the current URL fragment. A pass-through to options.routeHandler. + * @returns {boolean} Returns true/false from the route handler. + */ + export function loadUrl(): boolean; + + /** + * Save a fragment into the hash history, or replace the URL state if the + * 'replace' option is passed. You are responsible for properly URL-encoding + * the fragment in advance. + * The options object can contain `trigger: false` if you wish to not have the + * route callback be fired, or `replace: true`, if + * you wish to modify the current URL without adding an entry to the history. + * @param {string} fragment The url fragment to navigate to. + * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. + * @return {boolean} Returns true/false from loading the url. + */ + export function navigate(fragment: string, trigger?: boolean): boolean; + + /** + * Save a fragment into the hash history, or replace the URL state if the + * 'replace' option is passed. You are responsible for properly URL-encoding + * the fragment in advance. + * The options object can contain `trigger: false` if you wish to not have the + * route callback be fired, or `replace: true`, if + * you wish to modify the current URL without adding an entry to the history. + * @param {string} fragment The url fragment to navigate to. + * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. + * @return {boolean} Returns true/false from loading the url. + */ + export function navigate(fragment: string, options: DurandalNavigationOptions): boolean; + + /** + * Navigates back in the browser history. + */ + export function navigateBack(): void; +} + +/** + * Enables common http request scenarios. + * @requires jquery + * @requires knockout + */ +declare module 'plugins/http' { + /** + * The name of the callback parameter to inject into jsonp requests by default. + * @default callback + */ + export var callbackParam: string; + + /** + * Converts the data to JSON. + * @param {object} data The data to convert to JSON. + * @return {string} JSON. + */ + export function toJSON(data: Object): string; + + /** + * Makes an HTTP GET request. + * @param {string} url The url to send the get request to. + * @param {object} [query] An optional key/value object to transform into query string parameters. + * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. + * @returns {Promise} A promise of the get response data. + */ + export function get(url: string, query?: Object, headers?: Object): JQueryPromise; + + /** + * Makes an JSONP request. + * @param {string} url The url to send the get request to. + * @param {object} [query] An optional key/value object to transform into query string parameters. + * @param {string} [callbackParam] The name of the callback parameter the api expects (overrides the default callbackParam). + * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. + * @returns {Promise} A promise of the response data. + */ + export function jsonp(url: string, query?: Object, callbackParam?: string, headers?: Object): JQueryPromise; + + /** + * Makes an HTTP POST request. + * @param {string} url The url to send the post request to. + * @param {object} data The data to post. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. + * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. + * @returns {Promise} A promise of the response data. + */ + export function post(url: string, data: Object, headers?: Object): JQueryPromise; + + /** + * Makes an HTTP PUT request. + * @method put + * @param {string} url The url to send the put request to. + * @param {object} data The data to put. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. + * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. + * @return {Promise} A promise of the response data. + */ + export function put(url: string, data: Object, headers?: Object): JQueryPromise; + + /** + * Makes an HTTP DELETE request. + * @method remove + * @param {string} url The url to send the delete request to. + * @param {object} [query] An optional key/value object to transform into query string parameters. + * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. + * @return {Promise} A promise of the get response data. + */ + export function remove(url: string, query?: Object, headers?: Object): JQueryPromise; +} + +/** + * Enables automatic observability of plain javascript object for ES5 compatible browsers. Also, converts promise properties into observables that are updated when the promise resolves. + * @requires system + * @requires binder + * @requires knockout + */ +declare module 'plugins/observable' { + function observable(obj: any, property: string): KnockoutObservable; + + module observable { + /** + * Converts an entire object into an observable object by re-writing its attributes using ES5 getters and setters. Attributes beginning with '_' or '$' are ignored. + * @param {object} obj The target object to convert. + */ + export function convertObject(obj: any): void; + + /** + * Converts a normal property into an observable property using ES5 getters and setters. + * @param {object} obj The target object on which the property to convert lives. + * @param {string} propertyName The name of the property to convert. + * @param {object} [original] The original value of the property. If not specified, it will be retrieved from the object. + * @returns {KnockoutObservable} The underlying observable. + */ + export function convertProperty(obj: any, propertyName: string, original?: any): KnockoutObservable; + + /** + * Defines a computed property using ES5 getters and setters. + * @param {object} obj The target object on which to create the property. + * @param {string} propertyName The name of the property to define. + * @param {function|object} evaluatorOrOptions The Knockout computed function or computed options object. + * @returns {KnockoutComputed} The underlying computed observable. + */ + export function defineProperty(obj: any, propertyName: string, evaluatorOrOptions?: KnockoutComputedDefine); + + /** + * Installs the plugin into the view model binder's `beforeBind` hook so that objects are automatically converted before being bound. + */ + export function install(config: Object): void; + } + + export = observable; +} + +/** + * Serializes and deserializes data to/from JSON. + * @requires system + */ +declare module 'plugins/serializer' { + interface SerializerOptions { + /** + * The default replacer function used during serialization. By default properties starting with '_' or '$' are removed from the serialized object. + * @param {string} key The object key to check. + * @param {object} value The object value to check. + * @returns {object} The value to serialize. + */ + replacer?: (key: string, value: any) => any; + + /** + * The amount of space to use for indentation when writing out JSON. + * @default undefined + */ + space: any; + } + + interface DeserializerOptions { + /** + * Gets the type id for an object instance, using the configured `typeAttribute`. + * @param {object} object The object to serialize. + * @returns {string} The type. + */ + getTypeId: (object: any) => string; + + /** + * Gets the constructor based on the type id. + * @param {string} typeId The type id. + * @returns {Function} The constructor. + */ + getConstructor: (typeId: string) => () => any; + + /** + * The default reviver function used during deserialization. By default is detects type properties on objects and uses them to re-construct the correct object using the provided constructor mapping. + * @param {string} key The attribute key. + * @param {object} value The object value associated with the key. + * @returns {object} The value. + */ + reviver: (key: string, value: any) => any; + } + + /** + * The name of the attribute that the serializer should use to identify an object's type. + * @default type + */ + export var typeAttribute: string; + + /** + * The amount of space to use for indentation when writing out JSON. + * @default undefined + */ + export var space: any; + + /** + * The default replacer function used during serialization. By default properties starting with '_' or '$' are removed from the serialized object. + * @param {string} key The object key to check. + * @param {object} value The object value to check. + * @returns {object} The value to serialize. + */ + export function replacer(key: string, value: any): any; + + /** + * Serializes the object. + * @param {object} object The object to serialize. + * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. + * @returns {string} The JSON string. + */ + export function serialize(object: any, settings?: string); + + /** + * Serializes the object. + * @param {object} object The object to serialize. + * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. + * @returns {string} The JSON string. + */ + export function serialize(object: any, settings?: number); + + /** + * Serializes the object. + * @param {object} object The object to serialize. + * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. + * @returns {string} The JSON string. + */ + export function serialize(object: any, settings?: SerializerOptions); + + /** + * Gets the type id for an object instance, using the configured `typeAttribute`. + * @param {object} object The object to serialize. + * @returns {string} The type. + */ + export function getTypeId(object: any): string; + + /** + * Maps type ids to object constructor functions. Keys are type ids and values are functions. + */ + export var typeMap: any; + + /** + * Adds a type id/constructor function mampping to the `typeMap`. + * @param {string} typeId The type id. + * @param {function} constructor The constructor. + */ + export function registerType(typeId: string, constructor: () => any); + + /** + * The default reviver function used during deserialization. By default is detects type properties on objects and uses them to re-construct the correct object using the provided constructor mapping. + * @param {string} key The attribute key. + * @param {object} value The object value associated with the key. + * @param {function} getTypeId A custom function used to get the type id from a value. + * @param {object} getConstructor A custom function used to get the constructor function associated with a type id. + * @returns {object} The value. + */ + export function reviver(key: string, value: any, getTypeId: (value: any) => string, getConstructor: (string) => () => any): any; + + /** + * Deserialize the JSON. + * @param {text} text The JSON string. + * @param {DeserializerOptions} settings Settings can specify a reviver, getTypeId function or getConstructor function. + * @returns {object} The deserialized object. + */ + export function deserialize(text: string, settings?: DeserializerOptions): T; + + /** + * Clone the object. + * @param {object} obj The object to clone. + * @param {object} [settings] Settings can specify any of the options allowed by the serialize or deserialize methods. + * @return {object} The new clone. + */ + export function clone(obj:T, settings?:Object): T; +} + +/** + * Layers the widget sugar on top of the composition system. + * @requires system + * @requires composition + * @requires jquery + * @requires knockout + */ +declare module 'plugins/widget' { + interface WidgetSettings { + kind: string; + model?: any; + view?: any; + } + + /** + * Creates a ko binding handler for the specified kind. + * @param {string} kind The kind to create a custom binding handler for. + */ + export function registerKind(kind: string); + + /** + * Maps views and module to the kind identifier if a non-standard pattern is desired. + * @param {string} kind The kind name. + * @param {string} [viewId] The unconventional view id to map the kind to. + * @param {string} [moduleId] The unconventional module id to map the kind to. + */ + export function mapKind(kind: string, viewId?: string, moduleId?: string); + + /** + * Maps a kind name to it's module id. First it looks up a custom mapped kind, then falls back to `convertKindToModulePath`. + * @param {string} kind The kind name. + * @returns {string} The module id. + */ + export function mapKindToModuleId(kind: string): string; + + /** + * Converts a kind name to it's module path. Used to conventionally map kinds who aren't explicitly mapped through `mapKind`. + * @param {string} kind The kind name. + * @returns {string} The module path. + */ + export function convertKindToModulePath(kind: string): string; + + /** + * Maps a kind name to it's view id. First it looks up a custom mapped kind, then falls back to `convertKindToViewPath`. + * @param {string} kind The kind name. + * @returns {string} The view id. + */ + export function mapKindToViewId(kind: string): string; + + /** + * Converts a kind name to it's view id. Used to conventionally map kinds who aren't explicitly mapped through `mapKind`. + * @param {string} kind The kind name. + * @returns {string} The view id. + */ + export function convertKindToViewPath(kind: string): string; + + /** + * Creates a widget. + * @param {DOMElement} element The DOMElement or knockout virtual element that serves as the target element for the widget. + * @param {object} settings The widget settings. + * @param {object} [bindingContext] The current binding context. + */ + export function create(element: HTMLElement, settings: WidgetSettings, bindingContext?: KnockoutBindingContext); +} + +/** + * Connects the history module's url and history tracking support to Durandal's activation and composition engine allowing you to easily build navigation-style applications. + * @requires system + * @requires app + * @requires activator + * @requires events + * @requires composition + * @requires history + * @requires knockout + * @requires jquery + */ +declare module 'plugins/router' { + var theModule: DurandalRootRouter; + export = theModule; +} + +interface DurandalEventSubscription { + /** + * Attaches a callback to the event subscription. + * @param {function} callback The callback function to invoke when the event is triggered. + * @param {object} [context] An object to use as `this` when invoking the `callback`. + * @chainable + */ + then(thenCallback: Function, context?: any): DurandalEventSubscription; + + /** + * Attaches a callback to the event subscription. + * @param {function} [callback] The callback function to invoke when the event is triggered. If `callback` is not provided, the previous callback will be re-activated. + * @param {object} [context] An object to use as `this` when invoking the `callback`. + * @chainable + */ + on(thenCallback: Function, context?: any): DurandalEventSubscription; + + /** + * Cancels the subscription. + * @chainable + */ + off(): DurandalEventSubscription; +} + +interface DurandalEventSupport { + /** + * Creates a subscription or registers a callback for the specified event. + * @param {string} events One or more events, separated by white space. + * @returns {Subscription} A subscription is returned. + */ + on(events: string): DurandalEventSubscription; + + /** + * Creates a subscription or registers a callback for the specified event. + * @param {string} events One or more events, separated by white space. + * @param {function} [callback] The callback function to invoke when the event is triggered. + * @param {object} [context] An object to use as `this` when invoking the `callback`. + * @returns {Events} The events object is returned for chaining. + */ + on(events: string, callback: Function, context?: any): T; + + /** + * Removes the callbacks for the specified events. + * @param {string} [events] One or more events, separated by white space to turn off. If no events are specified, then the callbacks will be removed. + * @param {function} [callback] The callback function to remove. If `callback` is not provided, all callbacks for the specified events will be removed. + * @param {object} [context] The object that was used as `this`. Callbacks with this context will be removed. + * @chainable + */ + off(events: string, callback: Function, context?: any): T; + + /** + * Triggers the specified events. + * @param {string} [events] One or more events, separated by white space to trigger. + * @chainable + */ + trigger(events: string, ...eventArgs: any[]): T; + + /** + * Creates a function that will trigger the specified events when called. Simplifies proxying jQuery (or other) events through to the events object. + * @param {string} events One or more events, separated by white space to trigger by invoking the returned function. + * @returns {function} Calling the function will invoke the previously specified events on the events object. + */ + proxy(events: string): Function; +} + +interface DurandalEventModule { + new (): DurandalEventSupport; + includeIn(targetObject: any): void; +} + +interface DialogButton { + text: string; + value: any; +} + +interface DurandalAppModule extends DurandalEventSupport { + /** + * The title of your application. + */ + title: string; + + /** + * Shows a dialog via the dialog plugin. + * @param {object|string} obj The object (or moduleId) to display as a dialog. + * @param {object} [activationData] The data that should be passed to the object upon activation. + * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. + * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. + */ + showDialog(obj: any, activationData?: any, context?: string): JQueryPromise; + + /** + * Closes the dialog associated with the specified object. via the dialog plugin. + * @param {object} obj The object whose dialog should be closed. + * @param {object} results* The results to return back to the dialog caller after closing. + */ + closeDialog(obj: any, ...results); + + /** + * Shows a message box via the dialog plugin. + * @param {string} message The message to display in the dialog. + * @param {string} [title] The title message. + * @param {string[]} [options] The options to provide to the user. + * @param {boolean} [autoclose] Automatically close the the message box when clicking outside? + * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. + * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. + */ + showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): JQueryPromise; + + /** + * Shows a message box. + * @param {string} message The message to display in the dialog. + * @param {string} [title] The title message. + * @param {DialogButton[]} [options] The options to provide to the user. + * @param {boolean} [autoclose] Automatically close the the message box when clicking outside? + * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. + * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. + */ + showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): JQueryPromise; + + /** + * Configures one or more plugins to be loaded and installed into the application. + * @method configurePlugins + * @param {object} config Keys are plugin names. Values can be truthy, to simply install the plugin, or a configuration object to pass to the plugin. + * @param {string} [baseUrl] The base url to load the plugins from. + */ + configurePlugins(config: Object, baseUrl?: string): void; + + /** + * Starts the application. + * @returns {promise} + */ + start(): JQueryPromise; + + /** + * Sets the root module/view for the application. + * @param {string} root The root view or module. + * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root. + * @param {string} [applicationHost] The application host element id. By default the id 'applicationHost' will be used. + */ + setRoot(root: any, transition?: string, applicationHost?: string): void; + + /** + * Sets the root module/view for the application. + * @param {string} root The root view or module. + * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root. + * @param {string} [applicationHost] The application host element. By default the id 'applicationHost' will be used. + */ + setRoot(root: any, transition?: string, applicationHost?: HTMLElement): void; +} + +interface DurandalActivatorSettings { + /** + * The default value passed to an object's deactivate function as its close parameter. + * @default true + */ + closeOnDeactivate: boolean; + + /** + * Lower-cased words which represent a truthy value. + * @default ['yes', 'ok', 'true'] + */ + affirmations: string[]; + + /** + * Interprets the response of a `canActivate` or `canDeactivate` call using the known affirmative values in the `affirmations` array. + * @param {object} value + * @returns {boolean} + */ + interpretResponse(value: any): boolean; + + /** + * Determines whether or not the current item and the new item are the same. + * @param {object} currentItem + * @param {object} newItem + * @param {object} currentActivationData + * @param {object} newActivationData + * @returns {boolean} + */ + areSameItem(currentItem: any, newItem: any, currentActivationData: any, newActivationData: any): boolean; + + /** + * Called immediately before the new item is activated. + * @param {object} newItem + */ + beforeActivate(newItem: any): any; + + /** + * Called immediately after the old item is deactivated. + * @param {object} oldItem The previous item. + * @param {boolean} close Whether or not the previous item was closed. + * @param {function} setter The activate item setter function. + */ + afterDeactivate(oldItem: any, close: boolean, setter: Function): void; +} + +interface DurandalActivator extends KnockoutComputed { + /** + * The settings for this activator. + */ + settings: DurandalActivatorSettings; + + /** + * An observable which indicates whether or not the activator is currently in the process of activating an instance. + * @returns {boolean} + */ + isActivating: KnockoutObservable; + + /** + * Determines whether or not the specified item can be deactivated. + * @param {object} item The item to check. + * @param {boolean} close Whether or not to check if close is possible. + * @returns {promise} + */ + canDeactivateItem(item: T, close: boolean): JQueryPromise; + + /** + * Deactivates the specified item. + * @param {object} item The item to deactivate. + * @param {boolean} close Whether or not to close the item. + * @returns {promise} + */ + deactivateItem(item: T, close: boolean): JQueryPromise; + + /** + * Determines whether or not the specified item can be activated. + * @param {object} item The item to check. + * @param {object} activationData Data associated with the activation. + * @returns {promise} + */ + canActivateItem(newItem: T, activationData?: any): JQueryPromise; + + /** + * Activates the specified item. + * @param {object} newItem The item to activate. + * @param {object} newActivationData Data associated with the activation. + * @returns {promise} + */ + activateItem(newItem: T, activationData?: any): JQueryPromise; + + /** + * Determines whether or not the activator, in its current state, can be activated. + * @returns {promise} + */ + canActivate(): JQueryPromise; + + /** + * Activates the activator, in its current state. + * @returns {promise} + */ + activate(): JQueryPromise; + + /** + * Determines whether or not the activator, in its current state, can be deactivated. + * @returns {promise} + */ + canDeactivate(close: boolean): JQueryPromise; + + /** + * Deactivates the activator, in its current state. + * @returns {promise} + */ + deactivate(close: boolean): JQueryPromise; + + /** + * Adds canActivate, activate, canDeactivate and deactivate functions to the provided model which pass through to the corresponding functions on the activator. + */ + includeIn(includeIn: any): void; + + /** + * Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them. + */ + forItems(items): DurandalActivator; +} + +interface DurandalHistoryOptions { + /** + * The function that will be called back when the fragment changes. + */ + routeHandler?: (fragment: string) => void; + + /** + * The url root used to extract the fragment when using push state. + */ + root?: string; + + /** + * Use hash change when present. + * @default true + */ + hashChange?: boolean; + + /** + * Use push state when present. + * @default false + */ + pushState?: boolean; + + /** + * Prevents loading of the current url when activating history. + * @default false + */ + silent?: boolean; + + /** + * Override default history init behavior by navigating directly to this route. + */ + startRoute?: string; +} + +interface DurandalNavigationOptions { + trigger: boolean; + replace: boolean; +} + +interface DurandalRouteConfiguration { + title?: any; + moduleId?: string; + hash?: string; + /** string or string[] */ + route?: any; + routePattern?: RegExp; + isActive?: KnockoutComputed; + nav?: any; + hasChildRoutes?: boolean; + viewUrl?:string; +} + +interface DurandalRouteInstruction { + fragment: string; + queryString: string; + config: DurandalRouteConfiguration; + params: any[]; + queryParams: Object; +} + +interface DurandalRelativeRouteSettings { + moduleId?: string; + route?: string; + fromParent?: boolean; +} + +interface DurandalRouterBase extends DurandalEventSupport { + /** + * The route handlers that are registered. Each handler consists of a `routePattern` and a `callback`. + */ + handlers: { routePattern: RegExp; callback: (fragment: string) => void; }[]; + + /** + * The route configs that are registered. + */ + routes: DurandalRouteConfiguration[]; + + /** + * The active item/screen based on the current navigation state. + */ + activeItem: DurandalActivator; + + /** + * The route configurations that have been designated as displayable in a nav ui (nav:true). + */ + navigationModel: KnockoutObservableArray; + + /** + * Indicates that the router (or a child router) is currently in the process of navigating. + */ + isNavigating: KnockoutComputed; + + /** + * An observable surfacing the active routing instruction that is currently being processed or has recently finished processing. + * The instruction object has `config`, `fragment`, `queryString`, `params` and `queryParams` properties. + */ + activeInstruction: KnockoutObservable; + + /** + * Parses a query string into an object. + * @param {string} queryString The query string to parse. + * @returns {object} An object keyed according to the query string parameters. + */ + parseQueryString(queryString: string): Object; + + /** + * Add a route to be tested when the url fragment changes. + * @param {RegEx} routePattern The route pattern to test against. + * @param {function} callback The callback to execute when the route pattern is matched. + */ + route(routePattern: RegExp, callback: (fragment: string) => void): void; + + /** + * Attempt to load the specified URL fragment. If a route succeeds with a match, returns `true`. If no defined routes matches the fragment, returns `false`. + * @param {string} fragment The URL fragment to find a match for. + * @returns {boolean} True if a match was found, false otherwise. + */ + loadUrl(fragment: string): boolean; + + /** + * Updates the document title based on the activated module instance, the routing instruction and the app.title. + * @param {object} instance The activated module. + * @param {object} instruction The routing instruction associated with the action. It has a `config` property that references the original route mapping config. + */ + updateDocumentTitle(instance: Object, instruction: DurandalRouteInstruction): void; + + /** + * Save a fragment into the hash history, or replace the URL state if the + * 'replace' option is passed. You are responsible for properly URL-encoding + * the fragment in advance. + * The options object can contain `trigger: false` if you wish to not have the + * route callback be fired, or `replace: true`, if + * you wish to modify the current URL without adding an entry to the history. + * @param {string} fragment The url fragment to navigate to. + * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. + * @return {boolean} Returns true/false from loading the url. + */ + navigate(fragment: string, trigger?: boolean): boolean; + + /** + * Save a fragment into the hash history, or replace the URL state if the + * 'replace' option is passed. You are responsible for properly URL-encoding + * the fragment in advance. + * The options object can contain `trigger: false` if you wish to not have the + * route callback be fired, or `replace: true`, if + * you wish to modify the current URL without adding an entry to the history. + * @param {string} fragment The url fragment to navigate to. + * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. + * @return {boolean} Returns true/false from loading the url. + */ + navigate(fragment: string, options: DurandalNavigationOptions): boolean; + + /** + * Navigates back in the browser history. + */ + navigateBack(): void; + + /** + * Converts a route to a hash suitable for binding to a link's href. + * @param {string} route + * @returns {string} The hash. + */ + convertRouteToHash(route: string): string; + + /** + * Converts a route to a module id. This is only called if no module id is supplied as part of the route mapping. + * @param {string} route + * @returns {string} The module id. + */ + convertRouteToModuleId(route: string): string; + + /** + * Converts a route to a displayable title. This is only called if no title is specified as part of the route mapping. + * @method convertRouteToTitle + * @param {string} route + * @returns {string} The title. + */ + convertRouteToTitle(route: string): string; + + /** + * Maps route patterns to modules. + * @param {string} route A route. + * @chainable + */ + map(route: string): T; + + /** + * Maps route patterns to modules. + * @param {string} route A route pattern. + * @param {string} moduleId The module id to map the route to. + * @chainable + */ + map(route: string, moduleId: string): T; + + /** + * Maps route patterns to modules. + * @param {RegExp} route A route pattern. + * @param {string} moduleId The module id to map the route to. + * @chainable + */ + map(route: RegExp, moduleId: string): T; + + /** + * Maps route patterns to modules. + * @param {string} route A route pattern. + * @param {RouteConfiguration} config The route's configuration. + * @chainable + */ + map(route: string, config: DurandalRouteConfiguration): T; + + /** + * Maps route patterns to modules. + * @method map + * @param {RegExp} route A route pattern. + * @param {RouteConfiguration} config The route's configuration. + * @chainable + */ + map(route: RegExp, config: DurandalRouteConfiguration): T; + + /** + * Maps route patterns to modules. + * @param {RouteConfiguration} config The route's configuration. + * @chainable + */ + map(config: DurandalRouteConfiguration): T; + + /** + * Maps route patterns to modules. + * @param {RouteConfiguration[]} configs An array of route configurations. + * @chainable + */ + map(configs: DurandalRouteConfiguration[]): T; + + /** + * Builds an observable array designed to bind a navigation UI to. The model will exist in the `navigationModel` property. + * @param {number} defaultOrder The default order to use for navigation visible routes that don't specify an order. The defualt is 100. + * @chainable + */ + buildNavigationModel(defaultOrder?: number): T; + + /** + * Configures the router to map unknown routes to modules at the same path. + * @chainable + */ + mapUnknownRoutes(): T; + + /** + * Configures the router use the specified module id for all unknown routes. + * @param {string} notFoundModuleId Represents the module id to route all unknown routes to. + * @param {string} [replaceRoute] Optionally provide a route to replace the url with. + * @chainable + */ + mapUnknownRoutes(notFoundModuleId: string, replaceRoute?: string): T; + + /** + * Configures how the router will handle unknown routes. + * @param {function} callback Called back with the route instruction containing the route info. The function can then modify the instruction by adding a moduleId and the router will take over from there. + * @chainable + */ + mapUnknownRoutes(callback: (instruction: DurandalRouteInstruction) => void): T; + + /** + * Configures how the router will handle unknown routes. + * @param {RouteConfiguration} config The route configuration to use for unknown routes. + * @chainable + */ + mapUnknownRoutes(config: DurandalRouteConfiguration): T; + + /** + * Resets the router by removing handlers, routes, event handlers and previously configured options. + * @chainable + */ + reset(): T; + + /** + * Makes all configured routes and/or module ids relative to a certain base url. + * @param {string} settings The value is used as the base for routes and module ids. + * @chainable + */ + makeRelative(settings: string): T; + + /** + * Makes all configured routes and/or module ids relative to a certain base url. + * @param {RelativeRouteSettings} settings If an object, you can specify `route` and `moduleId` separately. In place of specifying route, you can set `fromParent:true` to make routes automatically relative to the parent router's active route. + * @chainable + */ + makeRelative(settings: DurandalRelativeRouteSettings): T; + + /** + * Creates a child router. + * @returns {Router} The child router. + */ + createChildRouter(): T; + + /** + * Inspects routes and modules before activation. Can be used to protect access by cancelling navigation or redirecting. + * @param {object} instance The module instance that is about to be activated by the router. + * @param {object} instruction The route instruction. The instruction object has config, fragment, queryString, params and queryParams properties. + * @returns {Promise|Boolean|String} If a boolean, determines whether or not the route should activate or be cancelled. If a string, causes a redirect to the specified route. Can also be a promise for either of these value types. + */ + guardRoute?: (instance: Object, instruction: DurandalRouteInstruction) => any; +} + +interface DurandalRouter extends DurandalRouterBase { } + +interface DurandalRootRouter extends DurandalRouterBase { + /** + * Makes the RegExp generated for routes case sensitive, rather than the default of case insensitive. + */ + makeRoutesCaseSensitive(): void; + + /** + * Activates the router and the underlying history tracking mechanism. + * @returns {Promise} A promise that resolves when the router is ready. + */ + activate(options?: DurandalHistoryOptions): JQueryPromise; + + /** + * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. + */ + deactivate(): void; + + /** + * Installs the router's custom ko binding handler. + */ + install(): void; +} \ No newline at end of file diff --git a/flight/flight-tests.ts b/flight/flight-tests.ts index 1bfe68d3a9..9c66fa8b49 100644 --- a/flight/flight-tests.ts +++ b/flight/flight-tests.ts @@ -4,8 +4,12 @@ declare var els: Element[]; declare var mixinFn: Function; function TestComponent() { - var self: Flight.Component = this; - + var self: Flight.Component = this; + + self.attributes({ + fooSelector: '.bar' + }); + self.defaultAttrs({ fooSelector: '.bar' }); @@ -14,7 +18,7 @@ function TestComponent() { var el: HTMLElement = data.el; self.select('fooSelector').addClass('bar'); }; - + self.around('initialize', function () { }); self.before('initialize', function () { }); self.after("initialize", function () { diff --git a/flight/flight.d.ts b/flight/flight.d.ts index 19c8528df2..3a831f1d9f 100644 --- a/flight/flight.d.ts +++ b/flight/flight.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Flight 1.1.1 +// Type definitions for Flight 1.1.4 // Project: http://flightjs.github.com/flight/ // Definitions by: Jonathan Hedrén // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -9,10 +9,25 @@ declare module Flight { export interface Base { + /** + * Most Components and Mixins need to define attributes. In Flight, + * default values are assigned by passing an object to the attributes + * function. + * + * NOTE: this.attributes replaces the now deprecated this.defaultAttrs. + * However, for backwards compatibility, if you are using this.defaultAttrs + * then all the old attribute behavior remains in place. + */ + attributes(obj: Object): void; + /** * Most Components and Mixins need to define attributes. In Flight, * default values are assigned by passing an object to the defaultAttrs * function. + * + * NOTE: this.attributes replaces the now deprecated this.defaultAttrs. + * However, for backwards compatibility, if you are using this.defaultAttrs + * then all the old attribute behavior remains in place. */ defaultAttrs(obj: Object): void; @@ -181,7 +196,6 @@ declare module Flight { $node: JQuery; } - export interface AdviceStatic { withAdvice(): Function; } diff --git a/fs-extra/fs-extra.d.ts b/fs-extra/fs-extra.d.ts index 75f6c71a03..3d1af12ac3 100644 --- a/fs-extra/fs-extra.d.ts +++ b/fs-extra/fs-extra.d.ts @@ -1,4 +1,4 @@ -// Type definitions for aws-sdk +// Type definitions for fs-extra // Project: https://github.com/jprichardson/node-fs-extra // Definitions by: midknight41 // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/google.visualization/google.visualization-tests.ts b/google.visualization/google.visualization-tests.ts index 0f00828168..76dbd40a8a 100644 --- a/google.visualization/google.visualization-tests.ts +++ b/google.visualization/google.visualization-tests.ts @@ -37,5 +37,309 @@ function test_dataTableAddRow() { dataTable.addRow(['row3', 0]); } +function test_geoChart() { + var data = google.visualization.arrayToDataTable([ + ['Country', 'Population', 'Area Percentage'], + ['France', 65700000, 50], + ['Germany', 81890000, 27], + ['Poland', 38540000, 23], + ]); + var options = { + sizeAxis: { minValue: 0, maxValue: 100 }, + region: '155', // Western Europe + displayMode: 'markers', + colorAxis: {colors: ['#e7711c', '#4374e0']} // orange to blue + }; + var chart = new google.visualization.GeoChart(document.getElementById('chart_div')); + chart.draw(data, options); +} + +function test_scatterChart() { + var data = google.visualization.arrayToDataTable([ + ['Age', 'Weight'], + [ 8, 12], + [ 4, 5.5], + [ 11, 14], + [ 4, 5], + [ 3, 3.5], + [ 6.5, 7] + ]); + + var options = { + title: 'Age vs. Weight comparison', + hAxis: {title: 'Age', minValue: 0, maxValue: 15}, + vAxis: {title: 'Weight', minValue: 0, maxValue: 15}, + legend: 'none' + }; + + var chart = new google.visualization.ScatterChart(document.getElementById('chart_div')); + chart.draw(data, options); +} + +function test_barChart() { + var data = google.visualization.arrayToDataTable([ + ["Element", "Density", { role: "style" } ], + ["Copper", 8.94, "#b87333"], + ["Silver", 10.49, "silver"], + ["Gold", 19.30, "gold"], + ["Platinum", 21.45, "color: #e5e4e2"], + ]); + + var view = new google.visualization.DataView(data); + view.setColumns([0, 1, + { calc: "stringify", + sourceColumn: 1, + type: "string", + role: "annotation" }, + 2]); + + var options = { + title: "Density of Precious Metals, in g/cm^3", + width: 600, + height: 400, + bar: {groupWidth: "95%"}, + legend: { position: "none" } + }; + var chart = new google.visualization.BarChart(document.getElementById("barchart_values")); + chart.draw(view, options); +} + +function test_histogram() { + var data = google.visualization.arrayToDataTable([ + ['Dinosaur', 'Length'], + ['Acrocanthosaurus (top-spined lizard)', 12.2], + ['Albertosaurus (Alberta lizard)', 9.1], + ['Allosaurus (other lizard)', 12.2], + ['Apatosaurus (deceptive lizard)', 22.9], + ['Archaeopteryx (ancient wing)', 0.9], + ['Argentinosaurus (Argentina lizard)', 36.6], + ['Baryonyx (heavy claws)', 9.1], + ['Brachiosaurus (arm lizard)', 30.5], + ['Ceratosaurus (horned lizard)', 6.1], + ['Coelophysis (hollow form)', 2.7], + ['Compsognathus (elegant jaw)', 0.9], + ['Deinonychus (terrible claw)', 2.7], + ['Diplodocus (double beam)', 27.1], + ['Dromicelomimus (emu mimic)', 3.4], + ['Gallimimus (fowl mimic)', 5.5], + ['Mamenchisaurus (Mamenchi lizard)', 21.0], + ['Megalosaurus (big lizard)', 7.9], + ['Microvenator (small hunter)', 1.2], + ['Ornithomimus (bird mimic)', 4.6], + ['Oviraptor (egg robber)', 1.5], + ['Plateosaurus (flat lizard)', 7.9], + ['Sauronithoides (narrow-clawed lizard)', 2.0], + ['Seismosaurus (tremor lizard)', 45.7], + ['Spinosaurus (spiny lizard)', 12.2], + ['Supersaurus (super lizard)', 30.5], + ['Tyrannosaurus (tyrant lizard)', 15.2], + ['Ultrasaurus (ultra lizard)', 30.5], + ['Velociraptor (swift robber)', 1.8]]); + + var options = { + title: 'Lengths of dinosaurs, in meters', + legend: { position: 'none' } + }; + + var chart = new google.visualization.Histogram(document.getElementById('chart_div')); + chart.draw(data, options); +} + +function test_areaChart() { + var data = google.visualization.arrayToDataTable([ + ['Year', 'Sales', 'Expenses'], + ['2013', 1000, 400], + ['2014', 1170, 460], + ['2015', 660, 1120], + ['2016', 1030, 540] + ]); + + var options = { + title: 'Company Performance', + hAxis: {title: 'Year', titleTextStyle: {color: '#333'}}, + vAxis: {minValue: 0} + }; + + var chart = new google.visualization.AreaChart(document.getElementById('chart_div')); + chart.draw(data, options); +} + +function test_steppedAreaChart() { + var data = google.visualization.arrayToDataTable([ + ['Director (Year)', 'Rotten Tomatoes', 'IMDB'], + ['Alfred Hitchcock (1935)', 8.4, 7.9], + ['Ralph Thomas (1959)', 6.9, 6.5], + ['Don Sharp (1978)', 6.5, 6.4], + ['James Hawes (2008)', 4.4, 6.2] + ]); + + var options = { + title: 'The decline of \'The 39 Steps\'', + vAxis: {title: 'Accumulated Rating'}, + isStacked: true + }; + + var chart = new google.visualization.SteppedAreaChart(document.getElementById('chart_div')); + chart.draw(data, options); +} + +function test_lineChart() { + var data = google.visualization.arrayToDataTable([ + ['Year', 'Sales', 'Expenses'], + ['2004', 1000, 400], + ['2005', 1170, 460], + ['2006', 660, 1120], + ['2007', 1030, 540] + ]); + + var options = { + title: 'Company Performance' + }; + + var chart = new google.visualization.LineChart(document.getElementById('chart_div')); + chart.draw(data, options); +} + +function test_pieChart() { + var data = google.visualization.arrayToDataTable([ + ['Task', 'Hours per Day'], + ['Work', 11], + ['Eat', 2], + ['Commute', 2], + ['Watch TV', 2], + ['Sleep', 7] + ]); + + var options = { + title: 'My Daily Activities' + }; + + var chart = new google.visualization.PieChart(document.getElementById('piechart')); + chart.draw(data, options); +} + +function test_bubbleChart() { + var data = google.visualization.arrayToDataTable([ + ['ID', 'Life Expectancy', 'Fertility Rate', 'Region', 'Population'], + ['CAN', 80.66, 1.67, 'North America', 33739900], + ['DEU', 79.84, 1.36, 'Europe', 81902307], + ['DNK', 78.6, 1.84, 'Europe', 5523095], + ['EGY', 72.73, 2.78, 'Middle East', 79716203], + ['GBR', 80.05, 2, 'Europe', 61801570], + ['IRN', 72.49, 1.7, 'Middle East', 73137148], + ['IRQ', 68.09, 4.77, 'Middle East', 31090763], + ['ISR', 81.55, 2.96, 'Middle East', 7485600], + ['RUS', 68.6, 1.54, 'Europe', 141850000], + ['USA', 78.09, 2.05, 'North America', 307007000] + ]); + + var options = { + title: 'Correlation between life expectancy, fertility rate and population of some world countries (2010)', + hAxis: {title: 'Life Expectancy'}, + vAxis: {title: 'Fertility Rate'}, + bubble: {textStyle: {fontSize: 11}} + }; + + var chart = new google.visualization.BubbleChart(document.getElementById('chart_div')); + chart.draw(data, options); +} + +function test_treemap() { + // Create and populate the data table. + var data = google.visualization.arrayToDataTable([ + ['Location', 'Parent', 'Market trade volume (size)', 'Market increase/decrease (color)'], + ['Global', null, 0, 0], + ['America', 'Global', 0, 0], + ['Europe', 'Global', 0, 0], + ['Asia', 'Global', 0, 0], + ['Australia', 'Global', 0, 0], + ['Africa', 'Global', 0, 0], + ['Brazil', 'America', 11, 10], + ['USA', 'America', 52, 31], + ['Mexico', 'America', 24, 12], + ['Canada', 'America', 16, -23], + ['France', 'Europe', 42, -11], + ['Germany', 'Europe', 31, -2], + ['Sweden', 'Europe', 22, -13], + ['Italy', 'Europe', 17, 4], + ['UK', 'Europe', 21, -5], + ['China', 'Asia', 36, 4], + ['Japan', 'Asia', 20, -12], + ['India', 'Asia', 40, 63], + ['Laos', 'Asia', 4, 34], + ['Mongolia', 'Asia', 1, -5], + ['Israel', 'Asia', 12, 24], + ['Iran', 'Asia', 18, 13], + ['Pakistan', 'Asia', 11, -52], + ['Egypt', 'Africa', 21, 0], + ['S. Africa', 'Africa', 30, 43], + ['Sudan', 'Africa', 12, 2], + ['Congo', 'Africa', 10, 12], + ['Zaire', 'Africa', 8, 10] + ]); + + // Create and draw the visualization. + var tree = new google.visualization.TreeMap(document.getElementById('chart_div')); + tree.draw(data, { + minColor: '#f00', + midColor: '#ddd', + maxColor: '#0d0', + headerHeight: 15, + fontColor: 'black', + showScale: true}); +} + +function test_table() { + var data = new google.visualization.DataTable(); + data.addColumn('string', 'Name'); + data.addColumn('number', 'Salary'); + data.addColumn('boolean', 'Full Time Employee'); + data.addRows([ + ['Mike', {v: 10000, f: '$10,000'}, true], + ['Jim', {v:8000, f: '$8,000'}, false], + ['Alice', {v: 12500, f: '$12,500'}, true], + ['Bob', {v: 7000, f: '$7,000'}, true] + ]); + + var table = new google.visualization.Table(document.getElementById('table_div')); + table.draw(data, {showRowNumber: true}); +} + +function test_timeline() { + var container = document.getElementById('example1'); + + var chart = new google.visualization.Timeline(container); + + var dataTable = new google.visualization.DataTable(); + + dataTable.addColumn({ type: 'string', id: 'President' }); + dataTable.addColumn({ type: 'date', id: 'Start' }); + dataTable.addColumn({ type: 'date', id: 'End' }); + + dataTable.addRows([ + [ 'Washington', new Date(1789, 3, 29), new Date(1797, 2, 3) ], + [ 'Adams', new Date(1797, 2, 3), new Date(1801, 2, 3) ], + [ 'Jefferson', new Date(1801, 2, 3), new Date(1809, 2, 3) ]]); + + chart.draw(dataTable); +} + +function test_candlestickChart() { + var data = google.visualization.arrayToDataTable([ + ['Mon', 20, 28, 38, 45], + ['Tue', 31, 38, 55, 66], + ['Wed', 50, 55, 77, 80], + ['Thu', 77, 77, 66, 50], + ['Fri', 68, 66, 22, 15] + // Treat first row as data as well. + ], true); + + var options = { + legend:'none' + }; + + var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div')); + chart.draw(data, options); +} \ No newline at end of file diff --git a/google.visualization/google.visualization.d.ts b/google.visualization/google.visualization.d.ts index 553c8e6549..62b2a72d15 100644 --- a/google.visualization/google.visualization.d.ts +++ b/google.visualization/google.visualization.d.ts @@ -130,7 +130,7 @@ declare module google { maxValue?: any; } - function arrayToDataTable(data: any[]): DataTable; + function arrayToDataTable(data: any[], firstRowIsData?: boolean): DataTable; //#endregion //#region DataView @@ -139,27 +139,21 @@ declare module google { export class DataView { constructor(data: DataTable); constructor(data: DataView); - setColumns(columnIndexes: number[]): void; + setColumns(columnIndexes: any[]): void; } //#endregion //#region GeoChart //https://google-developers.appspot.com/chart/interactive/docs/gallery/geochart - export class GeoChart { - constructor(element: Element); - - // https://developers.google.com/chart/interactive/docs/gallery/geochart?hl=fr&csw=1#Methods + export class GeoChart extends ChartBase { draw(data: DataTable, options: GeoChartOptions): void; - getSelection(): GeoChartSelection[]; - setSelection(selection: VisualizationSelectionArray[]): void; - clearChart(): void; } // https://developers.google.com/chart/interactive/docs/gallery/geochart?hl=fr&csw=1#Configuration_Options export interface GeoChartOptions { backgroundColor?: any; - colorAxis?: GeoChartColorAxis; + colorAxis?: ChartColorAxis; datalessRegionColor?: string; displayMode?: string; enableRegionInteractivity?: boolean; @@ -180,12 +174,6 @@ declare module google { minSize?: number; minValue?: number; } - export interface GeoChartColorAxis extends GeoChartAxis { - minValue?: number; - maxValue?: number; - values?: number[]; - colors?: string[]; - } export interface GeoChartTextStyle { color?: string; fontName?: string; @@ -215,6 +203,67 @@ declare module google { //#endregion //#region Common + export interface ChartAnnotations { + boxStyle?: ChartBoxStyle; + textStyle?: ChartTextStyle; + } + + export interface ChartBoxStyle { + stroke?: string; + strokeWidth?: number; + rx?: number; + ry?: number; + gradient?: { + color1: string; + color2: string; + x1: string; + y1: string; + x2: string; + y2: string; + useObjectBoundingBoxUnits?: boolean; + } + } + + export interface ChartTextStyle { + fontName?: string; + fontSize?: number; + bold?: boolean; + italic?: boolean; + color?: string; + auraColor?: string; + opacity?: number; + } + + export interface ChartCrosshair { + color?: string; + focused?: { + color?: string; + opacity?: number; + } + opacity?: number; + orientation?: string; + selected?: { + color?: string; + opacity?: number; + } + trigger?: string; + } + + export interface ChartExplorer { + actions?: string[]; + axis?: string; + keepInBounds?: boolean; + maxZoomIn?: number; + maxZoomOut?: number; + zoomDelta?: number; + } + + export interface ChartStroke { + stroke: string; + strokeWidth: number; + fill: string; + } + export interface ChartArea { top: any; left: any; @@ -222,14 +271,6 @@ declare module google { height: any; } - export interface ChartTextStyle { - color?: string; - fontName?: string; - fontSize?: number; - bold?: boolean; - italic?: boolean; - } - export interface ChartLegend { alignment?: string; maxLines?: number; @@ -298,6 +339,14 @@ declare module google { height: number; } + export interface ChartColorAxis { + minValue?: number; + maxValue?: number; + values?: number[]; + colors?: string[]; + legend?: ChartLegend; + } + export interface ChartLayoutInterface { getBoundingBox(id: string): ChartBoundingBox; getChartAreaBoundingBox(): ChartBoundingBox; @@ -307,34 +356,91 @@ declare module google { getYLocation(position: number, axisIndex?: number): number; } + export interface GroupWidth { + groupWidth: any; // number | string + } + export interface VisualizationSelectionArray { column?: number; row?: number; } + class ChartBase { + constructor(element: Element); + getSelection(): any[]; + setSelection(selection: any[]): void; + clearChart(): void; + getImageURI(): string; + } + + class CoreChartBase extends ChartBase { + getBoundingBox(id: string): ChartBoundingBox; + getChartAreaBoundingBox(): ChartBoundingBox; + getChartLayoutInterface(): ChartLayoutInterface; + getHAxisValue(position: number, axisIndex?: number): number; + getVAxisValue(position: number, axisIndex?: number): number; + getXLocation(position: number, axisIndex?: number): number; + getYLocation(position: number, axisIndex?: number): number; + } + + //#endregion + //#region ScatterChart + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/scatterchart + export class ScatterChart extends CoreChartBase { + draw(data: DataTable, options?: ScatterChartOptions): void; + draw(data: DataView, options?: ScatterChartOptions): void; + } + + export interface ScatterChartOptions { + aggregationTarget?: string; + animation?: TransitionAnimation; + annotations?: ChartAnnotations; + axisTitlesPosition?: string; // in, out, none + backgroundColor?: any; + chartArea?: ChartArea; + colors?: string[]; + crosshair?: ChartCrosshair; + curveType?: string; + dataOpacity?: number; + enableInteractivity?: boolean; + explorer?: ChartExplorer; + fontSize?: number; + fontName?: string; + forceIFrame?: boolean; + hAxis?: ChartAxis; + height?: number; + legend?: ChartLegend; + lineWidth?: number; + pointSize?: number; + selectionMode?: string; + series?: any; + theme?: string; + title?: string; + titlePosition?: string; + titleTextStyle?: ChartTextStyle; + tooltip?: ChartTooltip; + vAxis?: ChartAxis; + width?: number; + } + //#endregion //#region ColumnChart // https://google-developers.appspot.com/chart/interactive/docs/gallery/columnchart - export class ColumnChart { - constructor(element: Element); - - // https://google-developers.appspot.com/chart/interactive/docs/gallery/columnchart#Methods - draw(data: DataTable, options?: ColumnChartOptions): void; - draw(data: DataView, options?: ColumnChartOptions): void; - getChartLayoutInterface(): ChartLayoutInterface; - getSelection(): any[]; - setSelection(selection: any[]): void; - clearChart(): void; + export class ColumnChart extends CoreChartBase { + draw(data: DataTable, options: ColumnChartOptions): void; + draw(data: DataView, options: ColumnChartOptions): void; } // https://google-developers.appspot.com/chart/interactive/docs/gallery/columnchart#Configuration_Options export interface ColumnChartOptions { aggregationTarget?: string; animation?: TransitionAnimation; + annotations?: ChartAnnotations; axisTitlesPosition?: string; // in, out, none backgroundColor?: any; - bar?: ColumnChartBarOptions; + bar?: GroupWidth; chartArea?: ChartArea; colors?: string[]; enableInteractivity?: boolean; @@ -358,36 +464,29 @@ declare module google { width?: number; } - export interface ColumnChartBarOptions { - groupWidth: any; - } - //#endregion //#region LineChart // https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart - export class LineChart { - constructor(element: Element); - - // https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Methods - draw(data: DataTable, options: any): void; - draw(data: DataView, options: any): void; - getChartLayoutInterface(): ChartLayoutInterface; - getSelection(): any[]; - setSelection(selection: any[]): void; - clearChart(): void; + export class LineChart extends CoreChartBase { + draw(data: DataTable, options: LineChartOptions): void; + draw(data: DataView, options: LineChartOptions): void; } // https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Configuration_Options export interface LineChartOptions { aggregationTarget?: string; animation?: TransitionAnimation; + annotations?: ChartAnnotations; axisTitlesPosition?: string; backgroundColor?: any; chartArea?: ChartArea; colors?: string[]; + crosshair?: ChartCrosshair; curveType?: string; + dataOpacity?: number; enableInteractivity?: boolean; + explorer?: ChartExplorer; focusTarget?: string; fontSize?: number; fontName?: string; @@ -396,6 +495,7 @@ declare module google { interpolateNulls?: boolean; legend?: ChartLegend; lineWidth?: number; + orientation?: string; pointSize?: number; reverseCategories?: boolean; selectionMode?: string // single / multiple @@ -417,9 +517,10 @@ declare module google { export interface BarChartOptions { aggregationTarget?: string; animation?: TransitionAnimation; + annotations?: ChartAnnotations; axisTitlesPosition?: string; // in, out, none backgroundColor?: any; - bar?: ColumnChartBarOptions; + bar?: GroupWidth; chartArea?: ChartArea; colors?: string[]; dataOpacity?: number; @@ -427,6 +528,7 @@ declare module google { focusTarget?: string; fontSize?: number; fontName?: string; + hAxes?: any; hAxis?: ChartAxis; height?: number; isStacked?: boolean; @@ -444,21 +546,388 @@ declare module google { } // https://google-developers.appspot.com/chart/interactive/docs/gallery/barchart - export class BarChart { - constructor(element: Element); + export class BarChart extends CoreChartBase { draw(data: DataTable, options: BarChartOptions): void; draw(data: DataView, options: BarChartOptions): void; - getBoundingBox(id: string): ChartBoundingBox; - getChartAreaBoundingBox(): ChartBoundingBox; - getChartLayoutInterface(): ChartLayoutInterface; - getHAxisValue(position: number, axisIndex?: number): number; - getVAxisValue(position: number, axisIndex?: number): number; - getXLocation(position: number, axisIndex?: number): number; - getYLocation(position: number, axisIndex?: number): number; - getSelection(): any[]; - setSelection(selection: any[]): void; - clearChart(): void; + } + //#endregion + //#region Histogram + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/histogram + export class Histogram extends CoreChartBase { + draw(data: DataTable, options: HistogramOptions): void; + draw(data: DataView, options: HistogramOptions): void; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/histogram#Configuration_Options + export interface HistogramOptions { + animation?: TransitionAnimation; + axisTitlesPosition?: string; // in, out, none + backgroundColor?: any; + bar?: GroupWidth; + chartArea?: ChartArea; + colors?: string[]; + dataOpacity?: number; + enableInteractivity?: boolean; + focusTarget?: string; + fontSize?: number; + fontName?: string; + hAxis?: ChartAxis; + histogram?: HistogramHistogramOptions; + height?: number; + interpolateNulls?: boolean; + isStacked?: boolean; + legend?: ChartLegend; + orientation?: string; + reverseCategories?: boolean; + series?: any; + theme?: string; + title?: string; + titlePosition?: string; + titleTextStyle?: ChartTextStyle; + tooltip?: ChartTooltip; + vAxes?: any; + vAxis?: ChartAxis; + width?: number; + } + + export interface HistogramHistogramOptions { + bucketSize?: number; + hideBucketItems?: boolean; + lastBucketPercentile?: number; + } + + //#endregion + //#region AreaChart + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/areachart + export class AreaChart extends CoreChartBase { + draw(data: DataTable, options: AreaChartOptions): void; + draw(data: DataView, options: AreaChartOptions): void; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/areachart#Configuration_Options + export interface AreaChartOptions { + aggregationTarget?: string; + animation?: TransitionAnimation; + areaOpacity?: number; + axisTitlesPosition?: string; + backgroundColor?: any; + chartArea?: ChartArea; + colors?: string[]; + crosshair?: ChartCrosshair; + dataOpacity?: number; + enableInteractivity?: boolean; + explorer?: ChartExplorer; + focusTarget?: string; + fontSize?: number; + fontName?: string; + hAxis?: ChartAxis; + height?: number; + interpolateNulls?: boolean; + isStacked?: boolean; + legend?: ChartLegend; + lineWidth?: number; + orientation?: string; + pointSize?: number; + reverseCategories?: boolean; + selectionMode?: string // single / multiple + series?: any; + theme?: string; + title?: string; + titlePosition?: string; + titleTextStyle?: ChartTextStyle; + tooltip?: ChartTooltip; + vAxes?: any; + vAxis?: ChartAxis; + width?: number; + } + + //#endregion + //#region SteppedAreaChart + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/areachart + export class SteppedAreaChart extends CoreChartBase { + draw(data: DataTable, options: SteppedAreaChartOptions): void; + draw(data: DataView, options: SteppedAreaChartOptions): void; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/areachart#Configuration_Options + export interface SteppedAreaChartOptions { + aggregationTarget?: string; + animation?: TransitionAnimation; + areaOpacity?: number; + axisTitlesPosition?: string; + backgroundColor?: any; + chartArea?: ChartArea; + colors?: string[]; + connectSteps?: boolean; + enableInteractivity?: boolean; + focusTarget?: string; + fontSize?: number; + fontName?: string; + hAxis?: ChartAxis; + height?: number; + interpolateNulls?: boolean; + isStacked?: boolean; + legend?: ChartLegend; + reverseCategories?: boolean; + selectionMode?: string // single / multiple + series?: any; + theme?: string; + title?: string; + titlePosition?: string; + titleTextStyle?: ChartTextStyle; + tooltip?: ChartTooltip; + vAxes?: any; + vAxis?: ChartAxis; + width?: number; + } + + //#endregion + //#region PieChart + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/piechart + export class PieChart extends CoreChartBase { + draw(data: DataTable, options: PieChartOptions): void; + draw(data: DataView, options: PieChartOptions): void; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/piechart#Configuration_Options + export interface PieChartOptions { + backgroundColor?: any; + chartArea?: ChartArea; + colors?: string[]; + enableInteractivity?: boolean; + fontSize?: number; + fontName?: string; + height?: number; + is3D?: boolean; + legend?: ChartLegend; + pieHole?: number; + pieSliceBorderColor?: string; + pieSliceText?: string; + pieSliceTextStyle?: ChartTextStyle; + pieStartAngle?: number; + reverseCategories?: boolean; + pieResidueSliceColor?: string; + pieResidueSliceLabel?: string; + slices?: any; + sliceVisibilityThreshold?: number; + title?: string; + titleTextStyle?: ChartTextStyle; + tooltip?: ChartTooltip; + width?: number; + } + + //#endregion + //#region BubbleChart + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/scatterchart + export class BubbleChart extends CoreChartBase { + draw(data: DataTable, options?: BubbleChartOptions): void; + draw(data: DataView, options?: BubbleChartOptions): void; + } + + export interface BubbleChartOptions { + animation?: TransitionAnimation; + axisTitlesPosition?: string; // in, out, none + backgroundColor?: any; + bubble?: ChartBubble; + chartArea?: ChartArea; + colors?: string[]; + colorAxis?: ChartColorAxis; + enableInteractivity?: boolean; + explorer?: ChartExplorer; + fontSize?: number; + fontName?: string; + forceIFrame?: boolean; + hAxis?: ChartAxis; + height?: number; + legend?: ChartLegend; + selectionMode?: string; + series?: any; + sizeAxis?: ChartSizeAxis; + sortBubblesBySize?: boolean; + theme?: string; + title?: string; + titlePosition?: string; + titleTextStyle?: ChartTextStyle; + tooltip?: ChartTooltip; + vAxis?: ChartAxis; + width?: number; + } + + export interface ChartBubble { + opacity?: number; + stroke?: string; + textStyle?: ChartTextStyle; + } + + export interface ChartSizeAxis { + maxSize: number; + maxValue: number; + minSize: number; + minValue: number; + } + + //#endregion + //#region TreeMap + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/treemap + export class TreeMap extends ChartBase { + draw(data: DataTable, options?: TreeMapOptions): void; + draw(data: DataView, options?: TreeMapOptions): void; + goUpAndDraw(): void; + getMaxPossibleDepth(): number; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/treemap#Configuration_Options + export interface TreeMapOptions { + fontColor?: string; + fontFamily?: string; + fontSize?: number; + forceIFrame?: boolean; + headerColor?: string; + headerHeight?: number; + headerHighlightColor?: string; + hintOpacity?: number; + maxColor?: string; + maxDepth?: number; + maxHighlightColor?: string; + maxPostDepth?: number; + maxColorValue?: number; + midColor?: string; + midHighlightColor?: string; + minColor?: string; + minHighlightColor?: string; + minColorValue?: number; + showScale?: boolean; + showTooltips?: boolean; + textStyle?: ChartTextStyle; + title?: string; + titleTextStyle?: ChartTextStyle; + useWeightedAverageForAggregation?: boolean; + } + + //#endregion + //#region Table + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/table + export class Table extends ChartBase { + draw(data: DataTable, options?: TableOptions): void; + draw(data: DataView, options?: TableOptions): void; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/table#Configuration_Options + export interface TableOptions { + allowHtml?: boolean; + alternatingRowStyle?: boolean; + cssClassName?: CssClassNames; + firstRowNumber?: number; + height?: string; + page?: string; + pageSize?: number; + rtlTable?: boolean; + scrollLeftStartPosition?: number; + showRowNumber?: boolean; + sort?: string; + sortAscending?: boolean; + sortColumn?: number; + startPage?: number; + width?: string; + } + + export interface CssClassNames { + headerRow?: string; + tableRow?: string; + oddTableRow?: string; + selectedTableRow?: string; + hoverTableRow?: string; + headerCell?: string; + tableCell?: string; + rowNumberCell?: string; + } + + //#endregion + //#region Timeline + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/timeline + export class Timeline { + constructor(element: Element); + draw(data: DataTable, options?: TimelineOptions): void; + draw(data: DataView, options?: TimelineOptions): void; + clearChart(): void; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/timeline#Configuration_Options + export interface TimelineOptions { + avoidOverlappingGridLines?: boolean; + backgroundColor?: string; + colors?: string[]; + enableInteractivity?: boolean; + forceIFrame?: boolean; + height?: number; + timeline?: { + barLabelStyle?: LabelStyle; + colorByRowLabel?: boolean; + groupByRowLabel?: boolean; + rowLabelStyle?: LabelStyle; + showRowLabels?: boolean; + singleColor?: string; + } + width?: number; + } + + export interface LabelStyle { + color: string; + fontName: string; + fontSize: string; + } + + //#endregion + //#region CandlestickChart + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/candlestickchart + export class CandlestickChart extends CoreChartBase { + draw(data: DataTable, options: CandlestickChartOptions): void; + draw(data: DataView, options: CandlestickChartOptions): void; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/candlestickchart#Configuration_Options + export interface CandlestickChartOptions { + aggregationTarget?: string; + animation?: TransitionAnimation; + axisTitlesPosition?: string; + backgroundColor?: any; + bar?: GroupWidth; + candlestick?: { + hollowIsRising?: boolean; + fallingColor?: ChartStroke; + risingColor?: ChartStroke; + } + chartArea?: ChartArea; + colors?: string[]; + enableInteractivity?: boolean; + focusTarget?: string; + fontSize?: number; + fontName?: string; + hAxis?: ChartAxis; + height?: number; + legend?: ChartLegend; + orientation?: string; + reverseCategories?: boolean; + selectionMode?: string // single / multiple + series?: any; + theme?: string; + title?: string; + titlePosition?: string; + titleTextStyle?: ChartTextStyle; + tooltip?: ChartTooltip; + vAxes?: any; + vAxis?: ChartAxis; + width?: number; } //#endregion diff --git a/jasmine/jasmine-1.3-tests.ts b/jasmine/legacy/jasmine-1.3-tests.ts similarity index 100% rename from jasmine/jasmine-1.3-tests.ts rename to jasmine/legacy/jasmine-1.3-tests.ts diff --git a/jasmine/jasmine-1.3.d.ts b/jasmine/legacy/jasmine-1.3.d.ts similarity index 100% rename from jasmine/jasmine-1.3.d.ts rename to jasmine/legacy/jasmine-1.3.d.ts diff --git a/jquery.validation/jquery.validation.d.ts b/jquery.validation/jquery.validation.d.ts index d0bee32796..585fb484fc 100644 --- a/jquery.validation/jquery.validation.d.ts +++ b/jquery.validation/jquery.validation.d.ts @@ -1,5 +1,5 @@ // Type definitions for jquery.validation 1.11.1 -// Project: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ +// Project: http://jqueryvalidation.org/ // Definitions by: https://github.com/fdecampredon , https://github.com/johnnyreilly // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 81ddb3ae19..79dda3e547 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -3114,6 +3114,9 @@ function test_parseHTML() { $( "
    " ) .append( nodeNames.join( "" ) ) .appendTo( $log ); + + // parse HTML with all parameters + $.parseHTML( str, document, true ); } // http://api.jquery.com/jQuery.parseJSON/ diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 70a9532ab2..d6a6a792e1 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1252,6 +1252,15 @@ interface JQueryStatic { * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string */ parseHTML(data: string, context?: HTMLElement, keepScripts?: boolean): any[]; + + /** + * Parses a string into an array of DOM nodes. + * + * @param data HTML string to be parsed + * @param context DOM element to serve as the context in which the HTML fragment will be created + * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string + */ + parseHTML(data: string, context?: Document, keepScripts?: boolean): any[]; } /** diff --git a/jstree/jstree.d.ts b/jstree/jstree.d.ts index 7d8561ed45..4039795bab 100644 --- a/jstree/jstree.d.ts +++ b/jstree/jstree.d.ts @@ -121,11 +121,11 @@ interface JSTreeStaticDefaults { * stores all defaults for the search plugin */ search?: JSTreeStaticDefaultsSearch; - /** - * the settings function used to sort the nodes. - * It is executed in the tree's context, accepts two nodes as arguments and should return `1` or `-1`. - * @name $.jstree.defaults.sort - * @plugin sort + /** + * the settings function used to sort the nodes. + * It is executed in the tree's context, accepts two nodes as arguments and should return `1` or `-1`. + * @name $.jstree.defaults.sort + * @plugin sort */ sort?: (x: any, y: any) => number; /** @@ -151,125 +151,131 @@ interface JSTreeStaticDefaults { * default represents the default node - any settings here will be applied to all nodes that do not have a type specified. */ types?: any; + /** + * stores all defaults for the unique plugin + * @name $.jstree.defaults.unique + * @plugin unique + */ + unique?: JSTreeStaticDefaultsUnique; } interface JSTreeStaticDefaultsCore { /** - * data configuration - * - * If left as `false` the HTML inside the jstree container element is used to populate the tree (that should be an unordered list with list items). - * - * You can also pass in a HTML string or a JSON array here. - * - * It is possible to pass in a standard jQuery-like AJAX config and jstree will automatically determine if the response is JSON or HTML and use that to populate the tree. - * In addition to the standard jQuery ajax options here you can suppy functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used. - * - * The last option is to specify a function, that function will receive the node being loaded as argument and a second param which is a function which should be called with the result. - * - * __Examples__ - * - * // AJAX - * $('#tree').jstree({ - * 'core' : { - * 'data' : { - * 'url' : '/get/children/', - * 'data' : function (node) { - * return { 'id' : node.id }; - * } - * } - * }); - * - * // direct data - * $('#tree').jstree({ - * 'core' : { - * 'data' : [ - * 'Simple root node', - * { - * 'id' : 'node_2', - * 'text' : 'Root node with options', - * 'state' : { 'opened' : true, 'selected' : true }, - * 'children' : [ { 'text' : 'Child 1' }, 'Child 2'] - * } - * ] - * }); - * - * // function - * $('#tree').jstree({ - * 'core' : { - * 'data' : function (obj, callback) { - * callback.call(this, ['Root 1', 'Root 2']); - * } - * }); - * - * @name $.jstree.defaults.core.data + * data configuration + * + * If left as `false` the HTML inside the jstree container element is used to populate the tree (that should be an unordered list with list items). + * + * You can also pass in a HTML string or a JSON array here. + * + * It is possible to pass in a standard jQuery-like AJAX config and jstree will automatically determine if the response is JSON or HTML and use that to populate the tree. + * In addition to the standard jQuery ajax options here you can suppy functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used. + * + * The last option is to specify a function, that function will receive the node being loaded as argument and a second param which is a function which should be called with the result. + * + * __Examples__ + * + * // AJAX + * $('#tree').jstree({ + * 'core' : { + * 'data' : { + * 'url' : '/get/children/', + * 'data' : function (node) { + * return { 'id' : node.id }; + * } + * } + * }); + * + * // direct data + * $('#tree').jstree({ + * 'core' : { + * 'data' : [ + * 'Simple root node', + * { + * 'id' : 'node_2', + * 'text' : 'Root node with options', + * 'state' : { 'opened' : true, 'selected' : true }, + * 'children' : [ { 'text' : 'Child 1' }, 'Child 2'] + * } + * ] + * }); + * + * // function + * $('#tree').jstree({ + * 'core' : { + * 'data' : function (obj, callback) { + * callback.call(this, ['Root 1', 'Root 2']); + * } + * }); + * + * @name $.jstree.defaults.core.data */ data?: any; /** - * configure the various strings used throughout the tree - * - * You can use an object where the key is the string you need to replace and the value is your replacement. - * Another option is to specify a function which will be called with an argument of the needed string and should return the replacement. - * If left as `false` no replacement is made. - * - * __Examples__ - * - * $('#tree').jstree({ - * 'core' : { - * 'strings' : { - * 'Loading...' : 'Please wait ...' - * } - * } - * }); - * - * @name $.jstree.defaults.core.strings + * configure the various strings used throughout the tree + * + * You can use an object where the key is the string you need to replace and the value is your replacement. + * Another option is to specify a function which will be called with an argument of the needed string and should return the replacement. + * If left as `false` no replacement is made. + * + * __Examples__ + * + * $('#tree').jstree({ + * 'core' : { + * 'strings' : { + * 'Loading...' : 'Please wait ...' + * } + * } + * }); + * + * @name $.jstree.defaults.core.strings */ strings?: any; /** - * determines what happens when a user tries to modify the structure of the tree - * If left as `false` all operations like create, rename, delete, move or copy are prevented. - * You can set this to `true` to allow all interactions or use a function to have better control. - * - * __Examples__ - * - * $('#tree').jstree({ - * 'core' : { - * 'check_callback' : function (operation, node, node_parent, node_position, more) { - * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node' or 'copy_node' - * // in case of 'rename_node' node_position is filled with the new node name - * return operation === 'rename_node' ? true : false; - * } - * } - * }); - * - * @name $.jstree.defaults.core.check_callback + * determines what happens when a user tries to modify the structure of the tree + * If left as `false` all operations like create, rename, delete, move or copy are prevented. + * You can set this to `true` to allow all interactions or use a function to have better control. + * + * __Examples__ + * + * $('#tree').jstree({ + * 'core' : { + * 'check_callback' : function (operation, node, node_parent, node_position, more) { + * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node' or 'copy_node' + * // in case of 'rename_node' node_position is filled with the new node name + * return operation === 'rename_node' ? true : false; + * } + * } + * }); + * + * @name $.jstree.defaults.core.check_callback */ check_callback?: any; - /** - * a callback called with a single object parameter in the instance's scope when something goes wrong (operation prevented, ajax failed, etc) - * @name $.jstree.defaults.core.error + /** + * a callback called with a single object parameter in the instance's scope when something goes wrong (operation prevented, ajax failed, etc) + * @name $.jstree.defaults.core.error */ error: () => any; - /** - * the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`) - * @name $.jstree.defaults.core.animation + /** + * the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`) + * @name $.jstree.defaults.core.animation */ animation?: any; - /** - * a boolean indicating if multiple nodes can be selected - * @name $.jstree.defaults.core.multiple + /** + * a boolean indicating if multiple nodes can be selected + * @name $.jstree.defaults.core.multiple */ multiple?: boolean; - /** - * theme configuration object - * @name $.jstree.defaults.core.themes + /** + * theme configuration object + * @name $.jstree.defaults.core.themes */ themes?: JSTreeStaticDefaultsCoreThemes; - /** - * if left as `true` all parents of all selected nodes will be opened once the tree loads (so that all selected nodes are visible to the user) - * @name $.jstree.defaults.core.expand_selected_onload + /** + * if left as `true` all parents of all selected nodes will be opened once the tree loads (so that all selected nodes are visible to the user) + * @name $.jstree.defaults.core.expand_selected_onload */ expand_selected_onload?: boolean; } @@ -315,186 +321,203 @@ interface JSTreeStaticDefaultsCoreThemes { } interface JSTreeStaticDefaultsCheckbox { - /** - * a boolean indicating if checkboxes should be visible (can be changed at a later time using `show_checkboxes()` and `hide_checkboxes`). Defaults to `true`. - * @name $.jstree.defaults.checkbox.visible - * @plugin checkbox + /** + * a boolean indicating if checkboxes should be visible (can be changed at a later time using `show_checkboxes()` and `hide_checkboxes`). Defaults to `true`. + * @name $.jstree.defaults.checkbox.visible + * @plugin checkbox */ visible: boolean; - /** - * a boolean indicating if checkboxes should cascade down and have an undetermined state. Defaults to `true`. - * @name $.jstree.defaults.checkbox.three_state - * @plugin checkbox + /** + * a boolean indicating if checkboxes should cascade down and have an undetermined state. Defaults to `true`. + * @name $.jstree.defaults.checkbox.three_state + * @plugin checkbox */ three_state: boolean; - /** - * a boolean indicating if clicking anywhere on the node should act as clicking on the checkbox. Defaults to `true`. - * @name $.jstree.defaults.checkbox.whole_node - * @plugin checkbox + /** + * a boolean indicating if clicking anywhere on the node should act as clicking on the checkbox. Defaults to `true`. + * @name $.jstree.defaults.checkbox.whole_node + * @plugin checkbox */ whole_node: boolean; - /** - * a boolean indicating if the selected style of a node should be kept, or removed. Defaults to `true`. - * @name $.jstree.defaults.checkbox.keep_selected_style - * @plugin checkbox + /** + * a boolean indicating if the selected style of a node should be kept, or removed. Defaults to `true`. + * @name $.jstree.defaults.checkbox.keep_selected_style + * @plugin checkbox */ keep_selected_style: boolean; + /** + * This setting controls how cascading and undetermined nodes are applied. + * If 'up' is in the string - cascading up is enabled, if 'down' is in the string - cascading down is enabled, if 'undetermined' is in the string - undetermined nodes will be used. + * If `three_state` is set to `true` this setting is automatically set to 'up+down+undetermined'. Defaults to ''. + * @name $.jstree.defaults.checkbox.cascade + * @plugin checkbox + */ + cascade:boolean; } interface JSTreeStaticDefaultsContextMenu { - /** - * a boolean indicating if the node should be selected when the context menu is invoked on it. Defaults to `true`. - * @name $.jstree.defaults.contextmenu.select_node - * @plugin contextmenu + /** + * a boolean indicating if the node should be selected when the context menu is invoked on it. Defaults to `true`. + * @name $.jstree.defaults.contextmenu.select_node + * @plugin contextmenu */ select_node: boolean; - /** - * a boolean indicating if the menu should be shown aligned with the node. Defaults to `true`, otherwise the mouse coordinates are used. - * @name $.jstree.defaults.contextmenu.show_at_node - * @plugin contextmenu + /** + * a boolean indicating if the menu should be shown aligned with the node. Defaults to `true`, otherwise the mouse coordinates are used. + * @name $.jstree.defaults.contextmenu.show_at_node + * @plugin contextmenu */ show_at_node: boolean; - /** - * an object of actions, or a function that accepts a node and a callback function and calls the callback function with an object of actions available for that node (you can also return the items too). - * - * Each action consists of a key (a unique name) and a value which is an object with the following properties (only label and action are required): - * - * * `separator_before` - a boolean indicating if there should be a separator before this item - * * `separator_after` - a boolean indicating if there should be a separator after this item - * * `_disabled` - a boolean indicating if this action should be disabled - * * `label` - a string - the name of the action (could be a function returning a string) - * * `action` - a function to be executed if this item is chosen - * * `icon` - a string, can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class - * * `shortcut` - keyCode which will trigger the action if the menu is open (for example `113` for rename, which equals F2) - * * `shortcut_label` - shortcut label (like for example `F2` for rename) - * - * @name $.jstree.defaults.contextmenu.items - * @plugin contextmenu + /** + * an object of actions, or a function that accepts a node and a callback function and calls the callback function with an object of actions available for that node (you can also return the items too). + * + * Each action consists of a key (a unique name) and a value which is an object with the following properties (only label and action are required): + * + * * `separator_before` - a boolean indicating if there should be a separator before this item + * * `separator_after` - a boolean indicating if there should be a separator after this item + * * `_disabled` - a boolean indicating if this action should be disabled + * * `label` - a string - the name of the action (could be a function returning a string) + * * `action` - a function to be executed if this item is chosen + * * `icon` - a string, can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class + * * `shortcut` - keyCode which will trigger the action if the menu is open (for example `113` for rename, which equals F2) + * * `shortcut_label` - shortcut label (like for example `F2` for rename) + * + * @name $.jstree.defaults.contextmenu.items + * @plugin contextmenu */ items: any; } interface JSTreeStaticDefaultsDragNDrop { - /** - * a boolean indicating if a copy should be possible while dragging (by pressint the meta key or Ctrl). Defaults to `true`. - * @name $.jstree.defaults.dnd.copy - * @plugin dnd + /** + * a boolean indicating if a copy should be possible while dragging (by pressint the meta key or Ctrl). Defaults to `true`. + * @name $.jstree.defaults.dnd.copy + * @plugin dnd */ copy: boolean; - /** - * a number indicating how long a node should remain hovered while dragging to be opened. Defaults to `500`. - * @name $.jstree.defaults.dnd.open_timeout - * @plugin dnd + /** + * a number indicating how long a node should remain hovered while dragging to be opened. Defaults to `500`. + * @name $.jstree.defaults.dnd.open_timeout + * @plugin dnd */ open_timeout: number; - /** - * a function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) - return `false` to prevent dragging - * @name $.jstree.defaults.dnd.is_draggable - * @plugin dnd + /** + * a function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) - return `false` to prevent dragging + * @name $.jstree.defaults.dnd.is_draggable + * @plugin dnd */ is_draggable: boolean; - /** - * a boolean indicating if checks should constantly be made while the user is dragging the node (as opposed to checking only on drop), default is `true` - * @name $.jstree.defaults.dnd.check_while_dragging - * @plugin dnd + /** + * a boolean indicating if checks should constantly be made while the user is dragging the node (as opposed to checking only on drop), default is `true` + * @name $.jstree.defaults.dnd.check_while_dragging + * @plugin dnd */ check_while_dragging: boolean; - /** - * a boolean indicating if nodes from this tree should only be copied with dnd (as opposed to moved), default is `false` - * @name $.jstree.defaults.dnd.always_copy - * @plugin dnd + /** + * a boolean indicating if nodes from this tree should only be copied with dnd (as opposed to moved), default is `false` + * @name $.jstree.defaults.dnd.always_copy + * @plugin dnd */ always_copy: boolean; - /** - * when dropping a node "inside", this setting indicates the position the node should go to - it can be an integer or a string: "first" (same as 0) or "last", default is `0` - * @name $.jstree.defaults.dnd.inside_pos - * @plugin dnd + /** + * when dropping a node "inside", this setting indicates the position the node should go to - it can be an integer or a string: "first" (same as 0) or "last", default is `0` + * @name $.jstree.defaults.dnd.inside_pos + * @plugin dnd */ inside_pos: any; } interface JSTreeStaticDefaultsSearch { - /** - * a jQuery-like AJAX config, which jstree uses if a server should be queried for results. - * - * A `str` (which is the search string) parameter will be added with the request. - * The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed. - * Leave this setting as `false` to not query the server. You can also set this to a function, - * which will be invoked in the instance's scope and receive 2 parameters - - * the search string and the callback to call with the array of nodes to load. - * @name $.jstree.defaults.search.ajax - * @plugin search + /** + * a jQuery-like AJAX config, which jstree uses if a server should be queried for results. + * + * A `str` (which is the search string) parameter will be added with the request. + * The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed. + * Leave this setting as `false` to not query the server. You can also set this to a function, + * which will be invoked in the instance's scope and receive 2 parameters - + * the search string and the callback to call with the array of nodes to load. + * @name $.jstree.defaults.search.ajax + * @plugin search */ ajax: any; - /** - * Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `true`. - * @name $.jstree.defaults.search.fuzzy - * @plugin search + /** + * Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `true`. + * @name $.jstree.defaults.search.fuzzy + * @plugin search */ fuzzy: boolean; - /** - * Indicates if the search should be case sensitive. Default is `false`. - * @name $.jstree.defaults.search.case_sensitive - * @plugin search + /** + * Indicates if the search should be case sensitive. Default is `false`. + * @name $.jstree.defaults.search.case_sensitive + * @plugin search */ case_sensitive: boolean; - /** - * Indicates if the tree should be filtered to show only matching nodes - * (keep in mind this can be a heavy on large trees in old browsers). Default is `false`. - * @name $.jstree.defaults.search.show_only_matches - * @plugin search + /** + * Indicates if the tree should be filtered to show only matching nodes + * (keep in mind this can be a heavy on large trees in old browsers). Default is `false`. + * @name $.jstree.defaults.search.show_only_matches + * @plugin search */ show_only_matches: boolean; - /** - * Indicates if all nodes opened to reveal the search result, - * should be closed when the search is cleared or a new search is performed. Default is `true`. - * @name $.jstree.defaults.search.close_opened_onclear - * @plugin search + /** + * Indicates if all nodes opened to reveal the search result, + * should be closed when the search is cleared or a new search is performed. Default is `true`. + * @name $.jstree.defaults.search.close_opened_onclear + * @plugin search */ close_opened_onclear: boolean; - /** - * Indicates if only leaf nodes should be included in search results. Default is `false`. - * @name $.jstree.defaults.search.search_leaves_only - * @plugin search + /** + * Indicates if only leaf nodes should be included in search results. Default is `false`. + * @name $.jstree.defaults.search.search_leaves_only + * @plugin search */ search_leaves_only: boolean; } interface JSTreeStaticDefaultsState { - /** - * A string for the key to use when saving the current tree (change if using multiple trees in your project). Defaults to `jstree`. - * @name $.jstree.defaults.state.key - * @plugin state + /** + * A string for the key to use when saving the current tree (change if using multiple trees in your project). Defaults to `jstree`. + * @name $.jstree.defaults.state.key + * @plugin state */ key: string; - /** - * A space separated list of events that trigger a state save. Defaults to `changed.jstree open_node.jstree close_node.jstree`. - * @name $.jstree.defaults.state.events - * @plugin state + /** + * A space separated list of events that trigger a state save. Defaults to `changed.jstree open_node.jstree close_node.jstree`. + * @name $.jstree.defaults.state.events + * @plugin state */ events: string; - /** - * Time in milliseconds after which the state will expire. Defaults to 'false' meaning - no expire. - * @name $.jstree.defaults.state.ttl - * @plugin state + /** + * Time in milliseconds after which the state will expire. Defaults to 'false' meaning - no expire. + * @name $.jstree.defaults.state.ttl + * @plugin state */ ttl: any; - /** - * A function that will be executed prior to restoring state with one argument - the state object. Can be used to clear unwanted parts of the state. - * @name $.jstree.defaults.state.filter - * @plugin state + /** + * A function that will be executed prior to restoring state with one argument - the state object. Can be used to clear unwanted parts of the state. + * @name $.jstree.defaults.state.filter + * @plugin state */ filter: any; } +interface JSTreeStaticDefaultsUnique { + /** + * Indicates if the comparison should be case sensitive. Default is `false`. + * @name $.jstree.defaults.unique.case_sensitive + * @plugin unique + */ + case_sensitive:boolean; +} + interface JQuery { jstree(): JSTree; jstree(options: JSTreeStaticDefaults): JSTree; @@ -503,482 +526,482 @@ interface JQuery { } interface JSTree extends JQuery { - /** - * destroy an instance - * @name destroy() - * @param {Boolean} keep_html if not set to `true` the container will be emptied, otherwise the current DOM elements will be kept intact + /** + * destroy an instance + * @name destroy() + * @param {Boolean} keep_html if not set to `true` the container will be emptied, otherwise the current DOM elements will be kept intact */ destroy: (keep_html?: boolean) => void; - /** - * returns the jQuery extended instance container - * @name get_container() - * @return {jQuery} + /** + * returns the jQuery extended instance container + * @name get_container() + * @return {jQuery} */ get_container: () => JQuery; - /** - * get the JSON representation of a node (or the actual jQuery extended DOM node) by using any input (child DOM element, ID string, selector, etc) - * @name get_node(obj [, as_dom]) - * @param {mixed} obj - * @param {Boolean} as_dom - * @return {Object|jQuery} + /** + * get the JSON representation of a node (or the actual jQuery extended DOM node) by using any input (child DOM element, ID string, selector, etc) + * @name get_node(obj [, as_dom]) + * @param {mixed} obj + * @param {Boolean} as_dom + * @return {Object|jQuery} */ get_node: (obj: any, as_dom?: boolean) => JQuery; - /** - * get the path to a node, either consisting of node texts, or of node IDs, optionally glued together (otherwise an array) - * @name get_path(obj [, glue, ids]) - * @param {mixed} obj the node - * @param {String} glue if you want the path as a string - pass the glue here (for example '/'), if a falsy value is supplied here, an array is returned - * @param {Boolean} ids if set to true build the path using ID, otherwise node text is used - * @return {mixed} + /** + * get the path to a node, either consisting of node texts, or of node IDs, optionally glued together (otherwise an array) + * @name get_path(obj [, glue, ids]) + * @param {mixed} obj the node + * @param {String} glue if you want the path as a string - pass the glue here (for example '/'), if a falsy value is supplied here, an array is returned + * @param {Boolean} ids if set to true build the path using ID, otherwise node text is used + * @return {mixed} */ get_path: (obj:any, glue:string, ids:boolean) => JQuery; - /** - * get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned. - * @name get_next_dom(obj [, strict]) - * @param {mixed} obj - * @param {Boolean} strict - * @return {jQuery} + /** + * get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned. + * @name get_next_dom(obj [, strict]) + * @param {mixed} obj + * @param {Boolean} strict + * @return {jQuery} */ get_next_dom: (obj:any, strict?:boolean) => JQuery; - /** - * get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned. - * @name get_prev_dom(obj [, strict]) - * @param {mixed} obj - * @param {Boolean} strict - * @return {jQuery} + /** + * get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned. + * @name get_prev_dom(obj [, strict]) + * @param {mixed} obj + * @param {Boolean} strict + * @return {jQuery} */ get_prev_dom: (obj: any, strict?: boolean) => JQuery; - /** - * get the parent ID of a node - * @name get_parent(obj) - * @param {mixed} obj - * @return {String} + /** + * get the parent ID of a node + * @name get_parent(obj) + * @param {mixed} obj + * @return {String} */ get_parent: (obj: any) => string; - /** - * get a jQuery collection of all the children of a node (node must be rendered) - * @name get_children_dom(obj) - * @param {mixed} obj - * @return {jQuery} + /** + * get a jQuery collection of all the children of a node (node must be rendered) + * @name get_children_dom(obj) + * @param {mixed} obj + * @return {jQuery} */ get_children_dom: (obj: any) => JQuery; - /** - * checks if a node has children - * @name is_parent(obj) - * @param {mixed} obj - * @return {Boolean} + /** + * checks if a node has children + * @name is_parent(obj) + * @param {mixed} obj + * @return {Boolean} */ is_parent: (obj: any) => boolean; - /** - * checks if a node is loaded (its children are available) - * @name is_loaded(obj) - * @param {mixed} obj - * @return {Boolean} + /** + * checks if a node is loaded (its children are available) + * @name is_loaded(obj) + * @param {mixed} obj + * @return {Boolean} */ is_loaded: (obj: any) => boolean; - /** - * check if a node is currently loading (fetching children) - * @name is_loading(obj) - * @param {mixed} obj - * @return {Boolean} + /** + * check if a node is currently loading (fetching children) + * @name is_loading(obj) + * @param {mixed} obj + * @return {Boolean} */ is_loading: (obj: any) => boolean; - /** - * check if a node is opened - * @name is_open(obj) - * @param {mixed} obj - * @return {Boolean} + /** + * check if a node is opened + * @name is_open(obj) + * @param {mixed} obj + * @return {Boolean} */ is_open: (obj: any) => boolean; - /** - * check if a node is in a closed state - * @name is_closed(obj) - * @param {mixed} obj - * @return {Boolean} + /** + * check if a node is in a closed state + * @name is_closed(obj) + * @param {mixed} obj + * @return {Boolean} */ is_closed: (obj: any) => boolean; - /** - * check if a node has no children - * @name is_leaf(obj) - * @param {mixed} obj - * @return {Boolean} + /** + * check if a node has no children + * @name is_leaf(obj) + * @param {mixed} obj + * @return {Boolean} */ is_leaf: (obj: any) => boolean; - /** - * loads a node (fetches its children using the `core.data` setting). Multiple nodes can be passed to by using an array. - * @name load_node(obj [, callback]) - * @param {mixed} obj - * @param {function} callback a function to be executed once loading is conplete, the function is executed in the instance's scope - * and receives two arguments - the node and a boolean status - * @return {Boolean} - * @trigger load_node.jstree + /** + * loads a node (fetches its children using the `core.data` setting). Multiple nodes can be passed to by using an array. + * @name load_node(obj [, callback]) + * @param {mixed} obj + * @param {function} callback a function to be executed once loading is conplete, the function is executed in the instance's scope + * and receives two arguments - the node and a boolean status + * @return {Boolean} + * @trigger load_node.jstree */ load_node: (obj: any, callback: any) => boolean; - /** - * redraws all nodes that need to be redrawn or optionally - the whole tree - * @name redraw([full]) - * @param {Boolean} full if set to `true` all nodes are redrawn. + /** + * redraws all nodes that need to be redrawn or optionally - the whole tree + * @name redraw([full]) + * @param {Boolean} full if set to `true` all nodes are redrawn. */ redraw: (full?: boolean) => void; - /** - * opens a node, revaling its children. If the node is not loaded it will be loaded and opened once ready. - * @name open_node(obj [, callback, animation]) - * @param {mixed} obj the node to open - * @param {Function} callback a function to execute once the node is opened - * @param {Number} animation the animation duration in milliseconds - * when opening the node (overrides the `core.animation` setting). Use `false` for no animation. - * @trigger open_node.jstree, after_open.jstree, before_open.jstree + /** + * opens a node, revaling its children. If the node is not loaded it will be loaded and opened once ready. + * @name open_node(obj [, callback, animation]) + * @param {mixed} obj the node to open + * @param {Function} callback a function to execute once the node is opened + * @param {Number} animation the animation duration in milliseconds + * when opening the node (overrides the `core.animation` setting). Use `false` for no animation. + * @trigger open_node.jstree, after_open.jstree, before_open.jstree */ open_node: (obj: any, callback?: any, animation?: any) => void; - /** - * closes a node, hiding its children - * @name close_node(obj [, animation]) - * @param {mixed} obj the node to close - * @param {Number} animation the animation duration in milliseconds - * when closing the node (overrides the `core.animation` setting). Use `false` for no animation. - * @trigger close_node.jstree, after_close.jstree + /** + * closes a node, hiding its children + * @name close_node(obj [, animation]) + * @param {mixed} obj the node to close + * @param {Number} animation the animation duration in milliseconds + * when closing the node (overrides the `core.animation` setting). Use `false` for no animation. + * @trigger close_node.jstree, after_close.jstree */ close_node: (obj: any, animation?: any) => void; - /** - * toggles a node - closing it if it is open, opening it if it is closed - * @name toggle_node(obj) - * @param {mixed} obj the node to toggle + /** + * toggles a node - closing it if it is open, opening it if it is closed + * @name toggle_node(obj) + * @param {mixed} obj the node to toggle */ toggle_node: (obj: any) => void; - /** - * opens all nodes within a node (or the tree), revaling their children. If the node is not loaded it will be loaded and opened once ready. - * @name open_all([obj, animation, original_obj]) - * @param {mixed} obj the node to open recursively, omit to open all nodes in the tree - * @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation - * @param {jQuery} reference to the node that started the process (internal use) - * @trigger open_all.jstree + /** + * opens all nodes within a node (or the tree), revaling their children. If the node is not loaded it will be loaded and opened once ready. + * @name open_all([obj, animation, original_obj]) + * @param {mixed} obj the node to open recursively, omit to open all nodes in the tree + * @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation + * @param {jQuery} reference to the node that started the process (internal use) + * @trigger open_all.jstree */ open_all: (obj?: any, animation?: number, original_obj?: any) => void; - /** - * closes all nodes within a node (or the tree), revaling their children - * @name close_all([obj, animation]) - * @param {mixed} obj the node to close recursively, omit to close all nodes in the tree - * @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation - * @trigger close_all.jstree + /** + * closes all nodes within a node (or the tree), revaling their children + * @name close_all([obj, animation]) + * @param {mixed} obj the node to close recursively, omit to close all nodes in the tree + * @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation + * @trigger close_all.jstree */ close_all: (obj?: any, animation?: number) => void; - /** - * checks if a node is disabled (not selectable) - * @name is_disabled(obj) - * @param {mixed} obj - * @return {Boolean} + /** + * checks if a node is disabled (not selectable) + * @name is_disabled(obj) + * @param {mixed} obj + * @return {Boolean} */ is_disabled: (obj: any) => boolean; - /** - * enables a node - so that it can be selected - * @name enable_node(obj) - * @param {mixed} obj the node to enable - * @trigger enable_node.jstree + /** + * enables a node - so that it can be selected + * @name enable_node(obj) + * @param {mixed} obj the node to enable + * @trigger enable_node.jstree */ enable_node: (obj: any) => boolean; - /** - * disables a node - so that it can not be selected - * @name disable_node(obj) - * @param {mixed} obj the node to disable - * @trigger disable_node.jstree + /** + * disables a node - so that it can not be selected + * @name disable_node(obj) + * @param {mixed} obj the node to disable + * @trigger disable_node.jstree */ disable_node: (obj: any) => boolean; - /** - * select a node - * @name select_node(obj [, supress_event, prevent_open]) - * @param {mixed} obj an array can be used to select multiple nodes - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @param {Boolean} prevent_open if set to `true` parents of the selected node won't be opened - * @trigger select_node.jstree, changed.jstree + /** + * select a node + * @name select_node(obj [, supress_event, prevent_open]) + * @param {mixed} obj an array can be used to select multiple nodes + * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered + * @param {Boolean} prevent_open if set to `true` parents of the selected node won't be opened + * @trigger select_node.jstree, changed.jstree */ select_node: (obj: any, supress_event?: boolean, prevent_open?: boolean, e?:any) => void; - /** - * deselect a node - * @name deselect_node(obj [, supress_event]) - * @param {mixed} obj an array can be used to deselect multiple nodes - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @trigger deselect_node.jstree, changed.jstree + /** + * deselect a node + * @name deselect_node(obj [, supress_event]) + * @param {mixed} obj an array can be used to deselect multiple nodes + * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered + * @trigger deselect_node.jstree, changed.jstree */ deselect_node: (obj: any, supress_event?: boolean, e?:any) => void; - /** - * select all nodes in the tree - * @name select_all([supress_event]) - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @trigger select_all.jstree, changed.jstree + /** + * select all nodes in the tree + * @name select_all([supress_event]) + * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered + * @trigger select_all.jstree, changed.jstree */ select_all: (supress_event?: boolean) => void; - /** - * deselect all selected nodes - * @name deselect_all([supress_event]) - * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered - * @trigger deselect_all.jstree, changed.jstree + /** + * deselect all selected nodes + * @name deselect_all([supress_event]) + * @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered + * @trigger deselect_all.jstree, changed.jstree */ deselect_all: (supress_event?: boolean) => void; - /** - * checks if a node is selected - * @name is_selected(obj) - * @param {mixed} obj - * @return {Boolean} + /** + * checks if a node is selected + * @name is_selected(obj) + * @param {mixed} obj + * @return {Boolean} */ is_selected: (obj: any) => boolean; - /** - * get an array of all selected nodes - * @name get_selected([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} + /** + * get an array of all selected nodes + * @name get_selected([full]) + * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned + * @return {Array} */ get_selected: (full?: any) => string[]; - /** - * get an array of all top level selected nodes (ignoring children of selected nodes) - * @name get_top_selected([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} + /** + * get an array of all top level selected nodes (ignoring children of selected nodes) + * @name get_top_selected([full]) + * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned + * @return {Array} */ get_top_selected: (full?: any) => string[]; - /** - * get an array of all bottom level selected nodes (ignoring selected parents) - * @name get_top_selected([full]) - * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned - * @return {Array} + /** + * get an array of all bottom level selected nodes (ignoring selected parents) + * @name get_top_selected([full]) + * @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned + * @return {Array} */ get_bottom_selected: (full?: any) => string[]; - /** - * refreshes the tree - all nodes are reloaded with calls to `load_node`. - * @name refresh() - * @param {Boolean} skip_loading an option to skip showing the loading indicator - * @trigger refresh.jstree + /** + * refreshes the tree - all nodes are reloaded with calls to `load_node`. + * @name refresh() + * @param {Boolean} skip_loading an option to skip showing the loading indicator + * @trigger refresh.jstree */ refresh: (skip_loading:boolean) => void; - /** - * refreshes a node in the tree (reload its children) all opened nodes inside that node are reloaded with calls to `load_node`. - * @name refresh_node(obj) - * @param {Boolean} skip_loading an option to skip showing the loading indicator - * @trigger refresh.jstree - */ + /** + * refreshes a node in the tree (reload its children) all opened nodes inside that node are reloaded with calls to `load_node`. + * @name refresh_node(obj) + * @param {Boolean} skip_loading an option to skip showing the loading indicator + * @trigger refresh.jstree + */ refresh_node: (obj:any) => void; - /** - * set (change) the ID of a node - * @name set_id(obj, id) - * @param {mixed} obj the node - * @param {String} id the new ID - * @return {Boolean} + /** + * set (change) the ID of a node + * @name set_id(obj, id) + * @param {mixed} obj the node + * @param {String} id the new ID + * @return {Boolean} */ set_id: (obj: any, id: string) => void; - /** - * get the text value of a node - * @name get_text(obj) - * @param {mixed} obj the node - * @return {String} + /** + * get the text value of a node + * @name get_text(obj) + * @param {mixed} obj the node + * @return {String} */ get_text: (obj: any) => string; - /** - * gets a JSON representation of a node (or the whole tree) - * @name get_json([obj, options]) - * @param {mixed} obj - * @param {Object} options - * @param {Boolean} options.no_state do not return state information - * @param {Boolean} options.no_id do not return ID - * @param {Boolean} options.no_children do not include children - * @param {Boolean} options.no_data do not include node data - * @param {Boolean} options.flat return flat JSON instead of nested - * @return {Object} + /** + * gets a JSON representation of a node (or the whole tree) + * @name get_json([obj, options]) + * @param {mixed} obj + * @param {Object} options + * @param {Boolean} options.no_state do not return state information + * @param {Boolean} options.no_id do not return ID + * @param {Boolean} options.no_children do not include children + * @param {Boolean} options.no_data do not include node data + * @param {Boolean} options.flat return flat JSON instead of nested + * @return {Object} */ get_json: (obj?: any, options?: JSTreeGetJsonOptions) => any; - /** - * create a new node (do not confuse with load_node) - * @name create_node([obj, node, pos, callback, is_loaded]) - * @param {mixed} par the parent node (to create a root node use either "#" (string) or `null`) - * @param {mixed} node the data for the new node (a valid JSON object, or a simple string with the name) - * @param {mixed} pos the index at which to insert the node, "first" and "last" are also supported, default is "last" - * @param {Function} callback a function to be called once the node is created - * @param {Boolean} is_loaded internal argument indicating if the parent node was succesfully loaded - * @return {String} the ID of the newly create node - * @trigger model.jstree, create_node.jstree + /** + * create a new node (do not confuse with load_node) + * @name create_node([obj, node, pos, callback, is_loaded]) + * @param {mixed} par the parent node (to create a root node use either "#" (string) or `null`) + * @param {mixed} node the data for the new node (a valid JSON object, or a simple string with the name) + * @param {mixed} pos the index at which to insert the node, "first" and "last" are also supported, default is "last" + * @param {Function} callback a function to be called once the node is created + * @param {Boolean} is_loaded internal argument indicating if the parent node was succesfully loaded + * @return {String} the ID of the newly create node + * @trigger model.jstree, create_node.jstree */ create_node: (obj?: any, node?: any, pos?: any, callback?: any, is_loaded?: boolean) => string; - /** - * set the text value of a node - * @name rename_node(obj, val) - * @param {mixed} obj the node, you can pass an array to rename multiple nodes to the same name - * @param {String} val the new text value - * @return {Boolean} - * @trigger rename_node.jstree + /** + * set the text value of a node + * @name rename_node(obj, val) + * @param {mixed} obj the node, you can pass an array to rename multiple nodes to the same name + * @param {String} val the new text value + * @return {Boolean} + * @trigger rename_node.jstree */ rename_node: (obj: any, val: string) => boolean; - /** - * remove a node - * @name delete_node(obj) - * @param {mixed} obj the node, you can pass an array to delete multiple nodes - * @return {Boolean} - * @trigger delete_node.jstree, changed.jstree + /** + * remove a node + * @name delete_node(obj) + * @param {mixed} obj the node, you can pass an array to delete multiple nodes + * @return {Boolean} + * @trigger delete_node.jstree, changed.jstree */ delete_node: (obj: any) => boolean; - /** - * get the last error - * @name last_error() - * @return {Object} + /** + * get the last error + * @name last_error() + * @return {Object} */ last_error: () => any; - /** - * move a node to a new parent - * @name move_node(obj, par [, pos, callback, is_loaded]) - * @param {mixed} obj the node to move, pass an array to move multiple nodes - * @param {mixed} par the new parent - * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0` - * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position - * @param {Boolean} internal parameter indicating if the parent node has been loaded - * @trigger move_node.jstree + /** + * move a node to a new parent + * @name move_node(obj, par [, pos, callback, is_loaded]) + * @param {mixed} obj the node to move, pass an array to move multiple nodes + * @param {mixed} par the new parent + * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0` + * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position + * @param {Boolean} internal parameter indicating if the parent node has been loaded + * @trigger move_node.jstree */ move_node: (obj: any, par: any, pos?: any, callback?: any, internal?: boolean) => void; - /** - * copy a node to a new parent - * @name copy_node(obj, par [, pos, callback, is_loaded]) - * @param {mixed} obj the node to copy, pass an array to copy multiple nodes - * @param {mixed} par the new parent - * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0` - * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position - * @param {Boolean} internal parameter indicating if the parent node has been loaded - * @trigger model.jstree copy_node.jstree + /** + * copy a node to a new parent + * @name copy_node(obj, par [, pos, callback, is_loaded]) + * @param {mixed} obj the node to copy, pass an array to copy multiple nodes + * @param {mixed} par the new parent + * @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0` + * @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position + * @param {Boolean} internal parameter indicating if the parent node has been loaded + * @trigger model.jstree copy_node.jstree */ copy_node: (obj: any, par: any, pos?: any, callback?: any, internal?: boolean) => void; - /** - * cut a node (a later call to `paste(obj)` would move the node) - * @name cut(obj) - * @param {mixed} obj multiple objects can be passed using an array - * @trigger cut.jstree + /** + * cut a node (a later call to `paste(obj)` would move the node) + * @name cut(obj) + * @param {mixed} obj multiple objects can be passed using an array + * @trigger cut.jstree */ cut: (obj: any) => void; - /** - * copy a node (a later call to `paste(obj)` would copy the node) - * @name copy(obj) - * @param {mixed} obj multiple objects can be passed using an array - * @trigger copy.jstre + /** + * copy a node (a later call to `paste(obj)` would copy the node) + * @name copy(obj) + * @param {mixed} obj multiple objects can be passed using an array + * @trigger copy.jstre */ copy: (obj: any) => void; - /** - * get the current buffer (any nodes that are waiting for a paste operation) - * @name get_buffer() - * @return {Object} an object consisting of `mode` ("copy_node" or "move_node"), `node` (an array of objects) and `inst` (the instance) + /** + * get the current buffer (any nodes that are waiting for a paste operation) + * @name get_buffer() + * @return {Object} an object consisting of `mode` ("copy_node" or "move_node"), `node` (an array of objects) and `inst` (the instance) */ get_buffer: () => any; - /** - * check if there is something in the buffer to paste - * @name can_paste() - * @return {Boolean} + /** + * check if there is something in the buffer to paste + * @name can_paste() + * @return {Boolean} */ can_paste: () => boolean; - /** - * copy or move the previously cut or copied nodes to a new parent - * @name paste(obj [, pos]) - * @param {mixed} obj the new parent - * @param {mixed} pos the position to insert at (besides integer, "first" and "last" are supported), defaults to integer `0` - * @trigger paste.jstree + /** + * copy or move the previously cut or copied nodes to a new parent + * @name paste(obj [, pos]) + * @param {mixed} obj the new parent + * @param {mixed} pos the position to insert at (besides integer, "first" and "last" are supported), defaults to integer `0` + * @trigger paste.jstree */ paste: (obj: any) => void; - /** - * put a node in edit mode (input field to rename the node) - * @name edit(obj [, default_text]) - * @param {mixed} obj - * @param {String} default_text the text to populate the input with (if omitted the node text value is used) + /** + * put a node in edit mode (input field to rename the node) + * @name edit(obj [, default_text]) + * @param {mixed} obj + * @param {String} default_text the text to populate the input with (if omitted the node text value is used) */ edit: (obj: any, default_text?: string) => void; - /** - * changes the theme - * @name set_theme(theme_name [, theme_url]) - * @param {String} theme_name the name of the new theme to apply - * @param {mixed} theme_url the location of the CSS file for this theme. Omit or set to `false` - * if you manually included the file. Set to `true` to autoload from the `core.themes.dir` directory. - * @trigger set_theme.jstree + /** + * changes the theme + * @name set_theme(theme_name [, theme_url]) + * @param {String} theme_name the name of the new theme to apply + * @param {mixed} theme_url the location of the CSS file for this theme. Omit or set to `false` + * if you manually included the file. Set to `true` to autoload from the `core.themes.dir` directory. + * @trigger set_theme.jstree */ set_theme: (theme_name: string, theme_url?: any) => void; - /** - * gets the name of the currently applied theme name - * @name get_theme() - * @return {String} + /** + * gets the name of the currently applied theme name + * @name get_theme() + * @return {String} */ get_theme: () => string; - /** - * changes the theme variant (if the theme has variants) - * @name set_theme_variant(variant_name) - * @param {String|Boolean} variant_name the variant to apply (if `false` is used the current variant is removed) + /** + * changes the theme variant (if the theme has variants) + * @name set_theme_variant(variant_name) + * @param {String|Boolean} variant_name the variant to apply (if `false` is used the current variant is removed) */ set_theme_variant: (variant_name: any) => void; - /** - * gets the name of the currently applied theme variant - * @name get_theme() - * @return {String} + /** + * gets the name of the currently applied theme variant + * @name get_theme() + * @return {String} */ get_theme_variant: () => string; - /** - * shows a striped background on the container (if the theme supports it) - * @name show_stripes() + /** + * shows a striped background on the container (if the theme supports it) + * @name show_stripes() */ show_stripes: () => void; - /** - * hides the striped background on the container - * @name hide_stripes() + /** + * hides the striped background on the container + * @name hide_stripes() */ hide_stripes: () => void; - /** - * toggles the striped background on the container - * @name toggle_stripes() + /** + * toggles the striped background on the container + * @name toggle_stripes() */ toggle_stripes: () => void; - /** - * shows the connecting dots (if the theme supports it) - * @name show_dots() + /** + * shows the connecting dots (if the theme supports it) + * @name show_dots() */ show_dots: () => void; - /** - * hides the connecting dots - * @name hide_dots() + /** + * hides the connecting dots + * @name hide_dots() */ hide_dots: () => void; - /** - * toggles the connecting dots - * @name toggle_dots() + /** + * toggles the connecting dots + * @name toggle_dots() */ toggle_dots: () => void; - /** - * show the node icons - * @name show_icons() + /** + * show the node icons + * @name show_icons() */ show_icons: () => void; - /** - * hide the node icons - * @name hide_icons() + /** + * hide the node icons + * @name hide_icons() */ hide_icons: () => void; - /** - * toggle the node icons - * @name toggle_icons() + /** + * toggle the node icons + * @name toggle_icons() */ toggle_icons: () => void; - /** - * set the node icon for a node - * @name set_icon(obj, icon) - * @param {mixed} obj - * @param {String} icon the new icon - can be a path to an icon or a className, - * if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class + /** + * set the node icon for a node + * @name set_icon(obj, icon) + * @param {mixed} obj + * @param {String} icon the new icon - can be a path to an icon or a className, + * if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class */ set_icon: (obj: any, icon: string) => void; - /** - * get the node icon for a node - * @name get_icon(obj) - * @param {mixed} obj - * @return {String} + /** + * get the node icon for a node + * @name get_icon(obj) + * @param {mixed} obj + * @return {String} */ get_icon: (obj: any) => string; - /** - * hide the icon on an individual node - * @name hide_icon(obj) - * @param {mixed} obj + /** + * hide the icon on an individual node + * @name hide_icon(obj) + * @param {mixed} obj */ hide_icon: (obj: any) => void; - /** - * show the icon on an individual node - * @name show_icon(obj) - * @param {mixed} obj + /** + * show the icon on an individual node + * @name show_icon(obj) + * @param {mixed} obj */ show_icon: (obj: any) => void; /** @@ -986,96 +1009,96 @@ interface JSTree extends JQuery { redraw_node: (obj: any, deep:boolean, is_callback:boolean) => any; activate_node: (obj: any, e: any) => any; - /** - * show the node checkbox icons - * @name show_checkboxes() - * @plugin checkbox + /** + * show the node checkbox icons + * @name show_checkboxes() + * @plugin checkbox */ show_checkboxes: () => void; - /** - * hide the node checkbox icons - * @name hide_checkboxes() - * @plugin checkbox + /** + * hide the node checkbox icons + * @name hide_checkboxes() + * @plugin checkbox */ hide_checkboxes: () => void; - /** - * toggle the node icons - * @name toggle_checkboxes() - * @plugin checkbox + /** + * toggle the node icons + * @name toggle_checkboxes() + * @plugin checkbox */ toggle_checkboxes: () => void; /** * context menu plugin */ teardown: () => void; - /** - * prepare and show the context menu for a node - * @name show_contextmenu(obj [, x, y]) - * @param {mixed} obj the node - * @param {Number} x the x-coordinate relative to the document to show the menu at - * @param {Number} y the y-coordinate relative to the document to show the menu at - * @param {Object} e the event if available that triggered the contextmenu - * @plugin contextmenu - * @trigger show_contextmenu.jstree + /** + * prepare and show the context menu for a node + * @name show_contextmenu(obj [, x, y]) + * @param {mixed} obj the node + * @param {Number} x the x-coordinate relative to the document to show the menu at + * @param {Number} y the y-coordinate relative to the document to show the menu at + * @param {Object} e the event if available that triggered the contextmenu + * @plugin contextmenu + * @trigger show_contextmenu.jstree */ show_contextmenu: (obj: any, x?: number, y?: number, e?:any) => void; - /** - * used to search the tree nodes for a given string - * @name search(str [, skip_async]) - * @param {String} str the search string - * @param {Boolean} skip_async if set to true server will not be queried even if configured - * @plugin search - * @trigger search.jstree + /** + * used to search the tree nodes for a given string + * @name search(str [, skip_async]) + * @param {String} str the search string + * @param {Boolean} skip_async if set to true server will not be queried even if configured + * @plugin search + * @trigger search.jstree */ search: (str: string, skip_async?: boolean) => void; - /** - * used to clear the last search (removes classes and shows all nodes if filtering is on) - * @name clear_search() - * @plugin search - * @trigger clear_search.jstree + /** + * used to clear the last search (removes classes and shows all nodes if filtering is on) + * @name clear_search() + * @plugin search + * @trigger clear_search.jstree */ clear_search: () => void; - /** - * save the state - * @name save_state() - * @plugin state + /** + * save the state + * @name save_state() + * @plugin state */ save_state: () => void; - /** - * restore the state from the user's computer - * @name restore_state() - * @plugin state + /** + * restore the state from the user's computer + * @name restore_state() + * @plugin state */ restore_state: () => void; - /** - * clear the state on the user's computer - * @name clear_state() - * @plugin state + /** + * clear the state on the user's computer + * @name clear_state() + * @plugin state */ clear_state: () => void; - /** - * used to retrieve the type settings object for a node - * @name get_rules(obj) - * @param {mixed} obj the node to find the rules for - * @return {Object} - * @plugin types + /** + * used to retrieve the type settings object for a node + * @name get_rules(obj) + * @param {mixed} obj the node to find the rules for + * @return {Object} + * @plugin types */ get_rules: (obj: any) => any; - /** - * used to retrieve the type string or settings object for a node - * @name get_type(obj [, rules]) - * @param {mixed} obj the node to find the rules for - * @param {Boolean} rules if set to `true` instead of a string the settings object will be returned - * @return {String|Object} - * @plugin types + /** + * used to retrieve the type string or settings object for a node + * @name get_type(obj [, rules]) + * @param {mixed} obj the node to find the rules for + * @param {Boolean} rules if set to `true` instead of a string the settings object will be returned + * @return {String|Object} + * @plugin types */ get_type: (obj: any, rules?: any) => any; - /** - * used to change a node's type - * @name set_type(obj, type) - * @param {mixed} obj the node to change - * @param {String} type the new type - * @plugin types + /** + * used to change a node's type + * @name set_type(obj, type) + * @param {mixed} obj the node to change + * @param {String} type the new type + * @plugin types */ set_type: (obj: any, type: string) => any; //bind(eventType: string, handler?: (event: any, data: JSTreeBindOptions) => any): JSTree; diff --git a/kolite/kolite-tests.ts b/kolite/kolite-tests.ts index f2013241d8..4306ede537 100644 --- a/kolite/kolite-tests.ts +++ b/kolite/kolite-tests.ts @@ -30,6 +30,22 @@ function test_asyncCommand() { }); } +function test_asyncCommand_isExecuting() { + var primaryCommand = ko.asyncCommand({ + execute: (complete) => { + $.when().always(complete); + }, + canExecute: (isExecuting) => { + return !isExecuting; + } + }); + + var firstRun = true; + var canCancel = ko.computed(() => { + return firstRun && !primaryCommand.isExecuting(); + }); +} + function test_dirtyFlag() { var viewModel; viewModel.dirtyFlag = new ko.DirtyFlag(viewModel.model); diff --git a/kolite/kolite.d.ts b/kolite/kolite.d.ts index 42efda4a94..4aa55fd817 100644 --- a/kolite/kolite.d.ts +++ b/kolite/kolite.d.ts @@ -58,6 +58,10 @@ interface KoliteCommand { execute(...args: any[]): any; } +interface KoliteAsyncCommand extends KoliteCommand { + isExecuting: KnockoutObservable; +} + interface KoLiteCommandOptions { execute?: any; canExecute?: (isExecuting: boolean) => any; @@ -65,7 +69,7 @@ interface KoLiteCommandOptions { interface KnockoutStatic { command(options: KoLiteCommandOptions): KoliteCommand; - asyncCommand(optons: KoLiteCommandOptions): KoliteCommand; + asyncCommand(optons: KoLiteCommandOptions): KoliteAsyncCommand; } interface KnockoutUtils { diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 953d32d379..d58368b794 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -183,6 +183,14 @@ result = _.first([1, 2, 3], function (num) { result = _.first(foodsOrganic, 'organic'); result = _.first(foodsType, { 'type': 'fruit' }); +result = _([1, 2, 3]).first(); +result = _([1, 2, 3]).first(2).value(); +result = _([1, 2, 3]).first(function (num) { + return num < 3; +}).value(); +result = _(foodsOrganic).first('organic').value(); +result = _(foodsType).first({ 'type': 'fruit' }).value(); + result = _.head([1, 2, 3]); result = _.head([1, 2, 3], 2); result = _.head([1, 2, 3], function (num) { @@ -191,12 +199,28 @@ result = _.head([1, 2, 3], function (num) { result = _.head(foodsOrganic, 'organic'); result = _.head(foodsType, { 'type': 'fruit' }); +result = _([1, 2, 3]).head(); +result = _([1, 2, 3]).head(2).value(); +result = _([1, 2, 3]).head(function (num) { + return num < 3; +}).value(); +result = _(foodsOrganic).head('organic').value(); +result = _(foodsType).head({ 'type': 'fruit' }).value(); + result = _.take([1, 2, 3]); result = _.take([1, 2, 3], 2); result = _.take([1, 2, 3], (num) => num < 3); result = _.take(foodsOrganic, 'organic'); result = _.take(foodsType, { 'type': 'fruit' }); +result = _([1, 2, 3]).take(); +result = _([1, 2, 3]).take(2).value(); +result = _([1, 2, 3]).take(function (num) { + return num < 3; +}).value(); +result = _(foodsOrganic).take('organic').value(); +result = _(foodsType).take({ 'type': 'fruit' }).value(); + result = _.flatten([1, [2], [3, [[4]]]]); result = _.flatten([1, [2], [3, [[4]]]], true); var result: any @@ -277,6 +301,22 @@ result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); result = <{ x: number; }[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +result = _([1, 2, 1, 3, 1]).uniq().value(); +result = _([1, 1, 2, 2, 3]).uniq(true).value(); +result = _(['A', 'b', 'C', 'a', 'B', 'c']).uniq(function (letter) { + return letter.toLowerCase(); +}).value(); +result = _([1, 2.5, 3, 1.5, 2, 3.5]).uniq(function (num) { return this.floor(num); }, Math).value(); +result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).uniq('x').value(); + +result = _([1, 2, 1, 3, 1]).unique().value(); +result = _([1, 1, 2, 2, 3]).unique(true).value(); +result = _(['A', 'b', 'C', 'a', 'B', 'c']).unique(function (letter) { + return letter.toLowerCase(); +}).value(); +result = _([1, 2.5, 3, 1.5, 2, 3.5]).unique(function (num) { return this.floor(num); }, Math).value(); +result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').value(); + result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); result = _.zip(['moe', 'larry'], [30, 40], [true, false]); @@ -357,9 +397,11 @@ result = _.findLast(foodsCombined, 'organic'); result = _.forEach([1, 2, 3], function (num) { console.log(num); }); result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); +result = _.forEach({ name: 'apple', type: 'fruit' }, function (value, key) { console.log(value, key) }); result = _.each([1, 2, 3], function (num) { console.log(num); }); result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); +result = _.each({ name: 'apple', type: 'fruit' }, function (value, key) { console.log(value, key) }); result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEach(function (num) { console.log(num); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); }); @@ -419,16 +461,18 @@ result = _.min(stoogesAges, function (stooge) { return stooge.age; result = _.min(stoogesAges, 'age'); result = _.pluck(stoogesAges, 'name'); +result = _(stoogesAges).pluck('name').value(); -result = _.reduce([1, 2, 3], function (sum: number, num: number) { - return sum + num; -}); interface ABC { [index: string]: number; a: number; b: number; c: number; } + +result = _.reduce([1, 2, 3], function (sum: number, num: number) { + return sum + num; +}); result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num: number, key: string) { r[key] = num * 3; return r; @@ -450,6 +494,30 @@ result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num: number return r; }, {}); +result = _([1, 2, 3]).reduce(function (sum: number, num: number) { + return sum + num; +}); +result = _({ 'a': 1, 'b': 2, 'c': 3 }).reduce(function (r: ABC, num: number, key: string) { + r[key] = num * 3; + return r; +}, {}); + +result = _([1, 2, 3]).foldl(function (sum: number, num: number) { + return sum + num; +}); +result = _({ 'a': 1, 'b': 2, 'c': 3 }).foldl(function (r: ABC, num: number, key: string) { + r[key] = num * 3; + return r; +}, {}); + +result = _([1, 2, 3]).inject(function (sum: number, num: number) { + return sum + num; +}); +result = _({ 'a': 1, 'b': 2, 'c': 3 }).inject(function (r: ABC, num: number, key: string) { + r[key] = num * 3; + return r; +}, {}); + result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); result = _.foldr([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); @@ -457,6 +525,10 @@ result = _.reject([1, 2, 3, 4, 5, 6], function (num) { return num % 2 result = _.reject(foodsCombined, 'organic'); result = _.reject(foodsCombined, { 'type': 'fruit' }); +result = _([1, 2, 3, 4, 5, 6]).reject(function (num) { return num % 2 == 0; }).value(); +result = _(foodsCombined).reject('organic').value(); +result = _(foodsCombined).reject({ 'type': 'fruit' }).value(); + result = _.sample([1, 2, 3, 4]); result = _.sample([1, 2, 3, 4], 2); @@ -469,20 +541,29 @@ result = _.size('curly'); result = _.some([null, 0, 'yes', false], Boolean); result = _.some(foodsCombined, 'organic'); result = _.some(foodsCombined, { 'type': 'meat' }); +result = _.some(foodsOrganic[0]); result = _.any([null, 0, 'yes', false], Boolean); result = _.any(foodsCombined, 'organic'); result = _.any(foodsCombined, { 'type': 'meat' }); +result = _.any(foodsOrganic[0]); result = _.sortBy([1, 2, 3], function (num) { return Math.sin(num); }); result = _.sortBy([1, 2, 3], function (num) { return this.sin(num); }, Math); result = _.sortBy(['banana', 'strawberry', 'apple'], 'length'); +result = _([1, 2, 3]).sortBy(function (num) { return Math.sin(num); }).value(); +result = _([1, 2, 3]).sortBy(function (num) { return this.sin(num); }, Math).value(); +result = _(['banana', 'strawberry', 'apple']).sortBy('length').value(); + (function (a: number, b: number, c: number, d: number) { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); result = _.where(stoogesCombined, { 'age': 40 }); result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); +result = _(stoogesCombined).where({ 'age': 40 }).value(); +result = _(stoogesCombined).where({ 'quotes': ['Poifect!'] }).value(); + /************* * Functions * *************/ @@ -832,6 +913,7 @@ result = _.isString('moe'); result = _.isUndefined(void 0); result = _.keys({ 'one': 1, 'two': 2, 'three': 3 }); +result = _({ 'one': 1, 'two': 2, 'three': 3 }).keys().value(); var mergeNames = { 'stooges': [ @@ -877,8 +959,14 @@ result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); result = _.omit({ 'name': 'moe', 'age': 40 }, function (value) { return typeof value == 'number'; }); +result = _({ 'name': 'moe', 'age': 40 }).omit('age').value(); +result = _({ 'name': 'moe', 'age': 40 }).omit(['age']).value(); +result = _({ 'name': 'moe', 'age': 40 }).omit(function (value) { + return typeof value == 'number'; +}).value(); result = _.pairs({ 'moe': 30, 'larry': 40 }); +result = _({ 'moe': 30, 'larry': 40 }).pairs().value(); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index cf227c25e5..e51a598252 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -644,6 +644,104 @@ declare module _ { whereValue: W): T[]; } + interface LoDashArrayWrapper { + /** + * @see _.first + **/ + first(): T; + + /** + * @see _.first + * @param n The number of elements to return. + **/ + first(n: number): LoDashArrayWrapper; + + /** + * @see _.first + * @param callback The function called per element. + * @param [thisArg] The this binding of callback. + **/ + first( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.first + * @param pluckValue "_.pluck" style callback value + **/ + first(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.first + * @param whereValue "_.where" style callback value + **/ + first(whereValue: W): LoDashArrayWrapper; + + /** + * @see _.first + **/ + head(): T; + + /** + * @see _.first + * @param n The number of elements to return. + **/ + head(n: number): LoDashArrayWrapper; + + /** + * @see _.first + * @param callback The function called per element. + * @param [thisArg] The this binding of callback. + **/ + head( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.first + * @param pluckValue "_.pluck" style callback value + **/ + head(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.first + * @param whereValue "_.where" style callback value + **/ + head(whereValue: W): LoDashArrayWrapper; + + /** + * @see _.first + **/ + take(): T; + + /** + * @see _.first + * @param n The number of elements to return. + **/ + take(n: number): LoDashArrayWrapper; + + /** + * @see _.first + * @param callback The function called per element. + * @param [thisArg] The this binding of callback. + **/ + take( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.first + * @param pluckValue "_.pluck" style callback value + **/ + take(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.first + * @param whereValue "_.where" style callback value + **/ + take(whereValue: W): LoDashArrayWrapper; + } + //_.flatten interface LoDashStatic { /** @@ -1750,6 +1848,106 @@ declare module _ { whereValue?: W): T[]; } + interface LoDashArrayWrapper { + /** + * @see _.uniq + **/ + uniq(isSorted?: boolean): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + uniq( + isSorted: boolean, + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + uniq( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + isSorted: boolean, + pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + isSorted: boolean, + whereValue: W): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + whereValue: W): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + unique(isSorted?: boolean): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + unique( + isSorted: boolean, + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + unique( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + isSorted: boolean, + pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + isSorted: boolean, + whereValue: W): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + whereValue: W): LoDashArrayWrapper; + } + //_.without interface LoDashStatic { /** @@ -2741,6 +2939,14 @@ declare module _ { callback: ObjectIterator, thisArg?: any): Dictionary; + /** + * @see _.each + **/ + forEach( + object: T, + callback: ObjectIterator, + thisArg?: any): T + /** * @see _.forEach **/ @@ -2767,6 +2973,14 @@ declare module _ { object: Dictionary, callback: ObjectIterator, thisArg?: any): Dictionary; + + /** + * @see _.each + **/ + each( + object: T, + callback: ObjectIterator, + thisArg?: any): T } interface LoDashArrayWrapper { @@ -3444,6 +3658,22 @@ declare module _ { property: string): any[]; } + interface LoDashArrayWrapper { + /** + * @see _.pluck + **/ + pluck( + property: string): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.pluck + **/ + pluck( + property: string): LoDashArrayWrapper; + } + //_.reduce interface LoDashStatic { /** @@ -3609,6 +3839,100 @@ declare module _ { thisArg?: any): TResult; } + interface LoDashArrayWrapper { + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + thisArg?: any): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + thisArg?: any): TResult; + } + //_.reduceRight interface LoDashStatic { /** @@ -3806,6 +4130,27 @@ declare module _ { whereValue: W): T[]; } + interface LoDashArrayWrapper { + /** + * @see _.reject + **/ + reject( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.reject + * @param pluckValue _.pluck style callback + **/ + reject(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.reject + * @param whereValue _.where style callback + **/ + reject(whereValue: W): LoDashArrayWrapper; + } + //_.sample interface LoDashStatic { /** @@ -3933,6 +4278,14 @@ declare module _ { callback?: ListIterator, thisArg?: any): boolean; + /** + * @see _.some + **/ + some( + collection: {}, + callback?: ListIterator<{}, boolean>, + thisArg?: any): boolean; + /** * @see _.some * @param pluckValue _.pluck style callback @@ -4005,6 +4358,14 @@ declare module _ { callback?: ListIterator, thisArg?: any): boolean; + /** + * @see _.some + **/ + any( + collection: {}, + callback?: ListIterator<{}, boolean>, + thisArg?: any): boolean; + /** * @see _.some * @param pluckValue _.pluck style callback @@ -4118,6 +4479,27 @@ declare module _ { whereValue: W): T[]; } + interface LoDashArrayWrapper { + /** + * @see _.sortBy + **/ + sortBy( + callback?: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.sortBy + * @param pluckValue _.pluck style callback + **/ + sortBy(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.sortBy + * @param whereValue _.where style callback + **/ + sortBy(whereValue: W): LoDashArrayWrapper; + } + //_.toArray interface LoDashStatic { /** @@ -4166,6 +4548,13 @@ declare module _ { properties: U): T[]; } + interface LoDashArrayWrapper { + /** + * @see _.where + **/ + where(properties: U): LoDashArrayWrapper; + } + /************* * Functions * *************/ @@ -5280,6 +5669,13 @@ declare module _ { keys(object: any): string[]; } + interface LoDashObjectWrapper { + /** + * @see _.keys + **/ + keys(): LoDashArrayWrapper + } + //_.mapValues interface LoDashStatic { /** @@ -5391,6 +5787,27 @@ declare module _ { thisArg?: any): Omitted; } + interface LoDashObjectWrapper { + /** + * @see _.omit + **/ + omit( + ...keys: string[]): LoDashObjectWrapper; + + /** + * @see _.omit + **/ + omit( + keys: string[]): LoDashObjectWrapper; + + /** + * @see _.omit + **/ + omit( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper; + } + //_.pairs interface LoDashStatic { /** @@ -5402,6 +5819,13 @@ declare module _ { pairs(object: any): any[][]; } + interface LoDashObjectWrapper { + /** + * @see _.pairs + **/ + pairs(): LoDashArrayWrapper; + } + //_.picks interface LoDashStatic { /** diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index f29b3f3bf1..763c1e7fb0 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -269,8 +269,8 @@ function Sys_CancelEventArgs_Tests() { } var ActivateAlertDiv = function (visString: string, msg: string) { - var adiv = $get(divElem); - var aspan = $get(messageElem); + var adiv = $get(divElem); + var aspan = $get(messageElem); adiv.style.visibility = visString; aspan.innerHTML = msg; } @@ -338,20 +338,20 @@ function Sys_Component_Tests() { function Sys_UI_Key_Tests() { - var backspace = Sys.UI.Key.backspace; - var del = Sys.UI.Key.del; - var down = Sys.UI.Key.down; - var end = Sys.UI.Key.end; - var pageDown = Sys.UI.Key.pageDown; - var pageUp = Sys.UI.Key.pageUp; - var home = Sys.UI.Key.home; - var enter = Sys.UI.Key.enter; - var esc = Sys.UI.Key.esc; - var tab = Sys.UI.Key.tab; - var key = Sys.UI.Key.up; - var left = Sys.UI.Key.left; - var right = Sys.UI.Key.right; - var space = Sys.UI.Key.space; + var backspace: number = Sys.UI.Key.backspace; + var del: number = Sys.UI.Key.del; + var down: number = Sys.UI.Key.down; + var end: number = Sys.UI.Key.end; + var pageDown: number = Sys.UI.Key.pageDown; + var pageUp: number = Sys.UI.Key.pageUp; + var home: number = Sys.UI.Key.home; + var enter: number = Sys.UI.Key.enter; + var esc: number = Sys.UI.Key.esc; + var tab: number = Sys.UI.Key.tab; + var key: number = Sys.UI.Key.up; + var left: number = Sys.UI.Key.left; + var right: number = Sys.UI.Key.right; + var space: number = Sys.UI.Key.space; } @@ -372,6 +372,117 @@ function Sys_UI_Control_Tests() { a.dispose(); } +function Sy_UI_Point_Tests() { + + var elementRef: Sys.UI.DomElement; + var result: string; + // Get the location of the element + var elementLoc = Sys.UI.DomElement.getLocation(elementRef); + result += "Before move - Label1 location (x,y) = (" + + elementLoc.x + "," + elementLoc.y + ")
    "; + // Move the element + Sys.UI.DomElement.setLocation(elementRef, 100, elementLoc.y); + elementLoc = Sys.UI.DomElement.getLocation(elementRef); + result += "After move - Label1 location (x,y) = (" + + elementLoc.x + "," + elementLoc.y + ")
    "; + +} + +function Sys_UI_DomEvent_Tests() { + + var object: any; + + Sys.UI.DomEvent.addHandler(object, "eventName", () => { }); + Sys.UI.DomEvent.addHandler(object, "eventName", () => { }, true); + + Sys.UI.DomEvent.addHandlers(object, object, object, true); + Sys.UI.DomEvent.removeHandler(object, "eventName", () => { }); + Sys.UI.DomEvent.clearHandlers(object); + + var domEvent = new Sys.UI.DomEvent(object); + var altKey: boolean = domEvent.altKey; + var mouseButton: Sys.UI.MouseButton = domEvent.button; + var charCode: number = domEvent.charCode; + var clientX: number = domEvent.clientX; + var ctrlKey: boolean = domEvent.ctrlKey; + var screenX: number = domEvent.screenX; + var screenY: number = domEvent.screenY; + var target: any = domEvent.target; + var shiftKey: boolean = domEvent.shiftKey; + var type: string = domEvent.type; +} + +function Sys_UI_DomElement_Tests() { + + // Add CSS class + Sys.UI.DomElement.addCssClass($get("Button1"), "redBackgroundColor"); + + var elementRef: Sys.UI.DomElement = $get("Label1"); + var elementBounds = Sys.UI.DomElement.getBounds(elementRef); + var toggleCssClassMethod = () => {}; + var removeCssClassMethod = () => {}; + var containsClass = Sys.UI.DomElement.containsCssClass(elementRef, "class-name"); + + // Add handler using the getElementById method + $addHandler(Sys.UI.DomElement.getElementById("Button1"), "click", toggleCssClassMethod); + // Add handler using the shortcut to the getElementById method + $addHandler($get("Button2"), "click", removeCssClassMethod); + + Sys.UI.DomElement.toggleCssClass($get("id"), "redBackgroundColor"); + + + // Add handlers using the $get shortcut to the + // Sys.UI.DomElement.getElementById method + $addHandler($get("Button1"), "click", toggleVisible); + $addHandler($get("Button2"), "click", toggleVisibilityMode); + + // This method is called when Button2 is clicked. + function toggleVisible() { + var anElement = $get("Label1"); + if (Sys.UI.DomElement.getVisible(anElement)) { + Sys.UI.DomElement.setVisible(anElement, false); + } + else { + Sys.UI.DomElement.setVisible(anElement, true); + } + } + + // This method is called when Button1 is clicked. + function toggleVisibilityMode() { + + var anElement = $get("Label1"); + + var visMode = Sys.UI.DomElement.getVisibilityMode(anElement); + + var status = visMode; + + if (visMode === 0) { + Sys.UI.DomElement.setVisibilityMode(anElement, Sys.UI.VisibilityMode.collapse); + if (document.all) { + anElement.innerText = + "Label1 VisibilityMode: Sys.UI.VisibilityMode.collapse"; + } + else { + //Firefox + anElement.textContent = + "Label1 VisibilityMode: Sys.UI.VisibilityMode.collapse"; + } + } + else { + Sys.UI.DomElement.setVisibilityMode(anElement, Sys.UI.VisibilityMode.hide); + if (document.all) { + anElement.innerText = "Label1 VisibilityMode: Sys.UI.VisibilityMode.hide"; + } + else { + //Firefox + anElement.textContent = "Label1 VisibilityMode: Sys.UI.VisibilityMode.hide"; + } + } + } + + +} + function Sys_Debug_Tests() { var condition = true; @@ -519,22 +630,52 @@ function Sys_Net_WebRequestManager_Tests() { function Sys_WebForms_PageRequestManager_Tests() { - var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); + var pageRequestManager: Sys.WebForms.PageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); - var eventArgs = pageRequestManager.Empty; + var beginRequestHandler = (sender: any, args: Sys.WebForms.BeginRequestEventArgs) => { + var postBackElement: HTMLElement = args.get_postBackElement(); + var webRequest: Sys.Net.WebRequest = args.get_request(); + var updatePanelsToUpdate: string[] = args.get_updatePanelsToUpdate(); + var empty: Sys.EventArgs = args.Empty; + } + var endRequestHandler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => { + var dataItems: any = args.get_dataItems(); + var error: Error = args.get_error(); + var errorHandled: boolean = args.get_errorHandled(); + var webRequestExecutor: Sys.Net.WebRequestExecutor = args.get_response(); + args.set_errorHandled(true); - var handler = (sender: any, args: any) => { } + } + var initializeRequestHandler = (sender: any, args: Sys.WebForms.InitializeRequestEventArgs) => { + var postBackElement: HTMLElement = args.get_postBackElement(); + var webRequestExecutor: Sys.Net.WebRequestExecutor = args.get_request(); + var updatePanelsToUpdate: string[] = args.get_updatePanelsToUpdate(); + var empty: Sys.EventArgs = args.Empty; + } + var pageLoadedRequestHandler = (sender: any, args: Sys.WebForms.PageLoadedEventArgs) => { + var dataItems: any = args.get_dataItems(); + var panelsCreated: HTMLDivElement[] = args.get_panelsCreated(); + var panelsUpdated: HTMLDivElement[] = args.get_panelsUpdated(); + var empty: Sys.EventArgs = args.Empty; + } + var pageLoadingRequestHandler = (sender: any, args: Sys.WebForms.PageLoadingEventArgs) => { + var dataItems: any = args.get_dataItems(); + var panelsDeleted: HTMLDivElement[] = args.get_panelsDeleted(); + var panelsUpdating = args.get_panelsUpdating(); + var empty: Sys.EventArgs = args.Empty; + } - var isInAsyncPostBack = pageRequestManager.get_isInAsyncPostBack(); + + var isInAsyncPostBack: boolean = pageRequestManager.get_isInAsyncPostBack(); - pageRequestManager.add_beginRequest(handler); - pageRequestManager.add_endRequest(handler); - pageRequestManager.add_initializeRequest(handler); - pageRequestManager.add_pageLoading(handler); - pageRequestManager.add_pageLoaded(handler); - pageRequestManager.remove_beginRequest(handler); - pageRequestManager.remove_pageLoaded(handler); - pageRequestManager.remove_pageLoading(handler); + pageRequestManager.add_beginRequest(beginRequestHandler); + pageRequestManager.add_endRequest(endRequestHandler); + pageRequestManager.add_initializeRequest(initializeRequestHandler); + pageRequestManager.add_pageLoading(pageLoadingRequestHandler); + pageRequestManager.add_pageLoaded(pageLoadedRequestHandler); + pageRequestManager.remove_beginRequest(beginRequestHandler); + pageRequestManager.remove_pageLoaded(pageLoadedRequestHandler); + pageRequestManager.remove_pageLoading(pageLoadingRequestHandler); pageRequestManager.beginAsyncPostBack(); pageRequestManager.abortPostBack(); pageRequestManager.dispose(); @@ -542,19 +683,19 @@ function Sys_WebForms_PageRequestManager_Tests() { function Sys_WebForms_EndRequestEventArgs_Tests() { - var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); + var pageRequestManager: Sys.WebForms.PageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); var handler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => { - var error = args.get_error(); - var message = error.message; - var name = error.name; - var response = args.get_response(); - var dataItems = args.get_dataItems(); - var eventArgs = args.Empty; + var error: Error = args.get_error(); + var message: string = error.message; + var name: string = error.name; + var response: Sys.Net.WebRequestExecutor = args.get_response(); + var dataItems: any = args.get_dataItems(); + var eventArgs: Sys.EventArgs = args.Empty; args.set_errorHandled(true); - var errorHandled = args.get_errorHandled(); + var errorHandled: boolean = args.get_errorHandled(); } pageRequestManager.add_endRequest(handler); diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 5dda0ae6cc..1c8968f440 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -326,7 +326,6 @@ interface Date { parseInvariant(value: string, ...formats: string[]): string; } - declare module MicrosoftAjaxBaseTypeExtensions { /** @@ -909,7 +908,7 @@ declare function $find(id: string, parent?: HTMLElement): Sys.Component; * @param handler The event handler to add. * @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. */ -declare function $addHandler(element: Element, eventName: string, handler: Function, autoRemove?: boolean): void; +declare function $addHandler(element: Sys.UI.DomElement, eventName: string, handler: Function, autoRemove?: boolean): void; /** * Provides a shortcut to the addHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -919,7 +918,7 @@ declare function $addHandler(element: Element, eventName: string, handler: Funct * @param handlerOwner (Optional) The object instance that is the context for the delegates that should be created from the handlers. * @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. */ -declare function $addHandlers(element: Element, events: any, handlerOwner?: any, autoRemove?: boolean): void; +declare function $addHandlers(element: Sys.UI.DomElement, events: any, handlerOwner?: any, autoRemove?: boolean): void; /** * Provides a shortcut to the clearHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -927,7 +926,7 @@ declare function $addHandlers(element: Element, events: any, handlerOwner?: any, * @see {@link http://msdn.microsoft.com/en-us/library/bb310959(v=vs.100).aspx} * @param The DOM element that exposes the events. */ -declare function $clearHandlers(element: Element): void; +declare function $clearHandlers(element: Sys.UI.DomElement): void; /** * Provides a shortcut to the getElementById method of the Sys.UI.DomElement class. This member is static and can be invoked without creating an instance of the class. @@ -937,9 +936,11 @@ declare function $clearHandlers(element: Element): void; * @param element * The parent element to search. The default is the document element. * @return -* The element +* The Sys.UI.DomElement */ -declare function $get(id: string, element?: Element): HTMLElement; +declare function $get(id: string): any; // Examples use HTMLElement and DomElement +declare function $get(id: string, element?: HTMLElement): HTMLElement; +declare function $get(id: string, element?: Sys.UI.DomElement): Sys.UI.DomElement; /** * Provides a shortcut to the removeHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -948,7 +949,9 @@ declare function $get(id: string, element?: Element): HTMLElement; * @param eventName The name of the DOM event. * @param handler The event handler to remove. */ -declare function $removeHandler(element: Element, eventName: string, handler: Function): void; +declare function $removeHandler(element: any, eventName: string, handler: Function): void; +declare function $removeHandler(element: HTMLElement, eventName: string, handler: Function): void; +declare function $removeHandler(element: Sys.UI.DomElement, eventName: string, handler: Function): void; //#endregion @@ -1384,7 +1387,7 @@ declare module Sys { * @param displayCaller * (Optional) true to indicate that the name of the function that is calling assert should be displayed in the message. The default is false. */ - static assert(condition: boolean, message?: string, displayCaller?: boolean): void; + static assert(condition: boolean, message?: string, displayCaller?: boolean): void; /** * Clears all trace messages from the trace console. */ @@ -2250,7 +2253,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb310823(v=vs.100).aspx} */ // Cannot create definitions for generated proxy classes. - + /** * Contains information about a Web request that is ready to be sent to the current Sys.Net.WebRequestExecutor instance. * This class represents the type for the second parameter of the callback function added by the add_invokingRequest method. @@ -2259,7 +2262,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397488(v=vs.100).aspx} */ class NetWorkRequestEventArgs { - + //#region Constructors /** @@ -2536,7 +2539,7 @@ declare module Sys { set_defaultTimeout(value: number): void; //#endregion - + } export var WebRequestManager: IWebRequestManager; @@ -3122,10 +3125,184 @@ declare module Sys { } /** * Defines static methods and properties that provide helper APIs for manipulating and inspecting DOM elements. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383788(v=vs.100).aspx} */ - class DomElement { - // todo + interface DomElement { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.UI.DomElement class. + */ + constructor(): void; + + //#endregion + + //#region Methods + + /** + * Adds a CSS class to a DOM element if the class is not already part of the DOM element. This member is static and can be invoked without creating an instance of the class. + * If the element does not support a CSS class, no change is made to the element. + * @param element + * The Sys.UI.DomElement object to add the CSS class to. + * @param className + * The name of the CSS class to add. + */ + addCssClass(element: Sys.UI.DomElement, className: string): void; + /** + * Gets a value that indicates whether the DOM element contains the specified CSS class. This member is static and can be invoked without creating an instance of the class. + * @param element + * The Sys.UI.DomElement object to test for the CSS class. + * @param className + * The name of the CSS class to test for. + * @return + * true if the element contains the specified CSS class; otherwise, false. + */ + containsCssClass(element: Sys.UI.DomElement, className: string): boolean; + /** + * Gets a set of integer coordinates that represent the position, width, and height of a DOM element. This member is static and can be invoked without creating an instance of the class. + * + * @param element + * The Sys.UI.DomElement instance to get the coordinates of. + * @return + * An object of the JavaScript type Object that contains the x-coordinate and y-coordinate of the upper-left corner, the width, and the height of the element in pixels. + */ + getBounds(element: Sys.UI.DomElement): Object; + /** + * @param id + * The ID of the element to find. + * @param element + * (optional) The parent element to search in. The default is the document element. + */ + getElementById(id: string): Sys.UI.DomElement; + getElementById(id: string, element?: Sys.UI.DomElement): Sys.UI.DomElement; + getElementById(id: string, element?: HTMLElement): HTMLElement; + getElementById(id: string, element: any): any; + /** + * Gets the absolute position of a DOM element relative to the upper-left corner of the owner frame or window. This member is static and can be invoked without creating an instance of the class. * + * @param element + * The target element. * + * @return + * An object of the JavaScript type Object that contains the x-coordinate and y-coordinate of the element in pixels. + */ + getLocation(element: Sys.UI.DomElement): Sys.UI.Point; + getLocation(element: any): Object; + /* + * Returns a value that represents the layout characteristics of a DOM element when it is hidden by invoking the Sys.UI.DomElement.setVisible method. This member is static and can be invoked without creating an instance of the class. + * @param element + * The target DOM element. + * @return + * A Sys.UI.VisibilityMode enumeration value that indicates the layout characteristics of element when it is hidden by invoking the setVisible method. + */ + getVisibilityMode(element: Sys.UI.DomElement): Sys.UI.VisibilityMode; + getVisibilityMode(element: any): Sys.UI.VisibilityMode; + /** + * Gets a value that indicates whether a DOM element is currently visible on the Web page. This member is static and can be invoked without creating an instance of the class. + * @param element + * The target DOM element. + * @return + * true if element is visible on the Web page; otherwise, false + */ + getVisible(element: any): boolean; + /** + * Determines whether the specified object is a DOM element. + * @param obj + * An object + * @return + * true if the object is a DOM element; otherwise, false. + */ + isDomElement(obj: any): boolean; + /** + * Raises a bubble event. A bubble event causes an event to be raised and then propagated up the control hierarchy until it is handled. + * @param source + * The DOM element that triggers the event. + * @param args + * The event arguments + */ + raiseBubbleEvent(source: Sys.UI.DomElement, args: EventArgs): void; + raiseBubbleEvent(source: any, args: any): void; + /** + * Removes a CSS class from a DOM element. This member is static and can be invoked without creating an instance of the class. If the element does not include a CSS class, no change is made to the element. + * @param element + * The Sys.UI.DomElement object to remove the CSS class from. + * @param className + * The name of the CSS class to remove. + */ + removeCssClass(element: Sys.UI.DomElement, className: string): void; + removeCssClass(element: HTMLElement, className: string): void; + removeCssClass(element: any, className: string): void; + /** + * Returns the element that has either the specified ID in the specified container, or is the specified element itself. + * The resolveElement method is used to verify that an ID or an object can be resolved as an element. * + * @param elementOrElementId + * The element to resolve, or the ID of the element to resolve. This parameter can be null. + * @param containerElement + * (Optional) The specified container. + * @return + * A DOM element. + */ + resolveElement(elementOrElementId: Sys.UI.DomElement, containerElement?: Sys.UI.DomElement): Sys.UI.DomElement; + resolveElement(elementOrElementId: HTMLElement, containerElement?: HTMLElement): HTMLElement; + resolveElement(elementOrElementId: string): any; + /** + * Sets the position of a DOM element. This member is static and can be invoked without creating an instance of the class. + * he left and top style attributes (upper-left corner) of an element specify the relative position of an element. + * The actual position will depend on the offsetParent property of the target element and the positioning mode of the element. * + * @param element The target element. + * @param x The x-coordinate in pixels. + * @param y The y-coordinate in pixels. + */ + setLocation(element: Sys.UI.DomElement, x: number, y: number): void; + setLocation(element: HTMLElement, x: number, y: number): void; + setLocation(element: any, x: number, y: number): void; + /** + * Sets the layout characteristics of a DOM element when it is hidden by invoking the Sys.UI.DomElement.setVisible method. + * This member is static and can be invoked without creating an instance of the class. + * + * Use the setVisibilityMode method to set the layout characteristics of a DOM element when it is hidden by invoking the Sys.UI.DomElement.setVisible method. + * For example, if value is set to Sys.UI.VisibilityMode.collapse, the element uses no space on the page when the setVisible method is called to hide the element. + * + * @param element + * The target DOM element. + * @param value + * A Sys.UI.VisibilityMode enumeration value. + */ + setVisibilityMode(element: Sys.UI.DomElement, value: Sys.UI.VisibilityMode): void; + /** + * Sets a DOM element to be visible or hidden. This member is static and can be invoked without creating an instance of the class. + * + * Use the setVisible method to set a DOM element as visible or hidden on the Web page. + * If you invoke this method with value set to false for an element whose visibility mode is set to "hide," the element will not be visible. + * However, it will occupy space on the page. If the element's visibility mode is set to "collapse," the element will occupy no space in the page. + * For more information about how to set the layout characteristics of hidden DOM elements, see Sys.UI.DomElement setVisibilityMode Method. + * + * @param element + * The target DOM element. + * @param value + * true to make element visible on the Web page; false to hide element. + */ + setVisible(element: Sys.UI.DomElement, value: boolean): void; + setVisible(element: HTMLElement, value: boolean): void; + setVisible(element: any, value: boolean): void; + /** + * Toggles a CSS class in a DOM element. This member is static and can be invoked without creating an instance of the class. + * Use the toggleCssClass method to hide a CSS class of an element if it is shown, or to show a CSS class of an element if it is hidden. + * + * @param element + * The Sys.UI.DomElement object to toggle. + * @param className + * The name of the CSS class to toggle. + */ + toggleCssClass(element: Sys.UI.DomElement, className: string): void; + toggleCssClass(element: HTMLElement, className: string): void; + toggleCssClass(element: any, className: string): void; + + //#endregion + } + + var DomElement: Sys.UI.DomElement; + /** * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. * @see {@link http://msdn.microsoft.com/en-us/library/bb310935(v=vs.100).aspx} @@ -3244,49 +3421,60 @@ declare module Sys { */ charCode: number; /** - * + * Gets the x-coordinate of the mouse pointer's position relative to the client area of the browser window, excluding window scroll bars. + * @return An integer that represents the x-coordinate in pixels. */ - clientX: any; // todo + clientX: number; /** - * + * Gets the y-coordinate of the mouse pointer's position relative to the client area of the browser window, excluding window scroll bars. + * @return An integer that represents the y-coordinate in pixels. */ - clientY: any; // todo + clientY: number; /** - * + * Gets a Boolean value that indicates the state of the CTRL key when the associated event occurred. + * @return true if the CTRL key was pressed when the event occurred; otherwise, false. */ - ctrlKey: any; // todo + ctrlKey: boolean; /** - * + * Gets the key code of the key that raised the keyUp or keyDown event. + * @return An integer value that represents the key code of the key that was pressed to raise the keyUp or keyDown event. */ - keyCode: any; // todo + keyCode: number; /** - * + * Gets the x-coordinate of the mouse pointer's position relative to the object that raised the event. + * @return An integer that represents the x-coordinate in pixels. */ - offsetX: any; // todo + offsetX: number; /** - * + * Gets the y-coordinate of the mouse pointer's position relative to the object that raised the event. + * @return An integer that represents the y-coordinate in pixels. */ - offsetY: any; // todo + offsetY: number; /** - * + * Gets the x-coordinate of the mouse pointer's position relative to the user's screen. + * @return An integer that represents the x-coordinate in pixels. */ - screenX: any; // todo + screenX: number; /** - * + * Gets the y-coordinate of the mouse pointer's position relative to the user's screen. + * @return An integer that represents the y-coordinate in pixels. */ - screenY: any; // todo + screenY: number; /** - * + * Gets a Boolean value that indicates the state of the SHIFT key when the associated event occurred. + * @return true if the SHIFT key was pressed when the event occurred; otherwise, false. */ - shiftKey: any; // todo + shiftKey: boolean; /** - * + * Gets the object that the event acted on. + * @return An object that represents the target that the event acted on. */ - target: any; // todo + target: any; /** - * + * Gets the name of the event that was raised. + * @return A string that represents the name of the event that was raised. */ - type: any; // todo + type: string; //#endregion } @@ -3359,16 +3547,52 @@ declare module Sys { // todo } /** - * Creates an object that contains a set of integer coordinates that represent a position. + * Creates an object that contains a set of integer coordinates that represent a position. The getLocation method of the Sys.UI.DomElement class returns a Point object. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383992(v=vs.100).aspx} * */ class Point { - // todo + + //#region Constructors + + /** + * Creates an object that contains a set of integer coordinates that represent a position. + * @param x The number of pixels between the location and the left edge of the parent frame. + * @param y The number of pixels between the location and the top edge of the parent frame. + */ + constructor(x: number, y: number); + + //#endregion + + //#region Fields + + /** + * Gets the x-coordinate of a Sys.UI.Point object in pixels. This property is read-only. + * @return A number that represents the x-coordinate of the Point object in pixels. + */ + x: number; + + /** + * Gets the y-coordinate of a Sys.UI.Point object in pixels. This property is read-only. + * @return A number that represents the y-coordinate of the Point object in pixels. + */ + y: number; + + //#endregion + } /** * Describes the layout of a DOM element in the page when the element's visible property is set to false. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397498(v=vs.100).aspx} */ enum VisibilityMode { - // todo + /** + * The element is not visible, but it occupies space on the page. + */ + hide, + /** + * The element is not visible, and the space it occupies is collapsed. + */ + collapse } } @@ -3622,7 +3846,7 @@ declare module Sys { * Manages client partial-page updates of server UpdatePanel controls. In addition, defines properties, events, and methods that can be used to customize a Web page with client script. * @see {@link http://msdn.microsoft.com/en-us/library/bb311028(v=vs.100).aspx} */ - class PageRequestManager extends EventArgs { + class PageRequestManager { //#region Constructors @@ -3640,7 +3864,7 @@ declare module Sys { * @param beginRequestHandler * The name of the handler method that will be called. */ - add_beginRequest(beginRequestHandler: (sender: any, args: any) => void): void; + add_beginRequest(beginRequestHandler: (sender: any, args: BeginRequestEventArgs) => void): void; /** * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. * @param beginRequestHandler @@ -3664,37 +3888,37 @@ declare module Sys { * @param initializeRequestHandler * The name of the handler method that will be called. */ - add_initializeRequest(initializeRequestHandler: (sender: any, args: any) => void): void; + add_initializeRequest(initializeRequestHandler: (sender: any, args: InitializeRequestEventArgs) => void): void; /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ - remove_initializeRequest(initializeRequestHandler: (sender: any, args: any) => void): void; + remove_initializeRequest(initializeRequestHandler: (sender: any, args: InitializeRequestEventArgs) => void): void; /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ - add_pageLoaded(pageLoadedHandler: (sender: any, args: any) => void): void; + add_pageLoaded(pageLoadedHandler: (sender: any, args: PageLoadedEventArgs) => void): void; /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ - remove_pageLoaded(pageLoadedHandler: (sender: any, args: any) => void): void; + remove_pageLoaded(pageLoadedHandler: (sender: any, args: PageLoadedEventArgs) => void): void; /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ - add_pageLoading(pageLoadingHandler: (sender: any, args: any) => void): void; + add_pageLoading(pageLoadingHandler: (sender: any, args: PageLoadingEventArgs) => void): void; /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ - remove_pageLoading(pageLoadingHandler: (sender: any, args: any) => void): void; + remove_pageLoading(pageLoadingHandler: (sender: any, args: PageLoadingEventArgs) => void): void; //#endregion diff --git a/node/node.d.ts b/node/node.d.ts index 5f169c8c8b..f3a778e019 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -67,7 +67,7 @@ declare var Buffer: { isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; concat(list: Buffer[], totalLength?: number): Buffer; -} +}; /************************************************ * * @@ -1240,14 +1240,14 @@ declare module "assert" { (block: Function, error: Function, message?: string): void; (block: Function, error: RegExp, message?: string): void; (block: Function, error: (err: any) => boolean, message?: string): void; - } + }; export var doesNotThrow: { (block: Function, message?: string): void; (block: Function, error: Function, message?: string): void; (block: Function, error: RegExp, message?: string): void; (block: Function, error: (err: any) => boolean, message?: string): void; - } + }; export function ifError(value: any): void; } diff --git a/requirejs/require.d.ts b/requirejs/require.d.ts index 6b2cc125f4..8623de8d64 100644 --- a/requirejs/require.d.ts +++ b/requirejs/require.d.ts @@ -262,6 +262,18 @@ interface Require { **/ toUrl(module: string): string; + /** + * Returns true if the module has already been loaded and defined. + * @param module Module to check + **/ + defined(module: string): boolean; + + /** + * Returns true if the module has already been requested or is in the process of loading and should be available at some point. + * @param module Module to check + **/ + specified(module: string): boolean; + /** * On Error override * @param err diff --git a/rtree/rtree-tests.ts b/rtree/rtree-tests.ts new file mode 100644 index 0000000000..67d35a4e61 --- /dev/null +++ b/rtree/rtree-tests.ts @@ -0,0 +1,13 @@ +/// + +var myRTree = RTree(5); +var el = "test"; + +myRTree.insert({x: 0, y: 0, w: 1, h: 1}, el); + +var intersections = myRTree.search({x: 0.5, y: 0.5, w: 1, h: 1}); + +intersections = myRTree.remove({x: 0.5, y: 0.5, w: 1, h: 1}, "notTest!"); + +intersections = myRTree.remove({x: 0.5, y: 0.5, w: 1, h: 1}); + diff --git a/rtree/rtree.d.ts b/rtree/rtree.d.ts new file mode 100644 index 0000000000..fa6276c6ef --- /dev/null +++ b/rtree/rtree.d.ts @@ -0,0 +1,25 @@ +// Type definitions for rtree 1.4.0 +// Project: https://github.com/leaflet-extras/RTree +// Definitions by: Omede Firouz +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Rectangle { + x: number; + y: number; + w: number; + h: number; +} + +interface RTreeStatic { + insert(bounds: Rectangle, element: Object): boolean; + remove(area: Rectangle, element?: Object): any[]; + geoJSON(geoJSON: any): void; + bbox(arg1: any, arg2?: any, arg3?: number, arg4?: number): any[]; + search(area: Rectangle, return_node?: boolean, return_array?: any[]): any[]; +} + +interface RTreeFactory { + (max_node_width?: number): RTreeStatic; +} + +declare var RTree: RTreeFactory; diff --git a/rx.js/rx-lite.d.ts b/rx.js/rx-lite.d.ts index 3bbdc2faad..dfae2289d9 100644 --- a/rx.js/rx-lite.d.ts +++ b/rx.js/rx-lite.d.ts @@ -227,6 +227,11 @@ declare module Rx { concat(sources: IPromise[]): Observable; concatAll(): T; concatObservable(): T; // alias for concatAll + concatMap(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => Observable): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => IPromise): Observable; // alias for selectConcat + concatMap(sequence: Observable): Observable; // alias for selectConcat merge(maxConcurrent: number): T; merge(other: Observable): Observable; merge(other: IPromise): Observable; @@ -293,6 +298,12 @@ declare module Rx { flatMap(other: Observable): Observable; // alias for selectMany flatMap(other: IPromise): Observable; // alias for selectMany + selectConcat(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; + selectConcat(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; + selectConcat(selector: (value: T, index: number) => Observable): Observable; + selectConcat(selector: (value: T, index: number) => IPromise): Observable; + selectConcat(sequence: Observable): Observable; + /** * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. diff --git a/rx.js/rx.aggregates.d.ts b/rx.js/rx.aggregates.d.ts index eb80475b1f..1305c18db4 100644 --- a/rx.js/rx.aggregates.d.ts +++ b/rx.js/rx.aggregates.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Aggregates v2.2.24 +// Type definitions for RxJS-Aggregates v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.all.ts b/rx.js/rx.all.ts index 7180cc292d..800baddeff 100644 --- a/rx.js/rx.all.ts +++ b/rx.js/rx.all.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-All v2.2.24 +// Type definitions for RxJS-All v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.async.d.ts b/rx.js/rx.async.d.ts index f25a64774d..582b60f43b 100644 --- a/rx.js/rx.async.d.ts +++ b/rx.js/rx.async.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Async v2.2.24 +// Type definitions for RxJS-Async v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: zoetrope // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.backpressure.d.ts b/rx.js/rx.backpressure.d.ts index 0580be7ebd..4d0e72f2ab 100644 --- a/rx.js/rx.backpressure.d.ts +++ b/rx.js/rx.backpressure.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-BackPressure v2.2.24 +// Type definitions for RxJS-BackPressure v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/rx.js/rx.binding.d.ts b/rx.js/rx.binding.d.ts index c74bcf2326..b9ea37fe63 100644 --- a/rx.js/rx.binding.d.ts +++ b/rx.js/rx.binding.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Binding v2.2.24 +// Type definitions for RxJS-Binding v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.coincidence.d.ts b/rx.js/rx.coincidence.d.ts index 5785867419..1fc45a2c6a 100644 --- a/rx.js/rx.coincidence.d.ts +++ b/rx.js/rx.coincidence.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Coincidence v2.2.24 +// Type definitions for RxJS-Coincidence v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.d.ts b/rx.js/rx.d.ts index 768adbd99f..e88480f956 100644 --- a/rx.js/rx.d.ts +++ b/rx.js/rx.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS v2.2.24 +// Type definitions for RxJS v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: gsino // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.experimental.d.ts b/rx.js/rx.experimental.d.ts index 60d9b9be4e..74b0351589 100644 --- a/rx.js/rx.experimental.d.ts +++ b/rx.js/rx.experimental.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Experimental v2.2.24 +// Type definitions for RxJS-Experimental v2.2.25 // Project: https://github.com/Reactive-Extensions/RxJS/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/rx.js/rx.joinpatterns.d.ts b/rx.js/rx.joinpatterns.d.ts index 82a7891f80..efd0adfc0f 100644 --- a/rx.js/rx.joinpatterns.d.ts +++ b/rx.js/rx.joinpatterns.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Join v2.2.24 +// Type definitions for RxJS-Join v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/rx.js/rx.lite.d.ts b/rx.js/rx.lite.d.ts index cb91342ea4..20d8a3179d 100644 --- a/rx.js/rx.lite.d.ts +++ b/rx.js/rx.lite.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Lite v2.2.20 +// Type definitions for RxJS-Lite v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: gsino // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.testing.d.ts b/rx.js/rx.testing.d.ts index 725f61feb4..ddbc0373bc 100644 --- a/rx.js/rx.testing.d.ts +++ b/rx.js/rx.testing.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Testing v2.2.24 +// Type definitions for RxJS-Testing v2.2.25 // Project: https://github.com/Reactive-Extensions/RxJS/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/rx.js/rx.time.d.ts b/rx.js/rx.time.d.ts index 048429074b..49b2f6b5e5 100644 --- a/rx.js/rx.time.d.ts +++ b/rx.js/rx.time.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Time v2.2.24 +// Type definitions for RxJS-Time v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.virtualtime.d.ts b/rx.js/rx.virtualtime.d.ts index 328042e360..25835e3ad2 100644 --- a/rx.js/rx.virtualtime.d.ts +++ b/rx.js/rx.virtualtime.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-VirtualTime v2.2.24 +// Type definitions for RxJS-VirtualTime v2.2.25 // Project: http://rx.codeplex.com/ // Definitions by: gsino // Definitions by: Igor Oleinikov diff --git a/slickgrid/slick.headerbuttons.d.ts b/slickgrid/slick.headerbuttons.d.ts index ab160ea836..613203f438 100644 --- a/slickgrid/slick.headerbuttons.d.ts +++ b/slickgrid/slick.headerbuttons.d.ts @@ -8,7 +8,7 @@ declare module Slick { export interface Column { - header: Header; + header?: Header; } export interface Header { diff --git a/webrtc/MediaStream.d.ts b/webrtc/MediaStream.d.ts index ddf2200be3..f9f549ed0f 100644 --- a/webrtc/MediaStream.d.ts +++ b/webrtc/MediaStream.d.ts @@ -6,8 +6,8 @@ // Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html interface MediaStreamConstraints { - audio: boolean; - video: boolean; + audio: any; + video: any; } declare var MediaStreamConstraints: { prototype: MediaStreamConstraints; @@ -40,8 +40,8 @@ declare var MediaTrackConstraint: { } interface Navigator { - getUserMedia(constraints: MediaStreamConstraints, successCallback: (stream: any) => void , errorCallback: (error: Error) => void ); - webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: (stream: any) => void , errorCallback: (error: Error) => void ); + getUserMedia(constraints: MediaStreamConstraints, successCallback: (stream: any) => void, errorCallback: (error: Error) => void); + webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: (stream: any) => void, errorCallback: (error: Error) => void); } interface EventHandler { (event: Event): void; } @@ -79,6 +79,7 @@ declare var webkitMediaStreamTrackList: { interface MediaStream { label: string; + id: string; getAudioTracks(): MediaStreamTrackList; getVideoTracks(): MediaStreamTrackList; ended: boolean; @@ -99,6 +100,17 @@ declare var webkitMediaStream: { new (trackContainers: MediaStreamTrack[]): MediaStream; } +// an - not defined in source doc. +interface SourceInfo { + label: string; + id: string; + kind: string; + facing: string; +} +declare var SourceInfo: { + prototype: SourceInfo; +} + interface LocalMediaStream extends MediaStream { stop(): void; } @@ -115,12 +127,13 @@ interface MediaStreamTrack { onunmute: (event: Event) => void; onended: (event: Event) => void; } -declare var MediaStramTrack: { +declare var MediaStreamTrack: { prototype: MediaStreamTrack; new (): MediaStreamTrack; LIVE: number; // = 0; MUTED: number; // = 1; ENDED: number; // = 2; + getSources: (callback: (sources: SourceInfo[]) => void) => void; } interface streamURL extends URL { @@ -136,6 +149,7 @@ interface WebkitURL extends streamURL { } declare var webkitURL: { prototype: WebkitURL; - new (): streamURL; + new (): streamURL; createObjectURL(stream: MediaStream): string; } + diff --git a/ws/ws.d.ts b/ws/ws.d.ts index b0b590b924..ef7acc3ba1 100644 --- a/ws/ws.d.ts +++ b/ws/ws.d.ts @@ -110,7 +110,7 @@ declare module "ws" { constructor(options?: IServerOptions, callback?: Function); close(): void; - handleUpgrade(request: http.ClientRequest, socket: net.Socket, + handleUpgrade(request: http.ServerRequest, socket: net.Socket, upgradeHead: Buffer, callback: (client: WebSocket) => void): void; // Events