|
|
@ -1,15 +1,24 @@ |
|
|
|
|
|
|
|
import { Single } from "../0.single" |
|
|
|
|
|
|
|
import { emptyFn, shortcut, extend, isFunction, createWidget, Widget, isObject, Controller } from "../../../core" |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* guy |
|
|
|
* guy |
|
|
|
* @class BI.BasicButton |
|
|
|
* @class BasicButton |
|
|
|
* @extends BI.Single |
|
|
|
* @extends Single |
|
|
|
* |
|
|
|
* |
|
|
|
* 一般的button父级 |
|
|
|
* 一般的button父级 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
@shortcut() |
|
|
|
_defaultConfig: function () { |
|
|
|
export class BasicButton extends Single { |
|
|
|
var conf = BI.BasicButton.superclass._defaultConfig.apply(this, arguments); |
|
|
|
|
|
|
|
|
|
|
|
static xtype = "bi.basic_button"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static EVENT_CHANGE = "BasicButton.EVENT_CHANGE"; |
|
|
|
|
|
|
|
|
|
|
|
return BI.extend(conf, { |
|
|
|
_defaultConfig() { |
|
|
|
|
|
|
|
const conf = super._defaultConfig(arguments); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return extend(conf, { |
|
|
|
_baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), |
|
|
|
_baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), |
|
|
|
// el: {} // 可以通过el来创建button元素
|
|
|
|
// el: {} // 可以通过el来创建button元素
|
|
|
|
value: "", |
|
|
|
value: "", |
|
|
@ -24,19 +33,18 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
shadow: false, |
|
|
|
shadow: false, |
|
|
|
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
|
|
|
|
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
|
|
|
|
trigger: null, |
|
|
|
trigger: null, |
|
|
|
handler: BI.emptyFn, |
|
|
|
handler: emptyFn, |
|
|
|
bubble: null, |
|
|
|
bubble: null, |
|
|
|
debounce: true |
|
|
|
debounce: true |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_init: function () { |
|
|
|
_init() { |
|
|
|
var self = this; |
|
|
|
const opts = this.options; |
|
|
|
var opts = this.options; |
|
|
|
opts.selected = isFunction(opts.selected) ? this.__watch(opts.selected, (context, newValue) => { |
|
|
|
opts.selected = BI.isFunction(opts.selected) ? this.__watch(opts.selected, function (context, newValue) { |
|
|
|
this.setSelected(newValue); |
|
|
|
self.setSelected(newValue); |
|
|
|
|
|
|
|
}) : opts.selected; |
|
|
|
}) : opts.selected; |
|
|
|
BI.BasicButton.superclass._init.apply(this, arguments); |
|
|
|
super._init(arguments); |
|
|
|
|
|
|
|
|
|
|
|
if (opts.shadow) { |
|
|
|
if (opts.shadow) { |
|
|
|
this._createShadow(); |
|
|
|
this._createShadow(); |
|
|
@ -44,9 +52,9 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
if (opts.level) { |
|
|
|
if (opts.level) { |
|
|
|
this.element.addClass("button-" + opts.level); |
|
|
|
this.element.addClass("button-" + opts.level); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_initRef: function () { |
|
|
|
_initRef() { |
|
|
|
if (this.options.selected === true) { |
|
|
|
if (this.options.selected === true) { |
|
|
|
this.setSelected(true); |
|
|
|
this.setSelected(true); |
|
|
|
} |
|
|
|
} |
|
|
@ -54,29 +62,29 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
BI.nextTick(() => { |
|
|
|
BI.nextTick(() => { |
|
|
|
!this.isDestroyed() && this.bindEvent(); |
|
|
|
!this.isDestroyed() && this.bindEvent(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
BI.BasicButton.superclass._initRef.apply(this, arguments); |
|
|
|
super._initRef.apply(this, arguments); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 默认render方法
|
|
|
|
// 默认render方法
|
|
|
|
render: function () { |
|
|
|
render() { |
|
|
|
return this.options.el; |
|
|
|
return this.options.el; |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_createShadow: function () { |
|
|
|
_createShadow() { |
|
|
|
var self = this, o = this.options; |
|
|
|
const o = this.options; |
|
|
|
|
|
|
|
|
|
|
|
function assertMask() { |
|
|
|
const assertMask = () => { |
|
|
|
if (!self.$mask) { |
|
|
|
if (!this.$mask) { |
|
|
|
self.$mask = BI.createWidget(BI.isObject(o.shadow) ? o.shadow : {}, { |
|
|
|
this.$mask = createWidget(isObject(o.shadow) ? o.shadow : {}, { |
|
|
|
type: "bi.layout", |
|
|
|
type: "bi.layout", |
|
|
|
cls: "bi-button-mask", |
|
|
|
cls: "bi-button-mask", |
|
|
|
}); |
|
|
|
}); |
|
|
|
self.$mask.invisible(); |
|
|
|
this.$mask.invisible(); |
|
|
|
BI.createWidget({ |
|
|
|
createWidget({ |
|
|
|
type: "bi.absolute", |
|
|
|
type: "bi.absolute", |
|
|
|
element: self, |
|
|
|
element: this, |
|
|
|
items: [{ |
|
|
|
items: [{ |
|
|
|
el: self.$mask, |
|
|
|
el: this.$mask, |
|
|
|
left: 0, |
|
|
|
left: 0, |
|
|
|
right: 0, |
|
|
|
right: 0, |
|
|
|
top: 0, |
|
|
|
top: 0, |
|
|
@ -86,48 +94,129 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.element.mouseup(function () { |
|
|
|
this.element.mouseup(() => { |
|
|
|
if (!self._hover && !o.isShadowShowingOnSelected) { |
|
|
|
if (!this._hover && !o.isShadowShowingOnSelected) { |
|
|
|
assertMask(); |
|
|
|
assertMask(); |
|
|
|
self.$mask.invisible(); |
|
|
|
this.$mask.invisible(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.element.on("mouseenter." + this.getName(), function (e) { |
|
|
|
this.element.on("mouseenter." + this.getName(), (e) => { |
|
|
|
if (self.element.__isMouseInBounds__(e)) { |
|
|
|
if (this.element.__isMouseInBounds__(e)) { |
|
|
|
if (self.isEnabled() && !self._hover && (o.isShadowShowingOnSelected || !self.isSelected())) { |
|
|
|
if (this.isEnabled() && !this._hover && (o.isShadowShowingOnSelected || !this.isSelected())) { |
|
|
|
assertMask(); |
|
|
|
assertMask(); |
|
|
|
self.$mask.visible(); |
|
|
|
this.$mask.visible(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.element.on("mousemove." + this.getName(), function (e) { |
|
|
|
this.element.on("mousemove." + this.getName(), (e) => { |
|
|
|
if (!self.element.__isMouseInBounds__(e)) { |
|
|
|
if (!this.element.__isMouseInBounds__(e)) { |
|
|
|
if (self.isEnabled() && !self._hover) { |
|
|
|
if (this.isEnabled() && !this._hover) { |
|
|
|
assertMask(); |
|
|
|
assertMask(); |
|
|
|
self.$mask.invisible(); |
|
|
|
this.$mask.invisible(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.element.on("mouseleave." + this.getName(), function () { |
|
|
|
this.element.on("mouseleave." + this.getName(), () => { |
|
|
|
if (self.isEnabled() && !self._hover) { |
|
|
|
if (this.isEnabled() && !this._hover) { |
|
|
|
assertMask(); |
|
|
|
assertMask(); |
|
|
|
self.$mask.invisible(); |
|
|
|
this.$mask.invisible(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bindEvent: function () { |
|
|
|
bindEvent() { |
|
|
|
var self = this; |
|
|
|
const o = this.options; |
|
|
|
var o = this.options, hand = this.handle(); |
|
|
|
let hand = this.handle(); |
|
|
|
if (!hand) { |
|
|
|
if (!hand) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
hand = hand.element; |
|
|
|
hand = hand.element; |
|
|
|
var triggerArr = (o.trigger || "").split(","); |
|
|
|
|
|
|
|
BI.each(triggerArr, function (idx, trigger) { |
|
|
|
const getBubble = () => { |
|
|
|
|
|
|
|
const bubble = o.bubble; |
|
|
|
|
|
|
|
if (isFunction(bubble)) { |
|
|
|
|
|
|
|
return bubble(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return bubble; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const clk = (e) => { |
|
|
|
|
|
|
|
ev(e); |
|
|
|
|
|
|
|
if (!this.isEnabled() || !this.isValid()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (this.isOnce() && this.isSelected()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (BI.isKey(o.bubble) || isFunction(o.bubble)) { |
|
|
|
|
|
|
|
if (BI.isNull(this.combo)) { |
|
|
|
|
|
|
|
let popup; |
|
|
|
|
|
|
|
createWidget({ |
|
|
|
|
|
|
|
type: "bi.absolute", |
|
|
|
|
|
|
|
element: this, |
|
|
|
|
|
|
|
items: [{ |
|
|
|
|
|
|
|
el: { |
|
|
|
|
|
|
|
type: "bi.bubble_combo", |
|
|
|
|
|
|
|
trigger: "", |
|
|
|
|
|
|
|
// bubble的提示不需要一直存在在界面上
|
|
|
|
|
|
|
|
destroyWhenHide: true, |
|
|
|
|
|
|
|
ref: (_ref) => { |
|
|
|
|
|
|
|
this.combo = _ref; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
el: { |
|
|
|
|
|
|
|
type: "bi.layout", |
|
|
|
|
|
|
|
height: "100%", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
popup: { |
|
|
|
|
|
|
|
type: "bi.text_bubble_bar_popup_view", |
|
|
|
|
|
|
|
text: getBubble(), |
|
|
|
|
|
|
|
ref: (_ref) => { |
|
|
|
|
|
|
|
popup = _ref; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
listeners: [{ |
|
|
|
|
|
|
|
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, |
|
|
|
|
|
|
|
action: (...args) => { |
|
|
|
|
|
|
|
const [v] = args; |
|
|
|
|
|
|
|
this.combo.hideView(); |
|
|
|
|
|
|
|
if (v) { |
|
|
|
|
|
|
|
onClick.apply(this, args); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
listeners: [{ |
|
|
|
|
|
|
|
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, |
|
|
|
|
|
|
|
action: function () { |
|
|
|
|
|
|
|
popup.populate(getBubble()); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
left: 0, |
|
|
|
|
|
|
|
right: 0, |
|
|
|
|
|
|
|
bottom: 0, |
|
|
|
|
|
|
|
top: 0, |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (this.combo.isViewVisible()) { |
|
|
|
|
|
|
|
this.combo.hideView(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.combo.showView(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
onClick.apply(this, arguments); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const triggerArr = (o.trigger || "").split(","); |
|
|
|
|
|
|
|
triggerArr.forEach((trigger) => { |
|
|
|
|
|
|
|
let mouseDown = false; |
|
|
|
switch (trigger) { |
|
|
|
switch (trigger) { |
|
|
|
case "mouseup": |
|
|
|
case "mouseup": |
|
|
|
var mouseDown = false; |
|
|
|
|
|
|
|
hand.mousedown(function () { |
|
|
|
hand.mousedown(function () { |
|
|
|
mouseDown = true; |
|
|
|
mouseDown = true; |
|
|
|
}); |
|
|
|
}); |
|
|
@ -140,24 +229,24 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
}); |
|
|
|
}); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "mousedown": |
|
|
|
case "mousedown": |
|
|
|
var mouseDown = false; |
|
|
|
// let mouseDown = false;
|
|
|
|
var selected = false; |
|
|
|
let selected = false; |
|
|
|
hand.mousedown(function (e) { |
|
|
|
hand.mousedown((e) => { |
|
|
|
// if (e.button === 0) {
|
|
|
|
// if (e.button === 0) {
|
|
|
|
BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function (e) { |
|
|
|
Widget._renderEngine.createElement(document).bind("mouseup." + this.getName(), (e) => { |
|
|
|
// if (e.button === 0) {
|
|
|
|
// if (e.button === 0) {
|
|
|
|
if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { |
|
|
|
if (BI.DOM.isExist(this) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { |
|
|
|
// self.setSelected(!self.isSelected());
|
|
|
|
// self.setSelected(!self.isSelected());
|
|
|
|
self._trigger(); |
|
|
|
this._trigger(); |
|
|
|
} |
|
|
|
} |
|
|
|
mouseDown = false; |
|
|
|
mouseDown = false; |
|
|
|
BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); |
|
|
|
Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}); |
|
|
|
}); |
|
|
|
if (mouseDown === true) { |
|
|
|
if (mouseDown === true) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (self.isSelected()) { |
|
|
|
if (this.isSelected()) { |
|
|
|
selected = true; |
|
|
|
selected = true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
clk(e); |
|
|
|
clk(e); |
|
|
@ -166,14 +255,14 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
ev(e); |
|
|
|
ev(e); |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}); |
|
|
|
}); |
|
|
|
hand.mouseup(function (e) { |
|
|
|
hand.mouseup((e) => { |
|
|
|
// if (e.button === 0) {
|
|
|
|
// if (e.button === 0) {
|
|
|
|
if (BI.DOM.isExist(self) && mouseDown === true && selected === true) { |
|
|
|
if (BI.DOM.isExist(this) && mouseDown === true && selected === true) { |
|
|
|
clk(e); |
|
|
|
clk(e); |
|
|
|
} |
|
|
|
} |
|
|
|
mouseDown = false; |
|
|
|
mouseDown = false; |
|
|
|
selected = false; |
|
|
|
selected = false; |
|
|
|
BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); |
|
|
|
Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}); |
|
|
|
}); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -181,22 +270,21 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
hand.dblclick(clk); |
|
|
|
hand.dblclick(clk); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "lclick": |
|
|
|
case "lclick": |
|
|
|
var mouseDown = false; |
|
|
|
let interval; |
|
|
|
var interval; |
|
|
|
hand.mousedown((e) => { |
|
|
|
hand.mousedown(function (e) { |
|
|
|
Widget._renderEngine.createElement(document).bind("mouseup." + this.getName(), () => { |
|
|
|
BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function () { |
|
|
|
|
|
|
|
interval && clearInterval(interval); |
|
|
|
interval && clearInterval(interval); |
|
|
|
interval = null; |
|
|
|
interval = null; |
|
|
|
mouseDown = false; |
|
|
|
mouseDown = false; |
|
|
|
BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); |
|
|
|
Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (mouseDown === true) { |
|
|
|
if (mouseDown === true) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!self.isEnabled() || !self.isValid()) { |
|
|
|
if (!this.isEnabled() || !this.isValid()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (self.isOnce() && self.isSelected()) { |
|
|
|
if (this.isOnce() && this.isSelected()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
interval = setInterval(function () { |
|
|
|
interval = setInterval(function () { |
|
|
@ -224,7 +312,7 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 之后的300ms点击无效
|
|
|
|
// 之后的300ms点击无效
|
|
|
|
var onClick = o.debounce ? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { |
|
|
|
let onClick = o.debounce ? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { |
|
|
|
"leading": true, |
|
|
|
"leading": true, |
|
|
|
"trailing": false, |
|
|
|
"trailing": false, |
|
|
|
}) : this._doClick; |
|
|
|
}) : this._doClick; |
|
|
@ -238,86 +326,13 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function clk(e) { |
|
|
|
|
|
|
|
ev(e); |
|
|
|
|
|
|
|
if (!self.isEnabled() || !self.isValid()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (self.isOnce() && self.isSelected()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (BI.isKey(o.bubble) || BI.isFunction(o.bubble)) { |
|
|
|
|
|
|
|
if (BI.isNull(self.combo)) { |
|
|
|
|
|
|
|
var popup; |
|
|
|
|
|
|
|
BI.createWidget({ |
|
|
|
|
|
|
|
type: "bi.absolute", |
|
|
|
|
|
|
|
element: self, |
|
|
|
|
|
|
|
items: [{ |
|
|
|
|
|
|
|
el: { |
|
|
|
|
|
|
|
type: "bi.bubble_combo", |
|
|
|
|
|
|
|
trigger: "", |
|
|
|
|
|
|
|
// bubble的提示不需要一直存在在界面上
|
|
|
|
|
|
|
|
destroyWhenHide: true, |
|
|
|
|
|
|
|
ref: function () { |
|
|
|
|
|
|
|
self.combo = this; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
el: { |
|
|
|
|
|
|
|
type: "bi.layout", |
|
|
|
|
|
|
|
height: "100%", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
popup: { |
|
|
|
|
|
|
|
type: "bi.text_bubble_bar_popup_view", |
|
|
|
|
|
|
|
text: getBubble(), |
|
|
|
|
|
|
|
ref: function () { |
|
|
|
|
|
|
|
popup = this; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
listeners: [{ |
|
|
|
|
|
|
|
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, |
|
|
|
|
|
|
|
action: function (v) { |
|
|
|
|
|
|
|
self.combo.hideView(); |
|
|
|
|
|
|
|
if (v) { |
|
|
|
|
|
|
|
onClick.apply(self, arguments); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
listeners: [{ |
|
|
|
|
|
|
|
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, |
|
|
|
|
|
|
|
action: function () { |
|
|
|
|
|
|
|
popup.populate(getBubble()); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
left: 0, |
|
|
|
|
|
|
|
right: 0, |
|
|
|
|
|
|
|
bottom: 0, |
|
|
|
|
|
|
|
top: 0, |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (self.combo.isViewVisible()) { |
|
|
|
|
|
|
|
self.combo.hideView(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self.combo.showView(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
onClick.apply(self, arguments); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getBubble() { |
|
|
|
|
|
|
|
var bubble = self.options.bubble; |
|
|
|
|
|
|
|
if (BI.isFunction(bubble)) { |
|
|
|
|
|
|
|
return bubble(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return bubble; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_trigger: function (e) { |
|
|
|
_trigger(e) { |
|
|
|
var o = this.options; |
|
|
|
const o = this.options; |
|
|
|
if (!this.isEnabled()) { |
|
|
|
if (!this.isEnabled()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -327,22 +342,22 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
this.setSelected(!this.isSelected())); |
|
|
|
this.setSelected(!this.isSelected())); |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.isValid()) { |
|
|
|
if (this.isValid()) { |
|
|
|
var v = this.getValue(); |
|
|
|
const v = this.getValue(); |
|
|
|
o.handler.call(this, v, this, e); |
|
|
|
o.handler.call(this, v, this, e); |
|
|
|
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, v, this, e); |
|
|
|
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.CLICK, v, this, e); |
|
|
|
this.fireEvent(BI.BasicButton.EVENT_CHANGE, v, this); |
|
|
|
this.fireEvent(BasicButton.EVENT_CHANGE, v, this); |
|
|
|
if (o.action) { |
|
|
|
if (o.action) { |
|
|
|
BI.Actions.runAction(o.action, "click", o, this); |
|
|
|
BI.Actions.runAction(o.action, "click", o, this); |
|
|
|
} |
|
|
|
} |
|
|
|
BI.Actions.runGlobalAction("click", o, this); |
|
|
|
BI.Actions.runGlobalAction("click", o, this); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_doClick: function (e) { |
|
|
|
_doClick(e) { |
|
|
|
if (!this.isEnabled() || !this.isValid()) { |
|
|
|
if (!this.isEnabled() || !this.isValid()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var isIntercepted = this.beforeClick(e); |
|
|
|
const isIntercepted = this.beforeClick(e); |
|
|
|
// 如果事件已经被消费掉了,就不再触发点击事件
|
|
|
|
// 如果事件已经被消费掉了,就不再触发点击事件
|
|
|
|
if (isIntercepted) { |
|
|
|
if (isIntercepted) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -352,41 +367,41 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
if (this.isEnabled() && this.isValid()) { |
|
|
|
if (this.isEnabled() && this.isValid()) { |
|
|
|
this.doClick(e); |
|
|
|
this.doClick(e); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 子类可以得写这个方法,如果返回为 true,则可以阻止 handler 的触发 |
|
|
|
* 子类可以得写这个方法,如果返回为 true,则可以阻止 handler 的触发 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
beforeClick: function () { |
|
|
|
beforeClick() { |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
doClick: function () { |
|
|
|
doClick() { |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handle: function () { |
|
|
|
handle() { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
hover: function () { |
|
|
|
hover() { |
|
|
|
this._hover = true; |
|
|
|
this._hover = true; |
|
|
|
this.handle().element.addClass("hover"); |
|
|
|
this.handle().element.addClass("hover"); |
|
|
|
if (this.options.shadow) { |
|
|
|
if (this.options.shadow) { |
|
|
|
this.$mask && this.$mask.setVisible(true); |
|
|
|
this.$mask && this.$mask.setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dishover: function () { |
|
|
|
dishover() { |
|
|
|
this._hover = false; |
|
|
|
this._hover = false; |
|
|
|
this.handle().element.removeClass("hover"); |
|
|
|
this.handle().element.removeClass("hover"); |
|
|
|
if (this.options.shadow) { |
|
|
|
if (this.options.shadow) { |
|
|
|
this.$mask && this.$mask.setVisible(false); |
|
|
|
this.$mask && this.$mask.setVisible(false); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setSelected: function (b) { |
|
|
|
setSelected(b) { |
|
|
|
var o = this.options; |
|
|
|
const o = this.options; |
|
|
|
o.selected = b; |
|
|
|
o.selected = b; |
|
|
|
if (b) { |
|
|
|
if (b) { |
|
|
|
this.handle().element.addClass("active"); |
|
|
|
this.handle().element.addClass("active"); |
|
|
@ -397,39 +412,39 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
this.$mask && this.$mask.setVisible(false); |
|
|
|
this.$mask && this.$mask.setVisible(false); |
|
|
|
} |
|
|
|
} |
|
|
|
this.options.setSelected && this.options.setSelected.call(this, b); |
|
|
|
this.options.setSelected && this.options.setSelected.call(this, b); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isSelected: function () { |
|
|
|
isSelected() { |
|
|
|
return this.options.selected; |
|
|
|
return this.options.selected; |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isOnce: function () { |
|
|
|
isOnce() { |
|
|
|
return this.options.once; |
|
|
|
return this.options.once; |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isForceSelected: function () { |
|
|
|
isForceSelected() { |
|
|
|
return this.options.forceSelected; |
|
|
|
return this.options.forceSelected; |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isForceNotSelected: function () { |
|
|
|
isForceNotSelected() { |
|
|
|
return this.options.forceNotSelected; |
|
|
|
return this.options.forceNotSelected; |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isDisableSelected: function () { |
|
|
|
isDisableSelected() { |
|
|
|
return this.options.disableSelected; |
|
|
|
return this.options.disableSelected; |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setText: function (text) { |
|
|
|
setText(text) { |
|
|
|
this.options.text = text; |
|
|
|
this.options.text = text; |
|
|
|
this.options.setText && this.options.setText.call(this, text); |
|
|
|
this.options.setText && this.options.setText.call(this, text); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getText: function () { |
|
|
|
getText() { |
|
|
|
return this.options.text; |
|
|
|
return this.options.text; |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_setEnable: function (enable) { |
|
|
|
_setEnable(enable) { |
|
|
|
BI.BasicButton.superclass._setEnable.apply(this, arguments); |
|
|
|
super._setEnable.apply(this, arguments); |
|
|
|
if (enable === true) { |
|
|
|
if (enable === true) { |
|
|
|
this.element.removeClass("base-disabled disabled"); |
|
|
|
this.element.removeClass("base-disabled disabled"); |
|
|
|
} else if (enable === false) { |
|
|
|
} else if (enable === false) { |
|
|
@ -440,12 +455,12 @@ BI.BasicButton = BI.inherit(BI.Single, { |
|
|
|
this.$mask && this.$mask.setVisible(false); |
|
|
|
this.$mask && this.$mask.setVisible(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
empty() { |
|
|
|
|
|
|
|
Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); |
|
|
|
|
|
|
|
super.empty.apply(this, arguments); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
empty: function () { |
|
|
|
|
|
|
|
BI.Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); |
|
|
|
|
|
|
|
BI.BasicButton.superclass.empty.apply(this, arguments); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE"; |
|
|
|
|
|
|
|
BI.shortcut("bi.basic_button", BI.BasicButton); |
|
|
|
|
|
|
|