1 line
18 KiB
JavaScript
1 line
18 KiB
JavaScript
|
!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('<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:functio
|