Commit 45910891 authored by Ad Schellevis's avatar Ad Schellevis

(mvc) pull in latest bootstrap-dialog

parent ff563e72
......@@ -11,17 +11,23 @@
*
* Licensed under The MIT License.
* ================================================ */
(function(root, factory) {
(function (root, factory) {
"use strict";
// CommonJS module is defined
if (typeof module !== 'undefined' && module.exports) {
module.exports = factory(require('jquery')(root));
var isNode = (typeof process !== "undefined");
var isElectron = isNode && ('electron' in process.versions);
if(isElectron) {
root.BootstrapDialog = factory(root.jQuery);
} else {
module.exports = factory(require('jquery'), require('bootstrap'));
}
}
// AMD module is defined
else if (typeof define === "function" && define.amd) {
define("bootstrap-dialog", ["jquery"], function($) {
define("bootstrap-dialog", ["jquery", "bootstrap"], function ($) {
return factory($);
});
} else {
......@@ -29,7 +35,7 @@
root.BootstrapDialog = factory(root.jQuery);
}
}(this, function($) {
}(this, function ($) {
"use strict";
......@@ -39,26 +45,28 @@
* BootstrapDialogModal === Modified Modal.
* ================================================ */
var Modal = $.fn.modal.Constructor;
var BootstrapDialogModal = function(element, options) {
var BootstrapDialogModal = function (element, options) {
Modal.call(this, element, options);
};
BootstrapDialogModal.getModalVersion = function() {
BootstrapDialogModal.getModalVersion = function () {
var version = null;
if (typeof $.fn.modal.Constructor.VERSION === 'undefined') {
version = 'v3.1';
} else if (/3\.2\.\d+/.test($.fn.modal.Constructor.VERSION)) {
version = 'v3.2';
} else if (/3\.3\.[1,2]/.test($.fn.modal.Constructor.VERSION)) {
version = 'v3.3'; // v3.3.1, v3.3.2
} else {
version = 'v3.3'; // v3.3+
version = 'v3.3.4';
}
return version;
};
BootstrapDialogModal.ORIGINAL_BODY_PADDING = $('body').css('padding-right') || 0;
BootstrapDialogModal.ORIGINAL_BODY_PADDING = parseInt(($('body').css('padding-right') || 0), 10);
BootstrapDialogModal.METHODS_TO_OVERRIDE = {};
BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.1'] = {};
BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.2'] = {
hide: function(e) {
hide: function (e) {
if (e) {
e.preventDefault();
}
......@@ -98,10 +106,10 @@
BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3'] = {
/**
* Overrided.
*
*
* @returns {undefined}
*/
setScrollbar: function() {
setScrollbar: function () {
var bodyPad = BootstrapDialogModal.ORIGINAL_BODY_PADDING;
if (this.bodyIsOverflowing) {
this.$body.css('padding-right', bodyPad + this.scrollbarWidth);
......@@ -109,10 +117,10 @@
},
/**
* Overrided.
*
*
* @returns {undefined}
*/
resetScrollbar: function() {
resetScrollbar: function () {
var openedDialogs = this.getGlobalOpenedDialogs();
if (openedDialogs.length === 0) {
this.$body.css('padding-right', BootstrapDialogModal.ORIGINAL_BODY_PADDING);
......@@ -120,12 +128,12 @@
},
/**
* Overrided.
*
*
* @returns {undefined}
*/
hideModal: function() {
hideModal: function () {
this.$element.hide();
this.backdrop($.proxy(function() {
this.backdrop($.proxy(function () {
var openedDialogs = this.getGlobalOpenedDialogs();
if (openedDialogs.length === 0) {
this.$body.removeClass('modal-open');
......@@ -136,16 +144,17 @@
}, this));
}
};
BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']);
BootstrapDialogModal.prototype = {
constructor: BootstrapDialogModal,
/**
* New function, to get the dialogs that opened by BootstrapDialog.
*
*
* @returns {undefined}
*/
getGlobalOpenedDialogs: function() {
getGlobalOpenedDialogs: function () {
var openedDialogs = [];
$.each(BootstrapDialog.dialogs, function(id, dialogInstance) {
$.each(BootstrapDialog.dialogs, function (id, dialogInstance) {
if (dialogInstance.isRealized() && dialogInstance.isOpened()) {
openedDialogs.push(dialogInstance);
}
......@@ -161,7 +170,7 @@
/* ================================================
* Definition of BootstrapDialog.
* ================================================ */
var BootstrapDialog = function(options) {
var BootstrapDialog = function (options) {
this.defaultOptions = $.extend(true, {
id: BootstrapDialog.newGuid(),
buttons: [],
......@@ -189,14 +198,12 @@
* Some constants.
*/
BootstrapDialog.NAMESPACE = 'bootstrap-dialog';
BootstrapDialog.TYPE_DEFAULT = 'type-default';
BootstrapDialog.TYPE_INFO = 'type-info';
BootstrapDialog.TYPE_PRIMARY = 'type-primary';
BootstrapDialog.TYPE_SUCCESS = 'type-success';
BootstrapDialog.TYPE_WARNING = 'type-warning';
BootstrapDialog.TYPE_DANGER = 'type-danger';
BootstrapDialog.DEFAULT_TEXTS = {};
BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT] = 'Information';
BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO] = 'Information';
......@@ -207,18 +214,15 @@
BootstrapDialog.DEFAULT_TEXTS['OK'] = 'OK';
BootstrapDialog.DEFAULT_TEXTS['CANCEL'] = 'Cancel';
BootstrapDialog.DEFAULT_TEXTS['CONFIRM'] = 'Confirmation';
BootstrapDialog.SIZE_NORMAL = 'size-normal';
BootstrapDialog.SIZE_SMALL = 'size-small';
BootstrapDialog.SIZE_WIDE = 'size-wide'; // size-wide is equal to modal-lg
BootstrapDialog.SIZE_LARGE = 'size-large';
BootstrapDialog.BUTTON_SIZES = {};
BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL] = '';
BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_SMALL] = '';
BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_WIDE] = '';
BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE] = 'btn-lg';
BootstrapDialog.ICON_SPINNER = 'glyphicon glyphicon-asterisk';
/**
......@@ -238,13 +242,14 @@
autodestroy: true,
draggable: false,
animate: true,
description: ''
description: '',
tabindex: -1
};
/**
* Config default options.
*/
BootstrapDialog.configDefaultOptions = function(options) {
BootstrapDialog.configDefaultOptions = function (options) {
BootstrapDialog.defaultOptions = $.extend(true, BootstrapDialog.defaultOptions, options);
};
......@@ -252,23 +257,58 @@
* Open / Close all created dialogs all at once.
*/
BootstrapDialog.dialogs = {};
BootstrapDialog.openAll = function() {
$.each(BootstrapDialog.dialogs, function(id, dialogInstance) {
BootstrapDialog.openAll = function () {
$.each(BootstrapDialog.dialogs, function (id, dialogInstance) {
dialogInstance.open();
});
};
BootstrapDialog.closeAll = function() {
$.each(BootstrapDialog.dialogs, function(id, dialogInstance) {
BootstrapDialog.closeAll = function () {
$.each(BootstrapDialog.dialogs, function (id, dialogInstance) {
dialogInstance.close();
});
};
/**
* Get dialog instance by given id.
*
* @returns dialog instance
*/
BootstrapDialog.getDialog = function (id) {
var dialog = null;
if (typeof BootstrapDialog.dialogs[id] !== 'undefined') {
dialog = BootstrapDialog.dialogs[id];
}
return dialog;
};
/**
* Set a dialog.
*
* @returns the dialog that has just been set.
*/
BootstrapDialog.setDialog = function (dialog) {
BootstrapDialog.dialogs[dialog.getId()] = dialog;
return dialog;
};
/**
* Alias of BootstrapDialog.setDialog(dialog)
*
* @param {type} dialog
* @returns {unresolved}
*/
BootstrapDialog.addDialog = function (dialog) {
return BootstrapDialog.setDialog(dialog);
};
/**
* Move focus to next visible dialog.
*/
BootstrapDialog.moveFocus = function() {
BootstrapDialog.moveFocus = function () {
var lastDialogInstance = null;
$.each(BootstrapDialog.dialogs, function(id, dialogInstance) {
$.each(BootstrapDialog.dialogs, function (id, dialogInstance) {
lastDialogInstance = dialogInstance;
});
if (lastDialogInstance !== null && lastDialogInstance.isRealized()) {
......@@ -278,8 +318,8 @@
BootstrapDialog.METHODS_TO_OVERRIDE = {};
BootstrapDialog.METHODS_TO_OVERRIDE['v3.1'] = {
handleModalBackdropEvent: function() {
this.getModal().on('click', {dialog: this}, function(event) {
handleModalBackdropEvent: function () {
this.getModal().on('click', {dialog: this}, function (event) {
event.target === this && event.data.dialog.isClosable() && event.data.dialog.canCloseByBackdrop() && event.data.dialog.close();
});
......@@ -287,14 +327,14 @@
},
/**
* To make multiple opened dialogs look better.
*
*
* Will be removed in later version, after Bootstrap Modal >= 3.3.0, updating z-index is unnecessary.
*/
updateZIndex: function() {
updateZIndex: function () {
var zIndexBackdrop = 1040;
var zIndexModal = 1050;
var dialogCount = 0;
$.each(BootstrapDialog.dialogs, function(dialogId, dialogInstance) {
$.each(BootstrapDialog.dialogs, function (dialogId, dialogInstance) {
dialogCount++;
});
var $modal = this.getModal();
......@@ -304,11 +344,10 @@
return this;
},
open: function() {
open: function () {
!this.isRealized() && this.realize();
this.getModal().modal('show');
this.updateZIndex();
this.setOpened(true);
return this;
}
......@@ -319,19 +358,20 @@
open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open']
};
BootstrapDialog.METHODS_TO_OVERRIDE['v3.3'] = {};
BootstrapDialog.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']);
BootstrapDialog.prototype = {
constructor: BootstrapDialog,
initOptions: function(options) {
initOptions: function (options) {
this.options = $.extend(true, this.defaultOptions, options);
return this;
},
holdThisInstance: function() {
BootstrapDialog.dialogs[this.getId()] = this;
holdThisInstance: function () {
BootstrapDialog.addDialog(this);
return this;
},
initModalStuff: function() {
initModalStuff: function () {
this.setModal(this.createModal())
.setModalDialog(this.createModalDialog())
.setModalContent(this.createModalContent())
......@@ -348,76 +388,77 @@
return this;
},
createModal: function() {
var $modal = $('<div class="modal" tabindex="-1" role="dialog" aria-hidden="true"></div>');
$modal.prop('id', this.getId()).attr('aria-labelledby', this.getId() + '_title');
createModal: function () {
var $modal = $('<div class="modal" role="dialog" aria-hidden="true"></div>');
$modal.prop('id', this.getId());
$modal.attr('aria-labelledby', this.getId() + '_title');
return $modal;
},
getModal: function() {
getModal: function () {
return this.$modal;
},
setModal: function($modal) {
setModal: function ($modal) {
this.$modal = $modal;
return this;
},
createModalDialog: function() {
createModalDialog: function () {
return $('<div class="modal-dialog"></div>');
},
getModalDialog: function() {
getModalDialog: function () {
return this.$modalDialog;
},
setModalDialog: function($modalDialog) {
setModalDialog: function ($modalDialog) {
this.$modalDialog = $modalDialog;
return this;
},
createModalContent: function() {
createModalContent: function () {
return $('<div class="modal-content"></div>');
},
getModalContent: function() {
getModalContent: function () {
return this.$modalContent;
},
setModalContent: function($modalContent) {
setModalContent: function ($modalContent) {
this.$modalContent = $modalContent;
return this;
},
createModalHeader: function() {
createModalHeader: function () {
return $('<div class="modal-header"></div>');
},
getModalHeader: function() {
getModalHeader: function () {
return this.$modalHeader;
},
setModalHeader: function($modalHeader) {
setModalHeader: function ($modalHeader) {
this.$modalHeader = $modalHeader;
return this;
},
createModalBody: function() {
createModalBody: function () {
return $('<div class="modal-body"></div>');
},
getModalBody: function() {
getModalBody: function () {
return this.$modalBody;
},
setModalBody: function($modalBody) {
setModalBody: function ($modalBody) {
this.$modalBody = $modalBody;
return this;
},
createModalFooter: function() {
createModalFooter: function () {
return $('<div class="modal-footer"></div>');
},
getModalFooter: function() {
getModalFooter: function () {
return this.$modalFooter;
},
setModalFooter: function($modalFooter) {
setModalFooter: function ($modalFooter) {
this.$modalFooter = $modalFooter;
return this;
},
createDynamicContent: function(rawContent) {
createDynamicContent: function (rawContent) {
var content = null;
if (typeof rawContent === 'function') {
content = rawContent.call(rawContent, this);
......@@ -430,39 +471,39 @@
return content;
},
formatStringContent: function(content) {
formatStringContent: function (content) {
if (this.options.nl2br) {
return content.replace(/\r\n/g, '<br />').replace(/[\r\n]/g, '<br />');
}
return content;
},
setData: function(key, value) {
setData: function (key, value) {
this.options.data[key] = value;
return this;
},
getData: function(key) {
getData: function (key) {
return this.options.data[key];
},
setId: function(id) {
setId: function (id) {
this.options.id = id;
return this;
},
getId: function() {
getId: function () {
return this.options.id;
},
getType: function() {
getType: function () {
return this.options.type;
},
setType: function(type) {
setType: function (type) {
this.options.type = type;
this.updateType();
return this;
},
updateType: function() {
updateType: function () {
if (this.isRealized()) {
var types = [BootstrapDialog.TYPE_DEFAULT,
BootstrapDialog.TYPE_INFO,
......@@ -476,16 +517,16 @@
return this;
},
getSize: function() {
getSize: function () {
return this.options.size;
},
setSize: function(size) {
setSize: function (size) {
this.options.size = size;
this.updateSize();
return this;
},
updateSize: function() {
updateSize: function () {
if (this.isRealized()) {
var dialog = this;
......@@ -509,13 +550,13 @@
}
// Button size
$.each(this.options.buttons, function(index, button) {
$.each(this.options.buttons, function (index, button) {
var $button = dialog.getButton(button.id);
var buttonSizes = ['btn-lg', 'btn-sm', 'btn-xs'];
var sizeClassSpecified = false;
if (typeof button['cssClass'] === 'string') {
var btnClasses = button['cssClass'].split(' ');
$.each(btnClasses, function(index, btnClass) {
$.each(btnClasses, function (index, btnClass) {
if ($.inArray(btnClass, buttonSizes) !== -1) {
sizeClassSpecified = true;
}
......@@ -530,24 +571,24 @@
return this;
},
getCssClass: function() {
getCssClass: function () {
return this.options.cssClass;
},
setCssClass: function(cssClass) {
setCssClass: function (cssClass) {
this.options.cssClass = cssClass;
return this;
},
getTitle: function() {
getTitle: function () {
return this.options.title;
},
setTitle: function(title) {
setTitle: function (title) {
this.options.title = title;
this.updateTitle();
return this;
},
updateTitle: function() {
updateTitle: function () {
if (this.isRealized()) {
var title = this.getTitle() !== null ? this.createDynamicContent(this.getTitle()) : this.getDefaultText();
this.getModalHeader().find('.' + this.getNamespace('title')).html('').append(title).prop('id', this.getId() + '_title');
......@@ -555,16 +596,16 @@
return this;
},
getMessage: function() {
getMessage: function () {
return this.options.message;
},
setMessage: function(message) {
setMessage: function (message) {
this.options.message = message;
this.updateMessage();
return this;
},
updateMessage: function() {
updateMessage: function () {
if (this.isRealized()) {
var message = this.createDynamicContent(this.getMessage());
this.getModalBody().find('.' + this.getNamespace('message')).html('').append(message);
......@@ -572,71 +613,71 @@
return this;
},
isClosable: function() {
isClosable: function () {
return this.options.closable;
},
setClosable: function(closable) {
setClosable: function (closable) {
this.options.closable = closable;
this.updateClosable();
return this;
},
setCloseByBackdrop: function(closeByBackdrop) {
setCloseByBackdrop: function (closeByBackdrop) {
this.options.closeByBackdrop = closeByBackdrop;
return this;
},
canCloseByBackdrop: function() {
canCloseByBackdrop: function () {
return this.options.closeByBackdrop;
},
setCloseByKeyboard: function(closeByKeyboard) {
setCloseByKeyboard: function (closeByKeyboard) {
this.options.closeByKeyboard = closeByKeyboard;
return this;
},
canCloseByKeyboard: function() {
canCloseByKeyboard: function () {
return this.options.closeByKeyboard;
},
isAnimate: function() {
isAnimate: function () {
return this.options.animate;
},
setAnimate: function(animate) {
setAnimate: function (animate) {
this.options.animate = animate;
return this;
},
updateAnimate: function() {
updateAnimate: function () {
if (this.isRealized()) {
this.getModal().toggleClass('fade', this.isAnimate());
}
return this;
},
getSpinicon: function() {
getSpinicon: function () {
return this.options.spinicon;
},
setSpinicon: function(spinicon) {
setSpinicon: function (spinicon) {
this.options.spinicon = spinicon;
return this;
},
addButton: function(button) {
addButton: function (button) {
this.options.buttons.push(button);
return this;
},
addButtons: function(buttons) {
addButtons: function (buttons) {
var that = this;
$.each(buttons, function(index, button) {
$.each(buttons, function (index, button) {
that.addButton(button);
});
return this;
},
getButtons: function() {
getButtons: function () {
return this.options.buttons;
},
setButtons: function(buttons) {
setButtons: function (buttons) {
this.options.buttons = buttons;
this.updateButtons();
......@@ -650,21 +691,21 @@
* @param {type} id
* @returns {undefined}
*/
getButton: function(id) {
getButton: function (id) {
if (typeof this.indexedButtons[id] !== 'undefined') {
return this.indexedButtons[id];
}
return null;
},
getButtonSize: function() {
getButtonSize: function () {
if (typeof BootstrapDialog.BUTTON_SIZES[this.getSize()] !== 'undefined') {
return BootstrapDialog.BUTTON_SIZES[this.getSize()];
}
return '';
},
updateButtons: function() {
updateButtons: function () {
if (this.isRealized()) {
if (this.getButtons().length === 0) {
this.getModalFooter().hide();
......@@ -675,27 +716,42 @@
return this;
},
isAutodestroy: function() {
isAutodestroy: function () {
return this.options.autodestroy;
},
setAutodestroy: function(autodestroy) {
setAutodestroy: function (autodestroy) {
this.options.autodestroy = autodestroy;
},
getDescription: function() {
getDescription: function () {
return this.options.description;
},
setDescription: function(description) {
setDescription: function (description) {
this.options.description = description;
return this;
},
getDefaultText: function() {
setTabindex: function (tabindex) {
this.options.tabindex = tabindex;
return this;
},
getTabindex: function () {
return this.options.tabindex;
},
updateTabindex: function () {
if (this.isRealized()) {
this.getModal().attr('tabindex', this.getTabindex());
}
return this;
},
getDefaultText: function () {
return BootstrapDialog.DEFAULT_TEXTS[this.getType()];
},
getNamespace: function(name) {
getNamespace: function (name) {
return BootstrapDialog.NAMESPACE + '-' + name;
},
createHeaderContent: function() {
createHeaderContent: function () {
var $container = $('<div></div>');
$container.addClass(this.getNamespace('header'));
......@@ -707,24 +763,24 @@
return $container;
},
createTitleContent: function() {
createTitleContent: function () {
var $title = $('<div></div>');
$title.addClass(this.getNamespace('title'));
return $title;
},
createCloseButton: function() {
createCloseButton: function () {
var $container = $('<div></div>');
$container.addClass(this.getNamespace('close-button'));
var $icon = $('<button class="close">&times;</button>');
$container.append($icon);
$container.on('click', {dialog: this}, function(event) {
$container.on('click', {dialog: this}, function (event) {
event.data.dialog.close();
});
return $container;
},
createBodyContent: function() {
createBodyContent: function () {
var $container = $('<div></div>');
$container.addClass(this.getNamespace('body'));
......@@ -733,24 +789,24 @@
return $container;
},
createMessageContent: function() {
createMessageContent: function () {
var $message = $('<div></div>');
$message.addClass(this.getNamespace('message'));
return $message;
},
createFooterContent: function() {
createFooterContent: function () {
var $container = $('<div></div>');
$container.addClass(this.getNamespace('footer'));
return $container;
},
createFooterButtons: function() {
createFooterButtons: function () {
var that = this;
var $container = $('<div></div>');
$container.addClass(this.getNamespace('footer-buttons'));
this.indexedButtons = {};
$.each(this.options.buttons, function(index, button) {
$.each(this.options.buttons, function (index, button) {
if (!button.id) {
button.id = BootstrapDialog.newGuid();
}
......@@ -761,7 +817,7 @@
return $container;
},
createButton: function(button) {
createButton: function (button) {
var $button = $('<button class="btn"></button>');
$button.prop('id', button.id);
$button.data('button', button);
......@@ -789,7 +845,7 @@
}
// Button on click
$button.on('click', {dialog: this, $button: $button, button: button}, function(event) {
$button.on('click', {dialog: this, $button: $button, button: button}, function (event) {
var dialog = event.data.dialog;
var $button = event.data.$button;
var button = $button.data('button');
......@@ -805,6 +861,11 @@
// Dynamically add extra functions to $button
this.enhanceButton($button);
//Initialize enabled or not
if(typeof button.enabled !== 'undefined') {
$button.toggleEnable(button.enabled);
}
return $button;
},
/**
......@@ -815,11 +876,11 @@
* @param {type} $button
* @returns {_L13.BootstrapDialog.prototype}
*/
enhanceButton: function($button) {
enhanceButton: function ($button) {
$button.dialog = this;
// Enable / Disable
$button.toggleEnable = function(enable) {
$button.toggleEnable = function (enable) {
var $this = this;
if (typeof enable !== 'undefined') {
$this.prop("disabled", !enable).toggleClass('disabled', !enable);
......@@ -829,13 +890,13 @@
return $this;
};
$button.enable = function() {
$button.enable = function () {
var $this = this;
$this.toggleEnable(true);
return $this;
};
$button.disable = function() {
$button.disable = function () {
var $this = this;
$this.toggleEnable(false);
......@@ -843,7 +904,7 @@
};
// Icon spinning, helpful for indicating ajax loading status.
$button.toggleSpin = function(spin) {
$button.toggleSpin = function (spin) {
var $this = this;
var dialog = $this.dialog;
var $icon = $this.find('.' + dialog.getNamespace('button-icon'));
......@@ -860,13 +921,13 @@
return $this;
};
$button.spin = function() {
$button.spin = function () {
var $this = this;
$this.toggleSpin(true);
return $this;
};
$button.stopSpin = function() {
$button.stopSpin = function () {
var $this = this;
$this.toggleSpin(false);
......@@ -875,7 +936,7 @@
return this;
},
createButtonIcon: function(icon) {
createButtonIcon: function (icon) {
var $icon = $('<span></span>');
$icon.addClass(this.getNamespace('button-icon')).addClass(icon);
......@@ -887,8 +948,8 @@
* @param {type} enable
* @returns {undefined}
*/
enableButtons: function(enable) {
$.each(this.indexedButtons, function(id, $button) {
enableButtons: function (enable) {
$.each(this.indexedButtons, function (id, $button) {
$button.toggleEnable(enable);
});
......@@ -899,7 +960,7 @@
*
* @returns {undefined}
*/
updateClosable: function() {
updateClosable: function () {
if (this.isRealized()) {
// Close button
this.getModalHeader().find('.' + this.getNamespace('close-button')).toggle(this.isClosable());
......@@ -911,7 +972,7 @@
* Set handler for modal event 'show.bs.modal'.
* This is a setter!
*/
onShow: function(onshow) {
onShow: function (onshow) {
this.options.onshow = onshow;
return this;
......@@ -920,7 +981,7 @@
* Set handler for modal event 'shown.bs.modal'.
* This is a setter!
*/
onShown: function(onshown) {
onShown: function (onshown) {
this.options.onshown = onshown;
return this;
......@@ -929,7 +990,7 @@
* Set handler for modal event 'hide.bs.modal'.
* This is a setter!
*/
onHide: function(onhide) {
onHide: function (onhide) {
this.options.onhide = onhide;
return this;
......@@ -938,29 +999,29 @@
* Set handler for modal event 'hidden.bs.modal'.
* This is a setter!
*/
onHidden: function(onhidden) {
onHidden: function (onhidden) {
this.options.onhidden = onhidden;
return this;
},
isRealized: function() {
isRealized: function () {
return this.realized;
},
setRealized: function(realized) {
setRealized: function (realized) {
this.realized = realized;
return this;
},
isOpened: function() {
isOpened: function () {
return this.opened;
},
setOpened: function(opened) {
setOpened: function (opened) {
this.opened = opened;
return this;
},
handleModalEvents: function() {
this.getModal().on('show.bs.modal', {dialog: this}, function(event) {
handleModalEvents: function () {
this.getModal().on('show.bs.modal', {dialog: this}, function (event) {
var dialog = event.data.dialog;
dialog.setOpened(true);
if (dialog.isModalEvent(event) && typeof dialog.options.onshow === 'function') {
......@@ -972,11 +1033,11 @@
return openIt;
}
});
this.getModal().on('shown.bs.modal', {dialog: this}, function(event) {
this.getModal().on('shown.bs.modal', {dialog: this}, function (event) {
var dialog = event.data.dialog;
dialog.isModalEvent(event) && typeof dialog.options.onshown === 'function' && dialog.options.onshown(dialog);
});
this.getModal().on('hide.bs.modal', {dialog: this}, function(event) {
this.getModal().on('hide.bs.modal', {dialog: this}, function (event) {
var dialog = event.data.dialog;
dialog.setOpened(false);
if (dialog.isModalEvent(event) && typeof dialog.options.onhide === 'function') {
......@@ -988,10 +1049,11 @@
return hideIt;
}
});
this.getModal().on('hidden.bs.modal', {dialog: this}, function(event) {
this.getModal().on('hidden.bs.modal', {dialog: this}, function (event) {
var dialog = event.data.dialog;
dialog.isModalEvent(event) && typeof dialog.options.onhidden === 'function' && dialog.options.onhidden(dialog);
if (dialog.isAutodestroy()) {
dialog.setRealized(false);
delete BootstrapDialog.dialogs[dialog.getId()];
$(this).remove();
}
......@@ -1002,12 +1064,12 @@
this.handleModalBackdropEvent();
// ESC key support
this.getModal().on('keyup', {dialog: this}, function(event) {
this.getModal().on('keyup', {dialog: this}, function (event) {
event.which === 27 && event.data.dialog.isClosable() && event.data.dialog.canCloseByKeyboard() && event.data.dialog.close();
});
// Button hotkey
this.getModal().on('keyup', {dialog: this}, function(event) {
this.getModal().on('keyup', {dialog: this}, function (event) {
var dialog = event.data.dialog;
if (typeof dialog.registeredButtonHotkeys[event.which] !== 'undefined') {
var $button = $(dialog.registeredButtonHotkeys[event.which]);
......@@ -1017,19 +1079,19 @@
return this;
},
handleModalBackdropEvent: function() {
this.getModal().on('click', {dialog: this}, function(event) {
handleModalBackdropEvent: function () {
this.getModal().on('click', {dialog: this}, function (event) {
$(event.target).hasClass('modal-backdrop') && event.data.dialog.isClosable() && event.data.dialog.canCloseByBackdrop() && event.data.dialog.close();
});
return this;
},
isModalEvent: function(event) {
isModalEvent: function (event) {
return typeof event.namespace !== 'undefined' && event.namespace === 'bs.modal';
},
makeModalDraggable: function() {
makeModalDraggable: function () {
if (this.options.draggable) {
this.getModalHeader().addClass(this.getNamespace('draggable')).on('mousedown', {dialog: this}, function(event) {
this.getModalHeader().addClass(this.getNamespace('draggable')).on('mousedown', {dialog: this}, function (event) {
var dialog = event.data.dialog;
dialog.draggableData.isMouseDown = true;
var dialogOffset = dialog.getModalDialog().offset();
......@@ -1038,10 +1100,10 @@
left: event.clientX - dialogOffset.left
};
});
this.getModal().on('mouseup mouseleave', {dialog: this}, function(event) {
this.getModal().on('mouseup mouseleave', {dialog: this}, function (event) {
event.data.dialog.draggableData.isMouseDown = false;
});
$('body').on('mousemove', {dialog: this}, function(event) {
$('body').on('mousemove', {dialog: this}, function (event) {
var dialog = event.data.dialog;
if (!dialog.draggableData.isMouseDown) {
return;
......@@ -1055,7 +1117,7 @@
return this;
},
realize: function() {
realize: function () {
this.initModalStuff();
this.getModal().addClass(BootstrapDialog.NAMESPACE)
.addClass(this.getCssClass());
......@@ -1081,16 +1143,18 @@
this.updateClosable();
this.updateAnimate();
this.updateSize();
this.updateTabindex();
return this;
},
open: function() {
open: function () {
!this.isRealized() && this.realize();
this.getModal().modal('show');
return this;
},
close: function() {
close: function () {
!this.isRealized() && this.realize();
this.getModal().modal('hide');
return this;
......@@ -1107,8 +1171,8 @@
*
* @returns {String}
*/
BootstrapDialog.newGuid = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
BootstrapDialog.newGuid = function () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
......@@ -1124,7 +1188,7 @@
* @param {type} options
* @returns the created dialog instance
*/
BootstrapDialog.show = function(options) {
BootstrapDialog.show = function (options) {
return new BootstrapDialog(options).open();
};
......@@ -1133,7 +1197,7 @@
*
* @returns the created dialog instance
*/
BootstrapDialog.alert = function() {
BootstrapDialog.alert = function () {
var options = {};
var defaultOptions = {
type: BootstrapDialog.TYPE_PRIMARY,
......@@ -1163,12 +1227,12 @@
data: {
callback: options.callback
},
onhide: function(dialog) {
onhide: function (dialog) {
!dialog.getData('btnClicked') && dialog.isClosable() && typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false);
},
buttons: [{
label: options.buttonLabel,
action: function(dialog) {
action: function (dialog) {
dialog.setData('btnClicked', true);
typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true);
dialog.close();
......@@ -1182,7 +1246,7 @@
*
* @returns the created dialog instance
*/
BootstrapDialog.confirm = function() {
BootstrapDialog.confirm = function () {
var options = {};
var defaultOptions = {
type: BootstrapDialog.TYPE_PRIMARY,
......@@ -1220,14 +1284,14 @@
},
buttons: [{
label: options.btnCancelLabel,
action: function(dialog) {
action: function (dialog) {
typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false);
dialog.close();
}
}, {
label: options.btnOKLabel,
cssClass: options.btnOKClass,
action: function(dialog) {
action: function (dialog) {
typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true);
dialog.close();
}
......@@ -1241,7 +1305,7 @@
* @param {type} message
* @returns the created dialog instance
*/
BootstrapDialog.warning = function(message, callback) {
BootstrapDialog.warning = function (message, callback) {
return new BootstrapDialog({
type: BootstrapDialog.TYPE_WARNING,
message: message
......@@ -1254,7 +1318,7 @@
* @param {type} message
* @returns the created dialog instance
*/
BootstrapDialog.danger = function(message, callback) {
BootstrapDialog.danger = function (message, callback) {
return new BootstrapDialog({
type: BootstrapDialog.TYPE_DANGER,
message: message
......@@ -1267,7 +1331,7 @@
* @param {type} message
* @returns the created dialog instance
*/
BootstrapDialog.success = function(message, callback) {
BootstrapDialog.success = function (message, callback) {
return new BootstrapDialog({
type: BootstrapDialog.TYPE_SUCCESS,
message: message
......
(function(a,b){if(typeof module!=="undefined"&&module.exports){module.exports=b(require("jquery")(a))}else{if(typeof define==="function"&&define.amd){define("bootstrap-dialog",["jquery"],function(c){return b(c)})}else{a.BootstrapDialog=b(a.jQuery)}}}(this,function(d){var b=d.fn.modal.Constructor;var c=function(f,e){b.call(this,f,e)};c.getModalVersion=function(){var e=null;if(typeof d.fn.modal.Constructor.VERSION==="undefined"){e="v3.1"}else{if(/3\.2\.\d+/.test(d.fn.modal.Constructor.VERSION)){e="v3.2"}else{e="v3.3"}}return e};c.ORIGINAL_BODY_PADDING=d("body").css("padding-right")||0;c.METHODS_TO_OVERRIDE={};c.METHODS_TO_OVERRIDE["v3.1"]={};c.METHODS_TO_OVERRIDE["v3.2"]={hide:function(g){if(g){g.preventDefault()}g=d.Event("hide.bs.modal");this.$element.trigger(g);if(!this.isShown||g.isDefaultPrevented()){return}this.isShown=false;var f=this.getGlobalOpenedDialogs();if(f.length===0){this.$body.removeClass("modal-open")}this.resetScrollbar();this.escape();d(document).off("focusin.bs.modal");this.$element.removeClass("in").attr("aria-hidden",true).off("click.dismiss.bs.modal");d.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",d.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal()}};c.METHODS_TO_OVERRIDE["v3.3"]={setScrollbar:function(){var e=c.ORIGINAL_BODY_PADDING;if(this.bodyIsOverflowing){this.$body.css("padding-right",e+this.scrollbarWidth)}},resetScrollbar:function(){var e=this.getGlobalOpenedDialogs();if(e.length===0){this.$body.css("padding-right",c.ORIGINAL_BODY_PADDING)}},hideModal:function(){this.$element.hide();this.backdrop(d.proxy(function(){var e=this.getGlobalOpenedDialogs();if(e.length===0){this.$body.removeClass("modal-open")}this.resetAdjustments();this.resetScrollbar();this.$element.trigger("hidden.bs.modal")},this))}};c.prototype={constructor:c,getGlobalOpenedDialogs:function(){var e=[];d.each(a.dialogs,function(g,f){if(f.isRealized()&&f.isOpened()){e.push(f)}});return e}};c.prototype=d.extend(c.prototype,b.prototype,c.METHODS_TO_OVERRIDE[c.getModalVersion()]);var a=function(e){this.defaultOptions=d.extend(true,{id:a.newGuid(),buttons:[],data:{},onshow:null,onshown:null,onhide:null,onhidden:null},a.defaultOptions);this.indexedButtons={};this.registeredButtonHotkeys={};this.draggableData={isMouseDown:false,mouseOffset:{}};this.realized=false;this.opened=false;this.initOptions(e);this.holdThisInstance()};a.BootstrapDialogModal=c;a.NAMESPACE="bootstrap-dialog";a.TYPE_DEFAULT="type-default";a.TYPE_INFO="type-info";a.TYPE_PRIMARY="type-primary";a.TYPE_SUCCESS="type-success";a.TYPE_WARNING="type-warning";a.TYPE_DANGER="type-danger";a.DEFAULT_TEXTS={};a.DEFAULT_TEXTS[a.TYPE_DEFAULT]="Information";a.DEFAULT_TEXTS[a.TYPE_INFO]="Information";a.DEFAULT_TEXTS[a.TYPE_PRIMARY]="Information";a.DEFAULT_TEXTS[a.TYPE_SUCCESS]="Success";a.DEFAULT_TEXTS[a.TYPE_WARNING]="Warning";a.DEFAULT_TEXTS[a.TYPE_DANGER]="Danger";a.DEFAULT_TEXTS.OK="OK";a.DEFAULT_TEXTS.CANCEL="Cancel";a.DEFAULT_TEXTS.CONFIRM="Confirmation";a.SIZE_NORMAL="size-normal";a.SIZE_SMALL="size-small";a.SIZE_WIDE="size-wide";a.SIZE_LARGE="size-large";a.BUTTON_SIZES={};a.BUTTON_SIZES[a.SIZE_NORMAL]="";a.BUTTON_SIZES[a.SIZE_SMALL]="";a.BUTTON_SIZES[a.SIZE_WIDE]="";a.BUTTON_SIZES[a.SIZE_LARGE]="btn-lg";a.ICON_SPINNER="glyphicon glyphicon-asterisk";a.defaultOptions={type:a.TYPE_PRIMARY,size:a.SIZE_NORMAL,cssClass:"",title:null,message:null,nl2br:true,closable:true,closeByBackdrop:true,closeByKeyboard:true,spinicon:a.ICON_SPINNER,autodestroy:true,draggable:false,animate:true,description:""};a.configDefaultOptions=function(e){a.defaultOptions=d.extend(true,a.defaultOptions,e)};a.dialogs={};a.openAll=function(){d.each(a.dialogs,function(f,e){e.open()})};a.closeAll=function(){d.each(a.dialogs,function(f,e){e.close()})};a.moveFocus=function(){var e=null;d.each(a.dialogs,function(g,f){e=f});if(e!==null&&e.isRealized()){e.getModal().focus()}};a.METHODS_TO_OVERRIDE={};a.METHODS_TO_OVERRIDE["v3.1"]={handleModalBackdropEvent:function(){this.getModal().on("click",{dialog:this},function(e){e.target===this&&e.data.dialog.isClosable()&&e.data.dialog.canCloseByBackdrop()&&e.data.dialog.close()});return this},updateZIndex:function(){var g=1040;var h=1050;var i=0;d.each(a.dialogs,function(j,k){i++});var f=this.getModal();var e=f.data("bs.modal").$backdrop;f.css("z-index",h+(i-1)*20);e.css("z-index",g+(i-1)*20);return this},open:function(){!this.isRealized()&&this.realize();this.getModal().modal("show");this.updateZIndex();this.setOpened(true);return this}};a.METHODS_TO_OVERRIDE["v3.2"]={handleModalBackdropEvent:a.METHODS_TO_OVERRIDE["v3.1"]["handleModalBackdropEvent"],updateZIndex:a.METHODS_TO_OVERRIDE["v3.1"]["updateZIndex"],open:a.METHODS_TO_OVERRIDE["v3.1"]["open"]};a.METHODS_TO_OVERRIDE["v3.3"]={};a.prototype={constructor:a,initOptions:function(e){this.options=d.extend(true,this.defaultOptions,e);return this},holdThisInstance:function(){a.dialogs[this.getId()]=this;return this},initModalStuff:function(){this.setModal(this.createModal()).setModalDialog(this.createModalDialog()).setModalContent(this.createModalContent()).setModalHeader(this.createModalHeader()).setModalBody(this.createModalBody()).setModalFooter(this.createModalFooter());this.getModal().append(this.getModalDialog());this.getModalDialog().append(this.getModalContent());this.getModalContent().append(this.getModalHeader()).append(this.getModalBody()).append(this.getModalFooter());return this},createModal:function(){var e=d('<div class="modal" tabindex="-1" role="dialog" aria-hidden="true"></div>');e.prop("id",this.getId()).attr("aria-labelledby",this.getId()+"_title");return e},getModal:function(){return this.$modal},setModal:function(e){this.$modal=e;return this},createModalDialog:function(){return d('<div class="modal-dialog"></div>')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(e){this.$modalDialog=e;return this},createModalContent:function(){return d('<div class="modal-content"></div>')},getModalContent:function(){return this.$modalContent},setModalContent:function(e){this.$modalContent=e;return this},createModalHeader:function(){return d('<div class="modal-header"></div>')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(e){this.$modalHeader=e;return this},createModalBody:function(){return d('<div class="modal-body"></div>')},getModalBody:function(){return this.$modalBody},setModalBody:function(e){this.$modalBody=e;return this},createModalFooter:function(){return d('<div class="modal-footer"></div>')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(e){this.$modalFooter=e;return this},createDynamicContent:function(f){var e=null;if(typeof f==="function"){e=f.call(f,this)}else{e=f}if(typeof e==="string"){e=this.formatStringContent(e)}return e},formatStringContent:function(e){if(this.options.nl2br){return e.replace(/\r\n/g,"<br />").replace(/[\r\n]/g,"<br />")}return e},setData:function(e,f){this.options.data[e]=f;return this},getData:function(e){return this.options.data[e]},setId:function(e){this.options.id=e;return this},getId:function(){return this.options.id},getType:function(){return this.options.type},setType:function(e){this.options.type=e;this.updateType();return this},updateType:function(){if(this.isRealized()){var e=[a.TYPE_DEFAULT,a.TYPE_INFO,a.TYPE_PRIMARY,a.TYPE_SUCCESS,a.TYPE_WARNING,a.TYPE_DANGER];this.getModal().removeClass(e.join(" ")).addClass(this.getType())}return this},getSize:function(){return this.options.size},setSize:function(e){this.options.size=e;this.updateSize();return this},updateSize:function(){if(this.isRealized()){var e=this;this.getModal().removeClass(a.SIZE_NORMAL).removeClass(a.SIZE_SMALL).removeClass(a.SIZE_WIDE).removeClass(a.SIZE_LARGE);this.getModal().addClass(this.getSize());this.getModalDialog().removeClass("modal-sm");if(this.getSize()===a.SIZE_SMALL){this.getModalDialog().addClass("modal-sm")}this.getModalDialog().removeClass("modal-lg");if(this.getSize()===a.SIZE_WIDE){this.getModalDialog().addClass("modal-lg")}d.each(this.options.buttons,function(g,i){var k=e.getButton(i.id);var f=["btn-lg","btn-sm","btn-xs"];var j=false;if(typeof i.cssClass==="string"){var h=i.cssClass.split(" ");d.each(h,function(l,m){if(d.inArray(m,f)!==-1){j=true}})}if(!j){k.removeClass(f.join(" "));k.addClass(e.getButtonSize())}})}return this},getCssClass:function(){return this.options.cssClass},setCssClass:function(e){this.options.cssClass=e;return this},getTitle:function(){return this.options.title},setTitle:function(e){this.options.title=e;this.updateTitle();return this},updateTitle:function(){if(this.isRealized()){var e=this.getTitle()!==null?this.createDynamicContent(this.getTitle()):this.getDefaultText();this.getModalHeader().find("."+this.getNamespace("title")).html("").append(e).prop("id",this.getId()+"_title")}return this},getMessage:function(){return this.options.message},setMessage:function(e){this.options.message=e;this.updateMessage();return this},updateMessage:function(){if(this.isRealized()){var e=this.createDynamicContent(this.getMessage());this.getModalBody().find("."+this.getNamespace("message")).html("").append(e)}return this},isClosable:function(){return this.options.closable},setClosable:function(e){this.options.closable=e;this.updateClosable();return this},setCloseByBackdrop:function(e){this.options.closeByBackdrop=e;return this},canCloseByBackdrop:function(){return this.options.closeByBackdrop},setCloseByKeyboard:function(e){this.options.closeByKeyboard=e;return this},canCloseByKeyboard:function(){return this.options.closeByKeyboard},isAnimate:function(){return this.options.animate},setAnimate:function(e){this.options.animate=e;return this},updateAnimate:function(){if(this.isRealized()){this.getModal().toggleClass("fade",this.isAnimate())}return this},getSpinicon:function(){return this.options.spinicon},setSpinicon:function(e){this.options.spinicon=e;return this},addButton:function(e){this.options.buttons.push(e);return this},addButtons:function(f){var e=this;d.each(f,function(g,h){e.addButton(h)});return this},getButtons:function(){return this.options.buttons},setButtons:function(e){this.options.buttons=e;this.updateButtons();return this},getButton:function(e){if(typeof this.indexedButtons[e]!=="undefined"){return this.indexedButtons[e]}return null},getButtonSize:function(){if(typeof a.BUTTON_SIZES[this.getSize()]!=="undefined"){return a.BUTTON_SIZES[this.getSize()]}return""},updateButtons:function(){if(this.isRealized()){if(this.getButtons().length===0){this.getModalFooter().hide()}else{this.getModalFooter().show().find("."+this.getNamespace("footer")).html("").append(this.createFooterButtons())}}return this},isAutodestroy:function(){return this.options.autodestroy},setAutodestroy:function(e){this.options.autodestroy=e},getDescription:function(){return this.options.description},setDescription:function(e){this.options.description=e;return this},getDefaultText:function(){return a.DEFAULT_TEXTS[this.getType()]},getNamespace:function(e){return a.NAMESPACE+"-"+e},createHeaderContent:function(){var e=d("<div></div>");e.addClass(this.getNamespace("header"));e.append(this.createTitleContent());e.prepend(this.createCloseButton());return e},createTitleContent:function(){var e=d("<div></div>");e.addClass(this.getNamespace("title"));return e},createCloseButton:function(){var f=d("<div></div>");f.addClass(this.getNamespace("close-button"));var e=d('<button class="close">&times;</button>');f.append(e);f.on("click",{dialog:this},function(g){g.data.dialog.close()});return f},createBodyContent:function(){var e=d("<div></div>");e.addClass(this.getNamespace("body"));e.append(this.createMessageContent());return e},createMessageContent:function(){var e=d("<div></div>");e.addClass(this.getNamespace("message"));return e},createFooterContent:function(){var e=d("<div></div>");e.addClass(this.getNamespace("footer"));return e},createFooterButtons:function(){var e=this;var f=d("<div></div>");f.addClass(this.getNamespace("footer-buttons"));this.indexedButtons={};d.each(this.options.buttons,function(g,h){if(!h.id){h.id=a.newGuid()}var i=e.createButton(h);e.indexedButtons[h.id]=i;f.append(i)});return f},createButton:function(e){var f=d('<button class="btn"></button>');f.prop("id",e.id);f.data("button",e);if(typeof e.icon!=="undefined"&&d.trim(e.icon)!==""){f.append(this.createButtonIcon(e.icon))}if(typeof e.label!=="undefined"){f.append(e.label)}if(typeof e.cssClass!=="undefined"&&d.trim(e.cssClass)!==""){f.addClass(e.cssClass)}else{f.addClass("btn-default")}if(typeof e.hotkey!=="undefined"){this.registeredButtonHotkeys[e.hotkey]=f}f.on("click",{dialog:this,$button:f,button:e},function(i){var h=i.data.dialog;var j=i.data.$button;var g=j.data("button");if(typeof g.action==="function"){g.action.call(j,h,i)}if(g.autospin){j.toggleSpin(true)}});this.enhanceButton(f);return f},enhanceButton:function(e){e.dialog=this;e.toggleEnable=function(f){var g=this;if(typeof f!=="undefined"){g.prop("disabled",!f).toggleClass("disabled",!f)}else{g.prop("disabled",!g.prop("disabled"))}return g};e.enable=function(){var f=this;f.toggleEnable(true);return f};e.disable=function(){var f=this;f.toggleEnable(false);return f};e.toggleSpin=function(i){var h=this;var g=h.dialog;var f=h.find("."+g.getNamespace("button-icon"));if(typeof i==="undefined"){i=!(e.find(".icon-spin").length>0)}if(i){f.hide();e.prepend(g.createButtonIcon(g.getSpinicon()).addClass("icon-spin"))}else{f.show();e.find(".icon-spin").remove()}return h};e.spin=function(){var f=this;f.toggleSpin(true);return f};e.stopSpin=function(){var f=this;f.toggleSpin(false);return f};return this},createButtonIcon:function(f){var e=d("<span></span>");e.addClass(this.getNamespace("button-icon")).addClass(f);return e},enableButtons:function(e){d.each(this.indexedButtons,function(g,f){f.toggleEnable(e)});return this},updateClosable:function(){if(this.isRealized()){this.getModalHeader().find("."+this.getNamespace("close-button")).toggle(this.isClosable())}return this},onShow:function(e){this.options.onshow=e;return this},onShown:function(e){this.options.onshown=e;return this},onHide:function(e){this.options.onhide=e;return this},onHidden:function(e){this.options.onhidden=e;return this},isRealized:function(){return this.realized},setRealized:function(e){this.realized=e;return this},isOpened:function(){return this.opened},setOpened:function(e){this.opened=e;return this},handleModalEvents:function(){this.getModal().on("show.bs.modal",{dialog:this},function(g){var f=g.data.dialog;f.setOpened(true);if(f.isModalEvent(g)&&typeof f.options.onshow==="function"){var e=f.options.onshow(f);if(e===false){f.setOpened(false)}return e}});this.getModal().on("shown.bs.modal",{dialog:this},function(f){var e=f.data.dialog;e.isModalEvent(f)&&typeof e.options.onshown==="function"&&e.options.onshown(e)});this.getModal().on("hide.bs.modal",{dialog:this},function(f){var e=f.data.dialog;e.setOpened(false);if(e.isModalEvent(f)&&typeof e.options.onhide==="function"){var g=e.options.onhide(e);if(g===false){e.setOpened(true)}return g}});this.getModal().on("hidden.bs.modal",{dialog:this},function(f){var e=f.data.dialog;e.isModalEvent(f)&&typeof e.options.onhidden==="function"&&e.options.onhidden(e);if(e.isAutodestroy()){delete a.dialogs[e.getId()];d(this).remove()}a.moveFocus()});this.handleModalBackdropEvent();this.getModal().on("keyup",{dialog:this},function(e){e.which===27&&e.data.dialog.isClosable()&&e.data.dialog.canCloseByKeyboard()&&e.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(f){var e=f.data.dialog;if(typeof e.registeredButtonHotkeys[f.which]!=="undefined"){var g=d(e.registeredButtonHotkeys[f.which]);!g.prop("disabled")&&g.focus().trigger("click")}});return this},handleModalBackdropEvent:function(){this.getModal().on("click",{dialog:this},function(e){d(e.target).hasClass("modal-backdrop")&&e.data.dialog.isClosable()&&e.data.dialog.canCloseByBackdrop()&&e.data.dialog.close()});return this},isModalEvent:function(e){return typeof e.namespace!=="undefined"&&e.namespace==="bs.modal"},makeModalDraggable:function(){if(this.options.draggable){this.getModalHeader().addClass(this.getNamespace("draggable")).on("mousedown",{dialog:this},function(g){var f=g.data.dialog;f.draggableData.isMouseDown=true;var e=f.getModalDialog().offset();f.draggableData.mouseOffset={top:g.clientY-e.top,left:g.clientX-e.left}});this.getModal().on("mouseup mouseleave",{dialog:this},function(e){e.data.dialog.draggableData.isMouseDown=false});d("body").on("mousemove",{dialog:this},function(f){var e=f.data.dialog;if(!e.draggableData.isMouseDown){return}e.getModalDialog().offset({top:f.clientY-e.draggableData.mouseOffset.top,left:f.clientX-e.draggableData.mouseOffset.left})})}return this},realize:function(){this.initModalStuff();this.getModal().addClass(a.NAMESPACE).addClass(this.getCssClass());this.updateSize();if(this.getDescription()){this.getModal().attr("aria-describedby",this.getDescription())}this.getModalFooter().append(this.createFooterContent());this.getModalHeader().append(this.createHeaderContent());this.getModalBody().append(this.createBodyContent());this.getModal().data("bs.modal",new c(this.getModal(),{backdrop:"static",keyboard:false,show:false}));this.makeModalDraggable();this.handleModalEvents();this.setRealized(true);this.updateButtons();this.updateType();this.updateTitle();this.updateMessage();this.updateClosable();this.updateAnimate();this.updateSize();return this},open:function(){!this.isRealized()&&this.realize();this.getModal().modal("show");return this},close:function(){this.getModal().modal("hide");return this}};a.prototype=d.extend(a.prototype,a.METHODS_TO_OVERRIDE[c.getModalVersion()]);a.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(g){var f=Math.random()*16|0,e=g==="x"?f:(f&3|8);return e.toString(16)})};a.show=function(e){return new a(e).open()};a.alert=function(){var f={};var e={type:a.TYPE_PRIMARY,title:null,message:null,closable:false,draggable:false,buttonLabel:a.DEFAULT_TEXTS.OK,callback:null};if(typeof arguments[0]==="object"&&arguments[0].constructor==={}.constructor){f=d.extend(true,e,arguments[0])}else{f=d.extend(true,e,{message:arguments[0],callback:typeof arguments[1]!=="undefined"?arguments[1]:null})}return new a({type:f.type,title:f.title,message:f.message,closable:f.closable,draggable:f.draggable,data:{callback:f.callback},onhide:function(g){!g.getData("btnClicked")&&g.isClosable()&&typeof g.getData("callback")==="function"&&g.getData("callback")(false)},buttons:[{label:f.buttonLabel,action:function(g){g.setData("btnClicked",true);typeof g.getData("callback")==="function"&&g.getData("callback")(true);g.close()}}]}).open()};a.confirm=function(){var f={};var e={type:a.TYPE_PRIMARY,title:null,message:null,closable:false,draggable:false,btnCancelLabel:a.DEFAULT_TEXTS.CANCEL,btnOKLabel:a.DEFAULT_TEXTS.OK,btnOKClass:null,callback:null};if(typeof arguments[0]==="object"&&arguments[0].constructor==={}.constructor){f=d.extend(true,e,arguments[0])}else{f=d.extend(true,e,{message:arguments[0],closable:false,buttonLabel:a.DEFAULT_TEXTS.OK,callback:typeof arguments[1]!=="undefined"?arguments[1]:null})}if(f.btnOKClass===null){f.btnOKClass=["btn",f.type.split("-")[1]].join("-")}return new a({type:f.type,title:f.title,message:f.message,closable:f.closable,draggable:f.draggable,data:{callback:f.callback},buttons:[{label:f.btnCancelLabel,action:function(g){typeof g.getData("callback")==="function"&&g.getData("callback")(false);g.close()}},{label:f.btnOKLabel,cssClass:f.btnOKClass,action:function(g){typeof g.getData("callback")==="function"&&g.getData("callback")(true);g.close()}}]}).open()};a.warning=function(e,f){return new a({type:a.TYPE_WARNING,message:e}).open()};a.danger=function(e,f){return new a({type:a.TYPE_DANGER,message:e}).open()};a.success=function(e,f){return new a({type:a.TYPE_SUCCESS,message:e}).open()};return a}));
\ No newline at end of file
!function(t,e){"use strict";if("undefined"!=typeof module&&module.exports){var n="undefined"!=typeof process,o=n&&"electron"in process.versions;o?t.BootstrapDialog=e(t.jQuery):module.exports=e(require("jquery"),require("bootstrap"))}else"function"==typeof define&&define.amd?define("bootstrap-dialog",["jquery","bootstrap"],function(t){return e(t)}):t.BootstrapDialog=e(t.jQuery)}(this,function(t){"use strict";var e=t.fn.modal.Constructor,n=function(t,n){e.call(this,t,n)};n.getModalVersion=function(){var e=null;return e="undefined"==typeof t.fn.modal.Constructor.VERSION?"v3.1":/3\.2\.\d+/.test(t.fn.modal.Constructor.VERSION)?"v3.2":/3\.3\.[1,2]/.test(t.fn.modal.Constructor.VERSION)?"v3.3":"v3.3.4"},n.ORIGINAL_BODY_PADDING=parseInt(t("body").css("padding-right")||0,10),n.METHODS_TO_OVERRIDE={},n.METHODS_TO_OVERRIDE["v3.1"]={},n.METHODS_TO_OVERRIDE["v3.2"]={hide:function(e){if(e&&e.preventDefault(),e=t.Event("hide.bs.modal"),this.$element.trigger(e),this.isShown&&!e.isDefaultPrevented()){this.isShown=!1;var n=this.getGlobalOpenedDialogs();0===n.length&&this.$body.removeClass("modal-open"),this.resetScrollbar(),this.escape(),t(document).off("focusin.bs.modal"),this.$element.removeClass("in").attr("aria-hidden",!0).off("click.dismiss.bs.modal"),t.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",t.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal()}}},n.METHODS_TO_OVERRIDE["v3.3"]={setScrollbar:function(){var t=n.ORIGINAL_BODY_PADDING;this.bodyIsOverflowing&&this.$body.css("padding-right",t+this.scrollbarWidth)},resetScrollbar:function(){var t=this.getGlobalOpenedDialogs();0===t.length&&this.$body.css("padding-right",n.ORIGINAL_BODY_PADDING)},hideModal:function(){this.$element.hide(),this.backdrop(t.proxy(function(){var t=this.getGlobalOpenedDialogs();0===t.length&&this.$body.removeClass("modal-open"),this.resetAdjustments(),this.resetScrollbar(),this.$element.trigger("hidden.bs.modal")},this))}},n.METHODS_TO_OVERRIDE["v3.3.4"]=t.extend({},n.METHODS_TO_OVERRIDE["v3.3"]),n.prototype={constructor:n,getGlobalOpenedDialogs:function(){var e=[];return t.each(o.dialogs,function(t,n){n.isRealized()&&n.isOpened()&&e.push(n)}),e}},n.prototype=t.extend(n.prototype,e.prototype,n.METHODS_TO_OVERRIDE[n.getModalVersion()]);var o=function(e){this.defaultOptions=t.extend(!0,{id:o.newGuid(),buttons:[],data:{},onshow:null,onshown:null,onhide:null,onhidden:null},o.defaultOptions),this.indexedButtons={},this.registeredButtonHotkeys={},this.draggableData={isMouseDown:!1,mouseOffset:{}},this.realized=!1,this.opened=!1,this.initOptions(e),this.holdThisInstance()};return o.BootstrapDialogModal=n,o.NAMESPACE="bootstrap-dialog",o.TYPE_DEFAULT="type-default",o.TYPE_INFO="type-info",o.TYPE_PRIMARY="type-primary",o.TYPE_SUCCESS="type-success",o.TYPE_WARNING="type-warning",o.TYPE_DANGER="type-danger",o.DEFAULT_TEXTS={},o.DEFAULT_TEXTS[o.TYPE_DEFAULT]="Information",o.DEFAULT_TEXTS[o.TYPE_INFO]="Information",o.DEFAULT_TEXTS[o.TYPE_PRIMARY]="Information",o.DEFAULT_TEXTS[o.TYPE_SUCCESS]="Success",o.DEFAULT_TEXTS[o.TYPE_WARNING]="Warning",o.DEFAULT_TEXTS[o.TYPE_DANGER]="Danger",o.DEFAULT_TEXTS.OK="OK",o.DEFAULT_TEXTS.CANCEL="Cancel",o.DEFAULT_TEXTS.CONFIRM="Confirmation",o.SIZE_NORMAL="size-normal",o.SIZE_SMALL="size-small",o.SIZE_WIDE="size-wide",o.SIZE_LARGE="size-large",o.BUTTON_SIZES={},o.BUTTON_SIZES[o.SIZE_NORMAL]="",o.BUTTON_SIZES[o.SIZE_SMALL]="",o.BUTTON_SIZES[o.SIZE_WIDE]="",o.BUTTON_SIZES[o.SIZE_LARGE]="btn-lg",o.ICON_SPINNER="glyphicon glyphicon-asterisk",o.defaultOptions={type:o.TYPE_PRIMARY,size:o.SIZE_NORMAL,cssClass:"",title:null,message:null,nl2br:!0,closable:!0,closeByBackdrop:!0,closeByKeyboard:!0,spinicon:o.ICON_SPINNER,autodestroy:!0,draggable:!1,animate:!0,description:"",tabindex:-1},o.configDefaultOptions=function(e){o.defaultOptions=t.extend(!0,o.defaultOptions,e)},o.dialogs={},o.openAll=function(){t.each(o.dialogs,function(t,e){e.open()})},o.closeAll=function(){t.each(o.dialogs,function(t,e){e.close()})},o.getDialog=function(t){var e=null;return"undefined"!=typeof o.dialogs[t]&&(e=o.dialogs[t]),e},o.setDialog=function(t){return o.dialogs[t.getId()]=t,t},o.addDialog=function(t){return o.setDialog(t)},o.moveFocus=function(){var e=null;t.each(o.dialogs,function(t,n){e=n}),null!==e&&e.isRealized()&&e.getModal().focus()},o.METHODS_TO_OVERRIDE={},o.METHODS_TO_OVERRIDE["v3.1"]={handleModalBackdropEvent:function(){return this.getModal().on("click",{dialog:this},function(t){t.target===this&&t.data.dialog.isClosable()&&t.data.dialog.canCloseByBackdrop()&&t.data.dialog.close()}),this},updateZIndex:function(){var e=1040,n=1050,i=0;t.each(o.dialogs,function(t,e){i++});var s=this.getModal(),a=s.data("bs.modal").$backdrop;return s.css("z-index",n+20*(i-1)),a.css("z-index",e+20*(i-1)),this},open:function(){return!this.isRealized()&&this.realize(),this.getModal().modal("show"),this.updateZIndex(),this}},o.METHODS_TO_OVERRIDE["v3.2"]={handleModalBackdropEvent:o.METHODS_TO_OVERRIDE["v3.1"].handleModalBackdropEvent,updateZIndex:o.METHODS_TO_OVERRIDE["v3.1"].updateZIndex,open:o.METHODS_TO_OVERRIDE["v3.1"].open},o.METHODS_TO_OVERRIDE["v3.3"]={},o.METHODS_TO_OVERRIDE["v3.3.4"]=t.extend({},o.METHODS_TO_OVERRIDE["v3.1"]),o.prototype={constructor:o,initOptions:function(e){return this.options=t.extend(!0,this.defaultOptions,e),this},holdThisInstance:function(){return o.addDialog(this),this},initModalStuff:function(){return this.setModal(this.createModal()).setModalDialog(this.createModalDialog()).setModalContent(this.createModalContent()).setModalHeader(this.createModalHeader()).setModalBody(this.createModalBody()).setModalFooter(this.createModalFooter()),this.getModal().append(this.getModalDialog()),this.getModalDialog().append(this.getModalContent()),this.getModalContent().append(this.getModalHeader()).append(this.getModalBody()).append(this.getModalFooter()),this},createModal:function(){var e=t('<div class="modal" role="dialog" aria-hidden="true"></div>');return e.prop("id",this.getId()),e.attr("aria-labelledby",this.getId()+"_title"),e},getModal:function(){return this.$modal},setModal:function(t){return this.$modal=t,this},createModalDialog:function(){return t('<div class="modal-dialog"></div>')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(t){return this.$modalDialog=t,this},createModalContent:function(){return t('<div class="modal-content"></div>')},getModalContent:function(){return this.$modalContent},setModalContent:function(t){return this.$modalContent=t,this},createModalHeader:function(){return t('<div class="modal-header"></div>')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(t){return this.$modalHeader=t,this},createModalBody:function(){return t('<div class="modal-body"></div>')},getModalBody:function(){return this.$modalBody},setModalBody:function(t){return this.$modalBody=t,this},createModalFooter:function(){return t('<div class="modal-footer"></div>')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(t){return this.$modalFooter=t,this},createDynamicContent:function(t){var e=null;return e="function"==typeof t?t.call(t,this):t,"string"==typeof e&&(e=this.formatStringContent(e)),e},formatStringContent:function(t){return this.options.nl2br?t.replace(/\r\n/g,"<br />").replace(/[\r\n]/g,"<br />"):t},setData:function(t,e){return this.options.data[t]=e,this},getData:function(t){return this.options.data[t]},setId:function(t){return this.options.id=t,this},getId:function(){return this.options.id},getType:function(){return this.options.type},setType:function(t){return this.options.type=t,this.updateType(),this},updateType:function(){if(this.isRealized()){var t=[o.TYPE_DEFAULT,o.TYPE_INFO,o.TYPE_PRIMARY,o.TYPE_SUCCESS,o.TYPE_WARNING,o.TYPE_DANGER];this.getModal().removeClass(t.join(" ")).addClass(this.getType())}return this},getSize:function(){return this.options.size},setSize:function(t){return this.options.size=t,this.updateSize(),this},updateSize:function(){if(this.isRealized()){var e=this;this.getModal().removeClass(o.SIZE_NORMAL).removeClass(o.SIZE_SMALL).removeClass(o.SIZE_WIDE).removeClass(o.SIZE_LARGE),this.getModal().addClass(this.getSize()),this.getModalDialog().removeClass("modal-sm"),this.getSize()===o.SIZE_SMALL&&this.getModalDialog().addClass("modal-sm"),this.getModalDialog().removeClass("modal-lg"),this.getSize()===o.SIZE_WIDE&&this.getModalDialog().addClass("modal-lg"),t.each(this.options.buttons,function(n,o){var i=e.getButton(o.id),s=["btn-lg","btn-sm","btn-xs"],a=!1;if("string"==typeof o.cssClass){var d=o.cssClass.split(" ");t.each(d,function(e,n){-1!==t.inArray(n,s)&&(a=!0)})}a||(i.removeClass(s.join(" ")),i.addClass(e.getButtonSize()))})}return this},getCssClass:function(){return this.options.cssClass},setCssClass:function(t){return this.options.cssClass=t,this},getTitle:function(){return this.options.title},setTitle:function(t){return this.options.title=t,this.updateTitle(),this},updateTitle:function(){if(this.isRealized()){var t=null!==this.getTitle()?this.createDynamicContent(this.getTitle()):this.getDefaultText();this.getModalHeader().find("."+this.getNamespace("title")).html("").append(t).prop("id",this.getId()+"_title")}return this},getMessage:function(){return this.options.message},setMessage:function(t){return this.options.message=t,this.updateMessage(),this},updateMessage:function(){if(this.isRealized()){var t=this.createDynamicContent(this.getMessage());this.getModalBody().find("."+this.getNamespace("message")).html("").append(t)}return this},isClosable:function(){return this.options.closable},setClosable:function(t){return this.options.closable=t,this.updateClosable(),this},setCloseByBackdrop:function(t){return this.options.closeByBackdrop=t,this},canCloseByBackdrop:function(){return this.options.closeByBackdrop},setCloseByKeyboard:function(t){return this.options.closeByKeyboard=t,this},canCloseByKeyboard:function(){return this.options.closeByKeyboard},isAnimate:function(){return this.options.animate},setAnimate:function(t){return this.options.animate=t,this},updateAnimate:function(){return this.isRealized()&&this.getModal().toggleClass("fade",this.isAnimate()),this},getSpinicon:function(){return this.options.spinicon},setSpinicon:function(t){return this.options.spinicon=t,this},addButton:function(t){return this.options.buttons.push(t),this},addButtons:function(e){var n=this;return t.each(e,function(t,e){n.addButton(e)}),this},getButtons:function(){return this.options.buttons},setButtons:function(t){return this.options.buttons=t,this.updateButtons(),this},getButton:function(t){return"undefined"!=typeof this.indexedButtons[t]?this.indexedButtons[t]:null},getButtonSize:function(){return"undefined"!=typeof o.BUTTON_SIZES[this.getSize()]?o.BUTTON_SIZES[this.getSize()]:""},updateButtons:function(){return this.isRealized()&&(0===this.getButtons().length?this.getModalFooter().hide():this.getModalFooter().show().find("."+this.getNamespace("footer")).html("").append(this.createFooterButtons())),this},isAutodestroy:function(){return this.options.autodestroy},setAutodestroy:function(t){this.options.autodestroy=t},getDescription:function(){return this.options.description},setDescription:function(t){return this.options.description=t,this},setTabindex:function(t){return this.options.tabindex=t,this},getTabindex:function(){return this.options.tabindex},updateTabindex:function(){return this.isRealized()&&this.getModal().attr("tabindex",this.getTabindex()),this},getDefaultText:function(){return o.DEFAULT_TEXTS[this.getType()]},getNamespace:function(t){return o.NAMESPACE+"-"+t},createHeaderContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("header")),e.append(this.createTitleContent()),e.prepend(this.createCloseButton()),e},createTitleContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("title")),e},createCloseButton:function(){var e=t("<div></div>");e.addClass(this.getNamespace("close-button"));var n=t('<button class="close">&times;</button>');return e.append(n),e.on("click",{dialog:this},function(t){t.data.dialog.close()}),e},createBodyContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("body")),e.append(this.createMessageContent()),e},createMessageContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("message")),e},createFooterContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("footer")),e},createFooterButtons:function(){var e=this,n=t("<div></div>");return n.addClass(this.getNamespace("footer-buttons")),this.indexedButtons={},t.each(this.options.buttons,function(t,i){i.id||(i.id=o.newGuid());var s=e.createButton(i);e.indexedButtons[i.id]=s,n.append(s)}),n},createButton:function(e){var n=t('<button class="btn"></button>');return n.prop("id",e.id),n.data("button",e),"undefined"!=typeof e.icon&&""!==t.trim(e.icon)&&n.append(this.createButtonIcon(e.icon)),"undefined"!=typeof e.label&&n.append(e.label),n.addClass("undefined"!=typeof e.cssClass&&""!==t.trim(e.cssClass)?e.cssClass:"btn-default"),"undefined"!=typeof e.hotkey&&(this.registeredButtonHotkeys[e.hotkey]=n),n.on("click",{dialog:this,$button:n,button:e},function(t){var e=t.data.dialog,n=t.data.$button,o=n.data("button");"function"==typeof o.action&&o.action.call(n,e,t),o.autospin&&n.toggleSpin(!0)}),this.enhanceButton(n),"undefined"!=typeof e.enabled&&n.toggleEnable(e.enabled),n},enhanceButton:function(t){return t.dialog=this,t.toggleEnable=function(t){var e=this;return"undefined"!=typeof t?e.prop("disabled",!t).toggleClass("disabled",!t):e.prop("disabled",!e.prop("disabled")),e},t.enable=function(){var t=this;return t.toggleEnable(!0),t},t.disable=function(){var t=this;return t.toggleEnable(!1),t},t.toggleSpin=function(e){var n=this,o=n.dialog,i=n.find("."+o.getNamespace("button-icon"));return"undefined"==typeof e&&(e=!(t.find(".icon-spin").length>0)),e?(i.hide(),t.prepend(o.createButtonIcon(o.getSpinicon()).addClass("icon-spin"))):(i.show(),t.find(".icon-spin").remove()),n},t.spin=function(){var t=this;return t.toggleSpin(!0),t},t.stopSpin=function(){var t=this;return t.toggleSpin(!1),t},this},createButtonIcon:function(e){var n=t("<span></span>");return n.addClass(this.getNamespace("button-icon")).addClass(e),n},enableButtons:function(e){return t.each(this.indexedButtons,function(t,n){n.toggleEnable(e)}),this},updateClosable:function(){return this.isRealized()&&this.getModalHeader().find("."+this.getNamespace("close-button")).toggle(this.isClosable()),this},onShow:function(t){return this.options.onshow=t,this},onShown:function(t){return this.options.onshown=t,this},onHide:function(t){return this.options.onhide=t,this},onHidden:function(t){return this.options.onhidden=t,this},isRealized:function(){return this.realized},setRealized:function(t){return this.realized=t,this},isOpened:function(){return this.opened},setOpened:function(t){return this.opened=t,this},handleModalEvents:function(){return this.getModal().on("show.bs.modal",{dialog:this},function(t){var e=t.data.dialog;if(e.setOpened(!0),e.isModalEvent(t)&&"function"==typeof e.options.onshow){var n=e.options.onshow(e);return n===!1&&e.setOpened(!1),n}}),this.getModal().on("shown.bs.modal",{dialog:this},function(t){var e=t.data.dialog;e.isModalEvent(t)&&"function"==typeof e.options.onshown&&e.options.onshown(e)}),this.getModal().on("hide.bs.modal",{dialog:this},function(t){var e=t.data.dialog;if(e.setOpened(!1),e.isModalEvent(t)&&"function"==typeof e.options.onhide){var n=e.options.onhide(e);return n===!1&&e.setOpened(!0),n}}),this.getModal().on("hidden.bs.modal",{dialog:this},function(e){var n=e.data.dialog;n.isModalEvent(e)&&"function"==typeof n.options.onhidden&&n.options.onhidden(n),n.isAutodestroy()&&(n.setRealized(!1),delete o.dialogs[n.getId()],t(this).remove()),o.moveFocus()}),this.handleModalBackdropEvent(),this.getModal().on("keyup",{dialog:this},function(t){27===t.which&&t.data.dialog.isClosable()&&t.data.dialog.canCloseByKeyboard()&&t.data.dialog.close()}),this.getModal().on("keyup",{dialog:this},function(e){var n=e.data.dialog;if("undefined"!=typeof n.registeredButtonHotkeys[e.which]){var o=t(n.registeredButtonHotkeys[e.which]);!o.prop("disabled")&&o.focus().trigger("click")}}),this},handleModalBackdropEvent:function(){return this.getModal().on("click",{dialog:this},function(e){t(e.target).hasClass("modal-backdrop")&&e.data.dialog.isClosable()&&e.data.dialog.canCloseByBackdrop()&&e.data.dialog.close()}),this},isModalEvent:function(t){return"undefined"!=typeof t.namespace&&"bs.modal"===t.namespace},makeModalDraggable:function(){return this.options.draggable&&(this.getModalHeader().addClass(this.getNamespace("draggable")).on("mousedown",{dialog:this},function(t){var e=t.data.dialog;e.draggableData.isMouseDown=!0;var n=e.getModalDialog().offset();e.draggableData.mouseOffset={top:t.clientY-n.top,left:t.clientX-n.left}}),this.getModal().on("mouseup mouseleave",{dialog:this},function(t){t.data.dialog.draggableData.isMouseDown=!1}),t("body").on("mousemove",{dialog:this},function(t){var e=t.data.dialog;e.draggableData.isMouseDown&&e.getModalDialog().offset({top:t.clientY-e.draggableData.mouseOffset.top,left:t.clientX-e.draggableData.mouseOffset.left})})),this},realize:function(){return this.initModalStuff(),this.getModal().addClass(o.NAMESPACE).addClass(this.getCssClass()),this.updateSize(),this.getDescription()&&this.getModal().attr("aria-describedby",this.getDescription()),this.getModalFooter().append(this.createFooterContent()),this.getModalHeader().append(this.createHeaderContent()),this.getModalBody().append(this.createBodyContent()),this.getModal().data("bs.modal",new n(this.getModal(),{backdrop:"static",keyboard:!1,show:!1})),this.makeModalDraggable(),this.handleModalEvents(),this.setRealized(!0),this.updateButtons(),this.updateType(),this.updateTitle(),this.updateMessage(),this.updateClosable(),this.updateAnimate(),this.updateSize(),this.updateTabindex(),this},open:function(){return!this.isRealized()&&this.realize(),this.getModal().modal("show"),this},close:function(){return!this.isRealized()&&this.realize(),this.getModal().modal("hide"),this}},o.prototype=t.extend(o.prototype,o.METHODS_TO_OVERRIDE[n.getModalVersion()]),o.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})},o.show=function(t){return new o(t).open()},o.alert=function(){var e={},n={type:o.TYPE_PRIMARY,title:null,message:null,closable:!1,draggable:!1,buttonLabel:o.DEFAULT_TEXTS.OK,callback:null};return e="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?t.extend(!0,n,arguments[0]):t.extend(!0,n,{message:arguments[0],callback:"undefined"!=typeof arguments[1]?arguments[1]:null}),new o({type:e.type,title:e.title,message:e.message,closable:e.closable,draggable:e.draggable,data:{callback:e.callback},onhide:function(t){!t.getData("btnClicked")&&t.isClosable()&&"function"==typeof t.getData("callback")&&t.getData("callback")(!1)},buttons:[{label:e.buttonLabel,action:function(t){t.setData("btnClicked",!0),"function"==typeof t.getData("callback")&&t.getData("callback")(!0),t.close()}}]}).open()},o.confirm=function(){var e={},n={type:o.TYPE_PRIMARY,title:null,message:null,closable:!1,draggable:!1,btnCancelLabel:o.DEFAULT_TEXTS.CANCEL,btnOKLabel:o.DEFAULT_TEXTS.OK,btnOKClass:null,callback:null};return e="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?t.extend(!0,n,arguments[0]):t.extend(!0,n,{message:arguments[0],closable:!1,buttonLabel:o.DEFAULT_TEXTS.OK,callback:"undefined"!=typeof arguments[1]?arguments[1]:null}),null===e.btnOKClass&&(e.btnOKClass=["btn",e.type.split("-")[1]].join("-")),new o({type:e.type,title:e.title,message:e.message,closable:e.closable,draggable:e.draggable,data:{callback:e.callback},buttons:[{label:e.btnCancelLabel,action:function(t){"function"==typeof t.getData("callback")&&t.getData("callback")(!1),t.close()}},{label:e.btnOKLabel,cssClass:e.btnOKClass,action:function(t){"function"==typeof t.getData("callback")&&t.getData("callback")(!0),t.close()}}]}).open()},o.warning=function(t,e){return new o({type:o.TYPE_WARNING,message:t}).open()},o.danger=function(t,e){return new o({type:o.TYPE_DANGER,message:t}).open()},o.success=function(t,e){return new o({type:o.TYPE_SUCCESS,message:t}).open()},o});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment