|
|
@ -40,7 +40,7 @@ |
|
|
|
cls: "", |
|
|
|
cls: "", |
|
|
|
css: null, |
|
|
|
css: null, |
|
|
|
|
|
|
|
|
|
|
|
vdom: false |
|
|
|
// vdom: false
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -195,9 +195,9 @@ |
|
|
|
this.element = BI.Widget._renderEngine.createElement(this); |
|
|
|
this.element = BI.Widget._renderEngine.createElement(this); |
|
|
|
} |
|
|
|
} |
|
|
|
this.element._isWidget = true; |
|
|
|
this.element._isWidget = true; |
|
|
|
var widgets = this.element.data("__widgets") || []; |
|
|
|
// var widgets = this.element.data("__widgets") || [];
|
|
|
|
widgets.push(this); |
|
|
|
// widgets.push(this);
|
|
|
|
this.element.data("__widgets", widgets); |
|
|
|
// this.element.data("__widgets", widgets);
|
|
|
|
this._initCurrent(); |
|
|
|
this._initCurrent(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -243,7 +243,7 @@ |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
var isMounted = this._isMounted; |
|
|
|
var isMounted = this._isMounted; |
|
|
|
this.__async === true && isMounted && callLifeHook(this, "beforeMount"); |
|
|
|
this.__async === true && isMounted && callLifeHook(this, "beforeMount"); |
|
|
|
if (!this._initVNode()) { |
|
|
|
// if (!this._initVNode()) {
|
|
|
|
var render = BI.isFunction(this.options.render) ? this.options.render : this.render; |
|
|
|
var render = BI.isFunction(this.options.render) ? this.options.render : this.render; |
|
|
|
var els = render && render.call(this); |
|
|
|
var els = render && render.call(this); |
|
|
|
els = BI.Plugin.getRender(this.options.type, els); |
|
|
|
els = BI.Plugin.getRender(this.options.type, els); |
|
|
@ -259,7 +259,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// }
|
|
|
|
this._mount(); |
|
|
|
this._mount(); |
|
|
|
if (this.__async === true && isMounted) { |
|
|
|
if (this.__async === true && isMounted) { |
|
|
|
callLifeHook(this, "mounted"); |
|
|
|
callLifeHook(this, "mounted"); |
|
|
@ -267,48 +267,48 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_initVNode: function () { |
|
|
|
// _initVNode: function () {
|
|
|
|
if (this.options.vdom) { |
|
|
|
// if (this.options.vdom) {
|
|
|
|
var div = document.createElement("div"); |
|
|
|
// var div = document.createElement("div");
|
|
|
|
var element = this.element; |
|
|
|
// var element = this.element;
|
|
|
|
element.append(div); |
|
|
|
// element.append(div);
|
|
|
|
this.vnode = this._renderVNode(); |
|
|
|
// this.vnode = this._renderVNode();
|
|
|
|
BI.patchVNode(div, this.vnode); |
|
|
|
// BI.patchVNode(div, this.vnode);
|
|
|
|
// 去除这个临时的div
|
|
|
|
// // 去除这个临时的div
|
|
|
|
BI.DOM.hang([div]); |
|
|
|
// BI.DOM.hang([div]);
|
|
|
|
element.attr("style", this.vnode.elm.getAttribute("style")); |
|
|
|
// element.attr("style", this.vnode.elm.getAttribute("style"));
|
|
|
|
element.addClass(this.vnode.elm.getAttribute("class")); |
|
|
|
// element.addClass(this.vnode.elm.getAttribute("class"));
|
|
|
|
element.empty(); |
|
|
|
// element.empty();
|
|
|
|
BI.each(BI.jQuery(this.vnode.elm).children(), function (i, node) { |
|
|
|
// BI.each(BI.jQuery(this.vnode.elm).children(), function (i, node) {
|
|
|
|
element.append(node); |
|
|
|
// element.append(node);
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
return true; |
|
|
|
// return true;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
return false; |
|
|
|
// return false;
|
|
|
|
}, |
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
|
|
_renderVNode: function () { |
|
|
|
// _renderVNode: function () {
|
|
|
|
var self = this; |
|
|
|
// var self = this;
|
|
|
|
var render = BI.isFunction(this.options.render) ? this.options.render : this.render; |
|
|
|
// var render = BI.isFunction(this.options.render) ? this.options.render : this.render;
|
|
|
|
var els = render && render.call(this); |
|
|
|
// var els = render && render.call(this);
|
|
|
|
els = BI.Plugin.getRender(this.options.type, els); |
|
|
|
// els = BI.Plugin.getRender(this.options.type, els);
|
|
|
|
if (BI.isPlainObject(els)) { |
|
|
|
// if (BI.isPlainObject(els)) {
|
|
|
|
els = [els]; |
|
|
|
// els = [els];
|
|
|
|
} |
|
|
|
// }
|
|
|
|
if (BI.isArray(els)) { |
|
|
|
// if (BI.isArray(els)) {
|
|
|
|
var container = document.createElement("div"); |
|
|
|
// var container = document.createElement("div");
|
|
|
|
this._children = {}; |
|
|
|
// this._children = {};
|
|
|
|
BI.each(els, function (i, el) { |
|
|
|
// BI.each(els, function (i, el) {
|
|
|
|
if (el) { |
|
|
|
// if (el) {
|
|
|
|
var w = BI._lazyCreateWidget(el, { |
|
|
|
// var w = BI._lazyCreateWidget(el, {
|
|
|
|
element: container |
|
|
|
// element: container
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
self.addWidget(w); |
|
|
|
// self.addWidget(w);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
} |
|
|
|
// }
|
|
|
|
return BI.Element2Vnode(container); |
|
|
|
// return BI.Element2Vnode(container);
|
|
|
|
}, |
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
|
|
_setParent: function (parent) { |
|
|
|
_setParent: function (parent) { |
|
|
|
this._parent = parent; |
|
|
|
this._parent = parent; |
|
|
@ -647,12 +647,12 @@ |
|
|
|
if (this.__async === true || this.__asking === true) { |
|
|
|
if (this.__async === true || this.__asking === true) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.options.vdom) { |
|
|
|
// if (this.options.vdom) {
|
|
|
|
var vnode = this._renderVNode(); |
|
|
|
// var vnode = this._renderVNode();
|
|
|
|
BI.patchVNode(this.vnode, vnode); |
|
|
|
// BI.patchVNode(this.vnode, vnode);
|
|
|
|
this.vnode = vnode; |
|
|
|
// this.vnode = vnode;
|
|
|
|
return; |
|
|
|
// return;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
// this._isMounted = false;
|
|
|
|
// this._isMounted = false;
|
|
|
|
// this.purgeListeners();
|
|
|
|
// this.purgeListeners();
|
|
|
|
this._empty(); |
|
|
|
this._empty(); |
|
|
|