Dailer 6 years ago
parent
commit
58594d3f7e
  1. 838
      dist/bundle.js
  2. 8
      dist/bundle.min.js
  3. 813
      dist/core.js
  4. 838
      dist/fineui.js
  5. 8
      dist/fineui.min.js

838
dist/bundle.js vendored

@ -21344,469 +21344,498 @@ _.extend(BI.OB.prototype, {
* *
* @cfg {JSON} options 配置属性 * @cfg {JSON} options 配置属性
*/ */
BI.Widget = BI.inherit(BI.OB, {
_defaultConfig: function () {
return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
root: false,
tagName: "div",
attributes: null,
data: null,
tag: null, !(function () {
disabled: false, var lazy = (typeof document !== 'undefined' &&
invisible: false, typeof document.documentMode === 'number') ||
invalid: false, (typeof navigator !== 'undefined' &&
baseCls: "", typeof navigator.userAgent === 'string' &&
extraCls: "", /\bEdge\/\d/.test(navigator.userAgent));
cls: "" BI.Widget = BI.inherit(BI.OB, {
}); _defaultConfig: function () {
}, return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
root: false,
tagName: "div",
attributes: null,
data: null,
tag: null,
disabled: false,
invisible: false,
invalid: false,
baseCls: "",
extraCls: "",
cls: ""
});
},
beforeInit: null, beforeInit: null,
// 生命周期函数 // 生命周期函数
beforeCreate: null, beforeCreate: null,
created: null, created: null,
render: null, render: null,
beforeMount: null, beforeMount: null,
mounted: null, mounted: null,
shouldUpdate: null, shouldUpdate: null,
update: function () { update: function () {
}, },
beforeDestroy: null, beforeDestroy: null,
destroyed: null, destroyed: null,
_init: function () { _init: function () {
BI.Widget.superclass._init.apply(this, arguments); BI.Widget.superclass._init.apply(this, arguments);
this._initRoot(); this._initRoot();
this._initElementWidth(); this._initElementWidth();
this._initElementHeight(); this._initElementHeight();
this._initVisual(); this._initVisual();
this._initState(); this._initState();
if (this.beforeInit) { if (this.isVisible()) {
this.__asking = true; if (this.beforeInit) {
this.beforeInit(BI.bind(this._render, this)); this.__asking = true;
if (this.__asking === true) { this.beforeInit(BI.bind(this._render, this));
this.__async = true; if (this.__asking === true) {
this.__async = true;
}
} else {
this._render();
}
this.rendered = true
} }
} else { if (this._isRoot) {
this._render(); this._mount()
} }
}, },
_render: function () { _render: function () {
this.__asking = false; this.__asking = false;
this.beforeCreate && this.beforeCreate(); this.beforeCreate && this.beforeCreate();
this._initElement(); this._initElement();
this._initEffects(); this._initEffects();
this.created && this.created(); this.created && this.created();
}, },
/** /**
* 初始化根节点 * 初始化根节点
* @private * @private
*/ */
_initRoot: function () { _initRoot: function () {
var o = this.options; var o = this.options;
this.widgetName = o.widgetName || BI.uniqueId("widget"); this.widgetName = o.widgetName || BI.uniqueId("widget");
this._isRoot = o.root; this._isRoot = o.root;
if (BI.isWidget(o.element)) { if (BI.isWidget(o.element)) {
if (o.element instanceof BI.Widget) { if (o.element instanceof BI.Widget) {
this._parent = o.element; this._parent = o.element;
this._parent.addWidget(this.widgetName, this); this._parent.addWidget(this.widgetName, this);
} else { } else {
this._isRoot = true;
}
this.element = this.options.element.element;
} else if (o.element) {
// if (o.root !== true) {
// throw new Error("root is a required property");
// }
this.element = $(o.element);
this._isRoot = true; this._isRoot = true;
} else {
this.element = $(document.createElement(o.tagName));
} }
this.element = this.options.element.element; this.element._isWidget = true;
} else if (o.element) { if (o.baseCls || o.extraCls || o.cls) {
// if (o.root !== true) { this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || ""));
// throw new Error("root is a required property"); }
// } if (o.attributes) {
this.element = $(o.element); this.element.attr(o.attributes);
this._isRoot = true; }
} else { if (o.data) {
this.element = $(document.createElement(o.tagName)); this.element.data(o.data);
} }
this.element._isWidget = true; this._children = {};
if (o.baseCls || o.extraCls || o.cls) { },
this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || ""));
}
if (o.attributes) {
this.element.attr(o.attributes);
}
if (o.data) {
this.element.data(o.data);
}
this._children = {};
},
_initElementWidth: function () {
var o = this.options;
if (BI.isWidthOrHeight(o.width)) {
this.element.css("width", o.width);
}
},
_initElementHeight: function () { _initElementWidth: function () {
var o = this.options; var o = this.options;
if (BI.isWidthOrHeight(o.height)) { if (BI.isWidthOrHeight(o.width)) {
this.element.css("height", o.height); this.element.css("width", o.width);
} }
}, },
_initVisual: function () { _initElementHeight: function () {
var o = this.options; var o = this.options;
if (o.invisible) { if (BI.isWidthOrHeight(o.height)) {
// 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 this.element.css("height", o.height);
this.element.css("display", "none"); }
} },
},
_initEffects: function () { _initVisual: function () {
var o = this.options; var o = this.options;
if (o.disabled || o.invalid) { if (o.invisible) {
if (this.options.disabled) { // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.setEnable(false); this.element.css("display", "none");
} }
if (this.options.invalid) { },
this.setValid(false);
_initEffects: function () {
var o = this.options;
if (o.disabled || o.invalid) {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
} }
} },
},
_initState: function () { _initState: function () {
this._isMounted = false; this._isMounted = false;
}, },
_initElement: function () { _initElement: function () {
var self = this; var self = this;
var els = this.render && this.render(); var els = this.render && this.render();
if (BI.isPlainObject(els)) { if (BI.isPlainObject(els)) {
els = [els]; els = [els];
} }
if (BI.isArray(els)) { if (BI.isArray(els)) {
BI.each(els, function (i, el) { BI.each(els, function (i, el) {
BI.createWidget(el, { BI.createWidget(el, {
element: self element: self
});
}); });
}); }
} // if (this._isRoot === true || !(this instanceof BI.Layout)) {
// if (this._isRoot === true || !(this instanceof BI.Layout)) { this._mount();
this._mount(); // }
// } },
},
_setParent: function (parent) { _setParent: function (parent) {
this._parent = parent; this._parent = parent;
}, },
_mount: function () { _mount: function () {
var self = this; var self = this;
var isMounted = this._isMounted; var isMounted = this._isMounted;
if (isMounted || !this.isVisible() || this.__asking === true) { if (this._isMounting || isMounted || !this.isVisible() || this.__asking === true) {
return; return;
} }
if (this._isRoot === true) { if (this._isRoot === true) {
isMounted = true; isMounted = true;
} else if (this._parent && this._parent._isMounted === true) { } else if (this._parent && this._parent._isMounted === true) {
isMounted = true; isMounted = true;
} }
if (!isMounted) { if (!isMounted) {
return; return;
} }
this.beforeMount && this.beforeMount(); this._isMounting = true
this._isMounted = true; if (!this.rendered) {
this._mountChildren && this._mountChildren(); if (this.beforeInit) {
BI.each(this._children, function (i, widget) { this.__asking = true;
!self.isEnabled() && widget._setEnable(false); this.beforeInit(BI.bind(this._render, this));
!self.isValid() && widget._setValid(false); if (this.__asking === true) {
widget._mount && widget._mount(); this.__async = true;
}); }
this.mounted && this.mounted(); } else {
}, this._render();
}
}
_mountChildren: null, this.beforeMount && this.beforeMount();
this._isMounted = true;
lazy && this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount();
});
!lazy && this._mountChildren && this._mountChildren();
this.mounted && this.mounted();
this._isMounting = false
},
isMounted: function () { _mountChildren: null,
return this._isMounted;
},
setWidth: function (w) { isMounted: function () {
this.options.width = w; return this._isMounted;
this._initElementWidth(); },
},
setHeight: function (h) { setWidth: function (w) {
this.options.height = h; this.options.width = w;
this._initElementHeight(); this._initElementWidth();
}, },
_setEnable: function (enable) { setHeight: function (h) {
if (enable === true) { this.options.height = h;
this.options.disabled = false; this._initElementHeight();
} else if (enable === false) { },
this.options.disabled = true;
}
// 递归将所有子组件使能
BI.each(this._children, function (i, child) {
!child._manualSetEnable && child._setEnable && child._setEnable(enable);
});
},
_setValid: function (valid) { _setEnable: function (enable) {
if (valid === true) { if (enable === true) {
this.options.invalid = false; this.options.disabled = false;
} else if (valid === false) { } else if (enable === false) {
this.options.invalid = true; this.options.disabled = true;
} }
// 递归将所有子组件使有效 // 递归将所有子组件使能
BI.each(this._children, function (i, child) { BI.each(this._children, function (i, child) {
!child._manualSetValid && child._setValid && child._setValid(valid); !child._manualSetEnable && child._setEnable && child._setEnable(enable);
}); });
}, },
_setVisible: function (visible) { _setValid: function (valid) {
if (visible === true) { if (valid === true) {
this.options.invisible = false; this.options.invalid = false;
} else if (visible === false) { } else if (valid === false) {
this.options.invisible = true; this.options.invalid = true;
} }
}, // 递归将所有子组件使有效
BI.each(this._children, function (i, child) {
!child._manualSetValid && child._setValid && child._setValid(valid);
});
},
setEnable: function (enable) { _setVisible: function (visible) {
this._manualSetEnable = true; if (visible === true) {
this._setEnable(enable); this.options.invisible = false;
if (enable === true) { } else if (visible === false) {
this.element.removeClass("base-disabled disabled"); this.options.invisible = true;
} else if (enable === false) { }
this.element.addClass("base-disabled disabled"); },
}
},
setVisible: function (visible) { setEnable: function (enable) {
this._setVisible(visible); this._manualSetEnable = true;
if (visible === true) { this._setEnable(enable);
// 用this.element.show()会把display属性改成block if (enable === true) {
this.element.css("display", ""); this.element.removeClass("base-disabled disabled");
this._mount(); } else if (enable === false) {
} else if (visible === false) { this.element.addClass("base-disabled disabled");
this.element.css("display", "none"); }
} },
this.fireEvent(BI.Events.VIEW, visible);
},
setValid: function (valid) { setVisible: function (visible) {
this._manualSetValid = true; this._setVisible(visible);
this._setValid(valid); if (visible === true) {
if (valid === true) { // 用this.element.show()会把display属性改成block
this.element.removeClass("base-invalid invalid"); this.element.css("display", "");
} else if (valid === false) { this._mount();
this.element.addClass("base-invalid invalid"); } else if (visible === false) {
} this.element.css("display", "none");
}, }
this.fireEvent(BI.Events.VIEW, visible);
},
doBehavior: function () { setValid: function (valid) {
var args = arguments; this._manualSetValid = true;
// 递归将所有子组件使有效 this._setValid(valid);
BI.each(this._children, function (i, child) { if (valid === true) {
child.doBehavior && child.doBehavior.apply(child, args); this.element.removeClass("base-invalid invalid");
}); } else if (valid === false) {
}, this.element.addClass("base-invalid invalid");
}
},
getWidth: function () { doBehavior: function () {
return this.options.width; var args = arguments;
}, // 递归将所有子组件使有效
BI.each(this._children, function (i, child) {
child.doBehavior && child.doBehavior.apply(child, args);
});
},
getHeight: function () { getWidth: function () {
return this.options.height; return this.options.width;
}, },
isValid: function () { getHeight: function () {
return !this.options.invalid; return this.options.height;
}, },
addWidget: function (name, widget) { isValid: function () {
var self = this; return !this.options.invalid;
if (name instanceof BI.Widget) { },
widget = name;
name = widget.getName();
}
if (BI.isKey(name)) {
name = name + "";
}
name = name || widget.getName() || BI.uniqueId("widget");
if (this._children[name]) {
throw new Error("name has already been existed");
}
widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () {
BI.remove(self._children, this);
});
return (this._children[name] = widget);
},
getWidgetByName: function (name) { addWidget: function (name, widget) {
if (!BI.isKey(name) || name === this.getName()) { var self = this;
return this; if (name instanceof BI.Widget) {
} widget = name;
name = name + ""; name = widget.getName();
var widget = void 0, other = {};
BI.any(this._children, function (i, wi) {
if (i === name) {
widget = wi;
return true;
} }
other[i] = wi; if (BI.isKey(name)) {
}); name = name + "";
if (!widget) { }
BI.any(other, function (i, wi) { name = name || widget.getName() || BI.uniqueId("widget");
return (widget = wi.getWidgetByName(i)); if (this._children[name]) {
throw new Error("name has already been existed");
}
widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () {
BI.remove(self._children, this);
}); });
} return (this._children[name] = widget);
return widget; },
},
removeWidget: function (nameOrWidget) { getWidgetByName: function (name) {
var self = this; if (!BI.isKey(name) || name === this.getName()) {
if (BI.isWidget(nameOrWidget)) { return this;
BI.remove(this._children, nameOrWidget); }
} else { name = name + "";
delete this._children[nameOrWidget]; var widget = void 0, other = {};
} BI.any(this._children, function (i, wi) {
}, if (i === name) {
widget = wi;
return true;
}
other[i] = wi;
});
if (!widget) {
BI.any(other, function (i, wi) {
return (widget = wi.getWidgetByName(i));
});
}
return widget;
},
hasWidget: function (name) { removeWidget: function (nameOrWidget) {
return this._children[name] != null; var self = this;
}, if (BI.isWidget(nameOrWidget)) {
BI.remove(this._children, nameOrWidget);
} else {
delete this._children[nameOrWidget];
}
},
getName: function () { hasWidget: function (name) {
return this.widgetName; return this._children[name] != null;
}, },
setTag: function (tag) { getName: function () {
this.options.tag = tag; return this.widgetName;
}, },
getTag: function () { setTag: function (tag) {
return this.options.tag; this.options.tag = tag;
}, },
attr: function (key, value) { getTag: function () {
var self = this; return this.options.tag;
if (BI.isPlainObject(key)) { },
BI.each(key, function (k, v) {
self.attr(k, v);
});
return;
}
if (BI.isNotNull(value)) {
return this.options[key] = value;
}
return this.options[key];
},
getText: function () { attr: function (key, value) {
var self = this;
if (BI.isPlainObject(key)) {
BI.each(key, function (k, v) {
self.attr(k, v);
});
return;
}
if (BI.isNotNull(value)) {
return this.options[key] = value;
}
return this.options[key];
},
}, getText: function () {
setText: function (text) { },
}, setText: function (text) {
getValue: function () { },
}, getValue: function () {
setValue: function (value) { },
}, setValue: function (value) {
isEnabled: function () { },
return !this.options.disabled;
},
isVisible: function () { isEnabled: function () {
return !this.options.invisible; return !this.options.disabled;
}, },
disable: function () { isVisible: function () {
this.setEnable(false); return !this.options.invisible;
}, },
enable: function () { disable: function () {
this.setEnable(true); this.setEnable(false);
}, },
valid: function () { enable: function () {
this.setValid(true); this.setEnable(true);
}, },
invalid: function () { valid: function () {
this.setValid(false); this.setValid(true);
}, },
invisible: function () { invalid: function () {
this.setVisible(false); this.setValid(false);
}, },
visible: function () { invisible: function () {
this.setVisible(true); this.setVisible(false);
}, },
__d: function () { visible: function () {
this.beforeDestroy && this.beforeDestroy(); this.setVisible(true);
BI.each(this._children, function (i, widget) { },
widget && widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed && this.destroyed();
},
_unMount: function () { __d: function () {
this.__d(); this.beforeDestroy && this.beforeDestroy();
this.fireEvent(BI.Events.UNMOUNT); BI.each(this._children, function (i, widget) {
this.purgeListeners(); widget && widget._unMount && widget._unMount();
}, });
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed && this.destroyed();
},
isolate: function () { _unMount: function () {
if (this._parent) { this.__d();
this._parent.removeWidget(this); this.fireEvent(BI.Events.UNMOUNT);
} this.purgeListeners();
BI.DOM.hang([this]); },
},
empty: function () { isolate: function () {
BI.each(this._children, function (i, widget) { if (this._parent) {
widget && widget._unMount && widget._unMount(); this._parent.removeWidget(this);
}); }
this._children = {}; BI.DOM.hang([this]);
this.element.empty(); },
},
_destroy: function () { empty: function () {
this.__d(); BI.each(this._children, function (i, widget) {
this.element.destroy(); widget && widget._unMount && widget._unMount();
this.purgeListeners(); });
}, this._children = {};
this.element.empty();
},
destroy: function () { _destroy: function () {
this.__d(); this.__d();
this.element.destroy(); this.element.destroy();
this.fireEvent(BI.Events.DESTROY); this.purgeListeners();
this._purgeRef(); },
this.purgeListeners();
} destroy: function () {
});(function () { this.__d();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
this._purgeRef();
this.purgeListeners();
}
});
})();(function () {
var kv = {}; var kv = {};
BI.shortcut = function (xtype, cls) { BI.shortcut = function (xtype, cls) {
if (kv[xtype] != null) { if (kv[xtype] != null) {
@ -81324,7 +81353,7 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
}); });
BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
function initWatch (vm, watch) { function initWatch(vm, watch) {
vm._watchers || (vm._watchers = []); vm._watchers || (vm._watchers = []);
for (var key in watch) { for (var key in watch) {
var handler = watch[key]; var handler = watch[key];
@ -81338,7 +81367,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
} }
} }
function createWatcher (vm, keyOrFn, handler) { function createWatcher(vm, keyOrFn, handler) {
return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), { return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), {
store: vm.store store: vm.store
}); });
@ -81347,24 +81376,24 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
var target = null; var target = null;
var targetStack = []; var targetStack = [];
function pushTarget (_target) { function pushTarget(_target) {
if (target) targetStack.push(target); if (target) targetStack.push(target);
Fix.Model.target = target = _target; Fix.Model.target = target = _target;
} }
function popTarget () { function popTarget() {
Fix.Model.target = target = targetStack.pop(); Fix.Model.target = target = targetStack.pop();
} }
var context = null; var context = null;
var contextStack = []; var contextStack = [];
function pushContext (_context) { function pushContext(_context) {
if (context) contextStack.push(context); if (context) contextStack.push(context);
Fix.Model.context = context = _context; Fix.Model.context = context = _context;
} }
function popContext () { function popContext() {
Fix.Model.context = context = contextStack.pop(); Fix.Model.context = context = contextStack.pop();
} }
@ -81385,7 +81414,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
}, options); }, options);
}; };
function findStore (widget) { function findStore(widget) {
if (target != null) { if (target != null) {
return target; return target;
} }
@ -81431,12 +81460,11 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
}; };
}); });
var _init = BI.Widget.prototype._init; function createStore() {
BI.Widget.prototype._init = function () {
var self = this;
var needPop = false; var needPop = false;
if (window.Fix && this._store) { if (!this._storeCreated && window.Fix && this._store && this.isVisible()) {
var store = findStore(this.options.context || this.options.element); var store = findStore(this.options.context || this.options.element);
this._storeCreated = true;
if (store) { if (store) {
pushTarget(store); pushTarget(store);
needPop = true; needPop = true;
@ -81453,6 +81481,13 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
} }
needPop = true; needPop = true;
} }
return needPop;
}
var _init = BI.Widget.prototype._init;
BI.Widget.prototype._init = function () {
var self = this;
var needPop = createStore.call(this);
_init.apply(this, arguments); _init.apply(this, arguments);
needPop && popTarget(); needPop && popTarget();
}; };
@ -81491,6 +81526,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
_.each(["_mount"], function (name) { _.each(["_mount"], function (name) {
var old = BI.Widget.prototype[name]; var old = BI.Widget.prototype[name];
old && (BI.Widget.prototype[name] = function () { old && (BI.Widget.prototype[name] = function () {
createStore.call(this);
this.store && pushTarget(this.store); this.store && pushTarget(this.store);
var res = old.apply(this, arguments); var res = old.apply(this, arguments);
this.store && popTarget(); this.store && popTarget();

8
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

813
dist/core.js vendored

@ -21344,469 +21344,498 @@ _.extend(BI.OB.prototype, {
* *
* @cfg {JSON} options 配置属性 * @cfg {JSON} options 配置属性
*/ */
BI.Widget = BI.inherit(BI.OB, {
_defaultConfig: function () {
return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
root: false,
tagName: "div",
attributes: null,
data: null,
tag: null,
disabled: false,
invisible: false,
invalid: false,
baseCls: "",
extraCls: "",
cls: ""
});
},
beforeInit: null, !(function () {
var lazy = (typeof document !== 'undefined' &&
// 生命周期函数 typeof document.documentMode === 'number') ||
beforeCreate: null, (typeof navigator !== 'undefined' &&
typeof navigator.userAgent === 'string' &&
/\bEdge\/\d/.test(navigator.userAgent));
BI.Widget = BI.inherit(BI.OB, {
_defaultConfig: function () {
return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
root: false,
tagName: "div",
attributes: null,
data: null,
tag: null,
disabled: false,
invisible: false,
invalid: false,
baseCls: "",
extraCls: "",
cls: ""
});
},
created: null, beforeInit: null,
render: null, // 生命周期函数
beforeCreate: null,
beforeMount: null, created: null,
mounted: null, render: null,
shouldUpdate: null, beforeMount: null,
update: function () { mounted: null,
},
beforeDestroy: null, shouldUpdate: null,
destroyed: null, update: function () {
},
_init: function () { beforeDestroy: null,
BI.Widget.superclass._init.apply(this, arguments);
this._initRoot(); destroyed: null,
this._initElementWidth();
this._initElementHeight(); _init: function () {
this._initVisual(); BI.Widget.superclass._init.apply(this, arguments);
this._initState(); this._initRoot();
if (this.beforeInit) { this._initElementWidth();
this.__asking = true; this._initElementHeight();
this.beforeInit(BI.bind(this._render, this)); this._initVisual();
if (this.__asking === true) { this._initState();
this.__async = true; if (this.isVisible()) {
if (this.beforeInit) {
this.__asking = true;
this.beforeInit(BI.bind(this._render, this));
if (this.__asking === true) {
this.__async = true;
}
} else {
this._render();
}
this.rendered = true
} }
} else { if (this._isRoot) {
this._render(); this._mount()
} }
}, },
_render: function () { _render: function () {
this.__asking = false; this.__asking = false;
this.beforeCreate && this.beforeCreate(); this.beforeCreate && this.beforeCreate();
this._initElement(); this._initElement();
this._initEffects(); this._initEffects();
this.created && this.created(); this.created && this.created();
}, },
/** /**
* 初始化根节点 * 初始化根节点
* @private * @private
*/ */
_initRoot: function () { _initRoot: function () {
var o = this.options; var o = this.options;
this.widgetName = o.widgetName || BI.uniqueId("widget"); this.widgetName = o.widgetName || BI.uniqueId("widget");
this._isRoot = o.root; this._isRoot = o.root;
if (BI.isWidget(o.element)) { if (BI.isWidget(o.element)) {
if (o.element instanceof BI.Widget) { if (o.element instanceof BI.Widget) {
this._parent = o.element; this._parent = o.element;
this._parent.addWidget(this.widgetName, this); this._parent.addWidget(this.widgetName, this);
} else { } else {
this._isRoot = true;
}
this.element = this.options.element.element;
} else if (o.element) {
// if (o.root !== true) {
// throw new Error("root is a required property");
// }
this.element = $(o.element);
this._isRoot = true; this._isRoot = true;
} else {
this.element = $(document.createElement(o.tagName));
} }
this.element = this.options.element.element; this.element._isWidget = true;
} else if (o.element) { if (o.baseCls || o.extraCls || o.cls) {
// if (o.root !== true) { this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || ""));
// throw new Error("root is a required property"); }
// } if (o.attributes) {
this.element = $(o.element); this.element.attr(o.attributes);
this._isRoot = true; }
} else { if (o.data) {
this.element = $(document.createElement(o.tagName)); this.element.data(o.data);
} }
this.element._isWidget = true; this._children = {};
if (o.baseCls || o.extraCls || o.cls) { },
this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || ""));
}
if (o.attributes) {
this.element.attr(o.attributes);
}
if (o.data) {
this.element.data(o.data);
}
this._children = {};
},
_initElementWidth: function () {
var o = this.options;
if (BI.isWidthOrHeight(o.width)) {
this.element.css("width", o.width);
}
},
_initElementHeight: function () { _initElementWidth: function () {
var o = this.options; var o = this.options;
if (BI.isWidthOrHeight(o.height)) { if (BI.isWidthOrHeight(o.width)) {
this.element.css("height", o.height); this.element.css("width", o.width);
} }
}, },
_initVisual: function () { _initElementHeight: function () {
var o = this.options; var o = this.options;
if (o.invisible) { if (BI.isWidthOrHeight(o.height)) {
// 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 this.element.css("height", o.height);
this.element.css("display", "none"); }
} },
},
_initEffects: function () { _initVisual: function () {
var o = this.options; var o = this.options;
if (o.disabled || o.invalid) { if (o.invisible) {
if (this.options.disabled) { // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.setEnable(false); this.element.css("display", "none");
} }
if (this.options.invalid) { },
this.setValid(false);
_initEffects: function () {
var o = this.options;
if (o.disabled || o.invalid) {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
} }
} },
},
_initState: function () { _initState: function () {
this._isMounted = false; this._isMounted = false;
}, },
_initElement: function () { _initElement: function () {
var self = this; var self = this;
var els = this.render && this.render(); var els = this.render && this.render();
if (BI.isPlainObject(els)) { if (BI.isPlainObject(els)) {
els = [els]; els = [els];
} }
if (BI.isArray(els)) { if (BI.isArray(els)) {
BI.each(els, function (i, el) { BI.each(els, function (i, el) {
BI.createWidget(el, { BI.createWidget(el, {
element: self element: self
});
}); });
}); }
} // if (this._isRoot === true || !(this instanceof BI.Layout)) {
// if (this._isRoot === true || !(this instanceof BI.Layout)) { this._mount();
this._mount(); // }
// } },
},
_setParent: function (parent) { _setParent: function (parent) {
this._parent = parent; this._parent = parent;
}, },
_mount: function () { _mount: function () {
var self = this; var self = this;
var isMounted = this._isMounted; var isMounted = this._isMounted;
if (isMounted || !this.isVisible() || this.__asking === true) { if (this._isMounting || isMounted || !this.isVisible() || this.__asking === true) {
return; return;
} }
if (this._isRoot === true) { if (this._isRoot === true) {
isMounted = true; isMounted = true;
} else if (this._parent && this._parent._isMounted === true) { } else if (this._parent && this._parent._isMounted === true) {
isMounted = true; isMounted = true;
} }
if (!isMounted) { if (!isMounted) {
return; return;
} }
this.beforeMount && this.beforeMount(); this._isMounting = true
this._isMounted = true; if (!this.rendered) {
this._mountChildren && this._mountChildren(); if (this.beforeInit) {
BI.each(this._children, function (i, widget) { this.__asking = true;
!self.isEnabled() && widget._setEnable(false); this.beforeInit(BI.bind(this._render, this));
!self.isValid() && widget._setValid(false); if (this.__asking === true) {
widget._mount && widget._mount(); this.__async = true;
}); }
this.mounted && this.mounted(); } else {
}, this._render();
}
}
_mountChildren: null, this.beforeMount && this.beforeMount();
this._isMounted = true;
lazy && this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount();
});
!lazy && this._mountChildren && this._mountChildren();
this.mounted && this.mounted();
this._isMounting = false
},
isMounted: function () { _mountChildren: null,
return this._isMounted;
},
setWidth: function (w) { isMounted: function () {
this.options.width = w; return this._isMounted;
this._initElementWidth(); },
},
setHeight: function (h) { setWidth: function (w) {
this.options.height = h; this.options.width = w;
this._initElementHeight(); this._initElementWidth();
}, },
_setEnable: function (enable) { setHeight: function (h) {
if (enable === true) { this.options.height = h;
this.options.disabled = false; this._initElementHeight();
} else if (enable === false) { },
this.options.disabled = true;
}
// 递归将所有子组件使能
BI.each(this._children, function (i, child) {
!child._manualSetEnable && child._setEnable && child._setEnable(enable);
});
},
_setValid: function (valid) { _setEnable: function (enable) {
if (valid === true) { if (enable === true) {
this.options.invalid = false; this.options.disabled = false;
} else if (valid === false) { } else if (enable === false) {
this.options.invalid = true; this.options.disabled = true;
} }
// 递归将所有子组件使有效 // 递归将所有子组件使能
BI.each(this._children, function (i, child) { BI.each(this._children, function (i, child) {
!child._manualSetValid && child._setValid && child._setValid(valid); !child._manualSetEnable && child._setEnable && child._setEnable(enable);
}); });
}, },
_setVisible: function (visible) { _setValid: function (valid) {
if (visible === true) { if (valid === true) {
this.options.invisible = false; this.options.invalid = false;
} else if (visible === false) { } else if (valid === false) {
this.options.invisible = true; this.options.invalid = true;
} }
}, // 递归将所有子组件使有效
BI.each(this._children, function (i, child) {
!child._manualSetValid && child._setValid && child._setValid(valid);
});
},
setEnable: function (enable) { _setVisible: function (visible) {
this._manualSetEnable = true; if (visible === true) {
this._setEnable(enable); this.options.invisible = false;
if (enable === true) { } else if (visible === false) {
this.element.removeClass("base-disabled disabled"); this.options.invisible = true;
} else if (enable === false) { }
this.element.addClass("base-disabled disabled"); },
}
},
setVisible: function (visible) { setEnable: function (enable) {
this._setVisible(visible); this._manualSetEnable = true;
if (visible === true) { this._setEnable(enable);
// 用this.element.show()会把display属性改成block if (enable === true) {
this.element.css("display", ""); this.element.removeClass("base-disabled disabled");
this._mount(); } else if (enable === false) {
} else if (visible === false) { this.element.addClass("base-disabled disabled");
this.element.css("display", "none"); }
} },
this.fireEvent(BI.Events.VIEW, visible);
},
setValid: function (valid) { setVisible: function (visible) {
this._manualSetValid = true; this._setVisible(visible);
this._setValid(valid); if (visible === true) {
if (valid === true) { // 用this.element.show()会把display属性改成block
this.element.removeClass("base-invalid invalid"); this.element.css("display", "");
} else if (valid === false) { this._mount();
this.element.addClass("base-invalid invalid"); } else if (visible === false) {
} this.element.css("display", "none");
}, }
this.fireEvent(BI.Events.VIEW, visible);
},
doBehavior: function () { setValid: function (valid) {
var args = arguments; this._manualSetValid = true;
// 递归将所有子组件使有效 this._setValid(valid);
BI.each(this._children, function (i, child) { if (valid === true) {
child.doBehavior && child.doBehavior.apply(child, args); this.element.removeClass("base-invalid invalid");
}); } else if (valid === false) {
}, this.element.addClass("base-invalid invalid");
}
},
getWidth: function () { doBehavior: function () {
return this.options.width; var args = arguments;
}, // 递归将所有子组件使有效
BI.each(this._children, function (i, child) {
child.doBehavior && child.doBehavior.apply(child, args);
});
},
getHeight: function () { getWidth: function () {
return this.options.height; return this.options.width;
}, },
isValid: function () { getHeight: function () {
return !this.options.invalid; return this.options.height;
}, },
addWidget: function (name, widget) { isValid: function () {
var self = this; return !this.options.invalid;
if (name instanceof BI.Widget) { },
widget = name;
name = widget.getName();
}
if (BI.isKey(name)) {
name = name + "";
}
name = name || widget.getName() || BI.uniqueId("widget");
if (this._children[name]) {
throw new Error("name has already been existed");
}
widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () {
BI.remove(self._children, this);
});
return (this._children[name] = widget);
},
getWidgetByName: function (name) { addWidget: function (name, widget) {
if (!BI.isKey(name) || name === this.getName()) { var self = this;
return this; if (name instanceof BI.Widget) {
} widget = name;
name = name + ""; name = widget.getName();
var widget = void 0, other = {};
BI.any(this._children, function (i, wi) {
if (i === name) {
widget = wi;
return true;
} }
other[i] = wi; if (BI.isKey(name)) {
}); name = name + "";
if (!widget) { }
BI.any(other, function (i, wi) { name = name || widget.getName() || BI.uniqueId("widget");
return (widget = wi.getWidgetByName(i)); if (this._children[name]) {
throw new Error("name has already been existed");
}
widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () {
BI.remove(self._children, this);
}); });
} return (this._children[name] = widget);
return widget; },
},
removeWidget: function (nameOrWidget) { getWidgetByName: function (name) {
var self = this; if (!BI.isKey(name) || name === this.getName()) {
if (BI.isWidget(nameOrWidget)) { return this;
BI.remove(this._children, nameOrWidget); }
} else { name = name + "";
delete this._children[nameOrWidget]; var widget = void 0, other = {};
} BI.any(this._children, function (i, wi) {
}, if (i === name) {
widget = wi;
return true;
}
other[i] = wi;
});
if (!widget) {
BI.any(other, function (i, wi) {
return (widget = wi.getWidgetByName(i));
});
}
return widget;
},
hasWidget: function (name) { removeWidget: function (nameOrWidget) {
return this._children[name] != null; var self = this;
}, if (BI.isWidget(nameOrWidget)) {
BI.remove(this._children, nameOrWidget);
} else {
delete this._children[nameOrWidget];
}
},
getName: function () { hasWidget: function (name) {
return this.widgetName; return this._children[name] != null;
}, },
setTag: function (tag) { getName: function () {
this.options.tag = tag; return this.widgetName;
}, },
getTag: function () { setTag: function (tag) {
return this.options.tag; this.options.tag = tag;
}, },
attr: function (key, value) { getTag: function () {
var self = this; return this.options.tag;
if (BI.isPlainObject(key)) { },
BI.each(key, function (k, v) {
self.attr(k, v);
});
return;
}
if (BI.isNotNull(value)) {
return this.options[key] = value;
}
return this.options[key];
},
getText: function () { attr: function (key, value) {
var self = this;
if (BI.isPlainObject(key)) {
BI.each(key, function (k, v) {
self.attr(k, v);
});
return;
}
if (BI.isNotNull(value)) {
return this.options[key] = value;
}
return this.options[key];
},
}, getText: function () {
setText: function (text) { },
}, setText: function (text) {
getValue: function () { },
}, getValue: function () {
setValue: function (value) { },
}, setValue: function (value) {
isEnabled: function () { },
return !this.options.disabled;
},
isVisible: function () { isEnabled: function () {
return !this.options.invisible; return !this.options.disabled;
}, },
disable: function () { isVisible: function () {
this.setEnable(false); return !this.options.invisible;
}, },
enable: function () { disable: function () {
this.setEnable(true); this.setEnable(false);
}, },
valid: function () { enable: function () {
this.setValid(true); this.setEnable(true);
}, },
invalid: function () { valid: function () {
this.setValid(false); this.setValid(true);
}, },
invisible: function () { invalid: function () {
this.setVisible(false); this.setValid(false);
}, },
visible: function () { invisible: function () {
this.setVisible(true); this.setVisible(false);
}, },
__d: function () { visible: function () {
this.beforeDestroy && this.beforeDestroy(); this.setVisible(true);
BI.each(this._children, function (i, widget) { },
widget && widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed && this.destroyed();
},
_unMount: function () { __d: function () {
this.__d(); this.beforeDestroy && this.beforeDestroy();
this.fireEvent(BI.Events.UNMOUNT); BI.each(this._children, function (i, widget) {
this.purgeListeners(); widget && widget._unMount && widget._unMount();
}, });
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed && this.destroyed();
},
isolate: function () { _unMount: function () {
if (this._parent) { this.__d();
this._parent.removeWidget(this); this.fireEvent(BI.Events.UNMOUNT);
} this.purgeListeners();
BI.DOM.hang([this]); },
},
empty: function () { isolate: function () {
BI.each(this._children, function (i, widget) { if (this._parent) {
widget && widget._unMount && widget._unMount(); this._parent.removeWidget(this);
}); }
this._children = {}; BI.DOM.hang([this]);
this.element.empty(); },
},
_destroy: function () { empty: function () {
this.__d(); BI.each(this._children, function (i, widget) {
this.element.destroy(); widget && widget._unMount && widget._unMount();
this.purgeListeners(); });
}, this._children = {};
this.element.empty();
},
destroy: function () { _destroy: function () {
this.__d(); this.__d();
this.element.destroy(); this.element.destroy();
this.fireEvent(BI.Events.DESTROY); this.purgeListeners();
this._purgeRef(); },
this.purgeListeners();
} destroy: function () {
});(function () { this.__d();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
this._purgeRef();
this.purgeListeners();
}
});
})();(function () {
var kv = {}; var kv = {};
BI.shortcut = function (xtype, cls) { BI.shortcut = function (xtype, cls) {
if (kv[xtype] != null) { if (kv[xtype] != null) {

838
dist/fineui.js vendored

@ -21565,469 +21565,498 @@ _.extend(BI.OB.prototype, {
* *
* @cfg {JSON} options 配置属性 * @cfg {JSON} options 配置属性
*/ */
BI.Widget = BI.inherit(BI.OB, {
_defaultConfig: function () {
return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
root: false,
tagName: "div",
attributes: null,
data: null,
tag: null, !(function () {
disabled: false, var lazy = (typeof document !== 'undefined' &&
invisible: false, typeof document.documentMode === 'number') ||
invalid: false, (typeof navigator !== 'undefined' &&
baseCls: "", typeof navigator.userAgent === 'string' &&
extraCls: "", /\bEdge\/\d/.test(navigator.userAgent));
cls: "" BI.Widget = BI.inherit(BI.OB, {
}); _defaultConfig: function () {
}, return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
root: false,
tagName: "div",
attributes: null,
data: null,
tag: null,
disabled: false,
invisible: false,
invalid: false,
baseCls: "",
extraCls: "",
cls: ""
});
},
beforeInit: null, beforeInit: null,
// 生命周期函数 // 生命周期函数
beforeCreate: null, beforeCreate: null,
created: null, created: null,
render: null, render: null,
beforeMount: null, beforeMount: null,
mounted: null, mounted: null,
shouldUpdate: null, shouldUpdate: null,
update: function () { update: function () {
}, },
beforeDestroy: null, beforeDestroy: null,
destroyed: null, destroyed: null,
_init: function () { _init: function () {
BI.Widget.superclass._init.apply(this, arguments); BI.Widget.superclass._init.apply(this, arguments);
this._initRoot(); this._initRoot();
this._initElementWidth(); this._initElementWidth();
this._initElementHeight(); this._initElementHeight();
this._initVisual(); this._initVisual();
this._initState(); this._initState();
if (this.beforeInit) { if (this.isVisible()) {
this.__asking = true; if (this.beforeInit) {
this.beforeInit(BI.bind(this._render, this)); this.__asking = true;
if (this.__asking === true) { this.beforeInit(BI.bind(this._render, this));
this.__async = true; if (this.__asking === true) {
this.__async = true;
}
} else {
this._render();
}
this.rendered = true
} }
} else { if (this._isRoot) {
this._render(); this._mount()
} }
}, },
_render: function () { _render: function () {
this.__asking = false; this.__asking = false;
this.beforeCreate && this.beforeCreate(); this.beforeCreate && this.beforeCreate();
this._initElement(); this._initElement();
this._initEffects(); this._initEffects();
this.created && this.created(); this.created && this.created();
}, },
/** /**
* 初始化根节点 * 初始化根节点
* @private * @private
*/ */
_initRoot: function () { _initRoot: function () {
var o = this.options; var o = this.options;
this.widgetName = o.widgetName || BI.uniqueId("widget"); this.widgetName = o.widgetName || BI.uniqueId("widget");
this._isRoot = o.root; this._isRoot = o.root;
if (BI.isWidget(o.element)) { if (BI.isWidget(o.element)) {
if (o.element instanceof BI.Widget) { if (o.element instanceof BI.Widget) {
this._parent = o.element; this._parent = o.element;
this._parent.addWidget(this.widgetName, this); this._parent.addWidget(this.widgetName, this);
} else { } else {
this._isRoot = true;
}
this.element = this.options.element.element;
} else if (o.element) {
// if (o.root !== true) {
// throw new Error("root is a required property");
// }
this.element = $(o.element);
this._isRoot = true; this._isRoot = true;
} else {
this.element = $(document.createElement(o.tagName));
} }
this.element = this.options.element.element; this.element._isWidget = true;
} else if (o.element) { if (o.baseCls || o.extraCls || o.cls) {
// if (o.root !== true) { this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || ""));
// throw new Error("root is a required property"); }
// } if (o.attributes) {
this.element = $(o.element); this.element.attr(o.attributes);
this._isRoot = true; }
} else { if (o.data) {
this.element = $(document.createElement(o.tagName)); this.element.data(o.data);
} }
this.element._isWidget = true; this._children = {};
if (o.baseCls || o.extraCls || o.cls) { },
this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || ""));
}
if (o.attributes) {
this.element.attr(o.attributes);
}
if (o.data) {
this.element.data(o.data);
}
this._children = {};
},
_initElementWidth: function () {
var o = this.options;
if (BI.isWidthOrHeight(o.width)) {
this.element.css("width", o.width);
}
},
_initElementHeight: function () { _initElementWidth: function () {
var o = this.options; var o = this.options;
if (BI.isWidthOrHeight(o.height)) { if (BI.isWidthOrHeight(o.width)) {
this.element.css("height", o.height); this.element.css("width", o.width);
} }
}, },
_initVisual: function () { _initElementHeight: function () {
var o = this.options; var o = this.options;
if (o.invisible) { if (BI.isWidthOrHeight(o.height)) {
// 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 this.element.css("height", o.height);
this.element.css("display", "none"); }
} },
},
_initEffects: function () { _initVisual: function () {
var o = this.options; var o = this.options;
if (o.disabled || o.invalid) { if (o.invisible) {
if (this.options.disabled) { // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.setEnable(false); this.element.css("display", "none");
} }
if (this.options.invalid) { },
this.setValid(false);
_initEffects: function () {
var o = this.options;
if (o.disabled || o.invalid) {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
} }
} },
},
_initState: function () { _initState: function () {
this._isMounted = false; this._isMounted = false;
}, },
_initElement: function () { _initElement: function () {
var self = this; var self = this;
var els = this.render && this.render(); var els = this.render && this.render();
if (BI.isPlainObject(els)) { if (BI.isPlainObject(els)) {
els = [els]; els = [els];
} }
if (BI.isArray(els)) { if (BI.isArray(els)) {
BI.each(els, function (i, el) { BI.each(els, function (i, el) {
BI.createWidget(el, { BI.createWidget(el, {
element: self element: self
});
}); });
}); }
} // if (this._isRoot === true || !(this instanceof BI.Layout)) {
// if (this._isRoot === true || !(this instanceof BI.Layout)) { this._mount();
this._mount(); // }
// } },
},
_setParent: function (parent) { _setParent: function (parent) {
this._parent = parent; this._parent = parent;
}, },
_mount: function () { _mount: function () {
var self = this; var self = this;
var isMounted = this._isMounted; var isMounted = this._isMounted;
if (isMounted || !this.isVisible() || this.__asking === true) { if (this._isMounting || isMounted || !this.isVisible() || this.__asking === true) {
return; return;
} }
if (this._isRoot === true) { if (this._isRoot === true) {
isMounted = true; isMounted = true;
} else if (this._parent && this._parent._isMounted === true) { } else if (this._parent && this._parent._isMounted === true) {
isMounted = true; isMounted = true;
} }
if (!isMounted) { if (!isMounted) {
return; return;
} }
this.beforeMount && this.beforeMount(); this._isMounting = true
this._isMounted = true; if (!this.rendered) {
this._mountChildren && this._mountChildren(); if (this.beforeInit) {
BI.each(this._children, function (i, widget) { this.__asking = true;
!self.isEnabled() && widget._setEnable(false); this.beforeInit(BI.bind(this._render, this));
!self.isValid() && widget._setValid(false); if (this.__asking === true) {
widget._mount && widget._mount(); this.__async = true;
}); }
this.mounted && this.mounted(); } else {
}, this._render();
}
}
_mountChildren: null, this.beforeMount && this.beforeMount();
this._isMounted = true;
lazy && this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount();
});
!lazy && this._mountChildren && this._mountChildren();
this.mounted && this.mounted();
this._isMounting = false
},
isMounted: function () { _mountChildren: null,
return this._isMounted;
},
setWidth: function (w) { isMounted: function () {
this.options.width = w; return this._isMounted;
this._initElementWidth(); },
},
setHeight: function (h) { setWidth: function (w) {
this.options.height = h; this.options.width = w;
this._initElementHeight(); this._initElementWidth();
}, },
_setEnable: function (enable) { setHeight: function (h) {
if (enable === true) { this.options.height = h;
this.options.disabled = false; this._initElementHeight();
} else if (enable === false) { },
this.options.disabled = true;
}
// 递归将所有子组件使能
BI.each(this._children, function (i, child) {
!child._manualSetEnable && child._setEnable && child._setEnable(enable);
});
},
_setValid: function (valid) { _setEnable: function (enable) {
if (valid === true) { if (enable === true) {
this.options.invalid = false; this.options.disabled = false;
} else if (valid === false) { } else if (enable === false) {
this.options.invalid = true; this.options.disabled = true;
} }
// 递归将所有子组件使有效 // 递归将所有子组件使能
BI.each(this._children, function (i, child) { BI.each(this._children, function (i, child) {
!child._manualSetValid && child._setValid && child._setValid(valid); !child._manualSetEnable && child._setEnable && child._setEnable(enable);
}); });
}, },
_setVisible: function (visible) { _setValid: function (valid) {
if (visible === true) { if (valid === true) {
this.options.invisible = false; this.options.invalid = false;
} else if (visible === false) { } else if (valid === false) {
this.options.invisible = true; this.options.invalid = true;
} }
}, // 递归将所有子组件使有效
BI.each(this._children, function (i, child) {
!child._manualSetValid && child._setValid && child._setValid(valid);
});
},
setEnable: function (enable) { _setVisible: function (visible) {
this._manualSetEnable = true; if (visible === true) {
this._setEnable(enable); this.options.invisible = false;
if (enable === true) { } else if (visible === false) {
this.element.removeClass("base-disabled disabled"); this.options.invisible = true;
} else if (enable === false) { }
this.element.addClass("base-disabled disabled"); },
}
},
setVisible: function (visible) { setEnable: function (enable) {
this._setVisible(visible); this._manualSetEnable = true;
if (visible === true) { this._setEnable(enable);
// 用this.element.show()会把display属性改成block if (enable === true) {
this.element.css("display", ""); this.element.removeClass("base-disabled disabled");
this._mount(); } else if (enable === false) {
} else if (visible === false) { this.element.addClass("base-disabled disabled");
this.element.css("display", "none"); }
} },
this.fireEvent(BI.Events.VIEW, visible);
},
setValid: function (valid) { setVisible: function (visible) {
this._manualSetValid = true; this._setVisible(visible);
this._setValid(valid); if (visible === true) {
if (valid === true) { // 用this.element.show()会把display属性改成block
this.element.removeClass("base-invalid invalid"); this.element.css("display", "");
} else if (valid === false) { this._mount();
this.element.addClass("base-invalid invalid"); } else if (visible === false) {
} this.element.css("display", "none");
}, }
this.fireEvent(BI.Events.VIEW, visible);
},
doBehavior: function () { setValid: function (valid) {
var args = arguments; this._manualSetValid = true;
// 递归将所有子组件使有效 this._setValid(valid);
BI.each(this._children, function (i, child) { if (valid === true) {
child.doBehavior && child.doBehavior.apply(child, args); this.element.removeClass("base-invalid invalid");
}); } else if (valid === false) {
}, this.element.addClass("base-invalid invalid");
}
},
getWidth: function () { doBehavior: function () {
return this.options.width; var args = arguments;
}, // 递归将所有子组件使有效
BI.each(this._children, function (i, child) {
child.doBehavior && child.doBehavior.apply(child, args);
});
},
getHeight: function () { getWidth: function () {
return this.options.height; return this.options.width;
}, },
isValid: function () { getHeight: function () {
return !this.options.invalid; return this.options.height;
}, },
addWidget: function (name, widget) { isValid: function () {
var self = this; return !this.options.invalid;
if (name instanceof BI.Widget) { },
widget = name;
name = widget.getName();
}
if (BI.isKey(name)) {
name = name + "";
}
name = name || widget.getName() || BI.uniqueId("widget");
if (this._children[name]) {
throw new Error("name has already been existed");
}
widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () {
BI.remove(self._children, this);
});
return (this._children[name] = widget);
},
getWidgetByName: function (name) { addWidget: function (name, widget) {
if (!BI.isKey(name) || name === this.getName()) { var self = this;
return this; if (name instanceof BI.Widget) {
} widget = name;
name = name + ""; name = widget.getName();
var widget = void 0, other = {};
BI.any(this._children, function (i, wi) {
if (i === name) {
widget = wi;
return true;
} }
other[i] = wi; if (BI.isKey(name)) {
}); name = name + "";
if (!widget) { }
BI.any(other, function (i, wi) { name = name || widget.getName() || BI.uniqueId("widget");
return (widget = wi.getWidgetByName(i)); if (this._children[name]) {
throw new Error("name has already been existed");
}
widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () {
BI.remove(self._children, this);
}); });
} return (this._children[name] = widget);
return widget; },
},
removeWidget: function (nameOrWidget) { getWidgetByName: function (name) {
var self = this; if (!BI.isKey(name) || name === this.getName()) {
if (BI.isWidget(nameOrWidget)) { return this;
BI.remove(this._children, nameOrWidget); }
} else { name = name + "";
delete this._children[nameOrWidget]; var widget = void 0, other = {};
} BI.any(this._children, function (i, wi) {
}, if (i === name) {
widget = wi;
return true;
}
other[i] = wi;
});
if (!widget) {
BI.any(other, function (i, wi) {
return (widget = wi.getWidgetByName(i));
});
}
return widget;
},
hasWidget: function (name) { removeWidget: function (nameOrWidget) {
return this._children[name] != null; var self = this;
}, if (BI.isWidget(nameOrWidget)) {
BI.remove(this._children, nameOrWidget);
} else {
delete this._children[nameOrWidget];
}
},
getName: function () { hasWidget: function (name) {
return this.widgetName; return this._children[name] != null;
}, },
setTag: function (tag) { getName: function () {
this.options.tag = tag; return this.widgetName;
}, },
getTag: function () { setTag: function (tag) {
return this.options.tag; this.options.tag = tag;
}, },
attr: function (key, value) { getTag: function () {
var self = this; return this.options.tag;
if (BI.isPlainObject(key)) { },
BI.each(key, function (k, v) {
self.attr(k, v);
});
return;
}
if (BI.isNotNull(value)) {
return this.options[key] = value;
}
return this.options[key];
},
getText: function () { attr: function (key, value) {
var self = this;
if (BI.isPlainObject(key)) {
BI.each(key, function (k, v) {
self.attr(k, v);
});
return;
}
if (BI.isNotNull(value)) {
return this.options[key] = value;
}
return this.options[key];
},
}, getText: function () {
setText: function (text) { },
}, setText: function (text) {
getValue: function () { },
}, getValue: function () {
setValue: function (value) { },
}, setValue: function (value) {
isEnabled: function () { },
return !this.options.disabled;
},
isVisible: function () { isEnabled: function () {
return !this.options.invisible; return !this.options.disabled;
}, },
disable: function () { isVisible: function () {
this.setEnable(false); return !this.options.invisible;
}, },
enable: function () { disable: function () {
this.setEnable(true); this.setEnable(false);
}, },
valid: function () { enable: function () {
this.setValid(true); this.setEnable(true);
}, },
invalid: function () { valid: function () {
this.setValid(false); this.setValid(true);
}, },
invisible: function () { invalid: function () {
this.setVisible(false); this.setValid(false);
}, },
visible: function () { invisible: function () {
this.setVisible(true); this.setVisible(false);
}, },
__d: function () { visible: function () {
this.beforeDestroy && this.beforeDestroy(); this.setVisible(true);
BI.each(this._children, function (i, widget) { },
widget && widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed && this.destroyed();
},
_unMount: function () { __d: function () {
this.__d(); this.beforeDestroy && this.beforeDestroy();
this.fireEvent(BI.Events.UNMOUNT); BI.each(this._children, function (i, widget) {
this.purgeListeners(); widget && widget._unMount && widget._unMount();
}, });
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed && this.destroyed();
},
isolate: function () { _unMount: function () {
if (this._parent) { this.__d();
this._parent.removeWidget(this); this.fireEvent(BI.Events.UNMOUNT);
} this.purgeListeners();
BI.DOM.hang([this]); },
},
empty: function () { isolate: function () {
BI.each(this._children, function (i, widget) { if (this._parent) {
widget && widget._unMount && widget._unMount(); this._parent.removeWidget(this);
}); }
this._children = {}; BI.DOM.hang([this]);
this.element.empty(); },
},
_destroy: function () { empty: function () {
this.__d(); BI.each(this._children, function (i, widget) {
this.element.destroy(); widget && widget._unMount && widget._unMount();
this.purgeListeners(); });
}, this._children = {};
this.element.empty();
},
destroy: function () { _destroy: function () {
this.__d(); this.__d();
this.element.destroy(); this.element.destroy();
this.fireEvent(BI.Events.DESTROY); this.purgeListeners();
this._purgeRef(); },
this.purgeListeners();
} destroy: function () {
});(function () { this.__d();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
this._purgeRef();
this.purgeListeners();
}
});
})();(function () {
var kv = {}; var kv = {};
BI.shortcut = function (xtype, cls) { BI.shortcut = function (xtype, cls) {
if (kv[xtype] != null) { if (kv[xtype] != null) {
@ -81545,7 +81574,7 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
}); });
BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
function initWatch (vm, watch) { function initWatch(vm, watch) {
vm._watchers || (vm._watchers = []); vm._watchers || (vm._watchers = []);
for (var key in watch) { for (var key in watch) {
var handler = watch[key]; var handler = watch[key];
@ -81559,7 +81588,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
} }
} }
function createWatcher (vm, keyOrFn, handler) { function createWatcher(vm, keyOrFn, handler) {
return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), { return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), {
store: vm.store store: vm.store
}); });
@ -81568,24 +81597,24 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
var target = null; var target = null;
var targetStack = []; var targetStack = [];
function pushTarget (_target) { function pushTarget(_target) {
if (target) targetStack.push(target); if (target) targetStack.push(target);
Fix.Model.target = target = _target; Fix.Model.target = target = _target;
} }
function popTarget () { function popTarget() {
Fix.Model.target = target = targetStack.pop(); Fix.Model.target = target = targetStack.pop();
} }
var context = null; var context = null;
var contextStack = []; var contextStack = [];
function pushContext (_context) { function pushContext(_context) {
if (context) contextStack.push(context); if (context) contextStack.push(context);
Fix.Model.context = context = _context; Fix.Model.context = context = _context;
} }
function popContext () { function popContext() {
Fix.Model.context = context = contextStack.pop(); Fix.Model.context = context = contextStack.pop();
} }
@ -81606,7 +81635,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
}, options); }, options);
}; };
function findStore (widget) { function findStore(widget) {
if (target != null) { if (target != null) {
return target; return target;
} }
@ -81652,12 +81681,11 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
}; };
}); });
var _init = BI.Widget.prototype._init; function createStore() {
BI.Widget.prototype._init = function () {
var self = this;
var needPop = false; var needPop = false;
if (window.Fix && this._store) { if (!this._storeCreated && window.Fix && this._store && this.isVisible()) {
var store = findStore(this.options.context || this.options.element); var store = findStore(this.options.context || this.options.element);
this._storeCreated = true;
if (store) { if (store) {
pushTarget(store); pushTarget(store);
needPop = true; needPop = true;
@ -81674,6 +81702,13 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
} }
needPop = true; needPop = true;
} }
return needPop;
}
var _init = BI.Widget.prototype._init;
BI.Widget.prototype._init = function () {
var self = this;
var needPop = createStore.call(this);
_init.apply(this, arguments); _init.apply(this, arguments);
needPop && popTarget(); needPop && popTarget();
}; };
@ -81712,6 +81747,7 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
_.each(["_mount"], function (name) { _.each(["_mount"], function (name) {
var old = BI.Widget.prototype[name]; var old = BI.Widget.prototype[name];
old && (BI.Widget.prototype[name] = function () { old && (BI.Widget.prototype[name] = function () {
createStore.call(this);
this.store && pushTarget(this.store); this.store && pushTarget(this.store);
var res = old.apply(this, arguments); var res = old.apply(this, arguments);
this.store && popTarget(); this.store && popTarget();

8
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save