diff --git a/bootbox/bootbox-tests.ts b/bootbox/bootbox-tests.ts
index 66922ab2e..7cf6124cd 100644
--- a/bootbox/bootbox-tests.ts
+++ b/bootbox/bootbox-tests.ts
@@ -2,73 +2,76 @@
///
bootbox.alert("Are we ok?");
-bootbox.alert("Are we ok with Test button?", "Test");
-bootbox.alert("Are we ok with callback?", function() {
+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.alert({
+ message: "Are we ok with callback and custom button?",
+ callback: function () {
+ console.log("Callback called!");
+ }
});
-bootbox.confirm("Click ok to pass test", function(result) {
- console.log(result);
-});
+bootbox.confirm("Click ok to pass test");
-bootbox.confirm("Click cancel to pass test", function(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.confirm({
+ message: "Click confirm to pass test",
+ callback: function (result) {
+ console.log(result);
+ }
});
bootbox.prompt("Are we ok?");
-
-bootbox.prompt("Enter 'ok' to pass test", function(result) {
+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({
+ message: "Enter 'ok' to pass test", callback: 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",
+
+
+bootbox.dialog("Test Dialog", function (result) {
+ return result;
+});
+
+bootbox.dialog({
+ message: "Test Dialog",
+ callback: function (result) { }
+});
+
+var bdo: BootboxDialogOptions;
+var sampleButton: BootboxButton = {
+ label: 'ButtonLabelToUse',
callback: function () {
- console.log("Test Dialog");
+ return 'callback of button click'
+ },
+ className: 'additionalButtonClassName'
+};
+
+bdo = {
+ message: '',
+ className: 'callName',
+ buttons: {
+ 'ButtonTextLabel': sampleButton
}
};
-var option = {
- header: "header",
- headerCloseButton: true
-};
+bootbox.dialog(bdo);
-bootbox.dialog("Test Dialog", handler);
-bootbox.dialog("Test Dialog", [handler], option);
+bootbox.setDefaults({
+ locale: 'en_US',
+ animate: false,
+ backdrop: false,
+ className: 'newClassName',
+ closeButton: true,
+ show: true
+})
-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" });
\ No newline at end of file
+bootbox.hideAll();
\ No newline at end of file
diff --git a/bootbox/bootbox.d.ts b/bootbox/bootbox.d.ts
index 17732b603..6177e1396 100644
--- a/bootbox/bootbox.d.ts
+++ b/bootbox/bootbox.d.ts
@@ -1,48 +1,63 @@
-// Type definitions for Bootbox 3.0.0
+// Type definitions for Bootbox 4.0.0
// Project: https://github.com/makeusabrew/bootbox
-// Definitions by: Vincent Bortone
+// Definitions by: Vincent Bortone , Kon Pik
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-interface BootboxLocale {
- OK: string;
- CANCEL: string;
- CONFIRM: string;
+
+interface BootboxAlertOptions {
+ message: string;
+ callback?: () => any;
}
-interface BootboxIcons {
- OK: any;
- CANCEL: any;
- CONFIRM: any;
+interface BootboxConfirmOptions {
+ message: string;
+ callback?: (result: boolean) => any;
}
-interface BootboxHandler {
- label: string;
- class: string;
- callback: (result?: any) => void;
+interface BootboxPromptOptions {
+ message: string;
+ callback?: (result: string) => any;
}
-interface BootboxOption {
- header: string;
- headerCloseButton: boolean;
+interface BootboxButton {
+ label?: string;
+ className?: string;
+ callback?: () => any;
+}
+
+interface BootboxDialogOptions {
+ message: any; // String | Element
+ title?: any; // String | Element
+ callback?: (result: boolean) => any;
+ show?: boolean;
+ onEscape?: () => any;
+ backdrop?: boolean;
+ closeButton?: boolean;
+ animate?: boolean;
+ className?: string;
+ buttons?: Object; // complex object where each key is of type BootboxButton
+}
+
+interface BootboxDefaultOptions {
+ locale?: string;
+ show?: boolean;
+ backdrop?: boolean;
+ closeButton?: boolean;
+ animate?: boolean;
+ className?: string;
}
interface BootboxStatic {
- alert(message: string, callback: () => void): void;
- alert(message: string, customButtonText?: string, callback?: () => void): void;
- confirm(message: string, callback: (result: boolean) => void): void;
- confirm(message: string, cancelButtonText?: string, confirmButtonText?: string, callback?: (result: boolean) => 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;
+ alert(message: string, callback?: () => void): void;
+ alert(options: BootboxAlertOptions): void;
+ confirm(message: string, callback?: (result: boolean) => void): void;
+ confirm(options: BootboxConfirmOptions): void;
+ prompt(message: string, callback?: (result: string) => void): void;
+ prompt(options: BootboxPromptOptions): void;
+ dialog(message: string, callback?: (result: string) => void): void;
+ dialog(options: BootboxDialogOptions): void;
+ setDefaults(options: BootboxDefaultOptions): void;
hideAll(): void;
- animate(shouldAnimate: boolean): 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;
\ No newline at end of file
+declare var bootbox: BootboxStatic;
\ No newline at end of file