diff --git a/bower.json b/bower.json index 6b655c8..324cefa 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ax5ui-modal", - "version": "0.5.0", + "version": "0.5.1", "authors": [ "ThomasJ " ], diff --git a/dist/ax5modal.js b/dist/ax5modal.js index 241d001..3d293f1 100755 --- a/dist/ax5modal.js +++ b/dist/ax5modal.js @@ -1,6 +1,8 @@ +"use strict"; + // ax5.ui.modal (function (root, _SUPER_) { - + /** * @class ax5.ui.modal * @classdesc @@ -13,13 +15,12 @@ * var my_modal = new ax5.ui.modal(); * ``` */ - + var U = ax5.util; - + //== UI Class - var axClass = function () { - var - self = this, + var axClass = function axClass() { + var self = this, cfg; if (_SUPER_) _SUPER_.call(this); // 부모호출 @@ -40,7 +41,7 @@ }; cfg = this.config; // extended config copy cfg cfg.id = 'ax5-modal-' + ax5.getGuid(); // instance id - + /** * Preferences of modal UI * @method ax5.ui.modal.setConfig @@ -50,20 +51,17 @@ * ``` * ``` */ - //== class body start - this.init = function () { - - }; - + //== class body start + this.init = function () {}; + this.getContent = function (modalId, opts) { - var - po = [], + var po = [], styles = []; - if(opts.zIndex){ + if (opts.zIndex) { styles.push("z-index:" + opts.zIndex); } - + po.push('
'); po.push('
'); // use iframe @@ -73,7 +71,7 @@ po.push('
'); po.push('
'); po.push(''); - if(typeof opts.iframe.param === "string"){ + if (typeof opts.iframe.param === "string") { opts.iframe.param = ax5.util.param(opts.iframe.param); } for (var p in opts.iframe.param) { @@ -91,7 +89,7 @@ opts = { title: cfg.title, msg: opts - } + }; } self.modalConfig = {}; @@ -104,11 +102,10 @@ }; this._open = function (opts, callBack) { - var - that; + var that; jQuery(document.body).append(this.getContent(opts.id, opts)); - + this.activeModal = jQuery('#' + opts.id); // 파트수집 @@ -116,17 +113,18 @@ "root": this.activeModal.find('[data-modal-els="root"]'), "body": this.activeModal.find('[data-modal-els="body"]') }; - + if (opts.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"]'); } - + //- position 정렬 this.align(); that = { + self: this, id: opts.id, theme: opts.theme, width: opts.width, @@ -136,22 +134,20 @@ }; if (opts.iframe) { - - console.log(); - - this.$["iframe-wrap"].css({height: opts.height}); - this.$["iframe"].css({height: opts.height}); - + + this.$["iframe-wrap"].css({ height: opts.height }); + this.$["iframe"].css({ height: opts.height }); + // iframe content load - this.$["iframe-form"].attr({"method": opts.iframe.method}); - this.$["iframe-form"].attr({"target": opts.id + "-frame"}); - this.$["iframe-form"].attr({"action": opts.iframe.url}); - this.$["iframe"].on("load", (function () { + this.$["iframe-form"].attr({ "method": opts.iframe.method }); + this.$["iframe-form"].attr({ "target": opts.id + "-frame" }); + this.$["iframe-form"].attr({ "action": opts.iframe.url }); + this.$["iframe"].on("load", function () { if (opts && opts.onStateChanged) { that.state = "load"; opts.onStateChanged.call(that, that); } - }).bind(this)); + }.bind(this)); this.$["iframe-form"].submit(); } @@ -162,64 +158,57 @@ // bind key event if (opts.closeToEsc) { - jQuery(window).bind("keydown.ax-modal", (function (e) { + jQuery(window).bind("keydown.ax-modal", function (e) { this.onkeyup(e || window.event); - }).bind(this)); + }.bind(this)); } - jQuery(window).bind("resize.ax-modal", (function (e) { + jQuery(window).bind("resize.ax-modal", function (e) { this.align(null, e || window.event); - }).bind(this)); + }.bind(this)); }; this.align = function (position, e) { if (!this.activeModal) return this; var opts = self.modalConfig, box = { - width: opts.width, - height: opts.height - }; + width: opts.width, + height: opts.height + }; - if(opts.fullScreen){ + if (opts.fullScreen) { box.width = jQuery(window).width(); box.height = jQuery(window).height(); box.left = 0; box.top = 0; if (opts.iframe) { - this.$["iframe-wrap"].css({height: box.height}); - this.$["iframe"].css({height: box.height}); + this.$["iframe-wrap"].css({ height: box.height }); + this.$["iframe"].css({ height: box.height }); } - } - else{ + } else { if (position) { jQuery.extend(true, opts.position, position); } //- position 정렬 if (opts.position.left == "left") { - box.left = (opts.position.margin || 0); - } - else if (opts.position.left == "right") { + box.left = opts.position.margin || 0; + } else if (opts.position.left == "right") { // window.innerWidth; box.left = jQuery(window).width() - box.width - (opts.position.margin || 0); - } - else if (opts.position.left == "center") { + } else if (opts.position.left == "center") { box.left = jQuery(window).width() / 2 - box.width / 2; - } - else { + } else { box.left = opts.position.left || 0; } if (opts.position.top == "top") { - box.top = (opts.position.margin || 0); - } - else if (opts.position.top == "bottom") { + box.top = opts.position.margin || 0; + } else if (opts.position.top == "bottom") { box.top = jQuery(window).height() - box.height - (opts.position.margin || 0); - } - else if (opts.position.top == "middle") { + } else if (opts.position.top == "middle") { box.top = jQuery(window).height() / 2 - box.height / 2; - } - else { + } else { box.top = opts.position.top || 0; } } @@ -227,13 +216,13 @@ this.activeModal.css(box); return this; }; - + this.onkeyup = function (e) { if (e.keyCode == ax5.info.eventKeys.ESC) { this.close(); } }; - + /** * close the modal * @method ax5.ui.modal.close @@ -250,16 +239,17 @@ jQuery(window).unbind("keydown.ax-modal"); jQuery(window).unbind("resize.ax-modal"); - setTimeout((function () { + setTimeout(function () { this.activeModal.remove(); this.activeModal = null; if (opts && opts.onStateChanged) { that = { + self: this, state: "close" }; opts.onStateChanged.call(that, that); } - }).bind(this), cfg.animateTime); + }.bind(this), cfg.animateTime); } return this; }; @@ -278,9 +268,9 @@ } if (css.height) { self.modalConfig.height = this.activeModal.height(); - if(this.$["iframe"]) { - this.$["iframe-wrap"].css({height: self.modalConfig.height}); - this.$["iframe"].css({height: self.modalConfig.height}); + if (this.$["iframe"]) { + this.$["iframe-wrap"].css({ height: self.modalConfig.height }); + this.$["iframe"].css({ height: self.modalConfig.height }); } } } @@ -288,17 +278,16 @@ }; // 클래스 생성자 - this.main = (function () { - if(arguments && U.isObject(arguments[0])) { + this.main = function () { + if (arguments && U.isObject(arguments[0])) { this.setConfig(arguments[0]); } - }).apply(this, arguments); + }.apply(this, arguments); }; //== UI Class - root.modal = (function(){ + root.modal = function () { if (U.isFunction(_SUPER_)) axClass.prototype = new _SUPER_(); // 상속 return axClass; - })(); // ax5.ui에 연결 - + }(); // ax5.ui에 연결 })(ax5.ui, ax5.ui.root); \ No newline at end of file diff --git a/dist/ax5modal.min.js b/dist/ax5modal.min.js index 41e2825..3821664 100755 --- a/dist/ax5modal.min.js +++ b/dist/ax5modal.min.js @@ -1 +1 @@ -!function(i,t){var e=ax5.util,a=function(){var i,a=this;t&&t.call(this),this.activeModal=null,this.$={},this.config={position:{left:"center",top:"middle",margin:10},clickEventName:"click",theme:"default",width:300,height:400,closeToEsc:!0,animateTime:250},i=this.config,i.id="ax5-modal-"+ax5.getGuid(),this.init=function(){},this.getContent=function(i,t){var e=[],a=[];if(t.zIndex&&a.push("z-index:"+t.zIndex),e.push('
'),e.push('
'),t.iframe){e.push('
'),e.push(''),e.push("
"),e.push(''),e.push(''),"string"==typeof t.iframe.param&&(t.iframe.param=ax5.util.param(t.iframe.param));for(var o in t.iframe.param)e.push('');e.push("")}return e.push("
"),e.push("
"),e.join("")},this.open=function(t,o){return e.isString(t)&&(t={title:i.title,msg:t}),a.modalConfig={},jQuery.extend(!0,a.modalConfig,i),jQuery.extend(!0,a.modalConfig,t),t=a.modalConfig,this._open(t,o),this},this._open=function(i,t){var e;jQuery(document.body).append(this.getContent(i.id,i)),this.activeModal=jQuery("#"+i.id),this.$={root:this.activeModal.find('[data-modal-els="root"]'),body:this.activeModal.find('[data-modal-els="body"]')},i.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.align(),e={id:i.id,theme:i.theme,width:i.width,height:i.height,state:"open",$:this.$},i.iframe&&(console.log(),this.$["iframe-wrap"].css({height:i.height}),this.$.iframe.css({height:i.height}),this.$["iframe-form"].attr({method:i.iframe.method}),this.$["iframe-form"].attr({target:i.id+"-frame"}),this.$["iframe-form"].attr({action:i.iframe.url}),this.$.iframe.on("load",function(){i&&i.onStateChanged&&(e.state="load",i.onStateChanged.call(e,e))}.bind(this)),this.$["iframe-form"].submit()),t&&t.call(e),i&&i.onStateChanged&&i.onStateChanged.call(e,e),i.closeToEsc&&jQuery(window).bind("keydown.ax-modal",function(i){this.onkeyup(i||window.event)}.bind(this)),jQuery(window).bind("resize.ax-modal",function(i){this.align(null,i||window.event)}.bind(this))},this.align=function(i,t){if(!this.activeModal)return this;var e=a.modalConfig,o={width:e.width,height:e.height};return e.fullScreen?(o.width=jQuery(window).width(),o.height=jQuery(window).height(),o.left=0,o.top=0,e.iframe&&(this.$["iframe-wrap"].css({height:o.height}),this.$.iframe.css({height:o.height}))):(i&&jQuery.extend(!0,e.position,i),"left"==e.position.left?o.left=e.position.margin||0:"right"==e.position.left?o.left=jQuery(window).width()-o.width-(e.position.margin||0):"center"==e.position.left?o.left=jQuery(window).width()/2-o.width/2:o.left=e.position.left||0,"top"==e.position.top?o.top=e.position.margin||0:"bottom"==e.position.top?o.top=jQuery(window).height()-o.height-(e.position.margin||0):"middle"==e.position.top?o.top=jQuery(window).height()/2-o.height/2:o.top=e.position.top||0),this.activeModal.css(o),this},this.onkeyup=function(i){i.keyCode==ax5.info.eventKeys.ESC&&this.close()},this.close=function(t,e){return this.activeModal&&(t=a.modalConfig,this.activeModal.addClass("destroy"),jQuery(window).unbind("keydown.ax-modal"),jQuery(window).unbind("resize.ax-modal"),setTimeout(function(){this.activeModal.remove(),this.activeModal=null,t&&t.onStateChanged&&(e={state:"close"},t.onStateChanged.call(e,e))}.bind(this),i.animateTime)),this},this.css=function(i){return this.activeModal&&!a.fullScreen&&(this.activeModal.css(i),i.width&&(a.modalConfig.width=this.activeModal.width()),i.height&&(a.modalConfig.height=this.activeModal.height(),this.$.iframe&&(this.$["iframe-wrap"].css({height:a.modalConfig.height}),this.$.iframe.css({height:a.modalConfig.height})))),this},this.main=function(){arguments&&e.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};i.modal=function(){return e.isFunction(t)&&(a.prototype=new t),a}()}(ax5.ui,ax5.ui.root); \ No newline at end of file +"use strict";!function(i,t){var e=ax5.util,a=function(){var i,a=this;t&&t.call(this),this.activeModal=null,this.$={},this.config={position:{left:"center",top:"middle",margin:10},clickEventName:"click",theme:"default",width:300,height:400,closeToEsc:!0,animateTime:250},i=this.config,i.id="ax5-modal-"+ax5.getGuid(),this.init=function(){},this.getContent=function(i,t){var e=[],a=[];if(t.zIndex&&a.push("z-index:"+t.zIndex),e.push('
'),e.push('
'),t.iframe){e.push('
'),e.push(''),e.push("
"),e.push('
'),e.push(''),"string"==typeof t.iframe.param&&(t.iframe.param=ax5.util.param(t.iframe.param));for(var o in t.iframe.param)e.push('');e.push("
")}return e.push("
"),e.push("
"),e.join("")},this.open=function(t,o){return e.isString(t)&&(t={title:i.title,msg:t}),a.modalConfig={},jQuery.extend(!0,a.modalConfig,i),jQuery.extend(!0,a.modalConfig,t),t=a.modalConfig,this._open(t,o),this},this._open=function(i,t){var e;jQuery(document.body).append(this.getContent(i.id,i)),this.activeModal=jQuery("#"+i.id),this.$={root:this.activeModal.find('[data-modal-els="root"]'),body:this.activeModal.find('[data-modal-els="body"]')},i.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.align(),e={self:this,id:i.id,theme:i.theme,width:i.width,height:i.height,state:"open",$:this.$},i.iframe&&(this.$["iframe-wrap"].css({height:i.height}),this.$.iframe.css({height:i.height}),this.$["iframe-form"].attr({method:i.iframe.method}),this.$["iframe-form"].attr({target:i.id+"-frame"}),this.$["iframe-form"].attr({action:i.iframe.url}),this.$.iframe.on("load",function(){i&&i.onStateChanged&&(e.state="load",i.onStateChanged.call(e,e))}.bind(this)),this.$["iframe-form"].submit()),t&&t.call(e),i&&i.onStateChanged&&i.onStateChanged.call(e,e),i.closeToEsc&&jQuery(window).bind("keydown.ax-modal",function(i){this.onkeyup(i||window.event)}.bind(this)),jQuery(window).bind("resize.ax-modal",function(i){this.align(null,i||window.event)}.bind(this))},this.align=function(i,t){if(!this.activeModal)return this;var e=a.modalConfig,o={width:e.width,height:e.height};return e.fullScreen?(o.width=jQuery(window).width(),o.height=jQuery(window).height(),o.left=0,o.top=0,e.iframe&&(this.$["iframe-wrap"].css({height:o.height}),this.$.iframe.css({height:o.height}))):(i&&jQuery.extend(!0,e.position,i),"left"==e.position.left?o.left=e.position.margin||0:"right"==e.position.left?o.left=jQuery(window).width()-o.width-(e.position.margin||0):"center"==e.position.left?o.left=jQuery(window).width()/2-o.width/2:o.left=e.position.left||0,"top"==e.position.top?o.top=e.position.margin||0:"bottom"==e.position.top?o.top=jQuery(window).height()-o.height-(e.position.margin||0):"middle"==e.position.top?o.top=jQuery(window).height()/2-o.height/2:o.top=e.position.top||0),this.activeModal.css(o),this},this.onkeyup=function(i){i.keyCode==ax5.info.eventKeys.ESC&&this.close()},this.close=function(t,e){return this.activeModal&&(t=a.modalConfig,this.activeModal.addClass("destroy"),jQuery(window).unbind("keydown.ax-modal"),jQuery(window).unbind("resize.ax-modal"),setTimeout(function(){this.activeModal.remove(),this.activeModal=null,t&&t.onStateChanged&&(e={self:this,state:"close"},t.onStateChanged.call(e,e))}.bind(this),i.animateTime)),this},this.css=function(i){return this.activeModal&&!a.fullScreen&&(this.activeModal.css(i),i.width&&(a.modalConfig.width=this.activeModal.width()),i.height&&(a.modalConfig.height=this.activeModal.height(),this.$.iframe&&(this.$["iframe-wrap"].css({height:a.modalConfig.height}),this.$.iframe.css({height:a.modalConfig.height})))),this},this.main=function(){arguments&&e.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};i.modal=function(){return e.isFunction(t)&&(a.prototype=new t),a}()}(ax5.ui,ax5.ui.root); \ No newline at end of file diff --git a/package.json b/package.json index bd88bff..7819580 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ax5ui-modal", - "version": "0.5.0", + "version": "0.5.1", "description": "A modal plugin that works with Bootstrap & jQuery", "license": "MIT", "repository": { diff --git a/src/ax5modal.js b/src/ax5modal.js index 241d001..513bb35 100755 --- a/src/ax5modal.js +++ b/src/ax5modal.js @@ -127,6 +127,7 @@ this.align(); that = { + self: this, id: opts.id, theme: opts.theme, width: opts.width, @@ -136,9 +137,7 @@ }; if (opts.iframe) { - - console.log(); - + this.$["iframe-wrap"].css({height: opts.height}); this.$["iframe"].css({height: opts.height}); @@ -255,6 +254,7 @@ this.activeModal = null; if (opts && opts.onStateChanged) { that = { + self: this, state: "close" }; opts.onStateChanged.call(that, that);