Skip to content

Commit

Permalink
fix #37
Browse files Browse the repository at this point in the history
  • Loading branch information
minghe committed Sep 18, 2012
1 parent c8aa80a commit 6a47319
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
41 changes: 36 additions & 5 deletions gallery/form/1.3/auth/msg/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @author czy88840616 <[email protected]>
*
*/
KISSY.add('gallery/form/1.3/auth/msg/base', function (S, Base) {

KISSY.add('gallery/form/1.3/auth/msg/base', function (S, Base,Node) {
var $ = Node.all;
/**
* msg cls
* @type {String}
Expand Down Expand Up @@ -32,12 +32,13 @@ KISSY.add('gallery/form/1.3/auth/msg/base', function (S, Base) {
self._el = S.one(srcNode);
self.set('tpl', cfg.tpl);
self.set('args', cfg.args);
var $wrapper = self._getWrapper();

self._msgContainer = S.one('.' + AUTH_MSG_CLS, self._el.parent());
self._msgContainer = S.one('.' + AUTH_MSG_CLS, $wrapper);

if(!self._msgContainer) {
self._msgContainer = S.one('<div class="' + AUTH_MSG_CLS +'" style="display: none"></div>');
self._el.parent().append(self._msgContainer);
$wrapper.append(self._msgContainer);
}

},
Expand All @@ -56,6 +57,24 @@ KISSY.add('gallery/form/1.3/auth/msg/base', function (S, Base) {
self._msgContainer.html(S.substitute(self.get('tpl'), o));
self._msgContainer.show();
}, 50)();
},
/**
* 获取消息层容器
* @private
*/
_getWrapper:function(){
var self = this;
var $wrapper = self.get('wrapper');
var $target = self._el;

//html标签属性上存在消息层
var wrapperHook = $target.attr('msg-wrapper');
if(wrapperHook) $wrapper = $(wrapperHook);

if(!$wrapper || !$wrapper.length){
$wrapper = $target.parent();
}
return $wrapper;
}
}, {
ATTRS:{
Expand All @@ -64,6 +83,17 @@ KISSY.add('gallery/form/1.3/auth/msg/base', function (S, Base) {
},
args:{
value:{}
},
/**
* 消息层容器
* @type String
* @default ''
*/
wrapper:{
value:'',
getter:function(v){
return $(v);
}
}
}
});
Expand All @@ -72,6 +102,7 @@ KISSY.add('gallery/form/1.3/auth/msg/base', function (S, Base) {

}, {
requires:[
'base'
'base',
'node'
]
});
1 change: 1 addition & 0 deletions gallery/form/1.3/auth/rule/ruleFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ KISSY.add('gallery/form/1.3/auth/rule/ruleFactory', function (S, Node,Base, Prop
_setMsg:function(el,ruleName){
var $el = $(el);
var msg = {};
//元素可能是一组,比如radio或chekcbox
if(!el.length) return msg;
var success = $el.attr(ruleName+'-success-msg');
var error = $el.attr(ruleName + '-msg');
Expand Down
3 changes: 3 additions & 0 deletions gallery/form/1.3/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,11 @@ <h5>[+] 新增Select</h5>
<h5>[+] 新增List</h5>
<h5>Auth</h5>
<ol class="list detail-list">
<li>[+] #34消息采用更简单属性配置方式</li>
<li>[+] #37可以通过msg-wrapper来配置消息层容器</li>
<li>[!] add方法返回Field实例</li>
<li>[!] 第一个参数可以为空</li>
<li>[!] #35修复消息层显示后无法隐藏的bug</li>
</ol>
<h5>Limiter</h5>
<ol class="list detail-list">
Expand Down

0 comments on commit 6a47319

Please sign in to comment.