|
|
@ -6,8 +6,11 @@ |
|
|
|
* @extends BI.Widget |
|
|
|
* @extends BI.Widget |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
BI.Combo = BI.inherit(BI.Bubble, { |
|
|
|
BI.Combo = BI.inherit(BI.Bubble, { |
|
|
|
|
|
|
|
_const: { |
|
|
|
|
|
|
|
TRIANGLE_LENGTH: 9 |
|
|
|
|
|
|
|
}, |
|
|
|
_defaultConfig: function () { |
|
|
|
_defaultConfig: function () { |
|
|
|
var conf = BI.Bubble.superclass._defaultConfig.apply(this, arguments); |
|
|
|
var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); |
|
|
|
return BI.extend(conf, { |
|
|
|
return BI.extend(conf, { |
|
|
|
baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""), |
|
|
|
baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""), |
|
|
|
attributes: { |
|
|
|
attributes: { |
|
|
@ -102,27 +105,6 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_assertPopupView: function () { |
|
|
|
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
|
|
|
if (this.popupView == null) { |
|
|
|
|
|
|
|
this.popupView = BI.createWidget(this.options.popup, { |
|
|
|
|
|
|
|
type: "bi.popup_view", |
|
|
|
|
|
|
|
value: o.value |
|
|
|
|
|
|
|
}, this); |
|
|
|
|
|
|
|
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { |
|
|
|
|
|
|
|
if (type === BI.Events.CLICK) { |
|
|
|
|
|
|
|
self.combo.setValue(self.getValue()); |
|
|
|
|
|
|
|
self.fireEvent(BI.Combo.EVENT_CHANGE, value, obj); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.popupView.setVisible(false); |
|
|
|
|
|
|
|
BI.nextTick(function () { |
|
|
|
|
|
|
|
self.fireEvent(BI.Combo.EVENT_AFTER_INIT); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_hideView: function (e) { |
|
|
|
_hideView: function (e) { |
|
|
|
var o = this.options; |
|
|
|
var o = this.options; |
|
|
|
this.fireEvent(BI.Combo.EVENT_BEFORE_HIDEVIEW); |
|
|
|
this.fireEvent(BI.Combo.EVENT_BEFORE_HIDEVIEW); |
|
|
@ -214,69 +196,79 @@ |
|
|
|
switch (o.direction) { |
|
|
|
switch (o.direction) { |
|
|
|
case "bottom": |
|
|
|
case "bottom": |
|
|
|
case "bottom,right": |
|
|
|
case "bottom,right": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ["bottom", "top", "right", "left"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["bottom", "top", "right", "left"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "top": |
|
|
|
case "top": |
|
|
|
case "top,right": |
|
|
|
case "top,right": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ["top", "bottom", "right", "left"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["top", "bottom", "right", "left"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "left": |
|
|
|
case "left": |
|
|
|
case "left,bottom": |
|
|
|
case "left,bottom": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "bottom", "top"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "bottom", "top"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "right": |
|
|
|
case "right": |
|
|
|
case "right,bottom": |
|
|
|
case "right,bottom": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "bottom", "top"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "bottom", "top"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "top,left": |
|
|
|
case "top,left": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ["top", "bottom", "left", "right"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["top", "bottom", "left", "right"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "bottom,left": |
|
|
|
case "bottom,left": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ["bottom", "top", "left", "right"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset, (o.adjustYOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["bottom", "top", "left", "right"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "left,top": |
|
|
|
case "left,top": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "top", "bottom"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "top", "bottom"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "right,top": |
|
|
|
case "right,top": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "top", "bottom"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "top", "bottom"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "right,innerRight": |
|
|
|
case "right,innerRight": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "innerRight", "innerLeft", "bottom", "top"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "innerRight", "innerLeft", "bottom", "top"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "right,innerLeft": |
|
|
|
case "right,innerLeft": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "innerLeft", "innerRight", "bottom", "top"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "innerLeft", "innerRight", "bottom", "top"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "innerRight": |
|
|
|
case "innerRight": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["innerRight", "innerLeft", "right", "left", "bottom", "top"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["innerRight", "innerLeft", "right", "left", "bottom", "top"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "innerLeft": |
|
|
|
case "innerLeft": |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["innerLeft", "innerRight", "left", "right", "bottom", "top"], o.offsetStyle); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.adjustYOffset, o.isNeedAdjustHeight, ["innerLeft", "innerRight", "left", "right", "bottom", "top"], o.offsetStyle); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "top,custom": |
|
|
|
case "top,custom": |
|
|
|
case "custom,top": |
|
|
|
case "custom,top": |
|
|
|
p = BI.DOM.getTopAdaptPosition(combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight); |
|
|
|
p = BI.DOM.getTopAdaptPosition(combo, this.popupView, (o.adjustYOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight); |
|
|
|
|
|
|
|
p.dir = "top"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "custom,bottom": |
|
|
|
case "custom,bottom": |
|
|
|
case "bottom,custom": |
|
|
|
case "bottom,custom": |
|
|
|
p = BI.DOM.getBottomAdaptPosition(combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight); |
|
|
|
p = BI.DOM.getBottomAdaptPosition(combo, this.popupView, (o.adjustYOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight); |
|
|
|
|
|
|
|
p.dir = "bottom"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "left,custom": |
|
|
|
case "left,custom": |
|
|
|
case "custom,left": |
|
|
|
case "custom,left": |
|
|
|
p = BI.DOM.getLeftAdaptPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength); |
|
|
|
p = BI.DOM.getLeftAdaptPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0)); |
|
|
|
delete p.top; |
|
|
|
delete p.top; |
|
|
|
delete p.adaptHeight; |
|
|
|
delete p.adaptHeight; |
|
|
|
|
|
|
|
p.dir = "left"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "custom,right": |
|
|
|
case "custom,right": |
|
|
|
case "right,custom": |
|
|
|
case "right,custom": |
|
|
|
p = BI.DOM.getRightAdaptPosition(combo, this.popupView, o.adjustXOffset || o.adjustLength); |
|
|
|
p = BI.DOM.getRightAdaptPosition(combo, this.popupView, (o.adjustXOffset || o.adjustLength) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0)); |
|
|
|
delete p.top; |
|
|
|
delete p.top; |
|
|
|
delete p.adaptHeight; |
|
|
|
delete p.adaptHeight; |
|
|
|
|
|
|
|
p.dir = "right"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ("adaptHeight" in p) { |
|
|
|
if ("adaptHeight" in p) { |
|
|
|
this.resetListHeight(p["adaptHeight"]); |
|
|
|
this.resetListHeight(p["adaptHeight"]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var width = this.combo.element.outerWidth(); |
|
|
|
|
|
|
|
var height = this.combo.element.outerHeight(); |
|
|
|
|
|
|
|
this.popupView.setDirection(p.dir, { |
|
|
|
|
|
|
|
width: width, |
|
|
|
|
|
|
|
height: height |
|
|
|
|
|
|
|
}); |
|
|
|
if ("left" in p) { |
|
|
|
if ("left" in p) { |
|
|
|
this.popupView.element.css({ |
|
|
|
this.popupView.element.css({ |
|
|
|
left: p.left |
|
|
|
left: p.left |
|
|
|