forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Valid for https://github.com/btford/angular-modal v0.5.0
- Loading branch information
1 parent
4f7b7e0
commit c7f1b56
Showing
2 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/// <reference path="../jquery/jquery.d.ts" /> | ||
/// <reference path="../angularjs/angular.d.ts" /> | ||
/// <reference path="angular-modal.d.ts" /> | ||
|
||
var btfModal: angularModal.AngularModalFactory; | ||
|
||
// Using template URL | ||
function withTemplateUrl() { | ||
btfModal({ | ||
controller: 'SomeController', | ||
controllerAs: 'vm', | ||
templateUrl: 'some-template.html' | ||
}); | ||
} | ||
|
||
// Using template | ||
function withTemplate() { | ||
btfModal({ | ||
controller: 'SomeController', | ||
controllerAs: 'vm', | ||
template: '<div></div>' | ||
}); | ||
} | ||
|
||
// Using controller function | ||
function withControllerAsFunction() { | ||
btfModal({ | ||
controller: function () {}, | ||
template: '<div></div>' | ||
}) | ||
} | ||
|
||
// Using constructor function | ||
function withControllerClass() { | ||
class TestController { | ||
constructor(dependency1:any, dependency2:any) {} | ||
} | ||
btfModal({ | ||
controller: TestController, | ||
template: '<div></div>' | ||
}); | ||
} | ||
|
||
// With container as selector | ||
function withContainerAsString() { | ||
btfModal({ | ||
template: '<div></div>', | ||
container: '.container' | ||
}); | ||
} | ||
|
||
// With container as jQuery element | ||
function withContainerAsJquery() { | ||
var container: JQuery = $('body'); | ||
btfModal({ | ||
template: '<div></div>', | ||
container: container | ||
}); | ||
} | ||
|
||
// With container as DOM Element | ||
function withContainerAsDom() { | ||
var container: Element = document.getElementById('container'); | ||
btfModal({ | ||
template: '<div></div>', | ||
container: container | ||
}); | ||
} | ||
|
||
// With container as DOM Element Array | ||
function withContainerAsDomArray() { | ||
var container: Element[] = [document.getElementById('container'), document.getElementById('container2')]; | ||
btfModal({ | ||
template: '<div></div>', | ||
container: container | ||
}); | ||
} | ||
|
||
// With container as function | ||
function withContainerAsFunction() { | ||
btfModal({ | ||
template: '<div></div>', | ||
container: function() {} | ||
}); | ||
} | ||
|
||
// With container as array | ||
function withContainerAsArray() { | ||
btfModal({ | ||
template: '<div></div>', | ||
container: ['1', 2] | ||
}); | ||
} | ||
|
||
// Calling return values | ||
function callingValues() { | ||
var modal: angularModal.AngularModal = btfModal({ | ||
template: '<div></div>' | ||
}); | ||
modal.activate().then(() => {}, () => {}); | ||
modal.deactivate().then(() => {}, () => {}); | ||
var isActive: boolean = modal.active(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Type definitions for angular-modal 0.5.0 | ||
// Project: https://github.com/btford/angular-modal | ||
// Definitions by: Paul Lessing <https://github.com/paullessing> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
/// <reference path="../angularjs/angular.d.ts" /> | ||
/// <reference path="../jquery/jquery.d.ts" /> | ||
|
||
declare module angularModal { | ||
|
||
type AngularModalControllerDefinition = (new (...args: any[]) => any) | Function | string; // Possible arguments to IControllerService | ||
|
||
type AngularModalJQuerySelector = string | Element | Element[] | JQuery | Function | any[] | {}; // Possible arguments to IAugmentedJQueryStatic | ||
|
||
interface AngularModalSettings { | ||
controller?: AngularModalControllerDefinition; | ||
controllerAs?: string; | ||
container?: AngularModalJQuerySelector; | ||
} | ||
|
||
export interface AngularModalSettingsWithTemplate extends AngularModalSettings { | ||
template: any; | ||
} | ||
|
||
export interface AngularModalSettingsWithTemplateUrl extends AngularModalSettings { | ||
templateUrl: string; | ||
} | ||
|
||
export interface AngularModal { | ||
activate(): angular.IPromise<void>; | ||
deactivate(): angular.IPromise<void>; | ||
active(): boolean; | ||
} | ||
|
||
export interface AngularModalFactory { | ||
(settings: AngularModalSettingsWithTemplate | AngularModalSettingsWithTemplateUrl): AngularModal; | ||
} | ||
} |