diff --git a/src/Web/Scripts/Chutzpah.json b/src/Web/Scripts/Chutzpah.json new file mode 100644 index 0000000..2807d28 --- /dev/null +++ b/src/Web/Scripts/Chutzpah.json @@ -0,0 +1,16 @@ +{ + "Framework": "jasmine", + "TypeScriptCodeGenTarget": "ES5", + "CodeCoverageExcludes": [ + "*\\vendor\\*.js", + "controllersSpec.js", + ], + "References": [ + { "Path": "vendor\\angular.min.js" }, + { "Path": "vendor\\angular-mocks.js" }, + { "Path": "typings\\jquery\\jquery.d.ts", "IncludeInTestHarness": false }, + { "Path": "typings\\angularjs\\angular.d.ts", "IncludeInTestHarness": false }, + { "Path": "typings\\angularjs\\angular-mocks.d.ts", "IncludeInTestHarness": false }, + { "Path": "typings\\jasmine\\jasmine.d.ts", "IncludeInTestHarness": false } + ] +} \ No newline at end of file diff --git a/src/Web/Scripts/_references.js b/src/Web/Scripts/_references.js deleted file mode 100644 index f99ab14..0000000 --- a/src/Web/Scripts/_references.js +++ /dev/null @@ -1,11 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -// -/// -/// \ No newline at end of file diff --git a/src/Web/Scripts/_references.ts b/src/Web/Scripts/_references.ts new file mode 100644 index 0000000..fc63335 --- /dev/null +++ b/src/Web/Scripts/_references.ts @@ -0,0 +1 @@ +/// diff --git a/src/Web/Scripts/app.js b/src/Web/Scripts/app.ts similarity index 86% rename from src/Web/Scripts/app.js rename to src/Web/Scripts/app.ts index 0a0b8aa..2aaaec9 100644 --- a/src/Web/Scripts/app.js +++ b/src/Web/Scripts/app.ts @@ -1,11 +1,17 @@ -'use strict'; +'use strict'; + +interface IAppRootScopeService extends ng.IRootScopeService { + $state: any; + $stateParams: any; + layout: string; +} // Declares how the application should be bootstrapped. See: http://docs.angularjs.org/guide/module angular.module('app', ['ui.router', 'app.filters', 'app.services', 'app.directives', 'app.controllers']) // Gets executed during the provider registrations and configuration phase. Only providers and constants can be // injected here. This is to prevent accidental instantiation of services before they have been fully configured. - .config(['$stateProvider', '$locationProvider', function ($stateProvider, $locationProvider) { + .config(['$stateProvider', '$locationProvider', function ($stateProvider, $locationProvider : ng.ILocationProvider) { // UI States, URL Routing & Mapping. For more info see: https://github.com/angular-ui/ui-router // ------------------------------------------------------------------------------------------------------------ @@ -40,7 +46,7 @@ angular.module('app', ['ui.router', 'app.filters', 'app.services', 'app.directiv // Gets executed after the injector is created and are used to kickstart the application. Only instances and constants // can be injected here. This is to prevent further system configuration during application run time. - .run(['$templateCache', '$rootScope', '$state', '$stateParams', function ($templateCache, $rootScope, $state, $stateParams) { + .run(['$templateCache', '$rootScope', '$state', '$stateParams', function ($templateCache: ng.ITemplateCacheService, $rootScope: IAppRootScopeService, $state, $stateParams) { // contains a pre-rendered template for the current view // caching it will prevent a round-trip to a server at the first page load @@ -50,8 +56,7 @@ angular.module('app', ['ui.router', 'app.filters', 'app.services', 'app.directiv // Allows to retrieve UI Router state information from inside templates $rootScope.$state = $state; $rootScope.$stateParams = $stateParams; - - $rootScope.$on('$stateChangeSuccess', function (event, toState) { + $rootScope.$on('$stateChangeSuccess', (event, toState?): any => { // Sets the layout name, which can be used to display different layouts (header, footer etc.) // based on which page the user is located diff --git a/src/Web/Scripts/controllers.js b/src/Web/Scripts/controllers.ts similarity index 73% rename from src/Web/Scripts/controllers.js rename to src/Web/Scripts/controllers.ts index 827c296..c105c90 100644 --- a/src/Web/Scripts/controllers.js +++ b/src/Web/Scripts/controllers.ts @@ -1,4 +1,4 @@ -'use strict'; +'use strict'; // Google Analytics Collection APIs Reference: // https://developers.google.com/analytics/devguides/collection/analyticsjs/ @@ -6,38 +6,38 @@ angular.module('app.controllers', []) // Path: / - .controller('HomeCtrl', ['$scope', '$location', '$window', function ($scope, $location, $window) { + .controller('HomeCtrl', ['$scope', '$location', '$window', ($scope, $location, $window) => { $scope.$root.title = 'AngularJS SPA Template for Visual Studio'; - $scope.$on('$viewContentLoaded', function () { + $scope.$on('$viewContentLoaded', () => { $window.ga('send', 'pageview', { 'page': $location.path(), 'title': $scope.$root.title }); }); }]) // Path: /about - .controller('AboutCtrl', ['$scope', '$location', '$window', function ($scope, $location, $window) { + .controller('AboutCtrl', ['$scope', '$location', '$window', ($scope, $location, $window) => { $scope.$root.title = 'AngularJS SPA | About'; - $scope.$on('$viewContentLoaded', function () { + $scope.$on('$viewContentLoaded', () => { $window.ga('send', 'pageview', { 'page': $location.path(), 'title': $scope.$root.title }); }); }]) // Path: /login - .controller('LoginCtrl', ['$scope', '$location', '$window', function ($scope, $location, $window) { + .controller('LoginCtrl', ['$scope', '$location', '$window', ($scope, $location, $window) => { $scope.$root.title = 'AngularJS SPA | Sign In'; // TODO: Authorize a user $scope.login = function () { $location.path('/'); return false; }; - $scope.$on('$viewContentLoaded', function () { + $scope.$on('$viewContentLoaded', () => { $window.ga('send', 'pageview', { 'page': $location.path(), 'title': $scope.$root.title }); }); }]) // Path: /error/404 - .controller('Error404Ctrl', ['$scope', '$location', '$window', function ($scope, $location, $window) { + .controller('Error404Ctrl', ['$scope', '$location', '$window', ($scope, $location, $window) => { $scope.$root.title = 'Error 404: Page Not Found'; - $scope.$on('$viewContentLoaded', function () { + $scope.$on('$viewContentLoaded', () => { $window.ga('send', 'pageview', { 'page': $location.path(), 'title': $scope.$root.title }); }); }]); \ No newline at end of file diff --git a/src/Web/Scripts/controllers.spec.js b/src/Web/Scripts/controllersSpec.ts similarity index 95% rename from src/Web/Scripts/controllers.spec.js rename to src/Web/Scripts/controllersSpec.ts index 6c42b58..5d0407b 100644 --- a/src/Web/Scripts/controllers.spec.js +++ b/src/Web/Scripts/controllersSpec.ts @@ -1,5 +1,4 @@ -/// -/// +/// 'use strict'; diff --git a/src/Web/Scripts/directives.js b/src/Web/Scripts/directives.js deleted file mode 100644 index 55627fc..0000000 --- a/src/Web/Scripts/directives.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -angular.module('app.directives', []) - - .directive('appVersion', ['version', function (version) { - return function (scope, elm, attrs) { - elm.text(version); - }; - }]); \ No newline at end of file diff --git a/src/Web/Scripts/directives.spec.js b/src/Web/Scripts/directives.spec.js deleted file mode 100644 index c3fc9a3..0000000 --- a/src/Web/Scripts/directives.spec.js +++ /dev/null @@ -1,20 +0,0 @@ -/// -/// - -'use strict'; - -describe('Directives', function () { - beforeEach(module('app.directives')); - - describe('app-version', function () { - it('should print current version', function () { - module(function ($provide) { - $provide.value('version', 'TEST_VER'); - }); - inject(function ($compile, $rootScope) { - var element = $compile('')($rootScope); - expect(element.text()).toEqual('TEST_VER'); - }); - }); - }); -}); \ No newline at end of file diff --git a/src/Web/Scripts/directives.ts b/src/Web/Scripts/directives.ts new file mode 100644 index 0000000..2e52da1 --- /dev/null +++ b/src/Web/Scripts/directives.ts @@ -0,0 +1,9 @@ +'use strict'; + +angular.module('app.directives', []) + + .directive('appVersion', ['version', (version : string) => { + return (scope, elm, attrs) => { + elm.text(version); + }; + }]); \ No newline at end of file diff --git a/src/Web/Scripts/directivesSpec.ts b/src/Web/Scripts/directivesSpec.ts new file mode 100644 index 0000000..099803a --- /dev/null +++ b/src/Web/Scripts/directivesSpec.ts @@ -0,0 +1,19 @@ +/// + +'use strict'; + +describe('Directives', () => { + beforeEach(module('app.directives')); + + describe('app-version', () => { + it('should print current version', () => { + module(($provide) => { + $provide.value('version', 'TEST_VER'); + }); + inject(($compile, $rootScope) => { + var element = $compile('')($rootScope); + expect(element.text()).toEqual('TEST_VER'); + }); + }); + }); +}); \ No newline at end of file diff --git a/src/Web/Scripts/filters.spec.js b/src/Web/Scripts/filters.spec.js deleted file mode 100644 index bafa186..0000000 --- a/src/Web/Scripts/filters.spec.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -/// - -'use strict'; - -describe('Filter', function () { - beforeEach(module('app.filters')); - - describe('interpolate', function () { - beforeEach(module(function ($provide) { - $provide.value('version', 'TEST_VER'); - })); - - it('should replace VERSION', inject(function (interpolateFilter) { - expect(interpolateFilter('before %VERSION% after')).toEqual('before TEST_VER after'); - })); - }); -}); \ No newline at end of file diff --git a/src/Web/Scripts/filters.js b/src/Web/Scripts/filters.ts similarity index 52% rename from src/Web/Scripts/filters.js rename to src/Web/Scripts/filters.ts index 1e5ee39..fd330b5 100644 --- a/src/Web/Scripts/filters.js +++ b/src/Web/Scripts/filters.ts @@ -1,9 +1,9 @@ -'use strict'; +'use strict'; angular.module('app.filters', []) - .filter('interpolate', ['version', function (version) { - return function (text) { + .filter('interpolate', ['version', (version) => { + return (text) => { return String(text).replace(/\%VERSION\%/mg, version); } }]); \ No newline at end of file diff --git a/src/Web/Scripts/filtersSpec.ts b/src/Web/Scripts/filtersSpec.ts new file mode 100644 index 0000000..edc5346 --- /dev/null +++ b/src/Web/Scripts/filtersSpec.ts @@ -0,0 +1,17 @@ +/// + +'use strict'; + +describe('Filters', () => { + beforeEach(module('app.filters')); + + describe('interpolate', () => { + beforeEach(module(($provide) => { + $provide.value('version', 'TEST_VER'); + })); + + it('should replace VERSION', inject((interpolateFilter) => { + expect(interpolateFilter('before %VERSION% after')).toEqual('before TEST_VER after'); + })); + }); +}); \ No newline at end of file diff --git a/src/Web/Scripts/services.spec.js b/src/Web/Scripts/services.spec.js deleted file mode 100644 index 3bf5488..0000000 --- a/src/Web/Scripts/services.spec.js +++ /dev/null @@ -1,14 +0,0 @@ -/// -/// - -'use strict'; - -describe('service', function () { - beforeEach(module('app.services')); - - describe('version', function () { - it('should return current version', inject(function (version) { - expect(version).toEqual('0.1'); - })); - }); -}); \ No newline at end of file diff --git a/src/Web/Scripts/services.js b/src/Web/Scripts/services.ts similarity index 72% rename from src/Web/Scripts/services.js rename to src/Web/Scripts/services.ts index a77e35b..5bad099 100644 --- a/src/Web/Scripts/services.js +++ b/src/Web/Scripts/services.ts @@ -1,7 +1,7 @@ -'use strict'; +'use strict'; // Demonstrate how to register services // In this case it is a simple value service. angular.module('app.services', []) - .value('version', '0.1'); \ No newline at end of file + .value('version', '1.0.0'); \ No newline at end of file diff --git a/src/Web/Scripts/servicesSpec.ts b/src/Web/Scripts/servicesSpec.ts new file mode 100644 index 0000000..cf48688 --- /dev/null +++ b/src/Web/Scripts/servicesSpec.ts @@ -0,0 +1,13 @@ +/// + +'use strict'; + +describe('Services', () => { + beforeEach(module('app.services')); + + describe('version', () => { + it('should return current version', inject((version) => { + expect(version).toEqual('1.0.0'); + })); + }); +}); \ No newline at end of file diff --git a/src/Web/Scripts/typings/angularjs/angular-cookies.d.ts b/src/Web/Scripts/typings/angularjs/angular-cookies.d.ts new file mode 100644 index 0000000..0840011 --- /dev/null +++ b/src/Web/Scripts/typings/angularjs/angular-cookies.d.ts @@ -0,0 +1,30 @@ +/// Type definitions for Angular JS 1.2 (ngCookies module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngCookies module (angular-cookies.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.cookies { + + /////////////////////////////////////////////////////////////////////////// + // CookieService + // see http://docs.angularjs.org/api/ngCookies.$cookies + /////////////////////////////////////////////////////////////////////////// + interface ICookiesService {} + + /////////////////////////////////////////////////////////////////////////// + // CookieStoreService + // see http://docs.angularjs.org/api/ngCookies.$cookieStore + /////////////////////////////////////////////////////////////////////////// + interface ICookieStoreService { + get(key: string): any; + put(key: string, value: any): void; + remove(key: string): void; + } + +} diff --git a/src/Web/Scripts/typings/angularjs/angular-mocks.d.ts b/src/Web/Scripts/typings/angularjs/angular-mocks.d.ts new file mode 100644 index 0000000..447aa22 --- /dev/null +++ b/src/Web/Scripts/typings/angularjs/angular-mocks.d.ts @@ -0,0 +1,218 @@ +// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/////////////////////////////////////////////////////////////////////////////// +// functions attached to global object (window) +/////////////////////////////////////////////////////////////////////////////// +declare var module: (...modules: any[]) => any; +declare var inject: (...fns: Function[]) => any; + +/////////////////////////////////////////////////////////////////////////////// +// ngMock module (angular-mocks.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // We reopen it to add the MockStatic definition + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + mock: IMockStatic; + } + + interface IMockStatic { + // see http://docs.angularjs.org/api/angular.mock.dump + dump(obj: any): string; + + // see http://docs.angularjs.org/api/angular.mock.inject + inject(...fns: Function[]): any; + + // see http://docs.angularjs.org/api/angular.mock.module + module(...modules: string[]): any; + module(...modules: Function[]): any; + module(modules: Object): any; + + // see http://docs.angularjs.org/api/angular.mock.TzDate + TzDate(offset: number, timestamp: number): Date; + TzDate(offset: number, timestamp: string): Date; + } + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ngMock.$exceptionHandler + // see http://docs.angularjs.org/api/ngMock.$exceptionHandlerProvider + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerProvider extends IServiceProvider { + mode(mode: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ngMock.$timeout + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + flush(delay?: number): void; + flushNext(expectedDelay?: number): void; + verifyNoPendingTasks(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ngMock.$log + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + assertEmpty(): void; + reset(): void; + } + + interface ILogCall { + logs: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ngMock.$httpBackend + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + flush(count?: number): void; + resetExpectations(): void; + verifyNoOutstandingExpectation(): void; + verifyNoOutstandingRequest(): void; + + expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + expectDELETE(url: string, headers?: Object): mock.IRequestHandler; + expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + expectGET(url: string, headers?: Object): mock.IRequestHandler; + expectGET(url: RegExp, headers?: Object): mock.IRequestHandler; + expectHEAD(url: string, headers?: Object): mock.IRequestHandler; + expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + expectJSONP(url: string): mock.IRequestHandler; + expectJSONP(url: RegExp): mock.IRequestHandler; + + expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenDELETE(url: string, headers?: Object): mock.IRequestHandler; + whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenGET(url: string, headers?: Object): mock.IRequestHandler; + whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenGET(url: RegExp, headers?: Object): mock.IRequestHandler; + whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenHEAD(url: string, headers?: Object): mock.IRequestHandler; + whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenJSONP(url: string): mock.IRequestHandler; + whenJSONP(url: RegExp): mock.IRequestHandler; + + whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + } + + export module mock { + + // returned interface by the the mocked HttpBackendService expect/when methods + interface IRequestHandler { + respond(func: Function): void; + respond(status: number, data?: any, headers?: any): void; + respond(data: any, headers?: any): void; + + // Available wehn ngMockE2E is loaded + passThrough(): void; + } + + } + +} diff --git a/src/Web/Scripts/typings/angularjs/angular-resource.d.ts b/src/Web/Scripts/typings/angularjs/angular-resource.d.ts new file mode 100644 index 0000000..f74f3eb --- /dev/null +++ b/src/Web/Scripts/typings/angularjs/angular-resource.d.ts @@ -0,0 +1,114 @@ +// Type definitions for Angular JS 1.2 (ngResource module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngResource module (angular-resource.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.resource { + + /////////////////////////////////////////////////////////////////////////// + // ResourceService + // see http://docs.angularjs.org/api/ngResource.$resource + // Most part of the following definitions were achieved by analyzing the + // actual implementation, since the documentation doesn't seem to cover + // that deeply. + /////////////////////////////////////////////////////////////////////////// + interface IResourceService { + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass; + } + + // Just a reference to facilitate describing new actions + interface IActionDescriptor { + method: string; + isArray?: boolean; + params?: any; + headers?: any; + } + + // Baseclass for everyresource with default actions. + // If you define your new actions for the resource, you will need + // to extend this interface and typecast the ResourceClass to it. + // + // In case of passing the first argument as anything but a function, + // it's gonna be considered data if the action method is POST, PUT or + // PATCH (in other words, methods with body). Otherwise, it's going + // to be considered as parameters to the request. + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465 + interface IResourceClass { + get(): IResource; + get(dataOrParams: any): IResource; + get(dataOrParams: any, success: Function): IResource; + get(success: Function, error?: Function): IResource; + get(params: any, data: any, success?: Function, error?: Function): IResource; + save(): IResource; + save(dataOrParams: any): IResource; + save(dataOrParams: any, success: Function): IResource; + save(success: Function, error?: Function): IResource; + save(params: any, data: any, success?: Function, error?: Function): IResource; + query(): IResource[]; + query(dataOrParams: any): IResource[]; + query(dataOrParams: any, success: Function): IResource[]; + query(success: Function, error?: Function): IResource[]; + query(params: any, data: any, success?: Function, error?: Function): IResource[]; + remove(): IResource; + remove(dataOrParams: any): IResource; + remove(dataOrParams: any, success: Function): IResource; + remove(success: Function, error?: Function): IResource; + remove(params: any, data: any, success?: Function, error?: Function): IResource; + delete(): IResource; + delete(dataOrParams: any): IResource; + delete(dataOrParams: any, success: Function): IResource; + delete(success: Function, error?: Function): IResource; + delete(params: any, data: any, success?: Function, error?: Function): IResource; + } + + interface IResource { + $get(): IResource; + $get(dataOrParams: any): IResource; + $get(dataOrParams: any, success: Function): IResource; + $get(success: Function, error?: Function): IResource; + $get(params: any, data: any, success?: Function, error?: Function): IResource; + $save(): IResource; + $save(dataOrParams: any): IResource; + $save(dataOrParams: any, success: Function): IResource; + $save(success: Function, error?: Function): IResource; + $save(params: any, data: any, success?: Function, error?: Function): IResource; + $query(): IResource[]; + $query(dataOrParams: any): IResource[]; + $query(dataOrParams: any, success: Function): IResource[]; + $query(success: Function, error?: Function): IResource[]; + $query(params: any, data: any, success?: Function, error?: Function): IResource[]; + $remove(): IResource; + $remove(dataOrParams: any): IResource; + $remove(dataOrParams: any, success: Function): IResource; + $remove(success: Function, error?: Function): IResource; + $remove(params: any, data: any, success?: Function, error?: Function): IResource; + $delete(): IResource; + $delete(dataOrParams: any): IResource; + $delete(dataOrParams: any, success: Function): IResource; + $delete(success: Function, error?: Function): IResource; + $delete(params: any, data: any, success?: Function, error?: Function): IResource; + } + + /** when creating a resource factory via IModule.factory */ + interface IResourceServiceFactoryFunction { + ($resource: ng.resource.IResourceService): ng.resource.IResourceClass; + } +} + +/** extensions to base ng based on using angular-resource */ +declare module ng { + + interface IModule { + /** creating a resource service factory */ + factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule; + } +} diff --git a/src/Web/Scripts/typings/angularjs/angular-route.d.ts b/src/Web/Scripts/typings/angularjs/angular-route.d.ts new file mode 100644 index 0000000..b8d1db5 --- /dev/null +++ b/src/Web/Scripts/typings/angularjs/angular-route.d.ts @@ -0,0 +1,64 @@ +// Type definitions for Angular JS 1.2 (ngRoute module) +// Project: http://angularjs.org +// Definitions by: Jonathan Park +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngRoute module (angular-route.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.route { + + /////////////////////////////////////////////////////////////////////////// + // RouteParamsService + // see http://docs.angularjs.org/api/ngRoute.$routeParams + /////////////////////////////////////////////////////////////////////////// + interface IRouteParamsService {} + + /////////////////////////////////////////////////////////////////////////// + // RouteService + // see http://docs.angularjs.org/api/ngRoute.$route + // see http://docs.angularjs.org/api/ngRoute.$routeProvider + /////////////////////////////////////////////////////////////////////////// + interface IRouteService { + reload(): void; + routes: any; + + // May not always be available. For instance, current will not be available + // 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 + interface IRoute { + controller?: any; + controllerAs?: any; + name?: string; + template?: string; + templateUrl?: any; + resolve?: any; + redirectTo?: any; + reloadOnSearch?: boolean; + } + + // see http://docs.angularjs.org/api/ng.$route#current + interface ICurrentRoute extends IRoute { + locals: { + $scope: IScope; + $template: string; + }; + + params: any; + } + + interface IRouteProvider extends IServiceProvider { + otherwise(params: any): IRouteProvider; + /** + * This is a description + * + */ + when(path: string, route: IRoute): IRouteProvider; + } +} diff --git a/src/Web/Scripts/typings/angularjs/angular-sanitize.d.ts b/src/Web/Scripts/typings/angularjs/angular-sanitize.d.ts new file mode 100644 index 0000000..36bca38 --- /dev/null +++ b/src/Web/Scripts/typings/angularjs/angular-sanitize.d.ts @@ -0,0 +1,35 @@ +// Type definitions for Angular JS 1.2 (ngSanitize module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngSanitize module (angular-sanitize.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.sanitize { + + /////////////////////////////////////////////////////////////////////////// + // SanitizeService + // see http://docs.angularjs.org/api/ngSanitize.$sanitize + /////////////////////////////////////////////////////////////////////////// + interface ISanitizeService { + (html: string): string; + } + + /////////////////////////////////////////////////////////////////////////// + // Filters included with the ngSanitize + // see https://github.com/angular/angular.js/tree/v1.2.0/src/ngSanitize/filter + /////////////////////////////////////////////////////////////////////////// + export module filter { + + // Finds links in text input and turns them into html links. + // Supports http/https/ftp/mailto and plain email address links. + // see http://code.angularjs.org/1.2.0/docs/api/ngSanitize.filter:linky + interface ILinky { + (text: string, target?: string): string; + } + } +} diff --git a/src/Web/Scripts/typings/angularjs/angular.d.ts b/src/Web/Scripts/typings/angularjs/angular.d.ts new file mode 100644 index 0000000..3b0599a --- /dev/null +++ b/src/Web/Scripts/typings/angularjs/angular.d.ts @@ -0,0 +1,820 @@ +// Type definitions for Angular JS 1.0 +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare var angular: ng.IAngularStatic; + +// Support for painless dependency injection +interface Function { + $inject:string[]; +} + +/////////////////////////////////////////////////////////////////////////////// +// ng module (angular.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + // All service providers extend this interface + interface IServiceProvider { + $get: any; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // see http://docs.angularjs.org/api + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + bind(context: any, fn: Function, ...args: any[]): Function; + bootstrap(element: string, modules?: any[]): auto.IInjectorService; + bootstrap(element: JQuery, modules?: any[]): auto.IInjectorService; + bootstrap(element: Element, modules?: any[]): auto.IInjectorService; + bootstrap(element: Document, modules?: any[]): auto.IInjectorService; + copy(source: any, destination?: any): any; + element: IAugmentedJQueryStatic; + equals(value1: any, value2: any): boolean; + extend(destination: any, ...sources: any[]): any; + forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any; + fromJson(json: string): any; + identity(arg?: any): any; + injector(modules?: any[]): auto.IInjectorService; + isArray(value: any): boolean; + isDate(value: any): boolean; + isDefined(value: any): boolean; + isElement(value: any): boolean; + isFunction(value: any): boolean; + isNumber(value: any): boolean; + isObject(value: any): boolean; + 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 + */ + module( + /** name of your module you want to create */ + name: string, + /** name of modules yours depends on */ + requires?: string[], + configFunction?: any): IModule; + noop(...args: any[]): void; + toJson(obj: any, pretty?: boolean): string; + uppercase(str: string): string; + version: { + full: string; + major: number; + minor: number; + dot: number; + codename: string; + }; + } + + /////////////////////////////////////////////////////////////////////////// + // Module + // see http://docs.angularjs.org/api/angular.Module + /////////////////////////////////////////////////////////////////////////// + interface IModule { + animation(name: string, animationFactory: Function): IModule; + animation(name: string, inlineAnnotadedFunction: any[]): IModule; + animation(object: Object): IModule; + /** configure existing services. + Use this method to register work which needs to be performed on module loading + */ + config(configFn: Function): IModule; + /** configure existing services. + Use this method to register work which needs to be performed on module loading + */ + config(inlineAnnotadedFunction: any[]): IModule; + constant(name: string, value: any): IModule; + constant(object: Object): IModule; + controller(name: string, controllerConstructor: Function): IModule; + controller(name: string, inlineAnnotadedConstructor: any[]): IModule; + controller(object : Object): IModule; + directive(name: string, directiveFactory: Function): IModule; + directive(name: string, inlineAnnotadedFunction: any[]): IModule; + directive(object: Object): IModule; + factory(name: string, serviceFactoryFunction: Function): IModule; + factory(name: string, inlineAnnotadedFunction: any[]): IModule; + factory(object: Object): IModule; + filter(name: string, filterFactoryFunction: Function): IModule; + filter(name: string, inlineAnnotadedFunction: any[]): IModule; + filter(object: Object): IModule; + provider(name: string, serviceProviderConstructor: Function): IModule; + provider(name: string, inlineAnnotadedConstructor: any[]): IModule; + provider(object: Object): IModule; + run(initializationFunction: Function): IModule; + run(inlineAnnotadedFunction: any[]): IModule; + service(name: string, serviceConstructor: Function): IModule; + service(name: string, inlineAnnotadedConstructor: any[]): IModule; + service(object: Object): IModule; + value(name: string, value: any): IModule; + value(object: Object): IModule; + + // Properties + name: string; + requires: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // Attributes + // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes + /////////////////////////////////////////////////////////////////////////// + interface IAttributes { + // this is necessary to be able to access the scoped attributes. it's not very elegant + // because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way + // this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656 + [name: string]: any; + + // Adds the CSS class value specified by the classVal parameter to the + // element. If animations are enabled then an animation will be triggered + // for the class addition. + $addClass(classVal: string): void; + + // Removes the CSS class value specified by the classVal parameter from the + // element. If animations are enabled then an animation will be triggered for + // the class removal. + $removeClass(classVal: string): void; + + // Set DOM element attribute value. + $set(key: string, value: any): void; + + // Observes an interpolated attribute. + // The observer function will be invoked once during the next $digest + // following compilation. The observer is then invoked whenever the + // interpolated value changes. + $observe(name: string, fn:(value?:any)=>any): Function; + + // A map of DOM element attribute names to the normalized name. This is needed + // to do reverse lookup from normalized name back to actual name. + $attr: Object; + } + + /////////////////////////////////////////////////////////////////////////// + // FormController + // see http://docs.angularjs.org/api/ng.directive:form.FormController + /////////////////////////////////////////////////////////////////////////// + interface IFormController { + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + $error: any; + $addControl(control: ng.INgModelController): void; + $removeControl(control: ng.INgModelController): void; + $setDirty(): void; + $setPristine(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // NgModelController + // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController + /////////////////////////////////////////////////////////////////////////// + interface INgModelController { + $render(): void; + $setValidity(validationErrorKey: string, isValid: boolean): void; + // Documentation states viewValue and modelValue to be a string but other + // types do work and it's common to use them. + $setViewValue(value: any): void; + $viewValue: any; + + $modelValue: any; + + $parsers: IModelParser[]; + $formatters: IModelFormatter[]; + $error: any; + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + } + + interface IModelParser { + (value: any): any; + } + + interface IModelFormatter { + (value: any): any; + } + + /////////////////////////////////////////////////////////////////////////// + // Scope + // see http://docs.angularjs.org/api/ng.$rootScope.Scope + /////////////////////////////////////////////////////////////////////////// + interface IScope { + $apply(): any; + $apply(exp: string): any; + $apply(exp: (scope: IScope) => any): any; + + $broadcast(name: string, ...args: any[]): IAngularEvent; + $destroy(): void; + $digest(): void; + $emit(name: string, ...args: any[]): IAngularEvent; + + // Documentation says exp is optional, but actual implementaton counts on it + $eval(expression: string, args?: Object): any; + $eval(expression: (scope: IScope) => any, args?: Object): any; + + // Documentation says exp is optional, but actual implementaton counts on it + $evalAsync(expression: string): void; + $evalAsync(expression: (scope: IScope) => any): void; + + // Defaults to false by the implementation checking strategy + $new(isolate?: boolean): IScope; + + $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + + $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + + $watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + + $parent: IScope; + + $id: number; + + // Hidden members + $$isolateBindings: any; + $$phase: any; + } + + interface IAngularEvent { + targetScope: IScope; + currentScope: IScope; + name: string; + preventDefault: Function; + defaultPrevented: boolean; + + // Available only events that were $emit-ted + stopPropagation?: Function; + } + + /////////////////////////////////////////////////////////////////////////// + // WindowService + // see http://docs.angularjs.org/api/ng.$window + /////////////////////////////////////////////////////////////////////////// + interface IWindowService extends Window {} + + /////////////////////////////////////////////////////////////////////////// + // BrowserService + // TODO undocumented, so we need to get it from the source code + /////////////////////////////////////////////////////////////////////////// + interface IBrowserService {} + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ng.$timeout + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + (func: Function, delay?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see http://docs.angularjs.org/api/ng.$interval + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + (func: Function, delay: number, count?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // FilterService + // see http://docs.angularjs.org/api/ng.$filter + // see http://docs.angularjs.org/api/ng.$filterProvider + /////////////////////////////////////////////////////////////////////////// + interface IFilterService { + (name: string): Function; + } + + interface IFilterProvider extends IServiceProvider { + register(name: string, filterFactory: Function): IServiceProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // LocaleService + // see http://docs.angularjs.org/api/ng.$locale + /////////////////////////////////////////////////////////////////////////// + interface ILocaleService { + id: string; + + // These are not documented + // Check angular's i18n files for exemples + NUMBER_FORMATS: ILocaleNumberFormatDescriptor; + DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor; + pluralCat: (num: any) => string; + } + + interface ILocaleNumberFormatDescriptor { + DECIMAL_SEP: string; + GROUP_SEP: string; + PATTERNS: ILocaleNumberPatternDescriptor[]; + CURRENCY_SYM: string; + } + + interface ILocaleNumberPatternDescriptor { + minInt: number; + minFrac: number; + maxFrac: number; + posPre: string; + posSuf: string; + negPre: string; + negSuf: string; + gSize: number; + lgSize: number; + } + + interface ILocaleDateTimeFormatDescriptor { + MONTH: string[]; + SHORTMONTH: string[]; + DAY: string[]; + SHORTDAY: string[]; + AMPMS: string[]; + medium: string; + short: string; + fullDate: string; + longDate: string; + mediumDate: string; + shortDate: string; + mediumTime: string; + shortTime: string; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ng.$log + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + debug: ILogCall; + error: ILogCall; + info: ILogCall; + log: ILogCall; + warn: ILogCall; + } + + // We define this as separete interface so we can reopen it later for + // the ngMock module. + interface ILogCall { + (...args: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // ParseService + // see http://docs.angularjs.org/api/ng.$parse + /////////////////////////////////////////////////////////////////////////// + interface IParseService { + (expression: string): ICompiledExpression; + } + + interface ICompiledExpression { + (context: any, locals?: any): any; + + // If value is not provided, undefined is gonna be used since the implementation + // does not check the parameter. Let's force a value for consistency. If consumer + // whants to undefine it, pass the undefined value explicitly. + assign(context: any, value: any): any; + } + + /////////////////////////////////////////////////////////////////////////// + // LocationService + // see http://docs.angularjs.org/api/ng.$location + // see http://docs.angularjs.org/api/ng.$locationProvider + // see http://docs.angularjs.org/guide/dev_guide.services.$location + /////////////////////////////////////////////////////////////////////////// + interface ILocationService { + absUrl(): string; + hash(): string; + hash(newHash: string): ILocationService; + host(): string; + path(): string; + path(newPath: string): ILocationService; + port(): number; + protocol(): string; + replace(): ILocationService; + search(): any; + search(parametersMap: any): ILocationService; + search(parameter: string, parameterValue: any): ILocationService; + url(): string; + url(url: string): ILocationService; + } + + interface ILocationProvider extends IServiceProvider { + hashPrefix(): string; + hashPrefix(prefix: string): ILocationProvider; + html5Mode(): boolean; + + // Documentation states that parameter is string, but + // implementation tests it as boolean, which makes more sense + // since this is a toggler + html5Mode(active: boolean): ILocationProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // DocumentService + // see http://docs.angularjs.org/api/ng.$document + /////////////////////////////////////////////////////////////////////////// + interface IDocumentService extends Document {} + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ng.$exceptionHandler + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerService { + (exception: Error, cause?: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // RootElementService + // see http://docs.angularjs.org/api/ng.$rootElement + /////////////////////////////////////////////////////////////////////////// + interface IRootElementService extends JQuery {} + + /////////////////////////////////////////////////////////////////////////// + // QService + // see http://docs.angularjs.org/api/ng.$q + /////////////////////////////////////////////////////////////////////////// + interface IQService { + all(promises: IPromise[]): IPromise; + defer(): IDeferred; + reject(reason?: any): IPromise; + when(value: T): IPromise; + } + + interface IPromise { + then(successCallback: (promiseValue: T) => IHttpPromise, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; + then(successCallback: (promiseValue: T) => IPromise, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; + then(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult, notifyCallback?: (state: any) => any): IPromise; + + + catch(onRejected: (reason: any) => IHttpPromise): IPromise; + catch(onRejected: (reason: any) => IPromise): IPromise; + catch(onRejected: (reason: any) => TResult): IPromise; + + finally(finallyCallback: ()=>any):IPromise; + } + + interface IDeferred { + resolve(value?: T): void; + reject(reason?: any): void; + notify(state?:any): void; + promise: IPromise; + } + + /////////////////////////////////////////////////////////////////////////// + // AnchorScrollService + // see http://docs.angularjs.org/api/ng.$anchorScroll + /////////////////////////////////////////////////////////////////////////// + interface IAnchorScrollService { + (): void; + } + + interface IAnchorScrollProvider extends IServiceProvider { + disableAutoScrolling(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CacheFactoryService + // see http://docs.angularjs.org/api/ng.$cacheFactory + /////////////////////////////////////////////////////////////////////////// + interface ICacheFactoryService { + // Lets not foce the optionsMap to have the capacity member. Even though + // it's the ONLY option considered by the implementation today, a consumer + // might find it useful to associate some other options to the cache object. + //(cacheId: string, optionsMap?: { capacity: number; }): CacheObject; + (cacheId: string, optionsMap?: { capacity: number; }): ICacheObject; + + // Methods bellow are not documented + info(): any; + get (cacheId: string): ICacheObject; + } + + interface ICacheObject { + info(): { + id: string; + size: number; + + // Not garanteed to have, since it's a non-mandatory option + //capacity: number; + }; + put(key: string, value?: any): void; + get (key: string): any; + remove(key: string): void; + removeAll(): void; + destroy(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CompileService + // see http://docs.angularjs.org/api/ng.$compile + // see http://docs.angularjs.org/api/ng.$compileProvider + /////////////////////////////////////////////////////////////////////////// + interface ICompileService { + (element: string, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: Element, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: JQuery, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction; + } + + interface ICompileProvider extends IServiceProvider { + directive(name: string, directiveFactory: Function): ICompileProvider; + + // Undocumented, but it is there... + directive(directivesMap: any): ICompileProvider; + } + + interface ITemplateLinkingFunction { + // Let's hint but not force cloneAttachFn's signature + (scope: IScope, cloneAttachFn?: (clonedElement?: JQuery, scope?: IScope) => any): JQuery; + } + + /////////////////////////////////////////////////////////////////////////// + // ControllerService + // see http://docs.angularjs.org/api/ng.$controller + // see http://docs.angularjs.org/api/ng.$controllerProvider + /////////////////////////////////////////////////////////////////////////// + interface IControllerService { + // Although the documentation doesn't state this, locals are optional + (controllerConstructor: Function, locals?: any): any; + (controllerName: string, locals?: any): any; + } + + interface IControllerProvider extends IServiceProvider { + register(name: string, controllerConstructor: Function): void; + register(name: string, dependencyAnnotadedConstructor: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpService + // see http://docs.angularjs.org/api/ng.$http + /////////////////////////////////////////////////////////////////////////// + interface IHttpService { + // At least moethod and url must be provided... + (config: IRequestConfig): IHttpPromise; + get (url: string, RequestConfig?: any): IHttpPromise; + delete (url: string, RequestConfig?: any): IHttpPromise; + head(url: string, RequestConfig?: any): IHttpPromise; + jsonp(url: string, RequestConfig?: any): IHttpPromise; + post(url: string, data: any, RequestConfig?: any): IHttpPromise; + put(url: string, data: any, RequestConfig?: any): IHttpPromise; + defaults: IRequestConfig; + + // For debugging, BUT it is documented as public, so... + pendingRequests: any[]; + } + + // This is just for hinting. + // Some opetions might not be available depending on the request. + // see http://docs.angularjs.org/api/ng.$http#Usage for options explanations + interface IRequestConfig { + method: string; + url: string; + params?: any; + + // XXX it has it's own structure... perhaps we should define it in the future + headers?: any; + + cache?: any; + withCredentials?: boolean; + + // These accept multiple types, so let's define them as any + data?: any; + transformRequest?: any; + transformResponse?: any; + timeout?: any; // number | promise + } + + interface IHttpPromiseCallback { + (data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): void; + } + + interface IHttpPromiseCallbackArg { + data?: T; + status?: number; + headers?: (headerName: string) => string; + config?: IRequestConfig; + } + + interface IHttpPromise extends IPromise { + success(callback: IHttpPromiseCallback): IHttpPromise; + error(callback: IHttpPromiseCallback): IHttpPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + } + + interface IHttpProvider extends IServiceProvider { + defaults: IRequestConfig; + interceptors: any[]; + responseInterceptors: any[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ng.$httpBackend + // You should never need to use this service directly. + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + // XXX Perhaps define callback signature in the future + (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // InterpolateService + // see http://docs.angularjs.org/api/ng.$interpolate + // see http://docs.angularjs.org/api/ng.$interpolateProvider + /////////////////////////////////////////////////////////////////////////// + interface IInterpolateService { + (text: string, mustHaveExpression?: boolean): IInterpolationFunction; + endSymbol(): string; + startSymbol(): string; + } + + interface IInterpolationFunction { + (context: any): string; + } + + interface IInterpolateProvider extends IServiceProvider { + startSymbol(): string; + startSymbol(value: string): IInterpolateProvider; + endSymbol(): string; + endSymbol(value: string): IInterpolateProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // TemplateCacheService + // see http://docs.angularjs.org/api/ng.$templateCache + /////////////////////////////////////////////////////////////////////////// + interface ITemplateCacheService extends ICacheObject {} + + /////////////////////////////////////////////////////////////////////////// + // RootScopeService + // see http://docs.angularjs.org/api/ng.$rootScope + /////////////////////////////////////////////////////////////////////////// + interface IRootScopeService extends IScope {} + + /////////////////////////////////////////////////////////////////////////// + // SCEService + // see http://docs.angularjs.org/api/ng.$sce + /////////////////////////////////////////////////////////////////////////// + interface ISCEService { + getTrusted(type: string, mayBeTrusted: any): any; + getTrustedCss(value: any): any; + getTrustedHtml(value: any): any; + getTrustedJs(value: any): any; + getTrustedResourceUrl(value: any): any; + getTrustedUrl(value: any): any; + parse(type: string, expression: string): (context: any, locals: any) => any; + parseAsCss(expression: string): (context: any, locals: any) => any; + parseAsHtml(expression: string): (context: any, locals: any) => any; + parseAsJs(expression: string): (context: any, locals: any) => any; + parseAsResourceUrl(expression: string): (context: any, locals: any) => any; + parseAsUrl(expression: string): (context: any, locals: any) => any; + trustAs(type: string, value: any): any; + trustAsHtml(value: any): any; + trustAsJs(value: any): any; + trustAsResourceUrl(value: any): any; + trustAsUrl(value: any): any; + isEnabled(): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEProvider + // see http://docs.angularjs.org/api/ng.$sceProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEProvider extends IServiceProvider { + enabled(value: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateService + // see http://docs.angularjs.org/api/ng.$sceDelegate + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateService { + getTrusted(type: string, mayBeTrusted: any): any; + trustAs(type: string, value: any): any; + valueOf(value: any): any; + } + + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateProvider + // see http://docs.angularjs.org/api/ng.$sceDelegateProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateProvider extends IServiceProvider { + resourceUrlBlacklist(blacklist: any[]): void; + resourceUrlWhitelist(whitelist: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // Directive + // see http://docs.angularjs.org/api/ng.$compileProvider#directive + // and http://docs.angularjs.org/guide/directive + /////////////////////////////////////////////////////////////////////////// + + interface IDirective{ + compile?: + (templateElement: any, + templateAttributes: IAttributes, + transclude: (scope: IScope, cloneLinkingFn: Function) => void + ) => any; + controller?: any; + controllerAs?: string; + link?: + (scope: IScope, + instanceElement: any, + instanceAttributes: IAttributes, + controller: any + ) => void; + name?: string; + priority?: number; + replace?: boolean; + require?: any; + restrict?: string; + scope?: any; + template?: any; + templateUrl?: any; + terminal?: boolean; + transclude?: any; + } + + /////////////////////////////////////////////////////////////////////////// + // angular.element + // when calling angular.element, angular returns a jQuery object, + // augmented with additional methods like e.g. scope. + // see: http://docs.angularjs.org/api/angular.element + /////////////////////////////////////////////////////////////////////////// + interface IAugmentedJQueryStatic extends JQueryStatic { + (selector: string, context?: any): IAugmentedJQuery; + (element: Element): IAugmentedJQuery; + (object: {}): IAugmentedJQuery; + (elementArray: Element[]): IAugmentedJQuery; + (object: JQuery): IAugmentedJQuery; + (func: Function): IAugmentedJQuery; + (array: any[]): IAugmentedJQuery; + (): IAugmentedJQuery; + } + + interface IAugmentedJQuery extends JQuery { + // TODO: events, how to define? + //$destroy + + find(selector: string): IAugmentedJQuery; + find(element: any): IAugmentedJQuery; + find(obj: JQuery): IAugmentedJQuery; + + controller(name: string): any; + injector(): any; + scope(): IScope; + + inheritedData(key: string, value: any): JQuery; + inheritedData(obj: { [key: string]: any; }): JQuery; + inheritedData(key?: string): any; + + + } + + + /////////////////////////////////////////////////////////////////////////// + // AUTO module (angular.js) + /////////////////////////////////////////////////////////////////////////// + export module auto { + + /////////////////////////////////////////////////////////////////////// + // InjectorService + // see http://docs.angularjs.org/api/AUTO.$injector + /////////////////////////////////////////////////////////////////////// + interface IInjectorService { + annotate(fn: Function): string[]; + annotate(inlineAnnotadedFunction: any[]): string[]; + get (name: string): any; + instantiate(typeConstructor: Function, locals?: any): any; + invoke(func: Function, context?: any, locals?: any): any; + } + + /////////////////////////////////////////////////////////////////////// + // ProvideService + // see http://docs.angularjs.org/api/AUTO.$provide + /////////////////////////////////////////////////////////////////////// + interface IProvideService { + // Documentation says it returns the registered instance, but actual + // implementation does not return anything. + // constant(name: string, value: any): any; + constant(name: string, value: any): void; + + decorator(name: string, decorator: Function): void; + decorator(name: string, decoratorInline: any[]): void; + factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider; + factory(name: string, inlineAnnotadedFunction: any[]): ng.IServiceProvider; + provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider; + provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider; + service(name: string, constructor: Function): ng.IServiceProvider; + value(name: string, value: any): ng.IServiceProvider; + } + + } +} diff --git a/src/Web/Scripts/typings/jasmine/jasmine.d.ts b/src/Web/Scripts/typings/jasmine/jasmine.d.ts new file mode 100644 index 0000000..82c1678 --- /dev/null +++ b/src/Web/Scripts/typings/jasmine/jasmine.d.ts @@ -0,0 +1,392 @@ +// Type definitions for Jasmine 1.2 +// Project: http://pivotal.github.com/jasmine/ +// Definitions by: Boris Yankov +// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped + + +declare function describe(description: string, specDefinitions: () => void): void; +declare function xdescribe(description: string, specDefinitions: () => void): void; + +declare function it(expectation: string, assertion: () => void): void; +declare function it(expectation: string, assertion: (done: (err?: any) => void) => void): void; +declare function xit(expectation: string, assertion: () => void): void; + +declare function beforeEach(action: () => void): void; +declare function afterEach(action: () => void): void; + +declare function expect(spy: Function): jasmine.Matchers; +//declare function expect(spy: jasmine.Spy): jasmine.Matchers; +declare function expect(actual: any): jasmine.Matchers; + +declare function spyOn(object: any, method: string): jasmine.Spy; + +declare function runs(asyncMethod: Function): void; +declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void; +declare function waits(timeout?: number): void; + +declare module jasmine { + + var Clock: Clock; + + function any(aclass: any): Any; + function objectContaining(sample: any): ObjectContaining; + function createSpy(name: string, originalFn?: Function): Spy; + function createSpyObj(baseName: string, methodNames: any[]): any; + function createSpyObj(baseName: string, methodNames: any[]): T; + function pp(value: any): string; + function getEnv(): Env; + + interface Any { + + new (expectedClass: any): any; + + jasmineMatches(other: any): boolean; + jasmineToString(): string; + } + + interface ObjectContaining { + new (sample: any): any; + + jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; + jasmineToString(): string; + } + + interface Block { + + new (env: Env, func: SpecFunction, spec: Spec): any; + + execute(onComplete: () => void): void; + } + + interface WaitsBlock extends Block { + new (env: Env, timeout: number, spec: Spec): any; + } + + interface WaitsForBlock extends Block { + new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any; + } + + interface Clock { + reset(): void; + tick(millis: number): void; + runFunctionsWithinRange(oldMillis: number, nowMillis: number): void; + scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void; + useMock(): void; + installMock(): void; + uninstallMock(): void; + real: void; + assertInstalled(): void; + isInstalled(): boolean; + installed: any; + } + + interface Env { + setTimeout: any; + clearTimeout: void; + setInterval: any; + clearInterval: void; + updateInterval: number; + + currentSpec: Spec; + + matchersClass: Matchers; + + version(): any; + versionString(): string; + nextSpecId(): number; + addReporter(reporter: Reporter): void; + execute(): void; + describe(description: string, specDefinitions: () => void): Suite; + beforeEach(beforeEachFunction: () => void): void; + currentRunner(): Runner; + afterEach(afterEachFunction: () => void): void; + xdescribe(desc: string, specDefinitions: () => void): XSuite; + it(description: string, func: () => void): Spec; + xit(desc: string, func: () => void): XSpec; + compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean; + compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; + equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; + contains_(haystack: any, needle: any): boolean; + addEqualityTester(equalityTester: (a: any, b: any, env: Env, mismatchKeys: string[], mismatchValues: string[]) => boolean): void; + specFilter(spec: Spec): boolean; + } + + interface FakeTimer { + + new (): any; + + reset(): void; + tick(millis: number): void; + runFunctionsWithinRange(oldMillis: number, nowMillis: number): void; + scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void; + } + + interface HtmlReporter { + new (): any; + } + + interface Result { + type: string; + } + + interface NestedResults extends Result { + description: string; + + totalCount: number; + passedCount: number; + failedCount: number; + + skipped: boolean; + + rollupCounts(result: NestedResults): void; + log(values: any): void; + getItems(): Result[]; + addResult(result: Result): void; + passed(): boolean; + } + + interface MessageResult extends Result { + values: any; + trace: Trace; + } + + interface ExpectationResult extends Result { + matcherName: string; + passed(): boolean; + expected: any; + actual: any; + message: string; + trace: Trace; + } + + interface Trace { + name: string; + message: string; + stack: any; + } + + interface PrettyPrinter { + + new (): any; + + format(value: any): void; + iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void; + emitScalar(value: any): void; + emitString(value: string): void; + emitArray(array: any[]): void; + emitObject(obj: any): void; + append(value: any): void; + } + + interface StringPrettyPrinter extends PrettyPrinter { + } + + interface Queue { + + new (env: any): any; + + env: Env; + ensured: boolean[]; + blocks: Block[]; + running: boolean; + index: number; + offset: number; + abort: boolean; + + addBefore(block: Block, ensure?: boolean): void; + add(block: any, ensure?: boolean): void; + insertNext(block: any, ensure?: boolean): void; + start(onComplete?: () => void): void; + isRunning(): boolean; + next_(): void; + results(): NestedResults; + } + + interface Matchers { + + new (env: Env, actual: any, spec: Env, isNot?: boolean): any; + + env: Env; + actual: any; + spec: Env; + isNot?: boolean; + message(): any; + + toBe(expected: any): boolean; + toNotBe(expected: any): boolean; + toEqual(expected: any): boolean; + toNotEqual(expected: any): boolean; + toMatch(expected: any): boolean; + toNotMatch(expected: any): boolean; + toBeDefined(): boolean; + toBeUndefined(): boolean; + toBeNull(): boolean; + toBeNaN(): boolean; + toBeTruthy(): boolean; + toBeFalsy(): boolean; + toHaveBeenCalled(): boolean; + wasNotCalled(): boolean; + toHaveBeenCalledWith(...params: any[]): boolean; + toContain(expected: any): boolean; + toNotContain(expected: any): boolean; + toBeLessThan(expected: any): boolean; + toBeGreaterThan(expected: any): boolean; + toBeCloseTo(expected: any, precision: any): boolean; + toContainHtml(expected: string): boolean; + toContainText(expected: string): boolean; + toThrow(expected?: any): boolean; + not: Matchers; + + Any: Any; + } + + interface Reporter { + reportRunnerStarting(runner: Runner): void; + reportRunnerResults(runner: Runner): void; + reportSuiteResults(suite: Suite): void; + reportSpecStarting(spec: Spec): void; + reportSpecResults(spec: Spec): void; + log(str: string): void; + } + + interface MultiReporter extends Reporter { + addReporter(reporter: Reporter): void; + } + + interface Runner { + + new (env: Env): any; + + execute(): void; + beforeEach(beforeEachFunction: SpecFunction): void; + afterEach(afterEachFunction: SpecFunction): void; + finishCallback(): void; + addSuite(suite: Suite): void; + add(block: Block): void; + specs(): Spec[]; + suites(): Suite[]; + topLevelSuites(): Suite[]; + results(): NestedResults; + } + + interface SpecFunction { + (spec?: Spec): void; + } + + interface SuiteOrSpec { + id: number; + env: Env; + description: string; + queue: Queue; + } + + interface Spec extends SuiteOrSpec { + + new (env: Env, suite: Suite, description: string): any; + + suite: Suite; + + afterCallbacks: SpecFunction[]; + spies_: Spy[]; + + results_: NestedResults; + matchersClass: Matchers; + + getFullName(): string; + results(): NestedResults; + log(arguments: any): any; + runs(func: SpecFunction): Spec; + addToQueue(block: Block): void; + addMatcherResult(result: Result): void; + expect(actual: any): any; + waits(timeout: number): Spec; + waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; + fail(e?: any): void; + getMatchersClass_(): Matchers; + addMatchers(matchersPrototype: any): void; + finishCallback(): void; + finish(onComplete?: () => void): void; + after(doAfter: SpecFunction): void; + execute(onComplete?: () => void): any; + addBeforesAndAftersToQueue(): void; + explodes(): void; + spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy; + removeAllSpies(): void; + } + + interface XSpec { + id: number; + runs(): void; + } + + interface Suite extends SuiteOrSpec { + + new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any; + + parentSuite: Suite; + + getFullName(): string; + finish(onComplete?: () => void): void; + beforeEach(beforeEachFunction: SpecFunction): void; + afterEach(afterEachFunction: SpecFunction): void; + results(): NestedResults; + add(suiteOrSpec: SuiteOrSpec): void; + specs(): Spec[]; + suites(): Suite[]; + children(): any[]; + execute(onComplete?: () => void): void; + } + + interface XSuite { + execute(): void; + } + + interface Spy { + (...params: any[]): any; + + identity: string; + calls: any[]; + mostRecentCall: { args: any[]; }; + argsForCall: any[]; + wasCalled: boolean; + callCount: number; + + andReturn(value: any): Spy; + andCallThrough(): Spy; + andCallFake(fakeFunc: Function): Spy; + } + + interface Util { + inherit(childClass: Function, parentClass: Function): any; + formatException(e: any): any; + htmlEscape(str: string): string; + argsToArray(args: any): any; + extend(destination: any, source: any): any; + } + + interface JsApiReporter extends Reporter { + + started: boolean; + finished: boolean; + result: any; + messages: any; + + new (): any; + + suites(): Suite[]; + summarize_(suiteOrSpec: SuiteOrSpec): any; + results(): any; + resultsForSpec(specId: any): any; + log(str: any): any; + resultsForSpecs(specIds: any): any; + summarizeResult_(result: any): any; + } + + interface Jasmine { + Spec: Spec; + Clock: Clock; + util: Util; + } + + export var HtmlReporter: any; +} diff --git a/src/Web/Scripts/typings/jquery/jquery.d.ts b/src/Web/Scripts/typings/jquery/jquery.d.ts new file mode 100644 index 0000000..e68d50e --- /dev/null +++ b/src/Web/Scripts/typings/jquery/jquery.d.ts @@ -0,0 +1,1545 @@ +/* ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +// Typing for the jQuery library, version 1.10.x / 2.0.x +// Project: http://jquery.com/ +// Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton, Diullei Gomes , Tass Iliopoulos , Jason Swearingen, Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* + Interface for the AJAX setting that will configure the AJAX request +*/ +interface JQueryAjaxSettings { + /** + * The content type sent in the request header that tells the server what kind of response it will accept in return. If the accepts setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. + */ + accepts?: any; + /** + * By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success(). + */ + async?: boolean; + /** + * A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request. + */ + beforeSend? (jqXHR: JQueryXHR, settings: JQueryAjaxSettings): any; + /** + * If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET. + */ + cache?: boolean; + /** + * A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request ("success", "notmodified", "error", "timeout", "abort", or "parsererror"). As of jQuery 1.5, the complete setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. + */ + complete? (jqXHR: JQueryXHR, textStatus: string): any; + /** + * An object of string/regular-expression pairs that determine how jQuery will parse the response, given its content type. (version added: 1.5) + */ + contents?: { [key: string]: any; }; + //According to jQuery.ajax source code, ajax's option actually allows contentType to set to "false" + // https://github.com/borisyankov/DefinitelyTyped/issues/742 + /** + * When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding. + */ + contentType?: any; + /** + * This object will be made the context of all Ajax-related callbacks. By default, the context is an object that represents the ajax settings used in the call ($.ajaxSettings merged with the settings passed to $.ajax). + */ + context?: any; + /** + * An object containing dataType-to-dataType converters. Each converter's value is a function that returns the transformed value of the response. (version added: 1.5) + */ + converters?: { [key: string]: any; }; + /** + * If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. (version added: 1.5) + */ + crossDomain?: boolean; + /** + * Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below). + */ + data?: any; + /** + * A function to be used to handle the raw response data of XMLHttpRequest.This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter. + */ + dataFilter? (data: any, ty: any): any; + /** + * The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). + */ + dataType?: string; + /** + * A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event. + */ + error? (jqXHR: JQueryXHR, textStatus: string, errorThrow: string): any; + /** + * Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events. + */ + global?: boolean; + /** + * An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added, but its default XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from within the beforeSend function. (version added: 1.5) + */ + headers?: { [key: string]: any; }; + /** + * Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header. In jQuery 1.4 this technique also checks the 'etag' specified by the server to catch unmodified data. + */ + ifModified?: boolean; + /** + * Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: file, *-extension, and widget. If the isLocal setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. (version added: 1.5.1) + */ + isLocal?: boolean; + /** + * Override the callback function name in a jsonp request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" } + */ + jsonp?: string; + /** + * Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function. + */ + jsonpCallback?: any; + /** + * A mime type to override the XHR mime type. (version added: 1.5.1) + */ + mimeType?: string; + /** + * A password to be used with XMLHttpRequest in response to an HTTP access authentication request. + */ + password?: string; + /** + * By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false. + */ + processData?: boolean; + /** + * Only applies when the "script" transport is used (e.g., cross-domain requests with "jsonp" or "script" dataType and "GET" type). Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script. + */ + scriptCharset?: string; + /** + * An object of numeric HTTP codes and functions to be called when the response has the corresponding code. f the request is successful, the status code functions take the same parameters as the success callback; if it results in an error (including 3xx redirect), they take the same parameters as the error callback. (version added: 1.5) + */ + statusCode?: { [key: string]: any; }; + /** + * A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. + */ + success? (data: any, textStatus: string, jqXHR: JQueryXHR): any; + /** + * Set a timeout (in milliseconds) for the request. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period. + */ + timeout?: number; + /** + * Set this to true if you wish to use the traditional style of param serialization. + */ + traditional?: boolean; + /** + * The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers. + */ + type?: string; + /** + * A string containing the URL to which the request is sent. + */ + url?: string; + /** + * A username to be used with XMLHttpRequest in response to an HTTP access authentication request. + */ + username?: string; + /** + * Callback for creating the XMLHttpRequest object. Defaults to the ActiveXObject when available (IE), the XMLHttpRequest otherwise. Override to provide your own implementation for XMLHttpRequest or enhancements to the factory. + */ + xhr?: any; + /** + * An object of fieldName-fieldValue pairs to set on the native XHR object. For example, you can use it to set withCredentials to true for cross-domain requests if needed. In jQuery 1.5, the withCredentials property was not propagated to the native XHR and thus CORS requests requiring it would ignore this flag. For this reason, we recommend using jQuery 1.5.1+ should you require the use of it. (version added: 1.5.1) + */ + xhrFields?: { [key: string]: any; }; +} + +/* + Interface for the jqXHR object +*/ +interface JQueryXHR extends XMLHttpRequest, JQueryPromise { + overrideMimeType(mimeType: string): any; + abort(statusText?: string): void; +} + +/* + Interface for the JQuery callback +*/ +interface JQueryCallback { + add(...callbacks: any[]): any; + disable(): any; + empty(): any; + fire(...arguments: any[]): any; + fired(): boolean; + fireWith(context: any, ...args: any[]): any; + has(callback: any): boolean; + lock(): any; + locked(): boolean; + remove(...callbacks: any[]): any; +} + +/* + Allows jQuery Promises to interop with non-jQuery promises +*/ +interface JQueryGenericPromise { + then(onFulfill: (value: T) => U, onReject?: (reason: any) => U): JQueryGenericPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (reason: any) => U): JQueryGenericPromise; + then(onFulfill: (value: T) => U, onReject?: (reason: any) => JQueryGenericPromise): JQueryGenericPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (reason: any) => JQueryGenericPromise): JQueryGenericPromise; +} + +/* + Interface for the JQuery promise, part of callbacks +*/ +interface JQueryPromise { + // Generic versions of callbacks + always(...alwaysCallbacks: T[]): JQueryPromise; + done(...doneCallbacks: T[]): JQueryPromise; + fail(...failCallbacks: T[]): JQueryPromise; + progress(...progressCallbacks: T[]): JQueryPromise; + + always(...alwaysCallbacks: any[]): JQueryPromise; + done(...doneCallbacks: any[]): JQueryPromise; + fail(...failCallbacks: any[]): JQueryPromise; + progress(...progressCallbacks: any[]): JQueryPromise; + + // Deprecated - given no typings + pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise; + + then(onFulfill: (value: T) => U, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise; + then(onFulfill: (value: T) => U, onReject?: (...reasons: any[]) => JQueryGenericPromise, onProgress?: (...progression: any[]) => any): JQueryPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (...reasons: any[]) => JQueryGenericPromise, onProgress?: (...progression: any[]) => any): JQueryPromise; + + // Because JQuery Promises Suck + then(onFulfill: (...values: any[]) => U, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise; + then(onFulfill: (...values: any[]) => JQueryGenericPromise, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise; + then(onFulfill: (...values: any[]) => U, onReject?: (...reasons: any[]) => JQueryGenericPromise, onProgress?: (...progression: any[]) => any): JQueryPromise; + then(onFulfill: (...values: any[]) => JQueryGenericPromise, onReject?: (...reasons: any[]) => JQueryGenericPromise, onProgress?: (...progression: any[]) => any): JQueryPromise; +} + +/* + Interface for the JQuery deferred, part of callbacks +*/ +interface JQueryDeferred extends JQueryPromise { + // Generic versions of callbacks + always(...alwaysCallbacks: T[]): JQueryDeferred; + done(...doneCallbacks: T[]): JQueryDeferred; + fail(...failCallbacks: T[]): JQueryDeferred; + progress(...progressCallbacks: T[]): JQueryDeferred; + + always(...alwaysCallbacks: any[]): JQueryDeferred; + done(...doneCallbacks: any[]): JQueryDeferred; + fail(...failCallbacks: any[]): JQueryDeferred; + progress(...progressCallbacks: any[]): JQueryDeferred; + + notify(...args: any[]): JQueryDeferred; + notifyWith(context: any, ...args: any[]): JQueryDeferred; + + reject(...args: any[]): JQueryDeferred; + rejectWith(context: any, ...args: any[]): JQueryDeferred; + + resolve(val: T): JQueryDeferred; + resolve(...args: any[]): JQueryDeferred; + resolveWith(context: any, ...args: any[]): JQueryDeferred; + state(): string; + + promise(target?: any): JQueryPromise; +} + +/* + Interface of the JQuery extension of the W3C event object +*/ + +interface BaseJQueryEventObject extends Event { + data: any; + delegateTarget: Element; + isDefaultPrevented(): boolean; + isImmediatePropogationStopped(): boolean; + isPropagationStopped(): boolean; + namespace: string; + preventDefault(): any; + relatedTarget: Element; + result: any; + stopImmediatePropagation(): void; + stopPropagation(): void; + pageX: number; + pageY: number; + which: number; + metaKey: boolean; +} + +interface JQueryInputEventObject extends BaseJQueryEventObject { + altKey: boolean; + ctrlKey: boolean; + metaKey: boolean; + shiftKey: boolean; +} + +interface JQueryMouseEventObject extends JQueryInputEventObject { + button: number; + clientX: number; + clientY: number; + offsetX: number; + offsetY: number; + pageX: number; + pageY: number; + screenX: number; + screenY: number; +} + +interface JQueryKeyEventObject extends JQueryInputEventObject { + char: any; + charCode: number; + key: any; + keyCode: number; +} + +interface JQueryPopStateEventObject extends BaseJQueryEventObject { + originalEvent: PopStateEvent; +} + +interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject, JQueryPopStateEventObject { +} + +/* + Collection of properties of the current browser +*/ + +interface JQuerySupport { + ajax?: boolean; + boxModel?: boolean; + changeBubbles?: boolean; + checkClone?: boolean; + checkOn?: boolean; + cors?: boolean; + cssFloat?: boolean; + hrefNormalized?: boolean; + htmlSerialize?: boolean; + leadingWhitespace?: boolean; + noCloneChecked?: boolean; + noCloneEvent?: boolean; + opacity?: boolean; + optDisabled?: boolean; + optSelected?: boolean; + scriptEval? (): boolean; + style?: boolean; + submitBubbles?: boolean; + tbody?: boolean; +} + +interface JQueryParam { + (obj: any): string; + (obj: any, traditional: boolean): string; +} + +/** + * The interface used to construct jQuery events (with $.Event). It is + * defined separately instead of inline in JQueryStatic to allow + * overriding the construction function with specific strings + * returning specific event objects. + */ +interface JQueryEventConstructor { + (name: string, eventProperties?: any): JQueryEventObject; + new (name: string, eventProperties?: any): JQueryEventObject; +} + +/** + * The interface used to specify easing functions. + */ +interface JQueryEasing { + linear(p: number): number; + swing(p: number): number; +} + +/* + Static members of jQuery (those on $ and jQuery themselves) +*/ +interface JQueryStatic { + + /** + * Perform an asynchronous HTTP (Ajax) request. + * + * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). + */ + ajax(settings: JQueryAjaxSettings): JQueryXHR; + /** + * Perform an asynchronous HTTP (Ajax) request. + * + * @param url A string containing the URL to which the request is sent. + * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). + */ + ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR; + + /** + * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). + * + * @param dataTypes An optional string containing one or more space-separated dataTypes + * @param handler A handler to set default values for future Ajax requests. + */ + ajaxPrefilter(dataTypes: string, handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; + /** + * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). + * + * @param handler A handler to set default values for future Ajax requests. + */ + ajaxPrefilter(handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; + + ajaxSettings: JQueryAjaxSettings; + + /** + * Set default values for future Ajax requests. Its use is not recommended. + * + * @param options A set of key/value pairs that configure the default Ajax request. All options are optional. + */ + ajaxSetup(options: JQueryAjaxSettings): void; + + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load a JavaScript file from the server using a GET HTTP request, then execute it. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + */ + getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + + param: JQueryParam; + + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + + /** + * A multi-purpose callbacks list object that provides a powerful way to manage callback lists. + * + * @param flags An optional list of space-separated flags that change how the callback list behaves. + */ + Callbacks(flags?: string): JQueryCallback; + + /** + * Holds or releases the execution of jQuery's ready event. + * + * @param hold Indicates whether the ready hold is being requested or released + */ + holdReady(hold: boolean): void; + + (selector: string, context?: any): JQuery; + (element: Element): JQuery; + (object: {}): JQuery; + (elementArray: Element[]): JQuery; + (object: JQuery): JQuery; + (func: Function): JQuery; + (array: any[]): JQuery; + (): JQuery; + + /** + * Relinquish jQuery's control of the $ variable. + * + * @param removeAll A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself). + */ + noConflict(removeAll?: boolean): Object; + + /** + * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. + * + * @param deferreds One or more Deferred objects, or plain JavaScript objects. + */ + when(...deferreds: JQueryGenericPromise[]): JQueryPromise; + /** + * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. + * + * @param deferreds One or more Deferred objects, or plain JavaScript objects. + */ + when(...deferreds: T[]): JQueryPromise; + /** + * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. + * + * @param deferreds One or more Deferred objects, or plain JavaScript objects. + */ + when(...deferreds: any[]): JQueryPromise; + + cssHooks: { [key: string]: any; }; + cssNumber: any; + + /** + * Store arbitrary data associated with the specified element. Returns the value that was set. + * + * @param element The DOM element to associate with the data. + * @param key A string naming the piece of data to set. + * @param value The new data value. + */ + data(element: Element, key: string, value: T): T; + /** + * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element. + * + * @param element The DOM element to associate with the data. + * @param key A string naming the piece of data to set. + */ + data(element: Element, key: string): any; + /** + * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element. + * + * @param element The DOM element to associate with the data. + */ + data(element: Element): any; + + dequeue(element: Element, queueName?: string): any; + + hasData(element: Element): boolean; + + queue(element: Element, queueName?: string): any[]; + queue(element: Element, queueName: string, newQueueOrCallback: any): JQuery; + + removeData(element: Element, name?: string): JQuery; + + // Deferred + Deferred(beforeStart?: (deferred: JQueryDeferred) => any): JQueryDeferred; + + // Effects + fx: { tick: () => void; interval: number; stop: () => void; speeds: { slow: number; fast: number; }; off: boolean; step: any; }; + + // Events + proxy(fn: (...args: any[]) => any, context: any, ...args: any[]): any; + proxy(context: any, name: string, ...args: any[]): any; + + Event: JQueryEventConstructor; + + // Internals + error(message: any): JQuery; + + // Miscellaneous + expr: any; + fn: any; //TODO: Decide how we want to type this + isReady: boolean; + + // Properties + support: JQuerySupport; + + // Utilities + contains(container: Element, contained: Element): boolean; + + each(collection: any, callback: (indexInArray: any, valueOfElement: any) => any): any; + each(collection: JQuery, callback: (indexInArray: number, valueOfElement: HTMLElement) => any): any; + each(collection: T[], callback: (indexInArray: number, valueOfElement: T) => any): any; + + extend(target: any, ...objs: any[]): any; + extend(deep: boolean, target: any, ...objs: any[]): any; + + globalEval(code: string): any; + + grep(array: T[], func: (elementOfArray: T, indexInArray: number) => boolean, invert?: boolean): T[]; + + inArray(value: T, array: T[], fromIndex?: number): number; + + isArray(obj: any): boolean; + isEmptyObject(obj: any): boolean; + isFunction(obj: any): boolean; + isNumeric(value: any): boolean; + isPlainObject(obj: any): boolean; + isWindow(obj: any): boolean; + isXMLDoc(node: Node): boolean; + + makeArray(obj: any): any[]; + + map(array: T[], callback: (elementOfArray: T, indexInArray: number) => U): U[]; + map(array: any, callback: (elementOfArray: any, indexInArray: any) => any): any; + + merge(first: T[], second: T[]): T[]; + merge(first: T[], second: U[]): any[]; + + noop(): any; + + now(): number; + + parseJSON(json: string): any; + + /** + * Parses a string into an XML document. + * + * @param dataa well-formed XML string to be parsed + */ + parseXML(data: string): XMLDocument; + + queue(element: Element, queueName: string, newQueue: any[]): JQuery; + + trim(str: string): string; + + type(obj: any): string; + + unique(arr: any[]): 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?: HTMLElement, keepScripts?: boolean): any[]; + + Animation(elem: any, properties: any, options: any): any; + + easing: JQueryEasing; +} + +/* + The jQuery instance members +*/ +interface JQuery { + // AJAX + ajaxComplete(handler: any): JQuery; + ajaxError(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; + ajaxSend(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; + ajaxStart(handler: () => any): JQuery; + ajaxStop(handler: () => any): JQuery; + ajaxSuccess(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery; + + load(url: string, data?: any, complete?: any): JQuery; + + serialize(): string; + serializeArray(): any[]; + + // Attributes + addClass(classNames: string): JQuery; + addClass(func: (index: any, currentClass: any) => string): JQuery; + + // http://api.jquery.com/addBack/ + addBack(selector?: string): JQuery; + + + attr(attributeName: string): string; + attr(attributeName: string, value: any): JQuery; + attr(attributeName: string, func: (index: any, attr: any) => any): JQuery; + attr(map: any): JQuery; + + hasClass(className: string): boolean; + + html(): string; + html(htmlString: string): JQuery; + html(htmlContent: (index: number, oldhtml: string) => string): JQuery; + html(obj: JQuery): JQuery; + + prop(propertyName: string): any; + prop(propertyName: string, value: any): JQuery; + prop(map: any): JQuery; + prop(propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery; + + removeAttr(attributeName: string): JQuery; + + removeClass(className?: string): JQuery; + removeClass(func: (index: any, cls: any) => any): JQuery; + + removeProp(propertyName: string): JQuery; + + toggleClass(className: string, swtch?: boolean): JQuery; + toggleClass(swtch?: boolean): JQuery; + toggleClass(func: (index: any, cls: any, swtch: any) => any): JQuery; + + val(): any; + val(value: string[]): JQuery; + val(value: string): JQuery; + val(value: number): JQuery; + val(func: (index: any, value: any) => any): JQuery; + + /** + * Get the value of style properties for the first element in the set of matched elements. + * + * @param propertyName A CSS property. + */ + css(propertyName: string): string; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + */ + css(propertyName: string, value: string): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + */ + css(propertyName: string, value: number): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + */ + css(propertyName: string, value: string[]): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + */ + css(propertyName: string, value: number[]): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + css(propertyName: string, value: (index: number, value: string) => string): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + css(propertyName: string, value: (index: number, value: number) => number): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param properties An object of property-value pairs to set. + */ + css(properties: Object): JQuery; + + height(): number; + height(value: number): JQuery; + height(value: string): JQuery; + height(func: (index: any, height: any) => any): JQuery; + + innerHeight(): number; + innerHeight(value: number): JQuery; + + innerWidth(): number; + innerWidth(value: number): JQuery; + + offset(): { left: number; top: number; }; + offset(coordinates: any): JQuery; + offset(func: (index: any, coords: any) => any): JQuery; + + outerHeight(includeMargin?: boolean): number; + outerHeight(value: number, includeMargin?: boolean): JQuery; + + outerWidth(includeMargin?: boolean): number; + outerWidth(value: number, includeMargin?: boolean): JQuery; + + position(): { top: number; left: number; }; + + scrollLeft(): number; + scrollLeft(value: number): JQuery; + + scrollTop(): number; + scrollTop(value: number): JQuery; + + width(): number; + width(value: number): JQuery; + width(value: string): JQuery; + width(func: (index: any, height: any) => any): JQuery; + + // Data + clearQueue(queueName?: string): JQuery; + + data(key: string, value: any): JQuery; + data(obj: { [key: string]: any; }): JQuery; + data(key?: string): any; + + dequeue(queueName?: string): JQuery; + + removeData(nameOrList?: any): JQuery; + + // Deferred + promise(type?: any, target?: any): JQueryPromise; + + // Effects + animate(properties: any, duration?: any, complete?: Function): JQuery; + animate(properties: any, duration?: any, easing?: string, complete?: Function): JQuery; + animate(properties: any, options: { duration?: any; easing?: string; complete?: Function; step?: Function; queue?: boolean; specialEasing?: any; }): JQuery; + + delay(duration: number, queueName?: string): JQuery; + + fadeIn(duration?: any, callback?: any): JQuery; + fadeIn(duration?: any, easing?: string, callback?: any): JQuery; + + fadeOut(duration?: any, callback?: any): JQuery; + fadeOut(duration?: any, easing?: string, callback?: any): JQuery; + + fadeTo(duration: any, opacity: number, callback?: any): JQuery; + fadeTo(duration: any, opacity: number, easing?: string, callback?: any): JQuery; + + fadeToggle(duration?: any, callback?: any): JQuery; + fadeToggle(duration?: any, easing?: string, callback?: any): JQuery; + + finish(): JQuery; + + hide(duration?: any, callback?: any): JQuery; + hide(duration?: any, easing?: string, callback?: any): JQuery; + + show(duration?: any, callback?: any): JQuery; + show(duration?: any, easing?: string, callback?: any): JQuery; + + slideDown(duration?: any, callback?: any): JQuery; + slideDown(duration?: any, easing?: string, callback?: any): JQuery; + + slideToggle(duration?: any, callback?: any): JQuery; + slideToggle(duration?: any, easing?: string, callback?: any): JQuery; + + slideUp(duration?: any, callback?: any): JQuery; + slideUp(duration?: any, easing?: string, callback?: any): JQuery; + + stop(clearQueue?: boolean, jumpToEnd?: boolean): JQuery; + stop(queue?: any, clearQueue?: boolean, jumpToEnd?: boolean): JQuery; + + toggle(duration?: any, callback?: any): JQuery; + toggle(duration?: any, easing?: string, callback?: any): JQuery; + toggle(showOrHide: boolean): JQuery; + + // Events + bind(eventType: string, eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + bind(eventType: string, eventData: any, preventBubble: boolean): JQuery; + bind(eventType: string, preventBubble: boolean): JQuery; + bind(...events: any[]): JQuery; + + blur(handler: (eventObject: JQueryEventObject) => any): JQuery; + blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "change" event on an element. + */ + change(): JQuery; + /** + * Bind an event handler to the "change" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + change(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "change" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + change(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "click" event on an element. + */ + click(): JQuery; + /** + * Bind an event handler to the "click" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + */ + click(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "click" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + click(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "dblclick" event on an element. + */ + dblclick(): JQuery; + /** + * Bind an event handler to the "dblclick" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + dblclick(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "dblclick" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + dblclick(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + delegate(selector: any, eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "focus" event on an element. + */ + focus(): JQuery; + /** + * Bind an event handler to the "focus" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + focus(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "focus" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + focus(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Bind an event handler to the "focusin" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + focusin(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "focusin" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + focusin(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Bind an event handler to the "focusout" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + focusout(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "focusout" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + focusout(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements. + * + * @param handlerIn A function to execute when the mouse pointer enters the element. + * @param handlerOut A function to execute when the mouse pointer leaves the element. + */ + hover(handlerIn: (eventObject: JQueryEventObject) => any, handlerOut: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements. + * + * @param handlerInOut A function to execute when the mouse pointer enters or leaves the element. + */ + hover(handlerInOut: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "keydown" event on an element. + */ + keydown(): JQuery; + /** + * Bind an event handler to the "keydown" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + keydown(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; + /** + * Bind an event handler to the keydown"" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + keydown(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; + + /** + * Trigger the "keypress" event on an element. + */ + keypress(): JQuery; + /** + * Bind an event handler to the "keypress" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + keypress(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; + /** + * Bind an event handler to the "keypress" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + keypress(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; + + /** + * Trigger the "keyup" event on an element. + */ + keyup(): JQuery; + /** + * Bind an event handler to the "keyup" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + keyup(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; + /** + * Bind an event handler to the "keyup" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + keyup(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; + + /** + * Bind an event handler to the "load" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + load(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "load" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + load(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "mousedown" event on an element. + */ + mousedown(): JQuery; + /** + * Bind an event handler to the "mousedown" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mousedown(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mousedown" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mousedown(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseenter" event on an element. + */ + mouseenter(): JQuery; + /** + * Bind an event handler to be fired when the mouse enters an element. + * + * @param handler A function to execute when the event is triggered. + */ + mouseenter(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to be fired when the mouse enters an element. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseenter(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseleave" event on an element. + */ + mouseleave(): JQuery; + /** + * Bind an event handler to be fired when the mouse leaves an element. + * + * @param handler A function to execute when the event is triggered. + */ + mouseleave(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to be fired when the mouse leaves an element. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseleave(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mousemove" event on an element. + */ + mousemove(): JQuery; + /** + * Bind an event handler to the "mousemove" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mousemove(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mousemove" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mousemove(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseout" event on an element. + */ + mouseout(): JQuery; + /** + * Bind an event handler to the "mouseout" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mouseout(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mouseout" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseout(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseover" event on an element. + */ + mouseover(): JQuery; + /** + * Bind an event handler to the "mouseover" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mouseover(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mouseover" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseover(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseup" event on an element. + */ + mouseup(): JQuery; + /** + * Bind an event handler to the "mouseup" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mouseup(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mouseup" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseup(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Remove an event handler. + */ + off(): JQuery; + /** + * Remove an event handler. + * + * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. + * @param handler A handler function previously attached for the event(s), or the special value false. + */ + off(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove an event handler. + * + * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + * @param handler A handler function previously attached for the event(s), or the special value false. + */ + off(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove an event handler. + * + * @param events An object where the string keys represent one or more space-separated event types and optional namespaces, and the values represent handler functions previously attached for the event(s). + * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. + */ + off(events: { [key: string]: any; }, selector?: string): JQuery; + + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax). + */ + on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + on(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + on(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event occurs. + */ + on(events: { [key: string]: any; }, selector?: any, data?: any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute at the time the event is triggered. + */ + one(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. + * @param data An object containing data that will be passed to the event handler. + * @param handler A function to execute at the time the event is triggered. + */ + one(events: string, data: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + one(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + one(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event occurs. + */ + one(events: { [key: string]: any; }, selector?: string, data?: any): JQuery; + + + /** + * Specify a function to execute when the DOM is fully loaded. + * + * @param handler A function to execute after the DOM is ready. + */ + ready(handler: Function): JQuery; + + /** + * Trigger the "resize" event on an element. + */ + resize(): JQuery; + /** + * Bind an event handler to the "resize" JavaScript event. + * + * @param handler A function to execute each time the event is triggered. + */ + resize(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "resize" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + resize(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "scroll" event on an element. + */ + scroll(): JQuery; + /** + * Bind an event handler to the "scroll" JavaScript event. + * + * @param handler A function to execute each time the event is triggered. + */ + scroll(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "scroll" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + scroll(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "select" event on an element. + */ + select(): JQuery; + /** + * Bind an event handler to the "select" JavaScript event. + * + * @param handler A function to execute each time the event is triggered. + */ + select(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "select" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + select(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "submit" event on an element. + */ + submit(): JQuery; + /** + * Bind an event handler to the "submit" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + submit(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "submit" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + submit(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + trigger(eventType: string, ...extraParameters: any[]): JQuery; + trigger(event: JQueryEventObject): JQuery; + + triggerHandler(eventType: string, ...extraParameters: any[]): Object; + + unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + unbind(eventType: string, fls: boolean): JQuery; + unbind(evt: any): JQuery; + + undelegate(): JQuery; + undelegate(selector: any, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + undelegate(selector: any, events: any): JQuery; + undelegate(namespace: string): JQuery; + + unload(handler: (eventObject: JQueryEventObject) => any): JQuery; + unload(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + // Internals + context: Element; + jquery: string; + + error(handler: (eventObject: JQueryEventObject) => any): JQuery; + error(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + + pushStack(elements: any[]): JQuery; + pushStack(elements: any[], name: any, arguments: any): JQuery; + + // Manipulation + after(...content: any[]): JQuery; + after(func: (index: any) => any): JQuery; + + append(...content: any[]): JQuery; + append(func: (index: any, html: any) => any): JQuery; + + appendTo(target: any): JQuery; + + before(...content: any[]): JQuery; + before(func: (index: any) => any): JQuery; + + clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean): JQuery; + + detach(selector?: any): JQuery; + + empty(): JQuery; + + insertAfter(target: any): JQuery; + insertBefore(target: any): JQuery; + + prepend(...content: any[]): JQuery; + prepend(func: (index: any, html: any) => any): JQuery; + + prependTo(target: any): JQuery; + + remove(selector?: any): JQuery; + + replaceAll(target: any): JQuery; + + replaceWith(func: any): JQuery; + + text(): string; + text(textString: any): JQuery; + text(textString: (index: number, text: string) => string): JQuery; + + toArray(): any[]; + + unwrap(): JQuery; + + wrap(wrappingElement: any): JQuery; + wrap(func: (index: any) => any): JQuery; + + wrapAll(wrappingElement: any): JQuery; + + wrapInner(wrappingElement: any): JQuery; + wrapInner(func: (index: any) => any): JQuery; + + // Miscellaneous + each(func: (index: any, elem: Element) => any): JQuery; + + get(index?: number): any; + + index(): number; + index(selector: string): number; + index(element: any): number; + + // Properties + length: number; + selector: string; + [x: string]: any; + [x: number]: HTMLElement; + + // Traversing + add(selector: string, context?: any): JQuery; + add(...elements: any[]): JQuery; + add(html: string): JQuery; + add(obj: JQuery): JQuery; + + children(selector?: any): JQuery; + + closest(selector: string): JQuery; + closest(selector: string, context?: Element): JQuery; + closest(obj: JQuery): JQuery; + closest(element: any): JQuery; + closest(selectors: any, context?: Element): any[]; + + contents(): JQuery; + + end(): JQuery; + + eq(index: number): JQuery; + + filter(selector: string): JQuery; + filter(func: (index: any) => any): JQuery; + filter(element: any): JQuery; + filter(obj: JQuery): JQuery; + + find(selector: string): JQuery; + find(element: any): JQuery; + find(obj: JQuery): JQuery; + + first(): JQuery; + + has(selector: string): JQuery; + has(contained: Element): JQuery; + + is(selector: string): boolean; + is(func: (index: any) => any): boolean; + is(element: any): boolean; + is(obj: JQuery): boolean; + + last(): JQuery; + + map(callback: (index: any, domElement: Element) => any): JQuery; + + next(selector?: string): JQuery; + + nextAll(selector?: string): JQuery; + + nextUntil(selector?: string, filter?: string): JQuery; + nextUntil(element?: Element, filter?: string): JQuery; + nextUntil(obj?: JQuery, filter?: string): JQuery; + + not(selector: string): JQuery; + not(func: (index: any) => any): JQuery; + not(element: any): JQuery; + not(obj: JQuery): JQuery; + + offsetParent(): JQuery; + + parent(selector?: string): JQuery; + + parents(selector?: string): JQuery; + + parentsUntil(selector?: string, filter?: string): JQuery; + parentsUntil(element?: Element, filter?: string): JQuery; + parentsUntil(obj?: JQuery, filter?: string): JQuery; + + prev(selector?: string): JQuery; + + prevAll(selector?: string): JQuery; + + prevUntil(selector?: string, filter?: string): JQuery; + prevUntil(element?: Element, filter?: string): JQuery; + prevUntil(obj?: JQuery, filter?: string): JQuery; + + siblings(selector?: string): JQuery; + + slice(start: number, end?: number): JQuery; + + // Utilities + + queue(queueName?: string): any[]; + queue(queueName: string, newQueueOrCallback: any): JQuery; + queue(newQueueOrCallback: any): JQuery; +} +declare module "jquery" { + export = $; +} +declare var jQuery: JQueryStatic; +declare var $: JQueryStatic; diff --git a/src/Web/Scripts/typings/signalr/signalr.d.ts b/src/Web/Scripts/typings/signalr/signalr.d.ts new file mode 100644 index 0000000..77895be --- /dev/null +++ b/src/Web/Scripts/typings/signalr/signalr.d.ts @@ -0,0 +1,110 @@ +// Type definitions for SignalR 1.0 +// Project: http://www.asp.net/signalr +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +interface HubMethod { + (callback: (data: string) => void ); +} + +interface SignalREvents { + onStart: string; + onStarting: string; + onReceived: string; + onError: string; + onConnectionSlow: string; + onReconnect: string; + onStateChanged: string; + onDisconnect: string; +} + +interface SignalRStateChange { + oldState: number; + newState: number; +} + +interface SignalR { + events: SignalREvents; + connectionState: any; + transports: any; + + hub: HubConnection; + id: string; + logging: boolean; + messageId: string; + url: string; + + (url: string, queryString?: any, logging?: boolean): SignalR; + hubConnection(url?: string): SignalR; + + log(msg: string, logging: boolean): void; + isCrossDomain(url: string): boolean; + changeState(connection: SignalR, expectedState: number, newState: number): boolean; + isDisconnecting(connection: SignalR): boolean; + + // createHubProxy(hubName: string): SignalR; + + start(): JQueryPromise; + start(callback: () => void ): JQueryPromise; + start(settings: ConnectionSettings): JQueryPromise; + start(settings: ConnectionSettings, callback: () => void ): JQueryPromise; + + + send(data: string): void; + stop(async?: boolean, notifyServer?: boolean): void; + + starting(handler: () => void ): SignalR; + received(handler: (data: any) => void ): SignalR; + error(handler: (error: string) => void ): SignalR; + stateChanged(handler: (change: SignalRStateChange) => void ): SignalR; + disconnected(handler: () => void ): SignalR; + connectionSlow(handler: () => void ): SignalR; + sending(handler: () => void ): SignalR; + reconnecting(handler: () => void): SignalR; + reconnected(handler: () => void): SignalR; +} + +interface HubProxy { + (connection: HubConnection, hubName: string): HubProxy; + state: any; + connection: HubConnection; + hubName: string; + init(connection: HubConnection, hubName: string): void; + hasSubscriptions(): boolean; + on(eventName: string, callback: (...msg) => void ): HubProxy; + off(eventName: string, callback: (msg) => void ): HubProxy; + invoke(methodName: string, ...args: any[]): JQueryDeferred; +} + +interface HubConnectionSettings { + queryString?: string; + logging?: boolean; + useDefaultPath?: boolean; +} + +interface HubConnection extends SignalR { + //(url?: string, queryString?: any, logging?: boolean): HubConnection; + proxies; + received(callback: (data: { Id; Method; Hub; State; Args; }) => void ): HubConnection; + createHubProxy(hubName: string): HubProxy; +} + +interface SignalRfn { + init(url, qs, logging); +} + +interface ConnectionSettings { + transport?; + callback?; + waitForPageLoad?: boolean; + jsonp?: boolean; +} + +interface JQueryStatic { + signalR: SignalR; + connection: SignalR; + hubConnection(url?: string, queryString?: any, logging?: boolean): HubConnection; +} diff --git a/src/Web/Views/Jasmine/SpecRunner.cshtml b/src/Web/Views/Jasmine/SpecRunner.cshtml index 6e3ffa6..a1b2ebf 100644 --- a/src/Web/Views/Jasmine/SpecRunner.cshtml +++ b/src/Web/Views/Jasmine/SpecRunner.cshtml @@ -18,9 +18,15 @@ + + + + + +