!function(n,t){"use strict";"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery"),require("bootstrap")):"function"==typeof define&&define.amd?define("bootstrap-dialog",["jquery"],function(n){return t(n)}):n.BootstrapDialog=t(n.jQuery)}(this,function(n){"use strict";var r=n.fn.modal.Constructor,i=function(n,t){r.call(this,n,t)},t;return i.getModalVersion=function(){return"undefined"==typeof n.fn.modal.Constructor.VERSION?"v3.1":/3\.2\.\d+/.test(n.fn.modal.Constructor.VERSION)?"v3.2":/3\.3\.[1,2]/.test(n.fn.modal.Constructor.VERSION)?"v3.3":"v3.3.4"},i.ORIGINAL_BODY_PADDING=n("body").css("padding-right")||0,i.METHODS_TO_OVERRIDE={},i.METHODS_TO_OVERRIDE["v3.1"]={},i.METHODS_TO_OVERRIDE["v3.2"]={hide:function(t){if(t&&t.preventDefault(),t=n.Event("hide.bs.modal"),this.$element.trigger(t),this.isShown&&!t.isDefaultPrevented()){this.isShown=!1;var i=this.getGlobalOpenedDialogs();0===i.length&&this.$body.removeClass("modal-open");this.resetScrollbar();this.escape();n(document).off("focusin.bs.modal");this.$element.removeClass("in").attr("aria-hidden",!0).off("click.dismiss.bs.modal");n.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",n.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal()}}},i.METHODS_TO_OVERRIDE["v3.3"]={setScrollbar:function(){var n=i.ORIGINAL_BODY_PADDING;this.bodyIsOverflowing&&this.$body.css("padding-right",n+this.scrollbarWidth)},resetScrollbar:function(){var n=this.getGlobalOpenedDialogs();0===n.length&&this.$body.css("padding-right",i.ORIGINAL_BODY_PADDING)},hideModal:function(){this.$element.hide();this.backdrop(n.proxy(function(){var n=this.getGlobalOpenedDialogs();0===n.length&&this.$body.removeClass("modal-open");this.resetAdjustments();this.resetScrollbar();this.$element.trigger("hidden.bs.modal")},this))}},i.METHODS_TO_OVERRIDE["v3.3.4"]=n.extend({},i.METHODS_TO_OVERRIDE["v3.3"]),i.prototype={constructor:i,getGlobalOpenedDialogs:function(){var i=[];return n.each(t.dialogs,function(n,t){t.isRealized()&&t.isOpened()&&i.push(t)}),i}},i.prototype=n.extend(i.prototype,r.prototype,i.METHODS_TO_OVERRIDE[i.getModalVersion()]),t=function(i){this.defaultOptions=n.extend(!0,{id:t.newGuid(),buttons:[],data:{},onshow:null,onshown:null,onhide:null,onhidden:null},t.defaultOptions);this.indexedButtons={};this.registeredButtonHotkeys={};this.draggableData={isMouseDown:!1,mouseOffset:{}};this.realized=!1;this.opened=!1;this.initOptions(i);this.holdThisInstance()},t.BootstrapDialogModal=i,t.NAMESPACE="bootstrap-dialog",t.TYPE_DEFAULT="type-default",t.TYPE_INFO="type-info",t.TYPE_PRIMARY="type-primary",t.TYPE_SUCCESS="type-success",t.TYPE_WARNING="type-warning",t.TYPE_DANGER="type-danger",t.DEFAULT_TEXTS={},t.DEFAULT_TEXTS[t.TYPE_DEFAULT]="Information",t.DEFAULT_TEXTS[t.TYPE_INFO]="Information",t.DEFAULT_TEXTS[t.TYPE_PRIMARY]="Information",t.DEFAULT_TEXTS[t.TYPE_SUCCESS]="Success",t.DEFAULT_TEXTS[t.TYPE_WARNING]="Warning",t.DEFAULT_TEXTS[t.TYPE_DANGER]="Danger",t.DEFAULT_TEXTS.OK="OK",t.DEFAULT_TEXTS.CANCEL="Cancel",t.DEFAULT_TEXTS.CONFIRM="Confirmation",t.SIZE_NORMAL="size-normal",t.SIZE_SMALL="size-small",t.SIZE_WIDE="size-wide",t.SIZE_LARGE="size-large",t.BUTTON_SIZES={},t.BUTTON_SIZES[t.SIZE_NORMAL]="",t.BUTTON_SIZES[t.SIZE_SMALL]="",t.BUTTON_SIZES[t.SIZE_WIDE]="",t.BUTTON_SIZES[t.SIZE_LARGE]="btn-lg",t.ICON_SPINNER="glyphicon glyphicon-asterisk",t.defaultOptions={type:t.TYPE_PRIMARY,size:t.SIZE_NORMAL,cssClass:"",title:null,message:null,nl2br:!0,closable:!0,closeByBackdrop:!0,closeByKeyboard:!0,spinicon:t.ICON_SPINNER,autodestroy:!0,draggable:!1,animate:!0,description:""},t.configDefaultOptions=function(i){t.defaultOptions=n.extend(!0,t.defaultOptions,i)},t.dialogs={},t.openAll=function(){n.each(t.dialogs,function(n,t){t.open()})},t.closeAll=function(){n.each(t.dialogs,function(n,t){t.close()})},t.moveFocus=function(){var i=null;n.each(t.dialogs,function(n,t){i=t});null!==i&&i.isRealized()&&i.getModal().focus()},t.METHODS_TO_OVERRIDE={},t.METHODS_TO_OVERRIDE["v3.1"]={handleModalBackdropEvent:function(){return this.getModal().on("click",{dialog:this},function(n){n.target===this&&n.data.dialog.isClosable()&&n.data.dialog.canCloseByBackdrop()&&n.data.dialog.close()}),this},updateZIndex:function(){var i=0,r,u;return n.each(t.dialogs,function(){i++}),r=this.getModal(),u=r.data("bs.modal").$backdrop,r.css("z-index",1050+20*(i-1)),u.css("z-index",1040+20*(i-1)),this},open:function(){return!this.isRealized()&&this.realize(),this.getModal().modal("show"),this.updateZIndex(),this}},t.METHODS_TO_OVERRIDE["v3.2"]={handleModalBackdropEvent:t.METHODS_TO_OVERRIDE["v3.1"].handleModalBackdropEvent,updateZIndex:t.METHODS_TO_OVERRIDE["v3.1"].updateZIndex,open:t.METHODS_TO_OVERRIDE["v3.1"].open},t.METHODS_TO_OVERRIDE["v3.3"]={},t.METHODS_TO_OVERRIDE["v3.3.4"]=n.extend({},t.METHODS_TO_OVERRIDE["v3.1"]),t.prototype={constructor:t,initOptions:function(t){return this.options=n.extend(!0,this.defaultOptions,t),this},holdThisInstance:function(){return t.dialogs[this.getId()]=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 t=n('<div class="modal" tabindex="-1" role="dialog" aria-hidden="true"><\/div>');return t.prop("id",this.getId()).attr("aria-labelledby",this.getId()+"_title"),t},getModal:function(){return this.$modal},setModal:function(n){return this.$modal=n,this},createModalDialog:function(){return n('<div class="modal-dialog"><\/div>')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(n){return this.$modalDialog=n,this},createModalContent:function(){return n('<div class="modal-content"><\/div>')},getModalContent:function(){return this.$modalContent},setModalContent:function(n){return this.$modalContent=n,this},createModalHeader:function(){return n('<div class="modal-header"><\/div>')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(n){return this.$modalHeader=n,this},createModalBody:function(){return n('<div class="modal-body"><\/div>')},getModalBody:function(){return this.$modalBody},setModalBody:function(n){return this.$modalBody=n,this},createModalFooter:function(){return n('<div class="modal-footer"><\/div>')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(n){return this.$modalFooter=n,this},createDynamicContent:function(n){var t=null;return t="function"==typeof n?n.call(n,this):n,"string"==typeof t&&(t=this.formatStringContent(t)),t},formatStringContent:function(n){return this.options.nl2br?n.replace(/\r\n/g,"<br />").replace(/[\r\n]/g,"<br />"):n},setData:function(n,t){return this.options.data[n]=t,this},getData:function(n){return this.options.data[n]},setId:function(n){return this.options.id=n,this},getId:function(){return this.options.id},getType:function(){return this.options.type},setType:function(n){return this.options.type=n,this.updateType(),this},updateType:function(){if(this.isRealized()){var n=[t.TYPE_DEFAULT,t.TYPE_INFO,t.TYPE_PRIMARY,t.TYPE_SUCCESS,t.TYPE_WARNING,t.TYPE_DANGER];this.getModal().removeClass(n.join(" ")).addClass(this.getType())}return this},getSize:function(){return this.options.size},setSize:function(n){return this.options.size=n,this.updateSize(),this},updateSize:function(){if(this.isRealized()){var i=this;this.getModal().removeClass(t.SIZE_NORMAL).removeClass(t.SIZE_SMALL).removeClass(t.SIZE_WIDE).removeClass(t.SIZE_LARGE);this.getModal().addClass(this.getSize());this.getModalDialog().removeClass("modal-sm");this.getSize()===t.SIZE_SMALL&&this.getModalDialog().addClass("modal-sm");this.getModalDialog().removeClass("modal-lg");this.getSize()===t.SIZE_WIDE&&this.getModalDialog().addClass("modal-lg");n.each(this.options.buttons,function(t,r){var u=i.getButton(r.id),f=["btn-lg","btn-sm","btn-xs"],e=!1,o;"string"==typeof r.cssClass&&(o=r.cssClass.split(" "),n.each(o,function(t,i){-1!==n.inArray(i,f)&&(e=!0)}));e||(u.removeClass(f.join(" ")),u.addClass(i.getButtonSize()))})}return this},getCssClass:function(){return this.options.cssClass},setCssClass:function(n){return this.options.cssClass=n,this},getTitle:function(){return this.options.title},setTitle:function(n){return this.options.title=n,this.updateTitle(),this},updateTitle:function(){if(this.isRealized()){var n=null!==this.getTitle()?this.createDynamicContent(this.getTitle()):this.getDefaultText();this.getModalHeader().find("."+this.getNamespace("title")).html("").append(n).prop("id",this.getId()+"_title")}return this},getMessage:function(){return this.options.message},setMessage:function(n){return this.options.message=n,this.updateMessage(),this},updateMessage:function(){if(this.isRealized()){var n=this.createDynamicContent(this.getMessage());this.getModalBody().find("."+this.getNamespace("message")).html("").append(n)}return this},isClosable:function(){return this.options.closable},setClosable:function(n){return this.options.closable=n,this.updateClosable(),this},setCloseByBackdrop:function(n){return this.options.closeByBackdrop=n,this},canCloseByBackdrop:function(){return this.options.closeByBackdrop},setCloseByKeyboard:function(n){return this.options.closeByKeyboard=n,this},canCloseByKeyboard:function(){return this.options.closeByKeyboard},isAnimate:function(){return this.options.animate},setAnimate:function(n){return this.options.animate=n,this},updateAnimate:function(){return this.isRealized()&&this.getModal().toggleClass("fade",this.isAnimate()),this},getSpinicon:function(){return this.options.spinicon},setSpinicon:function(n){return this.options.spinicon=n,this},addButton:function(n){return this.options.buttons.push(n),this},addButtons:function(t){var i=this;return n.each(t,function(n,t){i.addButton(t)}),this},getButtons:function(){return this.options.buttons},setButtons:function(n){return this.options.buttons=n,this.updateButtons(),this},getButton:function(n){return"undefined"!=typeof this.indexedButtons[n]?this.indexedButtons[n]:null},getButtonSize:function(){return"undefined"!=typeof t.BUTTON_SIZES[this.getSize()]?t.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(n){this.options.autodestroy=n},getDescription:function(){return this.options.description},setDescription:function(n){return this.options.description=n,this},getDefaultText:function(){return t.DEFAULT_TEXTS[this.getType()]},getNamespace:function(n){return t.NAMESPACE+"-"+n},createHeaderContent:function(){var t=n("<div><\/div>");return t.addClass(this.getNamespace("header")),t.append(this.createTitleContent()),t.prepend(this.createCloseButton()),t},createTitleContent:function(){var t=n("<div><\/div>");return t.addClass(this.getNamespace("title")),t},createCloseButton:function(){var t=n("<div><\/div>"),i;return t.addClass(this.getNamespace("close-button")),i=n('<button class="close">&times;<\/button>'),t.append(i),t.on("click",{dialog:this},function(n){n.data.dialog.close()}),t},createBodyContent:function(){var t=n("<div><\/div>");return t.addClass(this.getNamespace("body")),t.append(this.createMessageContent()),t},createMessageContent:function(){var t=n("<div><\/div>");return t.addClass(this.getNamespace("message")),t},createFooterContent:function(){var t=n("<div><\/div>");return t.addClass(this.getNamespace("footer")),t},createFooterButtons:function(){var r=this,i=n("<div><\/div>");return i.addClass(this.getNamespace("footer-buttons")),this.indexedButtons={},n.each(this.options.buttons,function(n,u){u.id||(u.id=t.newGuid());var f=r.createButton(u);r.indexedButtons[u.id]=f;i.append(f)}),i},createButton:function(t){var i=n('<button class="btn"><\/button>');return i.prop("id",t.id),i.data("button",t),"undefined"!=typeof t.icon&&""!==n.trim(t.icon)&&i.append(this.createButtonIcon(t.icon)),"undefined"!=typeof t.label&&i.append(t.label),i.addClass("undefined"!=typeof t.cssClass&&""!==n.trim(t.cssClass)?t.cssClass:"btn-default"),"undefined"!=typeof t.hotkey&&(this.registeredButtonHotkeys[t.hotkey]=i),i.on("click",{dialog:this,$button:i,button:t},function(n){var r=n.data.dialog,t=n.data.$button,i=t.data("button");"function"==typeof i.action&&i.action.call(t,r,n);i.autospin&&t.toggleSpin(!0)}),this.enhanceButton(i),i},enhanceButton:function(n){return n.dialog=this,n.toggleEnable=function(n){var t=this;return"undefined"!=typeof n?t.prop("disabled",!n).toggleClass("disabled",!n):t.prop("disabled",!t.prop("disabled")),t},n.enable=function(){var n=this;return n.toggleEnable(!0),n},n.disable=function(){var n=this;return n.toggleEnable(!1),n},n.toggleSpin=function(t){var i=this,r=i.dialog,u=i.find("."+r.getNamespace("button-icon"));return"undefined"==typeof t&&(t=!(n.find(".icon-spin").length>0)),t?(u.hide(),n.prepend(r.createButtonIcon(r.getSpinicon()).addClass("icon-spin"))):(u.show(),n.find(".icon-spin").remove()),i},n.spin=function(){var n=this;return n.toggleSpin(!0),n},n.stopSpin=function(){var n=this;return n.toggleSpin(!1),n},this},createButtonIcon:function(t){var i=n("<span><\/span>");return i.addClass(this.getNamespace("button-icon")).addClass(t),i},enableButtons:function(t){return n.each(this.indexedButtons,function(n,i){i.toggleEnable(t)}),this},updateClosable:function(){return this.isRealized()&&this.getModalHeader().find("."+this.getNamespace("close-button")).toggle(this.isClosable()),this},onShow:function(n){return this.options.onshow=n,this},onShown:function(n){return this.options.onshown=n,this},onHide:function(n){return this.options.onhide=n,this},onHidden:function(n){return this.options.onhidden=n,this},isRealized:function(){return this.realized},setRealized:function(n){return this.realized=n,this},isOpened:function(){return this.opened},setOpened:function(n){return this.opened=n,this},handleModalEvents:function(){return this.getModal().on("show.bs.modal",{dialog:this},function(n){var t=n.data.dialog,i;if(t.setOpened(!0),t.isModalEvent(n)&&"function"==typeof t.options.onshow)return i=t.options.onshow(t),i===!1&&t.setOpened(!1),i}),this.getModal().on("shown.bs.modal",{dialog:this},function(n){var t=n.data.dialog;t.isModalEvent(n)&&"function"==typeof t.options.onshown&&t.options.onshown(t)}),this.getModal().on("hide.bs.modal",{dialog:this},function(n){var t=n.data.dialog,i;if(t.setOpened(!1),t.isModalEvent(n)&&"function"==typeof t.options.onhide)return i=t.options.onhide(t),i===!1&&t.setOpened(!0),i}),this.getModal().on("hidden.bs.modal",{dialog:this},function(i){var r=i.data.dialog;r.isModalEvent(i)&&"function"==typeof r.options.onhidden&&r.options.onhidden(r);r.isAutodestroy()&&(delete t.dialogs[r.getId()],n(this).remove());t.moveFocus()}),this.handleModalBackdropEvent(),this.getModal().on("keyup",{dialog:this},function(n){27===n.which&&n.data.dialog.isClosable()&&n.data.dialog.canCloseByKeyboard()&&n.data.dialog.close()}),this.getModal().on("keyup",{dialog:this},function(t){var r=t.data.dialog,i;"undefined"!=typeof r.registeredButtonHotkeys[t.which]&&(i=n(r.registeredButtonHotkeys[t.which]),i.prop("disabled")||i.focus().trigger("click"))}),this},handleModalBackdropEvent:function(){return this.getModal().on("click",{dialog:this},function(t){n(t.target).hasClass("modal-backdrop")&&t.data.dialog.isClosable()&&t.data.dialog.canCloseByBackdrop()&&t.data.dialog.close()}),this},isModalEvent:function(n){return"undefined"!=typeof n.namespace&&"bs.modal"===n.namespace},makeModalDraggable:function(){return this.options.draggable&&(this.getModalHeader().addClass(this.getNamespace("draggable")).on("mousedown",{dialog:this},function(n){var t=n.data.dialog,i;t.draggableData.isMouseDown=!0;i=t.getModalDialog().offset();t.draggableData.mouseOffset={top:n.clientY-i.top,left:n.clientX-i.left}}),this.getModal().on("mouseup mouseleave",{dialog:this},function(n){n.data.dialog.draggableData.isMouseDown=!1}),n("body").on("mousemove",{dialog:this},function(n){var t=n.data.dialog;t.draggableData.isMouseDown&&t.getModalDialog().offset({top:n.clientY-t.draggableData.mouseOffset.top,left:n.clientX-t.draggableData.mouseOffset.left})})),this},realize:function(){return this.initModalStuff(),this.getModal().addClass(t.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 i(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},open:function(){return!this.isRealized()&&this.realize(),this.getModal().modal("show"),this},close:function(){return this.getModal().modal("hide"),this}},t.prototype=n.extend(t.prototype,t.METHODS_TO_OVERRIDE[i.getModalVersion()]),t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var t=16*Math.random()|0,i="x"===n?t:3&t|8;return i.toString(16)})},t.show=function(n){return new t(n).open()},t.alert=function(){var i={},r={type:t.TYPE_PRIMARY,title:null,message:null,closable:!1,draggable:!1,buttonLabel:t.DEFAULT_TEXTS.OK,callback:null};return i="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?n.extend(!0,r,arguments[0]):n.extend(!0,r,{message:arguments[0],callback:"undefined"!=typeof arguments[1]?arguments[1]:null}),new t({type:i.type,title:i.title,message:i.message,closable:i.closable,draggable:i.draggable,data:{callback:i.callback},onhide:function(n){!n.getData("btnClicked")&&n.isClosable()&&"function"==typeof n.getData("callback")&&n.getData("callback")(!1)},buttons:[{label:i.buttonLabel,action:function(n){n.setData("btnClicked",!0);"function"==typeof n.getData("callback")&&n.getData("callback")(!0);n.close()}}]}).open()},t.confirm=function(){var i={},r={type:t.TYPE_PRIMARY,title:null,message:null,closable:!1,draggable:!1,btnCancelLabel:t.DEFAULT_TEXTS.CANCEL,btnOKLabel:t.DEFAULT_TEXTS.OK,btnOKClass:null,callback:null};return i="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?n.extend(!0,r,arguments[0]):n.extend(!0,r,{message:arguments[0],closable:!1,buttonLabel:t.DEFAULT_TEXTS.OK,callback:"undefined"!=typeof arguments[1]?arguments[1]:null}),null===i.btnOKClass&&(i.btnOKClass=["btn",i.type.split("-")[1]].join("-")),new t({type:i.type,title:i.title,message:i.message,closable:i.closable,draggable:i.draggable,data:{callback:i.callback},buttons:[{label:i.btnCancelLabel,action:function(n){"function"==typeof n.getData("callback")&&n.getData("callback")(!1);n.close()}},{label:i.btnOKLabel,cssClass:i.btnOKClass,action:function(n){"function"==typeof n.getData("callback")&&n.getData("callback")(!0);n.close()}}]}).open()},t.warning=function(n){return new t({type:t.TYPE_WARNING,message:n}).open()},t.danger=function(n){return new t({type:t.TYPE_DANGER,message:n}).open()},t.success=function(n){return new t({type:t.TYPE_SUCCESS,message:n}).open()},t})