Browse Source

Pull request #2188: 无JIAR任务 优化一下

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit '32685f14ce9c689c22ebbd7de96ce9d7addee9da':
  支持自动watch
  支持自动watch
es6
guy 3 years ago
parent
commit
ae8bf7e350
  1. 24
      src/core/4.widget.js

24
src/core/4.widget.js

@ -164,9 +164,7 @@
if (o.cls) {
if (BI.isFunction(o.cls)) {
var cls = this.__watch(o.cls, function (newValue) {
if (newValue !== cls) {
self.element.removeClass(cls).addClass(cls = newValue);
}
});
this.element.addClass(cls);
} else {
@ -191,6 +189,8 @@
}
}
self.element.css(css = newValue);
}, {
deep: true
});
this.element.css(css);
} else {
@ -199,10 +199,10 @@
}
},
__watch: function (getter, handler) {
__watch: function (getter, handler, options) {
if (Fix.Model.target) {
this._watchers = this._watchers || [];
var watcher = new Fix.Watcher(Fix.Model.target, BI.bind(getter, this), handler || BI.emptyFn);
var watcher = new Fix.Watcher(Fix.Model.target, BI.bind(getter, this), (handler && BI.bind(handler, this)) || BI.emptyFn, options);
this._watchers.push(watcher);
return watcher.value;
} else {
@ -259,7 +259,7 @@
},
_initEffects: function () {
var o = this.options;
var self = this, o = this.options;
if (o.disabled || o.invalid) {
if (this.options.disabled) {
this.setEnable(false);
@ -269,8 +269,22 @@
}
}
if (o.effect) {
if (BI.isArray(o.effect)) {
if (BI.isArray(o.effect[0])) {
BI.each(o.effect, function (i, effect) {
self.__watch(effect[0], effect[1], {
deep: true
});
});
} else {
self.__watch(o.effect[0], o.effect[1], {
deep: true
});
}
} else {
this.__watch(o.effect);
}
}
},
_initState: function () {

Loading…
Cancel
Save