Browse Source

Pull request #3108: feature: 支持type可以直接传函数,没有xtype都行

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

* commit '422594d6da2558330543629185c7b9645640b3aa':
  feature: 支持type可以直接传函数,没有xtype都行
  chore: 优化
es6
guy-王川 2 years ago
parent
commit
8d1f20f8e1
  1. 7
      src/base/list/virtualgrouplist.js
  2. 16
      src/core/5.inject.js

7
src/base/list/virtualgrouplist.js

@ -27,7 +27,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: "bi.vertical", type: "bi.vertical",
items: [{ items: [{
@ -97,12 +97,13 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
this.container[self.renderedIndex === -1 ? "populate" : "addItems"](items.map(function (item, i) { this.container[self.renderedIndex === -1 ? "populate" : "addItems"](items.map(function (item, i) {
return o.itemFormatter(item, index + i); return o.itemFormatter(item, index + i);
}), this); }), this);
var addedHeight = getElementHeight() - lastHeight; var elementHeight = getElementHeight();
var addedHeight = elementHeight - lastHeight;
this.tree.set(cnt, addedHeight); this.tree.set(cnt, addedHeight);
this.renderedIndex = cnt; this.renderedIndex = cnt;
cnt++; cnt++;
index += o.blockSize; index += o.blockSize;
lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight(); lastHeight = this.renderedIndex === -1 ? 0 : elementHeight;
} }
}, },

16
src/core/5.inject.js

@ -411,7 +411,7 @@
// 根据配置属性生成widget // 根据配置属性生成widget
var createWidget = function (config, context, lazy) { var createWidget = function (config, context, lazy) {
var cls = kv[config.type]; var cls = BI.isFunction(config.type) ? config.type : kv[config.type];
if (!cls) { if (!cls) {
throw new Error("组件: [" + config.type + "] 未定义"); throw new Error("组件: [" + config.type + "] 未定义");
@ -449,9 +449,10 @@
} else if (item.el && (item.el.type || options.type)) { } else if (item.el && (item.el.type || options.type)) {
el = BI.extend({}, options, item.el); el = BI.extend({}, options, item.el);
} }
if (el) { if (el) {
runConfigFunction(el.type); var elType = (el.type && el.type.xtype) || el.type;
runConfigFunction(elType);
} }
// 先把准备环境准备好 // 先把准备环境准备好
@ -466,13 +467,14 @@
return item; return item;
} }
if (el) { if (el) {
w = BI.Plugin.getWidget(el.type, el); w = BI.Plugin.getWidget(elType, el);
if (w.type === el.type) { var wType = (w.type && w.type.xtype) || w.type;
if (BI.Plugin.hasObject(el.type)) { if (wType === elType) {
if (BI.Plugin.hasObject(elType)) {
w.listeners = (w.listeners || []).concat([{ w.listeners = (w.listeners || []).concat([{
eventName: BI.Events.MOUNT, eventName: BI.Events.MOUNT,
action: function () { action: function () {
BI.Plugin.getObject(el.type, this); BI.Plugin.getObject(elType, this);
} }
}]); }]);
} }

Loading…
Cancel
Save