diff --git a/bower.json b/bower.json index 80a86fe..ef5e20a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ax5ui-modal", - "version": "1.4.29", + "version": "1.4.30", "authors": [ "ThomasJ " ], diff --git a/dist/ax5modal.js b/dist/ax5modal.js index b0e4c17..3477df7 100755 --- a/dist/ax5modal.js +++ b/dist/ax5modal.js @@ -15,7 +15,7 @@ UI.addClass({ className: "modal", - version: "1.4.29" + version: "1.4.30" }, function () { /** * @class ax5modal diff --git a/dist/ax5modal.min.js b/dist/ax5modal.min.js index 2706c79..4037449 100755 --- a/dist/ax5modal.min.js +++ b/dist/ax5modal.min.js @@ -1 +1 @@ -"use strict";!function(){var t=ax5.ui,e=ax5.util,i=void 0;t.addClass({className:"modal",version:"1.4.29"},function(){return function(){var o=this,d=void 0,a={mousedown:ax5.info.supportTouch?"touchstart":"mousedown",mousemove:ax5.info.supportTouch?"touchmove":"mousemove",mouseup:ax5.info.supportTouch?"touchend":"mouseup"},h=function(t){var e=t;return"changedTouches"in t&&t.changedTouches&&(e=t.changedTouches[0]),{clientX:e.clientX,clientY:e.clientY}};this.instanceId=ax5.getGuid(),this.config={id:"ax5-modal-"+this.instanceId,position:{left:"center",top:"middle",margin:10},minimizePosition:"bottom-right",clickEventName:"click",theme:"default",width:300,height:400,closeToEsc:!0,disableDrag:!1,disableResize:!1,animateTime:250,iframe:!1},this.activeModal=null,this.watingModal=!1,this.$={},d=this.config;var n=function(t,e){var i={resize:function(e){t&&t.onResize?t.onResize.call(e,e):this.onResize&&this.onResize.call(e,e)},move:function(){}};return e.state in i&&i[e.state].call(this,e),t&&t.onStateChanged?t.onStateChanged.call(e,e):this.onStateChanged&&this.onStateChanged.call(e,e),!0},s=function(t,e){var o={modalId:t,theme:e.theme,header:e.header,fullScreen:e.fullScreen?"fullscreen":"",styles:"",iframe:e.iframe,iframeLoadingMsg:e.iframeLoadingMsg,disableResize:e.disableResize};return e.zIndex&&(o.styles+="z-index:"+e.zIndex+";"),e.absolute&&(o.styles+="position:absolute;"),o.iframe&&"string"==typeof o.iframe.param&&(o.iframe.param=ax5.util.param(o.iframe.param)),i.tmpl.get.call(this,"content",o,{})},l=function(t,i){var l=void 0;jQuery(document.body).append(s.call(this,t.id,t)),this.activeModal=jQuery("#"+t.id),this.$={root:this.activeModal,header:this.activeModal.find('[data-modal-els="header"]'),body:this.activeModal.find('[data-modal-els="body"]')},t.iframe?(this.$["iframe-wrap"]=this.activeModal.find('[data-modal-els="iframe-wrap"]'),this.$.iframe=this.activeModal.find('[data-modal-els="iframe"]'),this.$["iframe-form"]=this.activeModal.find('[data-modal-els="iframe-form"]'),this.$["iframe-loading"]=this.activeModal.find('[data-modal-els="iframe-loading"]')):this.$["body-frame"]=this.activeModal.find('[data-modal-els="body-frame"]'),this.align(),l={self:this,id:t.id,theme:t.theme,width:t.width,height:t.height,state:"open",$:this.$},t.iframe&&(this.$["iframe-wrap"].css({height:t.height}),this.$.iframe.css({height:t.height}),this.$["iframe-form"].attr({method:t.iframe.method}),this.$["iframe-form"].attr({target:t.id+"-frame"}),this.$["iframe-form"].attr({action:t.iframe.url}),this.$.iframe.on("load",function(){l.state="load",t.iframeLoadingMsg&&this.$["iframe-loading"].hide(),n.call(this,t,l)}.bind(this)),t.iframeLoadingMsg||this.$.iframe.show(),this.$["iframe-form"].submit()),i&&i.call(l,l),this.watingModal||n.call(this,t,l),t.closeToEsc&&jQuery(window).bind("keydown.ax-modal",function(t){f.call(this,t||window.event)}.bind(this)),jQuery(window).bind("resize.ax-modal",function(t){this.align(null,t||window.event)}.bind(this)),this.activeModal.on(d.clickEventName,"[data-modal-header-btn]",function(e){r.call(this,e||window.event,t)}.bind(this)),this.$.header.off(a.mousedown).off("dragstart").on(a.mousedown,function(i){if(t.isFullScreen)return!1;var d=e.findParentNode(i.target,function(t){if(t.getAttribute("data-modal-header-btn"))return!0});d||1==t.disableDrag||(o.mousePosition=h(i),c.on.call(o))}).on("dragstart",function(t){return e.stopEvent(t.originalEvent),!1}),this.activeModal.off(a.mousedown).off("dragstart").on(a.mousedown,"[data-ax5modal-resizer]",function(e){return!t.disableDrag&&!t.isFullScreen&&(o.mousePosition=h(e),void u.on.call(o,this.getAttribute("data-ax5modal-resizer")))}).on("dragstart",function(t){return e.stopEvent(t.originalEvent),!1})},r=function(t,i,o,d,a){var h=void 0;t.srcElement&&(t.target=t.srcElement),d=e.findParentNode(t.target,function(t){if(t.getAttribute("data-modal-header-btn"))return!0}),d&&(a=d.getAttribute("data-modal-header-btn"),h={self:this,key:a,value:i.header.btns[a],dialogId:i.id,btnTarget:d},i.header.btns[a].onClick&&i.header.btns[a].onClick.call(h,a)),h=null,i=null,o=null,d=null,a=null},f=function(t){t.keyCode==ax5.info.eventKeys.ESC&&this.close()},m={"top-left":function(){this.align({left:"left",top:"top"})},"top-right":function(){this.align({left:"right",top:"top"})},"bottom-left":function(){this.align({left:"left",top:"bottom"})},"bottom-right":function(){this.align({left:"right",top:"bottom"})},"center-middle":function(){this.align({left:"center",top:"middle"})}},c={on:function(){var t=this.activeModal.css("z-index"),e=this.activeModal.position(),i={width:this.activeModal.outerWidth(),height:this.activeModal.outerHeight()},d={width:jQuery(window).width(),height:jQuery(window).height(),scrollLeft:o.modalConfig.absolute?0:jQuery(document).scrollLeft(),scrollTop:o.modalConfig.absolute?0:jQuery(document).scrollTop()},h=function(t){return o.__dx=t.clientX-o.mousePosition.clientX,o.__dy=t.clientY-o.mousePosition.clientY,n>e.left+o.__dx?o.__dx=-e.left:se.top+o.__dy?o.__dy=-e.top:r'),o.resizer=jQuery('
'),o.resizerBg.css({zIndex:t}),o.resizer.css({left:e.left+d.scrollLeft,top:e.top+d.scrollTop,width:i.width,height:i.height,zIndex:t+1}),jQuery(document.body).append(o.resizerBg).append(o.resizer),o.activeModal.addClass("draged"),jQuery(document.body).on(a.mousemove+".ax5modal-move-"+this.instanceId,function(t){o.resizer.css(h(t))}).on(a.mouseup+".ax5modal-move-"+this.instanceId,function(t){c.off.call(o)}).on("mouseleave.ax5modal-move-"+this.instanceId,function(t){c.off.call(o)}),jQuery(document.body).attr("unselectable","on").css("user-select","none").on("selectstart",!1)},off:function(){var t=function(){var t=this.resizer.offset();this.modalConfig.absolute||(t.left-=jQuery(document).scrollLeft(),t.top-=jQuery(document).scrollTop()),this.activeModal.css(t),this.modalConfig.left=t.left,this.modalConfig.top=t.top,t=null};this.activeModal.removeClass("draged"),t.call(this),this.resizer.remove(),this.resizer=null,this.resizerBg.remove(),this.resizerBg=null,jQuery(document.body).off(a.mousemove+".ax5modal-move-"+this.instanceId).off(a.mouseup+".ax5modal-move-"+this.instanceId).off("mouseleave.ax5modal-move-"+this.instanceId),jQuery(document.body).removeAttr("unselectable").css("user-select","auto").off("selectstart"),n.call(this,o.modalConfig,{self:this,state:"move"})}},u={on:function(t){var e=this.activeModal.css("z-index"),i=this.activeModal.position(),d={width:this.activeModal.outerWidth(),height:this.activeModal.outerHeight()},h={width:jQuery(window).width(),height:jQuery(window).height(),scrollLeft:this.modalConfig.absolute?0:jQuery(document).scrollLeft(),scrollTop:this.modalConfig.absolute?0:jQuery(document).scrollTop()},n={top:function(t){return r>d.height-o.__dy&&(o.__dy=d.height-r),t.shiftKey?(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),{left:i.left,top:i.top+o.__dy,width:d.width,height:d.height-2*o.__dy}):t.altKey?(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),{left:i.left+o.__dy,top:i.top+o.__dy,width:d.width-2*o.__dy,height:d.height-2*o.__dy}):{left:i.left,top:i.top+o.__dy,width:d.width,height:d.height-o.__dy}},bottom:function(t){return r>d.height+o.__dy&&(o.__dy=-d.height+r),t.shiftKey?(r>d.height+2*o.__dy&&(o.__dy=(-d.height+r)/2),{left:i.left,top:i.top-o.__dy,width:d.width,height:d.height+2*o.__dy}):t.altKey?(r>d.height+2*o.__dy&&(o.__dy=(-d.height+r)/2),{left:i.left-o.__dy,top:i.top-o.__dy,width:d.width+2*o.__dy,height:d.height+2*o.__dy}):{left:i.left,top:i.top,width:d.width,height:d.height+o.__dy}},left:function(t){return l>d.width-o.__dx&&(o.__dx=d.width-l),t.shiftKey?(l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),{left:i.left+o.__dx,top:i.top,width:d.width-2*o.__dx,height:d.height}):t.altKey?(l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),{left:i.left+o.__dx,top:i.top+o.__dx,width:d.width-2*o.__dx,height:d.height-2*o.__dx}):{left:i.left+o.__dx,top:i.top,width:d.width-o.__dx,height:d.height}},right:function(t){return l>d.width+o.__dx&&(o.__dx=-d.width+l),t.shiftKey?(l>d.width+2*o.__dx&&(o.__dx=(-d.width+l)/2),{left:i.left-o.__dx,top:i.top,width:d.width+2*o.__dx,height:d.height}):t.altKey?(l>d.width+2*o.__dx&&(o.__dx=(-d.width+l)/2),{left:i.left-o.__dx,top:i.top-o.__dx,width:d.width+2*o.__dx,height:d.height+2*o.__dx}):{left:i.left,top:i.top,width:d.width+o.__dx,height:d.height}},"top-left":function(t){return l>d.width-o.__dx&&(o.__dx=d.width-l),r>d.height-o.__dy&&(o.__dy=d.height-r),t.shiftKey||t.altKey?(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),{left:i.left+o.__dx,top:i.top+o.__dy,width:d.width-2*o.__dx,height:d.height-2*o.__dy}):(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),{left:i.left+o.__dx,top:i.top+o.__dy,width:d.width-o.__dx,height:d.height-o.__dy})},"top-right":function(t){return l>d.width+o.__dx&&(o.__dx=-d.width+l),r>d.height-o.__dy&&(o.__dy=d.height-r),t.shiftKey||t.altKey?(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),l>d.width+2*o.__dx&&(o.__dx=(-d.width+l)/2),{left:i.left-o.__dx,top:i.top+o.__dy,width:d.width+2*o.__dx,height:d.height-2*o.__dy}):{left:i.left,top:i.top+o.__dy,width:d.width+o.__dx,height:d.height-o.__dy}},"bottom-left":function(t){return l>d.width-o.__dx&&(o.__dx=d.width-l),r>d.height+o.__dy&&(o.__dy=-d.height+r),t.shiftKey||t.altKey?(l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),r>d.height+2*o.__dy&&(o.__dy=(-d.height+r)/2),{left:i.left+o.__dx,top:i.top-o.__dy,width:d.width-2*o.__dx,height:d.height+2*o.__dy}):{left:i.left+o.__dx,top:i.top,width:d.width-o.__dx,height:d.height+o.__dy}},"bottom-right":function(t){return l>d.width+o.__dx&&(o.__dx=-d.width+l),r>d.height+o.__dy&&(o.__dy=-d.height+r),t.shiftKey||t.altKey?(l>d.width+2*o.__dx&&(o.__dx=(-d.width+l)/2),r>d.height+2*o.__dy&&(o.__dy=(-d.height+r)/2),{left:i.left-o.__dx,top:i.top-o.__dy,width:d.width+2*o.__dx,height:d.height+2*o.__dy}):{left:i.left,top:i.top,width:d.width+o.__dx,height:d.height+o.__dy}}},s=function(e){return o.__dx=e.clientX-o.mousePosition.clientX,o.__dy=e.clientY-o.mousePosition.clientY,n[t](e)};this.modalConfig.absolute||(i.left+=h.scrollLeft,i.top+=h.scrollTop);var l=100,r=100,f={top:"row-resize",bottom:"row-resize",left:"col-resize",right:"col-resize","top-left":"nwse-resize","top-right":"nesw-resize","bottom-left":"nesw-resize","bottom-right":"nwse-resize"};o.__dx=0,o.__dy=0,o.resizerBg=jQuery('
'),o.resizer=jQuery('
'),o.resizerBg.css({zIndex:e,cursor:f[t]}),o.resizer.css({left:i.left,top:i.top,width:d.width,height:d.height,zIndex:e+1,cursor:f[t]}),jQuery(document.body).append(o.resizerBg).append(o.resizer),o.activeModal.addClass("draged"),jQuery(document.body).bind(a.mousemove+".ax5modal-resize-"+this.instanceId,function(t){o.resizer.css(s(t))}).bind(a.mouseup+".ax5modal-resize-"+this.instanceId,function(t){u.off.call(o)}).bind("mouseleave.ax5modal-resize-"+this.instanceId,function(t){u.off.call(o)}),jQuery(document.body).attr("unselectable","on").css("user-select","none").bind("selectstart",!1)},off:function(){var t=function(){var t=this.resizer.offset();jQuery.extend(t,{width:this.resizer.width(),height:this.resizer.height()}),this.modalConfig.absolute||(t.left-=jQuery(document).scrollLeft(),t.top-=jQuery(document).scrollTop()),this.activeModal.css(t),this.modalConfig.left=t.left,this.modalConfig.top=t.top,this.modalConfig.width=t.width,this.modalConfig.height=t.height,this.$.body.css({height:t.height-this.modalConfig.headerHeight}),this.modalConfig.iframe&&(this.$["iframe-wrap"].css({height:t.height-this.modalConfig.headerHeight}),this.$.iframe.css({height:t.height-this.modalConfig.headerHeight})),t=null};this.activeModal.removeClass("draged"),t.call(this),this.resizer.remove(),this.resizer=null,this.resizerBg.remove(),this.resizerBg=null,n.call(this,o.modalConfig,{self:this,state:"resize"}),jQuery(document.body).unbind(a.mousemove+".ax5modal-resize-"+this.instanceId).unbind(a.mouseup+".ax5modal-resize-"+this.instanceId).unbind("mouseleave.ax5modal-resize-"+this.instanceId),jQuery(document.body).removeAttr("unselectable").css("user-select","auto").unbind("selectstart")}};this.init=function(){this.onStateChanged=d.onStateChanged,this.onResize=d.onResize},this.open=function(t,e,i){return"undefined"==typeof i&&(i=0),this.activeModal?i<3&&(this.watingModal=!0,setTimeout(function(){this.open(t,e,i+1)}.bind(this),d.animateTime)):(t=o.modalConfig=jQuery.extend(!0,{},d,t),l.call(this,t,e),this.watingModal=!1),this},this.close=function(t){return this.activeModal&&(t=o.modalConfig,this.activeModal.addClass("destroy"),jQuery(window).unbind("keydown.ax-modal"),jQuery(window).unbind("resize.ax-modal"),setTimeout(function(){if(this.activeModal){if(t.iframe){var e=this.$.iframe;if(e){var i=e.get(0),o=i.contentDocument?i.contentDocument:i.contentWindow.document;try{$(o.body).children().each(function(){$(this).remove()})}catch(d){}o.innerHTML="",e.attr("src","about:blank").remove(),window.CollectGarbage&&window.CollectGarbage()}}this.activeModal.remove(),this.activeModal=null}this.watingModal||n.call(this,t,{self:this,state:"close"})}.bind(this),d.animateTime)),this.minimized=!1,this},this.minimize=function(){return function(t){if(this.minimized!==!0){var e=o.modalConfig;"undefined"==typeof t&&(t=d.minimizePosition),this.minimized=!0,this.$.body.hide(),o.modalConfig.originalHeight=e.height,o.modalConfig.height=0,m[t].call(this),n.call(this,e,{self:this,state:"minimize"})}return this}}(),this.restore=function(){var t=o.modalConfig;return this.minimized&&(this.minimized=!1,this.$.body.show(),o.modalConfig.height=o.modalConfig.originalHeight,o.modalConfig.originalHeight=void 0,this.align({left:"center",top:"middle"}),n.call(this,t,{self:this,state:"restore"})),this},this.css=function(t){return this.activeModal&&!o.fullScreen&&(this.activeModal.css(t),t.width&&(o.modalConfig.width=this.activeModal.width()),t.height&&(o.modalConfig.height=this.activeModal.height(),this.$.iframe&&(this.$["iframe-wrap"].css({height:o.modalConfig.height}),this.$.iframe.css({height:o.modalConfig.height})))),this},this.setModalConfig=function(t){return o.modalConfig=jQuery.extend({},o.modalConfig,t),this.align(),this},this.align=function(){return function(t,i){if(!this.activeModal)return this;var d=o.modalConfig,a={width:d.width,height:d.height},h=d.isFullScreen=function(t){return"undefined"!=typeof t&&(e.isFunction(t)?t():void 0)}(d.fullScreen);return h?(d.header&&this.$.header.show(),a.width=jQuery(window).width(),a.height=d.height,a.left=0,a.top=0):(d.header&&this.$.header.show(),t&&jQuery.extend(!0,d.position,t),d.header?(d.headerHeight=this.$.header.outerHeight(),a.height+=d.headerHeight):d.headerHeight=0,"left"==d.position.left?a.left=d.position.margin||0:"right"==d.position.left?a.left=jQuery(window).width()-a.width-(d.position.margin||0):"center"==d.position.left?a.left=jQuery(window).width()/2-a.width/2:a.left=d.position.left||0,"top"==d.position.top?a.top=d.position.margin||0:"bottom"==d.position.top?a.top=jQuery(window).height()-a.height-(d.position.margin||0):"middle"==d.position.top?a.top=jQuery(window).height()/2-a.height/2:a.top=d.position.top||0,a.left<0&&(a.left=0),a.top<0&&(a.top=0)),this.activeModal.css(a),this.$.body.css({height:a.height-d.headerHeight}),d.iframe&&(this.$["iframe-wrap"].css({height:a.height-d.headerHeight}),this.$.iframe.css({height:a.height-d.headerHeight})),this}}(),this.main=function(){t.modal_instance=t.modal_instance||[],t.modal_instance.push(this),arguments&&e.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)}}()),i=ax5.ui.modal}(),function(){var t=ax5.ui.modal,e=function(){return' \n
\n {{#header}}\n
\n {{{title}}}\n {{#btns}}\n
\n {{#@each}}\n \n {{/@each}}\n
\n {{/btns}}\n
\n {{/header}}\n
\n {{#iframe}}\n
\n
{{{iframeLoadingMsg}}}
\n \n
\n
\n \n {{#param}}\n {{#@each}}\n \n {{/@each}}\n {{/param}}\n
\n {{/iframe}}\n {{^iframe}}\n
\n {{/iframe}}\n
\n {{^disableResize}}\n
\n
\n
\n
\n
\n
\n
\n
\n {{/disableResize}}\n
\n '};t.tmpl={content:e,get:function(e,i,o){return ax5.mustache.render(t.tmpl[e].call(this,o),i)}}}(); \ No newline at end of file +"use strict";!function(){var t=ax5.ui,e=ax5.util,i=void 0;t.addClass({className:"modal",version:"1.4.30"},function(){return function(){var o=this,d=void 0,a={mousedown:ax5.info.supportTouch?"touchstart":"mousedown",mousemove:ax5.info.supportTouch?"touchmove":"mousemove",mouseup:ax5.info.supportTouch?"touchend":"mouseup"},h=function(t){var e=t;return"changedTouches"in t&&t.changedTouches&&(e=t.changedTouches[0]),{clientX:e.clientX,clientY:e.clientY}};this.instanceId=ax5.getGuid(),this.config={id:"ax5-modal-"+this.instanceId,position:{left:"center",top:"middle",margin:10},minimizePosition:"bottom-right",clickEventName:"click",theme:"default",width:300,height:400,closeToEsc:!0,disableDrag:!1,disableResize:!1,animateTime:250,iframe:!1},this.activeModal=null,this.watingModal=!1,this.$={},d=this.config;var n=function(t,e){var i={resize:function(e){t&&t.onResize?t.onResize.call(e,e):this.onResize&&this.onResize.call(e,e)},move:function(){}};return e.state in i&&i[e.state].call(this,e),t&&t.onStateChanged?t.onStateChanged.call(e,e):this.onStateChanged&&this.onStateChanged.call(e,e),!0},s=function(t,e){var o={modalId:t,theme:e.theme,header:e.header,fullScreen:e.fullScreen?"fullscreen":"",styles:"",iframe:e.iframe,iframeLoadingMsg:e.iframeLoadingMsg,disableResize:e.disableResize};return e.zIndex&&(o.styles+="z-index:"+e.zIndex+";"),e.absolute&&(o.styles+="position:absolute;"),o.iframe&&"string"==typeof o.iframe.param&&(o.iframe.param=ax5.util.param(o.iframe.param)),i.tmpl.get.call(this,"content",o,{})},l=function(t,i){var l=void 0;jQuery(document.body).append(s.call(this,t.id,t)),this.activeModal=jQuery("#"+t.id),this.$={root:this.activeModal,header:this.activeModal.find('[data-modal-els="header"]'),body:this.activeModal.find('[data-modal-els="body"]')},t.iframe?(this.$["iframe-wrap"]=this.activeModal.find('[data-modal-els="iframe-wrap"]'),this.$.iframe=this.activeModal.find('[data-modal-els="iframe"]'),this.$["iframe-form"]=this.activeModal.find('[data-modal-els="iframe-form"]'),this.$["iframe-loading"]=this.activeModal.find('[data-modal-els="iframe-loading"]')):this.$["body-frame"]=this.activeModal.find('[data-modal-els="body-frame"]'),this.align(),l={self:this,id:t.id,theme:t.theme,width:t.width,height:t.height,state:"open",$:this.$},t.iframe&&(this.$["iframe-wrap"].css({height:t.height}),this.$.iframe.css({height:t.height}),this.$["iframe-form"].attr({method:t.iframe.method}),this.$["iframe-form"].attr({target:t.id+"-frame"}),this.$["iframe-form"].attr({action:t.iframe.url}),this.$.iframe.on("load",function(){l.state="load",t.iframeLoadingMsg&&this.$["iframe-loading"].hide(),n.call(this,t,l)}.bind(this)),t.iframeLoadingMsg||this.$.iframe.show(),this.$["iframe-form"].submit()),i&&i.call(l,l),this.watingModal||n.call(this,t,l),t.closeToEsc&&jQuery(window).bind("keydown.ax-modal",function(t){f.call(this,t||window.event)}.bind(this)),jQuery(window).bind("resize.ax-modal",function(t){this.align(null,t||window.event)}.bind(this)),this.activeModal.on(d.clickEventName,"[data-modal-header-btn]",function(e){r.call(this,e||window.event,t)}.bind(this)),this.$.header.off(a.mousedown).off("dragstart").on(a.mousedown,function(i){if(t.isFullScreen)return!1;var d=e.findParentNode(i.target,function(t){if(t.getAttribute("data-modal-header-btn"))return!0});d||1==t.disableDrag||(o.mousePosition=h(i),c.on.call(o))}).on("dragstart",function(t){return e.stopEvent(t.originalEvent),!1}),this.activeModal.off(a.mousedown).off("dragstart").on(a.mousedown,"[data-ax5modal-resizer]",function(e){return!t.disableDrag&&!t.isFullScreen&&(o.mousePosition=h(e),void u.on.call(o,this.getAttribute("data-ax5modal-resizer")))}).on("dragstart",function(t){return e.stopEvent(t.originalEvent),!1})},r=function(t,i,o,d,a){var h=void 0;t.srcElement&&(t.target=t.srcElement),d=e.findParentNode(t.target,function(t){if(t.getAttribute("data-modal-header-btn"))return!0}),d&&(a=d.getAttribute("data-modal-header-btn"),h={self:this,key:a,value:i.header.btns[a],dialogId:i.id,btnTarget:d},i.header.btns[a].onClick&&i.header.btns[a].onClick.call(h,a)),h=null,i=null,o=null,d=null,a=null},f=function(t){t.keyCode==ax5.info.eventKeys.ESC&&this.close()},m={"top-left":function(){this.align({left:"left",top:"top"})},"top-right":function(){this.align({left:"right",top:"top"})},"bottom-left":function(){this.align({left:"left",top:"bottom"})},"bottom-right":function(){this.align({left:"right",top:"bottom"})},"center-middle":function(){this.align({left:"center",top:"middle"})}},c={on:function(){var t=this.activeModal.css("z-index"),e=this.activeModal.position(),i={width:this.activeModal.outerWidth(),height:this.activeModal.outerHeight()},d={width:jQuery(window).width(),height:jQuery(window).height(),scrollLeft:o.modalConfig.absolute?0:jQuery(document).scrollLeft(),scrollTop:o.modalConfig.absolute?0:jQuery(document).scrollTop()},h=function(t){return o.__dx=t.clientX-o.mousePosition.clientX,o.__dy=t.clientY-o.mousePosition.clientY,n>e.left+o.__dx?o.__dx=-e.left:se.top+o.__dy?o.__dy=-e.top:r'),o.resizer=jQuery('
'),o.resizerBg.css({zIndex:t}),o.resizer.css({left:e.left+d.scrollLeft,top:e.top+d.scrollTop,width:i.width,height:i.height,zIndex:t+1}),jQuery(document.body).append(o.resizerBg).append(o.resizer),o.activeModal.addClass("draged"),jQuery(document.body).on(a.mousemove+".ax5modal-move-"+this.instanceId,function(t){o.resizer.css(h(t))}).on(a.mouseup+".ax5modal-move-"+this.instanceId,function(t){c.off.call(o)}).on("mouseleave.ax5modal-move-"+this.instanceId,function(t){c.off.call(o)}),jQuery(document.body).attr("unselectable","on").css("user-select","none").on("selectstart",!1)},off:function(){var t=function(){var t=this.resizer.offset();this.modalConfig.absolute||(t.left-=jQuery(document).scrollLeft(),t.top-=jQuery(document).scrollTop()),this.activeModal.css(t),this.modalConfig.left=t.left,this.modalConfig.top=t.top,t=null};this.activeModal.removeClass("draged"),t.call(this),this.resizer.remove(),this.resizer=null,this.resizerBg.remove(),this.resizerBg=null,jQuery(document.body).off(a.mousemove+".ax5modal-move-"+this.instanceId).off(a.mouseup+".ax5modal-move-"+this.instanceId).off("mouseleave.ax5modal-move-"+this.instanceId),jQuery(document.body).removeAttr("unselectable").css("user-select","auto").off("selectstart"),n.call(this,o.modalConfig,{self:this,state:"move"})}},u={on:function(t){var e=this.activeModal.css("z-index"),i=this.activeModal.position(),d={width:this.activeModal.outerWidth(),height:this.activeModal.outerHeight()},h={width:jQuery(window).width(),height:jQuery(window).height(),scrollLeft:this.modalConfig.absolute?0:jQuery(document).scrollLeft(),scrollTop:this.modalConfig.absolute?0:jQuery(document).scrollTop()},n={top:function(t){return r>d.height-o.__dy&&(o.__dy=d.height-r),t.shiftKey?(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),{left:i.left,top:i.top+o.__dy,width:d.width,height:d.height-2*o.__dy}):t.altKey?(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),{left:i.left+o.__dy,top:i.top+o.__dy,width:d.width-2*o.__dy,height:d.height-2*o.__dy}):{left:i.left,top:i.top+o.__dy,width:d.width,height:d.height-o.__dy}},bottom:function(t){return r>d.height+o.__dy&&(o.__dy=-d.height+r),t.shiftKey?(r>d.height+2*o.__dy&&(o.__dy=(-d.height+r)/2),{left:i.left,top:i.top-o.__dy,width:d.width,height:d.height+2*o.__dy}):t.altKey?(r>d.height+2*o.__dy&&(o.__dy=(-d.height+r)/2),{left:i.left-o.__dy,top:i.top-o.__dy,width:d.width+2*o.__dy,height:d.height+2*o.__dy}):{left:i.left,top:i.top,width:d.width,height:d.height+o.__dy}},left:function(t){return l>d.width-o.__dx&&(o.__dx=d.width-l),t.shiftKey?(l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),{left:i.left+o.__dx,top:i.top,width:d.width-2*o.__dx,height:d.height}):t.altKey?(l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),{left:i.left+o.__dx,top:i.top+o.__dx,width:d.width-2*o.__dx,height:d.height-2*o.__dx}):{left:i.left+o.__dx,top:i.top,width:d.width-o.__dx,height:d.height}},right:function(t){return l>d.width+o.__dx&&(o.__dx=-d.width+l),t.shiftKey?(l>d.width+2*o.__dx&&(o.__dx=(-d.width+l)/2),{left:i.left-o.__dx,top:i.top,width:d.width+2*o.__dx,height:d.height}):t.altKey?(l>d.width+2*o.__dx&&(o.__dx=(-d.width+l)/2),{left:i.left-o.__dx,top:i.top-o.__dx,width:d.width+2*o.__dx,height:d.height+2*o.__dx}):{left:i.left,top:i.top,width:d.width+o.__dx,height:d.height}},"top-left":function(t){return l>d.width-o.__dx&&(o.__dx=d.width-l),r>d.height-o.__dy&&(o.__dy=d.height-r),t.shiftKey||t.altKey?(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),{left:i.left+o.__dx,top:i.top+o.__dy,width:d.width-2*o.__dx,height:d.height-2*o.__dy}):(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),{left:i.left+o.__dx,top:i.top+o.__dy,width:d.width-o.__dx,height:d.height-o.__dy})},"top-right":function(t){return l>d.width+o.__dx&&(o.__dx=-d.width+l),r>d.height-o.__dy&&(o.__dy=d.height-r),t.shiftKey||t.altKey?(r>d.height-2*o.__dy&&(o.__dy=(d.height-r)/2),l>d.width+2*o.__dx&&(o.__dx=(-d.width+l)/2),{left:i.left-o.__dx,top:i.top+o.__dy,width:d.width+2*o.__dx,height:d.height-2*o.__dy}):{left:i.left,top:i.top+o.__dy,width:d.width+o.__dx,height:d.height-o.__dy}},"bottom-left":function(t){return l>d.width-o.__dx&&(o.__dx=d.width-l),r>d.height+o.__dy&&(o.__dy=-d.height+r),t.shiftKey||t.altKey?(l>d.width-2*o.__dx&&(o.__dx=(d.width-l)/2),r>d.height+2*o.__dy&&(o.__dy=(-d.height+r)/2),{left:i.left+o.__dx,top:i.top-o.__dy,width:d.width-2*o.__dx,height:d.height+2*o.__dy}):{left:i.left+o.__dx,top:i.top,width:d.width-o.__dx,height:d.height+o.__dy}},"bottom-right":function(t){return l>d.width+o.__dx&&(o.__dx=-d.width+l),r>d.height+o.__dy&&(o.__dy=-d.height+r),t.shiftKey||t.altKey?(l>d.width+2*o.__dx&&(o.__dx=(-d.width+l)/2),r>d.height+2*o.__dy&&(o.__dy=(-d.height+r)/2),{left:i.left-o.__dx,top:i.top-o.__dy,width:d.width+2*o.__dx,height:d.height+2*o.__dy}):{left:i.left,top:i.top,width:d.width+o.__dx,height:d.height+o.__dy}}},s=function(e){return o.__dx=e.clientX-o.mousePosition.clientX,o.__dy=e.clientY-o.mousePosition.clientY,n[t](e)};this.modalConfig.absolute||(i.left+=h.scrollLeft,i.top+=h.scrollTop);var l=100,r=100,f={top:"row-resize",bottom:"row-resize",left:"col-resize",right:"col-resize","top-left":"nwse-resize","top-right":"nesw-resize","bottom-left":"nesw-resize","bottom-right":"nwse-resize"};o.__dx=0,o.__dy=0,o.resizerBg=jQuery('
'),o.resizer=jQuery('
'),o.resizerBg.css({zIndex:e,cursor:f[t]}),o.resizer.css({left:i.left,top:i.top,width:d.width,height:d.height,zIndex:e+1,cursor:f[t]}),jQuery(document.body).append(o.resizerBg).append(o.resizer),o.activeModal.addClass("draged"),jQuery(document.body).bind(a.mousemove+".ax5modal-resize-"+this.instanceId,function(t){o.resizer.css(s(t))}).bind(a.mouseup+".ax5modal-resize-"+this.instanceId,function(t){u.off.call(o)}).bind("mouseleave.ax5modal-resize-"+this.instanceId,function(t){u.off.call(o)}),jQuery(document.body).attr("unselectable","on").css("user-select","none").bind("selectstart",!1)},off:function(){var t=function(){var t=this.resizer.offset();jQuery.extend(t,{width:this.resizer.width(),height:this.resizer.height()}),this.modalConfig.absolute||(t.left-=jQuery(document).scrollLeft(),t.top-=jQuery(document).scrollTop()),this.activeModal.css(t),this.modalConfig.left=t.left,this.modalConfig.top=t.top,this.modalConfig.width=t.width,this.modalConfig.height=t.height,this.$.body.css({height:t.height-this.modalConfig.headerHeight}),this.modalConfig.iframe&&(this.$["iframe-wrap"].css({height:t.height-this.modalConfig.headerHeight}),this.$.iframe.css({height:t.height-this.modalConfig.headerHeight})),t=null};this.activeModal.removeClass("draged"),t.call(this),this.resizer.remove(),this.resizer=null,this.resizerBg.remove(),this.resizerBg=null,n.call(this,o.modalConfig,{self:this,state:"resize"}),jQuery(document.body).unbind(a.mousemove+".ax5modal-resize-"+this.instanceId).unbind(a.mouseup+".ax5modal-resize-"+this.instanceId).unbind("mouseleave.ax5modal-resize-"+this.instanceId),jQuery(document.body).removeAttr("unselectable").css("user-select","auto").unbind("selectstart")}};this.init=function(){this.onStateChanged=d.onStateChanged,this.onResize=d.onResize},this.open=function(t,e,i){return"undefined"==typeof i&&(i=0),this.activeModal?i<3&&(this.watingModal=!0,setTimeout(function(){this.open(t,e,i+1)}.bind(this),d.animateTime)):(t=o.modalConfig=jQuery.extend(!0,{},d,t),l.call(this,t,e),this.watingModal=!1),this},this.close=function(t){return this.activeModal&&(t=o.modalConfig,this.activeModal.addClass("destroy"),jQuery(window).unbind("keydown.ax-modal"),jQuery(window).unbind("resize.ax-modal"),setTimeout(function(){if(this.activeModal){if(t.iframe){var e=this.$.iframe;if(e){var i=e.get(0),o=i.contentDocument?i.contentDocument:i.contentWindow.document;try{$(o.body).children().each(function(){$(this).remove()})}catch(d){}o.innerHTML="",e.attr("src","about:blank").remove(),window.CollectGarbage&&window.CollectGarbage()}}this.activeModal.remove(),this.activeModal=null}this.watingModal||n.call(this,t,{self:this,state:"close"})}.bind(this),d.animateTime)),this.minimized=!1,this},this.minimize=function(){return function(t){if(this.minimized!==!0){var e=o.modalConfig;"undefined"==typeof t&&(t=d.minimizePosition),this.minimized=!0,this.$.body.hide(),o.modalConfig.originalHeight=e.height,o.modalConfig.height=0,m[t].call(this),n.call(this,e,{self:this,state:"minimize"})}return this}}(),this.restore=function(){var t=o.modalConfig;return this.minimized&&(this.minimized=!1,this.$.body.show(),o.modalConfig.height=o.modalConfig.originalHeight,o.modalConfig.originalHeight=void 0,this.align({left:"center",top:"middle"}),n.call(this,t,{self:this,state:"restore"})),this},this.css=function(t){return this.activeModal&&!o.fullScreen&&(this.activeModal.css(t),t.width&&(o.modalConfig.width=this.activeModal.width()),t.height&&(o.modalConfig.height=this.activeModal.height(),this.$.iframe&&(this.$["iframe-wrap"].css({height:o.modalConfig.height}),this.$.iframe.css({height:o.modalConfig.height})))),this},this.setModalConfig=function(t){return o.modalConfig=jQuery.extend({},o.modalConfig,t),this.align(),this},this.align=function(){return function(t,i){if(!this.activeModal)return this;var d=o.modalConfig,a={width:d.width,height:d.height},h=d.isFullScreen=function(t){return"undefined"!=typeof t&&(e.isFunction(t)?t():void 0)}(d.fullScreen);return h?(d.header&&this.$.header.show(),a.width=jQuery(window).width(),a.height=d.height,a.left=0,a.top=0):(d.header&&this.$.header.show(),t&&jQuery.extend(!0,d.position,t),d.header?(d.headerHeight=this.$.header.outerHeight(),a.height+=d.headerHeight):d.headerHeight=0,"left"==d.position.left?a.left=d.position.margin||0:"right"==d.position.left?a.left=jQuery(window).width()-a.width-(d.position.margin||0):"center"==d.position.left?a.left=jQuery(window).width()/2-a.width/2:a.left=d.position.left||0,"top"==d.position.top?a.top=d.position.margin||0:"bottom"==d.position.top?a.top=jQuery(window).height()-a.height-(d.position.margin||0):"middle"==d.position.top?a.top=jQuery(window).height()/2-a.height/2:a.top=d.position.top||0,a.left<0&&(a.left=0),a.top<0&&(a.top=0)),this.activeModal.css(a),this.$.body.css({height:a.height-d.headerHeight}),d.iframe&&(this.$["iframe-wrap"].css({height:a.height-d.headerHeight}),this.$.iframe.css({height:a.height-d.headerHeight})),this}}(),this.main=function(){t.modal_instance=t.modal_instance||[],t.modal_instance.push(this),arguments&&e.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)}}()),i=ax5.ui.modal}(),function(){var t=ax5.ui.modal,e=function(){return' \n
\n {{#header}}\n
\n {{{title}}}\n {{#btns}}\n
\n {{#@each}}\n \n {{/@each}}\n
\n {{/btns}}\n
\n {{/header}}\n
\n {{#iframe}}\n
\n
{{{iframeLoadingMsg}}}
\n \n
\n
\n \n {{#param}}\n {{#@each}}\n \n {{/@each}}\n {{/param}}\n
\n {{/iframe}}\n {{^iframe}}\n
\n {{/iframe}}\n
\n {{^disableResize}}\n
\n
\n
\n
\n
\n
\n
\n
\n {{/disableResize}}\n
\n '};t.tmpl={content:e,get:function(e,i,o){return ax5.mustache.render(t.tmpl[e].call(this,o),i)}}}(); \ No newline at end of file diff --git a/package.json b/package.json index 5ea159b..630c0ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ax5ui-modal", - "version": "1.4.29", + "version": "1.4.30", "description": "A modal plugin that works with Bootstrap & jQuery", "license": "MIT", "repository": {