|
|
|
/**
|
|
|
|
*
|
|
|
|
* 复选下拉框
|
|
|
|
* @class BI.MultiSelectTrigger
|
|
|
|
* @extends BI.Trigger
|
|
|
|
*/
|
|
|
|
|
|
|
|
BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
|
|
|
|
|
|
|
|
constants: {
|
|
|
|
height: 14,
|
|
|
|
rgap: 4,
|
|
|
|
lgap: 4
|
|
|
|
},
|
|
|
|
|
|
|
|
_defaultConfig: function () {
|
|
|
|
return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
|
|
|
|
baseCls: "bi-multi-select-trigger",
|
|
|
|
itemsCreator: BI.emptyFn,
|
|
|
|
valueFormatter: BI.emptyFn,
|
|
|
|
searcher: {},
|
|
|
|
switcher: {},
|
|
|
|
|
|
|
|
adapter: null,
|
|
|
|
masker: {}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_init: function () {
|
|
|
|
BI.MultiSelectTrigger.superclass._init.apply(this, arguments);
|
|
|
|
|
|
|
|
var self = this, o = this.options;
|
|
|
|
if (o.height) {
|
|
|
|
this.setHeight(o.height - 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.searcher = BI.createWidget(o.searcher, {
|
|
|
|
type: "bi.multi_select_searcher",
|
|
|
|
height: o.height,
|
|
|
|
itemsCreator: o.itemsCreator,
|
|
|
|
valueFormatter: o.valueFormatter,
|
|
|
|
popup: {},
|
|
|
|
adapter: o.adapter,
|
|
|
|
masker: o.masker
|
|
|
|
});
|
|
|
|
this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () {
|
|
|
|
self.fireEvent(BI.MultiSelectTrigger.EVENT_START);
|
|
|
|
});
|
|
|
|
this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () {
|
|
|
|
self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE);
|
|
|
|
});
|
|
|
|
this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () {
|
|
|
|
self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments);
|
|
|
|
});
|
|
|
|
this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () {
|
|
|
|
self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP);
|
|
|
|
});
|
|
|
|
this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () {
|
|
|
|
self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments);
|
|
|
|
});
|
|
|
|
this.numberCounter = BI.createWidget(o.switcher, {
|
|
|
|
type: 'bi.multi_select_check_selected_switcher',
|
|
|
|
valueFormatter: o.valueFormatter,
|
|
|
|
itemsCreator: o.itemsCreator,
|
|
|
|
adapter: o.adapter,
|
|
|
|
masker: o.masker
|
|
|
|
});
|
|
|
|
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
|
|
|
|
self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK);
|
|
|
|
});
|
|
|
|
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
|
|
|
|
self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
|
|
|
|
});
|
|
|
|
|
|
|
|
var wrapNumberCounter = BI.createWidget({
|
|
|
|
type: 'bi.right_vertical_adapt',
|
|
|
|
hgap: 4,
|
|
|
|
items: [{
|
|
|
|
el: this.numberCounter
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
var wrapper = BI.createWidget({
|
|
|
|
type: 'bi.htape',
|
|
|
|
element: this,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
el: this.searcher,
|
|
|
|
width: 'fill'
|
|
|
|
}, {
|
|
|
|
el: wrapNumberCounter,
|
|
|
|
width: 0
|
|
|
|
}, {
|
|
|
|
el: BI.createWidget(),
|
|
|
|
width: 30
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
this.numberCounter.on(BI.Events.VIEW, function (b) {
|
|
|
|
BI.nextTick(function () {//自动调整宽度
|
|
|
|
wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
|
|
|
|
wrapper.resize();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.element.click(function (e) {
|
|
|
|
if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) {
|
|
|
|
self.numberCounter.hideView();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
getCounter: function () {
|
|
|
|
return this.numberCounter;
|
|
|
|
},
|
|
|
|
|
|
|
|
getSearcher: function () {
|
|
|
|
return this.searcher;
|
|
|
|
},
|
|
|
|
|
|
|
|
stopEditing: function () {
|
|
|
|
this.searcher.stopSearch();
|
|
|
|
this.numberCounter.hideView();
|
|
|
|
},
|
|
|
|
|
|
|
|
setValue: function (ob) {
|
|
|
|
this.searcher.setValue(ob);
|
|
|
|
this.numberCounter.setValue(ob);
|
|
|
|
},
|
|
|
|
|
|
|
|
setEnable: function (v) {
|
|
|
|
this.searcher.setEnable(v);
|
|
|
|
},
|
|
|
|
|
|
|
|
getKey: function () {
|
|
|
|
return this.searcher.getKey();
|
|
|
|
},
|
|
|
|
|
|
|
|
getValue: function () {
|
|
|
|
return this.searcher.getValue();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
|
|
|
|
BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
|
|
|
|
BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
|
|
|
|
BI.MultiSelectTrigger.EVENT_START = "EVENT_START";
|
|
|
|
BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP";
|
|
|
|
BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
|
|
|
|
BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
|
|
|
|
BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
|
|
|
|
|
|
|
|
BI.shortcut('bi.multi_select_trigger', BI.MultiSelectTrigger);
|