Update AngularJS to 1.5

This commit is contained in:
Michal Miszczyszyn 2016-02-18 01:45:25 +01:00
parent 9c2dd05cb4
commit 65347efe70
9 changed files with 2513 additions and 94 deletions

View File

@ -19,6 +19,7 @@ The following extra definition files are available for referencing:
* angular-route.d.ts (for the **ngRoute** module)
* angular-cookies.d.ts (for the **ngCookies** module)
* angular-sanitize.d.ts (for the **ngSanitize** module)
* angular-animate.d.ts (for the **ngAnimate** module)
* angular-mocks.d.ts (for the **ngMock** and **ngMockE2E** modules)
(postfix with version number for specific verion, eg. angular-resource-1.0.d.ts)
@ -39,6 +40,7 @@ To avoid cluttering the list of suggestions as you type in your IDE, all interfa
* `ng.resource` for **ngResource**
* `ng.route` for **ngRoute**
* `ng.sanitize` for **ngSanitize**
* `ng.animate` for **ngAnimate**
**ngMockE2E** does not define a new namespace, but rather modifies some of **ng**'s interfaces.

View File

@ -1,4 +1,4 @@
// Type definitions for Angular JS 1.3 (ngAnimate module)
// Type definitions for Angular JS 1.5 (ngAnimate module)
// Project: http://angularjs.org
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>, Raphael Schweizer <https://github.com/rasch>, Cody Schaaf <https://github.com/codyschaaf>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@ -14,19 +14,54 @@ declare module "angular-animate" {
* ngAnimate module (angular-animate.js)
*/
declare module angular.animate {
interface IAnimateFactory extends Function {
enter?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void;
leave?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void;
addClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void;
removeClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void;
setClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void;
interface IAnimateFactory {
(...args: any[]): IAnimateCallbackObject;
}
interface IAnimateCallbackObject {
eventFn?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
setClass?: (element: IAugmentedJQuery, addedClasses: string, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
addClass?: (element: IAugmentedJQuery, addedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
removeClass?: (element: IAugmentedJQuery, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
enter?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
leave?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
move?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
animate?: (element: IAugmentedJQuery, fromStyles: string, toStyles: string, doneFunction: Function, options: IAnimationOptions) => any;
}
interface IAnimationPromise extends IPromise<void> {}
/**
* AnimateService
* see http://docs.angularjs.org/api/ngAnimate/service/$animate
*/
interface IAnimateService {
/**
* Sets up an event listener to fire whenever the animation event has fired on the given element or among any of its children.
*
* @param event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...)
* @param container the container element that will capture each of the animation events that are fired on itself as well as among its children
* @param callback the callback function that will be fired when the listener is triggered
*/
on(event: string, container: JQuery, callback: Function): void;
/**
* Deregisters an event listener based on the event which has been associated with the provided element.
*
* @param event the animation event (e.g. enter, leave, move, addClass, removeClass, etc...)
* @param container the container element the event listener was placed on
* @param callback the callback function that was registered as the listener
*/
off(event: string, container?: JQuery, callback?: Function): void;
/**
* Associates the provided element with a host parent element to allow the element to be animated even if it exists outside of the DOM structure of the Angular application.
*
* @param element the external element that will be pinned
* @param parentElement the host parent element that will be associated with the external element
*/
pin(element: JQuery, parentElement: JQuery): void;
/**
* Globally enables / disables animations.
*
@ -34,7 +69,13 @@ declare module angular.animate {
* @param value If provided then set the animation on or off.
* @returns current animation state
*/
enabled(element?: JQuery, value?: boolean): boolean;
enabled(element: JQuery, value?: boolean): boolean;
enabled(value: boolean): boolean;
/**
* Cancels the provided animation.
*/
cancel(animationPromise: IAnimationPromise): void;
/**
* Performs an inline animation on the element.
@ -46,7 +87,7 @@ declare module angular.animate {
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
animate(element: JQuery, from: any, to: any, className?: string, options?: IAnimationOptions): IPromise<void>;
animate(element: JQuery, from: any, to: any, className?: string, options?: IAnimationOptions): IAnimationPromise;
/**
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
@ -57,7 +98,7 @@ declare module angular.animate {
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, options?: IAnimationOptions): IPromise<void>;
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, options?: IAnimationOptions): IAnimationPromise;
/**
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
@ -66,7 +107,7 @@ declare module angular.animate {
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
leave(element: JQuery, options?: IAnimationOptions): IPromise<void>;
leave(element: JQuery, options?: IAnimationOptions): IAnimationPromise;
/**
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
@ -78,7 +119,7 @@ declare module angular.animate {
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
* @returns the animation callback promise
*/
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): IPromise<void>;
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): IAnimationPromise;
/**
* Triggers a custom animation event based off the className variable and then attaches the className
@ -89,7 +130,7 @@ declare module angular.animate {
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
addClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise<void>;
addClass(element: JQuery, className: string, options?: IAnimationOptions): IAnimationPromise;
/**
* Triggers a custom animation event based off the className variable and then removes the CSS class
@ -100,7 +141,7 @@ declare module angular.animate {
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
removeClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise<void>;
removeClass(element: JQuery, className: string, options?: IAnimationOptions): IAnimationPromise;
/**
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
@ -112,12 +153,7 @@ declare module angular.animate {
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
setClass(element: JQuery, add: string, remove: string, options?: IAnimationOptions): IPromise<void>;
/**
* Cancels the provided animation.
*/
cancel(animationPromise: IPromise<void>): void;
setClass(element: JQuery, add: string, remove: string, options?: IAnimationOptions): IAnimationPromise;
}
/**
@ -131,7 +167,7 @@ declare module angular.animate {
* @param name The name of the animation.
* @param factory The factory function that will be executed to return the animation object.
*/
register(name: string, factory: () => IAnimateCallbackObject): void;
register(name: string, factory: IAnimateFactory): void;
/**
* Gets and/or sets the CSS class expression that is checked when performing an animation.
@ -252,10 +288,10 @@ declare module angular.animate {
(element: JQuery, animateCssOptions: IAnimationOptions): IAnimateCssRunner;
}
}
declare module angular {
interface IModule {
animate(cssSelector: string, animateFactory: angular.animate.IAnimateFactory): IModule;
animation(name: string, animationFactory: IAnimateFactory): IModule;
animation(name: string, inlineAnnotatedFunction: any[]): IModule;
animation(object: Object): IModule;
}
}

View File

@ -1,14 +1,19 @@
/// <reference path="angular-resource.d.ts" />
interface IMyResource extends angular.resource.IResource<IMyResource> { };
interface IMyResourceClass extends angular.resource.IResourceClass<IMyResource> { };
import IHttpPromiseCallbackArg = angular.IHttpPromiseCallbackArg;
interface IMyData {}
interface IMyHttpPromiseCallbackArg extends IHttpPromiseCallbackArg<IMyData> {}
interface IMyResource extends angular.resource.IResource<IMyResource> { }
interface IMyResourceClass extends angular.resource.IResourceClass<IMyResource> { }
///////////////////////////////////////
// IActionDescriptor
///////////////////////////////////////
var actionDescriptor: angular.resource.IActionDescriptor;
angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactoryService, $timeout: angular.ITimeoutService) {
angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactoryService) {
actionDescriptor.method = 'method action';
actionDescriptor.params = { key: 'value' };
actionDescriptor.url = '/api/test-url/';
@ -21,10 +26,13 @@ angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactorySe
actionDescriptor.cache = true;
actionDescriptor.cache = $cacheFactory('cacheId');
actionDescriptor.timeout = 1000;
actionDescriptor.timeout = $timeout(function () { });
actionDescriptor.withCredentials = true;
actionDescriptor.responseType = 'response type';
actionDescriptor.interceptor = { key: 'value' };
actionDescriptor.interceptor = {
response: function<IMyData> () { return <IMyHttpPromiseCallbackArg>{}; },
responseError: function () {}
};
actionDescriptor.cancellable = true;
});
@ -44,6 +52,7 @@ resource = resourceClass.delete({ key: 'value' }, { key: 'value' });
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { });
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { });
resource.$promise.then(function(data: IMyResource) {});
resource.$cancelRequest();
resource = resourceClass.get();
resource = resourceClass.get({ key: 'value' });

View File

@ -1,4 +1,4 @@
// Type definitions for Angular JS 1.3 (ngResource module)
// Type definitions for Angular JS 1.5 (ngResource module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
// Definitions: https://github.com/daptiv/DefinitelyTyped
@ -23,6 +23,11 @@ declare module angular.resource {
* If true then the trailing slashes from any calculated URL will be stripped (defaults to true)
*/
stripTrailingSlashes?: boolean;
/**
* If true, the request made by a "non-instance" call will be cancelled (if not already completed) by calling
* $cancelRequest() on the call's return value. This can be overwritten per action. (Defaults to false.)
*/
cancellable?: boolean;
}
@ -58,10 +63,16 @@ declare module angular.resource {
transformResponse?: angular.IHttpResponseTransformer | angular.IHttpResponseTransformer[];
headers?: any;
cache?: boolean | angular.ICacheObject;
timeout?: number | angular.IPromise<any>;
/**
* Note: In contrast to $http.config, promises are not supported in $resource, because the same value
* would be used for multiple requests. If you are looking for a way to cancel requests, you should
* use the cancellable option.
*/
timeout?: number
cancellable?: boolean;
withCredentials?: boolean;
responseType?: string;
interceptor?: any;
interceptor?: IHttpInterceptor;
}
// Baseclass for everyresource with default actions.
@ -137,6 +148,8 @@ declare module angular.resource {
$delete(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
$delete(success: Function, error?: Function): angular.IPromise<T>;
$cancelRequest(): void;
/** the promise of the original server interaction that created this instance. **/
$promise : angular.IPromise<T>;
$resolved : boolean;

View File

@ -62,6 +62,10 @@ angular.module('http-auth-interceptor', [])
*/
.config(['$httpProvider', 'authServiceProvider', <any>function ($httpProvider: ng.IHttpProvider, authServiceProvider: any) {
$httpProvider.defaults.headers.common = {'Authorization': 'Bearer token'};
$httpProvider.defaults.headers.get['Authorization'] = 'Bearer token';
$httpProvider.defaults.headers.post['Authorization'] = function (config:ng.IRequestConfig):string { return 'Bearer token'; }
var interceptor = ['$rootScope', '$q', <any>function ($rootScope: ng.IScope, $q: ng.IQService) {
function success(response: ng.IHttpPromiseCallbackArg<any>) {
return response;
@ -510,6 +514,7 @@ test_IAttributes({
$normalize: function (classVal){ return "foo" },
$addClass: function (classVal){},
$removeClass: function(classVal){},
$updateClass: function(newClass, oldClass){},
$set: function(key, value){},
$observe: function(name: any, fn: any){
return fn;
@ -748,6 +753,7 @@ angular.module('docsTransclusionExample', [])
};
});
angular.module('docsIsoFnBindExample', [])
.controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) {
$scope.name = 'Tobias';
@ -847,6 +853,30 @@ angular.module('docsTabsExample', [])
};
});
angular.module('componentExample', [])
.component('counter', {
require: ['^ctrl'],
bindings: {
count: '='
},
controller: 'CounterCtrl',
controllerAs: 'counterCtrl',
template: function () {
return '';
},
transclude: {
'el': 'target'
}
})
.component('anotherCounter', {
controller: function(){},
require: {
'parent': '^parentCtrl'
},
template: '',
transclude: true
});
interface copyExampleUser {
name?: string;
email?: string;

128
angularjs/angular.d.ts vendored
View File

@ -1,4 +1,4 @@
// Type definitions for Angular JS 1.4+
// Type definitions for Angular JS 1.5
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@ -178,9 +178,6 @@ declare module angular {
// see http://docs.angularjs.org/api/angular.Module
///////////////////////////////////////////////////////////////////////////
interface IModule {
animation(name: string, animationFactory: Function): IModule;
animation(name: string, inlineAnnotatedFunction: any[]): IModule;
animation(object: Object): IModule;
/**
* Use this method to register a component.
*
@ -336,6 +333,12 @@ declare module angular {
*/
$removeClass(classVal: string): void;
/**
* Adds and removes the appropriate CSS class values to the element based on the difference between
* the new and old CSS class values (specified as newClasses and oldClasses).
*/
$updateClass(newClasses: string, oldClasses: string): void;
/**
* Set DOM element attribute value.
*/
@ -605,15 +608,6 @@ declare module angular {
[key: string]: any;
}
///////////////////////////////////////////////////////////////////////////
// BrowserService
// TODO undocumented, so we need to get it from the source code
///////////////////////////////////////////////////////////////////////////
interface IBrowserService {
defer: angular.ITimeoutService;
[key: string]: any;
}
///////////////////////////////////////////////////////////////////////////
// TimeoutService
// see http://docs.angularjs.org/api/ng.$timeout
@ -633,35 +627,6 @@ declare module angular {
cancel(promise: IPromise<any>): boolean;
}
///////////////////////////////////////////////////////////////////////////
// AnimateProvider
// see http://docs.angularjs.org/api/ng/provider/$animateProvider
///////////////////////////////////////////////////////////////////////////
interface IAnimateProvider {
/**
* Registers a new injectable animation factory function.
*
* @param name The name of the animation.
* @param factory The factory function that will be executed to return the animation object.
*/
register(name: string, factory: () => IAnimateCallbackObject): void;
/**
* Gets and/or sets the CSS class expression that is checked when performing an animation.
*
* @param expression The className expression which will be checked against all animations.
* @returns The current CSS className expression value. If null then there is no expression value.
*/
classNameFilter(expression?: RegExp): RegExp;
}
/**
* The animation object which contains callback functions for each event that is expected to be animated.
*/
interface IAnimateCallbackObject {
eventFn(element: Node, doneFn: () => void): Function;
}
/**
* $filter - $filterProvider - service in module ng
*
@ -1209,10 +1174,15 @@ declare module angular {
interface ICompileProvider extends IServiceProvider {
directive(name: string, directiveFactory: Function): ICompileProvider;
directive(directivesMap: Object, directiveFactory: Function): ICompileProvider;
directive(name: string, inlineAnnotatedFunction: any[]): ICompileProvider;
directive(directivesMap: Object, inlineAnnotatedFunction: any[]): ICompileProvider;
// Undocumented, but it is there...
directive(directivesMap: any): ICompileProvider;
component(name: string, options: IComponentOptions): ICompileProvider;
aHrefSanitizationWhitelist(): RegExp;
aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider;
@ -1258,6 +1228,15 @@ declare module angular {
allowGlobals(): void;
}
/**
* xhrFactory
* Replace or decorate this service to create your own custom XMLHttpRequest objects.
* see https://docs.angularjs.org/api/ng/service/$xhrFactory
*/
interface IXhrFactory<T> {
(method: string, url: string): T;
}
/**
* HttpService
* see http://docs.angularjs.org/api/ng/service/$http
@ -1399,8 +1378,18 @@ declare module angular {
}
interface IHttpPromise<T> extends IPromise<IHttpPromiseCallbackArg<T>> {
success(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
error(callback: IHttpPromiseCallback<any>): IHttpPromise<T>;
/**
* The $http legacy promise methods success and error have been deprecated. Use the standard then method instead.
* If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error.
* @deprecated
*/
success?(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
/**
* The $http legacy promise methods success and error have been deprecated. Use the standard then method instead.
* If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error.
* @deprecated
*/
error?(callback: IHttpPromiseCallback<any>): IHttpPromise<T>;
}
// See the jsdoc for transformData() at https://github.com/angular/angular.js/blob/master/src/ng/http.js#L228
@ -1413,13 +1402,15 @@ declare module angular {
(data: any, headersGetter: IHttpHeadersGetter, status: number): any;
}
type HttpHeaderType = {[requestType: string]:string|((config:IRequestConfig) => string)};
interface IHttpRequestConfigHeaders {
[requestType: string]: string|(() => string);
common?: string|(() => string);
get?: string|(() => string);
post?: string|(() => string);
put?: string|(() => string);
patch?: string|(() => string);
[requestType: string]: any;
common?: any;
get?: any;
post?: any;
put?: any;
patch?: any;
}
/**
@ -1479,7 +1470,7 @@ declare module angular {
interface IHttpInterceptor {
request?: (config: IRequestConfig) => IRequestConfig|IPromise<IRequestConfig>;
requestError?: (rejection: any) => any;
response?: <T>(response: IHttpPromiseCallbackArg<T>) => IPromise<T>|T;
response?: <T>(response: IHttpPromiseCallbackArg<T>) => IPromise<IHttpPromiseCallbackArg<T>>|IHttpPromiseCallbackArg<T>;
responseError?: (rejection: any) => any;
}
@ -1685,10 +1676,11 @@ declare module angular {
* Controller constructor function that should be associated with newly created scope or the name of a registered
* controller if passed as a string. Empty function by default.
*/
controller?: any;
controller?: string | Function;
/**
* An identifier name for a reference to the controller. If present, the controller will be published to scope under
* the controllerAs name. If not present, this will default to be the same as the component name.
* @default "$ctrl"
*/
controllerAs?: string;
/**
@ -1710,14 +1702,12 @@ declare module angular {
* Define DOM attribute binding to component properties. Component properties are always bound to the component
* controller and not to the scope.
*/
bindings?: any;
bindings?: {[binding: string]: string};
/**
* Whether transclusion is enabled. Enabled by default.
*/
transclude?: boolean;
require? : Object;
$canActivate?: () => boolean;
$routeConfig?: RouteDefinition[];
transclude?: boolean | string | {[slot: string]: string};
require?: string | string[] | {[controller: string]: string};
}
interface IComponentTemplateFn {
@ -1753,6 +1743,12 @@ declare module angular {
(
templateElement: IAugmentedJQuery,
templateAttributes: IAttributes,
/**
* @deprecated
* Note: The transclude function that is passed to the compile function is deprecated,
* as it e.g. does not know about the right outer scope. Please use the transclude function
* that is passed to the link function instead.
*/
transclude: ITranscludeFunction
): IDirectivePrePost;
}
@ -1761,19 +1757,29 @@ declare module angular {
compile?: IDirectiveCompileFn;
controller?: any;
controllerAs?: string;
bindToController?: boolean|Object;
/**
* @deprecated
* Deprecation warning: although bindings for non-ES6 class controllers are currently bound to this before
* the controller constructor is called, this use is now deprecated. Please place initialization code that
* relies upon bindings inside a $onInit method on the controller, instead.
*/
bindToController?: boolean | Object;
link?: IDirectiveLinkFn | IDirectivePrePost;
multiElement?: boolean;
name?: string;
priority?: number;
/**
* @deprecated
*/
replace?: boolean;
require? : any;
require?: string | string[] | {[controller: string]: string};
restrict?: string;
scope?: any;
scope?: boolean | Object;
template?: string | Function;
templateNamespace?: string;
templateUrl?: string | Function;
terminal?: boolean;
transclude?: any;
transclude?: boolean | string | {[slot: string]: string};
}
/**

1877
angularjs/legacy/angular-1.4.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,261 @@
// Type definitions for Angular JS 1.3 (ngAnimate module)
// Project: http://angularjs.org
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>, Raphael Schweizer <https://github.com/rasch>, Cody Schaaf <https://github.com/codyschaaf>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="angular-1.4.d.ts" />
declare module "angular-animate" {
var _: string;
export = _;
}
/**
* ngAnimate module (angular-animate.js)
*/
declare module angular.animate {
interface IAnimateFactory extends Function {
enter?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void;
leave?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void;
addClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void;
removeClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void;
setClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void;
}
/**
* AnimateService
* see http://docs.angularjs.org/api/ngAnimate/service/$animate
*/
interface IAnimateService {
/**
* Globally enables / disables animations.
*
* @param element If provided then the element will be used to represent the enable/disable operation.
* @param value If provided then set the animation on or off.
* @returns current animation state
*/
enabled(element?: JQuery, value?: boolean): boolean;
/**
* Performs an inline animation on the element.
*
* @param element the element that will be the focus of the animation
* @param from a collection of CSS styles that will be applied to the element at the start of the animation
* @param to a collection of CSS styles that the element will animate towards
* @param className an optional CSS class that will be added to the element for the duration of the animation (the default class is 'ng-inline-animate')
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
animate(element: JQuery, from: any, to: any, className?: string, options?: IAnimationOptions): IPromise<void>;
/**
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
*
* @param element the element that will be the focus of the enter animation
* @param parentElement the parent element of the element that will be the focus of the enter animation
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, options?: IAnimationOptions): IPromise<void>;
/**
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
*
* @param element the element that will be the focus of the leave animation
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
leave(element: JQuery, options?: IAnimationOptions): IPromise<void>;
/**
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
* it into the parentElement container or add the element directly after the afterElement element if present.
* Then the move animation will be run.
*
* @param element the element that will be the focus of the move animation
* @param parentElement the parent element of the element that will be the focus of the move animation
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
* @returns the animation callback promise
*/
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): IPromise<void>;
/**
* Triggers a custom animation event based off the className variable and then attaches the className
* value to the element as a CSS class.
*
* @param element the element that will be animated
* @param className the CSS class that will be added to the element and then animated
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
addClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise<void>;
/**
* Triggers a custom animation event based off the className variable and then removes the CSS class
* provided by the className value from the element.
*
* @param element the element that will be animated
* @param className the CSS class that will be animated and then removed from the element
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
removeClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise<void>;
/**
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
* will be fired (if provided).
*
* @param element the element which will have its CSS classes changed removed from it
* @param add the CSS classes which will be added to the element
* @param remove the CSS class which will be removed from the element CSS classes have been set on the element
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
* @returns the animation callback promise
*/
setClass(element: JQuery, add: string, remove: string, options?: IAnimationOptions): IPromise<void>;
/**
* Cancels the provided animation.
*/
cancel(animationPromise: IPromise<void>): void;
}
/**
* AnimateProvider
* see http://docs.angularjs.org/api/ngAnimate/provider/$animateProvider
*/
interface IAnimateProvider {
/**
* Registers a new injectable animation factory function.
*
* @param name The name of the animation.
* @param factory The factory function that will be executed to return the animation object.
*/
register(name: string, factory: () => IAnimateCallbackObject): void;
/**
* Gets and/or sets the CSS class expression that is checked when performing an animation.
*
* @param expression The className expression which will be checked against all animations.
* @returns The current CSS className expression value. If null then there is no expression value.
*/
classNameFilter(expression?: RegExp): RegExp;
}
/**
* Angular Animation Options
* see https://docs.angularjs.org/api/ngAnimate/#applying-directive-specific-styles-to-an-animation
*/
interface IAnimationOptions {
/**
* The ending CSS styles (a key/value object) that will be applied across the animation via a CSS transition.
*/
to?: Object;
/**
* The starting CSS styles (a key/value object) that will be applied at the start of the animation.
*/
from?: Object;
/**
* The DOM event (e.g. enter, leave, move). When used, a generated CSS class of ng-EVENT and
* ng-EVENT-active will be applied to the element during the animation. Multiple events can be provided when
* spaces are used as a separator. (Note that this will not perform any DOM operation.)
*/
event?: string;
/**
* The CSS easing value that will be applied to the transition or keyframe animation (or both).
*/
easing?: string;
/**
* The raw CSS transition style that will be used (e.g. 1s linear all).
*/
transition?: string;
/**
* The raw CSS keyframe animation style that will be used (e.g. 1s my_animation linear).
*/
keyframe?: string;
/**
* A space separated list of CSS classes that will be added to the element and spread across the animation.
*/
addClass?: string;
/**
* A space separated list of CSS classes that will be removed from the element and spread across
* the animation.
*/
removeClass?: string;
/**
* A number value representing the total duration of the transition and/or keyframe (note that a value
* of 1 is 1000ms). If a value of 0 is provided then the animation will be skipped entirely.
*/
duration?: number;
/**
* A number value representing the total delay of the transition and/or keyframe (note that a value of
* 1 is 1000ms). If a value of true is used then whatever delay value is detected from the CSS classes will be
* mirrored on the elements styles (e.g. by setting delay true then the style value of the element will be
* transition-delay: DETECTED_VALUE). Using true is useful when you want the CSS classes and inline styles to
* all share the same CSS delay value.
*/
delay?: number;
/**
* A numeric time value representing the delay between successively animated elements (Click here to
* learn how CSS-based staggering works in ngAnimate.)
*/
stagger?: number;
/**
* The numeric index representing the stagger item (e.g. a value of 5 is equal to the sixth item
* in the stagger; therefore when a stagger option value of 0.1 is used then there will be a stagger delay of 600ms)
* applyClassesEarly - Whether or not the classes being added or removed will be used when detecting the animation.
* This is set by $animate when enter/leave/move animations are fired to ensure that the CSS classes are resolved in time.
* (Note that this will prevent any transitions from occuring on the classes being added and removed.)
*/
staggerIndex?: number;
}
interface IAnimateCssRunner {
/**
* Starts the animation
*
* @returns The animation runner with a done function for supplying a callback.
*/
start(): IAnimateCssRunnerStart;
/**
* Ends (aborts) the animation
*/
end(): void;
}
interface IAnimateCssRunnerStart extends IPromise<void> {
/**
* Allows you to add done callbacks to the running animation
*
* @param callbackFn: the callback function to be run
*/
done(callbackFn: (animationFinished: boolean) => void): void;
}
/**
* AnimateCssService
* see http://docs.angularjs.org/api/ngAnimate/service/$animateCss
*/
interface IAnimateCssService {
(element: JQuery, animateCssOptions: IAnimationOptions): IAnimateCssRunner;
}
}
declare module angular {
interface IModule {
animate(cssSelector: string, animateFactory: angular.animate.IAnimateFactory): IModule;
}
}

View File

@ -0,0 +1,185 @@
// Type definitions for Angular JS 1.3 (ngResource module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
// Definitions: https://github.com/daptiv/DefinitelyTyped
/// <reference path="angular-1.4.d.ts" />
declare module 'angular-resource' {
var _: string;
export = _;
}
///////////////////////////////////////////////////////////////////////////////
// ngResource module (angular-resource.js)
///////////////////////////////////////////////////////////////////////////////
declare module angular.resource {
/**
* Currently supported options for the $resource factory options argument.
*/
interface IResourceOptions {
/**
* If true then the trailing slashes from any calculated URL will be stripped (defaults to true)
*/
stripTrailingSlashes?: boolean;
}
///////////////////////////////////////////////////////////////////////////
// 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 */
actions?: any, options?: IResourceOptions): IResourceClass<IResource<any>>;
<T, U>(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actions?: any, options?: IResourceOptions): U;
<T>(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actions?: any, options?: IResourceOptions): IResourceClass<T>;
}
// Just a reference to facilitate describing new actions
interface IActionDescriptor {
method: string;
params?: any;
url?: string;
isArray?: boolean;
transformRequest?: angular.IHttpRequestTransformer | angular.IHttpRequestTransformer[];
transformResponse?: angular.IHttpResponseTransformer | angular.IHttpResponseTransformer[];
headers?: any;
cache?: boolean | angular.ICacheObject;
timeout?: number | angular.IPromise<any>;
withCredentials?: boolean;
responseType?: string;
interceptor?: 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
//
// Only those methods with an HTTP body do have 'data' as first parameter:
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463
// More specifically, those methods are POST, PUT and PATCH:
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432
//
// Also, static calls always return the IResource (or IResourceArray) retrieved
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549
interface IResourceClass<T> {
new(dataOrParams? : any) : T;
get(): T;
get(params: Object): T;
get(success: Function, error?: Function): T;
get(params: Object, success: Function, error?: Function): T;
get(params: Object, data: Object, success?: Function, error?: Function): T;
query(): IResourceArray<T>;
query(params: Object): IResourceArray<T>;
query(success: Function, error?: Function): IResourceArray<T>;
query(params: Object, success: Function, error?: Function): IResourceArray<T>;
query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray<T>;
save(): T;
save(data: Object): T;
save(success: Function, error?: Function): T;
save(data: Object, success: Function, error?: Function): T;
save(params: Object, data: Object, success?: Function, error?: Function): T;
remove(): T;
remove(params: Object): T;
remove(success: Function, error?: Function): T;
remove(params: Object, success: Function, error?: Function): T;
remove(params: Object, data: Object, success?: Function, error?: Function): T;
delete(): T;
delete(params: Object): T;
delete(success: Function, error?: Function): T;
delete(params: Object, success: Function, error?: Function): T;
delete(params: Object, data: Object, success?: Function, error?: Function): T;
}
// Instance calls always return the the promise of the request which retrieved the object
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546
interface IResource<T> {
$get(): angular.IPromise<T>;
$get(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
$get(success: Function, error?: Function): angular.IPromise<T>;
$query(): angular.IPromise<IResourceArray<T>>;
$query(params?: Object, success?: Function, error?: Function): angular.IPromise<IResourceArray<T>>;
$query(success: Function, error?: Function): angular.IPromise<IResourceArray<T>>;
$save(): angular.IPromise<T>;
$save(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
$save(success: Function, error?: Function): angular.IPromise<T>;
$remove(): angular.IPromise<T>;
$remove(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
$remove(success: Function, error?: Function): angular.IPromise<T>;
$delete(): angular.IPromise<T>;
$delete(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
$delete(success: Function, error?: Function): angular.IPromise<T>;
/** the promise of the original server interaction that created this instance. **/
$promise : angular.IPromise<T>;
$resolved : boolean;
toJSON: () => {
[index: string]: any;
}
}
/**
* Really just a regular Array object with $promise and $resolve attached to it
*/
interface IResourceArray<T> extends Array<T & IResource<T>> {
/** the promise of the original server interaction that created this collection. **/
$promise : angular.IPromise<IResourceArray<T>>;
$resolved : boolean;
}
/** when creating a resource factory via IModule.factory */
interface IResourceServiceFactoryFunction<T> {
($resource: angular.resource.IResourceService): IResourceClass<T>;
<U extends IResourceClass<T>>($resource: angular.resource.IResourceService): U;
}
// IResourceServiceProvider used to configure global settings
interface IResourceServiceProvider extends angular.IServiceProvider {
defaults: IResourceOptions;
}
}
/** extensions to base ng based on using angular-resource */
declare module angular {
interface IModule {
/** creating a resource service factory */
factory(name: string, resourceServiceFactoryFunction: angular.resource.IResourceServiceFactoryFunction<any>): IModule;
}
}
interface Array<T>
{
/** the promise of the original server interaction that created this collection. **/
$promise : angular.IPromise<Array<T>>;
$resolved : boolean;
}