fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.2 KiB

/**
* @class BI.SelectTreeExpander
* @extends BI.Widget
*/
BI.SelectTreeExpander = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-select-tree-expander",
7 years ago
trigger: "",
toggle: true,
direction: "bottom",
isDefaultInit: true,
el: {},
popup: {}
});
},
_init: function () {
BI.SelectTreeExpander.superclass._init.apply(this, arguments);
var self = this, o = this.options;
7 years ago
this.trigger = BI.createWidget(o.el);
this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
if (this.isSelected()) {
self.expander.setValue([]);
}
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.expander = BI.createWidget({
type: "bi.expander",
element: this,
trigger: o.trigger,
toggle: o.toggle,
direction: o.direction,
isDefaultInit: o.isDefaultInit,
el: this.trigger,
popup: o.popup
});
this.expander.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
self.trigger.setSelected(false);
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);
this.expander.setValue([]);
} else {
this.trigger.setSelected(false);
this.expander.setValue(v);
}
},
getValue: function () {
if (this.trigger.isSelected()) {
return [this.trigger.getValue()];
}
return this.expander.getValue();
},
populate: function (items) {
this.expander.populate(items);
}
});
8 years ago
BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);