Browse Source

KERNEL-13972 refactor: 解决冲突

es6
Joker.Wang-王顺 2 years ago
parent
commit
f931531212
  1. 12
      src/base/1.pane.js
  2. 77
      src/base/single/button/button.basic.js
  3. 7
      src/base/single/button/button.node.js
  4. 3
      src/base/single/button/buttons/button.image.js
  5. 25
      src/base/single/button/buttons/button.js
  6. 11
      src/base/single/button/buttons/button.text.js
  7. 23
      src/base/single/button/listitem/blankiconicontextitem.js
  8. 21
      src/base/single/button/listitem/blankicontexticonitem.js
  9. 21
      src/base/single/button/listitem/blankicontextitem.js
  10. 21
      src/base/single/button/listitem/icontexticonitem.js
  11. 21
      src/base/single/button/listitem/icontextitem.js
  12. 21
      src/base/single/button/listitem/texticonitem.js
  13. 19
      src/base/single/button/listitem/textitem.js
  14. 17
      src/base/single/button/node/icontexticonnode.js
  15. 17
      src/base/single/button/node/icontextnode.js
  16. 17
      src/base/single/button/node/texticonnode.js
  17. 15
      src/base/single/button/node/textnode.js
  18. 66
      src/case/button/icon/icon.change.js
  19. 27
      src/case/button/icon/icon.trigger.js
  20. 23
      src/case/button/icon/iconhalf/icon.half.image.js
  21. 36
      src/case/button/icon/iconhalf/icon.half.js
  22. 29
      src/case/button/index.js
  23. 64
      src/case/button/item.multiselect.js
  24. 60
      src/case/button/item.singleselect.icontext.js
  25. 65
      src/case/button/item.singleselect.js
  26. 69
      src/case/button/item.singleselect.radio.js
  27. 71
      src/case/button/node/node.arrow.js
  28. 82
      src/case/button/node/node.first.plus.js
  29. 99
      src/case/button/node/node.icon.arrow.js
  30. 93
      src/case/button/node/node.last.plus.js
  31. 85
      src/case/button/node/node.mid.plus.js
  32. 88
      src/case/button/node/node.multilayer.icon.arrow.js
  33. 79
      src/case/button/node/node.plus.js
  34. 45
      src/case/button/node/siwtcher.tree.node.js
  35. 77
      src/case/button/node/treenode.js
  36. 85
      src/case/button/switch.js
  37. 92
      src/case/button/treeitem/item.first.treeleaf.js
  38. 86
      src/case/button/treeitem/item.icon.treeleaf.js
  39. 94
      src/case/button/treeitem/item.last.treeleaf.js
  40. 94
      src/case/button/treeitem/item.mid.treeleaf.js
  41. 92
      src/case/button/treeitem/item.multilayer.icon.treeleaf.js
  42. 78
      src/case/button/treeitem/item.root.treeleaf.js
  43. 68
      src/case/button/treeitem/item.treetextleaf.js
  44. 62
      src/case/button/treeitem/treeitem.js
  45. 7
      src/case/index.js
  46. 7
      src/core/0.foundation.js
  47. 3
      src/core/2.base.js
  48. 82
      src/core/6.plugin.js
  49. 15
      src/core/action/action.js
  50. 17
      src/core/action/action.show.js
  51. 2
      src/core/action/index.js
  52. 24
      src/core/behavior/0.behavior.js
  53. 26
      src/core/behavior/behavior.highlight.js
  54. 19
      src/core/behavior/behavior.redmark.js
  55. 27
      src/core/behavior/index.js
  56. 9
      src/core/constant/events.js
  57. 2
      src/core/constant/index.js
  58. 141
      src/core/constant/var.js
  59. 4
      src/core/controller/0.controller.js
  60. 9
      src/core/controller/controller.broadcast.js
  61. 38
      src/core/controller/controller.bubbles.js
  62. 38
      src/core/controller/controller.drawer.js
  63. 55
      src/core/controller/controller.layer.js
  64. 2
      src/core/controller/controller.masker.js
  65. 46
      src/core/controller/controller.popover.js
  66. 21
      src/core/controller/controller.resizer.js
  67. 40
      src/core/controller/controller.tooltips.js
  68. 14
      src/core/decorator.js
  69. 24
      src/core/element/element.js
  70. 26
      src/core/element/index.js
  71. 23
      src/core/element/plugins/attr.js
  72. 26
      src/core/element/plugins/class.js
  73. 22
      src/core/element/plugins/css.js
  74. 9
      src/core/element/plugins/data.js
  75. 7
      src/core/element/plugins/empty.js
  76. 55
      src/core/element/plugins/event.js
  77. 16
      src/core/element/plugins/html.js
  78. 28
      src/core/element/plugins/index.js
  79. 5
      src/core/element/plugins/keywordMark.js
  80. 58
      src/core/element/plugins/renderToHtml.js
  81. 42
      src/core/element/plugins/renderToString.js
  82. 8
      src/core/element/plugins/text.js
  83. 6
      src/core/element/plugins/val.js
  84. 49
      src/core/h.js
  85. 25
      src/core/index.js
  86. 20
      src/core/listener/listener.show.js
  87. 9
      src/core/loader/loader.style.js
  88. 83
      src/core/logic/index.js
  89. 82
      src/core/logic/logic.js
  90. 109
      src/core/logic/logic.layout.js
  91. 120
      src/core/system.js
  92. 49
      src/core/worker.js

12
src/base/1.pane.js

@ -33,7 +33,7 @@ export class Pane extends Widget {
element: this, element: this,
items: [{ items: [{
type: "bi.label", type: "bi.label",
ref: (_ref) => { ref: _ref => {
this._tipText = _ref; this._tipText = _ref;
}, },
cls: "bi-tips", cls: "bi-tips",
@ -54,15 +54,15 @@ export class Pane extends Widget {
// loading的异步情况下由loaded后对面板的populate的时机决定 // loading的异步情况下由loaded后对面板的populate的时机决定
this.setTipVisible(false); this.setTipVisible(false);
if (o.overlap === true) { if (o.overlap === true) {
if (!Layers.has(this.getName() + "-loading")) { if (!Layers.has(`${this.getName()}-loading`)) {
createWidget({ createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
cls: "loading-container", cls: "loading-container",
items: this._getLoadingTipItems(loadingAnimation), items: this._getLoadingTipItems(loadingAnimation),
element: Layers.make(this.getName() + "-loading", this), element: Layers.make(`${this.getName()}-loading`, this),
}); });
} }
Layers.show(this.getName() + "-loading"); Layers.show(`${this.getName()}-loading`);
} else if (isNull(this._loading)) { } else if (isNull(this._loading)) {
loadingAnimation.element.css("zIndex", 1); loadingAnimation.element.css("zIndex", 1);
createWidget({ createWidget({
@ -94,7 +94,7 @@ export class Pane extends Widget {
return [{ return [{
type: "bi.vertical", type: "bi.vertical",
ref: (_ref) => { ref: _ref => {
this._loading = _ref; this._loading = _ref;
}, },
items: loadingTipItems, items: loadingTipItems,
@ -102,7 +102,7 @@ export class Pane extends Widget {
} }
loaded() { loaded() {
Layers.remove(this.getName() + "-loading"); Layers.remove(`${this.getName()}-loading`);
this._loading && this._loading.destroy(); this._loading && this._loading.destroy();
this.options.onLoaded(); this.options.onLoaded();
this.fireEvent(Pane.EVENT_LOADED); this.fireEvent(Pane.EVENT_LOADED);

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

@ -1,5 +1,5 @@
import { Single } from "../0.single" import { Single } from "../0.single";
import { emptyFn, shortcut, extend, isFunction, createWidget, Widget, isObject, Controller } from "../../../core" import { emptyFn, shortcut, extend, isFunction, createWidget, Widget, isObject, Controller } from "../../../core";
/** /**
* guy * guy
@ -10,7 +10,6 @@ import { emptyFn, shortcut, extend, isFunction, createWidget, Widget, isObject,
*/ */
@shortcut() @shortcut()
export class BasicButton extends Single { export class BasicButton extends Single {
static xtype = "bi.basic_button"; static xtype = "bi.basic_button";
static EVENT_CHANGE = "BasicButton.EVENT_CHANGE"; static EVENT_CHANGE = "BasicButton.EVENT_CHANGE";
@ -19,7 +18,7 @@ export class BasicButton extends Single {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { 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: "",
stopEvent: false, stopEvent: false,
@ -35,7 +34,7 @@ export class BasicButton extends Single {
trigger: null, trigger: null,
handler: emptyFn, handler: emptyFn,
bubble: null, bubble: null,
debounce: true debounce: true,
}); });
} }
@ -50,7 +49,7 @@ export class BasicButton extends Single {
this._createShadow(); this._createShadow();
} }
if (opts.level) { if (opts.level) {
this.element.addClass("button-" + opts.level); this.element.addClass(`button-${opts.level}`);
} }
} }
@ -92,7 +91,7 @@ export class BasicButton extends Single {
}], }],
}); });
} }
} };
this.element.mouseup(() => { this.element.mouseup(() => {
if (!this._hover && !o.isShadowShowingOnSelected) { if (!this._hover && !o.isShadowShowingOnSelected) {
@ -100,7 +99,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();
@ -108,7 +107,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();
@ -116,7 +115,7 @@ export class BasicButton extends Single {
} }
} }
}); });
this.element.on("mouseleave." + this.getName(), () => { this.element.on(`mouseleave.${this.getName()}`, () => {
if (this.isEnabled() && !this._hover) { if (this.isEnabled() && !this._hover) {
assertMask(); assertMask();
this.$mask.invisible(); this.$mask.invisible();
@ -139,9 +138,9 @@ 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;
@ -161,7 +160,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: {
@ -171,7 +170,7 @@ export class BasicButton extends Single {
popup: { popup: {
type: "bi.text_bubble_bar_popup_view", type: "bi.text_bubble_bar_popup_view",
text: getBubble(), text: getBubble(),
ref: (_ref) => { ref: _ref => {
popup = _ref; popup = _ref;
}, },
listeners: [{ listeners: [{
@ -187,7 +186,7 @@ export class BasicButton extends Single {
}, },
listeners: [{ listeners: [{
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW,
action: function () { action () {
popup.populate(getBubble()); popup.populate(getBubble());
}, },
}], }],
@ -208,19 +207,21 @@ export class BasicButton extends Single {
return; return;
} }
onClick.apply(this, arguments); onClick.apply(this, arguments);
} };
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 interval;
switch (trigger) { switch (trigger) {
case "mouseup": case "mouseup":
hand.mousedown(function () { hand.mousedown(() => {
mouseDown = true; mouseDown = true;
}); });
hand.mouseup(function (e) { hand.mouseup(e => {
if (mouseDown === true) { if (mouseDown === true) {
clk(e); clk(e);
} }
@ -230,17 +231,16 @@ export class BasicButton extends Single {
break; break;
case "mousedown": case "mousedown":
// let mouseDown = false; // let mouseDown = false;
let selected = false; hand.mousedown(e => {
hand.mousedown((e) => {
// if (e.button === 0) { // if (e.button === 0) {
Widget._renderEngine.createElement(document).bind("mouseup." + this.getName(), (e) => { Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, e => {
// if (e.button === 0) { // if (e.button === 0) {
if (BI.DOM.isExist(this) && !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());
this._trigger(); this._trigger();
} }
mouseDown = false; mouseDown = false;
Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
// } // }
}); });
if (mouseDown === true) { if (mouseDown === true) {
@ -255,14 +255,14 @@ export class BasicButton extends Single {
ev(e); ev(e);
// } // }
}); });
hand.mouseup((e) => { hand.mouseup(e => {
// if (e.button === 0) { // if (e.button === 0) {
if (BI.DOM.isExist(this) && 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;
Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
// } // }
}); });
break; break;
@ -270,13 +270,12 @@ export class BasicButton extends Single {
hand.dblclick(clk); hand.dblclick(clk);
break; break;
case "lclick": case "lclick":
let interval; hand.mousedown(e => {
hand.mousedown((e) => { Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, () => {
Widget._renderEngine.createElement(document).bind("mouseup." + this.getName(), () => {
interval && clearInterval(interval); interval && clearInterval(interval);
interval = null; interval = null;
mouseDown = false; mouseDown = false;
Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
}); });
if (mouseDown === true) { if (mouseDown === true) {
return; return;
@ -287,8 +286,8 @@ export class BasicButton extends Single {
if (this.isOnce() && this.isSelected()) { if (this.isOnce() && this.isSelected()) {
return; return;
} }
interval = setInterval(function () { interval = setInterval(() => {
clk(e) clk(e);
}, 180); }, 180);
mouseDown = true; mouseDown = true;
ev(e); ev(e);
@ -296,13 +295,13 @@ export class BasicButton extends Single {
break; break;
default: default:
if (o.stopEvent || o.stopPropagation) { if (o.stopEvent || o.stopPropagation) {
hand.mousedown(function (e) { hand.mousedown(e => {
ev(e); ev(e);
}); });
} }
hand.click(clk); hand.click(clk);
// enter键等同于点击 // enter键等同于点击
o.attributes && o.attributes.zIndex >= 0 && hand.keyup(function (e) { o.attributes && o.attributes.zIndex >= 0 && hand.keyup(e => {
if (e.keyCode === BI.KeyCode.ENTER) { if (e.keyCode === BI.KeyCode.ENTER) {
clk(e); clk(e);
} }
@ -312,9 +311,9 @@ export class BasicButton extends Single {
}); });
// 之后的300ms点击无效 // 之后的300ms点击无效
let onClick = o.debounce ? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { const onClick = o.debounce ? 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) {
@ -325,10 +324,6 @@ export class BasicButton extends Single {
e.stopPropagation(); e.stopPropagation();
} }
} }
} }
_trigger(e) { _trigger(e) {
@ -458,7 +453,7 @@ export class BasicButton extends Single {
} }
empty() { empty() {
Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
super.empty.apply(this, arguments); super.empty.apply(this, arguments);
} }
} }

7
src/base/single/button/button.node.js

@ -1,5 +1,5 @@
import { BasicButton } from "./button.basic" import { BasicButton } from "./button.basic";
import { shortcut, extend, Controller } from "../../../core" import { shortcut, extend, Controller } from "../../../core";
/** /**
* 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 * 表示一个可以展开的节点, 不仅有选中状态而且有展开状态
@ -11,14 +11,13 @@ import { shortcut, extend, Controller } from "../../../core"
*/ */
@shortcut() @shortcut()
export class NodeButton extends BasicButton { export class NodeButton extends BasicButton {
static xtype = "bi.node_button"; static xtype = "bi.node_button";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-node", _baseCls: `${conf._baseCls || ""} bi-node`,
open: false, open: false,
once: false, once: false,
}); });

3
src/base/single/button/buttons/button.image.js

@ -11,7 +11,6 @@ import { shortcut, extend, isNumber, createWidget } from "../../../../core";
*/ */
@shortcut() @shortcut()
export class ImageButton extends BasicButton { export class ImageButton extends BasicButton {
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.image_button"; static xtype = "bi.image_button";
@ -19,7 +18,7 @@ export class ImageButton extends BasicButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-image-button", baseCls: `${conf.baseCls || ""} bi-image-button`,
src: "", src: "",
iconWidth: "100%", iconWidth: "100%",
iconHeight: "100%", iconHeight: "100%",

25
src/base/single/button/buttons/button.js

@ -17,7 +17,6 @@ const loadingCls = "button-loading-font anim-rotate";
*/ */
@shortcut() @shortcut()
export class Button extends BasicButton { export class Button extends BasicButton {
_const = { _const = {
iconWidth: 18, iconWidth: 18,
} }
@ -33,16 +32,16 @@ export class Button extends BasicButton {
// 图标高度和文字高度默认相等 // 图标高度和文字高度默认相等
adaptiveHeight += (props.textHeight || 16) * 2; adaptiveHeight += (props.textHeight || 16) * 2;
adaptiveHeight += props.iconGap || 0; adaptiveHeight += props.iconGap || 0;
let tGap = props.tgap || props.vgap || 2; const tGap = props.tgap || props.vgap || 2;
let bGap = props.bgap || props.vgap || 2; const bGap = props.bgap || props.vgap || 2;
adaptiveHeight += (tGap + bGap); adaptiveHeight += (tGap + bGap);
} }
let clearMinWidth = props.block === true || props.clear === true || props.plain; const clearMinWidth = props.block === true || props.clear === true || props.plain;
return { return {
...conf, ...conf,
baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""), baseCls: `${conf.baseCls || ""} bi-button${(BI.isIE() && BI.isIE9Below()) ? " hack" : ""}`,
attributes: { attributes: {
tabIndex: 1, tabIndex: 1,
}, },
@ -72,7 +71,7 @@ export class Button extends BasicButton {
icon: "", icon: "",
iconGap: 0, iconGap: 0,
iconPosition: "left", iconPosition: "left",
} };
} }
render() { render() {
@ -83,7 +82,7 @@ export class Button extends BasicButton {
type: "bi.center_adapt", type: "bi.center_adapt",
horizontalAlign: o.textAlign, horizontalAlign: o.textAlign,
element: this, element: this,
ref: (ref) => { ref: ref => {
this.containerRef = ref; this.containerRef = ref;
}, },
hgap: o.hgap, hgap: o.hgap,
@ -97,7 +96,7 @@ export class Button extends BasicButton {
if (BI.get(o, clz) === true) { if (BI.get(o, clz) === true) {
this.element.addClass(clz); this.element.addClass(clz);
} }
}) });
if (o.minWidth > 0) { if (o.minWidth > 0) {
this.element.css({ "min-width": BI.pixFormat(o.minWidth) }); this.element.css({ "min-width": BI.pixFormat(o.minWidth) });
@ -139,7 +138,7 @@ export class Button extends BasicButton {
text: o.text, text: o.text,
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
textAlign: o.textAlign, textAlign: o.textAlign,
textWidth: textWidth, textWidth,
textHeight: BI.toPix(textHeight, hasBorder ? 2 : 0), textHeight: BI.toPix(textHeight, hasBorder ? 2 : 0),
height: BI.toPix(lineHeight, hasBorder ? 2 : 0), height: BI.toPix(lineHeight, hasBorder ? 2 : 0),
value: o.value, value: o.value,
@ -258,19 +257,19 @@ export class Button extends BasicButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
doHighLight() { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
} }
unHighLight() { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
} }
} }

11
src/base/single/button/buttons/button.text.js

@ -10,7 +10,6 @@ import { shortcut, extend, createWidget } from "../../../../core";
*/ */
@shortcut() @shortcut()
export class TextButton extends BasicButton { export class TextButton extends BasicButton {
static xtype = "bi.text_button"; static xtype = "bi.text_button";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -18,7 +17,7 @@ export class TextButton extends BasicButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-button", baseCls: `${conf.baseCls || ""} bi-text-button`,
textAlign: "center", textAlign: "center",
whiteSpace: "nowrap", whiteSpace: "nowrap",
textWidth: null, textWidth: null,
@ -61,19 +60,19 @@ export class TextButton extends BasicButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
doHighLight() { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
} }
unHighLight() { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
} }
setText(text) { setText(text) {

23
src/base/single/button/listitem/blankiconicontextitem.js

@ -1,5 +1,5 @@
import { BasicButton } from "../button.basic" import { BasicButton } from "../button.basic";
import { emptyFn, shortcut } from "../../../../core" import { shortcut } from "../../../../core";
/** /**
* 带有一个占位 * 带有一个占位
@ -10,15 +10,14 @@ import { emptyFn, shortcut } from "../../../../core"
*/ */
@shortcut() @shortcut()
export class BlankIconIconTextItem extends BasicButton { export class BlankIconIconTextItem extends BasicButton {
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.blank_icon_icon_text_item"; static xtype = "bi.blank_icon_icon_text_item";
_defaultConfig() { _defaultConfig() {
var conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-blank-icon-icon-text-item", baseCls: `${conf.baseCls || ""} bi-blank-icon-icon-text-item`,
iconCls1: "", iconCls1: "",
iconCls2: "", iconCls2: "",
blankWidth: 0, blankWidth: 0,
@ -57,7 +56,7 @@ export class BlankIconIconTextItem extends BasicButton {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
@ -89,7 +88,7 @@ export class BlankIconIconTextItem extends BasicButton {
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -98,7 +97,7 @@ export class BlankIconIconTextItem extends BasicButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {
@ -106,18 +105,18 @@ export class BlankIconIconTextItem extends BasicButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
doHighLight() { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
} }
unHighLight() { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
} }
} }

21
src/base/single/button/listitem/blankicontexticonitem.js

@ -1,5 +1,5 @@
import { BasicButton } from "../button.basic" import { BasicButton } from "../button.basic";
import { emptyFn, shortcut, extend } from "../../../../core" import { shortcut, extend } from "../../../../core";
/** /**
* guy * guy
@ -11,7 +11,6 @@ import { emptyFn, shortcut, extend } from "../../../../core"
*/ */
@shortcut() @shortcut()
export class BlankIconTextIconItem extends BasicButton { export class BlankIconTextIconItem extends BasicButton {
static xtype = "bi.blank_icon_text_icon_item"; static xtype = "bi.blank_icon_text_icon_item";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -19,7 +18,7 @@ export class BlankIconTextIconItem extends BasicButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-blank-icon-text-icon-item", baseCls: `${conf.baseCls || ""} bi-blank-icon-text-icon-item`,
iconCls1: "", iconCls1: "",
iconCls2: "", iconCls2: "",
blankWidth: 0, blankWidth: 0,
@ -51,7 +50,7 @@ export class BlankIconTextIconItem extends BasicButton {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
@ -83,24 +82,24 @@ export class BlankIconTextIconItem extends BasicButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
doHighLight() { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
} }
unHighLight() { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
} }
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -109,7 +108,7 @@ export class BlankIconTextIconItem extends BasicButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {

21
src/base/single/button/listitem/blankicontextitem.js

@ -1,5 +1,5 @@
import { BasicButton } from "../button.basic" import { BasicButton } from "../button.basic";
import { extend, shortcut } from "../../../../core" import { extend, shortcut } from "../../../../core";
/** /**
* 带有一个占位 * 带有一个占位
@ -10,7 +10,6 @@ import { extend, shortcut } from "../../../../core"
*/ */
@shortcut() @shortcut()
export class BlankIconTextItem extends BasicButton { export class BlankIconTextItem extends BasicButton {
static xtype = "bi.blank_icon_text_item"; static xtype = "bi.blank_icon_text_item";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -18,7 +17,7 @@ export class BlankIconTextItem extends BasicButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item", baseCls: `${conf.baseCls || ""} bi-blank-icon-text-item`,
blankWidth: 0, blankWidth: 0,
iconHeight: null, iconHeight: null,
iconWidth: null, iconWidth: null,
@ -49,7 +48,7 @@ export class BlankIconTextItem extends BasicButton {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
@ -76,7 +75,7 @@ export class BlankIconTextItem extends BasicButton {
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -85,7 +84,7 @@ export class BlankIconTextItem extends BasicButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {
@ -93,18 +92,18 @@ export class BlankIconTextItem extends BasicButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
doHighLight() { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
} }
unHighLight() { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
} }
} }

21
src/base/single/button/listitem/icontexticonitem.js

@ -1,5 +1,5 @@
import { BasicButton } from "../button.basic" import { BasicButton } from "../button.basic";
import { extend, shortcut } from "../../../../core" import { extend, shortcut } from "../../../../core";
/** /**
* guy * guy
@ -12,7 +12,6 @@ import { extend, shortcut } from "../../../../core"
@shortcut() @shortcut()
export class IconTextIconItem extends BasicButton { export class IconTextIconItem extends BasicButton {
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.icon_text_icon_item"; static xtype = "bi.icon_text_icon_item";
@ -20,7 +19,7 @@ export class IconTextIconItem extends BasicButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-icon-item", baseCls: `${conf.baseCls || ""} bi-icon-text-icon-item`,
iconCls1: "", iconCls1: "",
iconCls2: "", iconCls2: "",
iconHeight: null, iconHeight: null,
@ -48,7 +47,7 @@ export class IconTextIconItem extends BasicButton {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
@ -80,24 +79,24 @@ export class IconTextIconItem extends BasicButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
doHighLight() { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
} }
unHighLight() { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
} }
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -106,7 +105,7 @@ export class IconTextIconItem extends BasicButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {

21
src/base/single/button/listitem/icontextitem.js

@ -1,5 +1,5 @@
import { BasicButton } from "../button.basic" import { BasicButton } from "../button.basic";
import { extend, shortcut } from "../../../../core" import { extend, shortcut } from "../../../../core";
/** /**
* guy * guy
@ -10,7 +10,6 @@ import { extend, shortcut } from "../../../../core"
*/ */
@shortcut() @shortcut()
export class IconTextItem extends BasicButton { export class IconTextItem extends BasicButton {
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.icon_text_item"; static xtype = "bi.icon_text_item";
@ -18,7 +17,7 @@ export class IconTextItem extends BasicButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-item", baseCls: `${conf.baseCls || ""} bi-icon-text-item`,
direction: BI.Direction.Left, direction: BI.Direction.Left,
iconWrapperWidth: null, iconWrapperWidth: null,
iconHeight: null, iconHeight: null,
@ -47,7 +46,7 @@ export class IconTextItem extends BasicButton {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
@ -74,7 +73,7 @@ export class IconTextItem extends BasicButton {
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -83,7 +82,7 @@ export class IconTextItem extends BasicButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {
@ -91,18 +90,18 @@ export class IconTextItem extends BasicButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
doHighLight() { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
} }
unHighLight() { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
} }
} }

21
src/base/single/button/listitem/texticonitem.js

@ -1,5 +1,5 @@
import { BasicButton } from "../button.basic" import { BasicButton } from "../button.basic";
import { extend, shortcut } from "../../../../core" import { extend, shortcut } from "../../../../core";
/** /**
* *
@ -11,7 +11,6 @@ import { extend, shortcut } from "../../../../core"
*/ */
@shortcut() @shortcut()
export class TextIconItem extends BasicButton { export class TextIconItem extends BasicButton {
static xtype = "bi.text_icon_item"; static xtype = "bi.text_icon_item";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE"
@ -19,7 +18,7 @@ export class TextIconItem extends BasicButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-icon-item", baseCls: `${conf.baseCls || ""} bi-text-icon-item`,
iconWrapperWidth: null, iconWrapperWidth: null,
iconHeight: null, iconHeight: null,
iconWidth: null, iconWidth: null,
@ -40,7 +39,7 @@ export class TextIconItem extends BasicButton {
items: [{ items: [{
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref (_ref) {
self.text = _ref; self.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
@ -74,7 +73,7 @@ export class TextIconItem extends BasicButton {
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -83,7 +82,7 @@ export class TextIconItem extends BasicButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {
@ -91,18 +90,18 @@ export class TextIconItem extends BasicButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
doHighLight() { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
} }
unHighLight() { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
} }
} }

19
src/base/single/button/listitem/textitem.js

@ -1,5 +1,5 @@
import { BasicButton } from "../button.basic" import { BasicButton } from "../button.basic";
import { extend, shortcut } from "../../../../core" import { extend, shortcut } from "../../../../core";
/** /**
* guy * guy
@ -11,7 +11,6 @@ import { extend, shortcut } from "../../../../core"
*/ */
@shortcut @shortcut
export class TextItem extends BasicButton { export class TextItem extends BasicButton {
static xtype = "bi.text_item"; static xtype = "bi.text_item";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -19,7 +18,7 @@ export class TextItem extends BasicButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-item", baseCls: `${conf.baseCls || ""} bi-text-item`,
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
textHgap: 0, textHgap: 0,
@ -57,24 +56,24 @@ export class TextItem extends BasicButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
doHighLight() { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
} }
unHighLight() { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
} }
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -83,7 +82,7 @@ export class TextItem extends BasicButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {

17
src/base/single/button/node/icontexticonnode.js

@ -1,5 +1,5 @@
import { NodeButton } from "../button.node" import { NodeButton } from "../button.node";
import { extend, shortcut } from "../../../../core" import { extend, shortcut } from "../../../../core";
/** /**
* guy * guy
@ -9,7 +9,6 @@ import { extend, shortcut } from "../../../../core"
*/ */
@shortcut() @shortcut()
export class IconTextIconNode extends NodeButton { export class IconTextIconNode extends NodeButton {
static xtype = "bi.icon_text_icon_node"; static xtype = "bi.icon_text_icon_node";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -17,7 +16,7 @@ export class IconTextIconNode extends NodeButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node", baseCls: `${conf.baseCls || ""} bi-icon-text-icon-node`,
iconCls1: "close-ha-font", iconCls1: "close-ha-font",
iconCls2: "close-ha-font", iconCls2: "close-ha-font",
iconHeight: null, iconHeight: null,
@ -45,7 +44,7 @@ export class IconTextIconNode extends NodeButton {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
@ -77,16 +76,16 @@ export class IconTextIconNode extends NodeButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -95,7 +94,7 @@ export class IconTextIconNode extends NodeButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {

17
src/base/single/button/node/icontextnode.js

@ -1,5 +1,5 @@
import { NodeButton } from "../button.node" import { NodeButton } from "../button.node";
import { extend, shortcut } from "../../../../core" import { extend, shortcut } from "../../../../core";
/** /**
* guy * guy
@ -9,7 +9,6 @@ import { extend, shortcut } from "../../../../core"
*/ */
@shortcut() @shortcut()
export class IconTextNode extends NodeButton { export class IconTextNode extends NodeButton {
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.icon_text_node"; static xtype = "bi.icon_text_node";
@ -17,7 +16,7 @@ export class IconTextNode extends NodeButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-node", baseCls: `${conf.baseCls || ""} bi-icon-text-node`,
cls: "close-ha-font", cls: "close-ha-font",
iconHeight: null, iconHeight: null,
iconWidth: null, iconWidth: null,
@ -44,7 +43,7 @@ export class IconTextNode extends NodeButton {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
@ -71,7 +70,7 @@ export class IconTextNode extends NodeButton {
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -80,7 +79,7 @@ export class IconTextNode extends NodeButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {
@ -88,11 +87,11 @@ export class IconTextNode extends NodeButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
} }

17
src/base/single/button/node/texticonnode.js

@ -1,5 +1,5 @@
import { NodeButton } from "../button.node" import { NodeButton } from "../button.node";
import { extend, shortcut } from "../../../../core" import { extend, shortcut } from "../../../../core";
/** /**
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
@ -8,7 +8,6 @@ import { extend, shortcut } from "../../../../core"
*/ */
@shortcut() @shortcut()
export default class TextIconNode extends NodeButton { export default class TextIconNode extends NodeButton {
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.text_icon_node"; static xtype = "bi.text_icon_node";
@ -16,7 +15,7 @@ export default class TextIconNode extends NodeButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-icon-node", baseCls: `${conf.baseCls || ""} bi-text-icon-node`,
cls: "close-ha-font", cls: "close-ha-font",
iconHeight: null, iconHeight: null,
iconWidth: null, iconWidth: null,
@ -36,7 +35,7 @@ export default class TextIconNode extends NodeButton {
items: [{ items: [{
el: { el: {
type: "bi.label", type: "bi.label",
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
@ -70,7 +69,7 @@ export default class TextIconNode extends NodeButton {
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -79,7 +78,7 @@ export default class TextIconNode extends NodeButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {
@ -87,10 +86,10 @@ export default class TextIconNode extends NodeButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
} }

15
src/base/single/button/node/textnode.js

@ -1,5 +1,5 @@
import { NodeButton } from "../button.node" import { NodeButton } from "../button.node";
import { extend, shortcut } from "../../../../core" import { extend, shortcut } from "../../../../core";
/** /**
* guy * guy
@ -10,7 +10,6 @@ import { extend, shortcut } from "../../../../core"
*/ */
@shortcut() @shortcut()
export class TextNode extends NodeButton { export class TextNode extends NodeButton {
static xtype = "bi.text_node" static xtype = "bi.text_node"
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE"
@ -20,7 +19,7 @@ export class TextNode extends NodeButton {
const conf = super._defaultConfig(arguments); const conf = super._defaultConfig(arguments);
return extend(conf, { return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-node", baseCls: `${conf.baseCls || ""} bi-text-node`,
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
textHgap: 0, textHgap: 0,
@ -58,16 +57,16 @@ export class TextNode extends NodeButton {
} }
doRedMark() { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
} }
unRedMark() { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
setValue() { setValue() {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue(...arguments);
} }
} }
@ -76,7 +75,7 @@ export class TextNode extends NodeButton {
} }
setText() { setText() {
this.text.setText.apply(this.text, arguments); this.text.setText(...arguments);
} }
getText() { getText() {

66
src/case/button/icon/icon.change.js

@ -1,15 +1,25 @@
import { Single } from "../../../base/single/0.single";
import { IconButton } from "../../../base/single/button/buttons/button.icon";
import { shortcut, extend, emptyFn, isFunction, createWidget, Controller } from "../../../core";
/** /**
* 可以改变图标的button * 可以改变图标的button
* *
* Created by GUY on 2016/2/2. * Created by GUY on 2016/2/2.
* *
* @class BI.IconChangeButton * @class IconChangeButton
* @extends BI.Single * @extends Single
*/ */
BI.IconChangeButton = BI.inherit(BI.Single, { @shortcut()
_defaultConfig: function () { export class IconChangeButton extends Single {
var conf = BI.IconChangeButton.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.icon_change_button";
return BI.extend(conf, { static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: "bi-icon-change-button", baseCls: "bi-icon-change-button",
iconCls: "", iconCls: "",
iconWidth: null, iconWidth: null,
@ -26,17 +36,17 @@ BI.IconChangeButton = BI.inherit(BI.Single, {
shadow: false, shadow: false,
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
trigger: null, trigger: null,
handler: BI.emptyFn handler: emptyFn,
}); });
}, }
_init: function () { _init() {
var self = this, o = this.options; const o = this.options;
o.iconCls = BI.isFunction(o.iconCls) ? this.__watch(o.iconCls, function (context, newValue) { o.iconCls = isFunction(o.iconCls) ? this.__watch(o.iconCls, (context, newValue) => {
self.setIcon(newValue); this.setIcon(newValue);
}) : o.iconCls; }) : o.iconCls;
BI.IconChangeButton.superclass._init.apply(this, arguments); super._init.apply(this, arguments);
this.button = BI.createWidget({ this.button = createWidget({
type: "bi.icon_button", type: "bi.icon_button",
element: this, element: this,
cls: o.iconCls, cls: o.iconCls,
@ -55,32 +65,30 @@ BI.IconChangeButton = BI.inherit(BI.Single, {
shadow: o.shadow, shadow: o.shadow,
isShadowShowingOnSelected: o.isShadowShowingOnSelected, isShadowShowingOnSelected: o.isShadowShowingOnSelected,
trigger: o.trigger, trigger: o.trigger,
handler: o.handler handler: o.handler,
}); });
this.button.on(BI.Controller.EVENT_CHANGE, function () { this.button.on(Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, args);
}); });
this.button.on(BI.IconButton.EVENT_CHANGE, function () { this.button.on(IconButton.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.IconChangeButton.EVENT_CHANGE, arguments); this.fireEvent(IconChangeButton.EVENT_CHANGE, args);
}); });
}, }
isSelected: function () { isSelected() {
return this.button.isSelected(); return this.button.isSelected();
}, }
setSelected: function (b) { setSelected(b) {
this.button.setSelected(b); this.button.setSelected(b);
}, }
setIcon: function (cls) { setIcon(cls) {
var o = this.options; const o = this.options;
if (o.iconCls !== cls) { if (o.iconCls !== cls) {
this.element.removeClass(o.iconCls).addClass(cls); this.element.removeClass(o.iconCls).addClass(cls);
o.iconCls = cls; o.iconCls = cls;
} }
} }
}); }
BI.IconChangeButton.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_change_button", BI.IconChangeButton);

27
src/case/button/icon/icon.trigger.js

@ -1,19 +1,24 @@
import { IconButton } from "../../../base/single/button/buttons/button.icon";
import { shortcut, extend } from "../../../core";
/** /**
* 统一的trigger图标按钮 * 统一的trigger图标按钮
* *
* Created by GUY on 2015/9/16. * Created by GUY on 2015/9/16.
* @class BI.TriggerIconButton * @class TriggerIconButton
* @extends BI.IconButton * @extends IconButton
*/ */
BI.TriggerIconButton = BI.inherit(BI.IconButton, { @shortcut()
export class TriggerIconButton extends IconButton {
static xtype = "bi.trigger_icon_button";
EVENT_CHANGE = IconButton.EVENT_CHANGE;
_defaultConfig() {
const conf = super._defaultConfig(arguments);
_defaultConfig: function () { return extend(conf, {
var conf = BI.TriggerIconButton.superclass._defaultConfig.apply(this, arguments); baseCls: `${conf.baseCls || ""} bi-trigger-icon-button overflow-hidden`,
return BI.extend(conf, { extraCls: "pull-down-font",
baseCls: (conf.baseCls || "") + " bi-trigger-icon-button overflow-hidden",
extraCls: "pull-down-font"
}); });
} }
}); }
BI.TriggerIconButton.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE;
BI.shortcut("bi.trigger_icon_button", BI.TriggerIconButton);

23
src/case/button/icon/iconhalf/icon.half.image.js

@ -1,21 +1,28 @@
import { IconButton } from "../../../../base/single/button/buttons/button.icon";
import { shortcut, extend } from "../../../../core";
/** /**
* guy * guy
* @extends BI.Single * @extends BI.Single
* @type {*|void|Object} * @type {*|void|Object}
*/ */
BI.HalfIconButton = BI.inherit(BI.IconButton, { @shortcut()
_defaultConfig: function () { export class HalfIconButton extends IconButton {
var conf = BI.HalfIconButton.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.half_icon_button";
return BI.extend(conf, { static EVENT_CHANGE = IconButton.EVENT_CHANGE
_defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
extraCls: "bi-half-icon-button check-half-select-icon", extraCls: "bi-half-icon-button check-half-select-icon",
height: 16, height: 16,
width: 16, width: 16,
iconWidth: 16, iconWidth: 16,
iconHeight: 16, iconHeight: 16,
selected: false selected: false,
}); });
} }
}); }
BI.HalfIconButton.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE;
BI.shortcut("bi.half_icon_button", BI.HalfIconButton);

36
src/case/button/icon/iconhalf/icon.half.js

@ -1,22 +1,31 @@
import { BasicButton } from "../../../../base/single/button/button.basic";
import { shortcut, extend } from "../../../../core";
/** /**
* guy * guy
* @extends BI.Single * @extends BI.Single
* @type {*|void|Object} * @type {*|void|Object}
*/ */
BI.HalfButton = BI.inherit(BI.BasicButton, { @shortcut()
_defaultConfig: function () { export class HalfButton extends BasicButton {
var conf = BI.HalfIconButton.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.half_button";
return BI.extend(conf, { static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
selected: false, selected: false,
width: 14, width: 14,
height: 14, height: 14,
iconWidth: 14, iconWidth: 14,
iconHeight: 14, iconHeight: 14,
}); });
}, }
render() {
const o = this.options;
render: function () {
var o = this.options;
return { return {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [{ items: [{
@ -26,15 +35,12 @@ BI.HalfButton = BI.inherit(BI.BasicButton, {
height: o.iconHeight, height: o.iconHeight,
}], }],
}; };
}, }
doClick: function () { doClick() {
BI.HalfButton.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.HalfButton.EVENT_CHANGE); this.fireEvent(HalfButton.EVENT_CHANGE);
} }
} }
}); }
BI.HalfButton.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.half_button", BI.HalfButton);

29
src/case/button/index.js

@ -0,0 +1,29 @@
export { MultiSelectItem } from "./item.multiselect";
export { SingleSelectIconTextItem } from "./item.singleselect.icontext";
export { SingleSelectItem } from "./item.singleselect";
export { SingleSelectRadioItem } from "./item.singleselect.radio";
export { Switch } from "./switch";
export { IconChangeButton } from "./icon/icon.change";
export { TriggerIconButton } from "./icon/icon.trigger";
export { HalfIconButton } from "./icon/iconhalf/icon.half.image";
export { HalfButton } from "./icon/iconhalf/icon.half";
export { ArrowNode } from "./node/node.arrow";
export { FirstPlusGroupNode } from "./node/node.first.plus";
export { IconArrowNode } from "./node/node.icon.arrow";
export { LastPlusGroupNode } from "./node/node.last.plus";
export { MidPlusGroupNode } from "./node/node.mid.plus";
export { MultiLayerIconArrowNode } from "./node/node.multilayer.icon.arrow";
export { PlusGroupNode } from "./node/node.plus";
export { TreeNodeSwitcher } from "./node/siwtcher.tree.node";
export { BasicTreeNode } from "./node/treenode";
export { FirstTreeLeafItem } from "./treeitem/item.first.treeleaf";
export { IconTreeLeafItem } from "./treeitem/item.icon.treeleaf";
export { LastTreeLeafItem } from "./treeitem/item.last.treeleaf";
export { MidTreeLeafItem } from "./treeitem/item.mid.treeleaf";
export { MultiLayerIconTreeLeafItem } from "./treeitem/item.multilayer.icon.treeleaf";
export { RootTreeLeafItem } from "./treeitem/item.root.treeleaf";
export { TreeTextLeafItem } from "./treeitem/item.treetextleaf";
export { BasicTreeItem } from "./treeitem/treeitem";

64
src/case/button/item.multiselect.js

@ -1,36 +1,45 @@
import { BasicButton } from "../../base/single/button/button.basic";
import { shortcut, extend, createWidget } from "../../core";
/** /**
* guy * guy
* 复选框item * 复选框item
* @type {*|void|Object} * @type {*|void|Object}
*/ */
BI.MultiSelectItem = BI.inherit(BI.BasicButton, { @shortcut()
_defaultConfig: function () { export class MultiSelectItem extends BasicButton {
return BI.extend(BI.MultiSelectItem.superclass._defaultConfig.apply(this, arguments), { static xtype = "bi.multi_select_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
extraCls: "bi-multi-select-item", extraCls: "bi-multi-select-item",
attributes: { attributes: {
tabIndex: 1 tabIndex: 1,
}, },
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 26, iconWrapperWidth: 26,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
this.checkbox = BI.createWidget({ this.checkbox = createWidget({
type: "bi.checkbox" type: "bi.checkbox",
}); });
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
columnSize: [o.iconWrapperWidth || o.height, "fill"], columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [{ items: [{
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.checkbox] items: [this.checkbox],
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: _ref => {
self.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
textAlign: "left", textAlign: "left",
@ -44,11 +53,11 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
keyword: o.keyword, keyword: o.keyword,
value: o.value, value: o.value,
py: o.py py: o.py,
}
}]
};
}, },
}],
};
}
// _setEnable: function (enable) { // _setEnable: function (enable) {
// BI.MultiSelectItem.superclass._setEnable.apply(this, arguments); // BI.MultiSelectItem.superclass._setEnable.apply(this, arguments);
@ -59,25 +68,24 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
// } // }
// }, // },
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
BI.MultiSelectItem.superclass.doClick.apply(this, arguments); BI.MultiSelectItem.superclass.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.MultiSelectItem.EVENT_CHANGE, this.getValue(), this); this.fireEvent(BI.MultiSelectItem.EVENT_CHANGE, this.getValue(), this);
} }
}, }
setSelected: function (v) { setSelected(v) {
BI.MultiSelectItem.superclass.setSelected.apply(this, arguments); BI.MultiSelectItem.superclass.setSelected.apply(this, arguments);
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
} }
}); }
BI.MultiSelectItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multi_select_item", BI.MultiSelectItem);

60
src/case/button/item.singleselect.icontext.js

@ -1,24 +1,30 @@
import { Single } from "../../base/single/0.single";
import { shortcut, extend, createWidget, Controller } from "../../core";
/** /**
* Created by GUY on 2016/2/2. * Created by GUY on 2016/2/2.
* *
* @class BI.SingleSelectIconTextItem * @class BI.SingleSelectIconTextItem
* @extends BI.BasicButton * @extends BI.BasicButton
*/ */
BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { @shortcut()
_defaultConfig: function () { export class SingleSelectIconTextItem extends Single {
return BI.extend(BI.SingleSelectIconTextItem.superclass._defaultConfig.apply(this, arguments), { static xtype = "bi.single_select_icon_text_item";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
extraCls: "bi-single-select-icon-text-item bi-list-item-active", extraCls: "bi-single-select-icon-text-item bi-list-item-active",
attributes: { attributes: {
tabIndex: 1 tabIndex: 1,
}, },
iconCls: "", iconCls: "",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
this.text = BI.createWidget({ this.text = createWidget({
type: "bi.icon_text_item", type: "bi.icon_text_item",
element: this, element: this,
cls: o.iconCls, cls: o.iconCls,
@ -35,37 +41,37 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, {
text: o.text, text: o.text,
keyword: o.keyword, keyword: o.keyword,
value: o.value, value: o.value,
py: o.py py: o.py,
}); });
this.text.on(BI.Controller.EVENT_CHANGE, function () { this.text.on(Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(Controller.EVENT_CHANGE, arguments);
}); });
}, }
_setEnable: function (enable) { _setEnable(enable) {
BI.SingleSelectIconTextItem.superclass._setEnable.apply(this, arguments); super._setEnable.apply(this, arguments);
if (enable === true) { if (enable === true) {
this.element.attr("tabIndex", 1); this.element.attr("tabIndex", 1);
} else if (enable === false) { } else if (enable === false) {
this.element.removeAttr("tabIndex"); this.element.removeAttr("tabIndex");
} }
}, }
isSelected: function () { isSelected() {
return this.text.isSelected(); return this.text.isSelected();
}, }
setSelected: function (b) { setSelected(b) {
this.text.setSelected(b); this.text.setSelected(b);
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
} }
}); }
BI.shortcut("bi.single_select_icon_text_item", BI.SingleSelectIconTextItem);

65
src/case/button/item.singleselect.js

@ -1,19 +1,26 @@
BI.SingleSelectItem = BI.inherit(BI.BasicButton, { import { BasicButton } from "../../base/single/button/button.basic";
_defaultConfig: function () { import { shortcut, extend, createWidget } from "../../core";
return BI.extend(BI.SingleSelectItem.superclass._defaultConfig.apply(this, arguments), {
@shortcut()
export class SingleSelectItem extends BasicButton {
static xtype = "bi.single_select_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
extraCls: "bi-single-select-item bi-list-item-active", extraCls: "bi-single-select-item bi-list-item-active",
attributes: { attributes: {
tabIndex: 1 tabIndex: 1,
}, },
textHgap: 10, textHgap: 10,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
textAlign: "left" textAlign: "left",
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
this.text = BI.createWidget({ this.text = createWidget({
type: "bi.label", type: "bi.label",
element: this, element: this,
textAlign: o.textAlign, textAlign: o.textAlign,
@ -27,38 +34,38 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
keyword: o.keyword, keyword: o.keyword,
value: o.value, value: o.value,
py: o.py py: o.py,
}); });
}, }
_setEnable: function (enable) { _setEnable(enable) {
BI.SingleSelectItem.superclass._setEnable.apply(this, arguments); super._setEnable.apply(this, arguments);
if (enable === true) { if (enable === true) {
this.element.attr("tabIndex", 1); this.element.attr("tabIndex", 1);
} else if (enable === false) { } else if (enable === false) {
this.element.removeAttr("tabIndex"); this.element.removeAttr("tabIndex");
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
BI.SingleSelectItem.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.SingleSelectItem.EVENT_CHANGE, this.isSelected(), this); this.fireEvent(SingleSelectItem.EVENT_CHANGE, this.isSelected(), this);
}
} }
},
setSelected: function (v) { setSelected(v) {
BI.SingleSelectItem.superclass.setSelected.apply(this, arguments); super.setSelected.apply(this, arguments);
} }
}); }
BI.SingleSelectItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.single_select_item", BI.SingleSelectItem);

69
src/case/button/item.singleselect.radio.js

@ -1,23 +1,31 @@
import { BasicButton } from "../../base/single/button/button.basic";
import { shortcut, extend } from "../../core";
/** /**
* guy * guy
* 单选框item * 单选框item
* @type {*|void|Object} * @type {*|void|Object}
*/ */
BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { @shortcut()
_defaultConfig: function () { export class SingleSelectRadioItem extends BasicButton {
return BI.extend(BI.SingleSelectRadioItem.superclass._defaultConfig.apply(this, arguments), { static xtype = "bi.single_select_radio_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
extraCls: "bi-single-select-radio-item", extraCls: "bi-single-select-radio-item",
attributes: { attributes: {
tabIndex: 1 tabIndex: 1,
}, },
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 16, iconWrapperWidth: 16,
textHgap: 10, textHgap: 10,
}); });
}, }
render() {
const o = this.options;
render: function () {
var self = this, o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
columnSize: [o.iconWrapperWidth || o.height, "fill"], columnSize: [o.iconWrapperWidth || o.height, "fill"],
@ -25,15 +33,15 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [{ items: [{
type: "bi.radio", type: "bi.radio",
ref: function (_ref) { ref: _ref => {
self.radio = _ref; this.radio = _ref;
}, },
}] }],
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: _ref => {
self.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
textAlign: "left", textAlign: "left",
@ -47,42 +55,39 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
keyword: o.keyword, keyword: o.keyword,
value: o.value, value: o.value,
py: o.py py: o.py,
}
}]
};
}, },
}],
};
}
_setEnable: function (enable) { _setEnable(enable) {
BI.SingleSelectRadioItem.superclass._setEnable.apply(this, arguments); super._setEnable.apply(this, arguments);
if (enable === true) { if (enable === true) {
this.element.attr("tabIndex", 1); this.element.attr("tabIndex", 1);
} else if (enable === false) { } else if (enable === false) {
this.element.removeAttr("tabIndex"); this.element.removeAttr("tabIndex");
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
BI.SingleSelectRadioItem.superclass.doClick.apply(this, arguments); BI.SingleSelectRadioItem.superclass.doClick.apply(this, arguments);
if (this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.SingleSelectRadioItem.EVENT_CHANGE, this.isSelected(), this); this.fireEvent(BI.SingleSelectRadioItem.EVENT_CHANGE, this.isSelected(), this);
} }
}, }
setSelected: function (v) { setSelected(v) {
BI.SingleSelectRadioItem.superclass.setSelected.apply(this, arguments); BI.SingleSelectRadioItem.superclass.setSelected.apply(this, arguments);
this.radio.setSelected(v); this.radio.setSelected(v);
} }
}); }
BI.SingleSelectRadioItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.single_select_radio_item", BI.SingleSelectRadioItem);

71
src/case/button/node/node.arrow.js

@ -1,34 +1,42 @@
import { NodeButton } from "../../../base/single/button/button.node";
import { shortcut, extend, createWidget } from "../../../core";
/** /**
* Created by roy on 15/10/16. * Created by roy on 15/10/16.
*/ */
BI.ArrowNode = BI.inherit(BI.NodeButton, { @shortcut()
_defaultConfig: function () { export class ArrowNode extends NodeButton {
var conf = BI.ArrowNode.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.arrow_group_node";
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-arrow-group-node bi-list-item", _defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-arrow-group-node bi-list-item`,
id: "", id: "",
pId: "", pId: "",
open: false, open: false,
height: 24, height: 24,
iconWrapperWidth: 16 iconWrapperWidth: 16,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
this.checkbox = BI.createWidget({ this.checkbox = createWidget({
type: "bi.arrow_group_node_checkbox", type: "bi.arrow_group_node_checkbox",
expandIcon: o.expandIcon, expandIcon: o.expandIcon,
collapseIcon: o.collapseIcon, collapseIcon: o.collapseIcon,
}); });
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
columnSize: [o.iconWrapperWidth || o.height, "fill"], columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [this.checkbox, { items: [this.checkbox, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: _ref => {
self.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -41,34 +49,33 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}
}]
};
}, },
}],
};
}
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
BI.ArrowNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
this.checkbox.setSelected(this.isOpened()); this.checkbox.setSelected(this.isOpened());
}, }
setText: function (text) { setText(text) {
BI.ArrowNode.superclass.setText.apply(this, arguments); super.setText.apply(this, arguments);
this.text.setText(text); this.text.setText(text);
}, }
setOpened: function (v) { setOpened(v) {
BI.ArrowNode.superclass.setOpened.apply(this, arguments); super.setOpened.apply(this, arguments);
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
} }
}); }
BI.shortcut("bi.arrow_group_node", BI.ArrowNode);

82
src/case/button/node/node.first.plus.js

@ -1,33 +1,42 @@
import { NodeButton } from "../../../base/single/button/button.node";
import { shortcut, extend, createWidget, Controller } from "../../../core";
/** /**
* 加号表示的组节点 * 加号表示的组节点
* Created by GUY on 2015/9/6. * Created by GUY on 2015/9/6.
* @class BI.FirstPlusGroupNode * @class FirstPlusGroupNode
* @extends BI.NodeButton * @extends NodeButton
*/ */
BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, { @shortcut()
_defaultConfig: function () { export class FirstPlusGroupNode extends NodeButton {
var conf = BI.FirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.first_plus_group_node";
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-first-plus-group-node bi-list-item", _defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-first-plus-group-node bi-list-item`,
logic: { logic: {
dynamic: false dynamic: false,
}, },
id: "", id: "",
pId: "", pId: "",
open: false, open: false,
height: 24 height: 24,
}); });
}, }
_init: function () {
BI.FirstPlusGroupNode.superclass._init.apply(this, arguments); _init() {
var self = this, o = this.options; super._init.apply(this, arguments);
this.checkbox = BI.createWidget({ const o = this.options;
this.checkbox = createWidget({
type: "bi.first_tree_node_checkbox", type: "bi.first_tree_node_checkbox",
stopPropagation: true, stopPropagation: true,
iconHeight: o.height, iconHeight: o.height,
iconWidth: o.height iconWidth: o.height,
}); });
this.text = BI.createWidget({ this.text = createWidget({
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -37,9 +46,9 @@ BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { this.checkbox.on(Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
if (this.isSelected()) { if (this.isSelected()) {
self.triggerExpand(); self.triggerExpand();
@ -48,37 +57,36 @@ BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, {
} }
} }
}); });
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: this.checkbox el: this.checkbox,
}, this.text); }, this.text);
BI.createWidget(BI.extend({ BI.createWidget(BI.extend({
element: this element: this,
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items items,
})))); }))));
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
BI.FirstPlusGroupNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
this.checkbox.setSelected(this.isSelected()); this.checkbox.setSelected(this.isSelected());
}, }
setOpened: function (v) { setOpened(v) {
BI.FirstPlusGroupNode.superclass.setOpened.apply(this, arguments); super.setOpened.apply(this, arguments);
if (BI.isNotNull(this.checkbox)) { if (BI.isNotNull(this.checkbox)) {
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
} }
} }
}); }
BI.shortcut("bi.first_plus_group_node", BI.FirstPlusGroupNode);

99
src/case/button/node/node.icon.arrow.js

@ -1,18 +1,24 @@
import { NodeButton } from "../../../base/single/button/button.node";
import { shortcut, extend, createWidget, Controller } from "../../../core";
/** /**
* Created by User on 2016/3/31. * Created by User on 2016/3/31.
*/ *
/**
* > + icon + 文本 * > + icon + 文本
* @class BI.IconArrowNode * @class IconArrowNode
* @extends BI.NodeButton * @extends NodeButton
*/ */
BI.IconArrowNode = BI.inherit(BI.NodeButton, { @shortcut()
_defaultConfig: function () { export class IconArrowNode extends NodeButton {
var conf = BI.IconArrowNode.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.icon_arrow_node";
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-arrow-node bi-list-item", _defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-icon-arrow-node bi-list-item`,
logic: { logic: {
dynamic: false dynamic: false,
}, },
id: "", id: "",
pId: "", pId: "",
@ -21,29 +27,30 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
iconHeight: 12, iconHeight: 12,
iconWidth: 12, iconWidth: 12,
iconCls: "", iconCls: "",
iconWrapperWidth: 16 iconWrapperWidth: 16,
}); });
}, }
_init: function () {
BI.IconArrowNode.superclass._init.apply(this, arguments); _init() {
var self = this, o = this.options; super._init.apply(this, arguments);
this.checkbox = BI.createWidget({ const o = this.options;
this.checkbox = createWidget({
type: "bi.arrow_group_node_checkbox", type: "bi.arrow_group_node_checkbox",
expandIcon: o.expandIcon, expandIcon: o.expandIcon,
collapseIcon: o.collapseIcon, collapseIcon: o.collapseIcon,
width: 24, width: 24,
stopPropagation: true stopPropagation: true,
}); });
var icon = BI.createWidget({ const icon = createWidget({
type: "bi.icon_label", type: "bi.icon_label",
width: 24, width: 24,
cls: o.iconCls, cls: o.iconCls,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight iconHeight: o.iconHeight,
}); });
this.text = BI.createWidget({ createWidget({
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -53,52 +60,50 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { this.checkbox.on(Controller.EVENT_CHANGE, type => {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
if (this.isSelected()) { if (this.checkbox.isSelected()) {
self.triggerExpand(); this.triggerExpand();
} else { } else {
self.triggerCollapse(); this.triggerCollapse();
} }
} }
}); });
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: o.iconWrapperWidth, width: o.iconWrapperWidth,
el: this.checkbox el: this.checkbox,
}, { }, {
width: 16, width: 16,
el: icon el: icon,
}, this.text); }, this.text);
BI.createWidget(BI.extend({ createWidget(extend({
element: this element: this,
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { }, BI.LogicFactory.createLogic(type, extend(o.logic, {
items: items, items,
rgap: 5 rgap: 5,
})))); }))));
}, }
doRedMark: function () { doRedMark () {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
BI.IconArrowNode.superclass.doClick.apply(this, arguments); BI.IconArrowNode.superclass.doClick.apply(this, arguments);
this.checkbox.setSelected(this.isSelected()); this.checkbox.setSelected(this.isSelected());
}, }
setOpened: function (v) { setOpened(v) {
BI.IconArrowNode.superclass.setOpened.apply(this, arguments); BI.IconArrowNode.superclass.setOpened.apply(this, arguments);
if (BI.isNotNull(this.checkbox)) { if (BI.isNotNull(this.checkbox)) {
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
} }
} }
}); }
BI.shortcut("bi.icon_arrow_node", BI.IconArrowNode);

93
src/case/button/node/node.last.plus.js

@ -1,33 +1,40 @@
import { NodeButton } from "../../../base/single/button/button.node";
import { shortcut, extend, createWidget, isNotNull } from "../../../core";
/** /**
* 加号表示的组节点 * 加号表示的组节点
* Created by GUY on 2015/9/6. * Created by GUY on 2015/9/6.
* @class BI.LastPlusGroupNode * @class LastPlusGroupNode
* @extends BI.NodeButton * @extends NodeButton
*/ */
BI.LastPlusGroupNode = BI.inherit(BI.NodeButton, { @shortcut()
_defaultConfig: function () { export class LastPlusGroupNode extends NodeButton {
var conf = BI.LastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.last_plus_group_node";
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-last-plus-group-node bi-list-item", _defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-last-plus-group-node bi-list-item`,
logic: { logic: {
dynamic: false dynamic: false,
}, },
id: "", id: "",
pId: "", pId: "",
open: false, open: false,
height: 24 height: 24,
}); });
}, }
_init: function () { _init() {
BI.LastPlusGroupNode.superclass._init.apply(this, arguments); BI.LastPlusGroupNode.superclass._init.apply(this, arguments);
var self = this, o = this.options; const o = this.options;
this.checkbox = BI.createWidget({ this.checkbox = createWidget({
type: "bi.last_tree_node_checkbox", type: "bi.last_tree_node_checkbox",
stopPropagation: true, stopPropagation: true,
iconHeight: o.height, iconHeight: o.height,
iconWidth: o.height iconWidth: o.height,
}); });
this.text = BI.createWidget({ this.text = createWidget({
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -37,48 +44,46 @@ BI.LastPlusGroupNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { this.checkbox.on(BI.Controller.EVENT_CHANGE, type => {
if(type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
if (this.isSelected()) { if (this.checkbox.isSelected()) {
self.triggerExpand(); this.triggerExpand();
} else { } else {
self.triggerCollapse(); this.triggerCollapse();
} }
} }
}); });
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: this.checkbox el: this.checkbox,
}, this.text); }, this.text);
BI.createWidget(BI.extend({ createWidget(extend({
element: this element: this,
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { }, BI.LogicFactory.createLogic(type, extend(o.logic, {
items: items items,
})))); }))));
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
BI.LastPlusGroupNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
this.checkbox.setSelected(this.isSelected()); this.checkbox.setSelected(this.isSelected());
}, }
setOpened: function (v) { setOpened(v) {
BI.LastPlusGroupNode.superclass.setOpened.apply(this, arguments); super.setOpened.apply(this, arguments);
if (BI.isNotNull(this.checkbox)) { if (isNotNull(this.checkbox)) {
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
} }
} }
}); }
BI.shortcut("bi.last_plus_group_node", BI.LastPlusGroupNode);

85
src/case/button/node/node.mid.plus.js

@ -1,33 +1,41 @@
import { NodeButton } from "../../../base/single/button/button.node";
import { shortcut, extend, createWidget, Controller } from "../../../core";
/** /**
* 加号表示的组节点 * 加号表示的组节点
* Created by GUY on 2015/9/6. * Created by GUY on 2015/9/6.
* @class BI.MidPlusGroupNode * @class BI.MidPlusGroupNode
* @extends BI.NodeButton * @extends BI.NodeButton
*/ */
BI.MidPlusGroupNode = BI.inherit(BI.NodeButton, { @shortcut
_defaultConfig: function () { export class MidPlusGroupNode extends NodeButton {
var conf = BI.MidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.mid_plus_group_node";
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-mid-plus-group-node bi-list-item", _defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-mid-plus-group-node bi-list-item`,
logic: { logic: {
dynamic: false dynamic: false,
}, },
id: "", id: "",
pId: "", pId: "",
open: false, open: false,
height: 24 height: 24,
}); });
}, }
_init: function () {
BI.MidPlusGroupNode.superclass._init.apply(this, arguments); _init() {
var self = this, o = this.options; super._init.apply(this, arguments);
this.checkbox = BI.createWidget({ const o = this.options;
this.checkbox = createWidget({
type: "bi.mid_tree_node_checkbox", type: "bi.mid_tree_node_checkbox",
stopPropagation: true, stopPropagation: true,
iconHeight: o.height, iconHeight: o.height,
iconWidth: o.height iconWidth: o.height,
}); });
this.text = BI.createWidget({ this.text = createWidget({
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -37,48 +45,47 @@ BI.MidPlusGroupNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { this.checkbox.on(Controller.EVENT_CHANGE, type => {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
if (this.isSelected()) { if (this.checkbox.isSelected()) {
self.triggerExpand(); this.triggerExpand();
} else { } else {
self.triggerCollapse(); this.triggerCollapse();
} }
} }
}); });
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: this.checkbox el: this.checkbox,
}, this.text); }, this.text);
BI.createWidget(BI.extend({ createWidget(extend({
element: this element: this,
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { }, BI.LogicFactory.createLogic(type, extend(o.logic, {
items: items items,
})))); }))));
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
BI.MidPlusGroupNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
this.checkbox.setSelected(this.isSelected()); this.checkbox.setSelected(this.isSelected());
}, }
setOpened: function (v) { setOpened(v) {
BI.MidPlusGroupNode.superclass.setOpened.apply(this, arguments); BI.MidPlusGroupNode.superclass.setOpened.apply(this, arguments);
if (BI.isNotNull(this.checkbox)) { if (BI.isNotNull(this.checkbox)) {
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
} }
} }
}); }
BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);

88
src/case/button/node/node.multilayer.icon.arrow.js

@ -1,7 +1,14 @@
BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, { import { NodeButton } from "../../../base/single/button/button.node";
_defaultConfig: function () { import { shortcut, extend, createWidget, Controller, count } from "../../../core";
var conf = BI.MultiLayerIconArrowNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { @shortcut()
export class MultiLayerIconArrowNode extends NodeButton {
static xtype = "bi.multilayer_icon_arrow_node";
_defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
extraCls: "bi-multilayer-icon-arrow-node bi-list-item", extraCls: "bi-multilayer-icon-arrow-node bi-list-item",
layer: 0, // 第几层级 layer: 0, // 第几层级
id: "", id: "",
@ -10,13 +17,14 @@ BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, {
height: 24, height: 24,
iconHeight: 16, iconHeight: 16,
iconWidth: 16, iconWidth: 16,
iconCls: "" iconCls: "",
}); });
}, }
_init: function () {
BI.MultiLayerIconArrowNode.superclass._init.apply(this, arguments); _init() {
var self = this, o = this.options; super._init.apply(this, arguments);
this.node = BI.createWidget({ const o = this.options;
this.node = createWidget({
type: "bi.icon_arrow_node", type: "bi.icon_arrow_node",
iconCls: o.iconCls, iconCls: o.iconCls,
cls: "bi-list-item-none", cls: "bi-list-item-none",
@ -30,60 +38,58 @@ BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
this.node.on(BI.Controller.EVENT_CHANGE, function (type) { this.node.on(Controller.EVENT_CHANGE, (...args) => {
self.setSelected(self.isSelected()); this.setSelected(this.isSelected());
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, args);
}); });
var items = []; const items = [];
BI.count(0, o.layer, function () { count(0, o.layer, () => {
items.push({ items.push({
type: "bi.layout", type: "bi.layout",
width: 15, width: 15,
height: o.height height: o.height,
}); });
}); });
items.push(this.node); items.push(this.node);
BI.createWidget({ createWidget({
type: "bi.horizontal_adapt", type: "bi.horizontal_adapt",
element: this, element: this,
columnSize: BI.makeArray(o.layer, 15), columnSize: BI.makeArray(o.layer, 15),
items: items items,
}); });
}, }
isOnce: function () { isOnce() {
return true; return true;
}, }
doRedMark: function () { doRedMark() {
this.node.doRedMark.apply(this.node, arguments); this.node.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.node.unRedMark.apply(this.node, arguments); this.node.unRedMark(...arguments);
}, }
isSelected: function () { isSelected() {
return this.node.isSelected(); return this.node.isSelected();
}, }
setSelected: function (b) { setSelected(b) {
BI.MultiLayerIconArrowNode.superclass.setSelected.apply(this, arguments); super.setSelected.apply(this, arguments);
this.node.setSelected(b); this.node.setSelected(b);
}, }
doClick: function () { doClick() {
BI.NodeButton.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
this.node.setSelected(this.isSelected()); this.node.setSelected(this.isSelected());
}, }
setOpened: function (v) { setOpened(v) {
BI.MultiLayerIconArrowNode.superclass.setOpened.apply(this, arguments); super.setOpened.apply(this, arguments);
this.node.setOpened(v); this.node.setOpened(v);
} }
}); }
BI.shortcut("bi.multilayer_icon_arrow_node", BI.MultiLayerIconArrowNode);

79
src/case/button/node/node.plus.js

@ -1,42 +1,51 @@
import { NodeButton } from "../../../base/single/button/button.node";
import { shortcut, extend, createWidget, Controller } from "../../../core";
/** /**
* 加号表示的组节点 * 加号表示的组节点
* Created by GUY on 2015/9/6. * Created by GUY on 2015/9/6.
* @class BI.PlusGroupNode * @class PlusGroupNode
* @extends BI.NodeButton * @extends NodeButton
*/ */
BI.PlusGroupNode = BI.inherit(BI.NodeButton, { @shortcut()
_defaultConfig: function () { export class PlusGroupNode extends NodeButton {
var conf = BI.PlusGroupNode.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.plus_group_node";
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-plus-group-node bi-list-item", _defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-plus-group-node bi-list-item`,
id: "", id: "",
pId: "", pId: "",
open: false, open: false,
height: 24 height: 24,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
this.checkbox = BI.createWidget({ this.checkbox = createWidget({
type: "bi.tree_node_checkbox", type: "bi.tree_node_checkbox",
iconHeight: o.height, iconHeight: o.height,
iconWidth: o.iconWrapperWidth || o.height iconWidth: o.iconWrapperWidth || o.height,
}); });
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { this.checkbox.on(Controller.EVENT_CHANGE, (...args) => {
const [type] = args;
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected()); this.setSelected(this.isSelected());
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, args);
}); });
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
columnSize: [o.iconWrapperWidth || o.height, "fill"], columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [this.checkbox, { items: [this.checkbox, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: _ref => {
self.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -49,31 +58,29 @@ BI.PlusGroupNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
py: o.py py: o.py,
}
}]
};
}, },
}],
};
}
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
BI.PlusGroupNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
this.checkbox.setSelected(this.isSelected()); this.checkbox.setSelected(this.isSelected());
}, }
setOpened: function (v) { setOpened(v) {
BI.PlusGroupNode.superclass.setOpened.apply(this, arguments); super.setOpened.apply(this, arguments);
if (this.checkbox) { if (this.checkbox) {
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
} }
} }
}); }
BI.shortcut("bi.plus_group_node", BI.PlusGroupNode);

45
src/case/button/node/siwtcher.tree.node.js

@ -1,17 +1,23 @@
BI.TreeNodeSwitcher = BI.inherit(BI.NodeButton, { import { NodeButton } from "../../../base/single/button/button.node";
_defaultConfig: function () { import { shortcut, extend } from "../../../core";
return BI.extend(BI.TreeNodeSwitcher.superclass._defaultConfig.apply(this, arguments), {
@shortcut()
export class TreeNodeSwitcher extends NodeButton {
static xtype = "bi.tree_node_switcher";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
baseCls: "bi-tree-node-switcher", baseCls: "bi-tree-node-switcher",
iconWidth: 24, iconWidth: 24,
iconHeight: 24, iconHeight: 24,
isFirstNode: false, isFirstNode: false,
isLastNode: false, isLastNode: false,
layer: 0 layer: 0,
}); });
}, }
render: function () {
render() {
const [collapse, expand] = this.getIconCls(); const [collapse, expand] = this.getIconCls();
return { return {
@ -20,10 +26,10 @@ BI.TreeNodeSwitcher = BI.inherit(BI.NodeButton, {
iconHeight: this.options.iconHeight, iconHeight: this.options.iconHeight,
cls: this.options.open ? expand : collapse, cls: this.options.open ? expand : collapse,
}; };
}, }
getIconCls: function () { getIconCls() {
var options = this.options; const options = this.options;
if (options.layer === 0 && options.isFirstNode && options.isLastNode) { if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
// 只有一层,并且是第一个节点,并且是最后一个节点 // 只有一层,并且是第一个节点,并且是最后一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type1", "tree-expand-icon-type1"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type1", "tree-expand-icon-type1"];
@ -37,23 +43,20 @@ BI.TreeNodeSwitcher = BI.inherit(BI.NodeButton, {
// 其他情况 // 其他情况
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type3", "tree-expand-icon-type3"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type3", "tree-expand-icon-type3"];
} }
}, }
setOpened: function (b) { setOpened(b) {
BI.TreeNodeSwitcher.superclass.setOpened.apply(this, arguments); super.setOpened.apply(this, arguments);
const [collapse, expand] = this.getIconCls(); const [collapse, expand] = this.getIconCls();
if (b) { if (b) {
this.element.addClass(expand).removeClass(collapse); this.element.addClass(expand).removeClass(collapse);
} else { } else {
this.element.addClass(collapse).removeClass(expand); this.element.addClass(collapse).removeClass(expand);
} }
},
doClick: function () {
BI.TreeNodeSwitcher.superclass.doClick.apply(this, arguments);
this.fireEvent(BI.TreeNodeSwitcher.EVENT_CHANGE, this);
} }
});
BI.TreeNodeSwitcher.EVENT_CHANGE = "EVENT_CHANGE"; doClick() {
BI.shortcut("bi.tree_node_switcher", BI.TreeNodeSwitcher); super.doClick.apply(this, arguments);
this.fireEvent(TreeNodeSwitcher.EVENT_CHANGE, this);
}
}

77
src/case/button/node/treenode.js

@ -1,8 +1,15 @@
BI.BasicTreeNode = BI.inherit(BI.NodeButton, { import { NodeButton } from "../../../base/single/button/button.node";
_defaultConfig: function (props) { import { shortcut, extend } from "../../../core";
var conf = BI.BasicTreeNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { @shortcut()
baseCls: (conf.baseCls || "") + " bi-tree-node " + (props.selectable ? "bi-list-item-active" : "bi-list-item"), export class BasicTreeNode extends NodeButton {
static xtype = "bi.tree_node";
_defaultConfig(props) {
const conf = super._defaultConfig.apply(this, arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-tree-node ${props.selectable ? "bi-list-item-active" : "bi-list-item"}`,
id: "", id: "",
pId: "", pId: "",
open: false, open: false,
@ -14,15 +21,15 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, {
selectable: true, selectable: true,
disabled: false, // disabled不会影响展开收起功能 disabled: false, // disabled不会影响展开收起功能
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
const checkbox = { const checkbox = {
type: "bi.tree_node_switcher", type: "bi.tree_node_switcher",
__ref: function (_ref) { __ref: _ref => {
self.switcher = _ref; this.switcher = _ref;
}, },
iconHeight: o.height, iconHeight: o.height,
iconWidth: o.iconWrapperWidth || o.height, iconWidth: o.iconWrapperWidth || o.height,
@ -32,7 +39,7 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, {
layer: o.layer, layer: o.layer,
...o.switcherIcon, ...o.switcherIcon,
stopPropagation: o.selectable, stopPropagation: o.selectable,
mounted: function () { mounted () {
this.setEnable(true); this.setEnable(true);
}, },
listeners: [ listeners: [
@ -42,9 +49,9 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, {
if (!this.isEnabled() || o.selectable) { if (!this.isEnabled() || o.selectable) {
this.isOpened() ? this.triggerCollapse() : this.triggerExpand(); this.isOpened() ? this.triggerCollapse() : this.triggerExpand();
} }
},
} }
} ],
]
}; };
return { return {
@ -57,8 +64,8 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, {
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: _ref => {
self.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -71,36 +78,36 @@ BI.BasicTreeNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
py: o.py py: o.py,
} },
} }
] ],
}; };
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doClick: function () { doClick() {
if (this.options.selectable) { if (this.options.selectable) {
return; return;
} }
BI.BasicTreeNode.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
}, }
setOpened: function (v) { setOpened(v) {
BI.BasicTreeNode.superclass.setOpened.apply(this, arguments); super.setOpened.apply(this, arguments);
this.switcher.setOpened(v); this.switcher.setOpened(v);
}, }
setValue: function () { setValue() {
BI.BasicTreeNode.superclass.setValue.apply(this, arguments); super.setValue.apply(this, arguments);
} }
}); }
BI.shortcut("bi.tree_node", BI.BasicTreeNode);

85
src/case/button/switch.js

@ -1,84 +1,95 @@
/** /**
* Created by Windy on 2018/2/1. * Created by Windy on 2018/2/1.
*/ */
BI.Switch = BI.inherit(BI.BasicButton, {
constants: { import { BasicButton } from "../../base/single/button/button.basic";
CIRCLE_SIZE: 12 import { shortcut } from "../../core";
},
@shortcut()
export class Switch extends BasicButton {
static xtype = "bi.switch";
static EVENT_CHANGE = "EVENT_CHANGE";
props: { constants = {
CIRCLE_SIZE: 12,
};
props = {
extraCls: "bi-switch", extraCls: "bi-switch",
attributes: { attributes: {
tabIndex: 1 tabIndex: 1,
}, },
height: 20, height: 20,
width: 44, width: 44,
showTip: false showTip: false,
}, };
render() {
const o = this.options,
c = this.constants;
const tgap = (o.height - c.CIRCLE_SIZE) / 2;
render: function () {
var self = this, o = this.options, c = this.constants;
var tgap = (o.height - c.CIRCLE_SIZE) / 2;
return { return {
type: "bi.absolute", type: "bi.absolute",
ref: function () { ref: _ref => {
self.layout = this; this.layout = _ref;
}, },
items: [{ items: [
{
el: { el: {
type: "bi.text_button", type: "bi.text_button",
cls: "circle-button" cls: "circle-button",
}, },
width: 12, width: 12,
height: 12, height: 12,
top: tgap, top: tgap,
left: o.selected ? 28 : 4 left: o.selected ? 28 : 4,
}, { },
{
type: "bi.label", type: "bi.label",
text: BI.i18nText("BI-Basic_Simple_Open"), text: BI.i18nText("BI-Basic_Simple_Open"),
cls: "content-tip", cls: "content-tip",
left: 8, left: 8,
top: tgap - 2, top: tgap - 2,
invisible: !(o.showTip && o.selected), invisible: !(o.showTip && o.selected),
ref: function (ref) { ref: _ref => {
self.openTip = ref; this.openTip = _ref;
} },
}, { },
{
type: "bi.label", type: "bi.label",
text: BI.i18nText("BI-Basic_Simple_Close"), text: BI.i18nText("BI-Basic_Simple_Close"),
cls: "content-tip", cls: "content-tip",
right: 8, right: 8,
top: tgap - 2, top: tgap - 2,
invisible: !(o.showTip && !o.selected), invisible: !(o.showTip && !o.selected),
ref: function (ref) { ref: _ref => {
self.closeTip = ref; this.closeTip = _ref;
},
} }
}] ],
}; };
}, }
_setEnable: function (enable) { _setEnable(enable) {
BI.Switch.superclass._setEnable.apply(this, arguments); super._setEnable.apply(this, arguments);
if (enable === true) { if (enable === true) {
this.element.attr("tabIndex", 1); this.element.attr("tabIndex", 1);
} else if (enable === false) { } else if (enable === false) {
this.element.removeAttr("tabIndex"); this.element.removeAttr("tabIndex");
} }
}, }
setSelected: function (v) { setSelected(v) {
BI.Switch.superclass.setSelected.apply(this, arguments); super.setSelected.apply(this, arguments);
this.layout.attr("items")[0].left = v ? 28 : 4; this.layout.attr("items")[0].left = v ? 28 : 4;
this.layout.resize(); this.layout.resize();
this.options.showTip && this.openTip.setVisible(v); this.options.showTip && this.openTip.setVisible(v);
this.options.showTip && this.closeTip.setVisible(!v); this.options.showTip && this.closeTip.setVisible(!v);
}, }
doClick: function () { doClick() {
BI.Switch.superclass.doClick.apply(this, arguments); super.doClick.apply(this, arguments);
this.fireEvent(BI.Switch.EVENT_CHANGE, this.isSelected()); this.fireEvent(Switch.EVENT_CHANGE, this.isSelected());
} }
}); }
BI.Switch.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.switch", BI.Switch);

92
src/case/button/treeitem/item.first.treeleaf.js

@ -1,20 +1,27 @@
BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, { import { BasicButton } from "../../../base/single/button/button.basic";
_defaultConfig: function () { import { shortcut, extend, createWidget } from "../../../core";
return BI.extend(BI.FirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
@shortcut()
export class FirstTreeLeafItem extends BasicButton {
static xtype = "bi.first_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
extraCls: "bi-first-tree-leaf-item bi-list-item-active", extraCls: "bi-first-tree-leaf-item bi-list-item-active",
logic: { logic: {
dynamic: false dynamic: false,
}, },
id: "", id: "",
pId: "", pId: "",
layer: 0, layer: 0,
height: 24 height: 24,
}); });
}, }
_init: function () {
BI.FirstTreeLeafItem.superclass._init.apply(this, arguments); _init() {
var o = this.options; super._init.apply(this, arguments);
this.text = BI.createWidget({ const o = this.options;
this.text = createWidget({
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -24,76 +31,75 @@ BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
el: { el: {
type: "bi.layout", type: "bi.layout",
cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(), cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
height: o.height height: o.height,
} },
}), { }), {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: { el: {
type: "bi.layout", type: "bi.layout",
cls: this._getFirstLineCls(), cls: this._getFirstLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: o.height height: o.height,
} },
}, { }, {
el: this.text el: this.text,
}); });
BI.createWidget(BI.extend({ createWidget(extend({
element: this element: this,
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items items,
})))); }))));
}, }
_getBaseLineCls: function () { _getBaseLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid": case "solid":
return "base-solid-line-conn-background"; return "base-solid-line-conn-background";
default: default:
return "base-line-conn-background"; return "base-line-conn-background";
} }
}, }
_getFirstLineCls: function () { _getFirstLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid": case "solid":
return "first-solid-line-conn-background"; return "first-solid-line-conn-background";
default: default:
return "first-line-conn-background"; return "first-line-conn-background";
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
}, }
getId: function () { getId() {
return this.options.id; return this.options.id;
}, }
getPId: function () { getPId() {
return this.options.pId; return this.options.pId;
} }
}); }
BI.shortcut("bi.first_tree_leaf_item", BI.FirstTreeLeafItem);

86
src/case/button/treeitem/item.icon.treeleaf.js

@ -1,33 +1,39 @@
BI.IconTreeLeafItem = BI.inherit(BI.BasicButton, { import { BasicButton } from "../../../base/single/button/button.basic";
_defaultConfig: function () { import { shortcut, extend, createWidget } from "../../../core";
return BI.extend(BI.IconTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
@shortcut()
export class IconTreeLeafItem extends BasicButton {
static xtype = "bi.icon_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
extraCls: "bi-icon-tree-leaf-item bi-list-item-active", extraCls: "bi-icon-tree-leaf-item bi-list-item-active",
logic: { logic: {
dynamic: false dynamic: false,
}, },
height: 24, height: 24,
iconWidth: 16, iconWidth: 16,
iconHeight: 16, iconHeight: 16,
iconCls: "" iconCls: "",
}); });
}, }
_init: function () { _init() {
BI.IconTreeLeafItem.superclass._init.apply(this, arguments); super._init.apply(this, arguments);
var self = this, o = this.options; const o = this.options;
var icon = BI.createWidget({ const icon = createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
width: 24, width: 24,
cls: o.iconCls, cls: o.iconCls,
items: [{ items: [{
type: "bi.icon", type: "bi.icon",
width: o.iconWidth, width: o.iconWidth,
height: o.iconHeight height: o.iconHeight,
}] }],
}); });
this.text = BI.createWidget({ this.text = createWidget({
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -37,46 +43,44 @@ BI.IconTreeLeafItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 16, width: 16,
el: icon el: icon,
}, { }, {
el: this.text el: this.text,
}); });
BI.createWidget(BI.extend({ createWidget(BI.extend({
element: this element: this,
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items, items,
hgap: 5 hgap: 5,
})))); }))));
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
}, }
getId: function () { getId() {
return this.options.id; return this.options.id;
}, }
getPId: function () { getPId() {
return this.options.pId; return this.options.pId;
} }
}); }
BI.shortcut("bi.icon_tree_leaf_item", BI.IconTreeLeafItem);

94
src/case/button/treeitem/item.last.treeleaf.js

@ -1,20 +1,27 @@
BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, { import { BasicButton } from "../../../base/single/button/button.basic";
_defaultConfig: function () { import { shortcut, extend, createWidget } from "../../../core";
return BI.extend(BI.LastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
@shortcut()
export class LastTreeLeafItem extends BasicButton {
static xtype = "bi.last_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
extraCls: "bi-last-tree-leaf-item bi-list-item-active", extraCls: "bi-last-tree-leaf-item bi-list-item-active",
logic: { logic: {
dynamic: false dynamic: false,
}, },
id: "", id: "",
pId: "", pId: "",
layer: 0, layer: 0,
height: 24 height: 24,
}); });
}, }
_init: function () {
BI.LastTreeLeafItem.superclass._init.apply(this, arguments); _init() {
var o = this.options; super._init.apply(this, arguments);
this.text = BI.createWidget({ const o = this.options;
this.text = createWidget({
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -24,76 +31,75 @@ BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
el: { el: {
type: "bi.layout", type: "bi.layout",
cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(), cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
height: o.height height: o.height,
} },
}), { }), {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: { el: {
type: "bi.layout", type: "bi.layout",
cls: this._getLastLineCls(), cls: this._getLastLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: o.height height: o.height,
} },
}, { }, {
el: this.text el: this.text,
}); });
BI.createWidget(BI.extend({ createWidget(BI.extend({
element: this element: this,
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { }, BI.LogicFactory.createLogic(type, extend(o.logic, {
items: items items,
})))); }))));
}, }
_getBaseLineCls: function () { _getBaseLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid": case "solid":
return "base-solid-line-conn-background"; return "base-solid-line-conn-background";
default: default:
return "base-line-conn-background"; return "base-line-conn-background";
} }
}, }
_getLastLineCls: function () { _getLastLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid": case "solid":
return "last-solid-line-conn-background"; return "last-solid-line-conn-background";
default: default:
return "last-line-conn-background"; return "last-line-conn-background";
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
}, }
getId: function () { getId() {
return this.options.id; return this.options.id;
}, }
getPId: function () { getPId() {
return this.options.pId; return this.options.pId;
} }
}); }
BI.shortcut("bi.last_tree_leaf_item", BI.LastTreeLeafItem);

94
src/case/button/treeitem/item.mid.treeleaf.js

@ -1,20 +1,27 @@
BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, { import { BasicButton } from "../../../base/single/button/button.basic";
_defaultConfig: function () { import { shortcut, extend, createWidget } from "../../../core";
return BI.extend(BI.MidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
@shortcut()
export class MidTreeLeafItem extends BasicButton {
static xtype = "bi.mid_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
extraCls: "bi-mid-tree-leaf-item bi-list-item-active", extraCls: "bi-mid-tree-leaf-item bi-list-item-active",
logic: { logic: {
dynamic: false dynamic: false,
}, },
id: "", id: "",
pId: "", pId: "",
layer: 0, layer: 0,
height: 24 height: 24,
}); });
}, }
_init: function () {
BI.MidTreeLeafItem.superclass._init.apply(this, arguments); _init() {
var o = this.options; super._init.apply(this, arguments);
this.text = BI.createWidget({ const o = this.options;
this.text = createWidget({
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -24,76 +31,75 @@ BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
el: { el: {
type: "bi.layout", type: "bi.layout",
cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(), cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
height: o.height height: o.height,
} },
}), { }), {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: { el: {
type: "bi.layout", type: "bi.layout",
cls: this._getMidLineCls(), cls: this._getMidLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: o.height height: o.height,
} },
}, { }, {
el: this.text el: this.text,
}); });
BI.createWidget(BI.extend({ createWidget(extend({
element: this element: this,
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { }, BI.LogicFactory.createLogic(type, extend(o.logic, {
items: items items,
})))); }))));
}, }
_getBaseLineCls: function () { _getBaseLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid": case "solid":
return "base-solid-line-conn-background"; return "base-solid-line-conn-background";
default: default:
return "base-line-conn-background"; return "base-line-conn-background";
} }
}, }
_getMidLineCls: function () { _getMidLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) { switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid": case "solid":
return "mid-solid-line-conn-background"; return "mid-solid-line-conn-background";
default: default:
return "mid-line-conn-background"; return "mid-line-conn-background";
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark () {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
}, }
getId: function () { getId() {
return this.options.id; return this.options.id;
}, }
getPId: function () { getPId() {
return this.options.pId; return this.options.pId;
} }
}); }
BI.shortcut("bi.mid_tree_leaf_item", BI.MidTreeLeafItem);

92
src/case/button/treeitem/item.multilayer.icon.treeleaf.js

@ -1,22 +1,29 @@
import { BasicButton } from "../../../base/single/button/button.basic";
import { shortcut, extend, createWidget, Controller, makeArray } from "../../../core";
/** /**
* @class BI.MultiLayerIconTreeLeafItem * @class BI.MultiLayerIconTreeLeafItem
* @extends BI.BasicButton * @extends BI.BasicButton
*/ */
BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, { @shortcut()
_defaultConfig: function () { export class MultiLayerIconTreeLeafItem extends BasicButton {
return BI.extend(BI.MultiLayerIconTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { static xtype = "bi.multilayer_icon_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(arguments), {
extraCls: "bi-multilayer-icon-tree-leaf-item bi-list-item-active", extraCls: "bi-multilayer-icon-tree-leaf-item bi-list-item-active",
layer: 0, layer: 0,
height: 24, height: 24,
iconCls: "", iconCls: "",
iconHeight: 16, iconHeight: 16,
iconWidth: 16 iconWidth: 16,
}); });
}, }
_init: function () {
BI.MultiLayerIconTreeLeafItem.superclass._init.apply(this, arguments); _init() {
var self = this, o = this.options; super._init.apply(this, arguments);
this.item = BI.createWidget({ const o = this.options;
this.item = createWidget({
type: "bi.icon_tree_leaf_item", type: "bi.icon_tree_leaf_item",
cls: "bi-list-item-none", cls: "bi-list-item-none",
iconCls: o.iconCls, iconCls: o.iconCls,
@ -30,69 +37,70 @@ BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, {
py: o.py, py: o.py,
keyword: o.keyword, keyword: o.keyword,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight iconHeight: o.iconHeight,
}); });
this.item.on(BI.Controller.EVENT_CHANGE, function (type) { this.item.on(Controller.EVENT_CHANGE, (...args) => {
const [type] = args;
if (type === BI.Events.CLICK) {// 本身实现click功能 if (type === BI.Events.CLICK) {// 本身实现click功能
return; return;
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, args);
}); });
var items = []; const items = [];
BI.count(0, o.layer, function () { BI.count(0, o.layer, () => {
items.push({ items.push({
type: "bi.layout", type: "bi.layout",
width: 15, width: 15,
height: o.height height: o.height,
}); });
}); });
items.push(this.item); items.push(this.item);
BI.createWidget({ createWidget({
type: "bi.horizontal_adapt", type: "bi.horizontal_adapt",
element: this, element: this,
columnSize: BI.makeArray(o.layer, 15), columnSize: makeArray(o.layer, 15),
items: items items,
}); });
}, }
doRedMark: function () { doRedMark () {
this.item.doRedMark.apply(this.item, arguments); this.item.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark () {
this.item.unRedMark.apply(this.item, arguments); this.item.unRedMark(...arguments);
}, }
doHighLight: function () { doHighLight() {
this.item.doHighLight.apply(this.item, arguments); this.item.doHighLight(...arguments);
}, }
unHighLight: function () { unHighLight () {
this.item.unHighLight.apply(this.item, arguments); this.item.unHighLight(...arguments);
}, }
getId: function () { getId () {
return this.options.id; return this.options.id;
}, }
getPId: function () { getPId () {
return this.options.pId; return this.options.pId;
}, }
doClick: function () { doClick () {
BI.MultiLayerIconTreeLeafItem.superclass.doClick.apply(this, arguments); BI.MultiLayerIconTreeLeafItem.superclass.doClick.apply(this, arguments);
this.item.setSelected(this.isSelected()); this.item.setSelected(this.isSelected());
}, }
setSelected: function (v) { setSelected(v) {
BI.MultiLayerIconTreeLeafItem.superclass.setSelected.apply(this, arguments); BI.MultiLayerIconTreeLeafItem.superclass.setSelected.apply(this, arguments);
this.item.setSelected(v); this.item.setSelected(v);
}, }
getValue: function () { getValue() {
return this.options.value; return this.options.value;
} }
}); }
BI.shortcut("bi.multilayer_icon_tree_leaf_item", BI.MultiLayerIconTreeLeafItem);

78
src/case/button/treeitem/item.root.treeleaf.js

@ -1,22 +1,27 @@
BI.RootTreeLeafItem = BI.inherit(BI.BasicButton, { import { BasicButton } from "../../../base/single/button/button.basic";
props: { import { shortcut, extend } from "../../../core";
@shortcut()
export class RootTreeLeafItem extends BasicButton {
static xtype = "bi.root_tree_leaf_item";
props = {
baseCls: "bi-root-tree-leaf-item bi-list-item-active", baseCls: "bi-root-tree-leaf-item bi-list-item-active",
logic: { logic: {
dynamic: false dynamic: false,
}, },
id: "", id: "",
pId: "", pId: "",
layer: 0, layer: 0,
height: 24 height: 24,
}, }
render: function () { render() {
var self = this; const o = this.options;
var o = this.options; const text = {
var text = {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: _ref => {
self.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -26,49 +31,48 @@ BI.RootTreeLeafItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}; };
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: { el: {
type: "bi.layout", type: "bi.layout",
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: o.height height: o.height,
} },
}, { }, {
el: text el: text,
}); });
return BI.LogicFactory.createLogic(type, BI.extend(o.logic, { return BI.LogicFactory.createLogic(type, extend(o.logic, {
items: items items,
})); }));
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
}, }
getId: function () { getId() {
return this.options.id; return this.options.id;
}, }
getPId: function () { getPId() {
return this.options.pId; return this.options.pId;
} }
}); }
BI.shortcut("bi.root_tree_leaf_item", BI.RootTreeLeafItem);

68
src/case/button/treeitem/item.treetextleaf.js

@ -1,25 +1,32 @@
import { BasicButton } from "../../../base/single/button/button.basic";
import { shortcut, extend, createWidget } from "../../../core";
/** /**
* 树叶子节点 * 树叶子节点
* Created by GUY on 2015/9/6. * Created by GUY on 2015/9/6.
* @class BI.TreeTextLeafItem * @class BI.TreeTextLeafItem
* @extends BI.BasicButton * @extends BI.BasicButton
*/ */
BI.TreeTextLeafItem = BI.inherit(BI.BasicButton, { @shortcut()
_defaultConfig: function () { export class TreeTextLeafItem extends BasicButton {
return BI.extend(BI.TreeTextLeafItem.superclass._defaultConfig.apply(this, arguments), { static xtype = "bi.tree_text_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig.apply(this, arguments), {
extraCls: "bi-tree-text-leaf-item bi-list-item-active", extraCls: "bi-tree-text-leaf-item bi-list-item-active",
id: "", id: "",
pId: "", pId: "",
height: 24, height: 24,
hgap: 0, hgap: 0,
lgap: 0, lgap: 0,
rgap: 0 rgap: 0,
}); });
}, }
_init: function () {
BI.TreeTextLeafItem.superclass._init.apply(this, arguments); _init() {
var self = this, o = this.options; super._init.apply(this, arguments);
this.text = BI.createWidget({ const o = this.options;
this.text = createWidget({
type: "bi.label", type: "bi.label",
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -31,40 +38,39 @@ BI.TreeTextLeafItem = BI.inherit(BI.BasicButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
py: o.py, py: o.py,
keyword: o.keyword keyword: o.keyword,
}); });
BI.createWidget({ createWidget({
type: "bi.htape", type: "bi.htape",
element: this, element: this,
items: [{ items: [{
el: this.text el: this.text,
}] }],
}); });
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
doHighLight: function () { doHighLight() {
this.text.doHighLight.apply(this.text, arguments); this.text.doHighLight(...arguments);
}, }
unHighLight: function () { unHighLight() {
this.text.unHighLight.apply(this.text, arguments); this.text.unHighLight(...arguments);
}, }
getId: function () { getId() {
return this.options.id; return this.options.id;
}, }
getPId: function () { getPId() {
return this.options.pId; return this.options.pId;
} }
}); }
BI.shortcut("bi.tree_text_leaf_item", BI.TreeTextLeafItem);

62
src/case/button/treeitem/treeitem.js

@ -1,8 +1,15 @@
BI.BasicTreeItem = BI.inherit(BI.NodeButton, { import { NodeButton } from "../../../base/single/button/button.node";
_defaultConfig: function () { import { shortcut, extend } from "../../../core";
var conf = BI.BasicTreeItem.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { @shortcut()
baseCls: (conf.baseCls || "") + " bi-tree-item bi-list-item-active", export class BasicTreeItem extends NodeButton {
static xtype = "bi.tree_item";
_defaultConfig() {
const conf = super._defaultConfig(arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-tree-item bi-list-item-active`,
id: "", id: "",
pId: "", pId: "",
height: 24, height: 24,
@ -10,10 +17,10 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, {
isFirstNode: false, isFirstNode: false,
isLastNode: false, isLastNode: false,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: "bi.vertical_adapt",
@ -31,8 +38,8 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, {
{ {
el: { el: {
type: "bi.label", type: "bi.label",
ref: function (_ref) { ref: _ref => {
self.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -45,15 +52,15 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
py: o.py py: o.py,
}, },
} }
] ],
}; };
}, }
getLineCls: function () { getLineCls() {
var options = this.options; const options = this.options;
if (options.layer === 0 && options.isFirstNode && options.isLastNode) { if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
return ""; return "";
} else if (options.layer === 0 && options.isFirstNode) { } else if (options.layer === 0 && options.isFirstNode) {
@ -63,24 +70,21 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, {
} else { } else {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-mid-solid-line-conn-background" : "mid-line-conn-background"; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-mid-solid-line-conn-background" : "mid-line-conn-background";
} }
}, }
doRedMark: function () { doRedMark() {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark(...arguments);
}, }
unRedMark: function () { unRedMark() {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark(...arguments);
}, }
getId: function () { getId() {
return this.options.id; return this.options.id;
}, }
getPId: function () { getPId() {
return this.options.pId; return this.options.pId;
} }
}
});
BI.shortcut("bi.tree_item", BI.BasicTreeItem);

7
src/case/index.js

@ -0,0 +1,7 @@
import * as button from "./button";
Object.assign(BI, {
...button,
});
export * from "./button";

7
src/core/0.foundation.js vendored

@ -1,10 +1,11 @@
/* eslint-disable eqeqeq */
/** /**
* Created by richie on 15/7/8. * Created by richie on 15/7/8.
*/ */
/** /**
* 初始化BI对象 * 初始化BI对象
*/ */
var _global = undefined; let _global = undefined;
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
_global = window; _global = window;
} else if (typeof global !== "undefined") { } else if (typeof global !== "undefined") {
@ -20,8 +21,8 @@ if (_global) {
} }
if (_global.BI == null) { if (_global.BI == null) {
_global.BI = {prepares: []}; _global.BI = { prepares: [] };
} }
if(_global.BI.prepares == null) { if (_global.BI.prepares == null) {
_global.BI.prepares = []; _global.BI.prepares = [];
} }

3
src/core/2.base.js

@ -488,7 +488,7 @@ BI._.each([
"keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn", "keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn",
"defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty", "defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty",
"isElement", "isNumber", "isString", "isArray", "isObject", "isPlainObject", "isArguments", "isFunction", "isFinite", "isElement", "isNumber", "isString", "isArray", "isObject", "isPlainObject", "isArguments", "isFunction", "isFinite",
"isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined", "zipObject", "cloneDeep" "isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined", "zipObject", "cloneDeep", "pickBy"
], name => { ], name => {
BI[name] = _apply(name); BI[name] = _apply(name);
}); });
@ -526,6 +526,7 @@ export const isNaN = BI.isNaN;
export const isUndefined = BI.isUndefined; export const isUndefined = BI.isUndefined;
export const zipObject = BI.zipObject; export const zipObject = BI.zipObject;
export const cloneDeep = BI.cloneDeep; export const cloneDeep = BI.cloneDeep;
export const pickBy = BI.pickBy;
BI._.each(["mapObject", "findKey", "pick", "omit", "tap"], name => { BI._.each(["mapObject", "findKey", "pick", "omit", "tap"], name => {
BI[name] = _applyFunc(name); BI[name] = _applyFunc(name);

82
src/core/6.plugin.js

@ -1,46 +1,47 @@
BI.Plugin = BI.Plugin || {}; const _WidgetsPlugin = {};
!(function () { const _ObjectPlugin = {};
var _WidgetsPlugin = {}; const _ConfigPlugin = {};
var _ObjectPlugin = {}; const _ConfigRenderPlugin = {};
var _ConfigPlugin = {}; let _GlobalWidgetConfigFns = [];
var _ConfigRenderPlugin = {}; let __GlobalObjectConfigFns = [];
var _GlobalWidgetConfigFns = [];
var __GlobalObjectConfigFns = []; export const Plugin = {
BI.defaults(BI.Plugin, { getWidget (type, options) {
getWidget: function (type, options) {
if (_GlobalWidgetConfigFns.length > 0) { if (_GlobalWidgetConfigFns.length > 0) {
var fns = _GlobalWidgetConfigFns.slice(0); const fns = _GlobalWidgetConfigFns.slice(0);
for (var i = fns.length - 1; i >= 0; i--) { for (let i = fns.length - 1; i >= 0; i--) {
fns[i](type, options); fns[i](type, options);
} }
} }
var res; let res;
if (_ConfigPlugin[type]) { if (_ConfigPlugin[type]) {
for (var i = _ConfigPlugin[type].length - 1; i >= 0; i--) { for (let i = _ConfigPlugin[type].length - 1; i >= 0; i--) {
if (res = _ConfigPlugin[type][i](options)) { res = _ConfigPlugin[type][i](options);
if (res) {
options = res; options = res;
} }
} }
} }
// Deprecated // Deprecated
if (_WidgetsPlugin[type]) { if (_WidgetsPlugin[type]) {
for (var i = _WidgetsPlugin[type].length - 1; i >= 0; i--) { for (let i = _WidgetsPlugin[type].length - 1; i >= 0; i--) {
if (res = _WidgetsPlugin[type][i](options)) { res = _WidgetsPlugin[type][i](options);
if (res) {
return res; return res;
} }
} }
} }
return options; return options;
}, },
config: function (widgetConfigFn, objectConfigFn) { config (widgetConfigFn, objectConfigFn) {
_GlobalWidgetConfigFns = _GlobalWidgetConfigFns.concat(BI._.isArray(widgetConfigFn) ? widgetConfigFn : [widgetConfigFn]); _GlobalWidgetConfigFns = _GlobalWidgetConfigFns.concat(BI._.isArray(widgetConfigFn) ? widgetConfigFn : [widgetConfigFn]);
__GlobalObjectConfigFns = __GlobalObjectConfigFns.concat(BI._.isArray(objectConfigFn) ? objectConfigFn : [objectConfigFn]); __GlobalObjectConfigFns = __GlobalObjectConfigFns.concat(BI._.isArray(objectConfigFn) ? objectConfigFn : [objectConfigFn]);
}, },
configWidget: function (type, fn, opt) { configWidget (type, fn, opt) {
// opt.single: true 最后一次注册有效 // opt.single: true 最后一次注册有效
if (!_ConfigPlugin[type] || (opt && opt.single)) { if (!_ConfigPlugin[type] || (opt && opt.single)) {
_ConfigPlugin[type] = []; _ConfigPlugin[type] = [];
@ -48,19 +49,21 @@ BI.Plugin = BI.Plugin || {};
_ConfigPlugin[type].push(fn); _ConfigPlugin[type].push(fn);
}, },
getRender: function (type, rendered) { getRender (type, rendered) {
var res; let res;
if (_ConfigRenderPlugin[type]) { if (_ConfigRenderPlugin[type]) {
for (var i = _ConfigRenderPlugin[type].length - 1; i >= 0; i--) { for (let i = _ConfigRenderPlugin[type].length - 1; i >= 0; i--) {
if (res = _ConfigRenderPlugin[type][i](rendered)) { res = _ConfigRenderPlugin[type][i](rendered);
if (res) {
rendered = res; rendered = res;
} }
} }
} }
return rendered; return rendered;
}, },
configRender: function (type, fn) { configRender (type, fn) {
if (!_ConfigRenderPlugin[type]) { if (!_ConfigRenderPlugin[type]) {
_ConfigRenderPlugin[type] = []; _ConfigRenderPlugin[type] = [];
} }
@ -68,7 +71,7 @@ BI.Plugin = BI.Plugin || {};
}, },
// Deprecated // Deprecated
registerWidget: function (type, fn) { registerWidget (type, fn) {
if (!_WidgetsPlugin[type]) { if (!_WidgetsPlugin[type]) {
_WidgetsPlugin[type] = []; _WidgetsPlugin[type] = [];
} }
@ -79,34 +82,36 @@ BI.Plugin = BI.Plugin || {};
}, },
// Deprecated // Deprecated
relieveWidget: function (type) { relieveWidget (type) {
delete _WidgetsPlugin[type]; delete _WidgetsPlugin[type];
}, },
getObject: function (type, object) { getObject (type, object) {
if (__GlobalObjectConfigFns.length > 0) { if (__GlobalObjectConfigFns.length > 0) {
var fns = __GlobalObjectConfigFns.slice(0); const fns = __GlobalObjectConfigFns.slice(0);
for (var i = fns.length - 1; i >= 0; i--) { for (let i = fns.length - 1; i >= 0; i--) {
fns[i](type, object); fns[i](type, object);
} }
} }
let res;
if (_ObjectPlugin[type]) { if (_ObjectPlugin[type]) {
var res; for (let i = 0, len = _ObjectPlugin[type].length; i < len; i++) {
for (var i = 0, len = _ObjectPlugin[type].length; i < len; i++) { res = _ObjectPlugin[type][i](object);
if (res = _ObjectPlugin[type][i](object)) { if (res) {
object = res; object = res;
} }
} }
} }
return res || object; return res || object;
}, },
hasObject: function (type) { hasObject (type) {
return __GlobalObjectConfigFns.length > 0 || !!_ObjectPlugin[type]; return __GlobalObjectConfigFns.length > 0 || !!_ObjectPlugin[type];
}, },
registerObject: function (type, fn) { registerObject (type, fn) {
if (!_ObjectPlugin[type]) { if (!_ObjectPlugin[type]) {
_ObjectPlugin[type] = []; _ObjectPlugin[type] = [];
} }
@ -116,8 +121,7 @@ BI.Plugin = BI.Plugin || {};
_ObjectPlugin[type].push(fn); _ObjectPlugin[type].push(fn);
}, },
relieveObject: function (type) { relieveObject (type) {
delete _ObjectPlugin[type]; delete _ObjectPlugin[type];
} },
}); };
})();

15
src/core/action/action.js

@ -6,10 +6,11 @@
* @abstract * @abstract
*/ */
import { OB } from "../3.ob"; import { OB } from "../3.ob";
export class Action extends OB { export class Action extends OB {
props = { props = {
src: null, src: null,
tar: null tar: null,
}; };
actionPerformed(src, tar, callback) { actionPerformed(src, tar, callback) {
@ -20,15 +21,3 @@ export class Action extends OB {
} }
} }
BI.ActionFactory = {
createAction: function (key, options) {
var action;
switch (key) {
case "show":
action = BI.ShowAction;
break;
}
return new action(options);
}
};

17
src/core/action/action.show.js

@ -1,10 +1,9 @@
/** /**
* guy * guy
* 由一个元素切换到另一个元素的行为 * 由一个元素切换到另一个元素的行为
* @class BI.ShowAction
* @extends BI.Action
*/ */
import { Action } from "./action"; import { Action } from "./action";
export class ShowAction extends Action { export class ShowAction extends Action {
actionPerformed(src, tar, callback) { actionPerformed(src, tar, callback) {
tar = tar || this.options.tar; tar = tar || this.options.tar;
@ -18,3 +17,17 @@ export class ShowAction extends Action {
callback && callback(); callback && callback();
} }
} }
export const ActionFactory = {
createAction (key, options) {
let Action;
switch (key) {
case "show":
Action = ShowAction;
break;
default:
}
return new Action(options);
},
};

2
src/core/action/index.js

@ -1,2 +1,2 @@
export { Action } from "./action"; export { Action } from "./action";
export { ShowAction } from "./action.show"; export { ShowAction, ActionFactory } from "./action.show";

24
src/core/behavior/0.behavior.js

@ -1,30 +1,14 @@
BI.BehaviorFactory = {
createBehavior: function (key, options) {
var behavior;
switch (key) {
case "highlight":
behavior = BI.HighlightBehavior;
break;
case "redmark":
behavior = BI.RedMarkBehavior;
break;
}
return new behavior(options);
}
};
/** /**
* guy * guy
* 行为控件 * 行为控件
* @class BI.Behavior
* @extends BI.OB
*/ */
import { OB } from "../3.ob"; import { OB } from "../3.ob";
import { extend } from "../2.base";
export class Behavior extends OB { export class Behavior extends OB {
_defaultConfig() { _defaultConfig() {
return BI.extend(super._defaultConfig(arguments), { return extend(super._defaultConfig(arguments), {
rule: () => true rule: () => true,
}); });
} }

26
src/core/behavior/behavior.highlight.js

@ -1,33 +1,33 @@
/** /**
* guy * guy
*
* @class BI.HighlightBehavior
* @extends BI.Behavior
*/ */
import { Behavior } from "./0.behavior"; import { Behavior } from "./0.behavior";
import { isFunction, each } from "../2.base";
import { Single } from "../../base";
export class HighlightBehavior extends Behavior { export class HighlightBehavior extends Behavior {
doBehavior(items) { doBehavior(items) {
const args = Array.prototype.slice.call(arguments, 1), const args = Array.prototype.slice.call(arguments, 1),
o = this.options; { rule } = this.options;
BI.each(items, function (i, item) { each(items, (i, item) => {
if (item instanceof BI.Single) { if (item instanceof Single) {
const rule = o.rule(item.getValue(), item); const rules = rule(item.getValue(), item);
function doBe (run) { function doBe (run) {
if (run === true) { if (run === true) {
item.doHighLight && item.doHighLight.apply(item, args); item.doHighLight && item.doHighLight(...args);
} else { } else {
item.unHighLight && item.unHighLight.apply(item, args); item.unHighLight && item.unHighLight(...args);
} }
} }
if (BI.isFunction(rule)) { if (isFunction(rules)) {
rule(doBe); rules(doBe);
} else { } else {
doBe(rule); doBe(rules);
} }
} else { } else {
item.doBehavior && item.doBehavior.apply(item, args); item.doBehavior && item.doBehavior(...args);
} }
}); });
} }

19
src/core/behavior/behavior.redmark.js

@ -1,23 +1,24 @@
/** /**
* guy * guy
* 标红行为 * 标红行为
* @class BI.RedMarkBehavior
* @extends BI.Behavior
*/ */
import { Behavior } from "./0.behavior"; import { Behavior } from "./0.behavior";
import { each } from "../2.base";
import { Single } from "../../base";
export class RedMarkBehavior extends Behavior { export class RedMarkBehavior extends Behavior {
doBehavior(items) { doBehavior(items) {
const args = Array.prototype.slice.call(arguments, 1), const args = Array.prototype.slice.call(arguments, 1),
o = this.options; { rule } = this.options;
BI.each(items, function (i, item) { each(items, (i, item) => {
if(item instanceof BI.Single) { if (item instanceof Single) {
if (o.rule(item.getValue(), item)) { if (rule(item.getValue(), item)) {
item.doRedMark && item.doRedMark.apply(item, args); item.doRedMark && item.doRedMark(...args);
} else { } else {
item.doRedMark && item.unRedMark.apply(item, args); item.doRedMark && item.unRedMark(...args);
} }
} else { } else {
item.doBehavior && item.doBehavior.apply(item, args); item.doBehavior && item.doBehavior(...args);
} }
}); });
} }

27
src/core/behavior/index.js

@ -1,3 +1,26 @@
import { HighlightBehavior } from "./behavior.highlight";
import { RedMarkBehavior } from "./behavior.redmark";
export const BehaviorFactory = {
createBehavior (key, options) {
let Behavior;
switch (key) {
case "highlight":
Behavior = HighlightBehavior;
break;
case "redmark":
Behavior = RedMarkBehavior;
break;
default:
}
return new Behavior(options);
},
};
export { Behavior } from "./0.behavior"; export { Behavior } from "./0.behavior";
export { HighlightBehavior } from "./behavior.highlight"; export {
export { RedMarkBehavior } from "./behavior.redmark"; HighlightBehavior,
RedMarkBehavior
};

9
src/core/constant/events.js

@ -1,9 +1,7 @@
/** /**
* 事件集合 * 事件集合
* @class BI.Events
*/ */
BI._.extend(BI, { export const Events = {
Events: {
/** /**
* @static * @static
@ -439,6 +437,5 @@ BI._.extend(BI, {
* @static * @static
* @property 邮件发送后事件 * @property 邮件发送后事件
*/ */
AEMAIL: "afteremail" AEMAIL: "afteremail",
} };
});

2
src/core/constant/index.js

@ -0,0 +1,2 @@
export { Events } from "./events";
export * from "./var";

141
src/core/constant/var.js

@ -1,50 +1,22 @@
/** /**
* 常量 * 常量
*/ */
import { isNumber } from "../2.base";
BI._.extend(BI, { export const MAX = 0xfffffffffffffff;
MAX: 0xfffffffffffffff, export const MIN = -0xfffffffffffffff;
MIN: -0xfffffffffffffff, export const EVENT_RESPONSE_TIME = 200;
EVENT_RESPONSE_TIME: 200, export const EVENT_BLUR = true;
EVENT_BLUR: true, export const zIndex_layer = 1e5;
zIndex_layer: 1e5, export const zIndex_popover = 1e6;
zIndex_popover: 1e6, export const zIndex_popup = 1e7;
zIndex_popup: 1e7, export const zIndex_masker = 1e8;
zIndex_masker: 1e8, export const zIndex_tip = 1e9;
zIndex_tip: 1e9, export const emptyStr = "";
emptyStr: "", export const pixUnit = "px";
pixUnit: "px", export const pixRatio = 1;
pixRatio: 1, export const empty = null;
// 一定返回最终的单位 export const Key = {
pixFormat: function (pix, border) {
if (!BI.isNumber(pix)) {
return pix;
}
if (BI.pixUnit === "px") {
return (pix / BI.pixRatio - (border || 0)) + BI.pixUnit;
}
var length = pix / BI.pixRatio + BI.pixUnit;
if (border > 0) {
return `calc(${length} - ${border + "px"})`;
}
return length;
},
toPix: function (pix, border) {
if (!BI.isNumber(pix)) {
return pix;
}
if (BI.pixUnit === "px") {
return pix - (border || 0) * BI.pixRatio;
}
if (border > 0) {
return `calc(${pix / BI.pixRatio + BI.pixUnit} - ${border + "px"})`;
}
return pix;
},
emptyFn: function () {
},
empty: null,
Key: {
48: "0", 48: "0",
49: "1", 49: "1",
50: "2", 50: "2",
@ -95,9 +67,9 @@ BI._.extend(BI, {
107: "+", 107: "+",
109: "-", 109: "-",
110: ".", 110: ".",
111: "/" 111: "/",
}, };
KeyCode: { export const KeyCode = {
BACKSPACE: 8, BACKSPACE: 8,
COMMA: 188, COMMA: 188,
DELETE: 46, DELETE: 46,
@ -119,9 +91,9 @@ BI._.extend(BI, {
RIGHT: 39, RIGHT: 39,
SPACE: 32, SPACE: 32,
TAB: 9, TAB: 9,
UP: 38 UP: 38,
}, };
Status: { export const Status = {
SUCCESS: 1, SUCCESS: 1,
WRONG: 2, WRONG: 2,
START: 3, START: 3,
@ -130,38 +102,69 @@ BI._.extend(BI, {
READY: 6, READY: 6,
RUNNING: 7, RUNNING: 7,
OUTOFBOUNDS: 8, OUTOFBOUNDS: 8,
NULL: -1 NULL: -1,
}, };
Direction: { export const Direction = {
Top: "top", Top: "top",
Bottom: "bottom", Bottom: "bottom",
Left: "left", Left: "left",
Right: "right", Right: "right",
Custom: "custom" Custom: "custom",
}, };
Axis: { export const Axis = {
Vertical: "vertical", Vertical: "vertical",
Horizontal: "horizontal" Horizontal: "horizontal",
}, };
Selection: { export const Selection = {
Default: -2, Default: -2,
None: -1, None: -1,
Single: 0, Single: 0,
Multi: 1, Multi: 1,
All: 2 All: 2,
}, };
HorizontalAlign: { export const HorizontalAlign = {
Left: "left", Left: "left",
Right: "right", Right: "right",
Center: "center", Center: "center",
Stretch: "stretch" Stretch: "stretch",
}, };
VerticalAlign: { export const VerticalAlign = {
Middle: "middle", Middle: "middle",
Top: "top", Top: "top",
Bottom: "bottom", Bottom: "bottom",
Stretch: "stretch" Stretch: "stretch",
}, };
StartOfWeek: 1, export const StartOfWeek = 1;
BlankSplitChar: "\u200b \u200b", export const BlankSplitChar = "\u200b \u200b";
});
// 一定返回最终的单位
export function pixFormat(pix, border) {
if (!isNumber(pix)) {
return pix;
}
if (pixUnit === "px") {
return (pix / pixRatio - (border || 0)) + pixUnit;
}
const length = pix / pixRatio + pixUnit;
if (border > 0) {
return `calc(${length} - ${`${border}px`})`;
}
return length;
}
export function toPix(pix, border) {
if (!isNumber(pix)) {
return pix;
}
if (pixUnit === "px") {
return pix - (border || 0) * pixRatio;
}
if (border > 0) {
return `calc(${pix / pixRatio + pixUnit} - ${`${border}px`})`;
}
return pix;
}
export function emptyFn() {}

4
src/core/controller/0.controller.js

@ -2,11 +2,9 @@
* guy * guy
* 控制器 * 控制器
* Controller层超类 * Controller层超类
* @class BI.Controller
* @extends BI.OB
* @abstract
*/ */
import { OB } from "../3.ob"; import { OB } from "../3.ob";
export class Controller extends OB { export class Controller extends OB {
static EVENT_CHANGE = "__EVENT_CHANGE__"; static EVENT_CHANGE = "__EVENT_CHANGE__";
} }

9
src/core/controller/controller.broadcast.js

@ -2,9 +2,10 @@
* 广播 * 广播
* *
* Created by GUY on 2015/12/23. * Created by GUY on 2015/12/23.
* @class
*/ */
import { Controller } from "./0.controller"; import { Controller } from "./0.controller";
import { each, remove } from "../2.base";
export class BroadcastController extends Controller { export class BroadcastController extends Controller {
init() { init() {
this._broadcasts = {}; this._broadcasts = {};
@ -15,23 +16,25 @@ export class BroadcastController extends Controller {
this._broadcasts[name] = []; this._broadcasts[name] = [];
} }
this._broadcasts[name].push(fn); this._broadcasts[name].push(fn);
return () => this.remove(name, fn); return () => this.remove(name, fn);
} }
send(name) { send(name) {
const args = [].slice.call(arguments, 1); const args = [].slice.call(arguments, 1);
BI.each(this._broadcasts[name], (i, fn) => fn.apply(null, args)); each(this._broadcasts[name], (i, fn) => fn(...args));
} }
remove(name, fn) { remove(name, fn) {
if (fn) { if (fn) {
BI.remove(this._broadcasts[name], (index, cb) => fn === cb); remove(this._broadcasts[name], (index, cb) => fn === cb);
if (this._broadcasts[name].length === 0) { if (this._broadcasts[name].length === 0) {
delete this._broadcasts[name]; delete this._broadcasts[name];
} }
} else { } else {
delete this._broadcasts[name]; delete this._broadcasts[name];
} }
return this; return this;
} }
} }

38
src/core/controller/controller.bubbles.js

@ -3,9 +3,11 @@
* 控制气泡图的显示方向 * 控制气泡图的显示方向
* *
* Created by GUY on 2015/8/21. * Created by GUY on 2015/8/21.
* @class
*/ */
import { Controller } from "./0.controller"; import { Controller } from "./0.controller";
import { isNotNull, each } from "../2.base";
import { createWidget } from "../5.inject";
export class BubblesController extends Controller { export class BubblesController extends Controller {
init() { init() {
this.storeBubbles = {}; this.storeBubbles = {};
@ -30,12 +32,12 @@ export class BubblesController extends Controller {
// const fixed = opt.fixed !== false; // const fixed = opt.fixed !== false;
if (!this.storeBubbles[name]) { if (!this.storeBubbles[name]) {
this.storeBubbles[name] = BI.createWidget({ this.storeBubbles[name] = createWidget({
type: "bi.text", type: "bi.text",
cls: "bi-bubble" + " bubble-" + level, cls: `bi-bubble bubble-${level}`,
text: text, text,
hgap: 5, hgap: 5,
height: 18 height: 18,
}); });
} }
const bubble = this.storeBubbles[name]; const bubble = this.storeBubbles[name];
@ -43,14 +45,14 @@ export class BubblesController extends Controller {
bubble.setText(text); bubble.setText(text);
} }
BI.createWidget({ createWidget({
type: "bi.default", type: "bi.default",
element: container, element: container,
items: [ items: [
{ {
el: bubble el: bubble,
} }
] ],
}); });
if (this.storePoppers[name]) { if (this.storePoppers[name]) {
this.storePoppers[name].destroy(); this.storePoppers[name].destroy();
@ -59,32 +61,34 @@ export class BubblesController extends Controller {
placement: ({ placement: ({
left: "top-start", left: "top-start",
center: "top", center: "top",
right: "top-end" right: "top-end",
})[offsetStyle], })[offsetStyle],
strategy: "fixed", strategy: "fixed",
modifiers: [ modifiers: [
{ {
name: "offset", name: "offset",
options: { options: {
offset: [adjustXOffset, adjustYOffset] offset: [adjustXOffset, adjustYOffset],
} },
}, },
{ {
name: "preventOverflow", name: "preventOverflow",
enabled: false enabled: false,
} }
] ],
}); });
return this; return this;
} }
hide(name) { hide(name) {
this.remove(name); this.remove(name);
return this; return this;
} }
has(name) { has(name) {
return this.storeBubbles[name] != null; return isNotNull(this.storeBubbles[name]);
} }
remove(name) { remove(name) {
@ -94,14 +98,16 @@ export class BubblesController extends Controller {
this.storeBubbles[name].destroy(); this.storeBubbles[name].destroy();
this.storePoppers[name] && this.storePoppers[name].destroy(); this.storePoppers[name] && this.storePoppers[name].destroy();
delete this.storeBubbles[name]; delete this.storeBubbles[name];
return this; return this;
} }
removeAll() { removeAll() {
BI.each(this.storeBubbles, (name, bubble) => bubble.destroy()); each(this.storeBubbles, (name, bubble) => bubble.destroy());
BI.each(this.storePoppers, (name, popper) => popper.destroy()); each(this.storePoppers, (name, popper) => popper.destroy());
this.storeBubbles = {}; this.storeBubbles = {};
this.storePoppers = {}; this.storePoppers = {};
return this; return this;
} }
} }

38
src/core/controller/controller.drawer.js

@ -1,10 +1,11 @@
/** /**
* guy * guy
* popover弹出层控制器, z-index在100w层级 * popover弹出层控制器, z-index在100w层级
* @class BI.popoverController
* @extends BI.Controller
*/ */
import { Controller } from "./0.controller"; import { Controller } from "./0.controller";
import { each, isNotNull } from "../2.base";
import { createWidget } from "../5.inject";
export class DrawerController extends Controller { export class DrawerController extends Controller {
constructor() { constructor() {
super(); super();
@ -13,7 +14,7 @@ export class DrawerController extends Controller {
} }
props = { props = {
modal: true, // 模态窗口 modal: true, // 模态窗口
render: "body" render: "body",
} }
init() { init() {
@ -28,15 +29,15 @@ export class DrawerController extends Controller {
if (this.has(name)) { if (this.has(name)) {
return this; return this;
} }
const popover = BI.createWidget(options || {}, { const popover = createWidget(options || {}, {
type: "bi.drawer" type: "bi.drawer",
}, context); }, context);
this.add(name, popover, options, context); this.add(name, popover, options, context);
return this; return this;
} }
open(name) { open(name) {
const o = this.options;
if (!this.has(name)) { if (!this.has(name)) {
return this; return this;
} }
@ -59,6 +60,7 @@ export class DrawerController extends Controller {
const popover = this.get(name); const popover = this.get(name);
popover.show && popover.show(); popover.show && popover.show();
} }
return this; return this;
} }
@ -71,6 +73,7 @@ export class DrawerController extends Controller {
this.floatContainer[name].invisible(); this.floatContainer[name].invisible();
this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]);
} }
return this; return this;
} }
@ -91,23 +94,23 @@ export class DrawerController extends Controller {
if (this.has(name)) { if (this.has(name)) {
return this; return this;
} }
this.floatContainer[name] = BI.createWidget({ this.floatContainer[name] = createWidget({
type: "bi.absolute", type: "bi.absolute",
cls: "bi-popup-view", cls: "bi-popup-view",
items: [{ items: [{
el: (this.floatLayer[name] = BI.createWidget({ el: (this.floatLayer[name] = createWidget({
type: "bi.absolute", type: "bi.absolute",
items: [popover] items: [popover],
}, context)), }, context)),
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0,
}] }],
}); });
this.floatManager[name] = popover; this.floatManager[name] = popover;
popover.on(BI.Drawer.EVENT_CLOSE, () => this.close(name)); popover.on(BI.Drawer.EVENT_CLOSE, () => this.close(name));
BI.createWidget({ createWidget({
type: "bi.absolute", type: "bi.absolute",
element: options.container || this.options.render, element: options.container || this.options.render,
items: [{ items: [{
@ -115,9 +118,10 @@ export class DrawerController extends Controller {
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0,
}] }],
}); });
return this; return this;
} }
@ -126,7 +130,7 @@ export class DrawerController extends Controller {
} }
has(name) { has(name) {
return BI.isNotNull(this.floatManager[name]); return isNotNull(this.floatManager[name]);
} }
remove(name) { remove(name) {
@ -140,11 +144,12 @@ export class DrawerController extends Controller {
delete this.zindexMap[name]; delete this.zindexMap[name];
delete this.floatContainer[name]; delete this.floatContainer[name];
delete this.floatOpened[name]; delete this.floatOpened[name];
return this; return this;
} }
removeAll() { removeAll() {
BI.each(this.floatContainer, (name, container) => { each(this.floatContainer, (name, container) => {
container.destroy(); container.destroy();
this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]);
}); });
@ -153,6 +158,7 @@ export class DrawerController extends Controller {
this.floatContainer = {}; this.floatContainer = {};
this.floatOpened = {}; this.floatOpened = {};
this.zindexMap = {}; this.zindexMap = {};
return this; return this;
} }
} }

55
src/core/controller/controller.layer.js

@ -2,9 +2,12 @@
* 弹出层面板控制器, z-index在10w层级 * 弹出层面板控制器, z-index在10w层级
* *
* Created by GUY on 2015/6/24. * Created by GUY on 2015/6/24.
* @class
*/ */
import { Controller } from "./0.controller"; import { Controller } from "./0.controller";
import { isNull, isNotNull, each, keys, isWidget, isNotEmptyString, extend } from "../2.base";
import { Widget } from "../4.widget";
import { createWidget } from "../5.inject";
export class LayerController extends Controller { export class LayerController extends Controller {
constructor() { constructor() {
super(); super();
@ -12,7 +15,7 @@ export class LayerController extends Controller {
} }
props = { props = {
render: "body" render: "body",
} }
init() { init() {
@ -22,11 +25,11 @@ export class LayerController extends Controller {
} }
_initResizer() { _initResizer() {
this.resizer = BI.Resizers.add("layerController" + BI.uniqueId(), BI.bind(this._resize, this)); this.resizer = BI.Resizers.add(`layerController${BI.uniqueId()}`, BI.bind(this._resize, this));
} }
_resize() { _resize() {
BI.each(this.layouts, function (i, layer) { each(this.layouts, (i, layer) => {
if (layer.element.is(":visible")) { if (layer.element.is(":visible")) {
layer.element.trigger("__resize__"); layer.element.trigger("__resize__");
} }
@ -34,37 +37,38 @@ export class LayerController extends Controller {
} }
make(name, container, op, context) { make(name, container, op, context) {
if (BI.isWidget(container)) { if (isWidget(container)) {
op = op || {}; op = op || {};
op.container = container; op.container = container;
} else { } else {
context = op; context = op;
op = container; op = container;
} }
return this.create(name, null, op, context); return this.create(name, null, op, context);
} }
create(name, from, op, context) { create(name, from, op, context) {
BI.isNull(this.resizer) && this._initResizer(); isNull(this.resizer) && this._initResizer();
if (this.has(name)) { if (this.has(name)) {
return this.get(name); return this.get(name);
} }
op || (op = {}); op || (op = {});
const offset = op.offset || {}; const offset = op.offset || {};
let w = from; let w = from;
if (BI.isWidget(from)) { if (isWidget(from)) {
w = from.element; w = from.element;
} }
if (BI.isNotEmptyString(w)) { if (isNotEmptyString(w)) {
w = BI.Widget._renderEngine.createElement(w); w = Widget._renderEngine.createElement(w);
} }
if (this.has(name)) { if (this.has(name)) {
return this.get(name); return this.get(name);
} }
const widget = BI.createWidget((op.render || {}), BI.extend({ const widget = createWidget((op.render || {}), extend({
type: "bi.layout" type: "bi.layout",
}, op), context); }, op), context);
const layout = BI.createWidget({ const layout = createWidget({
type: "bi.absolute", type: "bi.absolute",
invisible: true, invisible: true,
items: [ items: [
@ -73,11 +77,11 @@ export class LayerController extends Controller {
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0,
} }
] ],
}, context); }, context);
BI.createWidget({ createWidget({
type: "bi.absolute", type: "bi.absolute",
element: op.container || this.options.render, element: op.container || this.options.render,
items: [ items: [
@ -86,20 +90,19 @@ export class LayerController extends Controller {
left: offset.left || 0, left: offset.left || 0,
right: offset.right || 0, right: offset.right || 0,
top: offset.top || 0, top: offset.top || 0,
bottom: offset.bottom || 0 bottom: offset.bottom || 0,
} }
] ],
}); });
if (w) { if (w) {
layout.element.addClass("bi-popup-view"); layout.element.addClass("bi-popup-view");
function getComputedPosition() { function getComputedPosition() {
const css = {
var css = {
left: w.offset().left + (offset.left || 0), left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0), top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "", width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || "" height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || "",
}; };
const { top, left, scaleY, scaleX } = BI.DOM.getPositionRelativeContainingBlockRect(layout.element[0]); const { top, left, scaleY, scaleX } = BI.DOM.getPositionRelativeContainingBlockRect(layout.element[0]);
@ -112,12 +115,13 @@ export class LayerController extends Controller {
layout.element.css(getComputedPosition()); layout.element.css(getComputedPosition());
layout.element.on("__resize__", function () { layout.element.on("__resize__", () => {
w.is(":visible") && w.is(":visible") &&
layout.element.css(getComputedPosition()); layout.element.css(getComputedPosition());
}); });
} }
this.add(name, widget, layout); this.add(name, widget, layout);
return widget; return widget;
} }
@ -127,6 +131,7 @@ export class LayerController extends Controller {
} }
this._getLayout(name).visible(); this._getLayout(name).visible();
this._getLayout(name).element.css("z-index", this.zindex++).show(0, callback).trigger("__resize__"); this._getLayout(name).element.css("z-index", this.zindex++).show(0, callback).trigger("__resize__");
return this; return this;
} }
@ -136,6 +141,7 @@ export class LayerController extends Controller {
} }
this._getLayout(name).invisible(); this._getLayout(name).invisible();
this._getLayout(name).element.hide(0, callback); this._getLayout(name).element.hide(0, callback);
return this; return this;
} }
@ -151,6 +157,7 @@ export class LayerController extends Controller {
this.layerManager[name] = layer; this.layerManager[name] = layer;
this.layouts[name] = layout; this.layouts[name] = layout;
layout.element.css("z-index", this.zindex++); layout.element.css("z-index", this.zindex++);
return this; return this;
} }
@ -163,7 +170,7 @@ export class LayerController extends Controller {
} }
has(name) { has(name) {
return this.layerManager[name] != null; return isNotNull(this.layerManager[name]);
} }
remove(name) { remove(name) {
@ -174,16 +181,18 @@ export class LayerController extends Controller {
this.layouts[name].destroy(); this.layouts[name].destroy();
delete this.layerManager[name]; delete this.layerManager[name];
delete this.layouts[name]; delete this.layouts[name];
return this; return this;
} }
removeAll() { removeAll() {
BI.each(BI.keys(this.layerManager), (index, name) => { each(keys(this.layerManager), (index, name) => {
this.layerManager[name].destroy(); this.layerManager[name].destroy();
this.layouts[name].destroy(); this.layouts[name].destroy();
}); });
this.layerManager = {}; this.layerManager = {};
this.layouts = {}; this.layouts = {};
return this; return this;
} }
} }

2
src/core/controller/controller.masker.js

@ -2,9 +2,9 @@
* 遮罩面板, z-index在1亿层级 * 遮罩面板, z-index在1亿层级
* *
* Created by GUY on 2015/6/24. * Created by GUY on 2015/6/24.
* @class
*/ */
import { LayerController } from "./controller.layer"; import { LayerController } from "./controller.layer";
export class MaskersController extends LayerController { export class MaskersController extends LayerController {
init() { init() {
super.init(arguments); super.init(arguments);

46
src/core/controller/controller.popover.js

@ -1,10 +1,12 @@
/** /**
* guy * guy
* popover弹出层控制器, z-index在100w层级 * popover弹出层控制器, z-index在100w层级
* @class BI.popoverController
* @extends BI.Controller
*/ */
import { Controller } from "./0.controller"; import { Controller } from "./0.controller";
import { isNotNull, each } from "../2.base";
import { Widget } from "../4.widget";
import { createWidget } from "../5.inject";
export class PopoverController extends Controller { export class PopoverController extends Controller {
constructor() { constructor() {
super(); super();
@ -14,7 +16,7 @@ export class PopoverController extends Controller {
props = { props = {
modal: true, // 模态窗口 modal: true, // 模态窗口
render: "body" render: "body",
} }
init() { init() {
@ -30,10 +32,11 @@ export class PopoverController extends Controller {
if (this.has(name)) { if (this.has(name)) {
return this; return this;
} }
const popover = BI.createWidget(options || {}, { const popover = createWidget(options || {}, {
type: "bi.popover" type: "bi.popover",
}, context); }, context);
this.add(name, popover, options, context); this.add(name, popover, options, context);
return this; return this;
} }
@ -52,8 +55,8 @@ export class PopoverController extends Controller {
this.floatContainer[name].visible(); this.floatContainer[name].visible();
const popover = this.get(name); const popover = this.get(name);
popover.show && popover.show(); popover.show && popover.show();
const W = BI.Widget._renderEngine.createElement(this.options.render).width(), const W = Widget._renderEngine.createElement(this.options.render).width(),
H = BI.Widget._renderEngine.createElement(this.options.render).height(); H = Widget._renderEngine.createElement(this.options.render).height();
const w = popover.element.width(), h = popover.element.height(); const w = popover.element.width(), h = popover.element.height();
let left = (W - w) / 2, top = (H - h) / 2; let left = (W - w) / 2, top = (H - h) / 2;
if (left < 0) { if (left < 0) {
@ -64,10 +67,11 @@ export class PopoverController extends Controller {
} }
popover.element.css({ popover.element.css({
// 这里直接用px就可以 // 这里直接用px就可以
left: left + "px", left: `${left}px`,
top: top + "px" top: `${top}px`,
}); });
} }
return this; return this;
} }
@ -80,6 +84,7 @@ export class PopoverController extends Controller {
this.floatContainer[name].invisible(); this.floatContainer[name].invisible();
this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]);
} }
return this; return this;
} }
@ -100,23 +105,23 @@ export class PopoverController extends Controller {
if (this.has(name)) { if (this.has(name)) {
return this; return this;
} }
this.floatContainer[name] = BI.createWidget({ this.floatContainer[name] = createWidget({
type: "bi.absolute", type: "bi.absolute",
cls: "bi-popup-view", cls: "bi-popup-view",
items: [{ items: [{
el: (this.floatLayer[name] = BI.createWidget({ el: (this.floatLayer[name] = createWidget({
type: "bi.absolute", type: "bi.absolute",
items: [popover] items: [popover],
}, context)), }, context)),
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0,
}] }],
}); });
this.floatManager[name] = popover; this.floatManager[name] = popover;
popover.on(BI.Popover.EVENT_CLOSE, () => this.close(name)); popover.on(BI.Popover.EVENT_CLOSE, () => this.close(name));
BI.createWidget({ createWidget({
type: "bi.absolute", type: "bi.absolute",
element: options.container || this.options.render, element: options.container || this.options.render,
items: [{ items: [{
@ -124,9 +129,10 @@ export class PopoverController extends Controller {
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0,
}] }],
}); });
return this; return this;
} }
@ -135,7 +141,7 @@ export class PopoverController extends Controller {
} }
has(name) { has(name) {
return BI.isNotNull(this.floatManager[name]); return isNotNull(this.floatManager[name]);
} }
remove(name) { remove(name) {
@ -149,11 +155,12 @@ export class PopoverController extends Controller {
delete this.zindexMap[name]; delete this.zindexMap[name];
delete this.floatContainer[name]; delete this.floatContainer[name];
delete this.floatOpened[name]; delete this.floatOpened[name];
return this; return this;
} }
removeAll() { removeAll() {
BI.each(this.floatContainer, (name, container) => { each(this.floatContainer, (name, container) => {
container.destroy(); container.destroy();
this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]);
}); });
@ -162,6 +169,7 @@ export class PopoverController extends Controller {
this.floatContainer = {}; this.floatContainer = {};
this.floatOpened = {}; this.floatOpened = {};
this.zindexMap = {}; this.zindexMap = {};
return this; return this;
} }

21
src/core/controller/controller.resizer.js

@ -2,49 +2,53 @@
* window.resize 控制器 * window.resize 控制器
* *
* Created by GUY on 2015/6/24. * Created by GUY on 2015/6/24.
* @class
*/ */
import { Controller } from "./0.controller"; import { Controller } from "./0.controller";
export class ResizeController extends Controller { import { isNull, each, debounce, isNotNull, isFunction } from "../2.base";
import { Widget } from "../4.widget";
export class ResizeController extends Controller {
init() { init() {
this.resizerManger = {}; this.resizerManger = {};
} }
_initResizeListener() { _initResizeListener() {
this.resizeHandler = BI.debounce((ev) => this._resize(ev), 30); this.resizeHandler = debounce(ev => this._resize(ev), 30);
if ("onorientationchange" in _global) { if ("onorientationchange" in _global) {
_global.onorientationchange = this.resizeHandler; _global.onorientationchange = this.resizeHandler;
} else { } else {
BI.Widget._renderEngine.createElement(_global).resize(this.resizeHandler); Widget._renderEngine.createElement(_global).resize(this.resizeHandler);
} }
} }
_resize(ev) { _resize(ev) {
BI.each(this.resizerManger, function (key, resizer) { each(this.resizerManger, (key, resizer) => {
if (resizer instanceof BI.$) { if (resizer instanceof BI.$) {
if (resizer.is(":visible")) { if (resizer.is(":visible")) {
resizer.trigger("__resize__"); resizer.trigger("__resize__");
} }
return; return;
} }
if (resizer instanceof BI.Layout) { if (resizer instanceof BI.Layout) {
resizer.resize(); resizer.resize();
return; return;
} }
if (BI.isFunction(resizer)) { if (isFunction(resizer)) {
resizer(ev); resizer(ev);
} }
}); });
} }
add(name, resizer) { add(name, resizer) {
BI.isNull(this.resizeHandler) && this._initResizeListener(); isNull(this.resizeHandler) && this._initResizeListener();
if (this.has(name)) { if (this.has(name)) {
return this; return this;
} }
this.resizerManger[name] = resizer; this.resizerManger[name] = resizer;
return () => this.remove(name); return () => this.remove(name);
} }
@ -53,7 +57,7 @@ export class ResizeController extends Controller {
} }
has(name) { has(name) {
return this.resizerManger[name] != null; return isNotNull(this.resizerManger[name]);
} }
remove(name) { remove(name) {
@ -61,6 +65,7 @@ export class ResizeController extends Controller {
return this; return this;
} }
delete this.resizerManger[name]; delete this.resizerManger[name];
return this; return this;
} }
} }

40
src/core/controller/controller.tooltips.js

@ -3,10 +3,12 @@
* 控制tooltip的显示, 且页面中只有一个tooltip显示 * 控制tooltip的显示, 且页面中只有一个tooltip显示
* *
* Created by GUY on 2015/9/8. * Created by GUY on 2015/9/8.
* @class BI.TooltipsController
* @extends BI.Controller
*/ */
import { Controller } from "./0.controller"; import { Controller } from "./0.controller";
import { each, isNotNull } from "../2.base";
import { Widget } from "../4.widget";
import { createWidget } from "../5.inject";
export class TooltipsController extends Controller { export class TooltipsController extends Controller {
init() { init() {
this.tooltipsManager = {}; this.tooltipsManager = {};
@ -23,17 +25,17 @@ export class TooltipsController extends Controller {
* @private * @private
*/ */
_createTooltip(opt) { _createTooltip(opt) {
return BI.createWidget({ return createWidget({
type: "bi.tooltip", type: "bi.tooltip",
...opt, ...opt,
stopEvent: true stopEvent: true,
}); });
} }
// opt: {container: '', belowMouse: false} // opt: {container: '', belowMouse: false}
show(e, name, tooltipOpt, context, opt) { show(e, name, tooltipOpt, context, opt) {
opt || (opt = {}); opt || (opt = {});
BI.each(this.showingTips, (i, tip) => this.hide(i)); each(this.showingTips, (i, tip) => this.hide(i));
this.showingTips = {}; this.showingTips = {};
if (!this.has(name)) { if (!this.has(name)) {
this.create(name, tooltipOpt, document.fullscreenElement ? context : (opt.container || "body")); this.create(name, tooltipOpt, document.fullscreenElement ? context : (opt.container || "body"));
@ -51,7 +53,7 @@ export class TooltipsController extends Controller {
const tooltip = this.get(name); const tooltip = this.get(name);
tooltip.element.css({ tooltip.element.css({
left: "0px", left: "0px",
top: "0px" top: "0px",
}); });
tooltip.visible(); tooltip.visible();
tooltip.element.height(tooltip.element[0].scrollHeight); tooltip.element.height(tooltip.element[0].scrollHeight);
@ -60,10 +62,10 @@ export class TooltipsController extends Controller {
// const scale = context.element.offset().left / context.element.get(0).getBoundingClientRect().left; // const scale = context.element.offset().left / context.element.get(0).getBoundingClientRect().left;
// const x = (e.pageX || e.clientX) * scale + 15, y = (e.pageY || e.clientY) * scale + 15; // const x = (e.pageX || e.clientX) * scale + 15, y = (e.pageY || e.clientY) * scale + 15;
let x = (e.pageX || e.clientX) + 15, y = (e.pageY || e.clientY) + 15; let x = (e.pageX || e.clientX) + 15, y = (e.pageY || e.clientY) + 15;
if (x + tooltip.element.outerWidth() > BI.Widget._renderEngine.createElement("body").outerWidth()) { if (x + tooltip.element.outerWidth() > Widget._renderEngine.createElement("body").outerWidth()) {
x -= tooltip.element.outerWidth() + 15; x -= tooltip.element.outerWidth() + 15;
} }
const bodyHeight = BI.Widget._renderEngine.createElement("body").outerHeight(); const bodyHeight = Widget._renderEngine.createElement("body").outerHeight();
if (y + tooltip.element.outerHeight() > bodyHeight || top + tooltip.element.outerHeight() > bodyHeight) { if (y + tooltip.element.outerHeight() > bodyHeight || top + tooltip.element.outerHeight() > bodyHeight) {
y -= tooltip.element.outerHeight() + 15; y -= tooltip.element.outerHeight() + 15;
!opt.belowMouse && (y = Math.min(y, offset.top - tooltip.element.outerHeight() - 5)); !opt.belowMouse && (y = Math.min(y, offset.top - tooltip.element.outerHeight() - 5));
@ -72,13 +74,14 @@ export class TooltipsController extends Controller {
} }
tooltip.element.css({ tooltip.element.css({
// 这里直接用px就可以 // 这里直接用px就可以
left: x < 0 ? 0 : x + "px", left: x < 0 ? 0 : `${x}px`,
top: y < 0 ? 0 : y + "px" top: y < 0 ? 0 : `${y}px`,
}); });
tooltip.element.hover(() => { tooltip.element.hover(() => {
this.remove(name); this.remove(name);
context.element.trigger("mouseleave.title" + context.getName()); context.element.trigger(`mouseleave.title${context.getName()}`);
}); });
return this; return this;
} }
@ -89,6 +92,7 @@ export class TooltipsController extends Controller {
delete this.showingTips[name]; delete this.showingTips[name];
this.get(name).element.hide(0, callback); this.get(name).element.hide(0, callback);
this.get(name).invisible(); this.get(name).invisible();
return this; return this;
} }
@ -96,15 +100,16 @@ export class TooltipsController extends Controller {
if (!this.has(name)) { if (!this.has(name)) {
const tooltip = this._createTooltip(tooltipOpt); const tooltip = this._createTooltip(tooltipOpt);
this.add(name, tooltip); this.add(name, tooltip);
BI.createWidget({ createWidget({
type: "bi.absolute", type: "bi.absolute",
element: context || "body", element: context || "body",
items: [{ items: [{
el: tooltip el: tooltip,
}] }],
}); });
tooltip.invisible(); tooltip.invisible();
} }
return this.get(name); return this.get(name);
} }
@ -113,6 +118,7 @@ export class TooltipsController extends Controller {
return this; return this;
} }
this.set(name, bubble); this.set(name, bubble);
return this; return this;
} }
@ -125,7 +131,7 @@ export class TooltipsController extends Controller {
} }
has(name) { has(name) {
return this.tooltipsManager[name] != null; return isNotNull(this.tooltipsManager[name]);
} }
remove(name) { remove(name) {
@ -134,15 +140,17 @@ export class TooltipsController extends Controller {
} }
this.tooltipsManager[name].destroy(); this.tooltipsManager[name].destroy();
delete this.tooltipsManager[name]; delete this.tooltipsManager[name];
return this; return this;
} }
removeAll() { removeAll() {
BI.each(this.tooltipsManager, function (name, tooltip) { each(this.tooltipsManager, (name, tooltip) => {
tooltip.destroy(); tooltip.destroy();
}); });
this.tooltipsManager = {}; this.tooltipsManager = {};
this.showingTips = {}; this.showingTips = {};
return this; return this;
} }
} }

14
src/core/decorator.js

@ -1,9 +1,21 @@
// export * from "../../typescript/core/decorator/decorator.ts";
import { shortcut as biShortcut, provider as biProvider } from "./5.inject";
/** /**
* 注册widget * 注册widget
*/ */
import { shortcut as biShortcut } from "./5.inject";
export function shortcut() { export function shortcut() {
return function decorator(Target) { return function decorator(Target) {
biShortcut(Target.xtype, Target); biShortcut(Target.xtype, Target);
}; };
} }
/**
* 注册provider
*/
export function provider() {
return function decorator(Target) {
biProvider(Target.xtype, Target);
};
}

24
src/core/element/element.js

@ -1,8 +1,9 @@
import { registFunction } from './plugins'; import { registFunction } from "./plugins";
import { isWidget, isString } from "../2.base";
export function Element(widget, attribs) { export function Element(widget, attribs) {
this.l = this.r = this.t = this.b = 0; // 边框 this.l = this.r = this.t = this.b = 0; // 边框
this.marginLeft = this.marginRight = this.marginTop = this.marginBottom = 0; //间距 this.marginLeft = this.marginRight = this.marginTop = this.marginBottom = 0; // 间距
this.position = {}; this.position = {};
this.classMap = {}; this.classMap = {};
this.classList = []; this.classList = [];
@ -10,18 +11,18 @@ export function Element(widget, attribs) {
this.attribs = attribs || {}; this.attribs = attribs || {};
this.styles = {}; this.styles = {};
// 兼容处理 // 兼容处理
this['0'] = this; this["0"] = this;
this.style = {}; this.style = {};
if (!widget) { if (!widget) {
this.nodeName = 'body'; this.nodeName = "body";
this.position.x = 0; this.position.x = 0;
this.position.y = 0; this.position.y = 0;
this.attribs.id = 'body'; this.attribs.id = "body";
} else if (BI.isWidget(widget)) { } else if (isWidget(widget)) {
this.widget = widget; this.widget = widget;
this.nodeName = widget.options.tagName; this.nodeName = widget.options.tagName;
this.textBaseLine = widget.options.textBaseLine; this.textBaseLine = widget.options.textBaseLine;
} else if (BI.isString(widget)) { } else if (isString(widget)) {
this.nodeName = widget; this.nodeName = widget;
} }
} }
@ -34,7 +35,7 @@ function initElement(element) {
appendChild(child) { appendChild(child) {
child.parent = this; child.parent = this;
if (this.children.push(child) !== 1) { if (this.children.push(child) !== 1) {
var sibling = this.children[this.children.length - 2]; const sibling = this.children[this.children.length - 2];
sibling.next = child; sibling.next = child;
child.prev = sibling; child.prev = sibling;
child.next = null; child.next = null;
@ -43,7 +44,7 @@ function initElement(element) {
append(child) { append(child) {
child.parent = this; child.parent = this;
if (this.children.push(child) !== 1) { if (this.children.push(child) !== 1) {
var sibling = this.children[this.children.length - 2]; const sibling = this.children[this.children.length - 2];
sibling.next = child; sibling.next = child;
child.prev = sibling; child.prev = sibling;
child.next = null; child.next = null;
@ -53,7 +54,8 @@ function initElement(element) {
return this.parent; return this.parent;
}, },
getSiblings() { getSiblings() {
var parent = this.getParent(); const parent = this.getParent();
return parent ? parent.getChildren() : [this]; return parent ? parent.getChildren() : [this];
}, },
getChildren() { getChildren() {
@ -69,6 +71,6 @@ function initElement(element) {
}, },
height() { height() {
} },
}; };
} }

26
src/core/element/index.js

@ -1,16 +1,16 @@
import { Element } from './element'; import { Element } from "./element";
import { isString, isWidget } from "../2.base";
BI.Element = Element; Element.renderEngine = {
BI.Element.renderEngine = { createElement: widget => {
createElement: (widget) => { if (isWidget(widget)) {
// eslint-disable-next-line no-undef const o = widget.options;
if (BI.isWidget(widget)) {
var o = widget.options;
if (o.element instanceof Element) { if (o.element instanceof Element) {
return o.element; return o.element;
} }
if (typeof o.element === 'string' && o.element !== 'body') { if (typeof o.element === "string" && o.element !== "body") {
o.root = false; o.root = false;
return new Element(widget); return new Element(widget);
} }
@ -18,14 +18,16 @@ BI.Element.renderEngine = {
return new Element(); return new Element();
} }
} }
// eslint-disable-next-line no-undef if (isString(widget)) {
if (BI.isString(widget)) {
return new Element(widget); return new Element(widget);
} }
return new Element(widget); return new Element(widget);
}, },
createFragment() { createFragment() {
return new Element(); return new Element();
} },
} };
export { Element };

23
src/core/element/plugins/attr.js

@ -1,22 +1,25 @@
export const registAttrFun = (Element) => { import { isObject, each, isNull, isNotNull } from "../../2.base";
Element.registerFunction('attr', function (key, value) {
var self = this; export const registAttrFun = Element => {
if (BI.isObject(key)) { Element.registerFunction("attr", function (key, value) {
BI.each(key, (k, v) => { if (isObject(key)) {
self.attr(k, v); each(key, (k, v) => {
this.attr(k, v);
}); });
return this; return this;
} }
if (BI.isNull(value)) { if (isNull(value)) {
return this.attribs[key]; return this.attribs[key];
} }
this.attribs[key] = value; this.attribs[key] = value;
return this; return this;
}); });
Element.registerFunction('hasAttrib', function (key) { Element.registerFunction("hasAttrib", function (key) {
return this.attribs[key] != null; return isNotNull(this.attribs[key]);
}); });
Element.registerFunction('removeAttr', function (key) { Element.registerFunction("removeAttr", function (key) {
delete this.attribs[key]; delete this.attribs[key];
}); });
}; };

26
src/core/element/plugins/class.js

@ -1,23 +1,23 @@
export const registClassFun = (Element) => { export const registClassFun = Element => {
Element.registerFunction('addClass', function (classList) { Element.registerFunction("addClass", function (classList) {
var self = this; BI.each(classList.split(" "), (i, cls) => {
BI.each(classList.split(' '), (i, cls) => { if (cls && !this.classMap[cls]) {
if (cls && !self.classMap[cls]) { this.classList.push(cls);
self.classList.push(cls);
} }
cls && (self.classMap[cls] = true); cls && (this.classMap[cls] = true);
}); });
return this; return this;
}); });
Element.registerFunction('removeClass', function (classList) { Element.registerFunction("removeClass", function (classList) {
var self = this; BI.each(classList.split(" "), (i, cls) => {
BI.each(classList.split(' '), (i, cls) => { if (cls && this.classMap[cls]) {
if (cls && self.classMap[cls]) { delete this.classMap[cls];
delete self.classMap[cls]; this.classList.splice(this.classList.indexOf(cls), 1);
self.classList.splice(self.classList.indexOf(cls), 1);
} }
}); });
return this; return this;
}); });
}; };

22
src/core/element/plugins/css.js

@ -1,22 +1,26 @@
export const registCssFun = (Element) => { import { isNull, isObject, each, trim, camelize } from "../../2.base";
Element.registerFunction('css', function (key, value) {
var self = this; export const registCssFun = Element => {
if (BI.isObject(key)) { Element.registerFunction("css", function (key, value) {
BI.each(key, (k, v) => { if (isObject(key)) {
self.css(k, v); each(key, (k, v) => {
this.css(k, v);
}); });
return this; return this;
} }
key = BI.trim(BI.camelize(key)); key = trim(camelize(key));
return css(this, key, value); return css(this, key, value);
}); });
}; };
const css = (elem, key, value) => { const css = (elem, key, value) => {
key = BI.trim(BI.camelize(key)); key = trim(camelize(key));
if (BI.isNull(value)) { if (isNull(value)) {
return elem.styles[key]; return elem.styles[key];
} }
elem.styles[key] = value; elem.styles[key] = value;
return elem; return elem;
}; };

9
src/core/element/plugins/data.js

@ -1,12 +1,15 @@
export const registDataFun = (Element) => { import { isNull } from "../../2.base";
Element.registerFunction('data', function (key, value) {
export const registDataFun = Element => {
Element.registerFunction("data", function (key, value) {
if (!this._data) { if (!this._data) {
this._data = {}; this._data = {};
} }
if (BI.isNull(value)) { if (isNull(value)) {
return this._data[key]; return this._data[key];
} }
this._data[key] = value; this._data[key] = value;
return this; return this;
}); });
}; };

7
src/core/element/plugins/empty.js

@ -1,9 +1,10 @@
export const registEmptyFun = (Element) => { export const registEmptyFun = Element => {
Element.registerFunction('empty', function (text) { Element.registerFunction("empty", function (text) {
this.children = []; this.children = [];
return this; return this;
}); });
Element.registerFunction('destroy', function (text) { Element.registerFunction("destroy", function (text) {
return this; return this;
}); });
}; };

55
src/core/element/plugins/event.js

@ -1,32 +1,33 @@
var returnThis = function () { function returnThis () {
return this; return this;
}; }
export const registEventFun = (Element) => {
export const registEventFun = Element => {
[ [
'mousedown', "mousedown",
'mouseup', "mouseup",
'mousewheel', "mousewheel",
'keydown', "keydown",
'keyup', "keyup",
'focus', "focus",
'focusin', "focusin",
'focusout', "focusout",
'click', "click",
'on', "on",
'off', "off",
'bind', "bind",
'unbind', "unbind",
'trigger', "trigger",
'hover', "hover",
'scroll', "scroll",
'scrollLeft', "scrollLeft",
'scrollTop', "scrollTop",
'resize', "resize",
'show', "show",
'hide', "hide",
'dblclick', "dblclick",
'blur', "blur"
].forEach((event) => { ].forEach(event => {
Element.registerFunction(event, returnThis); Element.registerFunction(event, returnThis);
}); });
}; };

16
src/core/element/plugins/html.js

@ -1,15 +1,19 @@
export const registHtmlFun = (Element) => { import { createWidget } from "../../5.inject";
Element.registerFunction('html', function (text) { import { htmlDecode } from "../../func";
if (text && text.charAt(0) === '<') {
BI.createWidget({ export const registHtmlFun = Element => {
type: 'bi.html', Element.registerFunction("html", function (text) {
if (text && text.charAt(0) === "<") {
createWidget({
type: "bi.html",
element: this.widget, element: this.widget,
html: text, html: text,
}); });
this.originalHtml = text; this.originalHtml = text;
} else { } else {
this.text = BI.htmlDecode(text); this.text = htmlDecode(text);
} }
return this; return this;
}); });
}; };

28
src/core/element/plugins/index.js

@ -1,18 +1,18 @@
import { registAttrFun } from './attr'; import { registAttrFun } from "./attr";
import { registClassFun } from './class'; import { registClassFun } from "./class";
import { registCssFun } from './css'; import { registCssFun } from "./css";
import { registDataFun } from './data'; import { registDataFun } from "./data";
import { registEmptyFun } from './empty'; import { registEmptyFun } from "./empty";
import { registEventFun } from './event'; import { registEventFun } from "./event";
import { registHtmlFun } from './html'; import { registHtmlFun } from "./html";
import { registKeywordMarkFun } from './keywordMark'; import { registKeywordMarkFun } from "./keywordMark";
import { registRenderToHtmlFun } from './renderToHtml'; import { registRenderToHtmlFun } from "./renderToHtml";
import { registRenderToStringFun } from './renderToString'; import { registRenderToStringFun } from "./renderToString";
import { registTextFun } from './text'; import { registTextFun } from "./text";
import { registValFun } from './val'; import { registValFun } from "./val";
export const registFunction = (Element) => { export const registFunction = Element => {
var functionMap = {}; const functionMap = {};
Element.registerFunction = (key, fn) => { Element.registerFunction = (key, fn) => {
Element.prototype[key] = functionMap[key] = fn; Element.prototype[key] = functionMap[key] = fn;
}; };

5
src/core/element/plugins/keywordMark.js

@ -1,6 +1,7 @@
export const registKeywordMarkFun = (Element) => { export const registKeywordMarkFun = Element => {
Element.registerFunction('__textKeywordMarked__', function (text) { Element.registerFunction("__textKeywordMarked__", function (text) {
this[0].textContent = text; this[0].textContent = text;
return this; return this;
}); });
}; };

58
src/core/element/plugins/renderToHtml.js

@ -1,65 +1,69 @@
var skipArray = []; import { each, isNull, hyphenate, isNumeric, isKey } from "../../2.base";
var pxStyle = ['font-size', 'width', 'height'];
var _renderToHtml = function (root) { const skipArray = [];
var str = ''; const pxStyle = ["font-size", "width", "height"];
if (BI.isNull(root.originalHtml)) { function _renderToHtml(root) {
if (root.tag !== 'body') { let str = "";
if (isNull(root.originalHtml)) {
if (root.tag !== "body") {
str += `<${root.tag}`; str += `<${root.tag}`;
if (root.classList.length > 0) { if (root.classList.length > 0) {
str += ' class="'; str += " class=\"";
BI.each(root.classList, (i, cls) => { each(root.classList, (i, cls) => {
str += ` ${cls}`; str += ` ${cls}`;
}); });
str += '"'; str += "\"";
} }
str += ' style="'; str += " style=\"";
BI.each(root.originalStyles, (key, stl) => { each(root.originalStyles, (key, stl) => {
if ( if (
skipArray.contains(key) || skipArray.contains(key) ||
(key == 'height' && root.classList.contains('bi-design-components-data-data-table-cell')) (key === "height" && root.classList.contains("bi-design-components-data-data-table-cell"))
) { ) {
return; return;
} }
key = BI.hyphenate(key); key = hyphenate(key);
if (key === 'font-family') { if (key === "font-family") {
stl = stl.replace(/\"/g, ''); stl = stl.replace(/"/g, "");
} }
if (pxStyle.contains(key) && BI.isNumeric(stl)) { if (pxStyle.contains(key) && isNumeric(stl)) {
stl += 'px'; stl += "px";
} }
if (BI.isKey(stl)) { if (isKey(stl)) {
str += ` ${key}:${stl};`; str += ` ${key}:${stl};`;
} }
}); });
str += '"'; str += "\"";
BI.each(root.attribs, (key, attr) => { each(root.attribs, (key, attr) => {
if (BI.isKey(attr)) { if (isKey(attr)) {
str += ` ${key}=${attr}`; str += ` ${key}=${attr}`;
} }
}); });
if (root.textContent) { if (root.textContent) {
str += ` title=${root.textContent}`; str += ` title=${root.textContent}`;
} }
str += '>'; str += ">";
} }
// 特殊处理,spread_table的行列元素是不取配置里的高度的,使用stretch拉伸的(leaves取了高度),但是功能代码里给单元格默认高度了,导致拉伸不了 // 特殊处理,spread_table的行列元素是不取配置里的高度的,使用stretch拉伸的(leaves取了高度),但是功能代码里给单元格默认高度了,导致拉伸不了
// 而spread_grid_table的行列元素是取配置里的高度的,拉不拉伸都一样 // 而spread_grid_table的行列元素是取配置里的高度的,拉不拉伸都一样
BI.each(root.children, (i, child) => { each(root.children, (i, child) => {
str += _renderToHtml(child); str += _renderToHtml(child);
}); });
} else { } else {
str += root.originalHtml; str += root.originalHtml;
} }
if (root.tag !== 'body') { if (root.tag !== "body") {
if (root.textContent) { if (root.textContent) {
str += root.textContent; str += root.textContent;
} }
str += `</${root.tag}>`; str += `</${root.tag}>`;
} }
return str; return str;
}; }
export const registRenderToHtmlFun = (Element) => {
Element.registerFunction('renderToHtml', function () { export const registRenderToHtmlFun = Element => {
Element.registerFunction("renderToHtml", function () {
return _renderToHtml(this); return _renderToHtml(this);
}); });
}; };

42
src/core/element/plugins/renderToString.js

@ -1,50 +1,54 @@
var skipArray = ['width', 'height']; import { each, hyphenate } from "../../2.base";
var _renderToString = function (root) {
var str = ''; const skipArray = ["width", "height"];
if (root.nodeName !== 'body') { function _renderToString(root) {
let str = "";
if (root.nodeName !== "body") {
str += `<${root.nodeName}`; str += `<${root.nodeName}`;
if (root.classList.length > 0) { if (root.classList.length > 0) {
str += ' class="'; str += " class=\"";
BI.each(root.classList, (i, cls) => { each(root.classList, (i, cls) => {
str += ` ${cls}`; str += ` ${cls}`;
}); });
str += '"'; str += "\"";
} }
str += ' style="'; str += " style=\"";
BI.each(root.styles, (key, stl) => { each(root.styles, (key, stl) => {
if (skipArray.includes(key)) { if (skipArray.includes(key)) {
return; return;
} }
key = BI.hyphenate(key); key = hyphenate(key);
str += ` ${key}:${stl};`; str += ` ${key}:${stl};`;
}); });
str += ` width:${root.width}px;`; str += ` width:${root.width}px;`;
str += ` height:${root.height}px;`; str += ` height:${root.height}px;`;
str += ' position: fixed;'; str += " position: fixed;";
str += ` left: ${root.position.x}px;`; str += ` left: ${root.position.x}px;`;
str += ` top: ${root.position.y}px;`; str += ` top: ${root.position.y}px;`;
str += '"'; str += "\"";
BI.each(root.attribs, (key, attr) => { each(root.attribs, (key, attr) => {
str += ` ${key}:${attr}`; str += ` ${key}:${attr}`;
}); });
str += '>'; str += ">";
} }
BI.each(root.children, (i, child) => { each(root.children, (i, child) => {
str += _renderToString(child); str += _renderToString(child);
}); });
// if (root.htmlContent) { // if (root.htmlContent) {
// str += root.htmlContent; // str += root.htmlContent;
// } // }
if (root.nodeName !== 'body') { if (root.nodeName !== "body") {
if (root.text) { if (root.text) {
str += root.text; str += root.text;
} }
str += `</${root.nodeName}>`; str += `</${root.nodeName}>`;
} }
return str; return str;
}; }
export const registRenderToStringFun = (Element) => {
Element.registerFunction('renderToString', function () { export const registRenderToStringFun = Element => {
Element.registerFunction("renderToString", function () {
return _renderToString(this); return _renderToString(this);
}); });
}; };

8
src/core/element/plugins/text.js

@ -1,10 +1,12 @@
export const registTextFun = (Element) => { export const registTextFun = Element => {
Element.registerFunction('setText', function (text) { Element.registerFunction("setText", function (text) {
this.text = text; this.text = text;
return this; return this;
}); });
Element.registerFunction('setValue', function (text) { Element.registerFunction("setValue", function (text) {
this.text = text; this.text = text;
return this; return this;
}); });
}; };

6
src/core/element/plugins/val.js

@ -1,9 +1,11 @@
export const registValFun = (Element) => { export const registValFun = Element => {
Element.registerFunction('val', function (value) { Element.registerFunction("val", function (value) {
if (BI.isNotNull(value)) { if (BI.isNotNull(value)) {
this.text = `${value}`; this.text = `${value}`;
return this; return this;
} }
return this.text; return this.text;
}); });
}; };

49
src/core/h.js

@ -1,58 +1,59 @@
BI.Fragment = function () { import { isNotNull, isArray, isFunction, isKey, extend } from "./2.base";
};
BI.h = function (type, props, children) { export function Fragment () {}
if (children != null) {
if (!BI.isArray(children)) { export function h (type, props, children) {
if (isNotNull(children)) {
if (!isArray(children)) {
children = [children]; children = [children];
} }
} else { } else {
children = []; children = [];
} }
if (arguments.length > 3) { if (arguments.length > 3) {
for (var i = 3; i < arguments.length; i++) { for (let i = 3; i < arguments.length; i++) {
if (BI.isArray(arguments[i])) { if (isArray(arguments[i])) {
children = children.concat(arguments[i]); children = children.concat(arguments[i]);
} else { } else {
children.push(arguments[i]); children.push(arguments[i]);
} }
} }
} }
if (type === BI.Fragment) { if (type === Fragment) {
return children; return children;
} }
if (BI.isFunction(type)) { if (isFunction(type)) {
type = type.xtype || type; type = type.xtype || type;
} }
if (type === "el") { if (type === "el") {
return BI.extend({ return extend({
el: children[0] el: children[0],
}, props); }, props);
} }
if (type === "left") { if (type === "left") {
return BI.extend({ return extend({
left: children left: children,
}, props); }, props);
} }
if (type === "right") { if (type === "right") {
return BI.extend({ return extend({
right: children right: children,
}, props); }, props);
} }
if (children.length === 1) { if (children.length === 1) {
if (BI.isKey(children[0])) { if (isKey(children[0])) {
return BI.extend({ return extend({
type: type type,
}, { text: children[0] }, props); }, { text: children[0] }, props);
} }
if (BI.isFunction(children[0])) { if (isFunction(children[0])) {
return BI.extend({ return extend({
type: type type,
}, { items: children[0] }, props); }, { items: children[0] }, props);
} }
} }
return BI.extend({ return extend({
type: type type,
}, children.length > 0 ? { items: children } : {}, props); }, children.length > 0 ? { items: children } : {}, props);
}; }

25
src/core/index.js

@ -2,16 +2,21 @@ import * as base from "./2.base";
import * as ob from "./3.ob"; import * as ob from "./3.ob";
import * as widget from "./4.widget"; import * as widget from "./4.widget";
import * as inject from "./5.inject"; import * as inject from "./5.inject";
import { Plugin } from "./6.plugin";
import * as h from "./h";
import * as action from "./action"; import * as action from "./action";
import * as behavior from "./behavior"; import * as behavior from "./behavior";
import * as controllers from "./controller"; import * as controllers from "./controller";
import * as func from "./func"; import * as func from "./func";
import * as structure from "./structure"; import * as structure from "./structure";
import { StyleLoaderManager } from "./loader/loader.style"; import { StyleLoaderManager } from "./loader/loader.style";
import "./h";
import { ShowListener } from "./listener/listener.show"; import { ShowListener } from "./listener/listener.show";
import { shortcut } from "./decorator"; import { useInWorker } from "./worker";
import * as constant from "./constant";
import * as logic from "./logic";
import { Element } from "./element";
export * from "./decorator";
export * from "./2.base"; export * from "./2.base";
export * from "./3.ob"; export * from "./3.ob";
export * from "./4.widget"; export * from "./4.widget";
@ -21,14 +26,16 @@ export * from "./behavior";
export * from "./controller"; export * from "./controller";
export * from "./func"; export * from "./func";
export * from "./structure"; export * from "./structure";
export * from "./h";
// 有了后删掉 export * from "./constant";
export const emptyFn = () => { }; export * from "./logic";
export { export {
StyleLoaderManager, StyleLoaderManager,
ShowListener, ShowListener,
shortcut Plugin,
useInWorker,
Element
}; };
Object.assign(BI, { Object.assign(BI, {
@ -36,12 +43,18 @@ Object.assign(BI, {
...ob, ...ob,
...widget, ...widget,
...inject, ...inject,
Plugin,
...behavior, ...behavior,
...constant,
component: inject.shortcut, component: inject.shortcut,
...action, ...action,
...controllers, ...controllers,
Element,
...func, ...func,
StyleLoaderManager, StyleLoaderManager,
ShowListener, ShowListener,
...logic,
...structure, ...structure,
useInWorker,
...h,
}); });

20
src/core/listener/listener.show.js

@ -1,14 +1,12 @@
/** /**
* guy * guy
* 检测某个Widget的EventChange事件然后去show某个card * 检测某个Widget的EventChange事件然后去show某个card
* @type {*|void|Object}
* @class BI.ShowListener
* @extends BI.OB
*/ */
import { OB } from "../3.ob"; import { OB } from "../3.ob";
import { isArray, isNull, nextTick, } from "../2.base"; import { isArray, isNull, nextTick } from "../2.base";
import { createWidget } from "../5.inject"; import { createWidget } from "../5.inject";
import { Controller } from "../controller/0.controller"; import { Controller } from "../controller/0.controller";
import { Events, emptyFn } from "../constant";
export class ShowListener extends OB { export class ShowListener extends OB {
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -17,12 +15,10 @@ export class ShowListener extends OB {
return { return {
eventObj: createWidget(), eventObj: createWidget(),
cardLayout: null, cardLayout: null,
cardNameCreator: (v) => { cardNameCreator: v => v,
return v; cardCreator: emptyFn,
}, afterCardCreated: emptyFn,
cardCreator: BI.emptyFn, afterCardShow: emptyFn,
afterCardCreated: BI.emptyFn,
afterCardShow: BI.emptyFn
}; };
} }
@ -30,13 +26,13 @@ export class ShowListener extends OB {
const { eventObj, cardLayout, afterCardCreated, cardNameCreator, cardCreator, afterCardShow } = this.options; const { eventObj, cardLayout, afterCardCreated, cardNameCreator, cardCreator, afterCardShow } = this.options;
if (eventObj) { if (eventObj) {
eventObj.on(Controller.EVENT_CHANGE, (type, v, ob) => { eventObj.on(Controller.EVENT_CHANGE, (type, v, ob) => {
if (type === BI.Events.CLICK) { if (type === Events.CLICK) {
v = v || eventObj.getValue(); v = v || eventObj.getValue();
v = isArray(v) ? (v.length > 1 ? v.toString() : v[0]) : v; v = isArray(v) ? (v.length > 1 ? v.toString() : v[0]) : v;
if (isNull(v)) { if (isNull(v)) {
throw new Error("不能为null"); throw new Error("不能为null");
} }
var cardName = cardNameCreator(v); const cardName = cardNameCreator(v);
if (!cardLayout.isCardExisted(cardName)) { if (!cardLayout.isCardExisted(cardName)) {
const card = cardCreator(cardName); const card = cardCreator(cardName);
cardLayout.addCardByName(cardName, card); cardLayout.addCardByName(cardName, card);

9
src/core/loader/loader.style.js

@ -2,13 +2,13 @@
* style加载管理器 * style加载管理器
* *
* Created by GUY on 2015/9/7. * Created by GUY on 2015/9/7.
* @class
*/ */
import { extend, isNotNull } from "../2.base";
import { OB } from "../3.ob"; import { OB } from "../3.ob";
export class StyleLoaderManager extends OB { export class StyleLoaderManager extends OB {
_defaultConfig() { _defaultConfig() {
return BI.extend(super._defaultConfig(arguments), {}); return extend(super._defaultConfig(arguments), {});
} }
_init() { _init() {
@ -17,7 +17,7 @@ export class StyleLoaderManager extends OB {
} }
loadStyle(name, styleString) { loadStyle(name, styleString) {
if(!_global.document) { if (!_global.document) {
return; return;
} }
const d = document, styles = d.createElement("style"); const d = document, styles = d.createElement("style");
@ -38,7 +38,7 @@ export class StyleLoaderManager extends OB {
} }
has(name) { has(name) {
return this.stylesManager[name] != null; return isNotNull(this.stylesManager[name]);
} }
removeStyle(name) { removeStyle(name) {
@ -47,6 +47,7 @@ export class StyleLoaderManager extends OB {
} }
this.stylesManager[name].parentNode.removeChild(this.stylesManager[name]); this.stylesManager[name].parentNode.removeChild(this.stylesManager[name]);
delete this.stylesManager[name]; delete this.stylesManager[name];
return this; return this;
} }
} }

83
src/core/logic/index.js

@ -0,0 +1,83 @@
import { Logic } from "./logic";
import { VerticalLayoutLogic, HorizontalLayoutLogic, TableLayoutLogic, HorizontalFillLayoutLogic } from "./logic.layout";
export const LogicFactory = {
Type: {
Vertical: "vertical",
Horizontal: "horizontal",
Table: "table",
HorizontalFill: "horizontal_fill",
},
createLogic (key, options) {
let LogicCls;
switch (key) {
case LogicFactory.Type.Vertical:
LogicCls = VerticalLayoutLogic;
break;
case LogicFactory.Type.Horizontal:
LogicCls = HorizontalLayoutLogic;
break;
case LogicFactory.Type.Table:
LogicCls = TableLayoutLogic;
break;
case LogicFactory.Type.HorizontalFill:
LogicCls = HorizontalFillLayoutLogic;
break;
default:
LogicCls = Logic;
break;
}
return new LogicCls(options).createLogic();
},
createLogicTypeByDirection (direction) {
switch (direction) {
case BI.Direction.Top:
case BI.Direction.Bottom:
case BI.Direction.Custom:
return BI.LogicFactory.Type.Vertical;
case BI.Direction.Left:
case BI.Direction.Right:
return BI.LogicFactory.Type.Horizontal;
default:
}
},
createLogicItemsByDirection (direction) {
let items = Array.prototype.slice.call(arguments, 1);
items = BI.map(items, (i, item) => {
if (BI.isWidget(item)) {
return {
el: item,
width: item.options.width,
height: item.options.height,
};
}
return item;
});
switch (direction) {
case BI.Direction.Bottom:
items.reverse();
break;
case BI.Direction.Right:
items.reverse();
break;
case BI.Direction.Custom:
items = items.slice(1);
break;
default:
}
return items;
},
};
export {
Logic,
VerticalLayoutLogic,
HorizontalLayoutLogic,
TableLayoutLogic,
HorizontalFillLayoutLogic
};

82
src/core/logic/logic.js

@ -1,80 +1,8 @@
/**
* @class BI.Logic
* @extends BI.OB
*/
BI.Logic = BI.inherit(BI.OB, {
createLogic: function () {
return this.options || {};
}
});
BI.LogicFactory = {
Type: {
Vertical: "vertical",
Horizontal: "horizontal",
Table: "table",
HorizontalFill: "horizontal_fill"
},
createLogic: function (key, options) {
var logic;
switch (key) {
case BI.LogicFactory.Type.Vertical:
logic = BI.VerticalLayoutLogic;
break;
case BI.LogicFactory.Type.Horizontal:
logic = BI.HorizontalLayoutLogic;
break;
case BI.LogicFactory.Type.Table:
logic = BI.TableLayoutLogic;
break;
case BI.LogicFactory.Type.HorizontalFill:
logic = BI.HorizontalFillLayoutLogic;
break;
default:
logic = BI.Logic;
break;
}
return new logic(options).createLogic();
},
createLogicTypeByDirection: function (direction) { import { OB } from "../3.ob";
switch (direction) {
case BI.Direction.Top:
case BI.Direction.Bottom:
case BI.Direction.Custom:
return BI.LogicFactory.Type.Vertical;
case BI.Direction.Left:
case BI.Direction.Right:
return BI.LogicFactory.Type.Horizontal;
}
},
createLogicItemsByDirection: function (direction) { export class Logic extends OB {
var layout; createLogic() {
var items = Array.prototype.slice.call(arguments, 1); return this.options || {};
items = BI.map(items, function (i, item) {
if (BI.isWidget(item)) {
return {
el: item,
width: item.options.width,
height: item.options.height
};
}
return item;
});
switch (direction) {
case BI.Direction.Bottom:
layout = BI.LogicFactory.Type.Vertical;
items.reverse();
break;
case BI.Direction.Right:
layout = BI.LogicFactory.Type.Horizontal;
items.reverse();
break;
case BI.Direction.Custom:
items = items.slice(1);
break;
}
return items;
} }
}; }

109
src/core/logic/logic.layout.js

@ -1,13 +1,13 @@
import { Logic } from "./logic";
import { isNotNull, each, pickBy } from "../2.base";
/** /**
* guy * guy
* 上下布局逻辑 * 上下布局逻辑
* 上下布局的时候要考虑到是动态布局还是静态布局 * 上下布局的时候要考虑到是动态布局还是静态布局
*
* @class BI.VerticalLayoutLogic
* @extends BI.Logic
*/ */
BI.VerticalLayoutLogic = BI.inherit(BI.Logic, { export class VerticalLayoutLogic extends Logic {
props: function () { props() {
return { return {
dynamic: false, dynamic: false,
scrollable: null, scrollable: null,
@ -21,18 +21,20 @@ BI.VerticalLayoutLogic = BI.inherit(BI.Logic, {
tgap: 0, tgap: 0,
bgap: 0, bgap: 0,
innerVgap: 0, innerVgap: 0,
innerHgap: 0 innerHgap: 0,
}; };
}, }
createLogic: function () { createLogic() {
var layout, o = this.options; let layout;
const o = this.options;
if (o.dynamic) { if (o.dynamic) {
layout = "bi.vertical"; layout = "bi.vertical";
} else { } else {
layout = "bi.vtape"; layout = "bi.vtape";
} }
return BI._.pickBy({
return pickBy({
type: layout, type: layout,
scrollable: o.scrollable, scrollable: o.scrollable,
scrolly: o.scrolly, scrolly: o.scrolly,
@ -49,22 +51,19 @@ BI.VerticalLayoutLogic = BI.inherit(BI.Logic, {
horizontalAlign: o.horizontalAlign, horizontalAlign: o.horizontalAlign,
verticalAlign: o.verticalAlign, verticalAlign: o.verticalAlign,
columnSize: o.columnSize, columnSize: o.columnSize,
rowSize: o.rowSize rowSize: o.rowSize,
}, BI.isNotNull); }, isNotNull);
} }
}); }
/** /**
* guy * guy
* 左右布局逻辑 * 左右布局逻辑
* 左右布局的时候要考虑到是动态布局还是静态布局 * 左右布局的时候要考虑到是动态布局还是静态布局
*
* @class BI.HorizontalLayoutLogic
* @extends BI.Logic
*/ */
BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, { export class HorizontalLayoutLogic extends Logic {
props: function () { props() {
return { return {
dynamic: false, dynamic: false,
scrollable: null, scrollable: null,
@ -78,18 +77,20 @@ BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, {
tgap: 0, tgap: 0,
bgap: 0, bgap: 0,
innerVgap: 0, innerVgap: 0,
innerHgap: 0 innerHgap: 0,
}; };
}, }
createLogic: function () { createLogic() {
var layout, o = this.options; let layout;
const o = this.options;
if (o.dynamic) { if (o.dynamic) {
layout = "bi.vertical_adapt"; layout = "bi.vertical_adapt";
} else { } else {
layout = "bi.htape"; layout = "bi.htape";
} }
return BI._.pickBy({
return pickBy({
type: layout, type: layout,
scrollable: o.scrollable, scrollable: o.scrollable,
scrolly: o.scrolly, scrolly: o.scrolly,
@ -106,21 +107,18 @@ BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, {
horizontalAlign: o.horizontalAlign, horizontalAlign: o.horizontalAlign,
verticalAlign: o.verticalAlign, verticalAlign: o.verticalAlign,
columnSize: o.columnSize, columnSize: o.columnSize,
rowSize: o.rowSize rowSize: o.rowSize,
}, BI.isNotNull); }, isNotNull);
} }
}); }
/** /**
* guy * guy
* 表格布局逻辑 * 表格布局逻辑
* 表格布局的时候要考虑到是动态布局还是静态布局 * 表格布局的时候要考虑到是动态布局还是静态布局
*
* @class BI.TableLayoutLogic
* @extends BI.OB
*/ */
BI.TableLayoutLogic = BI.inherit(BI.Logic, { export class TableLayoutLogic extends Logic {
props: function () { props() {
return { return {
dynamic: false, dynamic: false,
scrollable: null, scrollable: null,
@ -132,18 +130,20 @@ BI.TableLayoutLogic = BI.inherit(BI.Logic, {
rowSize: [], rowSize: [],
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
items: [] items: [],
}; };
}, }
createLogic: function () { createLogic() {
var layout, o = this.options; let layout;
const o = this.options;
if (o.dynamic) { if (o.dynamic) {
layout = "bi.table"; layout = "bi.table";
} else { } else {
layout = "bi.window"; layout = "bi.window";
} }
return BI._.pickBy({
return pickBy({
type: layout, type: layout,
scrollable: o.scrollable, scrollable: o.scrollable,
scrolly: o.scrolly, scrolly: o.scrolly,
@ -156,20 +156,17 @@ BI.TableLayoutLogic = BI.inherit(BI.Logic, {
horizontalAlign: o.horizontalAlign, horizontalAlign: o.horizontalAlign,
verticalAlign: o.verticalAlign, verticalAlign: o.verticalAlign,
columnSize: o.columnSize, columnSize: o.columnSize,
rowSize: o.rowSize rowSize: o.rowSize,
}, BI.isNotNull); }, isNotNull);
} }
}); }
/** /**
* guy * guy
* 左右充满布局逻辑 * 左右充满布局逻辑
*
* @class BI.HorizontalFillLayoutLogic
* @extends BI.Logic
*/ */
BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, { export class HorizontalFillLayoutLogic extends Logic {
props: function () { props() {
return { return {
dynamic: false, dynamic: false,
scrollable: null, scrollable: null,
@ -183,14 +180,15 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, {
tgap: 0, tgap: 0,
bgap: 0, bgap: 0,
innerVgap: 0, innerVgap: 0,
innerHgap: 0 innerHgap: 0,
}; };
}, }
createLogic: function () { createLogic() {
var layout, o = this.options; let layout;
var columnSize = []; const o = this.options;
BI.each(o.items, function (i, item) { const columnSize = [];
each(o.items, (i, item) => {
columnSize.push(item.width || 0); columnSize.push(item.width || 0);
}); });
if (o.dynamic) { if (o.dynamic) {
@ -198,7 +196,8 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, {
} else { } else {
layout = "bi.htape"; layout = "bi.htape";
} }
return BI._.pickBy({
return pickBy({
type: layout, type: layout,
scrollable: o.scrollable, scrollable: o.scrollable,
scrolly: o.scrolly, scrolly: o.scrolly,
@ -214,8 +213,8 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, {
items: o.items, items: o.items,
horizontalAlign: o.horizontalAlign, horizontalAlign: o.horizontalAlign,
verticalAlign: o.verticalAlign, verticalAlign: o.verticalAlign,
columnSize: columnSize, columnSize,
rowSize: o.rowSize rowSize: o.rowSize,
}, BI.isNotNull); }, isNotNull);
} }
}); }

120
src/core/system.js

@ -3,9 +3,13 @@
* @version 2.0 * @version 2.0
* Created by windy on 2021/6/30 * Created by windy on 2021/6/30
*/ */
import { deepExtend, extend, inherit } from "./2.base";
import { OB } from "./3.ob";
import { Providers } from "./5.inject";
import { provider } from "./decorator";
// 系统参数常量 // 系统参数常量
!(function () { const system = {
var system = {
dependencies: {}, dependencies: {},
layoutOptimize: false, layoutOptimize: false,
responsiveMode: false, responsiveMode: false,
@ -18,12 +22,12 @@
TRIGGER_HEIGHT: 24, TRIGGER_HEIGHT: 24,
TOAST_TOP: 10, TOAST_TOP: 10,
H_GAP_SIZE: "M", H_GAP_SIZE: "M",
V_GAP_SIZE: "S" V_GAP_SIZE: "S",
}, },
loadingCreator: function(config) { loadingCreator(config) {
var loadingSize = (config ? config.loadingSize : "small") || "small"; const loadingSize = (config ? config.loadingSize : "small") || "small";
var isIE = BI.isIE(); const isIE = BI.isIE();
function getSize(v) { function getSize(v) {
return Math.ceil(v / (loadingSize === "small" ? 2 : 1)); return Math.ceil(v / (loadingSize === "small" ? 2 : 1));
@ -31,7 +35,7 @@
return { return {
type: "bi.horizontal", type: "bi.horizontal",
cls: "bi-loading-widget" + (isIE ? " wave-loading hack" : ""), cls: `bi-loading-widget${isIE ? " wave-loading hack" : ""}`,
height: getSize(60), height: getSize(60),
width: getSize(60), width: getSize(60),
hgap: getSize(10), hgap: getSize(10),
@ -40,105 +44,105 @@
type: "bi.layout", type: "bi.layout",
cls: "animate-rect rect1", cls: "animate-rect rect1",
height: getSize(50), height: getSize(50),
width: getSize(5) width: getSize(5),
}, { }, {
type: "bi.layout", type: "bi.layout",
cls: "animate-rect rect2", cls: "animate-rect rect2",
height: getSize(50), height: getSize(50),
width: getSize(5) width: getSize(5),
}, { }, {
type: "bi.layout", type: "bi.layout",
cls: "animate-rect rect3", cls: "animate-rect rect3",
height: getSize(50), height: getSize(50),
width: getSize(5) width: getSize(5),
}] }],
};
}
}; };
},
};
// 具体尺寸还没定,先写着 // 具体尺寸还没定,先写着
var sizeMap = { const sizeMap = {
"S": 10, S: 10,
"M": 20, M: 20,
"L": 24 L: 24,
}; };
function provider () { @provider()
this.SYSTEM = system; export class SystemProvider {
static xtype = "bi.provider.system";
this.setSize = function (opt) { SYSTEM = system;
BI.deepExtend(system, { size: opt });
};
this.setResponsiveMode = function (mode) { setSize(opt) {
deepExtend(system, { size: opt });
}
setResponsiveMode(mode) {
system.responsiveMode = !!mode; system.responsiveMode = !!mode;
}; }
this.setWorkerMode = function (mode) { setWorkerMode(mode) {
system.workerMode = !!mode; system.workerMode = !!mode;
}; }
this.setLayoutOptimize = function (layoutOptimize) { setLayoutOptimize(layoutOptimize) {
system.layoutOptimize = layoutOptimize; system.layoutOptimize = layoutOptimize;
}; }
this.addDependency = function (moduleId, minVersion, maxVersion) { addDependency(moduleId, minVersion, maxVersion) {
system.dependencies[moduleId] = { system.dependencies[moduleId] = {
min: minVersion, min: minVersion,
max: maxVersion max: maxVersion,
};
}; };
}
this.addDependencies = function (moduleConfig) { addDependencies(moduleConfig) {
BI.extend(system.dependencies, moduleConfig); extend(system.dependencies, moduleConfig);
}; }
this.setLoadingCreator = function(creator) { setLoadingCreator = function(creator) {
system.loadingCreator = creator; system.loadingCreator = creator;
}; };
this.$get = function () { $get() {
return BI.inherit(BI.OB, { return inherit(OB, {
getSize: function () { getSize () {
var size = system.size; const size = system.size;
var H_GAP_SIZE = sizeMap[size.H_GAP_SIZE]; const H_GAP_SIZE = sizeMap[size.H_GAP_SIZE];
var V_GAP_SIZE = sizeMap[size.V_GAP_SIZE]; const V_GAP_SIZE = sizeMap[size.V_GAP_SIZE];
return BI.extend({}, size, { return extend({}, size, {
H_GAP_SIZE: H_GAP_SIZE, H_GAP_SIZE,
V_GAP_SIZE: V_GAP_SIZE V_GAP_SIZE,
}); });
}, },
getResponsiveMode: function () { getResponsiveMode () {
return system.responsiveMode; return system.responsiveMode;
}, },
getWorkerMode: function () { getWorkerMode () {
return system.workerMode; return system.workerMode;
}, },
getLayoutOptimize: function () { getLayoutOptimize () {
return system.layoutOptimize; return system.layoutOptimize;
}, },
getDependencies: function () { getDependencies () {
return system.dependencies; return system.dependencies;
}, },
getLoading: function(config) { getLoading(config) {
return system.loadingCreator(config); return system.loadingCreator(config);
} },
}); });
};
} }
}
BI.provider("bi.provider.system", provider); BI.prepares.push(() => {
}()); BI.SIZE_CONSANTS = Providers.getProvider("bi.provider.system").getSize();
BI.prepares.push(function () {
BI.SIZE_CONSANTS = BI.Providers.getProvider("bi.provider.system").getSize();
// 不再增加线型的配置了,之后不维护前置版本直接删掉,都用实线连接线 // 不再增加线型的配置了,之后不维护前置版本直接删掉,都用实线连接线
BI.STYLE_CONSTANTS = {}; BI.STYLE_CONSTANTS = {};
BI.STYLE_CONSTANTS.LINK_LINE_TYPE = BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT === 24 ? "dashed" : "solid"; BI.STYLE_CONSTANTS.LINK_LINE_TYPE = BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT === 24 ? "dashed" : "solid";

49
src/core/worker.js

@ -1,27 +1,31 @@
!(function () { import { isPlainObject, extend, each, isArray } from "./2.base";
BI.useInWorker = function () { import { Models } from "./5.inject";
export function useInWorker () {
function createWatcher (model, keyOrFn, cb, options) { function createWatcher (model, keyOrFn, cb, options) {
if (BI.isPlainObject(cb)) { if (isPlainObject(cb)) {
options = cb; options = cb;
cb = cb.handler; cb = cb.handler;
} }
options = options || {}; options = options || {};
return Fix.watch(model, keyOrFn, cb, BI.extend(options, {
store: model return Fix.watch(model, keyOrFn, cb, extend(options, {
store: model,
})); }));
} }
var models = {}, watches = {}; const models = {}, watches = {};
addEventListener("message", function (e) { addEventListener("message", e => {
var data = e.data; const data = e.data;
let store;
switch (data.eventType) { switch (data.eventType) {
case "action": case "action":
models[data.name][data.action].apply(models[data.name], data.args); models[data.name][data.action](...data.args);
break; break;
case "destroy": case "destroy":
BI.each(watches[data.name], function (i, unwatches) { each(watches[data.name], (i, unwatches) => {
unwatches = BI.isArray(unwatches) ? unwatches : [unwatches]; unwatches = isArray(unwatches) ? unwatches : [unwatches];
BI.each(unwatches, function (j, unwatch) { each(unwatches, (j, unwatch) => {
unwatch(); unwatch();
}); });
}); });
@ -29,23 +33,22 @@
delete watches[data.name]; delete watches[data.name];
break; break;
case "create": case "create":
var store = models[data.name] = BI.Models.getModel(data.type, data.options); store = models[data.name] = Models.getModel(data.type, data.options);
watches[data.name] = []; watches[data.name] = [];
BI.each(data.watches, function (i, key) { each(data.watches, (i, key) => {
watches[data.name].push(createWatcher(store.model, key, function (newValue, oldValue) { watches[data.name].push(createWatcher(store.model, key, (newValue, oldValue) => {
postMessage(BI.extend({}, data, { postMessage(extend({}, data, {
eventType: "watch", eventType: "watch",
currentWatchType: key currentWatchType: key,
}, {args: [newValue, oldValue]})); }, { args: [newValue, oldValue] }));
})); }));
}); });
postMessage(BI.extend({}, data, { postMessage(extend({}, data, {
eventType: "create" eventType: "create",
}, {msg: store.model})); }, { msg: store.model }));
break; break;
default: default:
break; break;
} }
}, false); }, false);
}; }
}());

Loading…
Cancel
Save