mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-15 06:20:23 +00:00
Merge pull request #6645 from stpettersens/master
Type definitions and tests for ngBootbox
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="ngbootbox.d.ts" />
|
||||
|
||||
class TestBootboxController {
|
||||
|
||||
constructor(private $scope: angular.IScope, $ngBootbox: BootboxService) {
|
||||
|
||||
$ngBootbox.alert('An important message!').then(function() {
|
||||
console.log('Alert closed');
|
||||
});
|
||||
|
||||
$ngBootbox.confirm('A question?').then(function() {
|
||||
console.log('Confirmed!');
|
||||
}, function() {
|
||||
console.log('Confirm dismissed!');
|
||||
});
|
||||
|
||||
$ngBootbox.prompt('Enter something').then(function(result) {
|
||||
console.log('Prompt returned: ' + result);
|
||||
}, function() {
|
||||
console.log('Prompt dismissed!');
|
||||
});
|
||||
|
||||
var options: NgBootboxDialog = {
|
||||
message: 'This is a message!',
|
||||
title: 'The title!',
|
||||
className: 'test-class',
|
||||
buttons: {
|
||||
warning: {
|
||||
label: "Cancel",
|
||||
className: "btn-warning",
|
||||
callback: function() {
|
||||
console.log('warning callback');
|
||||
}
|
||||
},
|
||||
success: {
|
||||
label: "Ok",
|
||||
className: "btn-success",
|
||||
callback: function() {
|
||||
console.log('sucess callback');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
$ngBootbox.customDialog(options);
|
||||
}
|
||||
}
|
||||
|
||||
var app = angular.module('testBootbox', ['ngBootbox']);
|
||||
app.controller('TestBootboxCtrl', ['$scope', '$ngBootbox', TestBootboxController]);
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
// Type definitions for ngbootbox
|
||||
// Project: https://github.com/eriktufvesson/ngBootbox
|
||||
// Definitions by: Sam Saint-Pettersen <https://github.com/stpettersens>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts" />
|
||||
/// <reference path="../bootbox/bootbox.d.ts" />
|
||||
|
||||
interface NgBootboxDialog {
|
||||
title?: string;
|
||||
message?: string;
|
||||
templateUrl?: string;
|
||||
locale?: string;
|
||||
callback?: () => any;
|
||||
onEscape?: () => any | boolean;
|
||||
show?: boolean;
|
||||
backdrop?: boolean;
|
||||
closeButton?: boolean;
|
||||
animate?: boolean;
|
||||
className?: string;
|
||||
size?: string;
|
||||
buttons?: BootboxButtonMap;
|
||||
}
|
||||
|
||||
interface BootboxService {
|
||||
alert(msg: string): Promise<any>;
|
||||
confirm(msg: string): Promise<any>;
|
||||
prompt(msg: string): Promise<any>;
|
||||
customDialog(options: NgBootboxDialog): void;
|
||||
setDefaults(options: BootboxDefaultOptions): void;
|
||||
hideAll(): void;
|
||||
|
||||
addLocale(name: string, values: BootboxLocaleValues): void;
|
||||
removeLocale(name: string): void;
|
||||
setLocale(name: string): void;
|
||||
}
|
||||
|
||||
declare var $ngBootbox: BootboxService;
|
||||
Reference in New Issue
Block a user