forked from fanruan/fineui
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.
73 lines
2.1 KiB
73 lines
2.1 KiB
8 years ago
|
/**
|
||
|
* @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",
|
||
|
trigger: "click",
|
||
|
toggle: true,
|
||
|
direction: "bottom",
|
||
|
isDefaultInit: true,
|
||
|
el: {},
|
||
|
popup: {}
|
||
|
});
|
||
|
},
|
||
|
|
||
|
_init: function () {
|
||
|
BI.SelectTreeExpander.superclass._init.apply(this, arguments);
|
||
|
var self = this, o = this.options;
|
||
|
|
||
|
this.trigger = BI.createWidget(BI.extend({stopPropagation: true}, 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);
|
||
|
});
|
||
|
},
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
$.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);
|