|
|
|
/**
|
|
|
|
* @class BI.TextValueCombo
|
|
|
|
* @extend BI.Widget
|
|
|
|
* combo : text + icon, popup : text
|
|
|
|
* 参见场景dashboard布局方式选择
|
|
|
|
*/
|
|
|
|
BI.TextValueCombo = BI.inherit(BI.Widget, {
|
|
|
|
_defaultConfig: function () {
|
|
|
|
return BI.extend(BI.TextValueCombo.superclass._defaultConfig.apply(this, arguments), {
|
|
|
|
baseClass: "bi-text-value-combo",
|
|
|
|
height: 30,
|
|
|
|
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
|
|
|
|
text: "",
|
|
|
|
el: {}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_init: function () {
|
|
|
|
BI.TextValueCombo.superclass._init.apply(this, arguments);
|
|
|
|
var self = this, o = this.options;
|
|
|
|
this.trigger = BI.createWidget(o.el, {
|
|
|
|
type: "bi.select_text_trigger",
|
|
|
|
items: o.items,
|
|
|
|
height: o.height
|
|
|
|
});
|
|
|
|
this.popup = BI.createWidget({
|
|
|
|
type: "bi.text_value_combo_popup",
|
|
|
|
chooseType: o.chooseType,
|
|
|
|
items: o.items
|
|
|
|
});
|
|
|
|
this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () {
|
|
|
|
self.setValue(self.popup.getValue());
|
|
|
|
self.textIconCombo.hideView();
|
|
|
|
self.fireEvent(BI.TextValueCombo.EVENT_CHANGE, arguments);
|
|
|
|
});
|
|
|
|
this.popup.on(BI.Controller.EVENT_CHANGE, function () {
|
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
|
|
|
|
});
|
|
|
|
this.textIconCombo = BI.createWidget({
|
|
|
|
type: "bi.combo",
|
|
|
|
element: this,
|
|
|
|
adjustLength: 2,
|
|
|
|
el: this.trigger,
|
|
|
|
popup: {
|
|
|
|
el: this.popup,
|
|
|
|
maxHeight: 300
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (BI.isKey(o.text)) {
|
|
|
|
this.setValue(o.text);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setValue: function (v) {
|
|
|
|
this.textIconCombo.setValue(v);
|
|
|
|
},
|
|
|
|
|
|
|
|
getValue: function () {
|
|
|
|
return this.textIconCombo.getValue();
|
|
|
|
},
|
|
|
|
|
|
|
|
populate: function (items) {
|
|
|
|
this.options.items = items;
|
|
|
|
this.textIconCombo.populate(items);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
BI.TextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
|
|
|
|
BI.shortcut("bi.text_value_combo", BI.TextValueCombo);
|