diff --git a/example/includes/url-public.php b/example/includes/url-public.php index de3f530..023a1fa 100644 --- a/example/includes/url-public.php +++ b/example/includes/url-public.php @@ -102,8 +102,11 @@ function handle_search($request) { Tpl :: assign('nbs_by_page', $nbs_by_page); Tpl :: assign('status_list', $status_list); + Tpl :: add_css_file( + 'lib/bootstrap5-dialog/css/bootstrap-dialog.min.css', + ); Tpl :: add_js_file( - 'lib/bootstrap4dialog/bootstrap4dialog.min.js', + 'lib/bootstrap5-dialog/js/bootstrap-dialog.min.js', 'js/myconfirm.js', 'js/search.js' ); @@ -125,8 +128,11 @@ function handle_show($request) { Tpl :: assign('item', $item); // Dialog + Tpl :: add_css_file( + 'lib/bootstrap5-dialog/css/bootstrap-dialog.min.css', + ); Tpl :: add_js_file( - 'lib/bootstrap4dialog/bootstrap4dialog.min.js', + 'lib/bootstrap5-dialog/js/bootstrap-dialog.min.js', 'js/myconfirm.js', ); diff --git a/static/js/myconfirm.js b/static/js/myconfirm.js index 66b8940..5445c2c 100644 --- a/static/js/myconfirm.js +++ b/static/js/myconfirm.js @@ -1,36 +1,43 @@ var myconfirm = function(opts) { var confirm = false; - var dialog = Bootstrap4Dialog.show({ + var dialog = BootstrapDialog.show({ title: opts.title || _('Confirmation'), message: opts.question || _('Do you confirm?'), autodestroy: true, - type: opts.type || Bootstrap4Dialog.TYPE_LIGHT, - scrollable: opts.scrollable || false, + cssClass: opts.css_class || null, + type: opts.type || BootstrapDialog.TYPE_LIGHT, + draggable: opts.draggable || false, + data: { + oncancel: opts.oncancel, + onconfirm: opts.onconfirm, + data: opts.data, + confirm: false, + }, buttons: [ { label: opts.cancel_label || _('Cancel'), action: function(dialog) { - dialog.modal('hide'); + dialog.close(); } }, { label: opts.confirm_label || _('Validate'), cssClass: 'btn-danger', action: function(dialog) { - confirm = true; - dialog.modal('hide'); + dialog.setData('confirm',true); + dialog.close(); } } ], - close: function() { - if (confirm) { - if (jQuery.type(opts.onconfirm) == 'function') { - opts.onconfirm(opts.data); + onhidden: function(dialog) { + if (dialog.getData('confirm')) { + if (jQuery.type(dialog.getData('onconfirm')) == 'function') { + dialog.getData('onconfirm')(dialog.getData('data')); } } else { - if (jQuery.type(opts.oncancel) == 'function') { - opts.oncancel(opts.data); + if (jQuery.type(dialog.getData('oncancel')) == 'function') { + dialog.getData('oncancel')(dialog.getData('data')); } } } @@ -40,25 +47,30 @@ var myconfirm = function(opts) { var myalert = function(msg, title, opts) { if (!opts) opts={}; - var dialog = Bootstrap4Dialog.show({ + var dialog = BootstrapDialog.show({ title: title || opts.title || _('Error'), message: msg, autodestroy: true, - type: opts.type || Bootstrap4Dialog.TYPE_DANGER, - size: opts.size || Bootstrap4Dialog.SIZE_MEDIUM, - scrollable: opts.scrollable || false, + type: opts.type || BootstrapDialog.TYPE_DANGER, + size: opts.size || BootstrapDialog.SIZE_MEDIUM, + draggable: opts.draggable || false, + cssClass: opts.css_class || null, + data: { + onclose: opts.onclose, + data: opts.data, + }, buttons: [ { label: opts.btnLabel || _('OK'), cssClass: opts.btnCssClass ||'btn-primary', action: function(dialog) { - dialog.modal('hide'); + dialog.close(); } }, ], - close: function() { - if ($.type(opts.onclose) == 'function') { - opts.onclose(opts.data); + onhidden: function(dialog) { + if (jQuery.type(dialog.getData('onclose')) == 'function') { + dialog.getData('onclose')(dialog.getData('data')); } } }); @@ -74,25 +86,27 @@ var myprompt = function(opts) { var onSubmitBtnClick = function(dialog) { submited = true; var val = dialog.getModalBody().find('input').val(); - if (jQuery.type(opts.onsubmit) == 'function') { - if (!opts.onsubmit(val, opts.data)) { - if (jQuery.type(opts.onerror) == 'function') { - opts.onerror(val, opts.data); + if (jQuery.type(dialog.getData('onsubmit')) == 'function') { + if (!dialog.getData('onsubmit')(val, dialog.getData('data'))) { + if (jQuery.type(dialog.getData('onerror')) == 'function') { + dialog.getData('onerror')(val, dialog.getData('data')); } - if (!opts.closeonerror) { + if (!dialog.getData('closeonerror')) { return false; } } } - dialog.modal('hide'); + dialog.close(); }; - var dialog = Bootstrap4Dialog.show({ + var dialog = BootstrapDialog.show({ title: opts.title || _('Question'), message: "", autodestroy: true, - type: opts.type || Bootstrap4Dialog.TYPE_INFO, - size: opts.size || Bootstrap4Dialog.SIZE_MEDIUM, + type: opts.type || BootstrapDialog.TYPE_INFO, + size: opts.size || BootstrapDialog.SIZE_MEDIUM, + cssClass: opts.css_class || null, + draggable: opts.draggable || false, data: { oncancel: opts.oncancel, onsubmit: opts.onsubmit, @@ -107,7 +121,7 @@ var myprompt = function(opts) { { label: opts.cancel_label || _('Cancel'), action: function(dialog) { - dialog.modal('hide'); + dialog.close(); } }, { @@ -116,20 +130,20 @@ var myprompt = function(opts) { action: onSubmitBtnClick } ], - open: function() { + onshown: function(dialog) { var input = dialog.getModalBody().find('input'); input.on('keyup', function (e) { if (e.keyCode == 13) { - opts.onSubmitBtnClick(dialog); + dialog.getData('onSubmitBtnClick')(dialog); } }); - if (opts.default_answer) { - input.val(opts.default_answer); + if (dialog.getData('default_answer')) { + input.val(dialog.getData('default_answer')); } }, - close: function() { - if (!submited && jQuery.type(opts.oncancel) == 'function') { - opts.oncancel(opts.data); + onhidden: function(dialog) { + if (!submited && jQuery.type(dialog.getData('oncancel')) == 'function') { + dialog.getData('oncancel')(dialog.getData('data')); } } }); @@ -139,17 +153,19 @@ var myloadingalert = function(opts) { if (!opts) opts={}; var opened = false; var closed = false; - var dialog = Bootstrap4Dialog.show({ + var dialog = BootstrapDialog.show({ title: opts.title || _('Please wait'), message: opts.message || _('Please wait while your request is being processed.'), autodestroy: true, - type: opts.type || Bootstrap4Dialog.TYPE_INFO, - size: opts.size || Bootstrap4Dialog.SIZE_NORMAL, + type: opts.type || BootstrapDialog.TYPE_INFO, + size: opts.size || BootstrapDialog.SIZE_NORMAL, + cssClass: opts.css_class || null, centered: opts.centered || true, closable: opts.closable || false, - open: function () { + draggable: opts.draggable || false, + onshown: function (dialog) { if (closed) - dialog.modal('hide'); + dialog.close(); opened = true; } }); @@ -157,7 +173,7 @@ var myloadingalert = function(opts) { 'modal': dialog, 'close': function() { if (opened) - dialog.modal('hide'); + dialog.close(); closed = true; } }; diff --git a/static/lib/bootstrap4dialog/bootstrap4dialog.js b/static/lib/bootstrap4dialog/bootstrap4dialog.js deleted file mode 100644 index b53f653..0000000 --- a/static/lib/bootstrap4dialog/bootstrap4dialog.js +++ /dev/null @@ -1,320 +0,0 @@ -/** - * Bootstrap Modal for Bootstrap 4.* - * - * @author GR , https://github.com/SUXUMI - * @source https://github.com/SUXUMI/bootstrab4dialog - * @description Bootstrap Modal for Bootstrap 4.* - * @license MIT - */ - -(function (root, factory) { - "use strict"; - - // https://github.com/umdjs/umd - if (typeof module !== "undefined" && module.exports) { - module.exports = factory(require("jquery"), require("bootstrap")); - } - else if (typeof define === "function" && define.amd) { - define("bootstrap4dialog", ["jquery", "bootstrap"], function ($) { - return factory($); - }); - } else { - root.Bootstrap4Dialog = factory(root.jQuery); - } -})(this ? this : window, function ($) { - /** - * Set default global options - * - * @param {} options - */ - var Bootstrap4Dialog = function (options) { - $.extend(true, this.defaultOptions, options); - }; - - /** - * Constants - */ - Bootstrap4Dialog.TYPE_PRIMARY = "primary"; - Bootstrap4Dialog.TYPE_SECONDARY = "secondary"; - Bootstrap4Dialog.TYPE_SUCCESS = "success"; - Bootstrap4Dialog.TYPE_DANGER = "danger"; - Bootstrap4Dialog.TYPE_WARNING = "warning"; - Bootstrap4Dialog.TYPE_INFO = "info"; - Bootstrap4Dialog.TYPE_LIGHT = "light"; - Bootstrap4Dialog.TYPE_DARK = "dark"; - - Bootstrap4Dialog.SIZE_SMALL = "modal-sm"; - Bootstrap4Dialog.SIZE_MEDIUM = ""; - Bootstrap4Dialog.SIZE_LARGE = "modal-lg"; - Bootstrap4Dialog.SIZE_EXTRA_LARGE = "modal-xl"; - - Bootstrap4Dialog.BACKDROP_YES = "true"; - Bootstrap4Dialog.BACKDROP_NO = ""; - Bootstrap4Dialog.BACKDROP_STATIC = "static"; - - /** - * Default options - */ - Bootstrap4Dialog.defaultOptions = { - title: '', - message: '', - type: Bootstrap4Dialog.TYPE_PRIMARY, - size: Bootstrap4Dialog.SIZE_MEDIUM, - keyboard: true, - focus: true, - scrollable: false, // modal-dialog-scrollable - centered: false, // modal-dialog-centered - backdrop: Bootstrap4Dialog.BACKDROP_YES, - duration: 0, // SECONDS - how long the dialog should be displayed - autodestroy: true, - - open: null, - close: null, - buttons: [], - - // draggable: false, - // animate: true, - // tabindex: -1, - }; - - /** - * Prepares the dialog - * - * @param {type} options - * @returns the created dialog instance - */ - Bootstrap4Dialog.dialog = function(options) { - var dialog; - - var _options = $.extend(false, this.defaultOptions, options); - - _options['show'] = false; - - try { - if (!_options['title'] && !_options['message'] && (!_options['buttons'] || !_options['buttons'].length)) { - return false; - } - - var id = _options['id'] || 'modalWindow_' + uniqid(); - - var html = - '' - ; - - $('body').append( html ); - - var _modal_container = $('#' + id); - - // append title - if (_options['title'] && _options['title'].length) { - _modal_container.find('.modal-title').html( _options['title'] ); - } - - // append message - if (_options['message'] && _options['message'].length) { - _modal_container.find('.modal-body').html( _options['message'] ); - } - - if (_options['title'] && !_options['message'] && (!_options['buttons'] || !_options['buttons'].length)) { - _modal_container.find('.modal-header').css({'border-bottom':'0px'}); - } - - if (!_options['title'] && !_options['message'] && _options['buttons'] && _options['buttons'].length) { - _modal_container.find('.modal-footer').css({'border-top':'0px'}); - } - - if (_options['size'] && _options['size'].length) { - _modal_container.find('.modal-dialog').addClass(_options.size); - } - - if (_options['centered']) { - _modal_container.find('.modal-dialog').addClass('modal-dialog-centered'); - } - - if (_options['scrollable']) { - _modal_container.find('.modal-dialog').addClass('modal-dialog-scrollable'); - } - - switch(true) { - case _options['type'] == 'primary': - _modal_container.find('.modal-header').addClass('bg-primary').find('.modal-title').addClass('text-white'); - _modal_container.find('.modal-body').addClass('text-primary'); - break; - case _options['type'] == 'secondary': - _modal_container.find('.modal-header').addClass('bg-secondary').find('.modal-title').addClass('text-white'); - _modal_container.find('.modal-body').addClass('text-secondary'); - break; - case _options['type'] == 'success': - _modal_container.find('.modal-header').addClass('bg-success').find('.modal-title').addClass('text-white'); - _modal_container.find('.modal-body').addClass('text-success'); - break; - case _options['type'] == 'danger': - _modal_container.find('.modal-header').addClass('bg-danger').find('.modal-title').addClass('text-white'); - _modal_container.find('.modal-body').addClass('text-danger'); - break; - case _options['type'] == 'warning': - _modal_container.find('.modal-header').addClass('bg-warning'); - _modal_container.find('.modal-body').addClass('text-warning'); - break; - case _options['type'] == 'info': - _modal_container.find('.modal-header').addClass('bg-info').find('.modal-title').addClass('text-white'); - _modal_container.find('.modal-body').addClass('text-info'); - break; - case _options['type'] == 'light': - _modal_container.find('.modal-header').addClass('bg-light').find('.modal-title').addClass('text-black'); - _modal_container.find('.modal-body').addClass('text-black'); - break; - case _options['type'] == 'dark': - _modal_container.find('.modal-header').addClass('bg-dark').find('.modal-title').addClass('text-white'); - _modal_container.find('.modal-body').addClass('text-dark'); - break; - } - - dialog = _modal_container.modal(_options); - - // try set buttons - try { - // fooder - var _footer = _modal_container.find('.modal-footer'); - - for(i in _options['buttons']) { - var _button = _options['buttons'][i]; - - // append the button - _footer.append(''),s.message&&(n+=''),s.buttons&&s.buttons.length&&(n+=''),a("body").append(n);var r=a("#"+l);switch(s.title&&s.title.length&&r.find(".modal-title").html(s.title),s.message&&s.message.length&&r.find(".modal-body").html(s.message),!s.title||s.message||s.buttons&&s.buttons.length||r.find(".modal-header").css({"border-bottom":"0px"}),!s.title&&!s.message&&s.buttons&&s.buttons.length&&r.find(".modal-footer").css({"border-top":"0px"}),s.size&&s.size.length&&r.find(".modal-dialog").addClass(s.size),s.centered&&r.find(".modal-dialog").addClass("modal-dialog-centered"),s.scrollable&&r.find(".modal-dialog").addClass("modal-dialog-scrollable"),!0){case"primary"==s.type:r.find(".modal-header").addClass("bg-primary").find(".modal-title").addClass("text-white"),r.find(".modal-body").addClass("text-primary");break;case"secondary"==s.type:r.find(".modal-header").addClass("bg-secondary").find(".modal-title").addClass("text-white"),r.find(".modal-body").addClass("text-secondary");break;case"success"==s.type:r.find(".modal-header").addClass("bg-success").find(".modal-title").addClass("text-white"),r.find(".modal-body").addClass("text-success");break;case"danger"==s.type:r.find(".modal-header").addClass("bg-danger").find(".modal-title").addClass("text-white"),r.find(".modal-body").addClass("text-danger");break;case"warning"==s.type:r.find(".modal-header").addClass("bg-warning"),r.find(".modal-body").addClass("text-warning");break;case"info"==s.type:r.find(".modal-header").addClass("bg-info").find(".modal-title").addClass("text-white"),r.find(".modal-body").addClass("text-info");break;case"light"==s.type:r.find(".modal-header").addClass("bg-light").find(".modal-title").addClass("text-black"),r.find(".modal-body").addClass("text-black");break;case"dark"==s.type:r.find(".modal-header").addClass("bg-dark").find(".modal-title").addClass("text-white"),r.find(".modal-body").addClass("text-dark")}o=r.modal(s);try{var c=r.find(".modal-footer");for(i in s.buttons){var m=s.buttons[i];c.append(''); + $btn.addClass(this.getNamespace('close-button')); + $btn.on('click', {dialog: this}, function (event) { + event.data.dialog.close(); + }); + + return $btn; + }, + createBodyContent: function () { + var $container = $('
'); + $container.addClass(this.getNamespace('body')); + + // Message + $container.append(this.createMessageContent()); + + return $container; + }, + createMessageContent: function () { + var $message = $('
'); + $message.addClass(this.getNamespace('message')); + + return $message; + }, + createFooterContent: function () { + var $container = $('
'); + $container.addClass(this.getNamespace('footer')); + + return $container; + }, + createFooterButtons: function () { + var that = this; + var $container = $('
'); + $container.addClass(this.getNamespace('footer-buttons')); + this.indexedButtons = {}; + $.each(this.options.buttons, function (index, button) { + if (!button.id) { + button.id = BootstrapDialog.newGuid(); + } + var $button = that.createButton(button); + that.indexedButtons[button.id] = $button; + $container.append($button); + }); + + return $container; + }, + createButton: function (button) { + var $button = $(''); + $button.prop('id', button.id); + $button.data('button', button); + + // Icon + if (typeof button.icon !== 'undefined' && $.trim(button.icon) !== '') { + $button.append(this.createButtonIcon(button.icon)); + } + + // Label + if (typeof button.label !== 'undefined') { + $button.append(button.label); + } + + // title + if (typeof button.title !== 'undefined') { + $button.attr('title', button.title); + } + + // Css class + if (typeof button.cssClass !== 'undefined' && $.trim(button.cssClass) !== '') { + $button.addClass(button.cssClass); + } else { + $button.addClass('btn-light'); + } + + // Data attributes + if (typeof button.data === 'object' && button.data.constructor === {}.constructor) { + $.each(button.data, function (key, value) { + $button.attr('data-' + key, value); + }); + } + + // Hotkey + if (typeof button.hotkey !== 'undefined') { + this.registeredButtonHotkeys[button.hotkey] = $button; + } + + // Button on click + $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'); + if (button.autospin) { + $button.toggleSpin(true); + } + if (typeof button.action === 'function') { + return button.action.call($button, dialog, event); + } + }); + + // Dynamically add extra functions to $button + this.enhanceButton($button); + + //Initialize enabled or not + if (typeof button.enabled !== 'undefined') { + $button.toggleEnable(button.enabled); + } + + return $button; + }, + /** + * Dynamically add extra functions to $button + * + * Using '$this' to reference 'this' is just for better readability. + * + * @param {type} $button + * @returns {_L13.BootstrapDialog.prototype} + */ + enhanceButton: function ($button) { + $button.dialog = this; + + // Enable / Disable + $button.toggleEnable = function (enable) { + var $this = this; + if (typeof enable !== 'undefined') { + $this.prop('disabled', !enable).toggleClass('disabled', !enable); + } else { + $this.prop('disabled', !$this.prop('disabled')); + } + + return $this; + }; + $button.enable = function () { + var $this = this; + $this.toggleEnable(true); + + return $this; + }; + $button.disable = function () { + var $this = this; + $this.toggleEnable(false); + + return $this; + }; + + // Icon spinning, helpful for indicating ajax loading status. + $button.toggleSpin = function (spin) { + var $this = this; + var dialog = $this.dialog; + var $icon = $this.find('.' + dialog.getNamespace('button-icon')); + if (typeof spin === 'undefined') { + spin = !($button.find('.icon-spin').length > 0); + } + if (spin) { + $icon.hide(); + $button.prepend(dialog.createButtonIcon(dialog.getSpinicon()).addClass('icon-spin')); + } else { + $icon.show(); + $button.find('.icon-spin').remove(); + } + + return $this; + }; + $button.spin = function () { + var $this = this; + $this.toggleSpin(true); + + return $this; + }; + $button.stopSpin = function () { + var $this = this; + $this.toggleSpin(false); + + return $this; + }; + + return this; + }, + createButtonIcon: function (icon) { + var $icon = $(''); + $icon.addClass(this.getNamespace('button-icon')).addClass(icon); + + return $icon; + }, + /** + * Invoke this only after the dialog is realized. + * + * @param {type} enable + * @returns {undefined} + */ + enableButtons: function (enable) { + $.each(this.indexedButtons, function (id, $button) { + $button.toggleEnable(enable); + }); + + return this; + }, + /** + * Invoke this only after the dialog is realized. + * + * @returns {undefined} + */ + updateClosable: function () { + if (this.isRealized()) { + // Close button + this.getModalHeader().find('.' + this.getNamespace('close-button')).toggle(this.isClosable()); + } + + return this; + }, + /** + * Set handler for modal event 'show.bs.modal'. + * This is a setter! + */ + onShow: function (onshow) { + this.options.onshow = onshow; + + return this; + }, + /** + * Set handler for modal event 'shown.bs.modal'. + * This is a setter! + */ + onShown: function (onshown) { + this.options.onshown = onshown; + + return this; + }, + /** + * Set handler for modal event 'hide.bs.modal'. + * This is a setter! + */ + onHide: function (onhide) { + this.options.onhide = onhide; + + return this; + }, + /** + * Set handler for modal event 'hidden.bs.modal'. + * This is a setter! + */ + onHidden: function (onhidden) { + this.options.onhidden = onhidden; + + return this; + }, + isRealized: function () { + return this.realized; + }, + setRealized: function (realized) { + this.realized = realized; + + return this; + }, + isOpened: function () { + return this.opened; + }, + setOpened: function (opened) { + this.opened = opened; + + return this; + }, + 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') { + var openIt = dialog.options.onshow(dialog); + if (openIt === false) { + dialog.setOpened(false); + } + + return openIt; + } + }); + 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) { + var dialog = event.data.dialog; + dialog.setOpened(false); + if (dialog.isModalEvent(event) && typeof dialog.options.onhide === 'function') { + var hideIt = dialog.options.onhide(dialog); + if (hideIt === false) { + dialog.setOpened(true); + } + + return hideIt; + } + }); + 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(); + } + BootstrapDialog.moveFocus(); + if ($('.modal').hasClass('in')) { + $('body').addClass('modal-open'); + } + }); + + // Backdrop, I did't find a way to change bs3 backdrop option after the dialog is popped up, so here's a new wheel. + this.handleModalBackdropEvent(); + + // ESC key support + 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) { + var dialog = event.data.dialog; + if (typeof dialog.registeredButtonHotkeys[event.which] !== 'undefined') { + var $button = $(dialog.registeredButtonHotkeys[event.which]); + !$button.prop('disabled') && !$button.is(':focus') && $button.focus().trigger('click'); + } + }); + + return this; + }, + 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(); + }); + + return this; + }, + isModalEvent: function (event) { + return typeof event.namespace !== 'undefined' && event.namespace === 'bs.modal'; + }, + makeModalDraggable: function () { + if (this.options.draggable) { + 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(); + dialog.draggableData.mouseOffset = { + top: event.clientY - dialogOffset.top, + left: event.clientX - dialogOffset.left + }; + }); + this.getModal().on('mouseup mouseleave', {dialog: this}, function (event) { + event.data.dialog.draggableData.isMouseDown = false; + }); + $('body').on('mousemove', {dialog: this}, function (event) { + var dialog = event.data.dialog; + if (!dialog.draggableData.isMouseDown) { + return; + } + dialog.getModalDialog().offset({ + top: event.clientY - dialog.draggableData.mouseOffset.top, + left: event.clientX - dialog.draggableData.mouseOffset.left + }); + }); + } + + return this; + }, + realize: function () { + this.initModalStuff(); + this.getModal().addClass(BootstrapDialog.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 BootstrapDialogModal(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(); + this.updateTabindex(); + + return this; + }, + open: function () { + !this.isRealized() && this.realize(); + this.getModal().modal('show'); + + return this; + }, + close: function () { + !this.isRealized() && this.realize(); + this.getModal().modal('hide'); + + return this; + } + }; + + /** + * RFC4122 version 4 compliant unique id creator. + * + * Added by https://github.com/tufanbarisyildirim/ + * + * @returns {String} + */ + 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); + }); + }; + + /* ================================================ + * For lazy people + * ================================================ */ + + /** + * Shortcut function: show + * + * @param {type} options + * @returns the created dialog instance + */ + BootstrapDialog.show = function (options) { + return new BootstrapDialog(options).open(); + }; + + /** + * Alert window + * + * @returns the created dialog instance + */ + BootstrapDialog.alert = function () { + var alertOptions = {}; + var defaultAlertOptions = { + type: BootstrapDialog.TYPE_PRIMARY, + title: null, + message: null, + closable: false, + draggable: false, + buttonLabel: BootstrapDialog.DEFAULT_TEXTS.OK, + buttonHotkey: null, + callback: null + }; + + if (typeof arguments[0] === 'object' && arguments[0].constructor === {}.constructor) { + alertOptions = $.extend(true, defaultAlertOptions, arguments[0]); + } else { + alertOptions = $.extend(true, defaultAlertOptions, { + message: arguments[0], + callback: typeof arguments[1] !== 'undefined' ? arguments[1] : null + }); + } + + var dialog = new BootstrapDialog(alertOptions); + dialog.setData('callback', alertOptions.callback); + dialog.addButton({ + label: alertOptions.buttonLabel, + hotkey: alertOptions.buttonHotkey, + action: function (dialog) { + if (typeof dialog.getData('callback') === 'function' && dialog.getData('callback').call(this, true) === false) { + return false; + } + dialog.setData('btnClicked', true); + + return dialog.close(); + } + }); + if (typeof dialog.options.onhide === 'function') { + dialog.onHide(function (dialog) { + var hideIt = true; + if (!dialog.getData('btnClicked') && dialog.isClosable() && typeof dialog.getData('callback') === 'function') { + hideIt = dialog.getData('callback')(false); + } + if (hideIt === false) { + return false; + } + hideIt = this.onhide(dialog); + + return hideIt; + }.bind({ + onhide: dialog.options.onhide + })); + } else { + dialog.onHide(function (dialog) { + var hideIt = true; + if (!dialog.getData('btnClicked') && dialog.isClosable() && typeof dialog.getData('callback') === 'function') { + hideIt = dialog.getData('callback')(false); + } + + return hideIt; + }); + } + + return dialog.open(); + }; + + /** + * Confirm window + * + * @returns the created dialog instance + */ + BootstrapDialog.confirm = function () { + var confirmOptions = {}; + var defaultConfirmOptions = { + type: BootstrapDialog.TYPE_PRIMARY, + title: null, + message: null, + closable: false, + draggable: false, + btnCancelLabel: BootstrapDialog.DEFAULT_TEXTS.CANCEL, + btnCancelClass: null, + btnCancelHotkey: null, + btnOKLabel: BootstrapDialog.DEFAULT_TEXTS.OK, + btnOKClass: null, + btnOKHotkey: null, + btnsOrder: BootstrapDialog.defaultOptions.btnsOrder, + callback: null + }; + if (typeof arguments[0] === 'object' && arguments[0].constructor === {}.constructor) { + confirmOptions = $.extend(true, defaultConfirmOptions, arguments[0]); + } else { + confirmOptions = $.extend(true, defaultConfirmOptions, { + message: arguments[0], + callback: typeof arguments[1] !== 'undefined' ? arguments[1] : null + }); + } + if (confirmOptions.btnOKClass === null) { + confirmOptions.btnOKClass = ['btn', confirmOptions.type.split('-')[1]].join('-'); + } + + var dialog = new BootstrapDialog(confirmOptions); + dialog.setData('callback', confirmOptions.callback); + + var buttons = [{ + label: confirmOptions.btnCancelLabel, + cssClass: confirmOptions.btnCancelClass, + hotkey: confirmOptions.btnCancelHotkey, + action: function (dialog) { + if (typeof dialog.getData('callback') === 'function' && dialog.getData('callback').call(this, false) === false) { + return false; + } + + return dialog.close(); + } + }, { + label: confirmOptions.btnOKLabel, + cssClass: confirmOptions.btnOKClass, + hotkey: confirmOptions.btnOKHotkey, + action: function (dialog) { + if (typeof dialog.getData('callback') === 'function' && dialog.getData('callback').call(this, true) === false) { + return false; + } + + return dialog.close(); + } + }]; + if (confirmOptions.btnsOrder === BootstrapDialog.BUTTONS_ORDER_OK_CANCEL) { + buttons.reverse(); + } + dialog.addButtons(buttons); + + return dialog.open(); + + }; + + /** + * Warning window + * + * @param {type} message + * @returns the created dialog instance + */ + BootstrapDialog.warning = function (message, callback) { + return new BootstrapDialog({ + type: BootstrapDialog.TYPE_WARNING, + message: message + }).open(); + }; + + /** + * Danger window + * + * @param {type} message + * @returns the created dialog instance + */ + BootstrapDialog.danger = function (message, callback) { + return new BootstrapDialog({ + type: BootstrapDialog.TYPE_DANGER, + message: message + }).open(); + }; + + /** + * Success window + * + * @param {type} message + * @returns the created dialog instance + */ + BootstrapDialog.success = function (message, callback) { + return new BootstrapDialog({ + type: BootstrapDialog.TYPE_SUCCESS, + message: message + }).open(); + }; + + return BootstrapDialog; + +})); diff --git a/static/lib/bootstrap5-dialog/js/bootstrap-dialog.min.js b/static/lib/bootstrap5-dialog/js/bootstrap-dialog.min.js new file mode 100644 index 0000000..478e3b0 --- /dev/null +++ b/static/lib/bootstrap5-dialog/js/bootstrap-dialog.min.js @@ -0,0 +1 @@ +!function(t,e){"use strict";"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery"),require("bootstrap")):"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=function(e,n){new t.fn.modal.Constructor(e,n)};e.getModalVersion=function(){return void 0===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"},e.ORIGINAL_BODY_PADDING=parseInt(t("body").css("padding-right")||0,10),e.prototype={constructor:e,getGlobalOpenedDialogs:function(){var e=[];return t.each(n.dialogs,function(t,n){n.isRealized()&&n.isOpened()&&e.push(n)}),e}};var n=function(e){this.defaultOptions=t.extend(!0,{id:n.newGuid(),buttons:[],data:{},onshow:null,onshown:null,onhide:null,onhidden:null},n.defaultOptions),this.indexedButtons={},this.registeredButtonHotkeys={},this.draggableData={isMouseDown:!1,mouseOffset:{}},this.realized=!1,this.opened=!1,this.initOptions(e),this.holdThisInstance()};return n.BootstrapDialogModal=e,n.NAMESPACE="bootstrap-dialog",n.TYPE_PRIMARY="type-primary",n.TYPE_SECONDARY="type-secondary",n.TYPE_SUCCESS="type-success",n.TYPE_DANGER="type-danger",n.TYPE_WARNING="type-warning",n.TYPE_INFO="type-info",n.TYPE_LIGHT="type-light",n.TYPE_DARK="type-dark",n.DEFAULT_TEXTS={},n.DEFAULT_TEXTS[n.TYPE_PRIMARY]="Information",n.DEFAULT_TEXTS[n.TYPE_SECONDARY]="Information",n.DEFAULT_TEXTS[n.TYPE_SUCCESS]="Success",n.DEFAULT_TEXTS[n.TYPE_DANGER]="Danger",n.DEFAULT_TEXTS[n.TYPE_WARNING]="Warning",n.DEFAULT_TEXTS[n.TYPE_INFO]="Information",n.DEFAULT_TEXTS[n.TYPE_LIGHT]="Information",n.DEFAULT_TEXTS[n.TYPE_DARK]="Information",n.DEFAULT_TEXTS.OK="OK",n.DEFAULT_TEXTS.CANCEL="Cancel",n.DEFAULT_TEXTS.CONFIRM="Confirmation",n.SIZE_SMALL="size-small",n.SIZE_DEFAULT="size-default",n.SIZE_LARGE="size-large",n.SIZE_EXTRA_LARGE="size-extra-large",n.BUTTON_SIZES={},n.BUTTON_SIZES[n.SIZE_SMALL]="btn-sm",n.BUTTON_SIZES[n.SIZE_DEFAULT]="",n.BUTTON_SIZES[n.SIZE_LARGE]="btn-lg",n.BUTTON_SIZES[n.SIZE_EXTRA_LARGE]="btn-lg",n.ICON_SPINNER="spinner-border spinner-border-sm",n.BUTTONS_ORDER_CANCEL_OK="btns-order-cancel-ok",n.BUTTONS_ORDER_OK_CANCEL="btns-order-ok-cancel",n.defaultOptions={type:n.TYPE_PRIMARY,size:n.SIZE_DEFAULT,cssClass:"",title:null,message:null,nl2br:!0,closable:!0,closeByBackdrop:!0,closeByKeyboard:!0,spinicon:n.ICON_SPINNER,autodestroy:!0,draggable:!1,animate:!0,description:"",tabindex:-1,btnsOrder:n.BUTTONS_ORDER_CANCEL_OK},n.configDefaultOptions=function(e){n.defaultOptions=t.extend(!0,n.defaultOptions,e)},n.dialogs={},n.openAll=function(){t.each(n.dialogs,function(t,e){e.open()})},n.closeAll=function(){t.each(n.dialogs,function(t,e){e.close()})},n.getDialog=function(t){var e=null;return void 0!==n.dialogs[t]&&(e=n.dialogs[t]),e},n.setDialog=function(t){return n.dialogs[t.getId()]=t,t},n.addDialog=function(t){return n.setDialog(t)},n.moveFocus=function(){var e=null;t.each(n.dialogs,function(t,n){n.isRealized()&&n.isOpened()&&(e=n)}),null!==e&&e.getModal().focus()},n.prototype={constructor:n,initOptions:function(e){return this.options=t.extend(!0,this.defaultOptions,e),this},holdThisInstance:function(){return n.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('');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('')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(t){return this.$modalDialog=t,this},createModalContent:function(){return t('')},getModalContent:function(){return this.$modalContent},setModalContent:function(t){return this.$modalContent=t,this},createModalHeader:function(){return t('')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(t){return this.$modalHeader=t,this},createModalBody:function(){return t('')},getModalBody:function(){return this.$modalBody},setModalBody:function(t){return this.$modalBody=t,this},createModalFooter:function(){return t('')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(t){return this.$modalFooter=t,this},createDynamicContent:function(t){var e=null;return"string"==typeof(e="function"==typeof t?t.call(t,this):t)&&(e=this.formatStringContent(e)),e},formatStringContent:function(t){return this.options.nl2br?t.replace(/\r\n/g,"
").replace(/[\r\n]/g,"
"):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=[n.TYPE_PRIMARY,n.TYPE_SECONDARY,n.TYPE_SUCCESS,n.TYPE_DANGER,n.TYPE_WARNING,n.TYPE_INFO,n.TYPE_LIGHT,n.TYPE_DARK];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(n.SIZE_SMALL).removeClass(n.SIZE_DEFAULT).removeClass(n.SIZE_LARGE).removeClass(n.SIZE_EXTRA_LARGE),this.getModal().addClass(this.getSize()),this.getModalDialog().removeClass("modal-sm"),this.getSize()===n.SIZE_SMALL&&this.getModalDialog().addClass("modal-sm"),this.getModalDialog().removeClass("modal-lg"),this.getSize()===n.SIZE_LARGE&&this.getModalDialog().addClass("modal-lg"),this.getModalDialog().removeClass("modal-xl"),this.getSize()===n.SIZE_EXTRA_LARGE&&this.getModalDialog().addClass("modal-xl"),t.each(this.options.buttons,function(n,o){var i=e.getButton(o.id),s=["btn-lg","btn-sm"],a=!1;if("string"==typeof o.cssClass){var l=o.cssClass.split(" ");t.each(l,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 void 0!==this.indexedButtons[t]?this.indexedButtons[t]:null},getButtonSize:function(){return void 0!==n.BUTTON_SIZES[this.getSize()]?n.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 n.DEFAULT_TEXTS[this.getType()]},getNamespace:function(t){return n.NAMESPACE+"-"+t},createHeaderContent:function(){return[this.createTitleContent(),this.createCloseButton()]},createTitleContent:function(){var e=t('');return e.addClass(this.getNamespace("title")),e},createCloseButton:function(){var e=t('');return e.addClass(this.getNamespace("close-button")),e.on("click",{dialog:this},function(t){t.data.dialog.close()}),e},createBodyContent:function(){var e=t("
");return e.addClass(this.getNamespace("body")),e.append(this.createMessageContent()),e},createMessageContent:function(){var e=t("
");return e.addClass(this.getNamespace("message")),e},createFooterContent:function(){var e=t("
");return e.addClass(this.getNamespace("footer")),e},createFooterButtons:function(){var e=this,o=t("
");return o.addClass(this.getNamespace("footer-buttons")),this.indexedButtons={},t.each(this.options.buttons,function(t,i){i.id||(i.id=n.newGuid());var s=e.createButton(i);e.indexedButtons[i.id]=s,o.append(s)}),o},createButton:function(e){var n=t('');return n.prop("id",e.id),n.data("button",e),void 0!==e.icon&&""!==t.trim(e.icon)&&n.append(this.createButtonIcon(e.icon)),void 0!==e.label&&n.append(e.label),void 0!==e.title&&n.attr("title",e.title),void 0!==e.cssClass&&""!==t.trim(e.cssClass)?n.addClass(e.cssClass):n.addClass("btn-light"),"object"==typeof e.data&&e.data.constructor==={}.constructor&&t.each(e.data,function(t,e){n.attr("data-"+t,e)}),void 0!==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");if(o.autospin&&n.toggleSpin(!0),"function"==typeof o.action)return o.action.call(n,e,t)}),this.enhanceButton(n),void 0!==e.enabled&&n.toggleEnable(e.enabled),n},enhanceButton:function(t){return t.dialog=this,t.toggleEnable=function(t){return void 0!==t?this.prop("disabled",!t).toggleClass("disabled",!t):this.prop("disabled",!this.prop("disabled")),this},t.enable=function(){return this.toggleEnable(!0),this},t.disable=function(){return this.toggleEnable(!1),this},t.toggleSpin=function(e){var n=this.dialog,o=this.find("."+n.getNamespace("button-icon"));return void 0===e&&(e=!(t.find(".icon-spin").length>0)),e?(o.hide(),t.prepend(n.createButtonIcon(n.getSpinicon()).addClass("icon-spin"))):(o.show(),t.find(".icon-spin").remove()),this},t.spin=function(){return this.toggleSpin(!0),this},t.stopSpin=function(){return this.toggleSpin(!1),this},this},createButtonIcon:function(e){var n=t("");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!1===n&&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!1===n&&e.setOpened(!0),n}}),this.getModal().on("hidden.bs.modal",{dialog:this},function(e){var o=e.data.dialog;o.isModalEvent(e)&&"function"==typeof o.options.onhidden&&o.options.onhidden(o),o.isAutodestroy()&&(o.setRealized(!1),delete n.dialogs[o.getId()],t(this).remove()),n.moveFocus(),t(".modal").hasClass("in")&&t("body").addClass("modal-open")}),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(void 0!==n.registeredButtonHotkeys[e.which]){var o=t(n.registeredButtonHotkeys[e.which]);!o.prop("disabled")&&!o.is(":focus")&&o.focus().trigger("click")}}),this},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},isModalEvent:function(t){return void 0!==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(n.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 e(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}},n.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})},n.show=function(t){return new n(t).open()},n.alert=function(){var e={},o={type:n.TYPE_PRIMARY,title:null,message:null,closable:!1,draggable:!1,buttonLabel:n.DEFAULT_TEXTS.OK,buttonHotkey:null,callback:null};e="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?t.extend(!0,o,arguments[0]):t.extend(!0,o,{message:arguments[0],callback:void 0!==arguments[1]?arguments[1]:null});var i=new n(e);return i.setData("callback",e.callback),i.addButton({label:e.buttonLabel,hotkey:e.buttonHotkey,action:function(t){return("function"!=typeof t.getData("callback")||!1!==t.getData("callback").call(this,!0))&&(t.setData("btnClicked",!0),t.close())}}),"function"==typeof i.options.onhide?i.onHide(function(t){var e=!0;return!t.getData("btnClicked")&&t.isClosable()&&"function"==typeof t.getData("callback")&&(e=t.getData("callback")(!1)),!1!==e&&(e=this.onhide(t))}.bind({onhide:i.options.onhide})):i.onHide(function(t){var e=!0;return!t.getData("btnClicked")&&t.isClosable()&&"function"==typeof t.getData("callback")&&(e=t.getData("callback")(!1)),e}),i.open()},n.confirm=function(){var e={},o={type:n.TYPE_PRIMARY,title:null,message:null,closable:!1,draggable:!1,btnCancelLabel:n.DEFAULT_TEXTS.CANCEL,btnCancelClass:null,btnCancelHotkey:null,btnOKLabel:n.DEFAULT_TEXTS.OK,btnOKClass:null,btnOKHotkey:null,btnsOrder:n.defaultOptions.btnsOrder,callback:null};null===(e="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?t.extend(!0,o,arguments[0]):t.extend(!0,o,{message:arguments[0],callback:void 0!==arguments[1]?arguments[1]:null})).btnOKClass&&(e.btnOKClass=["btn",e.type.split("-")[1]].join("-"));var i=new n(e);i.setData("callback",e.callback);var s=[{label:e.btnCancelLabel,cssClass:e.btnCancelClass,hotkey:e.btnCancelHotkey,action:function(t){return("function"!=typeof t.getData("callback")||!1!==t.getData("callback").call(this,!1))&&t.close()}},{label:e.btnOKLabel,cssClass:e.btnOKClass,hotkey:e.btnOKHotkey,action:function(t){return("function"!=typeof t.getData("callback")||!1!==t.getData("callback").call(this,!0))&&t.close()}}];return e.btnsOrder===n.BUTTONS_ORDER_OK_CANCEL&&s.reverse(),i.addButtons(s),i.open()},n.warning=function(t,e){return new n({type:n.TYPE_WARNING,message:t}).open()},n.danger=function(t,e){return new n({type:n.TYPE_DANGER,message:t}).open()},n.success=function(t,e){return new n({type:n.TYPE_SUCCESS,message:t}).open()},n}); \ No newline at end of file