virt2/api/soft/tinymce/4.3.12/plugins/image2/js/bootstrap-modalmanager.min.js

1 line
5.8 KiB
JavaScript
Raw Normal View History

!function(e){"use strict";function r(e){return function(t){if(this===t.target){return e.apply(this,arguments)}}}var t=function(e,t){this.init(e,t)};t.prototype={constructor:t,init:function(t,n){this.$element=e(t);this.options=e.extend({},e.fn.modalmanager.defaults,this.$element.data(),typeof n=="object"&&n);this.stack=[];this.backdropCount=0;if(this.options.resize){var r,i=this;e(window).on("resize.modal",function(){r&&clearTimeout(r);r=setTimeout(function(){for(var e=0;e<i.stack.length;e++){i.stack[e].isShown&&i.stack[e].layout()}},10)})}},createModal:function(t,n){e(t).modal(e.extend({manager:this},n))},appendModal:function(t){this.stack.push(t);var n=this;t.$element.on("show.modalmanager",r(function(r){var i=function(){t.isShown=true;var r=e.support.transition&&t.$element.hasClass("fade");n.$element.toggleClass("modal-open",n.hasOpenModal()).toggleClass("page-overflow",e(window).height()<n.$element.height());t.$parent=t.$element.parent();t.$container=n.createContainer(t);t.$element.appendTo(t.$container);n.backdrop(t,function(){t.$element.show();if(r){t.$element[0].offsetWidth}t.layout();t.$element.addClass("in").attr("aria-hidden",false);var i=function(){n.setFocus();t.$element.trigger("shown")};r?t.$element.one(e.support.transition.end,i):i()})};t.options.replace?n.replace(i):i()}));t.$element.on("hidden.modalmanager",r(function(r){n.backdrop(t);if(t.$backdrop){e.support.transition&&t.$element.hasClass("fade")?t.$backdrop.one(e.support.transition.end,function(){n.destroyModal(t)}):n.destroyModal(t)}else{n.destroyModal(t)}}));t.$element.on("destroy.modalmanager",r(function(e){n.removeModal(t)}))},destroyModal:function(e){e.destroy();var t=this.hasOpenModal();this.$element.toggleClass("modal-open",t);if(!t){this.$element.removeClass("page-overflow")}this.removeContainer(e);this.setFocus()},hasOpenModal:function(){for(var e=0;e<this.stack.length;e++){if(this.stack[e].isShown)return true}return false},setFocus:function(){var e;for(var t=0;t<this.stack.length;t++){if(this.stack[t].isShown)e=this.stack[t]}if(!e)return;e.focus()},removeModal:function(e){e.$element.off(".modalmanager");if(e.$backdrop)this.removeBackdrop(e);this.stack.splice(this.getIndexOfModal(e),1)},getModalAt:function(e){return this.stack[e]},getIndexOfModal:function(e){for(var t=0;t<this.stack.length;t++){if(e===this.stack[t])return t}},replace:function(t){var n;for(var i=0;i<this.stack.length;i++){if(this.stack[i].isShown)n=this.stack[i]}if(n){this.$backdropHandle=n.$backdrop;n.$backdrop=null;t&&n.$element.one("hidden",r(e.proxy(t,this)));n.hide()}else if(t){t()}},removeBackdrop:function(e){e.$backdrop.remove();e.$backdrop=null},createBackdrop:function(t){var n;if(!this.$backdropHandle){n=e('<div class="modal-backdrop '+t+'" />').appendTo(this.$element)}else{n=this.$backdropHandle;n.off(".modalmanager");this.$backdropHandle=null;this.isLoading&&this.removeSpinner()}return n},removeContainer:function(e){e.$container.remove();e.$container=null},createContainer:function(t){var i;i=e('<div class="modal-scrollable">').css("z-index",n("modal",t?this.getIndexOfModal(t):this.stack.length)).appendTo(this.$element);if(t&&t.options.backdrop!="static"){i.on("click.modal",r(function(e){t.hide()}))}else if(t){i.on("click.modal",r(function(e){t.attention()}))}return i},backdrop:function(t,r){var i=t.$element.hasClass("fade")?"fade":"",s=t.options.backdrop&&this.backdropCount<this.options.backdropLimit;if(t.isShown&&s){var o=e.support.transition&&i&&!this.$backdropHandle;t.$backdrop=this.createBackdrop(i);t.$backdrop.css("z-index",n("backdrop",this.getIndexOfModal(t)));if(o)t.$backdrop[0].offsetWidth;t.$backdrop.addClass("in");this.backdropCount+=1;o?t.$backdrop.one(e.support.transition.end,r):r()}else if(!t.isShown&&t.$backdrop){t.$backdrop.removeClass("in");this.backdropCount-=1;var u=this;e.support.transition&&t.$element.hasClass("fade")?t.$backdrop.one(e.support.transition.end,function(){u.removeBackdrop(t)}):u.removeBackdrop(t)}else if(r){r()}},removeSpinner:function(){this.$spinner&&this.$spinner.remove();this.$spinner=null;this.isLoading=false},removeLoading:f