mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #196 from vbortone/bootbox
Added type definition file for Bootbox.js
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
// QUnit Tests for Bootbox 3.0
|
||||
/// <reference path="bootbox.d.ts" />
|
||||
|
||||
bootbox.alert("Are we ok?");
|
||||
bootbox.alert("Are we ok with Test button?", "Test");
|
||||
bootbox.alert("Are we ok with callback?", function() {
|
||||
console.log("Callback called!");
|
||||
});
|
||||
bootbox.alert("Are we ok with callback and custom button?", "Test", function() {
|
||||
console.log("Callback called!");
|
||||
});
|
||||
|
||||
bootbox.confirm("Click ok to pass test", function(result) {
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
bootbox.confirm("Click cancel to pass test", function(result) {
|
||||
console.log(!result);
|
||||
});
|
||||
|
||||
bootbox.confirm("Click confirm to pass test", "Cancel?", "Confirm?", function(result) {
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
bootbox.confirm("Click cancel to pass test", "Cancel?", "Confirm?", function(result) {
|
||||
console.log(!result);
|
||||
});
|
||||
|
||||
bootbox.prompt("Are we ok?");
|
||||
|
||||
bootbox.prompt("Enter 'ok' to pass test", function(result) {
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
bootbox.prompt("Enter 'ok' to pass test", "Cancel?", "Confirm?", function(result) {
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
bootbox.prompt("Keep default value and click ok", "Cancel?", "Confirm?", function(result) {
|
||||
console.log(result);
|
||||
}, "Test Value");
|
||||
|
||||
bootbox.dialog("Test Dialog");
|
||||
var handler = {
|
||||
label: "OK",
|
||||
class: "MyClass",
|
||||
callback: function () {
|
||||
console.log("Test Dialog");
|
||||
}
|
||||
};
|
||||
|
||||
var option = {
|
||||
header: "header",
|
||||
headerCloseButton: true
|
||||
};
|
||||
|
||||
bootbox.dialog("Test Dialog", handler);
|
||||
bootbox.dialog("Test Dialog", [handler], option);
|
||||
|
||||
bootbox.hideAll();
|
||||
bootbox.animate(false);
|
||||
bootbox.backdrop("backdrop");
|
||||
bootbox.classes("myClass");
|
||||
|
||||
var icons: BootboxIcons = {
|
||||
OK: "OK Icon",
|
||||
CANCEL: "Cancel Icon",
|
||||
CONFIRM: "Confirm Icon"
|
||||
};
|
||||
bootbox.setIcons(icons);
|
||||
|
||||
bootbox.setLocale("en");
|
||||
|
||||
bootbox.addLocale("klingon", { OK: "luq", CANCEL: "qIl", CONFIRM: "Confirm" });
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// Type definitions for Bootbox 3.0.0
|
||||
// Project: https://github.com/makeusabrew/bootbox
|
||||
// Definitions by: Vincent Bortone <https://github.com/vbortone/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface BootboxLocale {
|
||||
OK: string;
|
||||
CANCEL: string;
|
||||
CONFIRM: string;
|
||||
}
|
||||
|
||||
interface BootboxIcons {
|
||||
OK: any;
|
||||
CANCEL: any;
|
||||
CONFIRM: any;
|
||||
}
|
||||
|
||||
interface BootboxHandler {
|
||||
label: string;
|
||||
class: string;
|
||||
callback: (result?: any) => void;
|
||||
}
|
||||
|
||||
interface BootboxOption {
|
||||
header: string;
|
||||
headerCloseButton: bool;
|
||||
}
|
||||
|
||||
interface BootboxStatic {
|
||||
alert(message: string, callback: () => void): void;
|
||||
alert(message: string, customButtonText?: string, callback?: () => void): void;
|
||||
confirm(message: string, callback: (result: bool) => void): void;
|
||||
confirm(message: string, cancelButtonText?: string, confirmButtonText?: string, callback?: (result: bool) => void): void;
|
||||
prompt(message: string, callback: (result: string) => void, defaultValue?: string): void;
|
||||
prompt(message: string, cancelButtonText?: string, confirmButtonText?: string, callback?: (result: string) => void, defaultValue?: string): void;
|
||||
dialog(message: string, handlers: BootboxHandler[], options?: any): void;
|
||||
dialog(message: string, handler: BootboxHandler): void;
|
||||
dialog(message: string): void;
|
||||
hideAll(): void;
|
||||
animate(shouldAnimate: bool): void;
|
||||
backdrop(backdropValue: string): void;
|
||||
classes(customCssClasses: string): void;
|
||||
setIcons(icons: BootboxIcons): void;
|
||||
setLocale(localeName: string): void;
|
||||
addLocale(localeName: string, translations: BootboxLocale) : void;
|
||||
}
|
||||
|
||||
declare var bootbox : BootboxStatic;
|
||||
Reference in New Issue
Block a user