diff --git a/types/bootstrap3-dialog/bootstrap3-dialog-tests.ts b/types/bootstrap3-dialog/bootstrap3-dialog-tests.ts
index 5cb019a24a..5434971f41 100644
--- a/types/bootstrap3-dialog/bootstrap3-dialog-tests.ts
+++ b/types/bootstrap3-dialog/bootstrap3-dialog-tests.ts
@@ -1,6 +1,6 @@
function BootstrapDialogOptionsTests() {
- const options1: BootstrapDialogOptions = { };
- const options2: BootstrapDialogOptions = {
+ const options1: BootstrapDialog.DialogOptions = { };
+ const options2: BootstrapDialog.DialogOptions = {
animate: false,
buttons: [{id: "btn-1"}],
callback: (result: boolean) => { },
@@ -12,10 +12,10 @@ function BootstrapDialogOptionsTests() {
description: "",
buttonLabel: "",
message: "",
- onhide: (dialog: BootstrapDialogContext) => { },
- onhidden: (dialog: BootstrapDialogContext) => { },
- onshow: (dialog: BootstrapDialogContext) => { },
- onshown: (dialog: BootstrapDialogContext) => { },
+ onhide: (dialog: BootstrapDialog.DialogContext) => { },
+ onhidden: (dialog: BootstrapDialog.DialogContext) => { },
+ onshow: (dialog: BootstrapDialog.DialogContext) => { },
+ onshown: (dialog: BootstrapDialog.DialogContext) => { },
size: BootstrapDialog.SIZE_LARGE,
title: "",
type: BootstrapDialog.TYPE_DEFAULT,
@@ -27,14 +27,14 @@ function BootstrapDialogOptionsTests() {
autodestroy: false,
nl2br: false,
};
- options2.onhide = (dialog: BootstrapDialogContext): void => { };
- options2.onhide = (dialog: BootstrapDialogContext): boolean => false;
+ options2.onhide = (dialog: BootstrapDialog.DialogContext): void => { };
+ options2.onhide = (dialog: BootstrapDialog.DialogContext): boolean => false;
options2.message = "";
options2.message = $("#element");
- options2.message = (dialog?: BootstrapDialogContext): string => {
+ options2.message = (dialog?: BootstrapDialog.DialogContext): string => {
return "";
};
- options2.message = (dialog?: BootstrapDialogContext): JQuery => {
+ options2.message = (dialog?: BootstrapDialog.DialogContext): JQuery => {
return $("#element");
};
// BootstrapDialog.SIZE_xxx constants.
@@ -58,7 +58,7 @@ function BootstrapDialogStaticTests() {
BootstrapDialog.alert("", () => { });
BootstrapDialog.confirm("");
BootstrapDialog.confirm("", (result: boolean) => { });
- const instance1: BootstrapDialogInstance = BootstrapDialog.show({});
+ const instance1: BootstrapDialog.DialogInstance = BootstrapDialog.show({});
// BUTTON_SIZES
BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL] = '';
const buttonSize: string = BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL];
@@ -74,7 +74,7 @@ function BootstrapDialogStaticTests() {
}
function BootstrapDialogContextTests() {
- const dialog1: BootstrapDialogContext = BootstrapDialog({});
+ const dialog1: BootstrapDialog.DialogContext = BootstrapDialog({});
dialog1.close();
dialog1.enableButtons(false);
const button: JQuery = dialog1.getButton("");
@@ -97,20 +97,20 @@ function BootstrapDialogContextTests() {
}
function BootstrapDialogInstanceTests() {
- const instance1: BootstrapDialogInstance = BootstrapDialog.show({});
+ const instance1: BootstrapDialog.DialogInstance = BootstrapDialog.show({});
const modal: JQuery = instance1.$modal;
const modalBody: JQuery = instance1.$modalBody;
const modalContent: JQuery = instance1.$modalContent;
const modalDialog: JQuery = instance1.$modalDialog;
const modalHeader: JQuery = instance1.$modalHeader;
const modalFooter: JQuery = instance1.$modalFooter;
- const options: BootstrapDialogOptions = instance1.options;
+ const options: BootstrapDialog.DialogOptions = instance1.options;
const opened: boolean = instance1.opened;
}
function BootstrapDialogButtonTests() {
- const button1: BootstrapDialogButton = { };
- const button2: BootstrapDialogButton = {
+ const button1: BootstrapDialog.DialogButton = { };
+ const button2: BootstrapDialog.DialogButton = {
id: "",
label: "",
hotkey: 0,
@@ -118,6 +118,6 @@ function BootstrapDialogButtonTests() {
cssClass: "",
data: {name: "value"},
autospin: false,
- action: (dialog: BootstrapDialogContext) => { },
+ action: (dialog: BootstrapDialog.DialogContext) => { },
};
}
diff --git a/types/bootstrap3-dialog/index.d.ts b/types/bootstrap3-dialog/index.d.ts
index 3d4082f14e..d9612167f8 100644
--- a/types/bootstrap3-dialog/index.d.ts
+++ b/types/bootstrap3-dialog/index.d.ts
@@ -7,189 +7,191 @@
///
-interface BootstrapDialogStatic {
- BUTTON_SIZES: any;
- BUTTONS_ORDER_CANCEL_OK: string;
- BUTTONS_ORDER_OK_CANCEL: string;
- DEFAULT_TEXTS: any; /** For text localization. */
- ICON_SPINNER: string;
- NAMESPACE: string;
+declare namespace BootstrapDialog {
+ interface DialogStatic {
+ BUTTON_SIZES: any;
+ BUTTONS_ORDER_CANCEL_OK: string;
+ BUTTONS_ORDER_OK_CANCEL: string;
+ DEFAULT_TEXTS: any; /** For text localization. */
+ ICON_SPINNER: string;
+ NAMESPACE: string;
- SIZE_NORMAL: string;
- SIZE_SMALL: string;
- SIZE_WIDE: string;
- SIZE_LARGE: string;
+ SIZE_NORMAL: string;
+ SIZE_SMALL: string;
+ SIZE_WIDE: string;
+ SIZE_LARGE: string;
- TYPE_DEFAULT: string;
- TYPE_INFO: string;
- TYPE_PRIMARY: string;
- TYPE_SUCCESS: string;
- TYPE_WARNING: string;
- TYPE_DANGER: string;
+ TYPE_DEFAULT: string;
+ TYPE_INFO: string;
+ TYPE_PRIMARY: string;
+ TYPE_SUCCESS: string;
+ TYPE_WARNING: string;
+ TYPE_DANGER: string;
- (options: BootstrapDialogOptions): BootstrapDialogContext;
- alert(message: string, closeCallback?: () => void): void;
- confirm(message: string, closeCallback?: (result: boolean) => void): void;
- show(options: BootstrapDialogOptions): BootstrapDialogInstance;
+ (options: DialogOptions): DialogContext;
+ alert(message: string, closeCallback?: () => void): void;
+ confirm(message: string, closeCallback?: (result: boolean) => void): void;
+ show(options: DialogOptions): DialogInstance;
+ }
+
+ interface DialogOptions {
+ /** Dialog header type. See BootstrapDialog.TYPE_xxx constants. */
+ type?: string;
+ /** Text size. See BootstrapDialog.SIZE_xxx constants. By default - SIZE_NORMAL */
+ size?: string;
+ /** Dialog title. Either string or JQuery element. */
+ title?: string | JQuery;
+ /** Dialog message. Either string, JQuery element, or function that returns either string or JQuery element. */
+ message?: string | JQuery | ((dialog?: DialogContext) => string | JQuery);
+ /**
+ * When set to true, you can close the dialog by:
+ * - Clicking the close icon in dialog header.
+ * - Clicking outside the dialog.
+ * - ESC key.
+ *
+ * FALSE by default.
+ */
+ closable?: boolean;
+ /** Whether dialog will close by clicking outside of it. */
+ closeByBackdrop?: boolean;
+ /** Whether dialog will close by ESC. */
+ closeByKeyboard?: boolean;
+ /** Whether fade-out background while showing the dialog. TRUE by default. */
+ animate?: boolean;
+ /** Data to be bound to the dialog. */
+ data?: any;
+ /** Whether dialog could be dragged by its header. Cursor could be changed (see doc)! FALSE by default. */
+ draggable?: boolean;
+ /**
+ * If provided, 'aria-describedby' attribute will be added to the dialog with the description string as its value. This can improve accessibility, as the description can be read by screen
+ * readers.
+ */
+ description?: string;
+ /** Default button title. OK by default. */
+ buttonLabel?: string;
+ buttons?: DialogButton[];
+ /** Result will be true if button was click, while it will be false if users close the dialog directly. */
+ callback?: (result: boolean) => void;
+ /** If provided, it will be invoked when the dialog is popping up. */
+ onshow?(dialog?: DialogContext): void;
+ /** If provided, it will be invoked when the dialog is popped up. */
+ onshown?(dialog?: DialogContext): void;
+ /**
+ * If provided, it will be invoked when the dialog is popping down.
+ * Return FALSE to don`t close the dialog. Don`t return anything by default.
+ */
+ onhide?(dialog?: DialogContext): any;
+ /** If provided, it will be invoked when the dialog is popped down. */
+ onhidden?(dialog?: DialogContext): void;
+
+ /** 'Cancel' by default. */
+ btnCancelLabel?: string;
+ /** 'OK' by default. */
+ btnOKLabel?: string;
+ /** If you didn't specify it, dialog type will be used. */
+ btnOKClass?: string;
+ /** Additional css classes that will be added to your dialog. */
+ cssClass?: string;
+ /** Icon class name, for example 'glyphicon glyphicon-check'. */
+ spinicon?: string;
+ /**
+ * When it's true, all modal stuff will be removed from the DOM tree after the dialog is popped down,
+ * set it to false if you need your dialog (same instance) pups up and down again and again.
+ * Default is true.
+ */
+ autodestroy?: boolean;
+ /**
+ * Automatically convert line breaking character to
if it's set to true,
+ * everything keeps original if it's false.
+ */
+ nl2br?: boolean;
+ }
+
+ interface DialogInstance {
+ $modal: JQuery;
+ $modalBody: JQuery;
+ $modalContent: JQuery;
+ $modalDialog: JQuery;
+ $modalHeader: JQuery;
+ $modalFooter: JQuery;
+ options: DialogOptions;
+ opened: boolean;
+ }
+
+ interface DialogButton {
+ /** If id is set, you can use dialogInstance.getButton(id) to get the button later. */
+ id?: string;
+ label?: string;
+ /** Hotkey char code */
+ hotkey?: number;
+ /** If set, the specified icon will be added to the button. */
+ icon?: string;
+ /** Additional css class to be added to the button. */
+ cssClass?: string;
+ /** Object containing data attributes to be added to the button. */
+ data?: any;
+ /** If it's true, after clicked the button a spinning icon appears. */
+ autospin?: boolean;
+ /**
+ * If provided, the callback will be invoked after the button is clicked, and the dialog instance
+ * will be passed to the callback function.
+ */
+ action?: (dialog: DialogContext) => void;
+ }
+
+ interface DialogButtonInstance {
+ toggleEnable(enabled: boolean): void;
+ /** Equals to $button.toggleEnable(true); */
+ enable(): void;
+ /** Equals to $button.toggleEnable(false); */
+ disable(): void;
+ toggleSpin(spin: boolean): void;
+ /** Equals to $button.toggleSpin(true); */
+ spin(): void;
+ /** Equals to $button.toggleSpin(false); */
+ stopSpin(): void;
+ }
+
+ interface DialogContext {
+ /** Open the dialog. Usage: dialogInstance.open() */
+ open(): void;
+ /** Close the dialog. Usage: dialogInstance.close() */
+ close(): void;
+ /**
+ * Calling dialog.open() will automatically get this method called first, but if you want to do something on your dialog
+ * before it's shown, you can manually call dialog.realize() before calling dialog.open().
+ */
+ realize(): void;
+ getTitle(): string;
+ setTitle(title: string): void;
+ setMessage(message: string): void;
+ /** Bind data entry to dialog instance, value can be any types that javascript supports. */
+ setData(dataName: string, value: any): void;
+ /** Get data entry according to the given key, returns null if no data entry found. */
+ getData(dataName: string): any;
+ getButton(buttonId: string): JQuery;
+ /**
+ * When set to true (default), dialog can be closed by clicking close icon in dialog header,
+ * or by clicking outside the dialog, or, ESC key is pressed.
+ */
+ setClosable(closable: boolean): void;
+ /** See BootstrapDialog.TYPE_xxx constants. */
+ setType(dialogType: string): void;
+ /** Disable all buttons in dialog footer when it's false, enable all when it's true. */
+ enableButtons(enable: boolean): void;
+ /** Return the raw modal, equivalent to $('
') */
+ getModal(): JQuery;
+ /** Return the raw modal content. */
+ getModalContent(): JQuery;
+ /** Return the raw modal dialog. */
+ getModalDialog(): JQuery;
+ /** Return the raw modal header. */
+ getModalHeader(): JQuery;
+ /** Return the raw modal footer. */
+ getModalFooter(): JQuery;
+ /** Return the raw modal body. */
+ getModalBody(): JQuery;
+ }
}
-interface BootstrapDialogOptions {
- /** Dialog header type. See BootstrapDialog.TYPE_xxx constants. */
- type?: string;
- /** Text size. See BootstrapDialog.SIZE_xxx constants. By default - SIZE_NORMAL */
- size?: string;
- /** Dialog title. Either string or JQuery element. */
- title?: string | JQuery;
- /** Dialog message. Either string, JQuery element, or function that returns either string or JQuery element. */
- message?: string | JQuery | ((dialog?: BootstrapDialogContext) => string | JQuery);
- /**
- * When set to true, you can close the dialog by:
- * - Clicking the close icon in dialog header.
- * - Clicking outside the dialog.
- * - ESC key.
- *
- * FALSE by default.
- */
- closable?: boolean;
- /** Whether dialog will close by clicking outside of it. */
- closeByBackdrop?: boolean;
- /** Whether dialog will close by ESC. */
- closeByKeyboard?: boolean;
- /** Whether fade-out background while showing the dialog. TRUE by default. */
- animate?: boolean;
- /** Data to be bound to the dialog. */
- data?: any;
- /** Whether dialog could be dragged by its header. Cursor could be changed (see doc)! FALSE by default. */
- draggable?: boolean;
- /**
- * If provided, 'aria-describedby' attribute will be added to the dialog with the description string as its value. This can improve accessibility, as the description can be read by screen
- * readers.
- */
- description?: string;
- /** Default button title. OK by default. */
- buttonLabel?: string;
- buttons?: BootstrapDialogButton[];
- /** Result will be true if button was click, while it will be false if users close the dialog directly. */
- callback?: (result: boolean) => void;
- /** If provided, it will be invoked when the dialog is popping up. */
- onshow?(dialog?: BootstrapDialogContext): void;
- /** If provided, it will be invoked when the dialog is popped up. */
- onshown?(dialog?: BootstrapDialogContext): void;
- /**
- * If provided, it will be invoked when the dialog is popping down.
- * Return FALSE to don`t close the dialog. Don`t return anything by default.
- */
- onhide?(dialog?: BootstrapDialogContext): any;
- /** If provided, it will be invoked when the dialog is popped down. */
- onhidden?(dialog?: BootstrapDialogContext): void;
-
- /** 'Cancel' by default. */
- btnCancelLabel?: string;
- /** 'OK' by default. */
- btnOKLabel?: string;
- /** If you didn't specify it, dialog type will be used. */
- btnOKClass?: string;
- /** Additional css classes that will be added to your dialog. */
- cssClass?: string;
- /** Icon class name, for example 'glyphicon glyphicon-check'. */
- spinicon?: string;
- /**
- * When it's true, all modal stuff will be removed from the DOM tree after the dialog is popped down,
- * set it to false if you need your dialog (same instance) pups up and down again and again.
- * Default is true.
- */
- autodestroy?: boolean;
- /**
- * Automatically convert line breaking character to
if it's set to true,
- * everything keeps original if it's false.
- */
- nl2br?: boolean;
-}
-
-interface BootstrapDialogInstance {
- $modal: JQuery;
- $modalBody: JQuery;
- $modalContent: JQuery;
- $modalDialog: JQuery;
- $modalHeader: JQuery;
- $modalFooter: JQuery;
- options: BootstrapDialogOptions;
- opened: boolean;
-}
-
-interface BootstrapDialogButton {
- /** If id is set, you can use dialogInstance.getButton(id) to get the button later. */
- id?: string;
- label?: string;
- /** Hotkey char code */
- hotkey?: number;
- /** If set, the specified icon will be added to the button. */
- icon?: string;
- /** Additional css class to be added to the button. */
- cssClass?: string;
- /** Object containing data attributes to be added to the button. */
- data?: any;
- /** If it's true, after clicked the button a spinning icon appears. */
- autospin?: boolean;
- /**
- * If provided, the callback will be invoked after the button is clicked, and the dialog instance
- * will be passed to the callback function.
- */
- action?: (dialog: BootstrapDialogContext) => void;
-}
-
-interface BootstrapDialogButtonInstance {
- toggleEnable(enabled: boolean): void;
- /** Equals to $button.toggleEnable(true); */
- enable(): void;
- /** Equals to $button.toggleEnable(false); */
- disable(): void;
- toggleSpin(spin: boolean): void;
- /** Equals to $button.toggleSpin(true); */
- spin(): void;
- /** Equals to $button.toggleSpin(false); */
- stopSpin(): void;
-}
-
-interface BootstrapDialogContext {
- /** Open the dialog. Usage: dialogInstance.open() */
- open(): void;
- /** Close the dialog. Usage: dialogInstance.close() */
- close(): void;
- /**
- * Calling dialog.open() will automatically get this method called first, but if you want to do something on your dialog
- * before it's shown, you can manually call dialog.realize() before calling dialog.open().
- */
- realize(): void;
- getTitle(): string;
- setTitle(title: string): void;
- setMessage(message: string): void;
- /** Bind data entry to dialog instance, value can be any types that javascript supports. */
- setData(dataName: string, value: any): void;
- /** Get data entry according to the given key, returns null if no data entry found. */
- getData(dataName: string): any;
- getButton(buttonId: string): JQuery;
- /**
- * When set to true (default), dialog can be closed by clicking close icon in dialog header,
- * or by clicking outside the dialog, or, ESC key is pressed.
- */
- setClosable(closable: boolean): void;
- /** See BootstrapDialog.TYPE_xxx constants. */
- setType(dialogType: string): void;
- /** Disable all buttons in dialog footer when it's false, enable all when it's true. */
- enableButtons(enable: boolean): void;
- /** Return the raw modal, equivalent to $('') */
- getModal(): JQuery;
- /** Return the raw modal content. */
- getModalContent(): JQuery;
- /** Return the raw modal dialog. */
- getModalDialog(): JQuery;
- /** Return the raw modal header. */
- getModalHeader(): JQuery;
- /** Return the raw modal footer. */
- getModalFooter(): JQuery;
- /** Return the raw modal body. */
- getModalBody(): JQuery;
-}
-
-declare var BootstrapDialog: BootstrapDialogStatic;
+declare const BootstrapDialog: BootstrapDialog.DialogStatic;