|
|
|
/**
|
|
|
|
* 表示当前对象
|
|
|
|
*
|
|
|
|
* Created by GUY on 2015/9/7.
|
|
|
|
* @class BI.EL
|
|
|
|
* @extends BI.Widget
|
|
|
|
*/
|
|
|
|
BI.Context = BI.inherit(BI.Widget, {
|
|
|
|
props: {
|
|
|
|
context: "",
|
|
|
|
watch: {},
|
|
|
|
el: {},
|
|
|
|
items: [],
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function () {
|
|
|
|
var self = this, o = this.options;
|
|
|
|
if (o.context) {
|
|
|
|
this.context = BI.useContext(o.context);
|
|
|
|
}
|
|
|
|
this.widget = BI.createWidget((o.items[0] || o.el)(this.context), {
|
|
|
|
element: this,
|
|
|
|
});
|
|
|
|
this.widget.on(BI.Controller.EVENT_CHANGE, function () {
|
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
__initWatch: function () {
|
|
|
|
BI.Context.superclass.__initWatch.call(this);
|
|
|
|
var o = this.options;
|
|
|
|
BI.watch(this.context, o.context, o.watch);
|
|
|
|
},
|
|
|
|
|
|
|
|
setValue: function (v) {
|
|
|
|
this.widget.setValue(v);
|
|
|
|
},
|
|
|
|
|
|
|
|
getValue: function () {
|
|
|
|
return this.widget.getValue();
|
|
|
|
},
|
|
|
|
|
|
|
|
populate: function () {
|
|
|
|
this.widget.populate.apply(this, arguments);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
BI.shortcut("bi.context", BI.Context);
|