diff --git a/API.md b/API.md index 89379d2..deb3e93 100644 --- a/API.md +++ b/API.md @@ -13,6 +13,16 @@ mask.setConfig({ } }); ``` +**Easy Way - without setConfig** +```js +var mask = new ax5.ui.mask({ + zIndex: 1000, + content: 'Loading content', + onStateChanged: function(){ + console.log(this); + } +}); +``` ```json { [target: {Element} - target of mask,] diff --git a/bower.json b/bower.json index 77b7fe6..49c0e41 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bootstrap-ax5mask", - "version": "0.4.0", + "version": "0.5.0", "authors": [ "ThomasJ " ], diff --git a/dist/ax5mask.js b/dist/ax5mask.js index 78d2aca..44019cb 100644 --- a/dist/ax5mask.js +++ b/dist/ax5mask.js @@ -16,19 +16,19 @@ var U = ax5.util; var axClass = function () { - var self = this; - - // 클래스 생성자 - this.main = (function () { - if (_SUPER_) _SUPER_.call(this); // 부모호출 - this.config = { - theme: '', - target: jQuery(document.body).get(0) - }; - this.maskContent = ''; - this.status = "off"; + var + self = this + ; + + if (_SUPER_) _SUPER_.call(this); // 부모호출 + this.maskContent = ''; + this.status = "off"; + this.config = { + theme: '', + target: jQuery(document.body).get(0) + }; + var cfg = this.config; - }).apply(this, arguments); /** * Preferences of Mask UI @@ -44,9 +44,6 @@ * } * ``` */ - //== class body start - var cfg = this.config; - this.init = function () { // after setConfig(); if (this.config.content) this.setBody(this.config.content); @@ -158,6 +155,14 @@ return this; }; //== class body end + + + // 클래스 생성자 + this.main = (function () { + if(arguments && U.isObject(arguments[0])) { + this.setConfig(arguments[0]); + } + }).apply(this, arguments); }; //== ui class 공통 처리 구문 diff --git a/dist/ax5mask.min.js b/dist/ax5mask.min.js index 76f2e97..29fe829 100644 --- a/dist/ax5mask.min.js +++ b/dist/ax5mask.min.js @@ -1 +1 @@ -!function(t,s){var n=ax5.util,i=function(){var t=this;this.main=function(){s&&s.call(this),this.config={theme:"",target:jQuery(document.body).get(0)},this.maskContent="",this.status="off"}.apply(this,arguments);this.config;this.init=function(){this.config.content&&this.setBody(this.config.content)},this.setBody=function(t){this.maskContent=t},this.getBody=function(){return this.maskContent},this.open=function(s){"on"===this.status&&this.close(),s&&s.content&&this.setBody(s.content),t.maskConfig={},jQuery.extend(!0,t.maskConfig,this.config),jQuery.extend(!0,t.maskConfig,s);var n,i,s=t.maskConfig,e=s.target,o=jQuery(e),a=[],h="ax-mask-"+ax5.getGuid(),n={},u={};return a.push('
'),a.push('
'),a.push('
'),a.push('
'),a.push(t.getBody()),a.push("
"),a.push("
"),a.push("
"),jQuery(document.body).append(a.join("")),e!==document.body&&(n={position:"absolute",left:o.offset().left,top:o.offset().top,width:o.outerWidth(),height:o.outerHeight()},"undefined"!=typeof t.maskConfig.zIndex&&(n["z-index"]=t.maskConfig.zIndex),o.addClass("ax-masking")),this.$mask=i=jQuery("#"+h),this.$target=o,this.status="on",i.css(n),s.onStateChanged&&(u={state:"open"},s.onStateChanged.call(u,u)),this},this.close=function(){var t,s=this.maskConfig;return this.$mask.remove(),this.$target.removeClass("ax-masking"),s&&s.onStateChanged&&(t={state:"close"},s.onStateChanged.call(t,t)),this}};n.isFunction(s)&&(i.prototype=new s),t.mask=i}(ax5.ui,ax5.ui.root); \ No newline at end of file +!function(t,s){var n=ax5.util,e=function(){var t=this;s&&s.call(this),this.maskContent="",this.status="off",this.config={theme:"",target:jQuery(document.body).get(0)};this.config;this.init=function(){this.config.content&&this.setBody(this.config.content)},this.setBody=function(t){this.maskContent=t},this.getBody=function(){return this.maskContent},this.open=function(s){"on"===this.status&&this.close(),s&&s.content&&this.setBody(s.content),t.maskConfig={},jQuery.extend(!0,t.maskConfig,this.config),jQuery.extend(!0,t.maskConfig,s);var n,e,s=t.maskConfig,i=s.target,o=jQuery(i),a=[],h="ax-mask-"+ax5.getGuid(),n={},u={};return a.push('
'),a.push('
'),a.push('
'),a.push('
'),a.push(t.getBody()),a.push("
"),a.push("
"),a.push("
"),jQuery(document.body).append(a.join("")),i!==document.body&&(n={position:"absolute",left:o.offset().left,top:o.offset().top,width:o.outerWidth(),height:o.outerHeight()},"undefined"!=typeof t.maskConfig.zIndex&&(n["z-index"]=t.maskConfig.zIndex),o.addClass("ax-masking")),this.$mask=e=jQuery("#"+h),this.$target=o,this.status="on",e.css(n),s.onStateChanged&&(u={state:"open"},s.onStateChanged.call(u,u)),this},this.close=function(){var t,s=this.maskConfig;return this.$mask.remove(),this.$target.removeClass("ax-masking"),s&&s.onStateChanged&&(t={state:"close"},s.onStateChanged.call(t,t)),this},this.main=function(){arguments&&n.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};n.isFunction(s)&&(e.prototype=new s),t.mask=e}(ax5.ui,ax5.ui.root); \ No newline at end of file diff --git a/package.json b/package.json index b1f328b..176c2dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-ax5mask", - "version": "0.4.0", + "version": "0.5.0", "description": "A mask plugin that works with Bootstrap & jQuery", "license": "MIT", "repository": { diff --git a/src/ax5mask.js b/src/ax5mask.js index 78d2aca..44019cb 100644 --- a/src/ax5mask.js +++ b/src/ax5mask.js @@ -16,19 +16,19 @@ var U = ax5.util; var axClass = function () { - var self = this; - - // 클래스 생성자 - this.main = (function () { - if (_SUPER_) _SUPER_.call(this); // 부모호출 - this.config = { - theme: '', - target: jQuery(document.body).get(0) - }; - this.maskContent = ''; - this.status = "off"; + var + self = this + ; + + if (_SUPER_) _SUPER_.call(this); // 부모호출 + this.maskContent = ''; + this.status = "off"; + this.config = { + theme: '', + target: jQuery(document.body).get(0) + }; + var cfg = this.config; - }).apply(this, arguments); /** * Preferences of Mask UI @@ -44,9 +44,6 @@ * } * ``` */ - //== class body start - var cfg = this.config; - this.init = function () { // after setConfig(); if (this.config.content) this.setBody(this.config.content); @@ -158,6 +155,14 @@ return this; }; //== class body end + + + // 클래스 생성자 + this.main = (function () { + if(arguments && U.isObject(arguments[0])) { + this.setConfig(arguments[0]); + } + }).apply(this, arguments); }; //== ui class 공통 처리 구문