PluginProbe
MaxButtons – Create buttons / 6.27
MaxButtons – Create buttons v6.27
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / js / min / maxmodal.js

maxmodal.js in MaxButtons – Create buttons 6.27, at js/min/maxmodal.js

1 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var maxModal;jQuery(document).ready(function(t){(maxModal=function(){}).prototype={currentModal:null,modals:[],controls:[],parent:"#maxbuttons",multiple:!1,windowHeight:!1,windowWidth:!1,setWidth:!1,setHeight:!1,target:!1},maxModal.prototype.init=function(){this.windowHeight=t(window).height(),this.windowWidth=t(window).width(),t(document).on("click",".maxmodal",t.proxy(this.buildModal,this)),t(window).on("resize",t.proxy(this.checkResize,this))},maxModal.prototype.focus=function(){this.currentModal.show()},maxModal.prototype.get=function(){return this.currentModal},maxModal.prototype.show=function(){t(".maxmodal_overlay").remove(),t("body").removeClass("max-modal-active"),this.writeOverlay(),this.setWidth&&this.currentModal.width(this.setWidth),this.setHeight&&this.currentModal.height(this.setHeight);var o=this.currentModal.height(),e=this.currentModal.width(),a=(this.windowHeight-o)/2,i=(this.windowWidth-e)/2;a<30&&(a=30),o>this.windowHeight&&this.currentModal.height(this.windowHeight-a-5+"px"),this.currentModal.css("left",i+"px"),this.currentModal.css("top",a+"px"),this.currentModal.css("height",o),this.currentModal.show(),t(".maxmodal_overlay").show(),t("body").addClass("max-modal-active"),t(document).off("keydown",t.proxy(this.keyPressHandler,this)),t(document).on("keydown",t.proxy(this.keyPressHandler,this)),this.currentModal.focus()},maxModal.prototype.keyPressHandler=function(t){27===t.keyCode&&this.close()},maxModal.prototype.checkResize=function(){this.windowHeight=t(window).height(),this.windowWidth=t(window).width(),null!==this.currentModal&&(this.currentModal.removeAttr("style"),this.currentModal.find(".modal_content").removeAttr("style"),this.show())},maxModal.prototype.close=function(){this.currentModal.trigger("modal_close",[this]),this.currentModal.remove(),this.currentModal=null,t(".maxmodal_overlay").remove(),t("body").removeClass("max-modal-active"),t(document).off("keydown",t.proxy(this.keyPressHandler,this))},maxModal.prototype.fadeOut=function(t){void 0==typeof t&&(t=600);var o=this;this.currentModal.fadeOut(t,function(){o.close()})},maxModal.prototype.setTitle=function(t){this.currentModal.find(".modal_title").text(t)},maxModal.prototype.setControls=function(o){var e=this.currentModal.find(".modal_content"),a=t('<div class="controls">');for(i=0;i<this.controls.length;i++)a.append(this.controls[i]);void 0!==o&&a.append(o),e.append(a),t(this.currentModal).find(".modal_close").off("click"),t(this.currentModal).find(".modal_close").on("click",t.proxy(this.close,this))},maxModal.prototype.addControl=function(o,e,a){var i="";switch(o){case"yes":i=modaltext.yes;break;case"ok":i=modaltext.ok;break;case"no":i=modaltext.no;break;case"cancel":i=modaltext.cancel;break;case"insert":i=mbtrans.insert}var d=t('<a class="button-primary '+o+'">'+i+"</a>");d.on("click",e,a),this.controls.push(d)},maxModal.prototype.setContent=function(t){this.currentModal.find(".modal_content").html(t)},maxModal.prototype.buildModal=function(o){o.preventDefault();var e=t(o.target);void 0===e.data("modal")&&(e=e.parents(".maxmodal")),this.target=e;var a=e.data("modal"),i=t("#"+a);void 0!==i.data("width")?this.setWidth=i.data("width"):this.setWidth=!1,void 0!==i.data("height")?this.setHeight=i.data("height"):this.setHeight=!1;var d=t(i).find(".title").text(),s=t(i).find(".controls").html(),n=t(i).find(".content").html();if(this.newModal(a),this.setTitle(d),this.setContent(n),this.setControls(s),void 0!==t(i).data("load")){var l=i.data("load")+"(modal)",r=new Function("modal",l);try{r(this)}catch(t){console.log("MB Modal Callback Error: "+t.message),console.log("MB Mobdal tried calling: "+l)}}this.show()},maxModal.prototype.newModal=function(o){null!==this.currentModal&&this.close();var e=t('<div class="max-modal '+o+'" > \t\t\t\t\t\t <div class="modal_header"> \t\t\t\t\t\t\t <div class="modal_close dashicons dashicons-no"></div><h3 class="modal_title"></h3> \t\t\t\t\t\t </div> \t\t\t\t\t\t <div class="inner modal_content"></div>\t\t\t\t\t </div>');return t(this.parent).length>0?t(this.parent).append(e):t("body").append(e),t(e).draggable({handle:".modal_header"}),this.modals.push(e),this.currentModal=e,this.controls=[],this},maxModal.prototype.writeOverlay=function(){t(this.parent).append('<div class="maxmodal_overlay"></div>'),t(".maxmodal_overlay").on("click",t.proxy(this.close,this))}});