|
|
@ -1,19 +1,34 @@ |
|
|
|
!(function () { |
|
|
|
|
|
|
|
var needHideWhenAnotherComboOpen = {}; |
|
|
|
|
|
|
|
var currentOpenedCombos = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @class BI.Combo |
|
|
|
* @class BI.Combo |
|
|
|
* @extends BI.Widget |
|
|
|
* @extends BI.Widget |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
BI.Combo = BI.inherit(BI.Bubble, { |
|
|
|
|
|
|
|
_const: { |
|
|
|
|
|
|
|
TRIANGLE_LENGTH: 12, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
_defaultConfig: function () { |
|
|
|
|
|
|
|
var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return BI.extend(conf, { |
|
|
|
import { shortcut, Widget, Controller, extend, createWidget, nextTick, bind, isNotNull, isNull, isFunction, each } from "../../core"; |
|
|
|
|
|
|
|
import Bubble from "./bubble"; |
|
|
|
|
|
|
|
import { Resizers } from "../0.base"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let needHideWhenAnotherComboOpen = {}; |
|
|
|
|
|
|
|
let currentOpenedCombos = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@shortcut() |
|
|
|
|
|
|
|
export default class Combo extends Bubble { |
|
|
|
|
|
|
|
static xtype = "bi.combo"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; |
|
|
|
|
|
|
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
|
|
|
|
static EVENT_EXPAND = "EVENT_EXPAND"; |
|
|
|
|
|
|
|
static EVENT_COLLAPSE = "EVENT_COLLAPSE"; |
|
|
|
|
|
|
|
static EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
|
|
|
|
|
|
|
static EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; |
|
|
|
|
|
|
|
static EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; |
|
|
|
|
|
|
|
static EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_defaultConfig() { |
|
|
|
|
|
|
|
const conf = super._defaultConfig(arguments); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return extend(conf, { |
|
|
|
baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""), |
|
|
|
baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""), |
|
|
|
attributes: { |
|
|
|
attributes: { |
|
|
|
tabIndex: -1, |
|
|
|
tabIndex: -1, |
|
|
@ -47,93 +62,93 @@ |
|
|
|
hoverClass: "bi-combo-hover", |
|
|
|
hoverClass: "bi-combo-hover", |
|
|
|
belowMouse: false, |
|
|
|
belowMouse: false, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render: function () { |
|
|
|
render() { |
|
|
|
var self = this, o = this.options; |
|
|
|
const { hoverClass, logic, isDefaultInit } = this.options; |
|
|
|
this._initCombo(); |
|
|
|
this._initCombo(); |
|
|
|
// 延迟绑定事件,这样可以将自己绑定的事情优先执行
|
|
|
|
// 延迟绑定事件,这样可以将自己绑定的事情优先执行
|
|
|
|
BI.nextTick(() => { |
|
|
|
nextTick(() => { |
|
|
|
!this.isDestroyed() && this._initPullDownAction(); |
|
|
|
!this.isDestroyed() && this._initPullDownAction(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { |
|
|
|
this.combo.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => { |
|
|
|
if (self.isEnabled() && self.isValid()) { |
|
|
|
if (this.isEnabled() && this.isValid()) { |
|
|
|
if (type === BI.Events.TOGGLE) { |
|
|
|
if (type === BI.Events.TOGGLE) { |
|
|
|
self._toggle(); |
|
|
|
this._toggle(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (type === BI.Events.EXPAND) { |
|
|
|
if (type === BI.Events.EXPAND) { |
|
|
|
self._popupView(); |
|
|
|
this._popupView(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (type === BI.Events.COLLAPSE) { |
|
|
|
if (type === BI.Events.COLLAPSE) { |
|
|
|
self._hideView(); |
|
|
|
this._hideView(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (type === BI.Events.EXPAND) { |
|
|
|
if (type === BI.Events.EXPAND) { |
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
|
|
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args); |
|
|
|
self.fireEvent(BI.Combo.EVENT_EXPAND); |
|
|
|
this.fireEvent(Combo.EVENT_EXPAND); |
|
|
|
} |
|
|
|
} |
|
|
|
if (type === BI.Events.COLLAPSE) { |
|
|
|
if (type === BI.Events.COLLAPSE) { |
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
|
|
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args); |
|
|
|
self.isViewVisible() && self.fireEvent(BI.Combo.EVENT_COLLAPSE); |
|
|
|
this.isViewVisible() && this.fireEvent(Combo.EVENT_COLLAPSE); |
|
|
|
} |
|
|
|
} |
|
|
|
if (type === BI.Events.CLICK) { |
|
|
|
if (type === BI.Events.CLICK) { |
|
|
|
self.fireEvent(BI.Combo.EVENT_TRIGGER_CHANGE, obj); |
|
|
|
this.fireEvent(Combo.EVENT_TRIGGER_CHANGE, obj); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
self.element.on("mouseenter." + self.getName(), function (e) { |
|
|
|
this.element.on("mouseenter." + this.getName(), (e) => { |
|
|
|
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) { |
|
|
|
if (this.isEnabled() && this.isValid() && this.combo.isEnabled() && this.combo.isValid()) { |
|
|
|
self.element.addClass(o.hoverClass); |
|
|
|
this.element.addClass(hoverClass); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
self.element.on("mouseleave." + self.getName(), function (e) { |
|
|
|
this.element.on("mouseleave." + this.getName(), (e) => { |
|
|
|
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) { |
|
|
|
if (this.isEnabled() && this.isValid() && this.combo.isEnabled() && this.combo.isValid()) { |
|
|
|
self.element.removeClass(o.hoverClass); |
|
|
|
this.element.removeClass(hoverClass); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
BI.createWidget(BI.extend({ |
|
|
|
createWidget(extend({ |
|
|
|
element: this, |
|
|
|
element: this, |
|
|
|
scrolly: false, |
|
|
|
scrolly: false, |
|
|
|
}, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { |
|
|
|
}, BI.LogicFactory.createLogic("vertical", extend(logic, { |
|
|
|
items: [ |
|
|
|
items: [ |
|
|
|
{ el: this.combo } |
|
|
|
{ el: this.combo } |
|
|
|
], |
|
|
|
], |
|
|
|
})))); |
|
|
|
})))); |
|
|
|
o.isDefaultInit && (this._assertPopupView()); |
|
|
|
isDefaultInit && (this._assertPopupView()); |
|
|
|
BI.Resizers.add(this.getName(), BI.bind(function (e) { |
|
|
|
Resizers.add(this.getName(), bind((e) => { |
|
|
|
// 如果resize对象是combo的子元素,则不应该收起,或交由hideChecker去处理
|
|
|
|
// 如果resize对象是combo的子元素,则不应该收起,或交由hideChecker去处理
|
|
|
|
if (this.isViewVisible()) { |
|
|
|
if (this.isViewVisible()) { |
|
|
|
BI.isNotNull(e) ? this._hideIf(e) : this._hideView(); |
|
|
|
isNotNull(e) ? this._hideIf(e) : this._hideView(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, this)); |
|
|
|
}, this)); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_assertPopupView: function () { |
|
|
|
_assertPopupView() { |
|
|
|
var self = this, o = this.options; |
|
|
|
const { showArrow, value, hideWhenClickOutside, hideWhenBlur } = this.options; |
|
|
|
if (BI.isNull(this.popupView)) { |
|
|
|
if (isNull(this.popupView)) { |
|
|
|
this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, { |
|
|
|
this.popupView = createWidget(isFunction(this.options.popup) ? this.options.popup() : this.options.popup, { |
|
|
|
type: "bi.popup_view", |
|
|
|
type: "bi.popup_view", |
|
|
|
showArrow: o.showArrow, |
|
|
|
showArrow, |
|
|
|
value: o.value, |
|
|
|
value, |
|
|
|
}, this); |
|
|
|
}, this); |
|
|
|
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { |
|
|
|
this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => { |
|
|
|
if (type === BI.Events.CLICK) { |
|
|
|
if (type === BI.Events.CLICK) { |
|
|
|
self.combo.setValue(self.getValue()); |
|
|
|
this.combo.setValue(this.getValue()); |
|
|
|
self.fireEvent(BI.Bubble.EVENT_CHANGE, value, obj); |
|
|
|
this.fireEvent(Bubble.EVENT_CHANGE, value, obj); |
|
|
|
} |
|
|
|
} |
|
|
|
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
|
|
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args); |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.popupView.setVisible(false); |
|
|
|
this.popupView.setVisible(false); |
|
|
|
BI.nextTick(function () { |
|
|
|
nextTick(() => { |
|
|
|
self.fireEvent(BI.Bubble.EVENT_AFTER_INIT); |
|
|
|
this.fireEvent(Bubble.EVENT_AFTER_INIT); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_hideView: function (e) { |
|
|
|
_hideView(e) { |
|
|
|
var o = this.options; |
|
|
|
const { hideWhenClickOutside, hideWhenBlur } = this.options; |
|
|
|
this.fireEvent(BI.Combo.EVENT_BEFORE_HIDEVIEW); |
|
|
|
this.fireEvent(Combo.EVENT_BEFORE_HIDEVIEW); |
|
|
|
if (this.options.destroyWhenHide === true) { |
|
|
|
if (this.options.destroyWhenHide === true) { |
|
|
|
this.popupView && this.popupView.destroy(); |
|
|
|
this.popupView && this.popupView.destroy(); |
|
|
|
this.popupView = null; |
|
|
|
this.popupView = null; |
|
|
@ -152,20 +167,20 @@ |
|
|
|
delete needHideWhenAnotherComboOpen[this.getName()]; |
|
|
|
delete needHideWhenAnotherComboOpen[this.getName()]; |
|
|
|
delete currentOpenedCombos[this.getName()]; |
|
|
|
delete currentOpenedCombos[this.getName()]; |
|
|
|
|
|
|
|
|
|
|
|
o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName()); |
|
|
|
hideWhenClickOutside && Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName()); |
|
|
|
BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).unbind("blur." + this.getName()); |
|
|
|
BI.EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind("blur." + this.getName()); |
|
|
|
this.fireEvent(BI.Combo.EVENT_AFTER_HIDEVIEW, e); |
|
|
|
this.fireEvent(Combo.EVENT_AFTER_HIDEVIEW, e); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_popupView: function (e) { |
|
|
|
_popupView(e) { |
|
|
|
var self = this, o = this.options; |
|
|
|
const { hideWhenClickOutside, hideWhenBlur } = this.options; |
|
|
|
this._assertPopupViewRender(); |
|
|
|
this._assertPopupViewRender(); |
|
|
|
this.fireEvent(BI.Combo.EVENT_BEFORE_POPUPVIEW); |
|
|
|
this.fireEvent(Combo.EVENT_BEFORE_POPUPVIEW); |
|
|
|
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下
|
|
|
|
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下
|
|
|
|
this.popupView.css({ left: -99999, top: -99999 }); |
|
|
|
this.popupView.css({ left: -99999, top: -99999 }); |
|
|
|
this.popupView.visible(); |
|
|
|
this.popupView.visible(); |
|
|
|
BI.each(needHideWhenAnotherComboOpen, function (i, combo) { |
|
|
|
each(needHideWhenAnotherComboOpen, (i, combo) => { |
|
|
|
if (i !== self.getName()) { |
|
|
|
if (i !== this.getName()) { |
|
|
|
if (combo && combo._hideIf(e, true) === true) { |
|
|
|
if (combo && combo._hideIf(e, true) === true) { |
|
|
|
delete needHideWhenAnotherComboOpen[i]; |
|
|
|
delete needHideWhenAnotherComboOpen[i]; |
|
|
|
} |
|
|
|
} |
|
|
@ -177,113 +192,113 @@ |
|
|
|
this.adjustHeight(e); |
|
|
|
this.adjustHeight(e); |
|
|
|
|
|
|
|
|
|
|
|
this.element.addClass(this.options.comboClass); |
|
|
|
this.element.addClass(this.options.comboClass); |
|
|
|
o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName()); |
|
|
|
hideWhenClickOutside && Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName()); |
|
|
|
o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).unbind("mousewheel." + this.getName()); |
|
|
|
hideWhenClickOutside && Widget._renderEngine.createElement(document).unbind("mousewheel." + this.getName()); |
|
|
|
BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).unbind("blur." + this.getName()); |
|
|
|
BI.EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind("blur." + this.getName()); |
|
|
|
|
|
|
|
|
|
|
|
o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).bind("mousedown." + this.getName(), BI.bind(this._hideIf, this)).bind("mousewheel." + this.getName(), BI.bind(this._hideIf, this)); |
|
|
|
hideWhenClickOutside && Widget._renderEngine.createElement(document).bind("mousewheel." + this.getName(), bind(this._hideIf, this)); |
|
|
|
o.hideWhenClickOutside && BI.Widget._renderEngine.createElement(document).bind("mousewheel." + this.getName(), BI.bind(this._hideIf, this)); |
|
|
|
hideWhenClickOutside && Widget._renderEngine.createElement(document).bind("mousedown." + this.getName(), bind(this._hideIf, this)).bind("mousewheel." + this.getName(), bind(this._hideIf, this)); |
|
|
|
BI.EVENT_BLUR && o.hideWhenBlur && BI.Widget._renderEngine.createElement(window).bind("blur." + this.getName(), BI.bind(this._hideIf, this)); |
|
|
|
BI.EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).bind("blur." + this.getName(), bind(this._hideIf, this)); |
|
|
|
this.fireEvent(BI.Combo.EVENT_AFTER_POPUPVIEW); |
|
|
|
this.fireEvent(Combo.EVENT_AFTER_POPUPVIEW); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
adjustHeight: function (e) { |
|
|
|
adjustHeight(e) { |
|
|
|
var o = this.options, p = {}; |
|
|
|
const { belowMouse, supportCSSTransform, container, direction, adjustXOffset, adjustYOffset, adjustLength, showArrow, isNeedAdjustHeight, offsetStyle } = this.options; |
|
|
|
|
|
|
|
let p = {}; |
|
|
|
if (!this.popupView) { |
|
|
|
if (!this.popupView) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var isVisible = this.popupView.isVisible(); |
|
|
|
const isVisible = this.popupView.isVisible(); |
|
|
|
this.popupView.visible(); |
|
|
|
this.popupView.visible(); |
|
|
|
var combo = (o.belowMouse && BI.isNotNull(e)) ? { |
|
|
|
const combo = (belowMouse && isNotNull(e)) ? { |
|
|
|
element: { |
|
|
|
element: { |
|
|
|
0: BI.extend({}, e.target, { |
|
|
|
0: e.target, |
|
|
|
getBoundingClientRect: function () { |
|
|
|
offset: () => { |
|
|
|
return { |
|
|
|
return { |
|
|
|
left: e.pageX, |
|
|
|
left: e.pageX, |
|
|
|
top: e.pageY, |
|
|
|
top: e.pageY, |
|
|
|
width: 0, |
|
|
|
|
|
|
|
height: 0, |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
}, |
|
|
|
}), |
|
|
|
bounds: () => { |
|
|
|
offset: function () { |
|
|
|
// offset为其相对于父定位元素的偏移
|
|
|
|
return { |
|
|
|
return { |
|
|
|
left: e.pageX, |
|
|
|
x: e.offsetX, |
|
|
|
top: e.pageY, |
|
|
|
y: e.offsetY, |
|
|
|
|
|
|
|
width: 0, |
|
|
|
|
|
|
|
height: 24, |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
outerWidth: () => { |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
outerHeight: () => { |
|
|
|
|
|
|
|
return 24; |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
} : this.combo; |
|
|
|
} : this.combo; |
|
|
|
|
|
|
|
const positionRelativeElement = supportCSSTransform ? BI.DOM.getPositionRelativeContainingBlock(isNull(container) ? this.element[0] : Widget._renderEngine.createElement(isFunction(container) ? container() : container)[0]) : null; |
|
|
|
var positionRelativeElement = BI.DOM.getPositionRelativeContainingBlock( |
|
|
|
const TRIANGLE_LENGTH = 12; |
|
|
|
BI.isNull(o.container) |
|
|
|
switch (direction) { |
|
|
|
? this.element[0] |
|
|
|
|
|
|
|
: BI.isWidget(o.container) |
|
|
|
|
|
|
|
? o.container.element[0] |
|
|
|
|
|
|
|
: BI.Widget._renderEngine.createElement(BI.isFunction(o.container) ? o.container() : o.container)[0] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["bottom", "top", "right", "left"], o.offsetStyle, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, adjustXOffset, (adjustYOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), isNeedAdjustHeight, ["bottom", "top", "right", "left"], offsetStyle, positionRelativeElement); |
|
|
|
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.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight, ["top", "bottom", "right", "left"], o.offsetStyle, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, adjustXOffset, (adjustYOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), isNeedAdjustHeight, ["top", "bottom", "right", "left"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "left": |
|
|
|
case "left": |
|
|
|
case "left,bottom": |
|
|
|
case "left,bottom": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), adjustYOffset, isNeedAdjustHeight, ["left", "right", "bottom", "top"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "right": |
|
|
|
case "right": |
|
|
|
case "right,bottom": |
|
|
|
case "right,bottom": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), adjustYOffset, isNeedAdjustHeight, ["right", "left", "bottom", "top"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "top,left": |
|
|
|
case "top,left": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, adjustXOffset, (adjustYOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), isNeedAdjustHeight, ["top", "bottom", "left", "right"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "bottom,left": |
|
|
|
case "bottom,left": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, adjustXOffset, (adjustYOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), isNeedAdjustHeight, ["bottom", "top", "left", "right"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "left,top": |
|
|
|
case "left,top": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), adjustYOffset, isNeedAdjustHeight, ["left", "right", "top", "bottom"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "right,top": |
|
|
|
case "right,top": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), adjustYOffset, isNeedAdjustHeight, ["right", "left", "top", "bottom"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "right,innerRight": |
|
|
|
case "right,innerRight": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), adjustYOffset, isNeedAdjustHeight, ["right", "left", "innerRight", "innerLeft", "bottom", "top"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "right,innerLeft": |
|
|
|
case "right,innerLeft": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), adjustYOffset, isNeedAdjustHeight, ["right", "left", "innerLeft", "innerRight", "bottom", "top"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "innerRight": |
|
|
|
case "innerRight": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), adjustYOffset, isNeedAdjustHeight, ["innerRight", "innerLeft", "right", "left", "bottom", "top"], offsetStyle, positionRelativeElement); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "innerLeft": |
|
|
|
case "innerLeft": |
|
|
|
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, positionRelativeElement); |
|
|
|
p = BI.DOM.getComboPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), adjustYOffset, isNeedAdjustHeight, ["innerLeft", "innerRight", "left", "right", "bottom", "top"], offsetStyle, positionRelativeElement); |
|
|
|
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.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight); |
|
|
|
p = BI.DOM.getTopAdaptPosition(combo, this.popupView, (adjustYOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), isNeedAdjustHeight); |
|
|
|
p.dir = "top"; |
|
|
|
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.showArrow ? this._const.TRIANGLE_LENGTH : 0), o.isNeedAdjustHeight); |
|
|
|
p = BI.DOM.getBottomAdaptPosition(combo, this.popupView, (adjustYOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0), isNeedAdjustHeight); |
|
|
|
p.dir = "bottom"; |
|
|
|
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) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0)); |
|
|
|
p = BI.DOM.getLeftAdaptPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0)); |
|
|
|
delete p.top; |
|
|
|
delete p.top; |
|
|
|
delete p.adaptHeight; |
|
|
|
delete p.adaptHeight; |
|
|
|
p.dir = "left"; |
|
|
|
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) + (o.showArrow ? this._const.TRIANGLE_LENGTH : 0)); |
|
|
|
p = BI.DOM.getRightAdaptPosition(combo, this.popupView, (adjustXOffset + adjustLength) + (showArrow ? TRIANGLE_LENGTH : 0)); |
|
|
|
delete p.top; |
|
|
|
delete p.top; |
|
|
|
delete p.adaptHeight; |
|
|
|
delete p.adaptHeight; |
|
|
|
p.dir = "right"; |
|
|
|
p.dir = "right"; |
|
|
@ -292,32 +307,30 @@ |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var width = this.combo.element.outerWidth(); |
|
|
|
if ("adaptHeight" in p) { |
|
|
|
var height = this.combo.element.outerHeight(); |
|
|
|
this.resetListHeight(p.adaptHeight); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const width = this.combo.element.outerWidth(); |
|
|
|
|
|
|
|
const height = this.combo.element.outerHeight(); |
|
|
|
this.popupView.setDirection && this.popupView.setDirection(p.dir, { |
|
|
|
this.popupView.setDirection && this.popupView.setDirection(p.dir, { |
|
|
|
width: width, |
|
|
|
width, |
|
|
|
height: height, |
|
|
|
height, |
|
|
|
offsetStyle: o.offsetStyle, |
|
|
|
offsetStyle, |
|
|
|
adjustXOffset: o.adjustXOffset, |
|
|
|
adjustXOffset, |
|
|
|
adjustYOffset: o.adjustYOffset, |
|
|
|
adjustYOffset, |
|
|
|
offset: this.combo.element.offset(), |
|
|
|
offset: this.combo.element.offset(), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (o.supportCSSTransform) { |
|
|
|
if (supportCSSTransform) { |
|
|
|
|
|
|
|
|
|
|
|
var positonedRect = positionRelativeElement.getBoundingClientRect(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var scaleX = positonedRect.width / positionRelativeElement.offsetWidth; |
|
|
|
const positonedRect = positionRelativeElement.getBoundingClientRect(); |
|
|
|
var scaleY = positonedRect.height / positionRelativeElement.offsetHeight; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p.top && (p.top = Math.round(p.top / scaleY + positionRelativeElement.scrollTop)); |
|
|
|
const scaleX = positonedRect.width / positionRelativeElement.offsetWidth; |
|
|
|
p.left && (p.left = Math.round(p.left / scaleX + positionRelativeElement.scrollLeft)); |
|
|
|
const scaleY = positonedRect.height / positionRelativeElement.offsetHeight; |
|
|
|
|
|
|
|
|
|
|
|
p.adaptHeight && (p.adaptHeight = Math.round(p.adaptHeight / scaleY)); |
|
|
|
p.top && (p.top = p.top / scaleY); |
|
|
|
} |
|
|
|
p.left && (p.left = p.left / scaleX); |
|
|
|
|
|
|
|
|
|
|
|
if ("adaptHeight" in p) { |
|
|
|
|
|
|
|
this.resetListHeight(p.adaptHeight); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ("left" in p) { |
|
|
|
if ("left" in p) { |
|
|
@ -332,25 +345,26 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
this.position = p; |
|
|
|
this.position = p; |
|
|
|
this.popupView.setVisible(isVisible); |
|
|
|
this.popupView.setVisible(isVisible); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
destroyed: function () { |
|
|
|
destroyed() { |
|
|
|
BI.Widget._renderEngine.createElement(document) |
|
|
|
Widget._renderEngine.createElement(document) |
|
|
|
.unbind("click." + this.getName()) |
|
|
|
.unbind("click." + this.getName()) |
|
|
|
.unbind("mousedown." + this.getName()) |
|
|
|
.unbind("mousedown." + this.getName()) |
|
|
|
.unbind("mousewheel." + this.getName()) |
|
|
|
.unbind("mousewheel." + this.getName()) |
|
|
|
.unbind("mouseenter." + this.getName()) |
|
|
|
.unbind("mouseenter." + this.getName()) |
|
|
|
.unbind("mouseleave." + this.getName()); |
|
|
|
.unbind("mouseleave." + this.getName()); |
|
|
|
BI.Widget._renderEngine.createElement(window) |
|
|
|
Widget._renderEngine.createElement(window) |
|
|
|
.unbind("blur." + this.getName()); |
|
|
|
.unbind("blur." + this.getName()); |
|
|
|
BI.Resizers.remove(this.getName()); |
|
|
|
Resizers.remove(this.getName()); |
|
|
|
this.popupView && this.popupView._destroy(); |
|
|
|
this.popupView && this.popupView._destroy(); |
|
|
|
delete needHideWhenAnotherComboOpen[this.getName()]; |
|
|
|
delete needHideWhenAnotherComboOpen[this.getName()]; |
|
|
|
delete currentOpenedCombos[this.getName()]; |
|
|
|
delete currentOpenedCombos[this.getName()]; |
|
|
|
}, |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
BI.Combo.closeAll = function () { |
|
|
|
|
|
|
|
BI.each(currentOpenedCombos, function (i, combo) { |
|
|
|
Combo.closeAll = () => { |
|
|
|
|
|
|
|
each(currentOpenedCombos, (i, combo) => { |
|
|
|
if (combo) { |
|
|
|
if (combo) { |
|
|
|
combo.hideView(); |
|
|
|
combo.hideView(); |
|
|
|
} |
|
|
|
} |
|
|
@ -358,17 +372,3 @@ |
|
|
|
currentOpenedCombos = {}; |
|
|
|
currentOpenedCombos = {}; |
|
|
|
needHideWhenAnotherComboOpen = {}; |
|
|
|
needHideWhenAnotherComboOpen = {}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
BI.Combo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; |
|
|
|
|
|
|
|
BI.Combo.EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
|
|
|
|
BI.Combo.EVENT_EXPAND = "EVENT_EXPAND"; |
|
|
|
|
|
|
|
BI.Combo.EVENT_COLLAPSE = "EVENT_COLLAPSE"; |
|
|
|
|
|
|
|
BI.Combo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BI.Combo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
|
|
|
|
|
|
|
BI.Combo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; |
|
|
|
|
|
|
|
BI.Combo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; |
|
|
|
|
|
|
|
BI.Combo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BI.shortcut("bi.combo", BI.Combo); |
|
|
|
|
|
|
|
}()); |
|
|
|
|
|
|
|