!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=t.fn.modal.constructor,n=function(t,n){e.call(this,t,n)};n.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"},n.original_body_padding=parseint(t("body").css("padding-right")||0,10),(n.methods_to_override={})["v3.1"]={},n.methods_to_override["v3.2"]={hide:function(e){e&&e.preventdefault(),e=t.event("hide.bs.modal"),this.$element.trigger(e),this.isshown&&!e.isdefaultprevented()&&(this.isshown=!1,0===this.getglobalopeneddialogs().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(){0===this.getglobalopeneddialogs().length&&this.$body.css("padding-right",n.original_body_padding)},hidemodal:function(){this.$element.hide(),this.backdrop(t.proxy(function(){0===this.getglobalopeneddialogs().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.buttons_order_cancel_ok="btns-order-cancel-ok",o.buttons_order_ok_cancel="btns-order-ok-cancel",o.defaultoptions={type:o.type_primary,size:o.size_normal,cssclass:"",title:null,message:null,nl2br:!0,closable:!0,closebybackdrop:!0,closebykeyboard:!0,closeicon:"×",spinicon:o.icon_spinner,autodestroy:!0,draggable:!1,animate:!0,description:"",tabindex:-1,btnsorder:o.buttons_order_cancel_ok},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 void 0!==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){n.isrealized()&&n.isopened()&&(e=n)}),null!==e&&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(){if(this.isopened()){var e=0;t.each(o.dialogs,function(t,n){n.isrealized()&&n.isopened()&&e++});var n=this.getmodal(),i=n.data("bs.modal").$backdrop;n.css("z-index",1050+20*(e-1)),i.css("z-index",1040+20*(e-1))}return 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('');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=[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 void 0!==this.indexedbuttons[t]?this.indexedbuttons[t]:null},getbuttonsize:function(){return void 0!==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("
");return e.addclass(this.getnamespace("header")),e.append(this.createtitlecontent()),e.prepend(this.createclosebutton()),e},createtitlecontent:function(){var e=t("
");return e.addclass(this.getnamespace("title")),e},createclosebutton:function(){var e=t("
");e.addclass(this.getnamespace("close-button"));var n=t('');return n.append(this.options.closeicon),e.append(n),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,n=t("
");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('');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-default"),"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){var e=this;return void 0!==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 void 0===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("");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 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(),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(e){t(e.target).hasclass("modal-backdrop")&&e.data.dialog.isclosable()&&e.data.dialog.canclosebybackdrop()&&e.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(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;return("x"===t?e:3&e|8).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,buttonhotkey:null,callback:null};e="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?t.extend(!0,n,arguments[0]):t.extend(!0,n,{message:arguments[0],callback:void 0!==arguments[1]?arguments[1]:null});var i=new o(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()},o.confirm=function(){var e={},n={type:o.type_primary,title:null,message:null,closable:!1,draggable:!1,btncancellabel:o.default_texts.cancel,btncancelclass:null,btncancelhotkey:null,btnoklabel:o.default_texts.ok,btnokclass:null,btnokhotkey:null,btnsorder:o.defaultoptions.btnsorder,callback:null};null===(e="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?t.extend(!0,n,arguments[0]):t.extend(!0,n,{message:arguments[0],callback:void 0!==arguments[1]?arguments[1]:null})).btnokclass&&(e.btnokclass=["btn",e.type.split("-")[1]].join("-"));var i=new o(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===o.buttons_order_ok_cancel&&s.reverse(),i.addbuttons(s),i.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});