-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb7498f
commit 434aca0
Showing
6 changed files
with
112 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ax5ui-mask", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"authors": [ | ||
"ThomasJ <[email protected]>" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,8 @@ | |
/** | ||
* @class ax5.ui.mask | ||
* @classdesc | ||
* @version v0.0.1 | ||
* @version 0.6.4 | ||
* @author [email protected] | ||
* @logs | ||
* 2014-04-01 tom : 시작 | ||
* 2015-12-27 tom : refactoring | ||
* @example | ||
* ``` | ||
* var my_mask = new ax5.ui.mask(); | ||
|
@@ -18,7 +15,8 @@ | |
var U = ax5.util; | ||
|
||
var axClass = function axClass() { | ||
var self = this; | ||
var self = this, | ||
cfg; | ||
|
||
if (_SUPER_) _SUPER_.call(this); // 부모호출 | ||
this.maskContent = ''; | ||
|
@@ -27,7 +25,23 @@ | |
theme: '', | ||
target: jQuery(document.body).get(0) | ||
}; | ||
var cfg = this.config; | ||
|
||
cfg = this.config; | ||
|
||
var onStateChanged = function onStateChanged(opts, that) { | ||
if (opts && opts.onStateChanged) { | ||
opts.onStateChanged.call(that, that); | ||
} else if (this.onStateChanged) { | ||
this.onStateChanged.call(that, that); | ||
} | ||
return true; | ||
}, | ||
getBodyTmpl = function getBodyTmpl() { | ||
return '\n <div class="ax-mask {{theme}}" id="{{maskId}}">\n <div class="ax-mask-bg"></div>\n <div class="ax-mask-content">\n <div class="ax-mask-body">\n {{{body}}}\n </div>\n </div>\n </div>\n '; | ||
}, | ||
setBody = function setBody(content) { | ||
this.maskContent = content; | ||
}; | ||
|
||
/** | ||
* Preferences of Mask UI | ||
|
@@ -45,15 +59,9 @@ | |
*/ | ||
this.init = function () { | ||
// after setConfig(); | ||
if (this.config.content) this.setBody(this.config.content); | ||
}; | ||
|
||
this.setBody = function (content) { | ||
this.maskContent = content; | ||
}; | ||
|
||
this.getBody = function () { | ||
return this.maskContent; | ||
this.onStateChanged = cfg.onStateChanged; | ||
this.onClick = cfg.onClick; | ||
if (this.config.content) setBody.call(this, this.config.content); | ||
}; | ||
|
||
/** | ||
|
@@ -80,16 +88,15 @@ | |
* }); | ||
* ``` | ||
*/ | ||
this.open = function (config) { | ||
this.open = function (options) { | ||
|
||
if (this.status === "on") this.close(); | ||
if (config && config.content) this.setBody(config.content); | ||
if (options && options.content) setBody.call(this, options.content); | ||
self.maskConfig = {}; | ||
jQuery.extend(true, self.maskConfig, this.config); | ||
jQuery.extend(true, self.maskConfig, config); | ||
jQuery.extend(true, self.maskConfig, this.config, options); | ||
|
||
var config = self.maskConfig, | ||
target = config.target, | ||
var _cfg = self.maskConfig, | ||
target = _cfg.target, | ||
$target = jQuery(target), | ||
po = [], | ||
css, | ||
|
@@ -98,20 +105,15 @@ | |
css = {}, | ||
that = {}; | ||
|
||
po.push('<div class="ax-mask ' + config.theme + '" id="' + maskId + '">'); | ||
po.push('<div class="ax-mask-bg"></div>'); | ||
po.push('<div class="ax-mask-content">'); | ||
po.push('<div class="ax-mask-body">'); | ||
po.push(self.getBody()); | ||
po.push('</div>'); | ||
po.push('</div>'); | ||
po.push('</div>'); | ||
|
||
jQuery(document.body).append(po.join('')); | ||
jQuery(document.body).append(ax5.mustache.render(getBodyTmpl(), { | ||
theme: _cfg.theme, | ||
maskId: maskId, | ||
body: this.maskContent | ||
})); | ||
|
||
if (target && target !== jQuery(document.body).get(0)) { | ||
css = { | ||
position: config.position || "absolute", | ||
position: _cfg.position || "absolute", | ||
left: $target.offset().left, | ||
top: $target.offset().top, | ||
width: $target.outerWidth(), | ||
|
@@ -128,22 +130,21 @@ | |
this.status = "on"; | ||
$mask.css(css); | ||
|
||
if (config.onClick) { | ||
if (this.onClick) { | ||
$mask.click(function () { | ||
that = { | ||
self: this, | ||
state: "open", | ||
type: "click" | ||
}; | ||
config.onClick.call(that, that); | ||
this.onClick.call(that, that); | ||
}); | ||
} | ||
if (config.onStateChanged) { | ||
that = { | ||
self: this, | ||
state: "open" | ||
}; | ||
config.onStateChanged.call(that, that); | ||
} | ||
|
||
onStateChanged.call(this, null, { | ||
self: this, | ||
state: "open" | ||
}); | ||
return this; | ||
}; | ||
|
||
|
@@ -157,17 +158,13 @@ | |
* ``` | ||
*/ | ||
this.close = function () { | ||
var config = this.maskConfig, | ||
that; | ||
this.$mask.remove(); | ||
this.$target.removeClass("ax-masking"); | ||
if (config && config.onStateChanged) { | ||
that = { | ||
self: this, | ||
state: "close" | ||
}; | ||
config.onStateChanged.call(that, that); | ||
} | ||
|
||
onStateChanged.call(this, null, { | ||
self: this, | ||
state: "close" | ||
}); | ||
return this; | ||
}; | ||
//== class body end | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,8 @@ | |
/** | ||
* @class ax5.ui.mask | ||
* @classdesc | ||
* @version v0.0.1 | ||
* @version 0.6.4 | ||
* @author [email protected] | ||
* @logs | ||
* 2014-04-01 tom : 시작 | ||
* 2015-12-27 tom : refactoring | ||
* @example | ||
* ``` | ||
* var my_mask = new ax5.ui.mask(); | ||
|
@@ -17,7 +14,8 @@ | |
|
||
var axClass = function () { | ||
var | ||
self = this | ||
self = this, | ||
cfg | ||
; | ||
|
||
if (_SUPER_) _SUPER_.call(this); // 부모호출 | ||
|
@@ -27,7 +25,34 @@ | |
theme: '', | ||
target: jQuery(document.body).get(0) | ||
}; | ||
var cfg = this.config; | ||
|
||
cfg = this.config; | ||
|
||
var | ||
onStateChanged = function (opts, that) { | ||
if (opts && opts.onStateChanged) { | ||
opts.onStateChanged.call(that, that); | ||
} | ||
else if (this.onStateChanged) { | ||
this.onStateChanged.call(that, that); | ||
} | ||
return true; | ||
}, | ||
getBodyTmpl = function(){ | ||
return ` | ||
<div class="ax-mask {{theme}}" id="{{maskId}}"> | ||
<div class="ax-mask-bg"></div> | ||
<div class="ax-mask-content"> | ||
<div class="ax-mask-body"> | ||
{{{body}}} | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
}, | ||
setBody = function (content) { | ||
this.maskContent = content; | ||
}; | ||
|
||
/** | ||
* Preferences of Mask UI | ||
|
@@ -45,15 +70,9 @@ | |
*/ | ||
this.init = function () { | ||
// after setConfig(); | ||
if (this.config.content) this.setBody(this.config.content); | ||
}; | ||
|
||
this.setBody = function (content) { | ||
this.maskContent = content; | ||
}; | ||
|
||
this.getBody = function () { | ||
return this.maskContent; | ||
this.onStateChanged = cfg.onStateChanged; | ||
this.onClick = cfg.onClick; | ||
if (this.config.content) setBody.call(this, this.config.content); | ||
}; | ||
|
||
/** | ||
|
@@ -80,33 +99,29 @@ | |
* }); | ||
* ``` | ||
*/ | ||
this.open = function (config) { | ||
this.open = function (options) { | ||
|
||
if (this.status === "on") this.close(); | ||
if (config && config.content) this.setBody(config.content); | ||
if (options && options.content) setBody.call(this, options.content); | ||
self.maskConfig = {}; | ||
jQuery.extend(true, self.maskConfig, this.config); | ||
jQuery.extend(true, self.maskConfig, config); | ||
jQuery.extend(true, self.maskConfig, this.config, options); | ||
|
||
var config = self.maskConfig, | ||
target = config.target, $target = jQuery(target), | ||
var _cfg = self.maskConfig, | ||
target = _cfg.target, $target = jQuery(target), | ||
po = [], css, maskId = 'ax-mask-' + ax5.getGuid(), $mask, css = {}, | ||
that = {}; | ||
|
||
po.push('<div class="ax-mask ' + config.theme + '" id="' + maskId + '">'); | ||
po.push('<div class="ax-mask-bg"></div>'); | ||
po.push('<div class="ax-mask-content">'); | ||
po.push('<div class="ax-mask-body">'); | ||
po.push(self.getBody()); | ||
po.push('</div>'); | ||
po.push('</div>'); | ||
po.push('</div>'); | ||
|
||
jQuery(document.body).append(po.join('')); | ||
jQuery(document.body).append( | ||
ax5.mustache.render(getBodyTmpl(), { | ||
theme: _cfg.theme, | ||
maskId: maskId, | ||
body: this.maskContent | ||
}) | ||
); | ||
|
||
if (target && target !== jQuery(document.body).get(0)) { | ||
css = { | ||
position: config.position || "absolute", | ||
position: _cfg.position || "absolute", | ||
left: $target.offset().left, | ||
top: $target.offset().top, | ||
width: $target.outerWidth(), | ||
|
@@ -123,22 +138,21 @@ | |
this.status = "on"; | ||
$mask.css(css); | ||
|
||
if (config.onClick) { | ||
$mask.click(function(){ | ||
if (this.onClick) { | ||
$mask.click(function () { | ||
that = { | ||
self: this, | ||
state: "open", | ||
type: "click" | ||
}; | ||
config.onClick.call(that, that); | ||
this.onClick.call(that, that); | ||
}); | ||
} | ||
if (config.onStateChanged) { | ||
that = { | ||
self: this, | ||
state: "open" | ||
}; | ||
config.onStateChanged.call(that, that); | ||
} | ||
|
||
onStateChanged.call(this, null, { | ||
self: this, | ||
state: "open" | ||
}); | ||
return this; | ||
}; | ||
|
||
|
@@ -152,16 +166,13 @@ | |
* ``` | ||
*/ | ||
this.close = function () { | ||
var config = this.maskConfig, that; | ||
this.$mask.remove(); | ||
this.$target.removeClass("ax-masking"); | ||
if (config && config.onStateChanged) { | ||
that = { | ||
self: this, | ||
state: "close" | ||
}; | ||
config.onStateChanged.call(that, that); | ||
} | ||
|
||
onStateChanged.call(this, null, { | ||
self: this, | ||
state: "close" | ||
}); | ||
return this; | ||
}; | ||
//== class body end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters