Browse Source

无Jira refact:combo的xtype写的有点问题

es6
Treecat 2 years ago
parent
commit
3e7e83b692
  1. 197
      src/base/single/button/button.basic.js
  2. 2
      src/case/combo/bubblecombo/popup.bubble.js

197
src/base/single/button/button.basic.js

@ -12,6 +12,7 @@ import {
} from "@/core"; } from "@/core";
import { BubbleCombo } from "@/case/combo/bubblecombo/combo.bubble"; import { BubbleCombo } from "@/case/combo/bubblecombo/combo.bubble";
import { Single } from "../0.single"; import { Single } from "../0.single";
import { BubblePopupView } from "@/case/combo/bubblecombo/popup.bubble";
/** /**
* guy * guy
@ -56,8 +57,8 @@ export class BasicButton extends Single {
const opts = this.options; const opts = this.options;
opts.selected = isFunction(opts.selected) opts.selected = isFunction(opts.selected)
? this.__watch(opts.selected, (context, newValue) => { ? this.__watch(opts.selected, (context, newValue) => {
this.setSelected(newValue); this.setSelected(newValue);
}) })
: opts.selected; : opts.selected;
super._init(arguments); super._init(arguments);
@ -105,7 +106,7 @@ export class BasicButton extends Single {
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}, }
], ],
}); });
} }
@ -117,7 +118,7 @@ export class BasicButton extends Single {
this.$mask.invisible(); this.$mask.invisible();
} }
}); });
this.element.on(`mouseenter.${this.getName()}`, (e) => { this.element.on(`mouseenter.${this.getName()}`, e => {
if (this.element.__isMouseInBounds__(e)) { if (this.element.__isMouseInBounds__(e)) {
if (this.isEnabled() && !this._hover && (o.isShadowShowingOnSelected || !this.isSelected())) { if (this.isEnabled() && !this._hover && (o.isShadowShowingOnSelected || !this.isSelected())) {
assertMask(); assertMask();
@ -125,7 +126,7 @@ export class BasicButton extends Single {
} }
} }
}); });
this.element.on(`mousemove.${this.getName()}`, (e) => { this.element.on(`mousemove.${this.getName()}`, e => {
if (!this.element.__isMouseInBounds__(e)) { if (!this.element.__isMouseInBounds__(e)) {
if (this.isEnabled() && !this._hover) { if (this.isEnabled() && !this._hover) {
assertMask(); assertMask();
@ -158,7 +159,7 @@ export class BasicButton extends Single {
return bubble; return bubble;
}; };
const clk = (e) => { const clk = e => {
ev(e); ev(e);
if (!this.isEnabled() || !this.isValid()) { if (!this.isEnabled() || !this.isValid()) {
return; return;
@ -179,7 +180,7 @@ export class BasicButton extends Single {
trigger: "", trigger: "",
// bubble的提示不需要一直存在在界面上 // bubble的提示不需要一直存在在界面上
destroyWhenHide: true, destroyWhenHide: true,
ref: (_ref) => { ref: _ref => {
this.combo = _ref; this.combo = _ref;
}, },
el: { el: {
@ -187,9 +188,9 @@ export class BasicButton extends Single {
height: "100%", height: "100%",
}, },
popup: { popup: {
type: "bi.text_bubble_bar_popup_view", type: BubblePopupView.xtype,
text: getBubble(), text: getBubble(),
ref: (_ref) => { ref: _ref => {
popup = _ref; popup = _ref;
}, },
listeners: [ listeners: [
@ -202,7 +203,7 @@ export class BasicButton extends Single {
onClick.apply(this, args); onClick.apply(this, args);
} }
}, },
}, }
], ],
}, },
listeners: [ listeners: [
@ -211,14 +212,14 @@ export class BasicButton extends Single {
action() { action() {
popup.populate(getBubble()); popup.populate(getBubble());
}, },
}, }
], ],
}, },
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
top: 0, top: 0,
}, }
], ],
}); });
} }
@ -234,117 +235,117 @@ export class BasicButton extends Single {
}; };
const triggerArr = (o.trigger || "").split(","); const triggerArr = (o.trigger || "").split(",");
triggerArr.forEach((trigger) => { triggerArr.forEach(trigger => {
let mouseDown = false; let mouseDown = false;
let selected = false; let selected = false;
let interval; let interval;
switch (trigger) { switch (trigger) {
case "mouseup": case "mouseup":
hand.mousedown(() => { hand.mousedown(() => {
mouseDown = true; mouseDown = true;
}); });
hand.mouseup((e) => { hand.mouseup(e => {
if (mouseDown === true) { if (mouseDown === true) {
clk(e); clk(e);
} }
mouseDown = false; mouseDown = false;
ev(e); ev(e);
}); });
break; break;
case "mousedown": case "mousedown":
// let mouseDown = false; // let mouseDown = false;
hand.mousedown((e) => { hand.mousedown(e => {
// if (e.button === 0) {
Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, e => {
// if (e.button === 0) { // if (e.button === 0) {
Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, (e) => { if (
// if (e.button === 0) { BI.DOM.isExist(this) &&
if (
BI.DOM.isExist(this) &&
!hand.__isMouseInBounds__(e) && !hand.__isMouseInBounds__(e) &&
mouseDown === true && mouseDown === true &&
!selected !selected
) { ) {
// self.setSelected(!self.isSelected()); // self.setSelected(!self.isSelected());
this._trigger(); this._trigger();
}
mouseDown = false;
Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
// }
});
if (mouseDown === true) {
return;
}
if (this.isSelected()) {
selected = true;
} else {
clk(e);
} }
mouseDown = true; mouseDown = false;
ev(e); Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
// } // }
}); });
hand.mouseup((e) => { if (mouseDown === true) {
// if (e.button === 0) { return;
if (BI.DOM.isExist(this) && mouseDown === true && selected === true) { }
clk(e); if (this.isSelected()) {
} selected = true;
} else {
clk(e);
}
mouseDown = true;
ev(e);
// }
});
hand.mouseup(e => {
// if (e.button === 0) {
if (BI.DOM.isExist(this) && mouseDown === true && selected === true) {
clk(e);
}
mouseDown = false;
selected = false;
Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
// }
});
break;
case "dblclick":
hand.dblclick(clk);
break;
case "lclick":
hand.mousedown(e => {
Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, () => {
interval && clearInterval(interval);
interval = null;
mouseDown = false; mouseDown = false;
selected = false;
Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`); Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
// }
}); });
break; if (mouseDown === true) {
case "dblclick": return;
hand.dblclick(clk); }
break; if (!this.isEnabled() || !this.isValid()) {
case "lclick": return;
hand.mousedown((e) => { }
Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, () => { if (this.isOnce() && this.isSelected()) {
interval && clearInterval(interval); return;
interval = null; }
mouseDown = false; interval = setInterval(() => {
Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`); clk(e);
}); }, 180);
if (mouseDown === true) { mouseDown = true;
return; ev(e);
} });
if (!this.isEnabled() || !this.isValid()) { break;
return; default:
} if (o.stopEvent || o.stopPropagation) {
if (this.isOnce() && this.isSelected()) { hand.mousedown(e => {
return;
}
interval = setInterval(() => {
clk(e);
}, 180);
mouseDown = true;
ev(e); ev(e);
}); });
break; }
default: hand.click(clk);
if (o.stopEvent || o.stopPropagation) { // enter键等同于点击
hand.mousedown((e) => { o.attributes &&
ev(e);
});
}
hand.click(clk);
// enter键等同于点击
o.attributes &&
o.attributes.zIndex >= 0 && o.attributes.zIndex >= 0 &&
hand.keyup((e) => { hand.keyup(e => {
if (e.keyCode === BI.KeyCode.ENTER) { if (e.keyCode === BI.KeyCode.ENTER) {
clk(e); clk(e);
} }
}); });
break; break;
} }
}); });
// 之后的300ms点击无效 // 之后的300ms点击无效
const onClick = o.debounce const onClick = o.debounce
? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { ? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, {
leading: true, leading: true,
trailing: false, trailing: false,
}) })
: this._doClick; : this._doClick;
function ev(e) { function ev(e) {
@ -366,8 +367,8 @@ export class BasicButton extends Single {
this.isForceSelected() this.isForceSelected()
? this.setSelected(true) ? this.setSelected(true)
: this.isForceNotSelected() : this.isForceNotSelected()
? this.setSelected(false) ? this.setSelected(false)
: this.setSelected(!this.isSelected()); : this.setSelected(!this.isSelected());
} }
if (this.isValid()) { if (this.isValid()) {
const v = this.getValue(); const v = this.getValue();

2
src/case/combo/bubblecombo/popup.bubble.js

@ -4,7 +4,7 @@ import { Label } from "@/base/single/label/label";
@shortcut() @shortcut()
export class BubblePopupView extends PopupView { export class BubblePopupView extends PopupView {
static xtype = "bi.bubble_popup_view"; static xtype = "bi.text_bubble_bar_popup_view";
static EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON"; static EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON";
static EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON"; static EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON";

Loading…
Cancel
Save