From 2861d309d84663199dbfdc10707dfea5c65e0f0e Mon Sep 17 00:00:00 2001 From: Dante Date: Wed, 12 Feb 2014 16:00:51 +0800 Subject: [PATCH] Fixed a bug that caused by incorrect content generating order. --- examples/assets/bootstrap-dialog/js/bootstrap-dialog.js | 6 +++--- examples/assets/bootstrap-dialog/js/bootstrap-dialog.min.js | 2 +- js/bootstrap-dialog.js | 6 +++--- js/bootstrap-dialog.min.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/assets/bootstrap-dialog/js/bootstrap-dialog.js b/examples/assets/bootstrap-dialog/js/bootstrap-dialog.js index d273745..6c291d3 100644 --- a/examples/assets/bootstrap-dialog/js/bootstrap-dialog.js +++ b/examples/assets/bootstrap-dialog/js/bootstrap-dialog.js @@ -645,14 +645,14 @@ var BootstrapDialog = null; }); this.handleModalEvents(); this.setRealized(true); + this.updateTitle(); + this.updateMessage(); + this.updateClosable(); return this; }, open: function() { !this.isRealized() && this.realize(); - this.updateTitle(); - this.updateMessage(); - this.updateClosable(); this.getModal().modal('show'); this.setOpened(true); diff --git a/examples/assets/bootstrap-dialog/js/bootstrap-dialog.min.js b/examples/assets/bootstrap-dialog/js/bootstrap-dialog.min.js index 2e65a6e..0c53c81 100644 --- a/examples/assets/bootstrap-dialog/js/bootstrap-dialog.min.js +++ b/examples/assets/bootstrap-dialog/js/bootstrap-dialog.min.js @@ -1 +1 @@ -var BootstrapDialog=null;!function(a){BootstrapDialog=function(b){this.defaultOptions={id:BootstrapDialog.newGuid(),type:BootstrapDialog.TYPE_PRIMARY,size:BootstrapDialog.SIZE_NORMAL,cssClass:"",title:null,message:null,buttons:[],closable:true,spinicon:BootstrapDialog.ICON_SPINNER,data:{},onshow:null,onhide:null,autodestroy:true};this.indexedButtons={};this.registeredButtonHotkeys={};this.realized=false;this.opened=false;this.initOptions(b);this.holdThisInstance()};BootstrapDialog.NAMESPACE="bootstrap-dialog";BootstrapDialog.TYPE_DEFAULT="type-default";BootstrapDialog.TYPE_INFO="type-info";BootstrapDialog.TYPE_PRIMARY="type-primary";BootstrapDialog.TYPE_SUCCESS="type-success";BootstrapDialog.TYPE_WARNING="type-warning";BootstrapDialog.TYPE_DANGER="type-danger";BootstrapDialog.DEFAULT_TEXTS={};BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SUCCESS]="Success";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_WARNING]="Warning";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DANGER]="Danger";BootstrapDialog.SIZE_NORMAL="size-normal";BootstrapDialog.SIZE_LARGE="size-large";BootstrapDialog.BUTTON_SIZES={};BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL]="";BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE]="btn-lg";BootstrapDialog.ICON_SPINNER="glyphicon glyphicon-asterisk";BootstrapDialog.dialogs={};BootstrapDialog.openAll=function(){a.each(BootstrapDialog.dialogs,function(c,b){b.open()})};BootstrapDialog.closeAll=function(){a.each(BootstrapDialog.dialogs,function(c,b){b.close()})};BootstrapDialog.prototype={constructor:BootstrapDialog,initOptions:function(b){this.options=a.extend(true,this.defaultOptions,b);return this},holdThisInstance:function(){BootstrapDialog.dialogs[this.getId()]=this;return this},initModalStuff:function(){this.setModal(this.createModal()).setModalDialog(this.createModalDialog()).setModalContent(this.createModalContent()).setModalHeader(this.createModalHeader()).setModalBody(this.createModalBody()).setModalFooter(this.createModalFooter());this.getModal().append(this.getModalDialog());this.getModalDialog().append(this.getModalContent());this.getModalContent().append(this.getModalHeader()).append(this.getModalBody()).append(this.getModalFooter());return this},createModal:function(){var b=a('');b.prop("id",this.getId());return b},getModal:function(){return this.$modal},setModal:function(b){this.$modal=b;return this},createModalDialog:function(){return a('')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(b){this.$modalDialog=b;return this},createModalContent:function(){return a('')},getModalContent:function(){return this.$modalContent},setModalContent:function(b){this.$modalContent=b;return this},createModalHeader:function(){return a('')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(b){this.$modalHeader=b;return this},createModalBody:function(){return a('')},getModalBody:function(){return this.$modalBody},setModalBody:function(b){this.$modalBody=b;return this},createModalFooter:function(){return a('')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(b){this.$modalFooter=b;return this},createDynamicContent:function(c){var b=null;if(typeof c==="function"){b=c.call(c,this)}else{b=c}if(typeof b==="string"){b=this.formatStringContent(b)}return b},formatStringContent:function(b){return b.replace(/\r\n/g,"
").replace(/[\r\n]/g,"
")},setData:function(b,c){this.options.data[b]=c;return this},getData:function(b){return this.options.data[b]},setId:function(b){this.options.id=b;return this},getId:function(){return this.options.id},getType:function(){return this.options.type},setType:function(b){this.options.type=b;return this},getSize:function(){return this.options.size},setSize:function(b){this.options.size=b;return this},getCssClass:function(){return this.options.cssClass},setCssClass:function(b){this.options.cssClass=b;return this},getTitle:function(){return this.options.title},setTitle:function(b){this.options.title=b;this.updateTitle();return this},updateTitle:function(){if(this.isRealized()){var b=this.getTitle()!==null?this.createDynamicContent(this.getTitle()):this.getDefaultText();this.getModalHeader().find("."+this.getNamespace("title")).html("").append(b)}return this},getMessage:function(){return this.options.message},setMessage:function(b){this.options.message=b;this.updateMessage();return this},updateMessage:function(){if(this.isRealized()){var b=this.createDynamicContent(this.getMessage());this.getModalBody().find("."+this.getNamespace("message")).html("").append(b)}return this},isClosable:function(){return this.options.closable},setClosable:function(b){this.options.closable=b;this.updateClosable();return this},getSpinicon:function(){return this.options.spinicon},setSpinicon:function(b){this.options.spinicon=b;return this},addButton:function(b){this.options.buttons.push(b);return this},addButtons:function(c){var b=this;a.each(c,function(d,e){b.addButton(e)});return this},getButtons:function(){return this.options.buttons},setButtons:function(b){this.options.buttons=b;return this},getButton:function(b){if(typeof this.indexedButtons[b]!=="undefined"){return this.indexedButtons[b]}return null},getButtonSize:function(){if(typeof BootstrapDialog.BUTTON_SIZES[this.getSize()]!=="undefined"){return BootstrapDialog.BUTTON_SIZES[this.getSize()]}return""},isAutodestroy:function(){return this.options.autodestroy},setAutodestroy:function(b){this.options.autodestroy=b},getDefaultText:function(){return BootstrapDialog.DEFAULT_TEXTS[this.getType()]},getNamespace:function(b){return BootstrapDialog.NAMESPACE+"-"+b},createHeaderContent:function(){var b=a("
");b.addClass(this.getNamespace("header"));b.append(this.createTitleContent());b.append(this.createCloseButton());return b},createTitleContent:function(){var b=a("
");b.addClass(this.getNamespace("title"));return b},createCloseButton:function(){var c=a("
");c.addClass(this.getNamespace("close-button"));var b=a('');c.append(b);c.on("click",{dialog:this},function(d){d.data.dialog.close()});return c},createBodyContent:function(){var b=a("
");b.addClass(this.getNamespace("body"));b.append(this.createMessageContent());return b},createMessageContent:function(){var b=a("
");b.addClass(this.getNamespace("message"));return b},createFooterContent:function(){var b=a("
");b.addClass(this.getNamespace("footer"));b.append(this.createFooterButtons());return b},createFooterButtons:function(){var b=this;var c=a("
");c.addClass(this.getNamespace("footer-buttons"));this.indexedButtons={};a.each(this.options.buttons,function(d,e){if(!e.id){e.id=BootstrapDialog.newGuid()}var f=b.createButton(e);b.indexedButtons[e.id]=f;c.append(f)});return c},createButton:function(b){var c=a('');c.addClass(this.getButtonSize());c.prop("id",b.id);if(typeof b.icon!==undefined&&a.trim(b.icon)!==""){c.append(this.createButtonIcon(b.icon))}if(typeof b.label!==undefined){c.append(b.label)}if(typeof b.cssClass!==undefined&&a.trim(b.cssClass)!==""){c.addClass(b.cssClass)}else{c.addClass("btn-default")}if(typeof b.hotkey!==undefined){this.registeredButtonHotkeys[b.hotkey]=c}c.on("click",{dialog:this,$button:c,button:b},function(f){var e=f.data.dialog;var g=f.data.$button;var d=f.data.button;if(typeof d.action==="function"){d.action.call(g,e)}if(d.autospin){g.toggleSpin(true)}});this.enhanceButton(c);return c},enhanceButton:function(b){b.dialog=this;b.toggleEnable=function(c){var d=this;d.prop("disabled",!c).toggleClass("disabled",!c);return d};b.enable=function(){var c=this;c.toggleEnable(true);return c};b.disable=function(){var c=this;c.toggleEnable(false);return c};b.toggleSpin=function(f){var e=this;var d=e.dialog;var c=e.find("."+d.getNamespace("button-icon"));if(f){c.hide();b.prepend(d.createButtonIcon(d.getSpinicon()).addClass("icon-spin"))}else{c.show();b.find(".icon-spin").remove()}return e};b.spin=function(){var c=this;c.toggleSpin(true);return c};b.stopSpin=function(){var c=this;c.toggleSpin(false);return c};return this},createButtonIcon:function(c){var b=a("");b.addClass(this.getNamespace("button-icon")).addClass(c);return b},enableButtons:function(b){a.each(this.indexedButtons,function(d,c){c.toggleEnable(b)});return this},updateClosable:function(){if(this.isRealized()){this.getModalHeader().find("."+this.getNamespace("close-button")).toggle(this.isClosable())}return this},onShow:function(b){this.options.onshow=b;return this},onHide:function(b){this.options.onhide=b;return this},isRealized:function(){return this.realized},setRealized:function(b){this.realized=b;return this},isOpened:function(){return this.opened},setOpened:function(b){this.opened=b;return this},handleModalEvents:function(){this.getModal().on("show.bs.modal",{dialog:this},function(c){var b=c.data.dialog;typeof b.options.onshow==="function"&&b.options.onshow(b);b.showPageScrollBar(true)});this.getModal().on("hide.bs.modal",{dialog:this},function(c){var b=c.data.dialog;typeof b.options.onhide==="function"&&b.options.onhide(b)});this.getModal().on("hidden.bs.modal",{dialog:this},function(c){var b=c.data.dialog;b.isAutodestroy()&&a(this).remove();b.showPageScrollBar(false)});this.getModal().on("click",{dialog:this},function(b){b.target===this&&b.data.dialog.isClosable()&&b.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(b){b.which===27&&b.data.dialog.isClosable()&&b.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(c){var b=c.data.dialog;if(typeof b.registeredButtonHotkeys[c.which]!=="undefined"){var d=a(b.registeredButtonHotkeys[c.which]);!d.prop("disabled")&&d.focus().trigger("click")}});return this},showPageScrollBar:function(b){a(document.body).toggleClass("modal-open",b)},realize:function(){this.initModalStuff();this.getModal().addClass(BootstrapDialog.NAMESPACE).addClass(this.getType()).addClass(this.getSize()).addClass(this.getCssClass());this.getModalFooter().append(this.createFooterContent());this.getModalHeader().append(this.createHeaderContent());this.getModalBody().append(this.createBodyContent());this.getModal().modal({backdrop:"static",keyboard:false,show:false});this.handleModalEvents();this.setRealized(true);return this},open:function(){!this.isRealized()&&this.realize();this.updateTitle();this.updateMessage();this.updateClosable();this.getModal().modal("show");this.setOpened(true);return this},close:function(){this.getModal().modal("hide");if(this.isAutodestroy()){delete BootstrapDialog.dialogs[this.getId()]}this.setOpened(false);return this}};BootstrapDialog.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var d=Math.random()*16|0,b=e==="x"?d:(d&3|8);return b.toString(16)})};BootstrapDialog.show=function(b){return new BootstrapDialog(b).open()};BootstrapDialog.alert=function(b,c){return new BootstrapDialog({message:b,data:{callback:c},closable:false,buttons:[{label:"OK",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(true);d.close()}}]}).open()};BootstrapDialog.confirm=function(b,c){return new BootstrapDialog({title:"Confirmation",message:b,closable:false,data:{callback:c},buttons:[{label:"Cancel",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(false);d.close()}},{label:"OK",cssClass:"btn-primary",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(true);d.close()}}]}).open()}}(window.jQuery); \ No newline at end of file +var BootstrapDialog=null;!function(a){BootstrapDialog=function(b){this.defaultOptions={id:BootstrapDialog.newGuid(),type:BootstrapDialog.TYPE_PRIMARY,size:BootstrapDialog.SIZE_NORMAL,cssClass:"",title:null,message:null,buttons:[],closable:true,spinicon:BootstrapDialog.ICON_SPINNER,data:{},onshow:null,onhide:null,autodestroy:true};this.indexedButtons={};this.registeredButtonHotkeys={};this.realized=false;this.opened=false;this.initOptions(b);this.holdThisInstance()};BootstrapDialog.NAMESPACE="bootstrap-dialog";BootstrapDialog.TYPE_DEFAULT="type-default";BootstrapDialog.TYPE_INFO="type-info";BootstrapDialog.TYPE_PRIMARY="type-primary";BootstrapDialog.TYPE_SUCCESS="type-success";BootstrapDialog.TYPE_WARNING="type-warning";BootstrapDialog.TYPE_DANGER="type-danger";BootstrapDialog.DEFAULT_TEXTS={};BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SUCCESS]="Success";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_WARNING]="Warning";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DANGER]="Danger";BootstrapDialog.SIZE_NORMAL="size-normal";BootstrapDialog.SIZE_LARGE="size-large";BootstrapDialog.BUTTON_SIZES={};BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL]="";BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE]="btn-lg";BootstrapDialog.ICON_SPINNER="glyphicon glyphicon-asterisk";BootstrapDialog.dialogs={};BootstrapDialog.openAll=function(){a.each(BootstrapDialog.dialogs,function(c,b){b.open()})};BootstrapDialog.closeAll=function(){a.each(BootstrapDialog.dialogs,function(c,b){b.close()})};BootstrapDialog.prototype={constructor:BootstrapDialog,initOptions:function(b){this.options=a.extend(true,this.defaultOptions,b);return this},holdThisInstance:function(){BootstrapDialog.dialogs[this.getId()]=this;return this},initModalStuff:function(){this.setModal(this.createModal()).setModalDialog(this.createModalDialog()).setModalContent(this.createModalContent()).setModalHeader(this.createModalHeader()).setModalBody(this.createModalBody()).setModalFooter(this.createModalFooter());this.getModal().append(this.getModalDialog());this.getModalDialog().append(this.getModalContent());this.getModalContent().append(this.getModalHeader()).append(this.getModalBody()).append(this.getModalFooter());return this},createModal:function(){var b=a('');b.prop("id",this.getId());return b},getModal:function(){return this.$modal},setModal:function(b){this.$modal=b;return this},createModalDialog:function(){return a('')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(b){this.$modalDialog=b;return this},createModalContent:function(){return a('')},getModalContent:function(){return this.$modalContent},setModalContent:function(b){this.$modalContent=b;return this},createModalHeader:function(){return a('')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(b){this.$modalHeader=b;return this},createModalBody:function(){return a('')},getModalBody:function(){return this.$modalBody},setModalBody:function(b){this.$modalBody=b;return this},createModalFooter:function(){return a('')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(b){this.$modalFooter=b;return this},createDynamicContent:function(c){var b=null;if(typeof c==="function"){b=c.call(c,this)}else{b=c}if(typeof b==="string"){b=this.formatStringContent(b)}return b},formatStringContent:function(b){return b.replace(/\r\n/g,"
").replace(/[\r\n]/g,"
")},setData:function(b,c){this.options.data[b]=c;return this},getData:function(b){return this.options.data[b]},setId:function(b){this.options.id=b;return this},getId:function(){return this.options.id},getType:function(){return this.options.type},setType:function(b){this.options.type=b;return this},getSize:function(){return this.options.size},setSize:function(b){this.options.size=b;return this},getCssClass:function(){return this.options.cssClass},setCssClass:function(b){this.options.cssClass=b;return this},getTitle:function(){return this.options.title},setTitle:function(b){this.options.title=b;this.updateTitle();return this},updateTitle:function(){if(this.isRealized()){var b=this.getTitle()!==null?this.createDynamicContent(this.getTitle()):this.getDefaultText();this.getModalHeader().find("."+this.getNamespace("title")).html("").append(b)}return this},getMessage:function(){return this.options.message},setMessage:function(b){this.options.message=b;this.updateMessage();return this},updateMessage:function(){if(this.isRealized()){var b=this.createDynamicContent(this.getMessage());this.getModalBody().find("."+this.getNamespace("message")).html("").append(b)}return this},isClosable:function(){return this.options.closable},setClosable:function(b){this.options.closable=b;this.updateClosable();return this},getSpinicon:function(){return this.options.spinicon},setSpinicon:function(b){this.options.spinicon=b;return this},addButton:function(b){this.options.buttons.push(b);return this},addButtons:function(c){var b=this;a.each(c,function(d,e){b.addButton(e)});return this},getButtons:function(){return this.options.buttons},setButtons:function(b){this.options.buttons=b;return this},getButton:function(b){if(typeof this.indexedButtons[b]!=="undefined"){return this.indexedButtons[b]}return null},getButtonSize:function(){if(typeof BootstrapDialog.BUTTON_SIZES[this.getSize()]!=="undefined"){return BootstrapDialog.BUTTON_SIZES[this.getSize()]}return""},isAutodestroy:function(){return this.options.autodestroy},setAutodestroy:function(b){this.options.autodestroy=b},getDefaultText:function(){return BootstrapDialog.DEFAULT_TEXTS[this.getType()]},getNamespace:function(b){return BootstrapDialog.NAMESPACE+"-"+b},createHeaderContent:function(){var b=a("
");b.addClass(this.getNamespace("header"));b.append(this.createTitleContent());b.append(this.createCloseButton());return b},createTitleContent:function(){var b=a("
");b.addClass(this.getNamespace("title"));return b},createCloseButton:function(){var c=a("
");c.addClass(this.getNamespace("close-button"));var b=a('');c.append(b);c.on("click",{dialog:this},function(d){d.data.dialog.close()});return c},createBodyContent:function(){var b=a("
");b.addClass(this.getNamespace("body"));b.append(this.createMessageContent());return b},createMessageContent:function(){var b=a("
");b.addClass(this.getNamespace("message"));return b},createFooterContent:function(){var b=a("
");b.addClass(this.getNamespace("footer"));b.append(this.createFooterButtons());return b},createFooterButtons:function(){var b=this;var c=a("
");c.addClass(this.getNamespace("footer-buttons"));this.indexedButtons={};a.each(this.options.buttons,function(d,e){if(!e.id){e.id=BootstrapDialog.newGuid()}var f=b.createButton(e);b.indexedButtons[e.id]=f;c.append(f)});return c},createButton:function(b){var c=a('');c.addClass(this.getButtonSize());c.prop("id",b.id);if(typeof b.icon!==undefined&&a.trim(b.icon)!==""){c.append(this.createButtonIcon(b.icon))}if(typeof b.label!==undefined){c.append(b.label)}if(typeof b.cssClass!==undefined&&a.trim(b.cssClass)!==""){c.addClass(b.cssClass)}else{c.addClass("btn-default")}if(typeof b.hotkey!==undefined){this.registeredButtonHotkeys[b.hotkey]=c}c.on("click",{dialog:this,$button:c,button:b},function(f){var e=f.data.dialog;var g=f.data.$button;var d=f.data.button;if(typeof d.action==="function"){d.action.call(g,e)}if(d.autospin){g.toggleSpin(true)}});this.enhanceButton(c);return c},enhanceButton:function(b){b.dialog=this;b.toggleEnable=function(c){var d=this;d.prop("disabled",!c).toggleClass("disabled",!c);return d};b.enable=function(){var c=this;c.toggleEnable(true);return c};b.disable=function(){var c=this;c.toggleEnable(false);return c};b.toggleSpin=function(f){var e=this;var d=e.dialog;var c=e.find("."+d.getNamespace("button-icon"));if(f){c.hide();b.prepend(d.createButtonIcon(d.getSpinicon()).addClass("icon-spin"))}else{c.show();b.find(".icon-spin").remove()}return e};b.spin=function(){var c=this;c.toggleSpin(true);return c};b.stopSpin=function(){var c=this;c.toggleSpin(false);return c};return this},createButtonIcon:function(c){var b=a("");b.addClass(this.getNamespace("button-icon")).addClass(c);return b},enableButtons:function(b){a.each(this.indexedButtons,function(d,c){c.toggleEnable(b)});return this},updateClosable:function(){if(this.isRealized()){this.getModalHeader().find("."+this.getNamespace("close-button")).toggle(this.isClosable())}return this},onShow:function(b){this.options.onshow=b;return this},onHide:function(b){this.options.onhide=b;return this},isRealized:function(){return this.realized},setRealized:function(b){this.realized=b;return this},isOpened:function(){return this.opened},setOpened:function(b){this.opened=b;return this},handleModalEvents:function(){this.getModal().on("show.bs.modal",{dialog:this},function(c){var b=c.data.dialog;typeof b.options.onshow==="function"&&b.options.onshow(b);b.showPageScrollBar(true)});this.getModal().on("hide.bs.modal",{dialog:this},function(c){var b=c.data.dialog;typeof b.options.onhide==="function"&&b.options.onhide(b)});this.getModal().on("hidden.bs.modal",{dialog:this},function(c){var b=c.data.dialog;b.isAutodestroy()&&a(this).remove();b.showPageScrollBar(false)});this.getModal().on("click",{dialog:this},function(b){b.target===this&&b.data.dialog.isClosable()&&b.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(b){b.which===27&&b.data.dialog.isClosable()&&b.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(c){var b=c.data.dialog;if(typeof b.registeredButtonHotkeys[c.which]!=="undefined"){var d=a(b.registeredButtonHotkeys[c.which]);!d.prop("disabled")&&d.focus().trigger("click")}});return this},showPageScrollBar:function(b){a(document.body).toggleClass("modal-open",b)},realize:function(){this.initModalStuff();this.getModal().addClass(BootstrapDialog.NAMESPACE).addClass(this.getType()).addClass(this.getSize()).addClass(this.getCssClass());this.getModalFooter().append(this.createFooterContent());this.getModalHeader().append(this.createHeaderContent());this.getModalBody().append(this.createBodyContent());this.getModal().modal({backdrop:"static",keyboard:false,show:false});this.handleModalEvents();this.setRealized(true);this.updateTitle();this.updateMessage();this.updateClosable();return this},open:function(){!this.isRealized()&&this.realize();this.getModal().modal("show");this.setOpened(true);return this},close:function(){this.getModal().modal("hide");if(this.isAutodestroy()){delete BootstrapDialog.dialogs[this.getId()]}this.setOpened(false);return this}};BootstrapDialog.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var d=Math.random()*16|0,b=e==="x"?d:(d&3|8);return b.toString(16)})};BootstrapDialog.show=function(b){return new BootstrapDialog(b).open()};BootstrapDialog.alert=function(b,c){return new BootstrapDialog({message:b,data:{callback:c},closable:false,buttons:[{label:"OK",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(true);d.close()}}]}).open()};BootstrapDialog.confirm=function(b,c){return new BootstrapDialog({title:"Confirmation",message:b,closable:false,data:{callback:c},buttons:[{label:"Cancel",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(false);d.close()}},{label:"OK",cssClass:"btn-primary",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(true);d.close()}}]}).open()}}(window.jQuery); \ No newline at end of file diff --git a/js/bootstrap-dialog.js b/js/bootstrap-dialog.js index d273745..6c291d3 100644 --- a/js/bootstrap-dialog.js +++ b/js/bootstrap-dialog.js @@ -645,14 +645,14 @@ var BootstrapDialog = null; }); this.handleModalEvents(); this.setRealized(true); + this.updateTitle(); + this.updateMessage(); + this.updateClosable(); return this; }, open: function() { !this.isRealized() && this.realize(); - this.updateTitle(); - this.updateMessage(); - this.updateClosable(); this.getModal().modal('show'); this.setOpened(true); diff --git a/js/bootstrap-dialog.min.js b/js/bootstrap-dialog.min.js index 2e65a6e..0c53c81 100644 --- a/js/bootstrap-dialog.min.js +++ b/js/bootstrap-dialog.min.js @@ -1 +1 @@ -var BootstrapDialog=null;!function(a){BootstrapDialog=function(b){this.defaultOptions={id:BootstrapDialog.newGuid(),type:BootstrapDialog.TYPE_PRIMARY,size:BootstrapDialog.SIZE_NORMAL,cssClass:"",title:null,message:null,buttons:[],closable:true,spinicon:BootstrapDialog.ICON_SPINNER,data:{},onshow:null,onhide:null,autodestroy:true};this.indexedButtons={};this.registeredButtonHotkeys={};this.realized=false;this.opened=false;this.initOptions(b);this.holdThisInstance()};BootstrapDialog.NAMESPACE="bootstrap-dialog";BootstrapDialog.TYPE_DEFAULT="type-default";BootstrapDialog.TYPE_INFO="type-info";BootstrapDialog.TYPE_PRIMARY="type-primary";BootstrapDialog.TYPE_SUCCESS="type-success";BootstrapDialog.TYPE_WARNING="type-warning";BootstrapDialog.TYPE_DANGER="type-danger";BootstrapDialog.DEFAULT_TEXTS={};BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SUCCESS]="Success";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_WARNING]="Warning";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DANGER]="Danger";BootstrapDialog.SIZE_NORMAL="size-normal";BootstrapDialog.SIZE_LARGE="size-large";BootstrapDialog.BUTTON_SIZES={};BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL]="";BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE]="btn-lg";BootstrapDialog.ICON_SPINNER="glyphicon glyphicon-asterisk";BootstrapDialog.dialogs={};BootstrapDialog.openAll=function(){a.each(BootstrapDialog.dialogs,function(c,b){b.open()})};BootstrapDialog.closeAll=function(){a.each(BootstrapDialog.dialogs,function(c,b){b.close()})};BootstrapDialog.prototype={constructor:BootstrapDialog,initOptions:function(b){this.options=a.extend(true,this.defaultOptions,b);return this},holdThisInstance:function(){BootstrapDialog.dialogs[this.getId()]=this;return this},initModalStuff:function(){this.setModal(this.createModal()).setModalDialog(this.createModalDialog()).setModalContent(this.createModalContent()).setModalHeader(this.createModalHeader()).setModalBody(this.createModalBody()).setModalFooter(this.createModalFooter());this.getModal().append(this.getModalDialog());this.getModalDialog().append(this.getModalContent());this.getModalContent().append(this.getModalHeader()).append(this.getModalBody()).append(this.getModalFooter());return this},createModal:function(){var b=a('');b.prop("id",this.getId());return b},getModal:function(){return this.$modal},setModal:function(b){this.$modal=b;return this},createModalDialog:function(){return a('')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(b){this.$modalDialog=b;return this},createModalContent:function(){return a('')},getModalContent:function(){return this.$modalContent},setModalContent:function(b){this.$modalContent=b;return this},createModalHeader:function(){return a('')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(b){this.$modalHeader=b;return this},createModalBody:function(){return a('')},getModalBody:function(){return this.$modalBody},setModalBody:function(b){this.$modalBody=b;return this},createModalFooter:function(){return a('')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(b){this.$modalFooter=b;return this},createDynamicContent:function(c){var b=null;if(typeof c==="function"){b=c.call(c,this)}else{b=c}if(typeof b==="string"){b=this.formatStringContent(b)}return b},formatStringContent:function(b){return b.replace(/\r\n/g,"
").replace(/[\r\n]/g,"
")},setData:function(b,c){this.options.data[b]=c;return this},getData:function(b){return this.options.data[b]},setId:function(b){this.options.id=b;return this},getId:function(){return this.options.id},getType:function(){return this.options.type},setType:function(b){this.options.type=b;return this},getSize:function(){return this.options.size},setSize:function(b){this.options.size=b;return this},getCssClass:function(){return this.options.cssClass},setCssClass:function(b){this.options.cssClass=b;return this},getTitle:function(){return this.options.title},setTitle:function(b){this.options.title=b;this.updateTitle();return this},updateTitle:function(){if(this.isRealized()){var b=this.getTitle()!==null?this.createDynamicContent(this.getTitle()):this.getDefaultText();this.getModalHeader().find("."+this.getNamespace("title")).html("").append(b)}return this},getMessage:function(){return this.options.message},setMessage:function(b){this.options.message=b;this.updateMessage();return this},updateMessage:function(){if(this.isRealized()){var b=this.createDynamicContent(this.getMessage());this.getModalBody().find("."+this.getNamespace("message")).html("").append(b)}return this},isClosable:function(){return this.options.closable},setClosable:function(b){this.options.closable=b;this.updateClosable();return this},getSpinicon:function(){return this.options.spinicon},setSpinicon:function(b){this.options.spinicon=b;return this},addButton:function(b){this.options.buttons.push(b);return this},addButtons:function(c){var b=this;a.each(c,function(d,e){b.addButton(e)});return this},getButtons:function(){return this.options.buttons},setButtons:function(b){this.options.buttons=b;return this},getButton:function(b){if(typeof this.indexedButtons[b]!=="undefined"){return this.indexedButtons[b]}return null},getButtonSize:function(){if(typeof BootstrapDialog.BUTTON_SIZES[this.getSize()]!=="undefined"){return BootstrapDialog.BUTTON_SIZES[this.getSize()]}return""},isAutodestroy:function(){return this.options.autodestroy},setAutodestroy:function(b){this.options.autodestroy=b},getDefaultText:function(){return BootstrapDialog.DEFAULT_TEXTS[this.getType()]},getNamespace:function(b){return BootstrapDialog.NAMESPACE+"-"+b},createHeaderContent:function(){var b=a("
");b.addClass(this.getNamespace("header"));b.append(this.createTitleContent());b.append(this.createCloseButton());return b},createTitleContent:function(){var b=a("
");b.addClass(this.getNamespace("title"));return b},createCloseButton:function(){var c=a("
");c.addClass(this.getNamespace("close-button"));var b=a('');c.append(b);c.on("click",{dialog:this},function(d){d.data.dialog.close()});return c},createBodyContent:function(){var b=a("
");b.addClass(this.getNamespace("body"));b.append(this.createMessageContent());return b},createMessageContent:function(){var b=a("
");b.addClass(this.getNamespace("message"));return b},createFooterContent:function(){var b=a("
");b.addClass(this.getNamespace("footer"));b.append(this.createFooterButtons());return b},createFooterButtons:function(){var b=this;var c=a("
");c.addClass(this.getNamespace("footer-buttons"));this.indexedButtons={};a.each(this.options.buttons,function(d,e){if(!e.id){e.id=BootstrapDialog.newGuid()}var f=b.createButton(e);b.indexedButtons[e.id]=f;c.append(f)});return c},createButton:function(b){var c=a('');c.addClass(this.getButtonSize());c.prop("id",b.id);if(typeof b.icon!==undefined&&a.trim(b.icon)!==""){c.append(this.createButtonIcon(b.icon))}if(typeof b.label!==undefined){c.append(b.label)}if(typeof b.cssClass!==undefined&&a.trim(b.cssClass)!==""){c.addClass(b.cssClass)}else{c.addClass("btn-default")}if(typeof b.hotkey!==undefined){this.registeredButtonHotkeys[b.hotkey]=c}c.on("click",{dialog:this,$button:c,button:b},function(f){var e=f.data.dialog;var g=f.data.$button;var d=f.data.button;if(typeof d.action==="function"){d.action.call(g,e)}if(d.autospin){g.toggleSpin(true)}});this.enhanceButton(c);return c},enhanceButton:function(b){b.dialog=this;b.toggleEnable=function(c){var d=this;d.prop("disabled",!c).toggleClass("disabled",!c);return d};b.enable=function(){var c=this;c.toggleEnable(true);return c};b.disable=function(){var c=this;c.toggleEnable(false);return c};b.toggleSpin=function(f){var e=this;var d=e.dialog;var c=e.find("."+d.getNamespace("button-icon"));if(f){c.hide();b.prepend(d.createButtonIcon(d.getSpinicon()).addClass("icon-spin"))}else{c.show();b.find(".icon-spin").remove()}return e};b.spin=function(){var c=this;c.toggleSpin(true);return c};b.stopSpin=function(){var c=this;c.toggleSpin(false);return c};return this},createButtonIcon:function(c){var b=a("");b.addClass(this.getNamespace("button-icon")).addClass(c);return b},enableButtons:function(b){a.each(this.indexedButtons,function(d,c){c.toggleEnable(b)});return this},updateClosable:function(){if(this.isRealized()){this.getModalHeader().find("."+this.getNamespace("close-button")).toggle(this.isClosable())}return this},onShow:function(b){this.options.onshow=b;return this},onHide:function(b){this.options.onhide=b;return this},isRealized:function(){return this.realized},setRealized:function(b){this.realized=b;return this},isOpened:function(){return this.opened},setOpened:function(b){this.opened=b;return this},handleModalEvents:function(){this.getModal().on("show.bs.modal",{dialog:this},function(c){var b=c.data.dialog;typeof b.options.onshow==="function"&&b.options.onshow(b);b.showPageScrollBar(true)});this.getModal().on("hide.bs.modal",{dialog:this},function(c){var b=c.data.dialog;typeof b.options.onhide==="function"&&b.options.onhide(b)});this.getModal().on("hidden.bs.modal",{dialog:this},function(c){var b=c.data.dialog;b.isAutodestroy()&&a(this).remove();b.showPageScrollBar(false)});this.getModal().on("click",{dialog:this},function(b){b.target===this&&b.data.dialog.isClosable()&&b.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(b){b.which===27&&b.data.dialog.isClosable()&&b.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(c){var b=c.data.dialog;if(typeof b.registeredButtonHotkeys[c.which]!=="undefined"){var d=a(b.registeredButtonHotkeys[c.which]);!d.prop("disabled")&&d.focus().trigger("click")}});return this},showPageScrollBar:function(b){a(document.body).toggleClass("modal-open",b)},realize:function(){this.initModalStuff();this.getModal().addClass(BootstrapDialog.NAMESPACE).addClass(this.getType()).addClass(this.getSize()).addClass(this.getCssClass());this.getModalFooter().append(this.createFooterContent());this.getModalHeader().append(this.createHeaderContent());this.getModalBody().append(this.createBodyContent());this.getModal().modal({backdrop:"static",keyboard:false,show:false});this.handleModalEvents();this.setRealized(true);return this},open:function(){!this.isRealized()&&this.realize();this.updateTitle();this.updateMessage();this.updateClosable();this.getModal().modal("show");this.setOpened(true);return this},close:function(){this.getModal().modal("hide");if(this.isAutodestroy()){delete BootstrapDialog.dialogs[this.getId()]}this.setOpened(false);return this}};BootstrapDialog.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var d=Math.random()*16|0,b=e==="x"?d:(d&3|8);return b.toString(16)})};BootstrapDialog.show=function(b){return new BootstrapDialog(b).open()};BootstrapDialog.alert=function(b,c){return new BootstrapDialog({message:b,data:{callback:c},closable:false,buttons:[{label:"OK",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(true);d.close()}}]}).open()};BootstrapDialog.confirm=function(b,c){return new BootstrapDialog({title:"Confirmation",message:b,closable:false,data:{callback:c},buttons:[{label:"Cancel",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(false);d.close()}},{label:"OK",cssClass:"btn-primary",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(true);d.close()}}]}).open()}}(window.jQuery); \ No newline at end of file +var BootstrapDialog=null;!function(a){BootstrapDialog=function(b){this.defaultOptions={id:BootstrapDialog.newGuid(),type:BootstrapDialog.TYPE_PRIMARY,size:BootstrapDialog.SIZE_NORMAL,cssClass:"",title:null,message:null,buttons:[],closable:true,spinicon:BootstrapDialog.ICON_SPINNER,data:{},onshow:null,onhide:null,autodestroy:true};this.indexedButtons={};this.registeredButtonHotkeys={};this.realized=false;this.opened=false;this.initOptions(b);this.holdThisInstance()};BootstrapDialog.NAMESPACE="bootstrap-dialog";BootstrapDialog.TYPE_DEFAULT="type-default";BootstrapDialog.TYPE_INFO="type-info";BootstrapDialog.TYPE_PRIMARY="type-primary";BootstrapDialog.TYPE_SUCCESS="type-success";BootstrapDialog.TYPE_WARNING="type-warning";BootstrapDialog.TYPE_DANGER="type-danger";BootstrapDialog.DEFAULT_TEXTS={};BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY]="Information";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SUCCESS]="Success";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_WARNING]="Warning";BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DANGER]="Danger";BootstrapDialog.SIZE_NORMAL="size-normal";BootstrapDialog.SIZE_LARGE="size-large";BootstrapDialog.BUTTON_SIZES={};BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL]="";BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE]="btn-lg";BootstrapDialog.ICON_SPINNER="glyphicon glyphicon-asterisk";BootstrapDialog.dialogs={};BootstrapDialog.openAll=function(){a.each(BootstrapDialog.dialogs,function(c,b){b.open()})};BootstrapDialog.closeAll=function(){a.each(BootstrapDialog.dialogs,function(c,b){b.close()})};BootstrapDialog.prototype={constructor:BootstrapDialog,initOptions:function(b){this.options=a.extend(true,this.defaultOptions,b);return this},holdThisInstance:function(){BootstrapDialog.dialogs[this.getId()]=this;return this},initModalStuff:function(){this.setModal(this.createModal()).setModalDialog(this.createModalDialog()).setModalContent(this.createModalContent()).setModalHeader(this.createModalHeader()).setModalBody(this.createModalBody()).setModalFooter(this.createModalFooter());this.getModal().append(this.getModalDialog());this.getModalDialog().append(this.getModalContent());this.getModalContent().append(this.getModalHeader()).append(this.getModalBody()).append(this.getModalFooter());return this},createModal:function(){var b=a('');b.prop("id",this.getId());return b},getModal:function(){return this.$modal},setModal:function(b){this.$modal=b;return this},createModalDialog:function(){return a('')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(b){this.$modalDialog=b;return this},createModalContent:function(){return a('')},getModalContent:function(){return this.$modalContent},setModalContent:function(b){this.$modalContent=b;return this},createModalHeader:function(){return a('')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(b){this.$modalHeader=b;return this},createModalBody:function(){return a('')},getModalBody:function(){return this.$modalBody},setModalBody:function(b){this.$modalBody=b;return this},createModalFooter:function(){return a('')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(b){this.$modalFooter=b;return this},createDynamicContent:function(c){var b=null;if(typeof c==="function"){b=c.call(c,this)}else{b=c}if(typeof b==="string"){b=this.formatStringContent(b)}return b},formatStringContent:function(b){return b.replace(/\r\n/g,"
").replace(/[\r\n]/g,"
")},setData:function(b,c){this.options.data[b]=c;return this},getData:function(b){return this.options.data[b]},setId:function(b){this.options.id=b;return this},getId:function(){return this.options.id},getType:function(){return this.options.type},setType:function(b){this.options.type=b;return this},getSize:function(){return this.options.size},setSize:function(b){this.options.size=b;return this},getCssClass:function(){return this.options.cssClass},setCssClass:function(b){this.options.cssClass=b;return this},getTitle:function(){return this.options.title},setTitle:function(b){this.options.title=b;this.updateTitle();return this},updateTitle:function(){if(this.isRealized()){var b=this.getTitle()!==null?this.createDynamicContent(this.getTitle()):this.getDefaultText();this.getModalHeader().find("."+this.getNamespace("title")).html("").append(b)}return this},getMessage:function(){return this.options.message},setMessage:function(b){this.options.message=b;this.updateMessage();return this},updateMessage:function(){if(this.isRealized()){var b=this.createDynamicContent(this.getMessage());this.getModalBody().find("."+this.getNamespace("message")).html("").append(b)}return this},isClosable:function(){return this.options.closable},setClosable:function(b){this.options.closable=b;this.updateClosable();return this},getSpinicon:function(){return this.options.spinicon},setSpinicon:function(b){this.options.spinicon=b;return this},addButton:function(b){this.options.buttons.push(b);return this},addButtons:function(c){var b=this;a.each(c,function(d,e){b.addButton(e)});return this},getButtons:function(){return this.options.buttons},setButtons:function(b){this.options.buttons=b;return this},getButton:function(b){if(typeof this.indexedButtons[b]!=="undefined"){return this.indexedButtons[b]}return null},getButtonSize:function(){if(typeof BootstrapDialog.BUTTON_SIZES[this.getSize()]!=="undefined"){return BootstrapDialog.BUTTON_SIZES[this.getSize()]}return""},isAutodestroy:function(){return this.options.autodestroy},setAutodestroy:function(b){this.options.autodestroy=b},getDefaultText:function(){return BootstrapDialog.DEFAULT_TEXTS[this.getType()]},getNamespace:function(b){return BootstrapDialog.NAMESPACE+"-"+b},createHeaderContent:function(){var b=a("
");b.addClass(this.getNamespace("header"));b.append(this.createTitleContent());b.append(this.createCloseButton());return b},createTitleContent:function(){var b=a("
");b.addClass(this.getNamespace("title"));return b},createCloseButton:function(){var c=a("
");c.addClass(this.getNamespace("close-button"));var b=a('');c.append(b);c.on("click",{dialog:this},function(d){d.data.dialog.close()});return c},createBodyContent:function(){var b=a("
");b.addClass(this.getNamespace("body"));b.append(this.createMessageContent());return b},createMessageContent:function(){var b=a("
");b.addClass(this.getNamespace("message"));return b},createFooterContent:function(){var b=a("
");b.addClass(this.getNamespace("footer"));b.append(this.createFooterButtons());return b},createFooterButtons:function(){var b=this;var c=a("
");c.addClass(this.getNamespace("footer-buttons"));this.indexedButtons={};a.each(this.options.buttons,function(d,e){if(!e.id){e.id=BootstrapDialog.newGuid()}var f=b.createButton(e);b.indexedButtons[e.id]=f;c.append(f)});return c},createButton:function(b){var c=a('');c.addClass(this.getButtonSize());c.prop("id",b.id);if(typeof b.icon!==undefined&&a.trim(b.icon)!==""){c.append(this.createButtonIcon(b.icon))}if(typeof b.label!==undefined){c.append(b.label)}if(typeof b.cssClass!==undefined&&a.trim(b.cssClass)!==""){c.addClass(b.cssClass)}else{c.addClass("btn-default")}if(typeof b.hotkey!==undefined){this.registeredButtonHotkeys[b.hotkey]=c}c.on("click",{dialog:this,$button:c,button:b},function(f){var e=f.data.dialog;var g=f.data.$button;var d=f.data.button;if(typeof d.action==="function"){d.action.call(g,e)}if(d.autospin){g.toggleSpin(true)}});this.enhanceButton(c);return c},enhanceButton:function(b){b.dialog=this;b.toggleEnable=function(c){var d=this;d.prop("disabled",!c).toggleClass("disabled",!c);return d};b.enable=function(){var c=this;c.toggleEnable(true);return c};b.disable=function(){var c=this;c.toggleEnable(false);return c};b.toggleSpin=function(f){var e=this;var d=e.dialog;var c=e.find("."+d.getNamespace("button-icon"));if(f){c.hide();b.prepend(d.createButtonIcon(d.getSpinicon()).addClass("icon-spin"))}else{c.show();b.find(".icon-spin").remove()}return e};b.spin=function(){var c=this;c.toggleSpin(true);return c};b.stopSpin=function(){var c=this;c.toggleSpin(false);return c};return this},createButtonIcon:function(c){var b=a("");b.addClass(this.getNamespace("button-icon")).addClass(c);return b},enableButtons:function(b){a.each(this.indexedButtons,function(d,c){c.toggleEnable(b)});return this},updateClosable:function(){if(this.isRealized()){this.getModalHeader().find("."+this.getNamespace("close-button")).toggle(this.isClosable())}return this},onShow:function(b){this.options.onshow=b;return this},onHide:function(b){this.options.onhide=b;return this},isRealized:function(){return this.realized},setRealized:function(b){this.realized=b;return this},isOpened:function(){return this.opened},setOpened:function(b){this.opened=b;return this},handleModalEvents:function(){this.getModal().on("show.bs.modal",{dialog:this},function(c){var b=c.data.dialog;typeof b.options.onshow==="function"&&b.options.onshow(b);b.showPageScrollBar(true)});this.getModal().on("hide.bs.modal",{dialog:this},function(c){var b=c.data.dialog;typeof b.options.onhide==="function"&&b.options.onhide(b)});this.getModal().on("hidden.bs.modal",{dialog:this},function(c){var b=c.data.dialog;b.isAutodestroy()&&a(this).remove();b.showPageScrollBar(false)});this.getModal().on("click",{dialog:this},function(b){b.target===this&&b.data.dialog.isClosable()&&b.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(b){b.which===27&&b.data.dialog.isClosable()&&b.data.dialog.close()});this.getModal().on("keyup",{dialog:this},function(c){var b=c.data.dialog;if(typeof b.registeredButtonHotkeys[c.which]!=="undefined"){var d=a(b.registeredButtonHotkeys[c.which]);!d.prop("disabled")&&d.focus().trigger("click")}});return this},showPageScrollBar:function(b){a(document.body).toggleClass("modal-open",b)},realize:function(){this.initModalStuff();this.getModal().addClass(BootstrapDialog.NAMESPACE).addClass(this.getType()).addClass(this.getSize()).addClass(this.getCssClass());this.getModalFooter().append(this.createFooterContent());this.getModalHeader().append(this.createHeaderContent());this.getModalBody().append(this.createBodyContent());this.getModal().modal({backdrop:"static",keyboard:false,show:false});this.handleModalEvents();this.setRealized(true);this.updateTitle();this.updateMessage();this.updateClosable();return this},open:function(){!this.isRealized()&&this.realize();this.getModal().modal("show");this.setOpened(true);return this},close:function(){this.getModal().modal("hide");if(this.isAutodestroy()){delete BootstrapDialog.dialogs[this.getId()]}this.setOpened(false);return this}};BootstrapDialog.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var d=Math.random()*16|0,b=e==="x"?d:(d&3|8);return b.toString(16)})};BootstrapDialog.show=function(b){return new BootstrapDialog(b).open()};BootstrapDialog.alert=function(b,c){return new BootstrapDialog({message:b,data:{callback:c},closable:false,buttons:[{label:"OK",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(true);d.close()}}]}).open()};BootstrapDialog.confirm=function(b,c){return new BootstrapDialog({title:"Confirmation",message:b,closable:false,data:{callback:c},buttons:[{label:"Cancel",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(false);d.close()}},{label:"OK",cssClass:"btn-primary",action:function(d){typeof d.getData("callback")==="function"&&d.getData("callback")(true);d.close()}}]}).open()}}(window.jQuery); \ No newline at end of file