mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
Add angular-modal.d.ts
Valid for https://github.com/btford/angular-modal v0.5.0
This commit is contained in:
parent
4f7b7e01d3
commit
c7f1b568bd
104
angular-modal/angular-modal-tests.ts
Normal file
104
angular-modal/angular-modal-tests.ts
Normal file
@ -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();
|
||||
}
|
||||
|
||||
38
angular-modal/angular-modal.d.ts
vendored
Normal file
38
angular-modal/angular-modal.d.ts
vendored
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user