From 492d456a36abef7eea96331d86632b9b67d00439 Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Wed, 18 Jun 2014 17:49:05 -0700 Subject: [PATCH 01/22] angular.d.ts: new interface IServiceProviderClass Instead of IModule.provider simply accepting an Function for a class constructor, use an interface to enforce the type of class. --- angularjs/angular.d.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 92a02eef8..f2ecbd783 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -18,6 +18,11 @@ interface Function { /////////////////////////////////////////////////////////////////////////////// declare module ng { + // not directly implemented, but ensures that constructed class implements $get + interface IServiceProviderClass { + new(...args: any[]): IServiceProvider; + } + // All service providers extend this interface interface IServiceProvider { $get: any; @@ -140,9 +145,9 @@ declare module ng { filter(name: string, filterFactoryFunction: Function): IModule; filter(name: string, inlineAnnotatedFunction: any[]): IModule; filter(object: Object): IModule; - provider(name: string, serviceProviderConstructor: Function): IModule; + provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule; provider(name: string, inlineAnnotatedConstructor: any[]): IModule; - provider(name: string, providerObject: auto.IProvider): IModule; + provider(name: string, providerObject: IServiceProvider): IModule; provider(object: Object): IModule; run(initializationFunction: Function): IModule; run(inlineAnnotatedFunction: any[]): IModule; @@ -991,9 +996,6 @@ declare module ng { // AUTO module (angular.js) /////////////////////////////////////////////////////////////////////////// export module auto { - interface IProvider { - $get: any; - } /////////////////////////////////////////////////////////////////////// // InjectorService From 3a36795eb258f1797f7ebea8c496201a5ea1436b Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Wed, 18 Jun 2014 18:13:14 -0700 Subject: [PATCH 02/22] angular.d.ts: new interface IDirectiveFactory Adds intellisense when constructing directive objects --- angularjs/angular.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index f2ecbd783..cb03b6925 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -124,7 +124,7 @@ declare module ng { */ controller(name: string, inlineAnnotatedConstructor: any[]): IModule; controller(object : Object): IModule; - directive(name: string, directiveFactory: Function): IModule; + directive(name: string, directiveFactory: IDirectiveFactory): IModule; directive(name: string, inlineAnnotatedFunction: any[]): IModule; directive(object: Object): IModule; /** @@ -919,6 +919,11 @@ declare module ng { // and http://docs.angularjs.org/guide/directive /////////////////////////////////////////////////////////////////////////// + interface IDirectiveFactory { + (...args: any[]): IDirective; + } + + interface IDirective{ compile?: (templateElement: IAugmentedJQuery, From ef0e9da858b404c022455cbb38e2e95b3f6fa13c Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Wed, 18 Jun 2014 18:32:01 -0700 Subject: [PATCH 03/22] angular.d.ts: new interface IServiceProviderFactory Missed provider functions that return objects. Ensure that they also implement ng.IServiceProvider. --- angularjs/angular.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index cb03b6925..e8d1db837 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -22,6 +22,10 @@ declare module ng { interface IServiceProviderClass { new(...args: any[]): IServiceProvider; } + + interface IServiceProviderFactory { + (...args: any[]): IServiceProvider; + } // All service providers extend this interface interface IServiceProvider { @@ -145,6 +149,7 @@ declare module ng { filter(name: string, filterFactoryFunction: Function): IModule; filter(name: string, inlineAnnotatedFunction: any[]): IModule; filter(object: Object): IModule; + provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule; provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule; provider(name: string, inlineAnnotatedConstructor: any[]): IModule; provider(name: string, providerObject: IServiceProvider): IModule; From dd4602b27a74218079be508e51ea90f8df68ce44 Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Wed, 18 Jun 2014 18:41:06 -0700 Subject: [PATCH 04/22] angular-agility need to use ng.IServiceProvider --- angular-agility/angular-agility.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-agility/angular-agility.d.ts b/angular-agility/angular-agility.d.ts index c11aff0b0..872971aed 100644 --- a/angular-agility/angular-agility.d.ts +++ b/angular-agility/angular-agility.d.ts @@ -41,7 +41,7 @@ declare module aa { [settingName: string]: any; } - export interface IFormExtensionsProvider extends ng.auto.IProvider { + export interface IFormExtensionsProvider extends ng.IServiceProvider { defaultLabelStrategy:string; defaultFieldGroupStrategy:string; defaultValMsgPlacementStrategy:string; @@ -88,7 +88,7 @@ declare module aa { message:string; } - export interface INotifyConfigProvider extends ng.auto.IProvider { + export interface INotifyConfigProvider extends ng.IServiceProvider { notifyConfigs:any; defaultTargetContainerName:string; defaultNotifyConfig:string; From 72b9fbed7f7b96de942005c96e23f3535e7d0084 Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Wed, 18 Jun 2014 19:55:32 -0700 Subject: [PATCH 05/22] angular.d.ts: update test to use class for module Converted the test module, 'http-auth-interceptor', to a class to eliminate error on using anonymous type constructor. --- angularjs/angular-tests.ts | 63 +++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 419bed0d6..bac077131 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -7,27 +7,27 @@ * (c) 2012 Witold Szczerba * License: MIT */ -angular.module('http-auth-interceptor', []) - .provider('authService', function () { - /** - * Holds all the requests which failed due to 401 response, - * so they can be re-requested in future, once login is completed. - */ - var buffer: { config: ng.IRequestConfig; deferred: ng.IDeferred; }[] = []; +class AuthService { + /** + * Holds all the requests which failed due to 401 response, + * so they can be re-requested in future, once login is completed. + */ + buffer: { config: ng.IRequestConfig; deferred: ng.IDeferred; }[] = []; - /** - * Required by HTTP interceptor. - * Function is attached to provider to be invisible for regular users of this service. - */ - this.pushToBuffer = function (config: ng.IRequestConfig, deferred: ng.IDeferred) { - buffer.push({ - config: config, - deferred: deferred - }); - } + /** + * Required by HTTP interceptor. + * Function is attached to provider to be invisible for regular users of this service. + */ + pushToBuffer = function(config: ng.IRequestConfig, deferred: ng.IDeferred) { + this.buffer.push({ + config: config, + deferred: deferred + }); + } - this.$get = ['$rootScope', '$injector', function ($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) { + $get = [ + '$rootScope', '$injector', function($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) { var $http: ng.IHttpService; //initialized later because of circular dependency problem function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) { $http = $http || $injector.get('$http'); @@ -36,20 +36,25 @@ angular.module('http-auth-interceptor', []) }); } function retryAll() { - for (var i = 0; i < buffer.length; ++i) { - retry(buffer[i].config, buffer[i].deferred); + for (var i = 0; i < this.buffer.length; ++i) { + retry(this.buffer[i].config, this.buffer[i].deferred); } - buffer = []; + this.buffer = []; } - return { + return { loginConfirmed: function () { $rootScope.$broadcast('event:auth-loginConfirmed'); retryAll(); } } - }] - }) + } + ]; +} + +angular.module('http-auth-interceptor', []) + + .provider('authService', AuthService) /** * $http interceptor. @@ -176,7 +181,8 @@ mod.factory(My.Namespace); mod.filter('name', function ($scope: ng.IScope) { }) mod.filter('name', ['$scope', function ($scope: ng.IScope) { }]) mod.filter(My.Namespace); -mod.provider('name', function ($scope: ng.IScope) { }) +mod.provider('name', function ($scope: ng.IScope) { return { $get: () => { } } }) +mod.provider('name', TestProvider); mod.provider('name', ['$scope', function ($scope: ng.IScope) { }]) mod.provider(My.Namespace); mod.service('name', function ($scope: ng.IScope) { }) @@ -189,6 +195,13 @@ mod.value('name', 23); mod.value('name', "23"); mod.value(My.Namespace); +class TestProvider implements ng.IServiceProvider { + constructor(private $scope: ng.IScope) { + } + + $get() { + } +} // Promise signature tests var foo: ng.IPromise; From a001147307a688fe0f11ee0053b8e3321a167778 Mon Sep 17 00:00:00 2001 From: Jason Zhao Date: Fri, 27 Jun 2014 17:58:58 -0700 Subject: [PATCH 06/22] added definitions for angular-hotkeys --- angular-hotkeys/angular-hotkeys-tests.ts | 13 ++++++++++ angular-hotkeys/angular-hotkeys.d.ts | 30 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 angular-hotkeys/angular-hotkeys-tests.ts create mode 100644 angular-hotkeys/angular-hotkeys.d.ts diff --git a/angular-hotkeys/angular-hotkeys-tests.ts b/angular-hotkeys/angular-hotkeys-tests.ts new file mode 100644 index 000000000..4e63b32fa --- /dev/null +++ b/angular-hotkeys/angular-hotkeys-tests.ts @@ -0,0 +1,13 @@ +/// + +var hotkeyProvider: ng.hotkeys.HotkeysProvider; +var hotkeyObj: ng.hotkeys.Hotkey; + +hotkeyProvider.add("mod+s", "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} ); +hotkeyProvider.add(hotkeyObj); +hotkeyProvider.del("mod+s"); +hotkeyProvider.get("mod+s"); +hotkeyProvider.toggleCheatSheet(); + +hotkeyProvider.add(hotkeyObj.combo, hotkeyObj.description ,hotkeyObj.callback); + diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts new file mode 100644 index 000000000..8c2e1ff1c --- /dev/null +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -0,0 +1,30 @@ +// Type definitions for angular-hotkeys +// Project: https://github.com/chieffancypants/angular-hotkeys +// Definitions by: Jason Zhao +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module ng.hotkeys { + + interface HotkeysProvider { + template: string; + includeCheatSheet: boolean; + cheatSheetHotkey: string; + cheatSheetDescription: string; + + add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): void; + + add(hotkeyObj: ng.hotkeys.Hotkey): void; + + del(combo: string): void; + + get(combo: string): ng.hotkeys.Hotkey; + + toggleCheatSheet(): void; + } + + interface Hotkey { + combo: string; + description?: string; + callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void; + } +} From 56a71f88b0db9a2cd63759e10ba3155a2fde2613 Mon Sep 17 00:00:00 2001 From: Jason Zhao Date: Mon, 14 Jul 2014 14:11:51 -0700 Subject: [PATCH 07/22] added contributos --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ae430f57d..d40176b54 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -13,6 +13,7 @@ All definitions files include a header with the author and editors, so at some p * [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes)) * [angularLocalStorage](https://github.com/agrublev/angularLocalStorage) (by [Hiroki Horiuchi](https://github.com/horiuchi/)) * [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib)) +* [Angular Hotkeys](https://github.com/chieffancypants/angular-hotkeys/) (by [Jason Zhao](https://github.com/jlz27)) * [Angular Protractor](https://github.com/angular/protractor) (by [Bill Armstrong](https://github.com/BillArmstrong)) * [Angular Translate](http://pascalprecht.github.io/angular-translate/) (by [Michel Salib](https://github.com/michelsalib)) * [Angular UI Bootstrap](http://angular-ui.github.io/bootstrap) (by [Brian Surowiec](https://github.com/xt0rted)) From e43fb420097712a9f3af2758da56e2dbaeab177b Mon Sep 17 00:00:00 2001 From: Jason Zhao Date: Mon, 14 Jul 2014 16:28:09 -0700 Subject: [PATCH 08/22] bumped version to 1.4.0 --- angular-hotkeys/angular-hotkeys-tests.ts | 3 +++ angular-hotkeys/angular-hotkeys.d.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/angular-hotkeys/angular-hotkeys-tests.ts b/angular-hotkeys/angular-hotkeys-tests.ts index 4e63b32fa..66f9e6072 100644 --- a/angular-hotkeys/angular-hotkeys-tests.ts +++ b/angular-hotkeys/angular-hotkeys-tests.ts @@ -1,10 +1,13 @@ +/// /// +var scope: ng.IScope; var hotkeyProvider: ng.hotkeys.HotkeysProvider; var hotkeyObj: ng.hotkeys.Hotkey; hotkeyProvider.add("mod+s", "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} ); hotkeyProvider.add(hotkeyObj); +hotkeyProvider.bindTo(scope); hotkeyProvider.del("mod+s"); hotkeyProvider.get("mod+s"); hotkeyProvider.toggleCheatSheet(); diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts index 8c2e1ff1c..cc4a3680c 100644 --- a/angular-hotkeys/angular-hotkeys.d.ts +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -3,6 +3,8 @@ // Definitions by: Jason Zhao // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module ng.hotkeys { interface HotkeysProvider { @@ -15,6 +17,8 @@ declare module ng.hotkeys { add(hotkeyObj: ng.hotkeys.Hotkey): void; + bindTo(scope : ng.IScope): ng.hotkeys.HotkeysProvider; + del(combo: string): void; get(combo: string): ng.hotkeys.Hotkey; From 84f63e9cc3917650186dc88c996bad5436311405 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 16 Jul 2014 13:27:04 -0700 Subject: [PATCH 09/22] Added signal function to CodeMirror module --- codemirror/codemirror.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts index affee3458..316284a78 100644 --- a/codemirror/codemirror.d.ts +++ b/codemirror/codemirror.d.ts @@ -86,6 +86,11 @@ declare module CodeMirror { or the line the widget is on require the widget to be redrawn. */ function on(line: LineWidget, eventName: 'redraw', handler: () => void ): void; function off(line: LineWidget, eventName: 'redraw', handler: () => void ): void; + + /** Various CodeMirror-related objects emit events, which allow client code to react to various situations. + Handlers for such events can be registered with the on and off methods on the objects that the event fires on. + To fire your own events, use CodeMirror.signal(target, name, args...), where target is a non-DOM-node object. */ + function signal(target: any, name: string, ...args: any[]): void; interface Editor { From fe47b495c8aa7ee551fb3239fb08c93f15a05f92 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Mon, 21 Jul 2014 11:09:13 +0200 Subject: [PATCH 10/22] angularjs: allow $q.when to be called w/o args The current definition does not cover the case that the input type is void. --- angularjs/angular-tests.ts | 6 ++++++ angularjs/angular.d.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 37dae22f4..d7534bc36 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -139,6 +139,12 @@ module HttpAndRegularPromiseTests { dPromise.then((snack: string) => { $scope.snack = snack; }); + + // $q.when may be called without arguments + var ePromise: ng.IPromise = $q.when(); + ePromise.then(() => { + $scope.nothing = "really nothing"; + }); } // Test that we can pass around a type-checked success/error Promise Callback diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index d6b649a33..3880a8c05 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -565,6 +565,12 @@ declare module ng { * @param value Value or a promise */ when(value: T): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + when(): IPromise; } interface IPromise { From 625b9f2523e465181c9b3793269a2755e4fddca7 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Mon, 21 Jul 2014 15:33:31 +0200 Subject: [PATCH 11/22] Fixup --- angularjs/angular-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index d7534bc36..647287215 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -141,7 +141,7 @@ module HttpAndRegularPromiseTests { }); // $q.when may be called without arguments - var ePromise: ng.IPromise = $q.when(); + var ePromise: ng.IPromise = $q.when(); ePromise.then(() => { $scope.nothing = "really nothing"; }); From fde9a8e787f472f252b163ba83ed4e86867e1834 Mon Sep 17 00:00:00 2001 From: StefanSchoof Date: Tue, 22 Jul 2014 20:58:26 +0200 Subject: [PATCH 12/22] Added calendar Property to GlobalizeCulture The calendar Property is used to get and set the default calendar. See https://github.com/jquery/globalize/tree/79ae658b842f75f58199d6e9074e01f7ce207468#defining-culture-information and https://github.com/jquery/globalize/blob/79ae658b842f75f58199d6e9074e01f7ce207468/lib/globalize.js#L263 --- globalize/globalize.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/globalize/globalize.d.ts b/globalize/globalize.d.ts index 0bdaeb4bf..4510e38cb 100644 --- a/globalize/globalize.d.ts +++ b/globalize/globalize.d.ts @@ -91,6 +91,7 @@ interface GlobalizeCulture { isRTL: boolean; language: string; numberFormat: GlobalizeNumberFormat; + calendar: GlobalizeCalendar; calendars: GlobalizeCalendars; messages: any; } From c0e29234f7681f88ada9aa4ce09a32f655cb3388 Mon Sep 17 00:00:00 2001 From: brentj73 Date: Wed, 23 Jul 2014 12:19:26 +0100 Subject: [PATCH 13/22] Added typing for recaptcha.js --- recaptcha/recaptcha-tests.ts | 52 ++++++++++++++++++++++++++++++++++++ recaptcha/recaptcha.d.ts | 39 +++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 recaptcha/recaptcha-tests.ts create mode 100644 recaptcha/recaptcha.d.ts diff --git a/recaptcha/recaptcha-tests.ts b/recaptcha/recaptcha-tests.ts new file mode 100644 index 000000000..61ef51d9f --- /dev/null +++ b/recaptcha/recaptcha-tests.ts @@ -0,0 +1,52 @@ +/// + +var recaptchaOptions: RecaptchaOptions = { + theme : 'custom', + custom_theme_widget: 'recaptcha_widget' + }; + +var recaptchaOptions: RecaptchaOptions = { + custom_translations: { instructions_visual: "This is my text:" } +}; + +var recaptchaOptions: RecaptchaOptions = { + custom_translations: { + instructions_visual: "Scrivi le due parole:", + instructions_audio: "Trascrivi ci\u00f2 che senti:", + play_again: "Riascolta la traccia audio", + cant_hear_this: "Scarica la traccia in formato MP3", + visual_challenge: "Modalit\u00e0 visiva", + audio_challenge: "Modalit\u00e0 auditiva", + refresh_btn: "Chiedi due nuove parole", + help_btn: "Aiuto", + incorrect_try_again: "Scorretto. Riprova.", + }, + lang: 'it', + theme: 'red' +}; + +var recaptchaOptions: RecaptchaOptions = { + theme : 'white', + tabindex : 2 +}; + +Recaptcha.create("public_key_a", + "element_id_a", + { + theme: "red", + callback: Recaptcha.focus_response_field + } +); + +Recaptcha.create("public_key_b", + "element_id_b", + recaptchaOptions +); + +Recaptcha.switch_type("audio"); +Recaptcha.get_challenge(); +Recaptcha.get_response(); +Recaptcha.reload(); +Recaptcha.showhelp(); +Recaptcha.focus_response_field(); +Recaptcha.destroy(); diff --git a/recaptcha/recaptcha.d.ts b/recaptcha/recaptcha.d.ts new file mode 100644 index 000000000..410db7651 --- /dev/null +++ b/recaptcha/recaptcha.d.ts @@ -0,0 +1,39 @@ +// Type definitions for Google Recaptcha +// Project: https://www.google.com/recaptcha +// Definitions by: Brent Jenkins +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare class Recaptcha { + constructor(); + static reload(): void; + static switch_type(newtype: any); + static showhelp(): void; + static get_challenge(): string; + static get_response(): string; + static focus_response_field(): void; + static create(public_key: string, element: string, options: RecaptchaOptions): void; + static destroy(): void; +} + +interface RecaptchaOptions { + tabindex?: number; + theme?: string; + callback?: Function; + lang?: string; + custom_theme_widget?: string; + custom_translations?: CustomTranslations; +} + +interface CustomTranslations { + visual_challenge?: string; + audio_challenge?: string; + refresh_btn?: string; + instructions_visual?: string; + instructions_audio?: string; + help_btn?: string; + play_again?: string; + cant_hear_this?: string; + incorrect_try_again?: string; + image_alt_text?: string; + privacy_and_terms?: string; +} \ No newline at end of file From 4c3b64221298a22ea834fbb7c27e5c92a67f1615 Mon Sep 17 00:00:00 2001 From: brentj73 Date: Wed, 23 Jul 2014 13:01:36 +0100 Subject: [PATCH 14/22] Updated switch_type method with correct types --- recaptcha/recaptcha.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recaptcha/recaptcha.d.ts b/recaptcha/recaptcha.d.ts index 410db7651..db2096275 100644 --- a/recaptcha/recaptcha.d.ts +++ b/recaptcha/recaptcha.d.ts @@ -6,7 +6,7 @@ declare class Recaptcha { constructor(); static reload(): void; - static switch_type(newtype: any); + static switch_type(newtype: string): void; static showhelp(): void; static get_challenge(): string; static get_response(): string; @@ -36,4 +36,4 @@ interface CustomTranslations { incorrect_try_again?: string; image_alt_text?: string; privacy_and_terms?: string; -} \ No newline at end of file +} From ba1b3d7d609b1cde8d828cd67b91003e6aa3a60a Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Wed, 23 Jul 2014 14:08:31 +0200 Subject: [PATCH 15/22] Fixup --- angularjs/angular-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 647287215..788545156 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -95,6 +95,7 @@ module HttpAndRegularPromiseTests { theAnswer: number; letters: string[]; snack: string; + nothing?: string; } var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => { From 1e9a25470164976c069ecc4c7dce1941f60e85d8 Mon Sep 17 00:00:00 2001 From: Nickolas Westman Date: Wed, 23 Jul 2014 11:24:32 -0700 Subject: [PATCH 16/22] Update Anon Function Parameters in asyncTest Encountered compiler errors on using asyncTest ... fixed by making sure that the assert is a function of the anon function --- qunit/qunit.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qunit/qunit.d.ts b/qunit/qunit.d.ts index 5628feaa6..c6fe34f0f 100644 --- a/qunit/qunit.d.ts +++ b/qunit/qunit.d.ts @@ -381,7 +381,7 @@ interface QUnitStatic extends QUnitAssert{ * @param expected Number of assertions in this test * @param test Function to close over assertions */ - asyncTest(name: string, expected: number, test: () => any): any; + asyncTest(name: string, expected: number, test: (assert: QUnitAssert) => any): any; /** * Add an asynchronous test to run. The test must include a call to start(). @@ -392,7 +392,7 @@ interface QUnitStatic extends QUnitAssert{ * @param name Title of unit being tested * @param test Function to close over assertions */ - asyncTest(name: string, test: () => any): any; + asyncTest(name: string, test: (assert: QUnitAssert) => any): any; /** * Specify how many assertions are expected to run within a test. @@ -662,7 +662,7 @@ declare function testStart(callback: (details: TestStartCallbackObject) => any): * @param expected Number of assertions in this test * @param test Function to close over assertions */ -declare function asyncTest(name: string, expected?: any, test?: () => any): any; +declare function asyncTest(name: string, expected?: any, test?: (assert: QUnitAssert) => any): any; /** * Add an asynchronous test to run. The test must include a call to start(). @@ -673,7 +673,7 @@ declare function asyncTest(name: string, expected?: any, test?: () => any): any; * @param name Title of unit being tested * @param test Function to close over assertions */ -declare function asyncTest(name: string, test: () => any): any; +declare function asyncTest(name: string, test: (assert: QUnitAssert) => any): any; /** * Specify how many assertions are expected to run within a test. From 00fdeb909473de02d9f6634c47ece4bc87127a61 Mon Sep 17 00:00:00 2001 From: zaneli Date: Thu, 24 Jul 2014 11:32:35 +0900 Subject: [PATCH 17/22] Add definitions for bucks.js --- bucksjs/bucks-test.ts | 222 ++++++++++++++++++++++++++++++++++++++++++ bucksjs/bucks.d.ts | 55 +++++++++++ 2 files changed, 277 insertions(+) create mode 100644 bucksjs/bucks-test.ts create mode 100644 bucksjs/bucks.d.ts diff --git a/bucksjs/bucks-test.ts b/bucksjs/bucks-test.ts new file mode 100644 index 000000000..5ebbd882c --- /dev/null +++ b/bucksjs/bucks-test.ts @@ -0,0 +1,222 @@ +/// + +function add_and_end() { + // + // new Bucks object + // + var b = new Bucks(); + + // + // Add and add several tasks. + // + b.add(function f1(err, res) { + + return 'a'; + + }).add(function f2(err, res, next) { + + // res => 'a' + return next(null, 3); + + }).add(function f3(err, res, next) { + + // res => 3 + return next(new Error('error after 3')); + + }).add(function f4(err, res, next) { + + // err => 'error after 3' + return next(null, "recover 4"); + + }).add(function f5(err, res) { + + // res => 'recover 4' + throw new Error('error in f5'); + + }).add(function f6(err, res) { + + // err => 'error in f5' + throw err; + + }).add(function f7(err, res) { + + // err => 'error in f5' + // ignore and return + return "recover 7"; + + }).add(function f8(err, res, next) { + + // res => 'recover 7'; + throw new Error('error in f8'); + + }).add(function f9(err, res, next) { + + // err => 'Error in f8' + // ignore error + return next(null, 'result of 9'); + + }).end(function last(err, results) { + + // all of results + // are obtained in #end + + // err => null + + // results => [ + // 'a', + // null, + // null, + // 'recover 4', + // null, + // null, + // 'recover 7', + // null, + // 'result of 9' + // ]; + }); +} + +function then() { + var b = new Bucks(); + b.then(function start() { + return 'start'; + }).then(function second(res, next) { + // res => 'start' + return next(null, 'second') + }).end(); +} + +function delay() { + var b = new Bucks(); + b.add(function (){ /** program */ }) + .delay(1 * 1000) // 1ms + .add(function() { /** program */}) + .end(); +} + +function error() { + var b = new Bucks(); + b.then(function start() { + throw new Error('error in start'); + return 'start'; + }).error(function onError(e, next) { + // e => 'error in start' + return next(); + }).end(); +} + +function final_errorback_in_end() { + // + // last error back + // + var b = new Bucks(); + b.empty( + // add empty task (#end with no task cause error) + ).end(function last(err, res) { + // error in last callback + throw new Error('error in end'); + }, function finalErrorback(err) { + // catch uncaught error in last callback + // err => 'error in end' + }); +} + +function uncaught_error() { + try { + var b = new Bucks(); + b.then(function () { + throw new Error('error'); + }).end(); + } catch(e) { + // e => 'error' + } +} + +function waterfall() { + var t1: Bucks.Task = function t1(err, res) { + return 't1'; + }; + var t2: Bucks.Task = function t2(err, res) { + return 't2'; + }; + + new Bucks().waterfall([t1, t2]).end(function finish(err, ress) { + // ress => ['t1', 't2'] + }); + + // same as + new Bucks().add(t1).add(t2).end(function finish(err, ress) { + // ress => ['t1', 't2'] + }); +} + +function parallel() { + var b = new Bucks(); + + b.parallel([ + function task1(err, res) { + return "task1"; + }, + function task2(err, res, next) { + return next(null, "task2"); + }, + function task3(err, res, next) { + return next(new Error('passed error in task3')); + }, + function task4(err, res, next) { + throw new Error('thrown error in task4'); + } + ]).add(function getResults(err, res, next) { + // res => { + // err: [ + // null, + // null, + // [Error: passed error in task3], + // [Error: thrown error in task4] + // ], + // res: [ + // 'task1', + // 'task2', + // null, + // null + // ] + // } + next(); + }).end(); +} + +function onError() { + var onError = function (e: Error, bucks: Bucks.Bucks) { + console.log("Custom onError"); + }; + + // Bucks.onError!! + Bucks.onError(onError); + var b0 = new Bucks(); + b0 + .add(function(err, next) { + throw new Error('b0'); + }) + .end() + ; +} + +function dispose() { + var b0 = new Bucks(); + + b0.dispose = function dispose () { + // delete b0.dummy; + } + + b0 + .add(function(err, next) { + // b0.dummy = "dummy"; + next(); + }) + .end(null, null) + ; +} + +function debug() { + Bucks.DEBUG = true; +} diff --git a/bucksjs/bucks.d.ts b/bucksjs/bucks.d.ts new file mode 100644 index 000000000..111665744 --- /dev/null +++ b/bucksjs/bucks.d.ts @@ -0,0 +1,55 @@ +// Type definitions for bucks.js 0.8.3 +// Project: https://github.com/CyberAgent/bucks.js +// Definitions by: Shunsuke Ohtani +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Bucks { + + interface BucksStatic { + + VERSION: string; + + DEBUG: boolean; + + running: Bucks[]; + + living: Bucks[]; + + new (): Bucks; + + onError(onError:(err:Error, bucks:Bucks)=>any): void; + } + + interface Bucks { + + add(task: Task): Bucks; + + then(onSuccess: (res:any, next?:Next)=>any): Bucks; + + empty(): Bucks; + + error(onError: (err:Error, res:any, next?:Next)=>any): Bucks; + + parallel(tasks: Task[]): Bucks; + + waterfall(tasks: Task[]): Bucks; + + delay(ms: number): Bucks; + + dispose(): void; + + destroy(err: Error): Bucks; + + end(callback?: (err?:Error, res?:any)=>any, errback?: (err:Error)=>any): void; + } + + interface Task { + (err?: Error, res?: any, next?: Next): any; + } + + interface Next { + (err?: Error, res?: any): any; + } +} + +declare var Bucks: Bucks.BucksStatic; From c711aaae5cde8691b1d33b6d4d9dae876a0ebfde Mon Sep 17 00:00:00 2001 From: zaneli Date: Thu, 24 Jul 2014 12:17:15 +0900 Subject: [PATCH 18/22] Add comments for bucks.js --- CONTRIBUTORS.md | 1 + bucksjs/bucks.d.ts | 84 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e51d544d5..4a2d5d0ea 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -39,6 +39,7 @@ All definitions files include a header with the author and editors, so at some p * [Box2DWeb](http://code.google.com/p/box2dweb/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [Browser Harness](https://github.com/scriby/browser-harness) (by [Chris Scribner](https://github.com/scriby)) +* [bucks.js](https://github.com/CyberAgent/bucks.js) (by [Shunsuke Ohtani](https://github.com/zaneli)) * [CasperJS](http://casperjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) * [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle)) * [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/bucksjs/bucks.d.ts b/bucksjs/bucks.d.ts index 111665744..cac3c7121 100644 --- a/bucksjs/bucks.d.ts +++ b/bucksjs/bucks.d.ts @@ -7,47 +7,105 @@ declare module Bucks { interface BucksStatic { + /** + * bucks.js version. + */ VERSION: string; + /** + * If set `true`, uncaught errors are logged. + */ DEBUG: boolean; + /** + * Running bucks objects. + */ running: Bucks[]; + /** + * Not yet called `end` bucks object. + */ living: Bucks[]; - new (): Bucks; + /** + * Create bucks object. + */ + new(): Bucks; - onError(onError:(err:Error, bucks:Bucks)=>any): void; + /** + * Catch all errors. + * @param onError Function called after catching error + */ + onError(onError: (err:Error, bucks:Bucks)=>any): void; } interface Bucks { - add(task: Task): Bucks; + /** + * Add a task. + * @param task Function added async chain + */ + add(task: TaskWithNext): Bucks; - then(onSuccess: (res:any, next?:Next)=>any): Bucks; + /** + * Add a task called only in case of success. + * @param onSuccess Function called only in case of success + */ + then(onSuccess: (res:any, next?:Task)=>any): Bucks; + /** + * Add a empty task. + */ empty(): Bucks; - error(onError: (err:Error, res:any, next?:Next)=>any): Bucks; + /** + * Add a task called only in case of error. + * @param onError Function called only in case of error + */ + error(onError: (err:Error, next?:Task)=>any): Bucks; - parallel(tasks: Task[]): Bucks; + /** + * Add tasks in asynchronous way and join their results. + * @param tasks Functions called in asynchronous way and join their results + */ + parallel(tasks: TaskWithNext[]): Bucks; - waterfall(tasks: Task[]): Bucks; + /** + * Add tasks in asynchronous way and join their results. + * @param tasks Functions added async chain + */ + waterfall(tasks: TaskWithNext[]): Bucks; + /** + * Add delay execution. + * @param ms number millisecond for delaying + */ delay(ms: number): Bucks; + /** + * Called when destroy async chain. + */ dispose(): void; - destroy(err: Error): Bucks; + /** + * Destroy this object and call last callback function. + * @param err If specify err and no callback, throw to execute failure callback + */ + destroy(err?: Error): Bucks; - end(callback?: (err?:Error, res?:any)=>any, errback?: (err:Error)=>any): void; + /** + * Complete creating async chain and start executing. + * @param callback Last callback function + * @param errback Handler for occurring error in last callback function + */ + end(callback?: Task, errback?: (err:Error)=>any): void; + } + + interface TaskWithNext { + (err?: Error, res?: any, next?: Task): any; } interface Task { - (err?: Error, res?: any, next?: Next): any; - } - - interface Next { (err?: Error, res?: any): any; } } From cd24246cad4b8ccd0cf5c5755cf53dd158bcb060 Mon Sep 17 00:00:00 2001 From: jonathantyates Date: Thu, 24 Jul 2014 00:30:20 -0400 Subject: [PATCH 19/22] Add support for plugin --- browserify/browserify.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browserify/browserify.d.ts b/browserify/browserify.d.ts index 5326abaeb..02ac29bf2 100644 --- a/browserify/browserify.d.ts +++ b/browserify/browserify.d.ts @@ -22,6 +22,8 @@ interface BrowserifyObject extends NodeJS.EventEmitter { ignore(file: string): BrowserifyObject; transform(tr: string): BrowserifyObject; transform(tr: Function): BrowserifyObject; + plugin(plugin: string, opts?: any): BrowserifyObject; + plugin(plugin: Function, opts?: any): BrowserifyObject; } declare module "browserify" { @@ -33,4 +35,4 @@ declare module "browserify" { }): BrowserifyObject; export = browserify; -} \ No newline at end of file +} From 10f80b4b2080b3c5ede5f44cdf97f2f60b508644 Mon Sep 17 00:00:00 2001 From: zaneli Date: Thu, 24 Jul 2014 15:47:39 +0900 Subject: [PATCH 20/22] rename folder --- CONTRIBUTORS.md | 2 +- {bucksjs => bucks}/bucks-test.ts | 0 {bucksjs => bucks}/bucks.d.ts | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename {bucksjs => bucks}/bucks-test.ts (100%) rename {bucksjs => bucks}/bucks.d.ts (100%) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4a2d5d0ea..57e5eeb6f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -39,7 +39,7 @@ All definitions files include a header with the author and editors, so at some p * [Box2DWeb](http://code.google.com/p/box2dweb/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [Browser Harness](https://github.com/scriby/browser-harness) (by [Chris Scribner](https://github.com/scriby)) -* [bucks.js](https://github.com/CyberAgent/bucks.js) (by [Shunsuke Ohtani](https://github.com/zaneli)) +* [bucks](https://github.com/CyberAgent/bucks.js) (by [Shunsuke Ohtani](https://github.com/zaneli)) * [CasperJS](http://casperjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) * [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle)) * [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/bucksjs/bucks-test.ts b/bucks/bucks-test.ts similarity index 100% rename from bucksjs/bucks-test.ts rename to bucks/bucks-test.ts diff --git a/bucksjs/bucks.d.ts b/bucks/bucks.d.ts similarity index 100% rename from bucksjs/bucks.d.ts rename to bucks/bucks.d.ts From 2ca13ee457f59caea2c8e49fb44aca1c4cbcd617 Mon Sep 17 00:00:00 2001 From: brentj73 Date: Thu, 24 Jul 2014 13:08:45 +0100 Subject: [PATCH 21/22] Updated contributors.md for recaptcha.js details --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e51d544d5..ed2927d99 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -277,6 +277,7 @@ All definitions files include a header with the author and editors, so at some p * [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds)) * [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei)) * [Raven.js](https://github.com/getsentry/raven-js) (by [Santi Albo](https://github.com/santialbo)) +* [Recaptcha.js](https://www.google.com/recaptcha) (by [Brent Jenkins](https://github.com/brentj73)) * [Rickshaw](http://code.shutterstock.com/rickshaw/) (by [Blake Niemyjski](https://github.com/niemyjski)) * [Riot.js](https://github.com/moot/riotjs) (by [vvakame](https://github.com/vvakame)) * [Restify](https://github.com/mcavage/node-restify) (by [Bret Little](https://github.com/blittle)) From c322a99ff490720d05718d3d0eb6bb0fbf3c70c7 Mon Sep 17 00:00:00 2001 From: vvakame Date: Thu, 24 Jul 2014 23:07:06 +0900 Subject: [PATCH 22/22] add test for angular.d.ts --- angularjs/angular-tests.ts | 250 +++++++++++++++++++++++++++++++++++++ angularjs/angular.d.ts | 6 +- 2 files changed, 253 insertions(+), 3 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 8d86949d2..7f1e6edf9 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -271,3 +271,253 @@ test_IAttributes({ }, $attr: {} }); + +// test from https://docs.angularjs.org/guide/directive +angular.module('docsSimpleDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + template: 'Name: {{customer.name}} Address: {{customer.address}}' + }; + }); + +angular.module('docsTemplateUrlDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + templateUrl: 'my-customer.html' + }; + }); + +angular.module('docsRestrictDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); + +angular.module('docsScopeProblemExample', []) + .controller('NaomiController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .controller('IgorController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Igor', + address: '123 Somewhere' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); + +angular.module('docsIsolateScopeDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.igor = { name: 'Igor', address: '123 Somewhere' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-iso.html' + }; + }); + +angular.module('docsIsolationExample', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-plus-vojta.html' + }; + }); + +angular.module('docsTimeDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.format = 'M/d/yy h:mm:ss a'; + }]) + .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any): ng.IDirective { + + return { + link: function(scope: any, element: any, attrs: any) { + var format: any, + timeoutId: any; + + function updateTime() { + element.text(dateFilter(new Date(), format)); + } + + scope.$watch(attrs.myCurrentTime, function (value: any) { + format = value; + updateTime(); + }); + + element.on('$destroy', function () { + $interval.cancel(timeoutId); + }); + + // start the UI update process; save the timeoutId for canceling + timeoutId = $interval(function () { + updateTime(); // update DOM + }, 1000); + } + }; + }]); + +angular.module('docsTransclusionDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + templateUrl: 'my-dialog.html' + }; + }); + +angular.module('docsTransclusionExample', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + templateUrl: 'my-dialog.html', + link: function (scope: any, element: any) { + scope.name = 'Jeff'; + } + }; + }); + +angular.module('docsIsoFnBindExample', []) + .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) { + $scope.name = 'Tobias'; + $scope.hideDialog = function () { + $scope.dialogIsHidden = true; + $timeout(function () { + $scope.dialogIsHidden = false; + }, 2000); + }; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: { + 'close': '&onClose' + }, + templateUrl: 'my-dialog-close.html' + }; + }); + +angular.module('dragModule', []) + .directive('myDraggable', ['$document', function($document: any) { + return function(scope: any, element: any, attr: any) { + var startX = 0, startY = 0, x = 0, y = 0; + + element.css({ + position: 'relative', + border: '1px solid red', + backgroundColor: 'lightgrey', + cursor: 'pointer' + }); + + element.on('mousedown', function(event: any) { + // Prevent default dragging of selected content + event.preventDefault(); + startX = event.pageX - x; + startY = event.pageY - y; + $document.on('mousemove', mousemove); + $document.on('mouseup', mouseup); + }); + + function mousemove(event: any) { + y = event.pageY - startY; + x = event.pageX - startX; + element.css({ + top: y + 'px', + left: x + 'px' + }); + } + + function mouseup() { + $document.off('mousemove', mousemove); + $document.off('mouseup', mouseup); + } + }; + }]); + +angular.module('docsTabsExample', []) + .directive('myTabs', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + controller: function($scope: any) { + var panes: any = $scope.panes = []; + + $scope.select = function(pane: any) { + angular.forEach(panes, function(pane: any) { + pane.selected = false; + }); + pane.selected = true; + }; + + this.addPane = function(pane: any) { + if (panes.length === 0) { + $scope.select(pane); + } + panes.push(pane); + }; + }, + templateUrl: 'my-tabs.html' + }; + }) + .directive('myPane', function() { + return { + require: '^myTabs', + restrict: 'E', + transclude: true, + scope: { + title: '@' + }, + link: function(scope, element, attrs, tabsCtrl) { + tabsCtrl.addPane(scope); + }, + templateUrl: 'my-pane.html' + }; + }); diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index ca8751b8e..42d94ee8a 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1001,9 +1001,9 @@ declare module ng { link?: (scope: IScope, instanceElement: IAugmentedJQuery, - instanceAttributes: IAttributes, - controller: any, - transclude: ITranscludeFunction + instanceAttributes?: IAttributes, + controller?: any, + transclude?: ITranscludeFunction ) => void; name?: string; priority?: number;