|
|
|
/**
|
|
|
|
* @class BI.SingleTreeTrigger
|
|
|
|
* @extends BI.Trigger
|
|
|
|
*/
|
|
|
|
|
|
|
|
BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
|
|
|
|
|
|
|
|
_defaultConfig: function () {
|
|
|
|
return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), {
|
|
|
|
baseCls: "bi-single-tree-trigger",
|
|
|
|
height: 24,
|
|
|
|
text: "",
|
|
|
|
items: [],
|
|
|
|
value: "",
|
|
|
|
allowClear: false,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_init: function () {
|
|
|
|
BI.SingleTreeTrigger.superclass._init.apply(this, arguments);
|
|
|
|
|
|
|
|
var self = this, o = this.options;
|
|
|
|
|
|
|
|
this.trigger = BI.createWidget({
|
|
|
|
type: "bi.select_text_trigger",
|
|
|
|
element: this,
|
|
|
|
text: o.text,
|
|
|
|
items: o.items,
|
|
|
|
height: o.height,
|
|
|
|
warningTitle: o.warningTitle,
|
|
|
|
value: o.value,
|
|
|
|
allowClear: o.allowClear,
|
|
|
|
listeners: [
|
|
|
|
{
|
|
|
|
eventName: BI.SelectTextTrigger.EVENT_CLEAR,
|
|
|
|
action: function () {
|
|
|
|
self.fireEvent(BI.SingleTreeTrigger.EVENT_CLEAR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_checkTitle: function () {
|
|
|
|
var self = this, val = this.getValue();
|
|
|
|
BI.any(this.options.items, function (i, item) {
|
|
|
|
if (BI.contains(val, item.value)) {
|
|
|
|
self.trigger.setTitle(item.text || item.value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setValue: function (v) {
|
|
|
|
v = BI.isArray(v) ? v : [v];
|
|
|
|
this.options.value = v;
|
|
|
|
this.trigger.setValue(v);
|
|
|
|
this._checkTitle();
|
|
|
|
},
|
|
|
|
|
|
|
|
setTipType: function (v) {
|
|
|
|
this.trigger.setTipType(v);
|
|
|
|
},
|
|
|
|
|
|
|
|
getValue: function () {
|
|
|
|
return this.options.value || [];
|
|
|
|
},
|
|
|
|
|
|
|
|
getTextor: function () {
|
|
|
|
return this.trigger.getTextor();
|
|
|
|
},
|
|
|
|
|
|
|
|
populate: function (items) {
|
|
|
|
this.trigger.populate(items);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
BI.SingleTreeTrigger.EVENT_CLEAR = "EVENT_CLEAR";
|
|
|
|
BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);
|