Browse Source

Pull request #3417: KERNEL-14124 fix: 再梳理一遍去脚本难去掉的BI.以及eslint标红

Merge in VISUAL/fineui from ~ZHENFEI.LI/fineui:es6 to es6

* commit '069167c131b4aaa30a921fa81c8175099c638487':
  KERNEL-14124 fix: 再梳理一遍去脚本难去掉的BI.以及eslint标红
es6
Zhenfei.Li-李振飞 2 years ago
parent
commit
dc7a8861a1
  1. 2
      .eslintrc
  2. 12
      src/base/1.pane.js
  3. 11
      src/base/collection/collection.js
  4. 88
      src/base/combination/bubble.js
  5. 426
      src/base/combination/combo.js
  6. 145
      src/base/combination/expander.js
  7. 5
      src/base/combination/group.combo.js
  8. 61
      src/base/combination/loader.js
  9. 19
      src/base/combination/navigation.js
  10. 77
      src/base/combination/searcher.js
  11. 135
      src/base/combination/switcher.js
  12. 11
      src/base/combination/tab.js
  13. 8
      src/base/combination/tree.button.js
  14. 6
      src/base/context.js
  15. 33
      src/base/foundation/message.js
  16. 15
      src/base/grid/grid.js
  17. 152
      src/base/layer/layer.drawer.js
  18. 56
      src/base/layer/layer.popover.js
  19. 409
      src/base/layer/layer.popup.js
  20. 16
      src/base/layer/layer.searcher.js
  21. 12
      src/base/list/listview.js
  22. 12
      src/base/list/virtualgrouplist.js
  23. 12
      src/base/list/virtuallist.js
  24. 63
      src/base/pager/pager.js
  25. 60
      src/base/single/1.text.js
  26. 4
      src/base/single/a/a.js
  27. 22
      src/base/single/bar/bar.loading.js
  28. 185
      src/base/single/button/button.basic.js
  29. 6
      src/base/single/button/button.node.js
  30. 4
      src/base/single/button/buttons/button.icon.js
  31. 18
      src/base/single/button/buttons/button.js
  32. 2
      src/base/single/button/listitem/blankicontexticonitem.js
  33. 4
      src/base/single/button/listitem/icontextitem.js
  34. 16
      src/base/single/editor/editor.js
  35. 4
      src/base/single/editor/editor.multifile.js
  36. 34
      src/base/single/editor/editor.textarea.js
  37. 20
      src/base/single/html/html.js
  38. 8
      src/base/single/icon/icon.js
  39. 9
      src/base/single/img/img.js
  40. 4
      src/base/single/input/checkbox/checkbox.image.js
  41. 4
      src/base/single/input/checkbox/checkbox.js
  42. 99
      src/base/single/input/file.js
  43. 52
      src/base/single/input/input.js
  44. 4
      src/base/single/input/radio/radio.image.js
  45. 4
      src/base/single/input/radio/radio.js
  46. 18
      src/base/single/label/abstract.label.js
  47. 8
      src/base/single/label/icon.label.js
  48. 4
      src/base/single/link/link.js
  49. 8
      src/base/single/tip/0.tip.js
  50. 44
      src/base/single/tip/tip.toast.js
  51. 8
      src/base/single/tip/tip.tooltip.js
  52. 4
      src/base/single/trigger/trigger.js
  53. 9
      src/base/tree/customtree.js
  54. 5
      src/case/button/icon/iconhalf/icon.half.image.js
  55. 5
      src/case/button/icon/iconhalf/icon.half.js
  56. 10
      src/case/button/item.multiselect.js
  57. 8
      src/case/button/item.singleselect.icontext.js
  58. 4
      src/case/button/item.singleselect.js
  59. 12
      src/case/button/item.singleselect.radio.js
  60. 14
      src/case/button/node/node.icon.arrow.js
  61. 8
      src/case/button/node/node.plus.js
  62. 10
      src/case/button/node/siwtcher.tree.node.js
  63. 8
      src/case/button/node/treenode.js
  64. 19
      src/case/button/switch.js
  65. 12
      src/case/button/treeitem/item.icon.treeleaf.js
  66. 8
      src/case/button/treeitem/item.multilayer.icon.treeleaf.js
  67. 15
      src/case/button/treeitem/treeitem.js
  68. 4
      src/case/calendar/calendar.date.item.js
  69. 7
      src/case/calendar/calendar.js
  70. 7
      src/case/calendar/calendar.year.js
  71. 4
      src/case/checkbox/check.checkingmarknode.js
  72. 18
      src/case/checkbox/check.first.treenode.js
  73. 18
      src/case/checkbox/check.last.treenode.js
  74. 18
      src/case/checkbox/check.mid.treenode.js
  75. 18
      src/case/checkbox/check.treenode.js
  76. 46
      src/case/colorchooser/colorchooser.popup.hex.js
  77. 21
      src/case/colorchooser/colorchooser.popup.js
  78. 4
      src/case/colorchooser/colorchooser.trigger.js
  79. 8
      src/case/colorchooser/colorchooser.trigger.long.js
  80. 18
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.js
  81. 30
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js
  82. 18
      src/case/colorchooser/colorpicker/editor.colorpicker.js
  83. 12
      src/case/colorchooser/colorpicker/editor.colorpicker.simple.js
  84. 115
      src/case/combo/bubblecombo/popup.bubble.js
  85. 4
      src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js
  86. 8
      src/case/layer/layer.multipopup.js
  87. 4
      src/case/layer/layer.panel.js
  88. 4
      src/case/layer/pane.list.js
  89. 39
      src/case/pager/pager.all.count.js
  90. 54
      src/case/pager/pager.detail.js
  91. 22
      src/case/pager/pager.direction.js
  92. 5
      src/case/tree/tree.level.js
  93. 6
      src/case/tree/treeexpander/tree.expander.popup.js
  94. 6
      src/case/ztree/list/listtreeview.js
  95. 4
      src/case/ztree/parttree.js
  96. 10
      src/case/ztree/tree.display.js
  97. 8
      src/case/ztree/tree.list.display.js
  98. 8
      src/case/ztree/treeview.js
  99. 31
      src/core/4.widget.js
  100. 25
      src/core/5.inject.js
  101. Some files were not shown because too many files have changed in this diff Show More

2
.eslintrc

@ -35,7 +35,7 @@
"comma-dangle": ["error", { "arrays": "never", "objects": "always-multiline"}], // 多行对象字面量中要求拖尾逗号
"no-var": 2,
"prefer-const": 2,
"indent": ["error", 4],
"indent": ["error", 4, { "SwitchCase": 1 }],
"no-use-before-define": 0,
"eqeqeq": 0
}

12
src/base/1.pane.js

@ -10,7 +10,9 @@ import {
isNull,
isEmpty,
createWidget,
Providers
Providers,
i18nText,
emptyFn
} from "@/core";
import { Label, Text } from "./single";
import { Layers } from "@/base/0.base";
@ -19,8 +21,8 @@ import { Layers } from "@/base/0.base";
* 当没有元素时有提示信息的view
*
* Created by GUY on 2015/9/8.
* @class BI.Pane
* @extends BI.Widget
* @class Pane
* @extends Widget
* @abstract
*/
@ -33,11 +35,11 @@ export class Pane extends Widget {
_defaultConfig() {
return extend(super._defaultConfig(), {
_baseCls: "bi-pane",
tipText: BI.i18nText("BI-No_Selected_Item"),
tipText: i18nText("BI-No_Selected_Item"),
loadingText: "",
loadingSize: "small",
overlap: true,
onLoaded: BI.emptyFn,
onLoaded: emptyFn,
});
}

11
src/base/collection/collection.js

@ -16,7 +16,8 @@ import {
invert,
min,
max,
nextTick
nextTick,
DOM
} from "@/core";
import { Label } from "../single";
@ -24,8 +25,8 @@ import { Label } from "../single";
* CollectionView
*
* Created by GUY on 2016/1/15.
* @class BI.CollectionView
* @extends BI.Widget
* @class CollectionView
* @extends Widget
*/
@shortcut()
@ -376,11 +377,11 @@ export class CollectionView extends Widget {
}
_getMaxScrollLeft() {
return Math.max(0, this._width - this.options.width + (this._isOverflowX() ? BI.DOM.getScrollWidth() : 0));
return Math.max(0, this._width - this.options.width + (this._isOverflowX() ? DOM.getScrollWidth() : 0));
}
_getMaxScrollTop() {
return Math.max(0, this._height - this.options.height + (this._isOverflowY() ? BI.DOM.getScrollWidth() : 0));
return Math.max(0, this._height - this.options.height + (this._isOverflowY() ? DOM.getScrollWidth() : 0));
}
_populate(items) {

88
src/base/combination/bubble.js

@ -14,14 +14,14 @@ import {
isNull,
isFunction,
contains,
bind
bind,
Events,
emptyFn,
LogicFactory,
EVENT_RESPONSE_TIME,
EVENT_BLUR
} from "@/core";
/**
* @class BI.Bubble
* @extends BI.Widget
*/
@shortcut()
export class Bubble extends Widget {
static xtype = "bi.bubble";
@ -65,7 +65,7 @@ export class Bubble extends Widget {
adjustLength: 0, // 调整的距离
adjustXOffset: 0,
adjustYOffset: 0,
hideChecker: BI.emptyFn,
hideChecker: emptyFn,
offsetStyle: "left", // left,right,center
el: {},
popup: {},
@ -83,32 +83,32 @@ export class Bubble extends Widget {
});
this.combo.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
if (this.isEnabled() && this.isValid()) {
if (type === BI.Events.EXPAND) {
if (type === Events.EXPAND) {
this._popupView();
}
if (type === BI.Events.COLLAPSE) {
if (type === Events.COLLAPSE) {
this._hideView();
}
if (type === BI.Events.EXPAND) {
if (type === Events.EXPAND) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.fireEvent(Bubble.EVENT_EXPAND);
}
if (type === BI.Events.COLLAPSE) {
if (type === Events.COLLAPSE) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.isViewVisible() && this.fireEvent(Bubble.EVENT_COLLAPSE);
}
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(Bubble.EVENT_TRIGGER_CHANGE, obj);
}
}
});
this.element.on(`mouseenter.${this.getName()}`, (e) => {
this.element.on(`mouseenter.${this.getName()}`, e => {
if (this.isEnabled() && this.isValid() && this.combo.isEnabled() && this.combo.isValid()) {
this.element.addClass(hoverClass);
}
});
this.element.on(`mouseleave.${this.getName()}`, (e) => {
this.element.on(`mouseleave.${this.getName()}`, e => {
if (this.isEnabled() && this.isValid() && this.combo.isEnabled() && this.combo.isValid()) {
this.element.removeClass(hoverClass);
}
@ -120,7 +120,7 @@ export class Bubble extends Widget {
element: this,
scrolly: false,
},
BI.LogicFactory.createLogic(
LogicFactory.createLogic(
"vertical",
extend(logic, {
items: [{ el: this.combo }],
@ -146,7 +146,7 @@ export class Bubble extends Widget {
const { stopEvent, stopPropagation, toggle } = this.options;
const evs = (this.options.trigger || "").split(",");
const st = (e) => {
const st = e => {
if (stopEvent) {
e.stopEvent();
}
@ -157,7 +157,7 @@ export class Bubble extends Widget {
let enterPopup = false;
const hide = (e) => {
const hide = e => {
if (
this.isEnabled() &&
this.isValid() &&
@ -166,7 +166,7 @@ export class Bubble extends Widget {
toggle === true
) {
this._hideView(e);
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", this.combo);
this.fireEvent(Controller.EVENT_CHANGE, Events.COLLAPSE, "", this.combo);
this.fireEvent(Bubble.EVENT_COLLAPSE);
}
this.popupView &&
@ -178,18 +178,18 @@ export class Bubble extends Widget {
let debounced;
switch (ev) {
case "hover":
this.element.on(`mouseenter.${this.getName()}`, (e) => {
this.element.on(`mouseenter.${this.getName()}`, e => {
if (this.isEnabled() && this.isValid() && this.combo.isEnabled() && this.combo.isValid()) {
this._popupView(e);
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, "", this.combo);
this.fireEvent(Controller.EVENT_CHANGE, Events.EXPAND, "", this.combo);
this.fireEvent(Bubble.EVENT_EXPAND);
}
});
this.element.on(`mouseleave.${this.getName()}`, (e) => {
this.element.on(`mouseleave.${this.getName()}`, e => {
if (this.popupView) {
this.popupView.element.on(`mouseenter.${this.getName()}`, (e) => {
this.popupView.element.on(`mouseenter.${this.getName()}`, e => {
enterPopup = true;
this.popupView.element.on(`mouseleave.${this.getName()}`, (e) => {
this.popupView.element.on(`mouseleave.${this.getName()}`, e => {
hide(e);
});
this.popupView.element.off(`mouseenter.${this.getName()}`);
@ -204,7 +204,7 @@ export class Bubble extends Widget {
break;
case "click":
debounced = debounce(
(e) => {
e => {
if (this.combo.element.__isMouseInBounds__(e)) {
if (
this.isEnabled() &&
@ -217,29 +217,29 @@ export class Bubble extends Widget {
// }
toggle ? this._toggle(e) : this._popupView(e);
if (this.isViewVisible()) {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, "", this.combo);
this.fireEvent(Controller.EVENT_CHANGE, Events.EXPAND, "", this.combo);
this.fireEvent(Bubble.EVENT_EXPAND);
} else {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", this.combo);
this.fireEvent(Controller.EVENT_CHANGE, Events.COLLAPSE, "", this.combo);
this.fireEvent(Bubble.EVENT_COLLAPSE);
}
}
}
},
BI.EVENT_RESPONSE_TIME,
EVENT_RESPONSE_TIME,
{
leading: true,
trailing: false,
}
);
this.element.off(`${ev}.${this.getName()}`).on(`${ev}.${this.getName()}`, (e) => {
this.element.off(`${ev}.${this.getName()}`).on(`${ev}.${this.getName()}`, e => {
debounced(e);
st(e);
});
break;
case "click-hover":
debounced = debounce(
(e) => {
e => {
if (this.combo.element.__isMouseInBounds__(e)) {
if (
this.isEnabled() &&
@ -252,27 +252,27 @@ export class Bubble extends Widget {
// }
this._popupView(e);
if (this.isViewVisible()) {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, "", this.combo);
this.fireEvent(Controller.EVENT_CHANGE, Events.EXPAND, "", this.combo);
this.fireEvent(Bubble.EVENT_EXPAND);
}
}
}
},
BI.EVENT_RESPONSE_TIME,
EVENT_RESPONSE_TIME,
{
leading: true,
trailing: false,
}
);
this.element.off(`click.${this.getName()}`).on(`click.${this.getName()}`, (e) => {
this.element.off(`click.${this.getName()}`).on(`click.${this.getName()}`, e => {
debounced(e);
st(e);
});
this.element.on(`mouseleave.${this.getName()}`, (e) => {
this.element.on(`mouseleave.${this.getName()}`, e => {
if (this.popupView) {
this.popupView.element.on(`mouseenter.${this.getName()}`, (e) => {
this.popupView.element.on(`mouseenter.${this.getName()}`, e => {
enterPopup = true;
this.popupView.element.on(`mouseleave.${this.getName()}`, (e) => {
this.popupView.element.on(`mouseleave.${this.getName()}`, e => {
hide(e);
});
this.popupView.element.off(`mouseenter.${this.getName()}`);
@ -286,10 +286,10 @@ export class Bubble extends Widget {
});
break;
case "hover-click":
this.element.on(`mouseenter.${this.getName()}`, (e) => {
this.element.on(`mouseenter.${this.getName()}`, e => {
if (this.isEnabled() && this.isValid() && this.combo.isEnabled() && this.combo.isValid()) {
this._popupView(e);
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, "", this.combo);
this.fireEvent(Controller.EVENT_CHANGE, Events.EXPAND, "", this.combo);
this.fireEvent(Bubble.EVENT_EXPAND);
}
});
@ -319,7 +319,7 @@ export class Bubble extends Widget {
this
);
this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.combo.setValue(this.getValue());
this.fireEvent(Bubble.EVENT_CHANGE, value, obj);
}
@ -404,7 +404,7 @@ export class Bubble extends Widget {
.createElement(document)
.unbind(`mousedown.${this.getName()}`)
.unbind(`mousewheel.${this.getName()}`);
BI.EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind(`blur.${this.getName()}`);
EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind(`blur.${this.getName()}`);
this.fireEvent(Bubble.EVENT_AFTER_HIDEVIEW);
}
@ -427,7 +427,7 @@ export class Bubble extends Widget {
options: {
offset: () => [adjustXOffset, (showArrow ? 12 : 0) + (adjustYOffset + adjustLength)],
},
},
}
];
if (this.options.showArrow) {
modifiers.push({
@ -448,11 +448,11 @@ export class Bubble extends Widget {
this.element.addClass(this.options.comboClass);
hideWhenClickOutside && Widget._renderEngine.createElement(document).unbind(`mousedown.${this.getName()}`);
BI.EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind(`blur.${this.getName()}`);
EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind(`blur.${this.getName()}`);
hideWhenClickOutside &&
Widget._renderEngine.createElement(document).bind(`mousedown.${this.getName()}`, bind(this._hideIf, this));
BI.EVENT_BLUR &&
EVENT_BLUR &&
hideWhenBlur &&
Widget._renderEngine.createElement(window).bind(`blur.${this.getName()}`, bind(this._hideIf, this));
this.fireEvent(Bubble.EVENT_AFTER_POPUPVIEW);
@ -500,8 +500,8 @@ export class Bubble extends Widget {
populate(items) {
this._assertPopupView();
this.popupView.populate.apply(this.popupView, arguments);
this.combo.populate && this.combo.populate.apply(this.combo, arguments);
this.popupView.populate(...arguments);
this.combo.populate && this.combo.populate(...arguments);
}
_setEnable(arg) {

426
src/base/combination/combo.js

@ -11,15 +11,15 @@ import {
isNotNull,
isNull,
isFunction,
each
each,
Events,
EVENT_BLUR,
DOM,
emptyFn,
LogicFactory
} from "@/core";
import { Resizers } from "@/base/0.base";
/**
* @class BI.Combo
* @extends BI.Widget
*/
let needHideWhenAnotherComboOpen = {};
let currentOpenedCombos = {};
@ -42,7 +42,7 @@ export class Combo extends Bubble {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-combo${BI.isIE() ? " hack" : ""}`,
baseCls: `${conf.baseCls || ""} bi-comboisIE() ? " hack" : ""}`,
attributes: {
tabIndex: -1,
},
@ -67,7 +67,7 @@ export class Combo extends Bubble {
adjustXOffset: 0,
adjustYOffset: 0,
supportCSSTransform: true,
hideChecker: BI.emptyFn,
hideChecker: emptyFn,
offsetStyle: "", // "",center,middle
el: {},
popup: {},
@ -86,24 +86,24 @@ export class Combo extends Bubble {
});
this.combo.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
if (this.isEnabled() && this.isValid()) {
if (type === BI.Events.TOGGLE) {
if (type === Events.TOGGLE) {
this._toggle();
}
if (type === BI.Events.EXPAND) {
if (type === Events.EXPAND) {
this._popupView();
}
if (type === BI.Events.COLLAPSE) {
if (type === Events.COLLAPSE) {
this._hideView();
}
if (type === BI.Events.EXPAND) {
if (type === Events.EXPAND) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.fireEvent(Combo.EVENT_EXPAND);
}
if (type === BI.Events.COLLAPSE) {
if (type === Events.COLLAPSE) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.isViewVisible() && this.fireEvent(Combo.EVENT_COLLAPSE);
}
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(Combo.EVENT_TRIGGER_CHANGE, obj);
}
}
@ -126,7 +126,7 @@ export class Combo extends Bubble {
element: this,
scrolly: false,
},
BI.LogicFactory.createLogic(
LogicFactory.createLogic(
"vertical",
extend(logic, {
items: [{ el: this.combo }],
@ -147,7 +147,7 @@ export class Combo extends Bubble {
}
_assertPopupView() {
const { showArrow, value, hideWhenClickOutside, hideWhenBlur } = this.options;
const { showArrow, value } = this.options;
if (isNull(this.popupView)) {
this.popupView = createWidget(
isFunction(this.options.popup) ? this.options.popup() : this.options.popup,
@ -159,7 +159,7 @@ export class Combo extends Bubble {
this
);
this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.combo.setValue(this.getValue());
this.fireEvent(Bubble.EVENT_CHANGE, value, obj);
}
@ -198,7 +198,7 @@ export class Combo extends Bubble {
.createElement(document)
.unbind(`mousedown.${this.getName()}`)
.unbind(`mousewheel.${this.getName()}`);
BI.EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind(`blur.${this.getName()}`);
EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind(`blur.${this.getName()}`);
this.fireEvent(Combo.EVENT_AFTER_HIDEVIEW, e);
}
@ -228,7 +228,7 @@ export class Combo extends Bubble {
.unbind(`mousedown.${this.getName()}`)
.unbind(`mousewheel.${this.getName()}`);
hideWhenClickOutside && Widget._renderEngine.createElement(document).unbind(`mousewheel.${this.getName()}`);
BI.EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind(`blur.${this.getName()}`);
EVENT_BLUR && hideWhenBlur && Widget._renderEngine.createElement(window).unbind(`blur.${this.getName()}`);
hideWhenClickOutside &&
Widget._renderEngine.createElement(document).bind(`mousewheel.${this.getName()}`, bind(this._hideIf, this));
@ -237,7 +237,7 @@ export class Combo extends Bubble {
.createElement(document)
.bind(`mousedown.${this.getName()}`, bind(this._hideIf, this))
.bind(`mousewheel.${this.getName()}`, bind(this._hideIf, this));
BI.EVENT_BLUR &&
EVENT_BLUR &&
hideWhenBlur &&
Widget._renderEngine.createElement(window).bind(`blur.${this.getName()}`, bind(this._hideIf, this));
this.fireEvent(Combo.EVENT_AFTER_POPUPVIEW);
@ -288,7 +288,7 @@ export class Combo extends Bubble {
}
: this.combo;
const positionRelativeElement = supportCSSTransform
? BI.DOM.getPositionRelativeContainingBlock(
? DOM.getPositionRelativeContainingBlock(
isNull(container)
? this.element[0]
: Widget._renderEngine.createElement(isFunction(container) ? container() : container)[0]
@ -296,198 +296,198 @@ export class Combo extends Bubble {
: null;
const TRIANGLE_LENGTH = 12;
switch (direction) {
case "bottom":
case "bottom,right":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight,
["bottom", "top", "right", "left"],
offsetStyle,
positionRelativeElement
);
break;
case "top":
case "top,right":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight,
["top", "bottom", "right", "left"],
offsetStyle,
positionRelativeElement
);
break;
case "left":
case "left,bottom":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["left", "right", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "right":
case "right,bottom":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["right", "left", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "top,left":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight,
["top", "bottom", "left", "right"],
offsetStyle,
positionRelativeElement
);
break;
case "bottom,left":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight,
["bottom", "top", "left", "right"],
offsetStyle,
positionRelativeElement
);
break;
case "left,top":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["left", "right", "top", "bottom"],
offsetStyle,
positionRelativeElement
);
break;
case "right,top":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["right", "left", "top", "bottom"],
offsetStyle,
positionRelativeElement
);
break;
case "right,innerRight":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["right", "left", "innerRight", "innerLeft", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "right,innerLeft":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["right", "left", "innerLeft", "innerRight", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "innerRight":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["innerRight", "innerLeft", "right", "left", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "innerLeft":
p = BI.DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["innerLeft", "innerRight", "left", "right", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "top,custom":
case "custom,top":
p = BI.DOM.getTopAdaptPosition(
combo,
this.popupView,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight
);
p.dir = "top";
break;
case "custom,bottom":
case "bottom,custom":
p = BI.DOM.getBottomAdaptPosition(
combo,
this.popupView,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight
);
p.dir = "bottom";
break;
case "left,custom":
case "custom,left":
p = BI.DOM.getLeftAdaptPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0)
);
delete p.top;
delete p.adaptHeight;
p.dir = "left";
break;
case "custom,right":
case "right,custom":
p = BI.DOM.getRightAdaptPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0)
);
delete p.top;
delete p.adaptHeight;
p.dir = "right";
break;
default:
break;
case "bottom":
case "bottom,right":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight,
["bottom", "top", "right", "left"],
offsetStyle,
positionRelativeElement
);
break;
case "top":
case "top,right":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight,
["top", "bottom", "right", "left"],
offsetStyle,
positionRelativeElement
);
break;
case "left":
case "left,bottom":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["left", "right", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "right":
case "right,bottom":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["right", "left", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "top,left":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight,
["top", "bottom", "left", "right"],
offsetStyle,
positionRelativeElement
);
break;
case "bottom,left":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight,
["bottom", "top", "left", "right"],
offsetStyle,
positionRelativeElement
);
break;
case "left,top":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["left", "right", "top", "bottom"],
offsetStyle,
positionRelativeElement
);
break;
case "right,top":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["right", "left", "top", "bottom"],
offsetStyle,
positionRelativeElement
);
break;
case "right,innerRight":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["right", "left", "innerRight", "innerLeft", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "right,innerLeft":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["right", "left", "innerLeft", "innerRight", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "innerRight":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["innerRight", "innerLeft", "right", "left", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "innerLeft":
p = DOM.getComboPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
adjustYOffset,
isNeedAdjustHeight,
["innerLeft", "innerRight", "left", "right", "bottom", "top"],
offsetStyle,
positionRelativeElement
);
break;
case "top,custom":
case "custom,top":
p = DOM.getTopAdaptPosition(
combo,
this.popupView,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight
);
p.dir = "top";
break;
case "custom,bottom":
case "bottom,custom":
p = DOM.getBottomAdaptPosition(
combo,
this.popupView,
adjustYOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0),
isNeedAdjustHeight
);
p.dir = "bottom";
break;
case "left,custom":
case "custom,left":
p = DOM.getLeftAdaptPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0)
);
delete p.top;
delete p.adaptHeight;
p.dir = "left";
break;
case "custom,right":
case "right,custom":
p = DOM.getRightAdaptPosition(
combo,
this.popupView,
adjustXOffset + adjustLength + (showArrow ? TRIANGLE_LENGTH : 0)
);
delete p.top;
delete p.adaptHeight;
p.dir = "right";
break;
default:
break;
}
if ("adaptHeight" in p) {

145
src/base/combination/expander.js

@ -8,7 +8,9 @@ import {
each,
debounce,
isNull,
createWidget
createWidget,
Events,
EVENT_RESPONSE_TIME
} from "@/core";
import { ButtonGroup } from "./group.button";
@ -17,10 +19,9 @@ import { ButtonGroup } from "./group.button";
* 某个可以展开的节点
*
* Created by GUY on 2015/9/10.
* @class BI.Expander
* @extends BI.Widget
* @class Expander
* @extends Widget
*/
@shortcut()
export class Expander extends Widget {
static xtype = "bi.expander";
@ -60,21 +61,21 @@ export class Expander extends Widget {
});
this.expander.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
if (this.isEnabled() && this.isValid()) {
if (type === BI.Events.EXPAND) {
if (type === Events.EXPAND) {
this._popupView();
}
if (type === BI.Events.COLLAPSE) {
if (type === Events.COLLAPSE) {
this._hideView();
}
if (type === BI.Events.EXPAND) {
if (type === Events.EXPAND) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.fireEvent(Expander.EVENT_EXPAND);
}
if (type === BI.Events.COLLAPSE) {
if (type === Events.COLLAPSE) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.isViewVisible() && this.fireEvent(Expander.EVENT_COLLAPSE);
}
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(Expander.EVENT_TRIGGER_CHANGE, value, obj);
}
}
@ -120,80 +121,80 @@ export class Expander extends Widget {
const evs = this.options.trigger.split(",");
each(evs, (i, e) => {
switch (e) {
case "hover":
this.element[e](
e => {
if (
this.isEnabled() &&
case "hover":
this.element[e](
e => {
if (
this.isEnabled() &&
this.isValid() &&
this.expander.isEnabled() &&
this.expander.isValid()
) {
this._popupView();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, "", this.expander);
this.fireEvent(Expander.EVENT_EXPAND);
}
},
() => {
if (
this.isEnabled() &&
) {
this._popupView();
this.fireEvent(Controller.EVENT_CHANGE, Events.EXPAND, "", this.expander);
this.fireEvent(Expander.EVENT_EXPAND);
}
},
() => {
if (
this.isEnabled() &&
this.isValid() &&
this.expander.isEnabled() &&
this.expander.isValid() &&
toggle
) {
this._hideView();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", this.expander);
this.fireEvent(Expander.EVENT_COLLAPSE);
) {
this._hideView();
this.fireEvent(Controller.EVENT_CHANGE, Events.COLLAPSE, "", this.expander);
this.fireEvent(Expander.EVENT_COLLAPSE);
}
}
}
);
break;
case "click":
if (e) {
this.element.off(`${e}.${this.getName()}`).on(
`${e}.${this.getName()}`,
debounce(
e => {
if (this.expander.element.__isMouseInBounds__(e)) {
if (
this.isEnabled() &&
);
break;
case "click":
if (e) {
this.element.off(`${e}.${this.getName()}`).on(
`${e}.${this.getName()}`,
debounce(
e => {
if (this.expander.element.__isMouseInBounds__(e)) {
if (
this.isEnabled() &&
this.isValid() &&
this.expander.isEnabled() &&
this.expander.isValid()
) {
toggle ? this._toggle() : this._popupView();
if (this.isExpanded()) {
this.fireEvent(
Controller.EVENT_CHANGE,
BI.Events.EXPAND,
"",
this.expander
);
this.fireEvent(Expander.EVENT_EXPAND);
} else {
this.fireEvent(
Controller.EVENT_CHANGE,
BI.Events.COLLAPSE,
"",
this.expander
);
this.fireEvent(Expander.EVENT_COLLAPSE);
) {
toggle ? this._toggle() : this._popupView();
if (this.isExpanded()) {
this.fireEvent(
Controller.EVENT_CHANGE,
Events.EXPAND,
"",
this.expander
);
this.fireEvent(Expander.EVENT_EXPAND);
} else {
this.fireEvent(
Controller.EVENT_CHANGE,
Events.COLLAPSE,
"",
this.expander
);
this.fireEvent(Expander.EVENT_COLLAPSE);
}
}
}
},
EVENT_RESPONSE_TIME,
{
leading: true,
trailing: false,
}
},
BI.EVENT_RESPONSE_TIME,
{
leading: true,
trailing: false,
}
)
);
}
break;
default:
break;
)
);
}
break;
default:
break;
}
});
}
@ -223,7 +224,7 @@ export class Expander extends Widget {
);
this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
// self.setValue(self.getValue());
this.fireEvent(Expander.EVENT_CHANGE, value, obj);
}
@ -270,8 +271,8 @@ export class Expander extends Widget {
populate(items) {
// this._assertPopupView();
this.popupView && this.popupView.populate.apply(this.popupView, arguments);
this.expander.populate && this.expander.populate.apply(this.expander, arguments);
this.popupView && this.popupView.populate(...arguments);
this.expander.populate && this.expander.populate(...arguments);
}
_setEnable(arg) {

5
src/base/combination/group.combo.js

@ -10,7 +10,8 @@ import {
each,
formatEL,
clone,
createWidget
createWidget,
Events
} from "@/core";
import { Combo } from "./combo";
@ -115,7 +116,7 @@ export class ComboGroup extends Widget {
});
this.combo.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(ComboGroup.EVENT_CHANGE, obj);
}
});

61
src/base/combination/loader.js

@ -14,15 +14,18 @@ import {
isNotEmptyArray,
isNumber,
isObject,
each
each,
emptyFn,
Events,
LogicFactory
} from "@/core";
/**
* 加载控件
*
* Created by GUY on 2015/8/31.
* @class BI.Loader
* @extends BI.Widget
* @class Loader
* @extends Widget
*/
@shortcut()
@ -48,15 +51,15 @@ export class Loader extends Widget {
},
items: [],
itemsCreator: BI.emptyFn,
onLoaded: BI.emptyFn,
itemsCreator: emptyFn,
onLoaded: emptyFn,
// 下面是分页信息
count: false,
prev: false,
next: {},
hasPrev: BI.emptyFn,
hasNext: BI.emptyFn,
hasPrev: emptyFn,
hasNext: emptyFn,
});
}
@ -67,7 +70,7 @@ export class Loader extends Widget {
{ times: --this.times },
(...args) => {
this.prev.setLoaded();
this.prependItems.apply(this, args);
this.prependItems(...args);
}
]);
}
@ -79,7 +82,7 @@ export class Loader extends Widget {
{ times: ++this.times },
(...args) => {
this.next.setLoaded();
this.addItems.apply(this, args);
this.addItems(...args);
}
]);
}
@ -87,8 +90,6 @@ export class Loader extends Widget {
render() {
const {
itemsCreator,
prev,
next,
el,
items: optionsItems,
value,
@ -97,20 +98,20 @@ export class Loader extends Widget {
isDefaultInit,
} = this.options;
if (itemsCreator === false) {
prev = false;
next = false;
this.options.prev = false;
this.options.next = false;
}
if (prev !== false) {
if (this.options.prev !== false) {
this.prev = createWidget(
extend(
{
type: LoadingBar.xtype,
},
prev
this.options.prev
)
);
this.prev.on(Controller.EVENT_CHANGE, type => {
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this._prevLoad();
}
});
@ -130,22 +131,22 @@ export class Loader extends Widget {
});
this.button_group.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(Loader.EVENT_CHANGE, obj);
}
});
if (next !== false) {
if (this.options.next !== false) {
this.next = createWidget(
extend(
{
type: LoadingBar.xtype,
},
next
this.options.next
)
);
this.next.on(Controller.EVENT_CHANGE, type => {
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this._nextLoad();
}
});
@ -156,15 +157,15 @@ export class Loader extends Widget {
{
element: this,
},
BI.LogicFactory.createLogic(
BI.LogicFactory.createLogicTypeByDirection(direction),
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(direction),
extend(
{
scrolly: true,
},
logic,
{
items: BI.LogicFactory.createLogicItemsByDirection(
items: LogicFactory.createLogicItemsByDirection(
direction,
this.prev,
this.button_group,
@ -231,7 +232,7 @@ export class Loader extends Widget {
this.prev.setEnd();
}
}
this.button_group.prependItems.apply(this.button_group, arguments);
this.button_group.prependItems(...arguments);
}
addItems(items) {
@ -244,7 +245,7 @@ export class Loader extends Widget {
this.next.setEnd();
}
}
this.button_group.addItems.apply(this.button_group, arguments);
this.button_group.addItems(...arguments);
}
_populate(items) {
@ -256,7 +257,7 @@ export class Loader extends Widget {
if (args.length === 0) {
throw new Error("参数不能为空");
}
this.populate.apply(this, args);
this.populate(...args);
o.onLoaded();
}
]);
@ -286,11 +287,11 @@ export class Loader extends Widget {
}
populate() {
this._populate.apply(this, arguments) && this.button_group.populate.apply(this.button_group, arguments);
this._populate(...arguments) && this.button_group.populate(...arguments);
}
setNotSelectedValue() {
this.button_group.setNotSelectedValue.apply(this.button_group, arguments);
this.button_group.setNotSelectedValue(...arguments);
}
getNotSelectedValue() {
@ -298,11 +299,11 @@ export class Loader extends Widget {
}
setValue() {
this.button_group.setValue.apply(this.button_group, arguments);
this.button_group.setValue(...arguments);
}
getValue() {
return this.button_group.getValue.apply(this.button_group, arguments);
return this.button_group.getValue(...arguments);
}
getAllButtons() {

19
src/base/combination/navigation.js

@ -12,7 +12,10 @@ import {
each,
nextTick,
isKey,
values
values,
emptyFn,
LogicFactory,
Events
} from "@/core";
/**
@ -36,8 +39,8 @@ export class Navigation extends Widget {
tab: false,
cardCreator: v => createWidget(),
afterCardCreated: BI.emptyFn,
afterCardShow: BI.emptyFn,
afterCardCreated: emptyFn,
afterCardShow: emptyFn,
});
}
@ -54,10 +57,10 @@ export class Navigation extends Widget {
{
element: this,
},
BI.LogicFactory.createLogic(
BI.LogicFactory.createLogicTypeByDirection(direction),
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(direction),
extend({}, logic, {
items: BI.LogicFactory.createLogicItemsByDirection(direction, this.tab, this.layout),
items: LogicFactory.createLogicItemsByDirection(direction, this.tab, this.layout),
})
)
)
@ -107,7 +110,7 @@ export class Navigation extends Widget {
afterCardCreated(v) {
this.cardMap[v].on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(Navigation.EVENT_CHANGE, obj);
}
});
@ -123,7 +126,7 @@ export class Navigation extends Widget {
populate() {
const card = this.layout.getShowingCard();
if (card) {
return card.populate.apply(card, arguments);
return card.populate(...arguments);
}
}

77
src/base/combination/searcher.js

@ -14,7 +14,10 @@ import {
nextTick,
isEmptyString,
isNull,
BlankSplitChar
BlankSplitChar,
Events,
EVENT_RESPONSE_TIME,
Func
} from "@/core";
import { ButtonGroup } from "./group.button";
import { Maskers } from "@/base/0.base";
@ -23,8 +26,8 @@ import { Maskers } from "@/base/0.base";
* 搜索逻辑控件
*
* Created by GUY on 2015/9/28.
* @class BI.Searcher
* @extends BI.Widget
* @class Searcher
* @extends Widget
*/
@shortcut()
@ -94,28 +97,28 @@ export class Searcher extends Widget {
});
isDefaultInit && this._assertPopupView();
const search = debounce(bind(this._search, this), BI.EVENT_RESPONSE_TIME, {
const search = debounce(bind(this._search, this), EVENT_RESPONSE_TIME, {
leading: true,
trailing: false,
});
this.editor.on(Controller.EVENT_CHANGE, type => {
switch (type) {
case BI.Events.STARTEDIT:
this._startSearch();
break;
case BI.Events.EMPTY:
this._stopSearch();
break;
case BI.Events.CHANGE:
search();
break;
case BI.Events.PAUSE:
if (endWith(this.editor.getValue(), BlankSplitChar)) {
this._pauseSearch();
}
break;
default:
break;
case Events.STARTEDIT:
this._startSearch();
break;
case Events.EMPTY:
this._stopSearch();
break;
case Events.CHANGE:
search();
break;
case Events.PAUSE:
if (endWith(this.editor.getValue(), BlankSplitChar)) {
this._pauseSearch();
}
break;
default:
break;
}
});
}
@ -129,22 +132,22 @@ export class Searcher extends Widget {
});
this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
if (isAutoSync) {
const values = adapter && adapter.getValue();
switch (chooseType) {
case ButtonGroup.CHOOSE_TYPE_SINGLE:
adapter && adapter.setValue([obj.getValue()]);
break;
case ButtonGroup.CHOOSE_TYPE_MULTI:
if (!obj.isSelected()) {
adapter && adapter.setValue(deepWithout(values, obj.getValue()));
}
values.push(obj.getValue());
adapter && adapter.setValue(values);
break;
default:
break;
case ButtonGroup.CHOOSE_TYPE_SINGLE:
adapter && adapter.setValue([obj.getValue()]);
break;
case ButtonGroup.CHOOSE_TYPE_MULTI:
if (!obj.isSelected()) {
adapter && adapter.setValue(deepWithout(values, obj.getValue()));
}
values.push(obj.getValue());
adapter && adapter.setValue(values);
break;
default:
break;
}
}
this.fireEvent(Searcher.EVENT_CHANGE, value, obj);
@ -177,7 +180,7 @@ export class Searcher extends Widget {
this.fireEvent(Searcher.EVENT_START);
this.popupView.startSearch && this.popupView.startSearch();
// 搜索前先清空dom
// BI.Maskers.get(this.getName()).empty();
// Maskers.get(this.getName()).empty();
nextTick(name => {
Maskers.show(name);
}, this.getName());
@ -214,7 +217,7 @@ export class Searcher extends Widget {
}
if (isAutoSearch) {
const items = (adapter && ((adapter.getItems && adapter.getItems()) || adapter.attr("items"))) || [];
const finding = BI.Func.getSearchResult(items, keyword);
const finding = Func.getSearchResult(items, keyword);
const match = finding.match,
find = finding.find;
this.popupView.populate(find, match, keyword);
@ -237,7 +240,7 @@ export class Searcher extends Widget {
_args.push(keyword);
}
Maskers.show(this.getName());
this.popupView.populate.apply(this.popupView, _args);
this.popupView.populate(..._args);
isAutoSync && adapter && adapter.getValue && this.popupView.setValue(adapter.getValue());
this.popupView.loaded && this.popupView.loaded();
this.fireEvent(Searcher.EVENT_SEARCHING);
@ -346,7 +349,7 @@ export class Searcher extends Widget {
populate(result, searchResult, keyword) {
const { isAutoSync, adapter } = this.options;
this._assertPopupView();
this.popupView.populate.apply(this.popupView, arguments);
this.popupView.populate(...arguments);
if (isAutoSync && adapter && adapter.getValue) {
this.popupView.setValue(adapter.getValue());
}

135
src/base/combination/switcher.js

@ -8,7 +8,10 @@ import {
createWidget,
each,
debounce,
isNull
isNull,
Events,
Direction,
EVENT_RESPONSE_TIME
} from "@/core";
import { ButtonGroup } from "./group.button";
import { Maskers } from "@/base/0.base";
@ -18,8 +21,8 @@ import { Maskers } from "@/base/0.base";
* 切换显示或隐藏面板
*
* Created by GUY on 2015/11/2.
* @class BI.Switcher
* @extends BI.Widget
* @class Switcher
* @extends Widget
*/
@shortcut()
@ -40,7 +43,7 @@ export class Switcher extends Widget {
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-switcher",
direction: BI.Direction.Top,
direction: Direction.Top,
trigger: "click",
toggle: true,
el: {},
@ -61,21 +64,21 @@ export class Switcher extends Widget {
});
this.switcher.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
if (this.isEnabled() && this.isValid()) {
if (type === BI.Events.EXPAND) {
if (type === Events.EXPAND) {
this._popupView();
}
if (type === BI.Events.COLLAPSE) {
if (type === Events.COLLAPSE) {
this._hideView();
}
if (type === BI.Events.EXPAND) {
if (type === Events.EXPAND) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.fireEvent(Switcher.EVENT_EXPAND);
}
if (type === BI.Events.COLLAPSE) {
if (type === Events.COLLAPSE) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.isViewVisible() && this.fireEvent(Switcher.EVENT_COLLAPSE);
}
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(Switcher.EVENT_TRIGGER_CHANGE, value, obj);
}
}
@ -118,62 +121,62 @@ export class Switcher extends Widget {
const evs = this.options.trigger.split(",");
each(evs, (i, e) => {
switch (e) {
case "hover":
this.element[e](
e => {
if (this.isEnabled() && this.switcher.isEnabled()) {
this._popupView();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, "", this.switcher);
this.fireEvent(Switcher.EVENT_EXPAND);
}
},
() => {
if (this.isEnabled() && this.switcher.isEnabled() && toggle) {
this._hideView();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", this.switcher);
this.fireEvent(Switcher.EVENT_COLLAPSE);
case "hover":
this.element[e](
e => {
if (this.isEnabled() && this.switcher.isEnabled()) {
this._popupView();
this.fireEvent(Controller.EVENT_CHANGE, Events.EXPAND, "", this.switcher);
this.fireEvent(Switcher.EVENT_EXPAND);
}
},
() => {
if (this.isEnabled() && this.switcher.isEnabled() && toggle) {
this._hideView();
this.fireEvent(Controller.EVENT_CHANGE, Events.COLLAPSE, "", this.switcher);
this.fireEvent(Switcher.EVENT_COLLAPSE);
}
}
}
);
break;
default:
if (e) {
this.element.off(`${e}.${this.getName()}`).on(
`${e}.${this.getName()}`,
debounce(
e => {
if (this.switcher.element.__isMouseInBounds__(e)) {
if (this.isEnabled() && this.switcher.isEnabled()) {
toggle ? this._toggle() : this._popupView();
if (this.isExpanded()) {
this.fireEvent(
Controller.EVENT_CHANGE,
BI.Events.EXPAND,
"",
this.switcher
);
this.fireEvent(Switcher.EVENT_EXPAND);
} else {
this.fireEvent(
Controller.EVENT_CHANGE,
BI.Events.COLLAPSE,
"",
this.switcher
);
this.fireEvent(Switcher.EVENT_COLLAPSE);
);
break;
default:
if (e) {
this.element.off(`${e}.${this.getName()}`).on(
`${e}.${this.getName()}`,
debounce(
e => {
if (this.switcher.element.__isMouseInBounds__(e)) {
if (this.isEnabled() && this.switcher.isEnabled()) {
toggle ? this._toggle() : this._popupView();
if (this.isExpanded()) {
this.fireEvent(
Controller.EVENT_CHANGE,
Events.EXPAND,
"",
this.switcher
);
this.fireEvent(Switcher.EVENT_EXPAND);
} else {
this.fireEvent(
Controller.EVENT_CHANGE,
Events.COLLAPSE,
"",
this.switcher
);
this.fireEvent(Switcher.EVENT_COLLAPSE);
}
}
}
},
EVENT_RESPONSE_TIME,
{
leading: true,
trailing: false,
}
},
BI.EVENT_RESPONSE_TIME,
{
leading: true,
trailing: false,
}
)
);
}
break;
)
);
}
break;
}
});
}
@ -206,11 +209,11 @@ export class Switcher extends Widget {
);
this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(Switcher.EVENT_CHANGE, value, obj);
}
});
if (direction !== BI.Direction.Custom && !adapter) {
if (direction !== Direction.Custom && !adapter) {
createWidget({
type: VerticalLayout.xtype,
scrolly: false,
@ -250,12 +253,12 @@ export class Switcher extends Widget {
_populate() {
this._assertPopupView();
this.popupView.populate.apply(this.popupView, arguments);
this.popupView.populate(...arguments);
}
populate(items) {
this._populate.apply(this, arguments);
this.switcher.populate && this.switcher.populate.apply(this.switcher, arguments);
this._populate(...arguments);
this.switcher.populate && this.switcher.populate(...arguments);
}
_setEnable(arg) {

11
src/base/combination/tab.js

@ -12,7 +12,8 @@ import {
isFunction,
contains,
any,
isEqual
isEqual,
LogicFactory
} from "@/core";
/**
@ -58,10 +59,10 @@ export class Tab extends Widget {
{
element: this,
},
BI.LogicFactory.createLogic(
BI.LogicFactory.createLogicTypeByDirection(direction),
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(direction),
extend({}, logic, {
items: BI.LogicFactory.createLogicItemsByDirection(direction, this.tab, this.layout),
items: LogicFactory.createLogicItemsByDirection(direction, this.tab, this.layout),
})
)
)
@ -188,7 +189,7 @@ export class Tab extends Widget {
populate() {
const card = this.layout.getShowingCard();
if (card) {
return card.populate && card.populate.apply(card, arguments);
return card.populate && card.populate(...arguments);
}
}

8
src/base/combination/tree.button.js

@ -1,11 +1,5 @@
import { ButtonGroup } from "./group.button";
import { shortcut, Widget, extend, isArray, each, isFunction, deepContains, concat, any, contains } from "@/core";
/**
* Created by GUY on 2015/8/10.
* @class BI.ButtonTree
* @extends BI.ButtonGroup
*/
import { shortcut, extend, isArray, each, isFunction, deepContains, concat, any, contains } from "@/core";
@shortcut()
export class ButtonTree extends ButtonGroup {

6
src/base/context.js

@ -1,4 +1,4 @@
import { shortcut, Widget, createWidget, Controller } from "@/core";
import { shortcut, Widget, createWidget, Controller, useContext, watch } from "@/core";
@shortcut()
export class Context extends Widget {
@ -10,7 +10,7 @@ export class Context extends Widget {
const self = this,
o = this.options;
if (o.context) {
this.context = BI.useContext(o.context);
this.context = useContext(o.context);
}
this.widget = createWidget((o.items[0] || o.el)(this.context), {
element: this,
@ -23,7 +23,7 @@ export class Context extends Widget {
__initWatch() {
super.__initWatch.call(this);
const o = this.options;
BI.watch(this.context, o.context, o.watch);
watch(this.context, o.context, o.watch);
}
setValue(v) {

33
src/base/foundation/message.js

@ -1,9 +1,10 @@
/**
* z-index在1亿层级
* 弹出提示消息框用于模拟阻塞操作通过回调函数实现
* @class BI.Msg
* @class Msg
*/
import { Widget, isString, isNull, isFunction, createWidget, remove, each } from "../../core";
import { Widget, isString, isNull, isFunction, createWidget, remove, each, emptyFn, delay, zIndex_tip, i18nText, KeyCode, isPlainObject, SIZE_CONSANTS } from "../../core";
import { Toast } from "../single";
export const Msg = (() => {
let $mask, $pop;
@ -20,7 +21,7 @@ export const Msg = (() => {
this._show(true, title, message, callback);
},
prompt (title, message, value, callback, min_width) {
// BI.Msg.prompt(title, message, value, callback, min_width);
// Msg.prompt(title, message, value, callback, min_width);
},
toast (message, options, context) {
isString(options) && (options = { level: options });
@ -28,7 +29,7 @@ export const Msg = (() => {
context = context || Widget._renderEngine.createElement("body");
const level = options.level || "common";
const autoClose = isNull(options.autoClose) ? true : options.autoClose;
const callback = isFunction(options.callback) ? options.callback : BI.emptyFn;
const callback = isFunction(options.callback) ? options.callback : emptyFn;
const toast = createWidget({
type: "bi.toast",
cls: "bi-message-animate bi-message-leave",
@ -38,10 +39,10 @@ export const Msg = (() => {
text: message,
listeners: [
{
eventName: BI.Toast.EVENT_DESTORY,
eventName: Toast.EVENT_DESTORY,
action () {
remove(toastStack, toast.element);
let _height = BI.SIZE_CONSANTS.TOAST_TOP;
let _height = SIZE_CONSANTS.TOAST_TOP;
each(toastStack, (i, element) => {
element.css({ top: _height });
_height += element.outerHeight() + 10;
@ -51,7 +52,7 @@ export const Msg = (() => {
}
],
});
let height = BI.SIZE_CONSANTS.TOAST_TOP;
let height = SIZE_CONSANTS.TOAST_TOP;
each(toastStack, (i, element) => {
height += element.outerHeight() + 10;
});
@ -71,7 +72,7 @@ export const Msg = (() => {
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose &&
BI.delay(() => {
delay(() => {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
toast.destroy?.();
}, 5000);
@ -87,7 +88,7 @@ export const Msg = (() => {
.createElement("<div class=\"bi-z-index-mask\">")
.css({
position: "absolute",
zIndex: BI.zIndex_tip - 2,
zIndex: zIndex_tip - 2,
top: 0,
left: 0,
right: 0,
@ -99,7 +100,7 @@ export const Msg = (() => {
.createElement("<div class=\"bi-message-depend\">")
.css({
position: "absolute",
zIndex: BI.zIndex_tip - 1,
zIndex: zIndex_tip - 1,
top: 0,
left: 0,
right: 0,
@ -119,7 +120,7 @@ export const Msg = (() => {
controlItems.push({
el: {
type: "bi.button",
text: BI.i18nText("BI-Basic_Cancel"),
text: i18nText("BI-Basic_Cancel"),
level: "ignore",
handler () {
close();
@ -133,7 +134,7 @@ export const Msg = (() => {
controlItems.push({
el: {
type: "bi.button",
text: BI.i18nText("BI-Basic_OK"),
text: i18nText("BI-Basic_OK"),
handler () {
close();
if (isFunction(callback)) {
@ -153,12 +154,12 @@ export const Msg = (() => {
},
mounted () {
this.element.keyup(e => {
if (e.keyCode === BI.KeyCode.ENTER) {
if (e.keyCode === KeyCode.ENTER) {
close();
if (isFunction(callback)) {
callback.apply(null, [true]);
}
} else if (e.keyCode === BI.KeyCode.ESCAPE) {
} else if (e.keyCode === KeyCode.ESCAPE) {
close();
if (hasCancel === true) {
if (isFunction(callback)) {
@ -182,7 +183,7 @@ export const Msg = (() => {
el: {
type: "bi.label",
cls: "bi-font-bold",
text: title || BI.i18nText("BI-Basic_Prompt"),
text: title || i18nText("BI-Basic_Prompt"),
textAlign: "left",
hgap: 20,
height: 40,
@ -207,7 +208,7 @@ export const Msg = (() => {
height: 40,
},
center: {
el: BI.isPlainObject(message)
el: isPlainObject(message)
? message
: {
type: "bi.label",

15
src/base/grid/grid.js

@ -13,18 +13,11 @@ import {
ScalingCellSizeAndPositionManager,
clamp,
isEmpty,
nextTick
nextTick,
DOM
} from "@/core";
import { Label } from "../single";
/**
* GridView
*
* Created by GUY on 2016/1/11.
* @class BI.GridView
* @extends BI.Widget
*/
@shortcut()
export class GridView extends Widget {
_defaultConfig() {
@ -386,14 +379,14 @@ export class GridView extends Widget {
_getMaxScrollLeft() {
return Math.max(
0,
this._getContainerWidth() - this.options.width + (this._isOverflowX() ? BI.DOM.getScrollWidth() : 0)
this._getContainerWidth() - this.options.width + (this._isOverflowX() ? DOM.getScrollWidth() : 0)
);
}
_getMaxScrollTop() {
return Math.max(
0,
this._getContainerHeight() - this.options.height + (this._isOverflowY() ? BI.DOM.getScrollWidth() : 0)
this._getContainerHeight() - this.options.height + (this._isOverflowY() ? DOM.getScrollWidth() : 0)
);
}

152
src/base/layer/layer.drawer.js

@ -13,8 +13,8 @@ import { Label, IconButton } from "../single";
/**
* Popover弹出层
* @class BI.Popover
* @extends BI.Widget
* @class Popover
* @extends Widget
*/
@shortcut()
@ -43,16 +43,16 @@ export class Drawer extends Widget {
const { size, height, placement, width } = this.options;
let sizeValue = 0;
switch (size) {
case "big":
sizeValue = 736;
break;
case "small":
sizeValue = 200;
break;
case "normal":
default:
sizeValue = 378;
break;
case "big":
sizeValue = 736;
break;
case "small":
sizeValue = 200;
break;
case "normal":
default:
sizeValue = 378;
break;
}
if (placement === "top" || placement === "bottom") {
return {
@ -147,66 +147,66 @@ export class Drawer extends Widget {
mounted() {
const { placement } = this.options;
switch (placement) {
case "right":
this.element.css({
top: 0,
left: "100%",
bottom: 0,
});
break;
case "left":
this.element.css({
top: 0,
right: "100%",
bottom: 0,
});
break;
case "top":
this.element.css({
left: 0,
right: 0,
bottom: "100%",
});
break;
case "bottom":
this.element.css({
left: 0,
right: 0,
top: "100%",
});
break;
default:
break;
}
}
show(callback) {
const { placement } = this.options;
requestAnimationFrame(() => {
const size = this._getSuitableSize();
switch (placement) {
case "right":
this.element.css({
left: `calc(100% - ${size.width}px)`,
top: 0,
left: "100%",
bottom: 0,
});
break;
case "left":
this.element.css({
right: `calc(100% - ${size.width}px)`,
top: 0,
right: "100%",
bottom: 0,
});
break;
case "top":
this.element.css({
bottom: `calc(100% - ${size.height}px)`,
left: 0,
right: 0,
bottom: "100%",
});
break;
case "bottom":
this.element.css({
top: `calc(100% - ${size.height}px)`,
left: 0,
right: 0,
top: "100%",
});
break;
default:
break;
}
}
show(callback) {
const { placement } = this.options;
requestAnimationFrame(() => {
const size = this._getSuitableSize();
switch (placement) {
case "right":
this.element.css({
left: `calc(100% - ${size.width}px)`,
});
break;
case "left":
this.element.css({
right: `calc(100% - ${size.width}px)`,
});
break;
case "top":
this.element.css({
bottom: `calc(100% - ${size.height}px)`,
});
break;
case "bottom":
this.element.css({
top: `calc(100% - ${size.height}px)`,
});
break;
default:
break;
}
callback && callback();
});
@ -216,28 +216,28 @@ export class Drawer extends Widget {
const { placement } = this.options;
requestAnimationFrame(() => {
switch (placement) {
case "right":
this.element.css({
left: "100%",
});
break;
case "left":
this.element.css({
right: "100%",
});
break;
case "top":
this.element.css({
bottom: "100%",
});
break;
case "bottom":
this.element.css({
top: "100%",
});
break;
default:
break;
case "right":
this.element.css({
left: "100%",
});
break;
case "left":
this.element.css({
right: "100%",
});
break;
case "top":
this.element.css({
bottom: "100%",
});
break;
case "bottom":
this.element.css({
top: "100%",
});
break;
default:
break;
}
setTimeout(callback, 300);
});

56
src/base/layer/layer.popover.js

@ -9,14 +9,18 @@ import {
clamp,
isPlainObject,
extend,
isNotNull
isNotNull,
MouseMoveTracker,
i18nText,
SIZE_CONSANTS
} from "@/core";
import { Label, IconButton, Button } from "../single";
import { Resizers } from "../0.base";
/**
* Popover弹出层
* @class BI.Popover
* @extends BI.Widget
* @class Popover
* @extends Widget
*/
@shortcut()
@ -43,8 +47,8 @@ export class Popover extends Widget {
footer: null,
footerHeight: 44,
closable: true, // BI-40839 是否显示右上角的关闭按钮
bodyHgap: BI.SIZE_CONSANTS.H_GAP_SIZE,
bodyTgap: BI.SIZE_CONSANTS.V_GAP_SIZE,
bodyHgap: SIZE_CONSANTS.H_GAP_SIZE,
bodyTgap: SIZE_CONSANTS.V_GAP_SIZE,
};
}
@ -61,7 +65,7 @@ export class Popover extends Widget {
this.startX = 0;
this.startY = 0;
const size = this._calculateSize();
this.tracker = new BI.MouseMoveTracker(
this.tracker = new MouseMoveTracker(
(deltaX, deltaY) => {
const W = Widget._renderEngine.createElement("body").width();
const H = Widget._renderEngine.createElement("body").height();
@ -72,7 +76,7 @@ export class Popover extends Widget {
top: `${clamp(this.startY, 0, H - this.element.height())}px`,
});
// BI-12134 没有什么特别好的方法
BI.Resizers._resize({
Resizers._resize({
target: this.element[0],
});
},
@ -109,8 +113,8 @@ export class Popover extends Widget {
},
top: 0,
bottom: 0,
left: BI.SIZE_CONSANTS.H_GAP_SIZE,
right: closable ? 0 : BI.SIZE_CONSANTS.H_GAP_SIZE,
left: SIZE_CONSANTS.H_GAP_SIZE,
right: closable ? 0 : SIZE_CONSANTS.H_GAP_SIZE,
}
],
},
@ -181,9 +185,9 @@ export class Popover extends Widget {
items: [
{
el: footer,
left: BI.SIZE_CONSANTS.H_GAP_SIZE,
left: SIZE_CONSANTS.H_GAP_SIZE,
top: 0,
right: BI.SIZE_CONSANTS.H_GAP_SIZE,
right: SIZE_CONSANTS.H_GAP_SIZE,
bottom: 0,
}
],
@ -246,20 +250,20 @@ export class Popover extends Widget {
const sizeValue = {};
if (isNotNull(size)) {
switch (size) {
case this._constant.SIZE.SMALL:
sizeValue.width = 450;
sizeValue.height = 200;
sizeValue.type = "small";
break;
case this._constant.SIZE.BIG:
sizeValue.width = 900;
sizeValue.height = 500;
sizeValue.type = "big";
break;
default:
sizeValue.width = 550;
sizeValue.height = 500;
sizeValue.type = "default";
case this._constant.SIZE.SMALL:
sizeValue.width = 450;
sizeValue.height = 200;
sizeValue.type = "small";
break;
case this._constant.SIZE.BIG:
sizeValue.width = 900;
sizeValue.height = 500;
sizeValue.type = "big";
break;
default:
sizeValue.width = 550;
sizeValue.height = 500;
sizeValue.type = "default";
}
}
@ -296,7 +300,7 @@ export class BarPopover extends Popover {
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
btns: [BI.i18nText("BI-Basic_OK"), BI.i18nText("BI-Basic_Cancel")],
btns: [i18nText("BI-Basic_OK"), i18nText("BI-Basic_Cancel")],
});
}

409
src/base/layer/layer.popup.js

@ -10,13 +10,18 @@ import {
Controller,
createWidget,
createItems,
clamp
clamp,
Direction,
zIndex_popup,
pixFormat,
LogicFactory,
Events
} from "@/core";
/**
* 下拉框弹出层, zIndex在1000w
* @class BI.PopupView
* @extends BI.Widget
* @class PopupView
* @extends Widget
*/
@shortcut()
@ -46,7 +51,7 @@ export class PopupView extends Widget {
innerVgap: 0,
innerHgap: 0,
showArrow: false,
direction: BI.Direction.Top, // 工具栏的方向
direction: Direction.Top, // 工具栏的方向
stopEvent: false, // 是否停止mousedown、mouseup事件
stopPropagation: false, // 是否停止mousedown、mouseup向上冒泡
logic: {
@ -97,9 +102,9 @@ export class PopupView extends Widget {
}
this.element
.css({
"z-index": BI.zIndex_popup,
"min-width": BI.pixFormat(minWidth),
"max-width": BI.pixFormat(maxWidth),
"z-index": zIndex_popup,
"min-width": pixFormat(minWidth),
"max-width": pixFormat(maxWidth),
})
.bind({ click: fn });
@ -114,7 +119,7 @@ export class PopupView extends Widget {
this.view.on(Controller.EVENT_CHANGE, (type, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, ...args);
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(PopupView.EVENT_CHANGE);
}
});
@ -124,8 +129,8 @@ export class PopupView extends Widget {
{
element: this,
},
BI.LogicFactory.createLogic(
BI.LogicFactory.createLogicTypeByDirection(direction),
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(direction),
extend({}, logic, {
scrolly: false,
lgap,
@ -134,16 +139,16 @@ export class PopupView extends Widget {
bgap,
vgap,
hgap,
items: BI.LogicFactory.createLogicItemsByDirection(
items: LogicFactory.createLogicItemsByDirection(
direction,
extend(
{
cls: `list-view-outer bi-card list-view-shadow${primary ? " bi-primary" : ""}`,
},
BI.LogicFactory.createLogic(
BI.LogicFactory.createLogicTypeByDirection(direction),
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(direction),
extend({}, logic, {
items: BI.LogicFactory.createLogicItemsByDirection(
items: LogicFactory.createLogicItemsByDirection(
direction,
this.tool,
this.tab,
@ -202,11 +207,11 @@ export class PopupView extends Widget {
const { el, value, minHeight, innerVgap, innerHgap } = this.options;
this.button_group = createWidget(el, { type: ButtonGroup.xtype, value });
this.button_group.element.css({
"min-height": BI.pixFormat(minHeight),
"padding-top": BI.pixFormat(innerVgap),
"padding-bottom": BI.pixFormat(innerVgap),
"padding-left": BI.pixFormat(innerHgap),
"padding-right": BI.pixFormat(innerHgap),
"min-height": pixFormat(minHeight),
"padding-top": pixFormat(innerVgap),
"padding-bottom": pixFormat(innerVgap),
"padding-left": pixFormat(innerHgap),
"padding-right": pixFormat(innerHgap),
});
return this.button_group;
@ -281,189 +286,189 @@ export class PopupView extends Widget {
const maxTop = Math.min(popupHeight - 16 - 4, offset.top + position.height - 16 - 4);
const maxBottom = Math.min(popupHeight - 16 - 4, bodyHeight - (offset.top + position.height - 16 - 4));
switch (direction) {
case "bottom":
case "bottom,right":
direction = "bottom";
style = {
case "bottom":
case "bottom,right":
direction = "bottom";
style = {
// 5表示留出一定的空间
left: clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft),
};
wrapperStyle = {
top: tgap + vgap,
left: 0,
right: "",
bottom: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH,
bottom: "",
};
break;
case "bottom,left":
direction = "bottom";
style = {
right: clamp(
((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8,
minRight,
maxRight
),
};
wrapperStyle = {
top: bgap + vgap,
left: "",
right: 0,
bottom: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH,
bottom: "",
};
break;
case "top":
case "top,right":
direction = "top";
style = {
left: clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft),
};
wrapperStyle = {
bottom: bgap + vgap,
left: 0,
right: "",
top: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: "",
bottom: -this._const.TRIANGLE_LENGTH,
};
break;
case "top,left":
direction = "top";
style = {
right: clamp(
((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8,
minRight,
maxRight
),
};
wrapperStyle = {
bottom: bgap + vgap,
right: 0,
left: "",
top: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: "",
bottom: -this._const.TRIANGLE_LENGTH,
};
break;
case "left":
case "left,bottom":
direction = "left";
style = {
top: clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop),
};
wrapperStyle = {
right: rgap + hgap,
top: 0,
bottom: "",
left: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH,
left: "",
};
break;
case "left,top":
direction = "left";
style = {
bottom: clamp(
((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8,
minBottom,
maxBottom
),
};
wrapperStyle = {
right: rgap + hgap,
bottom: 0,
top: "",
left: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH,
left: "",
};
break;
case "right":
case "right,bottom":
direction = "right";
style = {
top: clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop),
};
wrapperStyle = {
left: lgap + hgap,
top: 0,
bottom: "",
right: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH,
right: "",
};
break;
case "right,top":
direction = "right";
style = {
bottom: clamp(
((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8,
minBottom,
maxBottom
),
};
wrapperStyle = {
left: lgap + hgap,
bottom: 0,
top: "",
right: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH,
right: "",
};
break;
case "right,innerRight":
break;
case "right,innerLeft":
break;
case "innerRight":
break;
case "innerLeft":
break;
default:
break;
left: clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft),
};
wrapperStyle = {
top: tgap + vgap,
left: 0,
right: "",
bottom: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH,
bottom: "",
};
break;
case "bottom,left":
direction = "bottom";
style = {
right: clamp(
((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8,
minRight,
maxRight
),
};
wrapperStyle = {
top: bgap + vgap,
left: "",
right: 0,
bottom: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH,
bottom: "",
};
break;
case "top":
case "top,right":
direction = "top";
style = {
left: clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft),
};
wrapperStyle = {
bottom: bgap + vgap,
left: 0,
right: "",
top: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: "",
bottom: -this._const.TRIANGLE_LENGTH,
};
break;
case "top,left":
direction = "top";
style = {
right: clamp(
((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8,
minRight,
maxRight
),
};
wrapperStyle = {
bottom: bgap + vgap,
right: 0,
left: "",
top: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: "",
bottom: -this._const.TRIANGLE_LENGTH,
};
break;
case "left":
case "left,bottom":
direction = "left";
style = {
top: clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop),
};
wrapperStyle = {
right: rgap + hgap,
top: 0,
bottom: "",
left: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH,
left: "",
};
break;
case "left,top":
direction = "left";
style = {
bottom: clamp(
((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8,
minBottom,
maxBottom
),
};
wrapperStyle = {
right: rgap + hgap,
bottom: 0,
top: "",
left: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH,
left: "",
};
break;
case "right":
case "right,bottom":
direction = "right";
style = {
top: clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop),
};
wrapperStyle = {
left: lgap + hgap,
top: 0,
bottom: "",
right: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH,
right: "",
};
break;
case "right,top":
direction = "right";
style = {
bottom: clamp(
((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8,
minBottom,
maxBottom
),
};
wrapperStyle = {
left: lgap + hgap,
bottom: 0,
top: "",
right: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH,
right: "",
};
break;
case "right,innerRight":
break;
case "right,innerLeft":
break;
case "innerRight":
break;
case "innerLeft":
break;
default:
break;
}
this.element
.removeClass("left")
@ -497,7 +502,7 @@ export class PopupView extends Widget {
const resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap;
this.view.resetHeight
? this.view.resetHeight(resetHeight)
: this.view.element.css({ "max-height": BI.pixFormat(resetHeight) });
: this.view.element.css({ "max-height": pixFormat(resetHeight) });
}
setValue(selectedValues) {

16
src/base/layer/layer.searcher.js

@ -1,13 +1,13 @@
import { ButtonGroup } from "../combination";
import { VerticalLayout, Layout, shortcut, extend, createWidget, Controller, isNotEmptyArray } from "@/core";
import { VerticalLayout, Layout, shortcut, extend, createWidget, Controller, isNotEmptyArray, Selection, i18nText, Events } from "@/core";
import { Pane } from "../1.pane";
/**
* 搜索面板
*
* Created by GUY on 2015/9/28.
* @class BI.SearcherView
* @extends BI.Pane
* @class SearcherView
* @extends Pane
*/
@shortcut()
@ -20,8 +20,8 @@ export class SearcherView extends Pane {
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-searcher-view bi-card`,
tipText: BI.i18nText("BI-No_Select"),
chooseType: BI.Selection.Single,
tipText: i18nText("BI-No_Select"),
chooseType: Selection.Single,
matcher: {
// 完全匹配的构造器
@ -68,7 +68,7 @@ export class SearcherView extends Pane {
});
this.matcher.on(Controller.EVENT_CHANGE, (type, val, ob, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, val, ob, ...args);
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(SearcherView.EVENT_CHANGE, val, ob);
}
});
@ -99,8 +99,8 @@ export class SearcherView extends Pane {
});
this.searcher.on(Controller.EVENT_CHANGE, (type, val, ob, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, val, ob, ...args);
if (type === BI.Events.CLICK) {
this.fireEvent(BI.SearcherView.EVENT_CHANGE, val, ob);
if (type === Events.CLICK) {
this.fireEvent(SearcherView.EVENT_CHANGE, val, ob);
}
});

12
src/base/list/listview.js

@ -1,11 +1,11 @@
import { VerticalLayout, Widget, shortcut, extend, isFunction } from "@/core";
import { VerticalLayout, Widget, shortcut, extend, isFunction, ResizeDetector } from "@/core";
/**
* 边滚动边加载的列表控件
*
* Created by GUY on 2017/5/23.
* @class BI.ListView
* @extends BI.Widget
* @class ListView
* @extends Widget
*/
@shortcut()
@ -66,7 +66,7 @@ export class ListView extends Widget {
});
let lastWidth = this.element.width(),
lastHeight = this.element.height();
BI.ResizeDetector.addResizeListener(this, () => {
ResizeDetector.addResizeListener(this, () => {
if (!this.element.is(":visible")) {
return;
}
@ -93,8 +93,8 @@ export class ListView extends Widget {
lastHeight = getElementHeight();
while (lastHeight < minContentHeight && index < items.length) {
const itemsArr = items.slice(index, index + blockSize);
// eslint-disable-next-line no-loop-func
this.container.addItems(
// eslint-disable-next-line no-loop-func
itemsArr.map((item, i) => itemFormatter(item, index + i)),
this
);
@ -148,7 +148,7 @@ export class ListView extends Widget {
}
beforeDestroy() {
BI.ResizeDetector.removeResizeListener(this);
ResizeDetector.removeResizeListener(this);
this.restore();
}
}

12
src/base/list/virtualgrouplist.js

@ -1,12 +1,12 @@
import { VerticalLayout, Layout, Widget, shortcut, extend, isFunction, isNumber, PrefixIntervalTree } from "@/core";
import { VerticalLayout, Layout, Widget, shortcut, extend, isFunction, isNumber, PrefixIntervalTree, ResizeDetector } from "@/core";
import { VirtualGroup } from "../combination";
/**
* 同时用于virtualGroup和virtualList特性的虚拟列表
*
* Created by GUY on 2017/5/22.
* @class BI.VirtualList
* @extends BI.Widget
* @class VirtualList
* @extends Widget
*/
@shortcut()
@ -89,7 +89,7 @@ export class VirtualGroupList extends Widget {
this.ticking = true;
}
});
BI.ResizeDetector.addResizeListener(this, () => {
ResizeDetector.addResizeListener(this, () => {
if (this.element.is(":visible")) {
this._calculateBlocksToRender();
}
@ -112,8 +112,8 @@ export class VirtualGroupList extends Widget {
lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight();
while (lastHeight < minContentHeight && index < items.length) {
const itemsArr = items.slice(index, index + blockSize);
// eslint-disable-next-line no-loop-func
this.container[this.renderedIndex === -1 ? "populate" : "addItems"](
// eslint-disable-next-line no-loop-func
itemsArr.map((item, i) => itemFormatter(item, index + i)),
this
);
@ -211,7 +211,7 @@ export class VirtualGroupList extends Widget {
}
beforeDestroy() {
BI.ResizeDetector.removeResizeListener(this);
ResizeDetector.removeResizeListener(this);
this.restore();
}
}

12
src/base/list/virtuallist.js

@ -1,11 +1,11 @@
import { VerticalLayout, Layout, Widget, shortcut, isFunction, each, PrefixIntervalTree } from "@/core";
import { VerticalLayout, Layout, Widget, shortcut, isFunction, each, PrefixIntervalTree, ResizeDetector } from "@/core";
/**
* 虚拟列表
*
* Created by GUY on 2017/5/22.
* @class BI.VirtualList
* @extends BI.Widget
* @class VirtualList
* @extends Widget
*/
@shortcut()
@ -68,7 +68,7 @@ export class VirtualList extends Widget {
o.scrollTop = this.element.scrollTop();
this._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, () => {
ResizeDetector.addResizeListener(this, () => {
if (this.element.is(":visible")) {
this._calculateBlocksToRender();
}
@ -87,8 +87,8 @@ export class VirtualList extends Widget {
lastHeight = getElementHeight();
while (lastHeight < minContentHeight && index < items.length) {
const itemsArr = items.slice(index, index + blockSize);
// eslint-disable-next-line no-loop-func
this.container.addItems(
// eslint-disable-next-line no-loop-func
itemsArr.map((item, i) => itemFormatter(item, index + i)),
this
);
@ -220,7 +220,7 @@ export class VirtualList extends Widget {
}
beforeDestroy() {
BI.ResizeDetector.removeResizeListener(this);
ResizeDetector.removeResizeListener(this);
this.restore();
}
}

63
src/base/pager/pager.js

@ -10,7 +10,10 @@ import {
map,
stripEL,
formatEL,
Controller
Controller,
Events,
MIN,
MAX
} from "@/core";
import { Label } from "../single";
import { ButtonGroup } from "../combination";
@ -19,8 +22,8 @@ import { ButtonGroup } from "../combination";
* 分页控件
*
* Created by GUY on 2015/8/31.
* @class BI.Pager
* @extends BI.Widget
* @class Pager
* @extends Widget
*/
@shortcut()
@ -66,7 +69,7 @@ export class Pager extends Widget {
this.currPage = result(this.options, "curr");
// 翻页太灵敏
// this._lock = false;
// this._debouce = BI.debounce(function () {
// this._debouce = debounce(function () {
// self._lock = false;
// }, 300);
this._populate();
@ -241,24 +244,24 @@ export class Pager extends Widget {
// }
// self._lock = true;
// self._debouce();
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
const v = this.button_group.getValue()[0];
switch (v) {
case "first":
this.currPage = 1;
break;
case "last":
this.currPage = pages;
break;
case "prev":
this.currPage--;
break;
case "next":
this.currPage++;
break;
default:
this.currPage = v;
break;
case "first":
this.currPage = 1;
break;
case "last":
this.currPage = pages;
break;
case "prev":
this.currPage--;
break;
case "next":
this.currPage++;
break;
default:
this.currPage = v;
break;
}
jump.apply(this, [
{
@ -317,16 +320,16 @@ export class Pager extends Widget {
getValue() {
const val = this.button_group.getValue()[0];
switch (val) {
case "prev":
return -1;
case "next":
return 1;
case "first":
return BI.MIN;
case "last":
return BI.MAX;
default:
return val;
case "prev":
return -1;
case "next":
return 1;
case "first":
return MIN;
case "last":
return MAX;
default:
return val;
}
}

60
src/base/single/1.text.js

@ -1,10 +1,10 @@
import { Layout, DefaultLayout, shortcut } from "@/core";
import { Layout, DefaultLayout, shortcut, pixFormat, isWidthOrHeight, emptyFn, createWidget, isKey, isFunction, isUndefined } from "@/core";
import { Single } from "./0.single";
/**
* guy 表示一行数据通过position来定位位置的数据
* @class BI.Text
* @extends BI.Single
* @class Text
* @extends Single
*/
@shortcut()
@ -50,48 +50,48 @@ export class Text extends Single {
} = this.options;
if (hgap + lgap > 0) {
this.element.css({
"padding-left": BI.pixFormat(hgap + lgap),
"padding-left": pixFormat(hgap + lgap),
});
}
if (hgap + rgap > 0) {
this.element.css({
"padding-right": BI.pixFormat(hgap + rgap),
"padding-right": pixFormat(hgap + rgap),
});
}
if (vgap + tgap > 0) {
this.element.css({
"padding-top": BI.pixFormat(vgap + tgap),
"padding-top": pixFormat(vgap + tgap),
});
}
if (vgap + bgap > 0) {
this.element.css({
"padding-bottom": BI.pixFormat(vgap + bgap),
"padding-bottom": pixFormat(vgap + bgap),
});
}
if (BI.isWidthOrHeight(height)) {
this.element.css({ lineHeight: BI.pixFormat(height) });
if (isWidthOrHeight(height)) {
this.element.css({ lineHeight: pixFormat(height) });
}
if (BI.isWidthOrHeight(lineHeight)) {
this.element.css({ lineHeight: BI.pixFormat(lineHeight) });
if (isWidthOrHeight(lineHeight)) {
this.element.css({ lineHeight: pixFormat(lineHeight) });
}
if (BI.isWidthOrHeight(maxWidth)) {
this.element.css({ maxWidth: BI.pixFormat(maxWidth) });
if (isWidthOrHeight(maxWidth)) {
this.element.css({ maxWidth: pixFormat(maxWidth) });
}
this.element.css({
textAlign,
whiteSpace: this._getTextWrap(),
textOverflow: whiteSpace === "nowrap" ? "ellipsis" : "",
overflow: whiteSpace === "nowrap" ? "" : BI.isWidthOrHeight(height) ? "auto" : "",
overflow: whiteSpace === "nowrap" ? "" : isWidthOrHeight(height) ? "auto" : "",
});
if (handler && handler !== BI.emptyFn) {
this.text = BI.createWidget({
if (handler && handler !== emptyFn) {
this.text = createWidget({
type: Layout.xtype,
tagName: "span",
});
this.text.element.click(e => {
!disabled && !invalid && handler.call(this, this.getValue(), this, e);
});
BI.createWidget({
createWidget({
type: DefaultLayout.xtype,
element: this,
items: [this.text],
@ -100,18 +100,18 @@ export class Text extends Single {
this.text = this;
}
const text = BI.isFunction(optionsText)
const text = isFunction(optionsText)
? this.__watch(optionsText, (context, newValue) => {
this.setText(newValue);
})
: optionsText;
// 只要不是undefined就可以显示text值,否则显示value
if (!BI.isUndefined(text)) {
if (!isUndefined(text)) {
this.setText(text);
} else if (BI.isKey(value)) {
} else if (isKey(value)) {
this.setText(value);
}
if (BI.isKey(keyword)) {
if (isKey(keyword)) {
this.doRedMark(keyword);
}
if (highLight) {
@ -122,20 +122,20 @@ export class Text extends Single {
_getTextWrap() {
const { whiteSpace } = this.options;
switch (whiteSpace) {
case "nowrap":
return "pre";
case "normal":
return "pre-wrap";
default:
return whiteSpace;
case "nowrap":
return "pre";
case "normal":
return "pre-wrap";
default:
return whiteSpace;
}
}
_getShowText() {
const { text: optionsText } = this.options;
const text = BI.isFunction(optionsText) ? optionsText() : optionsText;
const text = isFunction(optionsText) ? optionsText() : optionsText;
return BI.isKey(text) ? Text.formatText(`${text}`) : text;
return isKey(text) ? Text.formatText(`${text}`) : text;
}
_doRedMark(keyword) {
@ -146,7 +146,7 @@ export class Text extends Single {
}
doRedMark(keyword) {
if (BI.isKey(keyword)) {
if (isKey(keyword)) {
this._doRedMark(keyword);
}
}

4
src/base/single/a/a.js

@ -5,8 +5,8 @@ import { shortcut, extend, createWidget } from "@/core";
* 超链接
*
* Created by GUY on 2015/9/9.
* @class BI.A
* @extends BI.Text
* @class A
* @extends Text
* @abstract
*/

22
src/base/single/bar/bar.loading.js

@ -1,5 +1,5 @@
import { TextButton } from "../button";
import { Layout, CenterAdaptLayout, CardLayout, shortcut, emptyFn } from "@/core";
import { Layout, CenterAdaptLayout, CardLayout, shortcut, emptyFn, createWidget, i18nText, Controller } from "@/core";
import { Single } from "../0.single";
@shortcut()
@ -18,32 +18,32 @@ export class LoadingBar extends Single {
}
render() {
this.loaded = BI.createWidget({
this.loaded = createWidget({
type: TextButton.xtype,
cls: "loading-text bi-list-item-simple",
text: BI.i18nText("BI-Load_More"),
text: i18nText("BI-Load_More"),
width: 120,
handler: this.options.handler,
});
this.loaded.on(BI.Controller.EVENT_CHANGE, (...args) => {
this.fireEvent(BI.Controller.EVENT_CHANGE, ...args);
this.loaded.on(Controller.EVENT_CHANGE, (...args) => {
this.fireEvent(Controller.EVENT_CHANGE, ...args);
});
this.loading = BI.createWidget({
this.loading = createWidget({
type: Layout.xtype,
width: this.options.height,
height: this.options.height,
cls: "loading-background cursor-default",
});
const loaded = BI.createWidget({
const loaded = createWidget({
type: CenterAdaptLayout.xtype,
items: [this.loaded],
});
const loading = BI.createWidget({
const loading = createWidget({
type: CenterAdaptLayout.xtype,
items: [this.loading],
});
this.cardLayout = BI.createWidget({
this.cardLayout = createWidget({
type: CardLayout.xtype,
element: this,
items: [
@ -62,7 +62,7 @@ export class LoadingBar extends Single {
_reset() {
this.visible();
this.loaded.setText(BI.i18nText("BI-Load_More"));
this.loaded.setText(i18nText("BI-Load_More"));
this.loaded.enable();
}
@ -73,7 +73,7 @@ export class LoadingBar extends Single {
setEnd() {
this.setLoaded();
this.loaded.setText(BI.i18nText("BI-No_More_Data"));
this.loaded.setText(i18nText("BI-No_More_Data"));
this.loaded.disable();
}

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

@ -8,11 +8,22 @@ import {
createWidget,
Widget,
isObject,
Controller
Controller,
isIE,
getIEVersion,
nextTick,
isKey,
isNull,
DOM,
debounce,
KeyCode,
EVENT_RESPONSE_TIME,
Events,
Actions
} from "@/core";
import { BubbleCombo } from "@/case/combo/bubblecombo/combo.bubble";
import { Single } from "../0.single";
import { BubblePopupView } from "@/case/combo/bubblecombo/popup.bubble";
import { BubblePopupView, BubblePopupBarView } from "@/case/combo/bubblecombo/popup.bubble";
/**
* guy
@ -32,7 +43,7 @@ export class BasicButton extends Single {
return extend(conf, {
_baseCls: `${conf._baseCls || ""} bi-basic-button${conf.invalid ? "" : " cursor-pointer"}${
BI.isIE() && BI.getIEVersion() < 10 ? " hack" : ""
isIE() && getIEVersion() < 10 ? " hack" : ""
}`,
// el: {} // 可以通过el来创建button元素
value: "",
@ -75,7 +86,7 @@ export class BasicButton extends Single {
this.setSelected(true);
}
// 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(() => {
nextTick(() => {
!this.isDestroyed() && this.bindEvent();
});
super._initRef.apply(this, arguments);
@ -167,8 +178,8 @@ export class BasicButton extends Single {
if (this.isOnce() && this.isSelected()) {
return;
}
if (BI.isKey(o.bubble) || isFunction(o.bubble)) {
if (BI.isNull(this.combo)) {
if (isKey(o.bubble) || isFunction(o.bubble)) {
if (isNull(this.combo)) {
let popup;
createWidget({
type: AbsoluteLayout.xtype,
@ -195,7 +206,7 @@ export class BasicButton extends Single {
},
listeners: [
{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
eventName: BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action: (...args) => {
const [v] = args;
this.combo.hideView();
@ -240,109 +251,109 @@ export class BasicButton extends Single {
let selected = false;
let interval;
switch (trigger) {
case "mouseup":
hand.mousedown(() => {
mouseDown = true;
});
hand.mouseup(e => {
if (mouseDown === true) {
clk(e);
}
mouseDown = false;
ev(e);
});
break;
case "mousedown":
case "mouseup":
hand.mousedown(() => {
mouseDown = true;
});
hand.mouseup(e => {
if (mouseDown === true) {
clk(e);
}
mouseDown = false;
ev(e);
});
break;
case "mousedown":
// let mouseDown = false;
hand.mousedown(e => {
hand.mousedown(e => {
// 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 (
BI.DOM.isExist(this) &&
if (
DOM.isExist(this) &&
!hand.__isMouseInBounds__(e) &&
mouseDown === true &&
!selected
) {
) {
// self.setSelected(!self.isSelected());
this._trigger();
}
mouseDown = false;
Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
this._trigger();
}
mouseDown = false;
Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
// }
});
if (mouseDown === true) {
return;
}
if (this.isSelected()) {
selected = true;
} else {
clk(e);
}
mouseDown = true;
ev(e);
});
if (mouseDown === true) {
return;
}
if (this.isSelected()) {
selected = true;
} else {
clk(e);
}
mouseDown = true;
ev(e);
// }
});
hand.mouseup(e => {
});
hand.mouseup(e => {
// if (e.button === 0) {
if (BI.DOM.isExist(this) && mouseDown === true && selected === true) {
clk(e);
}
mouseDown = false;
selected = false;
Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
// }
});
break;
case "dblclick":
hand.dblclick(clk);
break;
case "lclick":
hand.mousedown(e => {
Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, () => {
interval && clearInterval(interval);
interval = null;
if (DOM.isExist(this) && mouseDown === true && selected === true) {
clk(e);
}
mouseDown = false;
selected = false;
Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
// }
});
if (mouseDown === true) {
return;
}
if (!this.isEnabled() || !this.isValid()) {
return;
}
if (this.isOnce() && this.isSelected()) {
return;
}
interval = setInterval(() => {
clk(e);
}, 180);
mouseDown = true;
ev(e);
});
break;
default:
if (o.stopEvent || o.stopPropagation) {
break;
case "dblclick":
hand.dblclick(clk);
break;
case "lclick":
hand.mousedown(e => {
Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, () => {
interval && clearInterval(interval);
interval = null;
mouseDown = false;
Widget._renderEngine.createElement(document).unbind(`mouseup.${this.getName()}`);
});
if (mouseDown === true) {
return;
}
if (!this.isEnabled() || !this.isValid()) {
return;
}
if (this.isOnce() && this.isSelected()) {
return;
}
interval = setInterval(() => {
clk(e);
}, 180);
mouseDown = true;
ev(e);
});
}
hand.click(clk);
// enter键等同于点击
o.attributes &&
break;
default:
if (o.stopEvent || o.stopPropagation) {
hand.mousedown(e => {
ev(e);
});
}
hand.click(clk);
// enter键等同于点击
o.attributes &&
o.attributes.zIndex >= 0 &&
hand.keyup(e => {
if (e.keyCode === BI.KeyCode.ENTER) {
if (e.keyCode === KeyCode.ENTER) {
clk(e);
}
});
break;
break;
}
});
// 之后的300ms点击无效
const onClick = o.debounce
? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, {
? debounce(this._doClick, EVENT_RESPONSE_TIME, {
leading: true,
trailing: false,
})
@ -373,12 +384,12 @@ export class BasicButton extends Single {
if (this.isValid()) {
const v = this.getValue();
o.handler.call(this, v, this, e);
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.CLICK, v, this, e);
this.fireEvent(Controller.EVENT_CHANGE, Events.CLICK, v, this, e);
this.fireEvent(BasicButton.EVENT_CHANGE, v, this);
if (o.action) {
BI.Actions.runAction(o.action, "click", o, this);
Actions.runAction(o.action, "click", o, this);
}
BI.Actions.runGlobalAction("click", o, this);
Actions.runGlobalAction("click", o, this);
}
}

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

@ -1,5 +1,5 @@
import { BasicButton } from "./button.basic";
import { shortcut, extend, Controller } from "@/core";
import { shortcut, extend, Controller, Events } from "@/core";
/**
* 表示一个可以展开的节点, 不仅有选中状态而且有展开状态
@ -46,14 +46,14 @@ export class NodeButton extends BasicButton {
triggerCollapse() {
if (this.isOpened()) {
this.setOpened(false);
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.COLLAPSE, this.getValue(), this);
}
}
triggerExpand() {
if (!this.isOpened()) {
this.setOpened(true);
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.EXPAND, this.getValue(), this);
}
}
}

4
src/base/single/button/buttons/button.icon.js

@ -1,5 +1,5 @@
import { Icon } from "../../icon/icon";
import { DefaultLayout, CenterAdaptLayout, shortcut, extend, isNumber, createWidget, isNull } from "@/core";
import { DefaultLayout, CenterAdaptLayout, shortcut, extend, isNumber, createWidget, isNull, pixFormat } from "@/core";
import { BasicButton } from "../button.basic";
/**
@ -39,7 +39,7 @@ export class IconButton extends BasicButton {
height: o.iconHeight,
});
if (isNumber(o.height) && o.height > 0 && isNull(o.iconWidth) && isNull(o.iconHeight)) {
this.element.css("lineHeight", BI.pixFormat(o.height));
this.element.css("lineHeight", pixFormat(o.height));
createWidget({
type: DefaultLayout.xtype,
element: this,

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

@ -1,4 +1,4 @@
import { CenterAdaptLayout, isNumber, shortcut, isPlainObject, createWidget } from "@/core";
import { CenterAdaptLayout, isNumber, shortcut, isPlainObject, createWidget, isIE, isIE9Below, pixFormat, get, isNull, toPix } from "@/core";
import { Label, IconLabel } from "../../label";
import { BasicButton } from "../button.basic";
@ -42,7 +42,7 @@ export class Button extends BasicButton {
return {
...conf,
baseCls: `${conf.baseCls || ""} bi-button${BI.isIE() && BI.isIE9Below() ? " hack" : ""}`,
baseCls: `${conf.baseCls || ""} bi-button${isIE() && isIE9Below() ? " hack" : ""}`,
attributes: {
tabIndex: 1,
},
@ -94,13 +94,13 @@ export class Button extends BasicButton {
// 如果 options 对应的属性为 true 则给元素添加 class
const classArr = ["block", "clear", "ghost", "plain", "loading", "light"];
classArr.forEach(clz => {
if (BI.get(o, clz) === true) {
if (get(o, clz) === true) {
this.element.addClass(clz);
}
});
if (o.minWidth > 0) {
this.element.css({ "min-width": BI.pixFormat(o.minWidth) });
this.element.css({ "min-width": pixFormat(o.minWidth) });
}
}
@ -133,7 +133,7 @@ export class Button extends BasicButton {
maxTextWidth -= o.hgap * 2 + o.iconGap;
// 减去图标水平占位宽度
maxTextWidth -= iconInvisible || isVertical(o.iconPosition) ? 0 : this._const.iconWidth;
const textWidth = BI.isNull(o.textWidth) ? maxTextWidth : Math.min(o.textWidth, maxTextWidth);
const textWidth = isNull(o.textWidth) ? maxTextWidth : Math.min(o.textWidth, maxTextWidth);
this.text = createWidget({
type: Label.xtype,
@ -141,8 +141,8 @@ export class Button extends BasicButton {
whiteSpace: o.whiteSpace,
textAlign: o.textAlign,
textWidth,
textHeight: BI.toPix(textHeight, hasBorder ? 2 : 0),
height: BI.toPix(lineHeight, hasBorder ? 2 : 0),
textHeight: toPix(textHeight, hasBorder ? 2 : 0),
height: toPix(lineHeight, hasBorder ? 2 : 0),
value: o.value,
title: null,
});
@ -160,8 +160,8 @@ export class Button extends BasicButton {
type: IconLabel.xtype,
cls: o.loading ? loadingCls : o.iconCls || o.icon,
width: this._const.iconWidth,
height: BI.toPix(lineHeight, hasBorder ? 2 : 0),
lineHeight: BI.toPix(lineHeight, hasBorder ? 2 : 0),
height: toPix(lineHeight, hasBorder ? 2 : 0),
lineHeight: toPix(lineHeight, hasBorder ? 2 : 0),
// 不设置,自定义按钮无法居中
iconWidth: o.iconWidth,
iconHeight: o.iconHeight,

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

@ -83,7 +83,7 @@ export class BlankIconTextIconItem extends BasicButton {
doClick() {
super.doClick(...arguments);
if (this.isValid()) {
this.fireEvent(BI.BlankIconTextIconItem.EVENT_CHANGE, this.getValue(), this);
this.fireEvent(BlankIconTextIconItem.EVENT_CHANGE, this.getValue(), this);
}
}

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

@ -1,4 +1,4 @@
import { VerticalAdaptLayout, extend, shortcut } from "@/core";
import { VerticalAdaptLayout, extend, shortcut, Direction } from "@/core";
import { IconLabel, Label } from "../../label";
import { BasicButton } from "../button.basic";
@ -19,7 +19,7 @@ export class IconTextItem extends BasicButton {
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-icon-text-item`,
direction: BI.Direction.Left,
direction: Direction.Left,
iconWrapperWidth: null,
iconHeight: null,
iconWidth: null,

16
src/base/single/editor/editor.js

@ -9,18 +9,14 @@ import {
isEmptyString,
isFunction,
isNull,
trim
trim,
emptyFn,
KeyCode
} from "@/core";
import { Label } from "../label";
import { Single } from "../0.single";
import { Bubbles } from "@/base/0.base";
/**
* Created by GUY on 2015/4/15.
* @class BI.Editor
* @extends BI.Single
*/
@shortcut()
export class Editor extends Single {
static xtype = "bi.editor";
@ -60,8 +56,8 @@ export class Editor extends Single {
// title,warningTitle这两个属性没用
tipType: "warning",
inputType: "text",
validationChecker: BI.emptyFn,
quitChecker: BI.emptyFn,
validationChecker: emptyFn,
quitChecker: emptyFn,
allowBlank: false,
watermark: "",
errorText: "",
@ -164,7 +160,7 @@ export class Editor extends Single {
this.editor.on(Input.EVENT_QUICK_DOWN, (...args) => {
const [e] = args;
// tab键就不要隐藏了
if (e.keyCode !== BI.KeyCode.TAB && this.watermark) {
if (e.keyCode !== KeyCode.TAB && this.watermark) {
this.watermark.invisible();
}
this.fireEvent(Editor.EVENT_QUICK_DOWN, ...args);

4
src/base/single/editor/editor.multifile.js

@ -5,8 +5,8 @@ import { AbsoluteLayout, AdaptiveLayout, shortcut, Widget, createWidget, extend
* 多文件
*
* Created by GUY on 2016/4/13.
* @class BI.MultifileEditor
* @extends BI.Single
* @class MultifileEditor
* @extends Single
* @abstract
*/

34
src/base/single/editor/editor.textarea.js

@ -12,7 +12,9 @@ import {
isNotEmptyString,
isNotNull,
trim,
isFunction
isFunction,
Events,
DOM
} from "@/core";
import { Label } from "../label";
import { Single } from "../0.single";
@ -21,8 +23,8 @@ import { Bubbles } from "@/base/0.base";
/**
*
* Created by GUY on 2016/1/18.
* @class BI.TextAreaEditor
* @extends BI.Single
* @class TextAreaEditor
* @extends Single
*/
@shortcut()
@ -84,10 +86,10 @@ export class TextAreaEditor extends Single {
this.content.element.on("input propertychange", e => {
this._checkError();
this._checkWaterMark();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.CHANGE, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.CHANGE, this.getValue(), this);
this.fireEvent(TextAreaEditor.EVENT_CHANGE);
if (isEmptyString(this.getValue())) {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.EMPTY, this.getValue(), this);
}
});
@ -96,7 +98,7 @@ export class TextAreaEditor extends Single {
this._focus();
this.fireEvent(TextAreaEditor.EVENT_FOCUS);
Widget._renderEngine.createElement(document).bind(`mousedown.${this.getName()}`, e => {
if (BI.DOM.isExist(this) && !this.element.__isMouseInBounds__(e)) {
if (DOM.isExist(this) && !this.element.__isMouseInBounds__(e)) {
Widget._renderEngine.createElement(document).unbind(`mousedown.${this.getName()}`);
this.content.element.blur();
}
@ -199,7 +201,7 @@ export class TextAreaEditor extends Single {
this.content.element.addClass("textarea-editor-focus");
this._checkWaterMark();
if (isEmptyString(this.getValue())) {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.EMPTY, this.getValue(), this);
}
}
@ -209,12 +211,12 @@ export class TextAreaEditor extends Single {
}
_setErrorVisible(b) {
const { errorText, adjustYOffset, adjustXOffset, offsetStyle } = this.options;
if (isFunction(errorText)) {
errorText = errorText(trim(this.getValue()));
const { adjustYOffset, adjustXOffset, offsetStyle } = this.options;
if (isFunction(this.options.errorText)) {
this.options.errorText = this.options.errorText(trim(this.getValue()));
}
if (!this.disabledError && isKey(errorText)) {
Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, {
if (!this.disabledError && isKey(this.options.errorText)) {
Bubbles[b ? "show" : "hide"](this.getName(), this.options.errorText, this, {
adjustYOffset,
adjustXOffset,
offsetStyle,
@ -224,7 +226,7 @@ export class TextAreaEditor extends Single {
_defaultState() {
if (isEmptyString(this.getValue())) {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.EMPTY, this.getValue(), this);
this.fireEvent(TextAreaEditor.EVENT_EMPTY);
}
}
@ -257,9 +259,9 @@ export class TextAreaEditor extends Single {
extend({}, style, {
color:
style.color ||
BI.DOM.getContrastColor(
BI.DOM.isRGBColor(style.backgroundColor)
? BI.DOM.rgb2hex(style.backgroundColor)
DOM.getContrastColor(
DOM.isRGBColor(style.backgroundColor)
? DOM.rgb2hex(style.backgroundColor)
: style.backgroundColor
),
})

20
src/base/single/html/html.js

@ -1,10 +1,10 @@
import { Layout, DefaultLayout, shortcut, isNumber, createWidget, isWidthOrHeight, isKey } from "@/core";
import { Layout, DefaultLayout, shortcut, isNumber, createWidget, isWidthOrHeight, isKey, pixFormat } from "@/core";
import { Single } from "../0.single";
/**
* guy 表示一行数据通过position来定位位置的数据
* @class BI.Html
* @extends BI.Single
* @class Html
* @extends Single
*/
@shortcut()
@ -47,35 +47,35 @@ export class Html extends Single {
} = this.options;
if (hgap + lgap > 0) {
this.element.css({
"padding-left": BI.pixFormat(hgap + lgap),
"padding-left": pixFormat(hgap + lgap),
});
}
if (hgap + rgap > 0) {
this.element.css({
"padding-right": BI.pixFormat(hgap + rgap),
"padding-right": pixFormat(hgap + rgap),
});
}
if (vgap + tgap > 0) {
this.element.css({
"padding-top": BI.pixFormat(vgap + tgap),
"padding-top": pixFormat(vgap + tgap),
});
}
if (vgap + bgap > 0) {
this.element.css({
"padding-bottom": BI.pixFormat(vgap + bgap),
"padding-bottom": pixFormat(vgap + bgap),
});
}
if (isNumber(height)) {
this.element.css({ lineHeight: BI.pixFormat(height) });
this.element.css({ lineHeight: pixFormat(height) });
}
if (isNumber(lineHeight)) {
this.element.css({ lineHeight: BI.pixFormat(lineHeight) });
this.element.css({ lineHeight: pixFormat(lineHeight) });
}
if (isWidthOrHeight(maxWidth)) {
this.element.css({ maxWidth });
}
if (isNumber(maxWidth)) {
this.element.css({ maxWidth: BI.pixFormat(maxWidth) });
this.element.css({ maxWidth: pixFormat(maxWidth) });
}
this.element.css({
textAlign,

8
src/base/single/icon/icon.js

@ -1,10 +1,10 @@
import { Single } from "../0.single";
import { shortcut, extend } from "@/core";
import { shortcut, extend, isIE9Below } from "@/core";
/**
* guy 图标
* @class BI.Icon
* @extends BI.Single
* @class Icon
* @extends Single
*/
@shortcut()
@ -21,7 +21,7 @@ export class Icon extends Single {
}
render() {
if (BI.isIE9Below && BI.isIE9Below()) {
if (isIE9Below && isIE9Below()) {
this.element.addClass("hack");
}
}

9
src/base/single/img/img.js

@ -1,15 +1,6 @@
import { Single } from "../0.single";
import { shortcut, extend } from "@/core";
/**
* ͼƬ
*
* Created by GUY on 2016/1/26.
* @class BI.Img
* @extends BI.Single
* @abstract
*/
@shortcut()
export class Img extends Single {
static xtype = "bi.img";

4
src/base/single/input/checkbox/checkbox.image.js

@ -1,5 +1,5 @@
import { IconButton } from "../../button";
import { shortcut, extend } from "@/core";
import { shortcut, extend, emptyFn } from "@/core";
/**
* guy
@ -19,7 +19,7 @@ export class ImageCheckbox extends IconButton {
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-image-checkbox check-box-icon`,
selected: false,
handler: BI.emptyFn,
handler: emptyFn,
width: 16,
height: 16,
iconWidth: 16,

4
src/base/single/input/checkbox/checkbox.js

@ -1,4 +1,4 @@
import { CenterAdaptLayout, DefaultLayout, shortcut } from "@/core";
import { CenterAdaptLayout, DefaultLayout, shortcut, emptyFn } from "@/core";
import { BasicButton } from "../../button";
/**
@ -16,7 +16,7 @@ export class Checkbox extends BasicButton {
props = {
baseCls: "bi-checkbox",
selected: false,
handler: BI.emptyFn,
handler: emptyFn,
width: 14,
height: 14,
iconWidth: 14,

99
src/base/single/input/file.js

@ -1,12 +1,12 @@
import { Msg } from "../../foundation/message";
import { shortcut, Widget, some, extend } from "@/core";
import { shortcut, Widget, some, extend, jsonDecode, appendQuery, emptyFn, i18nText } from "@/core";
/**
* 文件
*
* Created by GUY on 2016/1/27.
* @class BI.File
* @extends BI.Single
* @class File
* @extends Single
* @abstract
*/
@ -166,7 +166,7 @@ const sendFile = (toString => {
);
xhr.open(
"post",
BI.appendQuery(handler.url, {
appendQuery(handler.url, {
filename: _global.encodeURIComponent(handler.file.fileName),
}),
true
@ -188,53 +188,54 @@ const sendFile = (toString => {
};
xhr.onreadystatechange = () => {
switch (xhr.readyState) {
case 2:
case 3:
if (rpe.total <= rpe.loaded) {
case 2:
case 3:
if (rpe.total <= rpe.loaded) {
rpe.loaded = rpe.total;
}
upload.onprogress(rpe);
break;
case 4:
clearInterval(rpe.interval);
rpe.interval = 0;
rpe.loaded = rpe.total;
}
upload.onprogress(rpe);
break;
case 4:
clearInterval(rpe.interval);
rpe.interval = 0;
rpe.loaded = rpe.total;
upload.onprogress(rpe);
if (199 < xhr.status && xhr.status < 400) {
upload.onload({});
const attachO = BI.jsonDecode(xhr.responseText);
attachO.filename = handler.file.fileName;
if (handler.file.type.indexOf("image") !== -1) {
attachO.attach_type = "image";
upload.onprogress(rpe);
if (199 < xhr.status && xhr.status < 400) {
upload.onload({});
const attachO = jsonDecode(xhr.responseText);
attachO.filename = handler.file.fileName;
if (handler.file.type.indexOf("image") !== -1) {
attachO.attach_type = "image";
}
handler.attach_array[current] = attachO;
} else {
upload.onerror({});
}
handler.attach_array[current] = attachO;
} else {
upload.onerror({});
}
break;
default:
break;
break;
default:
break;
}
};
upload.onloadstart(rpe);
} else {
xhr.onreadystatechange = () => {
switch (xhr.readyState) {
case 4:
const attachO = BI.jsonDecode(xhr.responseText);
if (handler.file.type.indexOf("image") !== -1) {
attachO.attach_type = "image";
}
attachO.filename = handler.file.fileName;
if (handler.maxLength === 1) {
handler.attach_array[0] = attachO;
case 4: {
const attachO = jsonDecode(xhr.responseText);
if (handler.file.type.indexOf("image") !== -1) {
attachO.attach_type = "image";
}
attachO.filename = handler.file.fileName;
if (handler.maxLength === 1) {
handler.attach_array[0] = attachO;
// handler.attach_array.push(attachO);
} else {
handler.attach_array[current] = attachO;
} else {
handler.attach_array[current] = attachO;
}
break;
}
break;
default:
break;
default:
break;
}
};
if (isFunction(upload.onloadstart)) {
@ -285,7 +286,7 @@ const sendFile = (toString => {
const responseText = (iframe.contentWindow.document || iframe.contentWindow.contentDocument).body
.innerHTML;
try {
const attachO = BI.jsonDecode(responseText);
const attachO = jsonDecode(responseText);
if (handler.file.type.indexOf("image") !== -1) {
attachO.attach_type = "image";
}
@ -314,7 +315,9 @@ const sendFile = (toString => {
try {
// IE < 8 does not accept enctype attribute ...
// eslint-disable-next-line no-unused-vars
const form = document.createElement("<form enctype=\"multipart/form-data\"></form>"),
// eslint-disable-next-line no-unused-vars
iframe =
handler.iframe ||
(handler.iframe = document.createElement(
@ -447,7 +450,7 @@ const fileTypeValidate = (fileName, fileType) => {
if (!fileType) {
return true;
}
const mimes = fileType.split(",");
let mimes = fileType.split(",");
if (mimes[0] === fileType) {
mimes = `${fileType}`.split(";");
}
@ -490,7 +493,7 @@ export class File extends Widget {
accept: "", // .png,.pdf,image/jpg,image/* 等
maxSize: -1, // 1024 * 1024 单位b
maxLength: -1, // 无限制, 与multiple配合使用
errorText: BI.emptyFn,
errorText: emptyFn,
});
}
@ -562,14 +565,14 @@ export class File extends Widget {
// enable again the submit button/element
}, 100);
if (200 > xhr.status || xhr.status > 399) {
Msg.toast(BI.i18nText("BI-Upload_File_Error"), { level: "error" });
Msg.toast(i18nText("BI-Upload_File_Error"), { level: "error" });
this.fireEvent(File.EVENT_ERROR);
return;
}
const error = some(_wrap.attach_array, (index, attach) => {
if (attach.errorCode) {
Msg.toast(BI.i18nText(attach.errorMsg), { level: "error" });
Msg.toast(i18nText(attach.errorMsg), { level: "error" });
this.fireEvent(File.EVENT_ERROR, attach);
return true;
@ -607,7 +610,7 @@ export class File extends Widget {
errorText({
errorType: 0,
file: item,
}) || BI.i18nText("BI-Upload_File_Type_Error", wrap.fileType),
}) || i18nText("BI-Upload_File_Type_Error", wrap.fileType),
{ level: "error" }
);
this.fireEvent(File.EVENT_ERROR, {
@ -620,7 +623,7 @@ export class File extends Widget {
errorText({
errorType: 1,
file: item,
}) || BI.i18nText("BI-Upload_File_Size_Error", Math.ceil(wrap.maxSize / 1024 / 1024)),
}) || i18nText("BI-Upload_File_Size_Error", Math.ceil(wrap.maxSize / 1024 / 1024)),
{ level: "error" }
);
this.fireEvent(File.EVENT_ERROR, {

52
src/base/single/input/input.js

@ -12,13 +12,17 @@ import {
trim,
isEqual,
nextTick,
isEndWithBlank
isEndWithBlank,
emptyFn,
EVENT_RESPONSE_TIME,
KeyCode,
Events
} from "@/core";
/**
* guy
* @class BI.Input 一个button和一行数 组成的一行listitem
* @extends BI.Single
* @class Input 一个button和一行数 组成的一行listitem
* @extends Single
* @type {*|void|Object}
*/
@ -54,8 +58,8 @@ export class Input extends Single {
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-input display-block overflow-dot`,
tagName: "input",
validationChecker: BI.emptyFn,
quitChecker: BI.emptyFn, // 按确定键能否退出编辑
validationChecker: emptyFn,
quitChecker: emptyFn, // 按确定键能否退出编辑
allowBlank: false,
});
}
@ -67,16 +71,16 @@ export class Input extends Single {
const _keydown = debounce(keyCode => {
this.onKeyDown(keyCode, ctrlKey);
this._keydown_ = false;
}, BI.EVENT_RESPONSE_TIME);
const _clk = debounce(bind(this._click, this), BI.EVENT_RESPONSE_TIME, {
}, EVENT_RESPONSE_TIME);
const _clk = debounce(bind(this._click, this), EVENT_RESPONSE_TIME, {
leading: true,
trailing: false,
});
this._focusDebounce = debounce(bind(this._focus, this), BI.EVENT_RESPONSE_TIME, {
this._focusDebounce = debounce(bind(this._focus, this), EVENT_RESPONSE_TIME, {
leading: true,
trailing: false,
});
this._blurDebounce = debounce(bind(this._blur, this), BI.EVENT_RESPONSE_TIME, {
this._blurDebounce = debounce(bind(this._blur, this), EVENT_RESPONSE_TIME, {
leading: true,
trailing: false,
});
@ -89,7 +93,7 @@ export class Input extends Single {
})
.keyup(e => {
keyCode = null;
if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) {
if (!(inputEventValid && e.keyCode === KeyCode.ENTER)) {
this._keydown_ = true;
_keydown(e.keyCode);
}
@ -131,7 +135,7 @@ export class Input extends Single {
this._checkValidationOnValueChange();
this._isEditing = true;
if (this.getValue() === "") {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.EMPTY, this.getValue(), this);
this.fireEvent(Input.EVENT_EMPTY);
}
this.fireEvent(Input.EVENT_FOCUS);
@ -150,7 +154,7 @@ export class Input extends Single {
if (this.isValid()) {
const lastValidValue = this._lastValidValue;
this._lastValidValue = this.getValue();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.CONFIRM, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.CONFIRM, this.getValue(), this);
this.fireEvent(Input.EVENT_CONFIRM);
if (this._lastValidValue !== lastValidValue) {
this.fireEvent(Input.EVENT_CHANGE_CONFIRM);
@ -160,7 +164,7 @@ export class Input extends Single {
};
if (this._keydown_ === true) {
delay(blur, BI.EVENT_RESPONSE_TIME);
delay(blur, EVENT_RESPONSE_TIME);
} else {
blur();
}
@ -189,11 +193,11 @@ export class Input extends Single {
) {
this._start = true;
this._pause = false;
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.STARTEDIT, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.STARTEDIT, this.getValue(), this);
this.fireEvent(Input.EVENT_START);
}
}
if (isEqual(keyCode, BI.KeyCode.ENTER)) {
if (isEqual(keyCode, KeyCode.ENTER)) {
if (this.isValid() || this.options.quitChecker.apply(this, [trim(this.getValue())]) !== false) {
this.blur();
this.fireEvent(Input.EVENT_ENTER);
@ -201,13 +205,13 @@ export class Input extends Single {
this.fireEvent(Input.EVENT_RESTRICT);
}
}
if (isEqual(keyCode, BI.KeyCode.SPACE)) {
if (isEqual(keyCode, KeyCode.SPACE)) {
this.fireEvent(Input.EVENT_SPACE);
}
if (isEqual(keyCode, BI.KeyCode.BACKSPACE) && this._lastValue === "") {
if (isEqual(keyCode, KeyCode.BACKSPACE) && this._lastValue === "") {
this.fireEvent(Input.EVENT_REMOVE);
}
if (isEqual(keyCode, BI.KeyCode.BACKSPACE) || isEqual(keyCode, BI.KeyCode.DELETE)) {
if (isEqual(keyCode, KeyCode.BACKSPACE) || isEqual(keyCode, KeyCode.DELETE)) {
this.fireEvent(Input.EVENT_BACKSPACE);
}
this.fireEvent(Input.EVENT_KEY_DOWN, arguments);
@ -219,16 +223,16 @@ export class Input extends Single {
}
if (isEndWithBlank(this.getValue())) {
this._pause = true;
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.PAUSE, "", this);
this.fireEvent(Controller.EVENT_CHANGE, Events.PAUSE, "", this);
this.fireEvent(Input.EVENT_PAUSE);
this._defaultState();
} else if (
(keyCode === BI.KeyCode.BACKSPACE || keyCode === BI.KeyCode.DELETE) &&
(keyCode === KeyCode.BACKSPACE || keyCode === KeyCode.DELETE) &&
trim(this.getValue()) === "" &&
lastValue !== null &&
trim(lastValue) !== ""
) {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.STOPEDIT, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.STOPEDIT, this.getValue(), this);
this.fireEvent(Input.EVENT_STOP);
}
}
@ -236,7 +240,7 @@ export class Input extends Single {
// 初始状态
_defaultState() {
if (this.getValue() === "") {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.EMPTY, this.getValue(), this);
this.fireEvent(Input.EVENT_EMPTY);
}
this._lastValue = this.getValue();
@ -245,12 +249,12 @@ export class Input extends Single {
_valueChange() {
if (this.isValid() && trim(this.getValue()) !== this._lastSubmitValue) {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.CHANGE, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.CHANGE, this.getValue(), this);
this.fireEvent(Input.EVENT_CHANGE);
this._lastSubmitValue = trim(this.getValue());
}
if (this.getValue() === "") {
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(Controller.EVENT_CHANGE, Events.EMPTY, this.getValue(), this);
this.fireEvent(Input.EVENT_EMPTY);
}
this._lastValue = this.getValue();

4
src/base/single/input/radio/radio.image.js

@ -1,5 +1,5 @@
import { IconButton } from "../../button";
import { shortcut, extend } from "@/core";
import { shortcut, extend, emptyFn } from "@/core";
/**
* guy
@ -19,7 +19,7 @@ export class ImageRadio extends IconButton {
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-radio radio-icon`,
selected: false,
handler: BI.emptyFn,
handler: emptyFn,
width: 16,
height: 16,
iconWidth: 16,

4
src/base/single/input/radio/radio.js

@ -1,4 +1,4 @@
import { CenterAdaptLayout, Layout, shortcut } from "@/core";
import { CenterAdaptLayout, Layout, shortcut, emptyFn } from "@/core";
import { BasicButton } from "../../button";
/**
@ -15,7 +15,7 @@ export class Radio extends BasicButton {
props = {
baseCls: "bi-radio",
selected: false,
handler: BI.emptyFn,
handler: emptyFn,
width: 16,
height: 16,
iconWidth: 16,

18
src/base/single/label/abstract.label.js

@ -1,5 +1,5 @@
import { Text } from "../1.text";
import { CenterAdaptLayout, isNumber, createWidget, extend } from "@/core";
import { CenterAdaptLayout, isNumber, createWidget, extend, pixFormat } from "@/core";
import { Single } from "../0.single";
/**
@ -116,7 +116,7 @@ export class AbstractLabel extends Single {
if (isNumber(height) && height > 0) {
// 1.4
this.element.css({
"line-height": BI.pixFormat(height),
"line-height": pixFormat(height),
});
json.textAlign = textAlign;
delete json.maxWidth;
@ -196,7 +196,7 @@ export class AbstractLabel extends Single {
if (isNumber(height) && height > 0) {
// 1.8
this.element.css({
"line-height": BI.pixFormat(height),
"line-height": pixFormat(height),
});
json.textAlign = textAlign;
delete json.maxWidth;
@ -283,7 +283,7 @@ export class AbstractLabel extends Single {
// 2.3
if (whiteSpace !== "normal") {
this.element.css({
"line-height": BI.pixFormat(height - vgap * 2),
"line-height": pixFormat(height - vgap * 2),
});
}
delete json.maxWidth;
@ -351,7 +351,7 @@ export class AbstractLabel extends Single {
if (isNumber(height) && height > 0) {
if (whiteSpace !== "normal") {
this.element.css({
"line-height": BI.pixFormat(height - vgap * 2),
"line-height": pixFormat(height - vgap * 2),
});
}
delete json.maxWidth;
@ -391,19 +391,19 @@ export class AbstractLabel extends Single {
}
doRedMark() {
this.text.doRedMark.apply(this.text, arguments);
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark.apply(this.text, arguments);
this.text.unRedMark(...arguments);
}
doHighLight() {
this.text.doHighLight.apply(this.text, arguments);
this.text.doHighLight(...arguments);
}
unHighLight() {
this.text.unHighLight.apply(this.text, arguments);
this.text.unHighLight(...arguments);
}
setText(v) {

8
src/base/single/label/icon.label.js

@ -1,10 +1,10 @@
import { Icon } from "../icon/icon";
import { DefaultLayout, CenterAdaptLayout, shortcut, createWidget, isNumber, isNull } from "@/core";
import { DefaultLayout, CenterAdaptLayout, shortcut, createWidget, isNumber, isNull, pixFormat } from "@/core";
import { Single } from "../0.single";
/**
* @class BI.IconLabel
* @extends BI.Single
* @class IconLabel
* @extends Single
* 图标标签
*/
@ -36,7 +36,7 @@ export class IconLabel extends Single {
height: iconHeight,
});
if (isNumber(height) && height > 0 && isNull(iconWidth) && isNull(iconHeight)) {
this.element.css("lineHeight", BI.pixFormat(lineHeight || height));
this.element.css("lineHeight", pixFormat(lineHeight || height));
createWidget({
type: DefaultLayout.xtype,
element: this,

4
src/base/single/link/link.js

@ -4,8 +4,8 @@ import { shortcut, extend } from "@/core";
/**
* guy a元素
* @class BI.Link
* @extends BI.Text
* @class Link
* @extends Text
*/
@shortcut()

8
src/base/single/tip/0.tip.js

@ -1,12 +1,12 @@
import { Single } from "../0.single";
import { extend } from "@/core";
import { extend, zIndex_tip } from "@/core";
/**
* guy
* tip提示
* zIndex在10亿级别
* @class BI.Tip
* @extends BI.Single
* @class Tip
* @extends Single
* @abstract
*/
@ -16,7 +16,7 @@ export class Tip extends Single {
return extend(conf, {
_baseCls: `${conf._baseCls || ""} bi-tip`,
zIndex: BI.zIndex_tip,
zIndex: zIndex_tip,
});
}

44
src/base/single/tip/tip.toast.js

@ -1,14 +1,14 @@
import { IconLabel, Label } from "../label";
import { IconButton } from "../button";
import { HorizontalLayout, shortcut, extend, isPlainObject } from "@/core";
import { HorizontalLayout, shortcut, extend, isPlainObject, pixFormat, HorizontalAlign } from "@/core";
import { Tip } from "./0.tip";
/**
* toast提示
*
* Created by GUY on 2015/9/7.
* @class BI.Toast
* @extends BI.Tip
* @class Toast
* @extends Tip
*/
@shortcut()
@ -41,8 +41,8 @@ export class Toast extends Tip {
const { closable, level, autoClose, textHeight, text, hgap, vgap, innerHgap } = this.options;
const { closableMinWidth, minWidth, maxWidth, closableMaxWidth } = this._const;
this.element.css({
minWidth: BI.pixFormat(closable ? closableMinWidth : minWidth),
maxWidth: BI.pixFormat(closable ? closableMaxWidth : maxWidth),
minWidth: pixFormat(closable ? closableMinWidth : minWidth),
maxWidth: pixFormat(closable ? closableMaxWidth : maxWidth),
});
this.element.addClass(`toast-${level}`);
function fn(e) {
@ -62,22 +62,22 @@ export class Toast extends Tip {
});
let cls;
switch (level) {
case "success":
cls = "toast-success-font";
break;
case "error":
cls = "toast-error-font";
break;
case "warning":
cls = "toast-warning-font";
break;
case "loading":
cls = "toast-loading-font anim-rotate";
break;
case "normal":
default:
cls = "toast-message-font";
break;
case "success":
cls = "toast-success-font";
break;
case "error":
cls = "toast-error-font";
break;
case "warning":
cls = "toast-warning-font";
break;
case "loading":
cls = "toast-loading-font anim-rotate";
break;
case "normal":
default:
cls = "toast-message-font";
break;
}
function hasCloseIcon() {
@ -118,7 +118,7 @@ export class Toast extends Tip {
return {
type: HorizontalLayout.xtype,
horizontalAlign: BI.HorizontalAlign.Stretch,
horizontalAlign: HorizontalAlign.Stretch,
items,
hgap,
vgap,

8
src/base/single/tip/tip.tooltip.js

@ -1,4 +1,4 @@
import { VerticalLayout, shortcut, extend, createWidget, map } from "@/core";
import { VerticalLayout, shortcut, extend, createWidget, map, pixFormat } from "@/core";
import { Label } from "../label";
import { Tip } from "./0.tip";
@ -6,8 +6,8 @@ import { Tip } from "./0.tip";
* title提示
*
* Created by GUY on 2015/9/7.
* @class BI.Tooltip
* @extends BI.Tip
* @class Tooltip
* @extends Tip
*/
@shortcut()
@ -80,7 +80,7 @@ export class Tooltip extends Tip {
}
setWidth(width) {
this.element.width(BI.pixFormat(width - 2 * this._const.hgap));
this.element.width(pixFormat(width - 2 * this._const.hgap));
}
setText(text) {

4
src/base/single/trigger/trigger.js

@ -3,8 +3,8 @@ import { extend } from "@/core";
/**
* 下拉
* @class BI.Trigger
* @extends BI.Single
* @class Trigger
* @extends Single
* @abstract
*/

9
src/base/tree/customtree.js

@ -15,7 +15,8 @@ import {
isNotNull,
isNull,
createWidget,
Controller
Controller,
Events
} from "@/core";
/**
@ -23,8 +24,8 @@ import {
* 自定义树
*
* Created by GUY on 2015/9/7.
* @class BI.CustomTree
* @extends BI.Single
* @class CustomTree
* @extends Single
*/
@shortcut()
@ -131,7 +132,7 @@ export class CustomTree extends Widget {
});
this.tree.on(Controller.EVENT_CHANGE, (type, val, obj, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, val, obj, ...args);
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.fireEvent(CustomTree.EVENT_CHANGE, val, obj);
}
});

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

@ -1,11 +1,6 @@
import { IconButton } from "@/base";
import { shortcut, extend } from "@/core";
/**
* guy
* @extends BI.Single
* @type {*|void|Object}
*/
@shortcut()
export class HalfIconButton extends IconButton {
static xtype = "bi.half_icon_button";

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

@ -1,11 +1,6 @@
import { CenterAdaptLayout, DefaultLayout, shortcut, extend } from "@/core";
import { BasicButton } from "@/base";
/**
* guy
* @extends BI.Single
* @type {*|void|Object}
*/
@shortcut()
export class HalfButton extends BasicButton {
static xtype = "bi.half_button";

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

@ -1,4 +1,4 @@
import { Checkbox, Label, BasicButton } from "@/base";
import { Checkbox, Label, BasicButton, SIZE_CONSANTS } from "@/base";
import { VerticalAdaptLayout, CenterAdaptLayout, shortcut, extend, createWidget } from "@/core";
/**
@ -17,7 +17,7 @@ export class MultiSelectItem extends BasicButton {
attributes: {
tabIndex: 1,
},
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 26,
});
}
@ -39,7 +39,7 @@ export class MultiSelectItem extends BasicButton {
{
el: {
type: Label.xtype,
ref: (_ref) => {
ref: _ref => {
this.text = _ref;
},
cls: "list-item-text",
@ -56,13 +56,13 @@ export class MultiSelectItem extends BasicButton {
value: o.value,
py: o.py,
},
},
}
],
};
}
// _setEnable: function (enable) {
// BI.MultiSelectItem.superclass._setEnable.apply(this, arguments);
// MultiSelectItem.superclass._setEnable.apply(this, arguments);
// if (enable === true) {
// this.element.attr("tabIndex", 1);
// } else if (enable === false) {

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

@ -1,11 +1,11 @@
import { IconTextItem, Single } from "@/base";
import { IconTextItem, Single, SIZE_CONSANTS } from "@/base";
import { shortcut, extend, createWidget, Controller } from "@/core";
/**
* Created by GUY on 2016/2/2.
*
* @class BI.SingleSelectIconTextItem
* @extends BI.BasicButton
* @class SingleSelectIconTextItem
* @extends BasicButton
*/
@shortcut()
export class SingleSelectIconTextItem extends Single {
@ -18,7 +18,7 @@ export class SingleSelectIconTextItem extends Single {
tabIndex: 1,
},
iconCls: "",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
});
}

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

@ -1,5 +1,5 @@
import { Label, BasicButton } from "@/base";
import { shortcut, extend, createWidget } from "@/core";
import { shortcut, extend, createWidget, SIZE_CONSANTS } from "@/core";
@shortcut()
export class SingleSelectItem extends BasicButton {
@ -13,7 +13,7 @@ export class SingleSelectItem extends BasicButton {
tabIndex: 1,
},
textHgap: 10,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
textAlign: "left",
});
}

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

@ -1,4 +1,4 @@
import { VerticalAdaptLayout, CenterAdaptLayout, shortcut, extend } from "@/core";
import { VerticalAdaptLayout, CenterAdaptLayout, shortcut, extend, SIZE_CONSANTS } from "@/core";
import { Radio, Label, BasicButton } from "@/base";
/**
@ -17,7 +17,7 @@ export class SingleSelectRadioItem extends BasicButton {
attributes: {
tabIndex: 1,
},
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 16,
textHgap: 10,
});
@ -35,16 +35,16 @@ export class SingleSelectRadioItem extends BasicButton {
items: [
{
type: Radio.xtype,
ref: (_ref) => {
ref: _ref => {
this.radio = _ref;
},
},
}
],
},
{
el: {
type: Label.xtype,
ref: (_ref) => {
ref: _ref => {
this.text = _ref;
},
cls: "list-item-text",
@ -61,7 +61,7 @@ export class SingleSelectRadioItem extends BasicButton {
value: o.value,
py: o.py,
},
},
}
],
};
}

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

@ -1,6 +1,6 @@
import { ArrowTreeGroupNodeCheckbox } from "../../checkbox";
import { IconLabel, Label, NodeButton } from "@/base";
import { shortcut, extend, createWidget, Controller, isNotNull } from "@/core";
import { shortcut, extend, createWidget, Controller, isNotNull, Events, LogicFactory, Direction } from "@/core";
/**
* Created by User on 2016/3/31.
@ -63,8 +63,8 @@ export class IconArrowNode extends NodeButton {
py: o.py,
keyword: o.keyword,
});
this.checkbox.on(Controller.EVENT_CHANGE, (type) => {
if (type === BI.Events.CLICK) {
this.checkbox.on(Controller.EVENT_CHANGE, type => {
if (type === Events.CLICK) {
if (this.checkbox.isSelected()) {
this.triggerExpand();
} else {
@ -72,9 +72,9 @@ export class IconArrowNode extends NodeButton {
}
}
});
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
const items = BI.LogicFactory.createLogicItemsByDirection(
BI.Direction.Left,
const type = LogicFactory.createLogicTypeByDirection(Direction.Left);
const items = LogicFactory.createLogicItemsByDirection(
Direction.Left,
{
width: o.iconWrapperWidth,
el: this.checkbox,
@ -90,7 +90,7 @@ export class IconArrowNode extends NodeButton {
{
element: this,
},
BI.LogicFactory.createLogic(
LogicFactory.createLogic(
type,
extend(o.logic, {
items,

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

@ -1,5 +1,5 @@
import { TreeNodeCheckbox } from "../../checkbox";
import { VerticalAdaptLayout, shortcut, extend, createWidget, Controller } from "@/core";
import { VerticalAdaptLayout, shortcut, extend, createWidget, Controller, Events } from "@/core";
import { Label, NodeButton } from "@/base";
/**
@ -33,7 +33,7 @@ export class PlusGroupNode extends NodeButton {
});
this.checkbox.on(Controller.EVENT_CHANGE, (...args) => {
const [type] = args;
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
this.setSelected(this.isSelected());
}
this.fireEvent(Controller.EVENT_CHANGE, args);
@ -47,7 +47,7 @@ export class PlusGroupNode extends NodeButton {
{
el: {
type: Label.xtype,
ref: (_ref) => {
ref: _ref => {
this.text = _ref;
},
textAlign: "left",
@ -63,7 +63,7 @@ export class PlusGroupNode extends NodeButton {
keyword: o.keyword,
py: o.py,
},
},
}
],
};
}

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

@ -1,5 +1,5 @@
import { IconLabel, NodeButton } from "@/base";
import { shortcut, extend } from "@/core";
import { shortcut, extend, STYLE_CONSTANTS } from "@/core";
@shortcut()
export class TreeNodeSwitcher extends NodeButton {
@ -32,22 +32,22 @@ export class TreeNodeSwitcher extends NodeButton {
const options = this.options;
if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
// 只有一层,并且是第一个节点,并且是最后一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type1", "tree-expand-icon-type1"];
} else if (options.layer === 0 && options.isFirstNode) {
// 第一层,并且是第一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type2", "tree-expand-icon-type2"];
} else if (options.isLastNode) {
// 最后一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type4", "tree-expand-icon-type4"];
} else {
// 其他情况
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type3", "tree-expand-icon-type3"];
}

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

@ -1,5 +1,5 @@
import { IconLabel, Label, NodeButton } from "@/base";
import { shortcut, extend, VerticalAdaptLayout, Layout, isKey, compact } from "@/core";
import { shortcut, extend, VerticalAdaptLayout, isKey, compact, SIZE_CONSANTS } from "@/core";
import { TreeNodeSwitcher } from "@/case";
@shortcut()
@ -39,8 +39,6 @@ export class BasicTreeNode extends NodeButton {
isFirstNode,
isLastNode,
keyword,
iconWidth,
iconHeight,
iconWrapperWidth,
iconCls,
switcherIcon,
@ -82,7 +80,7 @@ export class BasicTreeNode extends NodeButton {
// width: height,
// cls: this.getLineCls(),
// },
// lgap: layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
// lgap: layer * SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
// width: "",
// };
@ -103,7 +101,7 @@ export class BasicTreeNode extends NodeButton {
items: compact([
{
el: checkbox,
lgap: layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
lgap: layer * SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
width: iconWrapperWidth || height,
},
icon,

19
src/case/button/switch.js

@ -1,11 +1,6 @@
import { AbsoluteLayout, shortcut } from "@/core";
import { AbsoluteLayout, shortcut, i18nText } from "@/core";
import { TextButton, Label, BasicButton } from "@/base";
/**
* Created by Windy on 2018/2/1.
*/
@shortcut()
export class Switch extends BasicButton {
static xtype = "bi.switch";
@ -32,7 +27,7 @@ export class Switch extends BasicButton {
return {
type: AbsoluteLayout.xtype,
ref: (_ref) => {
ref: _ref => {
this.layout = _ref;
},
items: [
@ -48,26 +43,26 @@ export class Switch extends BasicButton {
},
{
type: Label.xtype,
text: BI.i18nText("BI-Basic_Simple_Open"),
text: i18nText("BI-Basic_Simple_Open"),
cls: "content-tip",
left: 8,
top: tgap - 2,
invisible: !(o.showTip && o.selected),
ref: (_ref) => {
ref: _ref => {
this.openTip = _ref;
},
},
{
type: Label.xtype,
text: BI.i18nText("BI-Basic_Simple_Close"),
text: i18nText("BI-Basic_Simple_Close"),
cls: "content-tip",
right: 8,
top: tgap - 2,
invisible: !(o.showTip && !o.selected),
ref: (_ref) => {
ref: _ref => {
this.closeTip = _ref;
},
},
}
],
};
}

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

@ -1,4 +1,4 @@
import { CenterAdaptLayout, shortcut, extend, createWidget } from "@/core";
import { CenterAdaptLayout, shortcut, extend, createWidget, LogicFactory, Direction } from "@/core";
import { Icon, Label, BasicButton } from "@/base";
@shortcut()
@ -31,7 +31,7 @@ export class IconTreeLeafItem extends BasicButton {
type: Icon.xtype,
width: o.iconWidth,
height: o.iconHeight,
},
}
],
});
@ -47,9 +47,9 @@ export class IconTreeLeafItem extends BasicButton {
py: o.py,
keyword: o.keyword,
});
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
const items = BI.LogicFactory.createLogicItemsByDirection(
BI.Direction.Left,
const type = LogicFactory.createLogicTypeByDirection(Direction.Left);
const items = LogicFactory.createLogicItemsByDirection(
Direction.Left,
{
width: 16,
el: icon,
@ -63,7 +63,7 @@ export class IconTreeLeafItem extends BasicButton {
{
element: this,
},
BI.LogicFactory.createLogic(
LogicFactory.createLogic(
type,
extend(o.logic, {
items,

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

@ -1,11 +1,7 @@
import { IconTreeLeafItem } from "./item.icon.treeleaf";
import { Layout, HorizontalAdaptLayout, shortcut, extend, createWidget, Controller, makeArray, count } from "@/core";
import { Layout, HorizontalAdaptLayout, shortcut, extend, createWidget, Controller, makeArray, count, Events } from "@/core";
import { BasicButton } from "@/base";
/**
* @class BI.MultiLayerIconTreeLeafItem
* @extends BI.BasicButton
*/
@shortcut()
export class MultiLayerIconTreeLeafItem extends BasicButton {
static xtype = "bi.multilayer_icon_tree_leaf_item";
@ -42,7 +38,7 @@ export class MultiLayerIconTreeLeafItem extends BasicButton {
});
this.item.on(Controller.EVENT_CHANGE, (...args) => {
const [type] = args;
if (type === BI.Events.CLICK) {
if (type === Events.CLICK) {
// 本身实现click功能
return;
}

15
src/case/button/treeitem/treeitem.js

@ -1,4 +1,4 @@
import { shortcut, extend, VerticalAdaptLayout, Layout, compact, isKey } from "@/core";
import { shortcut, extend, VerticalAdaptLayout, Layout, compact, isKey, SIZE_CONSANTS, STYLE_CONSTANTS } from "@/core";
import { NodeButton, Label, IconLabel } from "@/base";
@shortcut()
@ -34,16 +34,11 @@ export class BasicTreeItem extends NodeButton {
textRgap,
text,
value,
isFirstNode,
isLastNode,
py,
keyword,
iconWidth,
iconHeight,
iconCls,
} = this.options;
const indent = {
el: {
type: Layout.xtype,
@ -51,7 +46,7 @@ export class BasicTreeItem extends NodeButton {
width: height,
cls: this.getLineCls(),
},
lgap: layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
lgap: layer * SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
width: "",
};
@ -101,11 +96,11 @@ export class BasicTreeItem extends NodeButton {
if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
return "";
} else if (options.layer === 0 && options.isFirstNode) {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-first-solid-line-conn-background" : "first-line-conn-background";
return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-first-solid-line-conn-background" : "first-line-conn-background";
} else if (options.isLastNode) {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-last-solid-line-conn-background" : "last-line-conn-background";
return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-last-solid-line-conn-background" : "last-line-conn-background";
} else {
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-mid-solid-line-conn-background" : "mid-line-conn-background";
return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-mid-solid-line-conn-background" : "mid-line-conn-background";
}
}

4
src/case/calendar/calendar.date.item.js

@ -1,4 +1,4 @@
import { AbsoluteLayout, shortcut } from "@/core";
import { AbsoluteLayout, shortcut, SIZE_CONSANTS } from "@/core";
import { TextItem, BasicButton } from "@/base";
/**
@ -9,7 +9,7 @@ export class CalendarDateItem extends BasicButton {
props() {
return {
baseCls: "bi-calendar-date-item",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 8,
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 8,
};
}

7
src/case/calendar/calendar.js

@ -19,7 +19,8 @@ import {
getShortDayName,
getOffsetDate,
isNotEmptyString,
parseInt
parseInt,
SIZE_CONSANTS
} from "@/core";
import { CalendarDateItem } from "./calendar.date.item";
@ -140,7 +141,7 @@ export class Calendar extends Widget {
const items = map(this._getWeekLabel(), (i, value) => {
return {
type: Label.xtype,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
text: value,
};
});
@ -168,7 +169,7 @@ export class Calendar extends Widget {
columns: 7,
rows: 6,
columnSize: [1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7],
rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 8,
rowSize: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 8,
})
)
],

7
src/case/calendar/calendar.year.js

@ -16,7 +16,8 @@ import {
Controller,
makeArray,
map,
isNotEmptyString
isNotEmptyString,
SIZE_CONSANTS
} from "@/core";
/**
@ -105,7 +106,7 @@ export class YearCalendar extends Widget {
columns: 2,
rows: 6,
columnSize: [1 / 2, 1 / 2],
rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
rowSize: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
})
),
{
@ -180,7 +181,7 @@ export class YearCalendar extends Widget {
whiteSpace: "normal",
once: false,
forceSelected: true,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
width: 45,
value: td.text,
disabled: td.disabled,

4
src/case/checkbox/check.checkingmarknode.js

@ -3,8 +3,8 @@ import { IconButton } from "@/base";
/**
* 十字型的树节点
* @class BI.CheckingMarkNode
* @extends BI.IconButton
* @class CheckingMarkNode
* @extends IconButton
*/
@shortcut()

18
src/case/checkbox/check.first.treenode.js

@ -1,10 +1,10 @@
import { extend, shortcut } from "@/core";
import { extend, shortcut, STYLE_CONSTANTS } from "@/core";
import { IconButton } from "@/base";
/**
* 十字型的树节点
* @class BI.FirstTreeNodeCheckbox
* @extends BI.IconButton
* @class FirstTreeNodeCheckbox
* @extends IconButton
*/
@shortcut()
@ -14,7 +14,7 @@ export class FirstTreeNodeCheckbox extends IconButton {
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls:
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? "tree-solid-collapse-icon-type2"
: "tree-collapse-icon-type2",
iconWidth: 24,
@ -23,11 +23,11 @@ export class FirstTreeNodeCheckbox extends IconButton {
}
getLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "tree-solid-expand-icon-type2";
default:
return "tree-expand-icon-type2";
switch (STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "tree-solid-expand-icon-type2";
default:
return "tree-expand-icon-type2";
}
}

18
src/case/checkbox/check.last.treenode.js

@ -1,10 +1,10 @@
import { extend, shortcut } from "@/core";
import { extend, shortcut, STYLE_CONSTANTS } from "@/core";
import { IconButton } from "@/base";
/**
* 十字型的树节点
* @class BI.LastTreeNodeCheckbox
* @extends BI.IconButton
* @class LastTreeNodeCheckbox
* @extends IconButton
*/
@shortcut()
@ -14,7 +14,7 @@ export class LastTreeNodeCheckbox extends IconButton {
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls:
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? "tree-solid-collapse-icon-type4"
: "tree-collapse-icon-type4",
iconWidth: 24,
@ -23,11 +23,11 @@ export class LastTreeNodeCheckbox extends IconButton {
}
getLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "tree-solid-expand-icon-type4";
default:
return "tree-expand-icon-type4";
switch (STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "tree-solid-expand-icon-type4";
default:
return "tree-expand-icon-type4";
}
}

18
src/case/checkbox/check.mid.treenode.js

@ -1,10 +1,10 @@
import { extend, shortcut } from "@/core";
import { extend, shortcut, STYLE_CONSTANTS } from "@/core";
import { IconButton } from "@/base";
/**
* 十字型的树节点
* @class BI.MidTreeNodeCheckbox
* @extends BI.IconButton
* @class MidTreeNodeCheckbox
* @extends IconButton
*/
@shortcut()
@ -14,7 +14,7 @@ export class MidTreeNodeCheckbox extends IconButton {
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls:
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? "tree-solid-collapse-icon-type3"
: "tree-collapse-icon-type3",
iconWidth: 24,
@ -23,11 +23,11 @@ export class MidTreeNodeCheckbox extends IconButton {
}
getLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "tree-solid-expand-icon-type3";
default:
return "tree-expand-icon-type3";
switch (STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "tree-solid-expand-icon-type3";
default:
return "tree-expand-icon-type3";
}
}

18
src/case/checkbox/check.treenode.js

@ -1,10 +1,10 @@
import { extend, shortcut } from "@/core";
import { extend, shortcut, STYLE_CONSTANTS } from "@/core";
import { IconButton } from "@/base";
/**
* 十字型的树节点
* @class BI.TreeNodeCheckbox
* @extends BI.IconButton
* @class TreeNodeCheckbox
* @extends IconButton
*/
@shortcut()
@ -14,7 +14,7 @@ export class TreeNodeCheckbox extends IconButton {
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls:
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? "tree-solid-collapse-icon-type1"
: "tree-collapse-icon-type1",
iconWidth: 24,
@ -23,11 +23,11 @@ export class TreeNodeCheckbox extends IconButton {
}
getLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "tree-solid-expand-icon-type1";
default:
return "tree-expand-icon-type1";
switch (STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "tree-solid-expand-icon-type1";
default:
return "tree-expand-icon-type1";
}
}

46
src/case/colorchooser/colorchooser.popup.hex.js

@ -14,7 +14,9 @@ import {
filter,
isArray,
Cache,
Queue
Queue,
i18nText,
emptyFn
} from "@/core";
import { Label, Combo, TextItem } from "@/base";
import { PopupPanel } from "../layer";
@ -37,7 +39,7 @@ export class HexColorChooserPopup extends Widget {
props = {
baseCls: "bi-color-chooser-popup",
width: 300,
recommendColorsGetter: BI.emptyFn, // 推荐色获取接口
recommendColorsGetter: emptyFn, // 推荐色获取接口
simple: false, // 简单模式, popup中没有自动和透明
};
@ -108,7 +110,7 @@ export class HexColorChooserPopup extends Widget {
items: [
{
type: Label.xtype,
text: BI.i18nText("BI-Basic_Recommend_Color"),
text: i18nText("BI-Basic_Recommend_Color"),
textAlign: "left",
height: 24,
},
@ -195,12 +197,12 @@ export class HexColorChooserPopup extends Widget {
textAlign: "center",
height: 24,
textLgap: 10,
text: `${BI.i18nText("BI-Basic_More")}...`,
text: `${i18nText("BI-Basic_More")}...`,
},
popup: {
type: PopupPanel.xtype,
buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")],
title: BI.i18nText("BI-Custom_Color"),
buttons: [i18nText("BI-Basic_Cancel"), i18nText("BI-Basic_Save")],
title: i18nText("BI-Custom_Color"),
el: {
type: CustomColorChooser.xtype,
value: o.value,
@ -216,25 +218,25 @@ export class HexColorChooserPopup extends Widget {
minWidth: 227,
listeners: [
{
eventName: BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON,
eventName: PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON,
action: (index, ...args) => {
switch (index) {
case 0:
this.more.hideView();
break;
case 1: {
const color = this.customColorChooser.getValue();
// farbtastic选择器没有透明和自动选项,点击保存不应该设置透明
if (isNotEmptyString(color)) {
this.setValue(color);
this._dealStoreColors();
case 0:
this.more.hideView();
break;
case 1: {
const color = this.customColorChooser.getValue();
// farbtastic选择器没有透明和自动选项,点击保存不应该设置透明
if (isNotEmptyString(color)) {
this.setValue(color);
this._dealStoreColors();
}
this.more.hideView();
this.fireEvent(ColorChooserPopup.EVENT_CHANGE, index, ...args);
break;
}
this.more.hideView();
this.fireEvent(ColorChooserPopup.EVENT_CHANGE, index, ...args);
break;
}
default:
break;
default:
break;
}
},
}

21
src/case/colorchooser/colorchooser.popup.js

@ -17,7 +17,8 @@ import {
count,
filter,
isNotEmptyString,
isArray
isArray,
i18nText
} from "@/core";
import { ColorPickerEditor, ColorPicker } from "./colorpicker";
@ -91,8 +92,8 @@ export class ColorChooserPopup extends Widget {
const panel = createWidget({
type: PopupPanel.xtype,
buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")],
title: BI.i18nText("BI-Custom_Color"),
buttons: [i18nText("BI-Basic_Cancel"), i18nText("BI-Basic_Save")],
title: i18nText("BI-Custom_Color"),
el: this.customColorChooser,
stopPropagation: false,
bgap: -1,
@ -113,7 +114,7 @@ export class ColorChooserPopup extends Widget {
textAlign: "center",
height: 24,
textLgap: 10,
text: `${BI.i18nText("BI-Basic_More")}...`,
text: `${i18nText("BI-Basic_More")}...`,
},
popup: panel,
});
@ -121,7 +122,7 @@ export class ColorChooserPopup extends Widget {
this.more.on(Combo.EVENT_AFTER_POPUPVIEW, () => {
this.customColorChooser.setValue(this.getValue());
});
panel.on(BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON, (index, ...args) => {
panel.on(PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON, (index, ...args) => {
switch (index) {
case 0:
this.more.hideView();
@ -154,7 +155,7 @@ export class ColorChooserPopup extends Widget {
left: 10,
right: 10,
top: 5,
},
}
],
},
height: 29,
@ -169,7 +170,7 @@ export class ColorChooserPopup extends Widget {
right: 10,
top: 5,
bottom: 5,
},
}
],
},
height: 60,
@ -177,7 +178,7 @@ export class ColorChooserPopup extends Widget {
{
el: this.more,
height: 24,
},
}
],
},
left: 0,
@ -198,7 +199,7 @@ export class ColorChooserPopup extends Widget {
right: 0,
top: 0,
bottom: 0,
},
}
],
};
}
@ -234,7 +235,7 @@ export class ColorChooserPopup extends Widget {
value: color,
};
});
count(colors.length, 8, (i) => {
count(colors.length, 8, i => {
items.push({
value: "",
disabled: true,

4
src/case/colorchooser/colorchooser.trigger.js

@ -1,4 +1,4 @@
import { Layout, AbsoluteLayout, shortcut, extend, createWidget, isNotNull } from "@/core";
import { Layout, AbsoluteLayout, shortcut, extend, createWidget, isNotNull, isIE9Below } from "@/core";
import { IconButton, Trigger } from "@/base";
/**
@ -29,7 +29,7 @@ export class ColorChooserTrigger extends Trigger {
super._init(...arguments);
this.colorContainer = createWidget({
type: Layout.xtype,
cls: `color-chooser-trigger-content${BI.isIE9Below && BI.isIE9Below() ? " hack" : ""}`,
cls: `color-chooser-trigger-content${isIE9Below && isIE9Below() ? " hack" : ""}`,
});
const down = createWidget({

8
src/case/colorchooser/colorchooser.trigger.long.js

@ -1,4 +1,4 @@
import { HTapeLayout, AbsoluteLayout, shortcut, extend, createWidget } from "@/core";
import { HTapeLayout, AbsoluteLayout, shortcut, extend, createWidget, i18nText } from "@/core";
import { IconChangeButton } from "../button";
import { Label, IconButton, Trigger } from "@/base";
@ -52,7 +52,7 @@ export class LongColorChooserTrigger extends Trigger {
textAlign: "left",
hgap: 5,
height: 18,
text: BI.i18nText("BI-Basic_Auto"),
text: i18nText("BI-Basic_Auto"),
},
}
],
@ -96,13 +96,13 @@ export class LongColorChooserTrigger extends Trigger {
this.changeIcon.setVisible(true);
this.label.setVisible(true);
this.changeIcon.setIcon("auto-color-icon");
this.label.setText(BI.i18nText("BI-Basic_Auto"));
this.label.setText(i18nText("BI-Basic_Auto"));
} else if (color === "transparent") {
this.colorContainer.element.css("background-color", "");
this.changeIcon.setVisible(true);
this.label.setVisible(true);
this.changeIcon.setIcon("trans-color-icon");
this.label.setText(BI.i18nText("BI-Transparent_Color"));
this.label.setText(i18nText("BI-Transparent_Color"));
} else {
this.colorContainer.element.css({ "background-color": color });
this.changeIcon.setVisible(false);

18
src/case/colorchooser/colorpicker/editor.colorpicker.hex.js

@ -13,11 +13,13 @@ import {
extend,
isEmptyString,
isNull,
DOM
DOM,
i18nText
} from "@/core";
import { ColorChooserShowButton } from "./button";
import { ColorPickerEditor } from "./editor.colorpicker";
import { SmallTextEditor } from "@/widget/editor/editor.text.small.js";
import { TextEditor } from "@/widget/editor/editor.text";
const RGB_WIDTH = 32,
HEX_WIDTH = 70,
@ -55,14 +57,14 @@ export class HexColorPickerEditor extends Widget {
type: SmallTextEditor.xtype,
cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
errorText: i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true,
value: 255,
width: RGB_WIDTH,
height: 24,
listeners: [
{
eventName: BI.TextEditor.EVENT_CHANGE,
eventName: TextEditor.EVENT_CHANGE,
action: () => {
this._checkEditors();
if (
@ -96,8 +98,8 @@ export class HexColorPickerEditor extends Widget {
type: ColorChooserShowButton.xtype,
cls: "trans-color-icon",
height: 22,
title: BI.i18nText("BI-Transparent_Color"),
text: BI.i18nText("BI-Transparent_Color"),
title: i18nText("BI-Transparent_Color"),
text: i18nText("BI-Transparent_Color"),
listeners: [
{
eventName: ColorChooserShowButton.EVENT_CHANGE,
@ -116,8 +118,8 @@ export class HexColorPickerEditor extends Widget {
type: ColorChooserShowButton.xtype,
cls: "auto-color-icon",
height: 22,
title: BI.i18nText("BI-Basic_Auto"),
text: BI.i18nText("BI-Basic_Auto"),
title: i18nText("BI-Basic_Auto"),
text: i18nText("BI-Basic_Auto"),
listeners: [
{
eventName: ColorChooserShowButton.EVENT_CHANGE,
@ -167,7 +169,7 @@ export class HexColorPickerEditor extends Widget {
cls: "color-picker-editor-input bi-border-radius",
validationChecker: this._hexChecker,
allowBlank: true,
errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"),
errorText: i18nText("BI-Color_Picker_Error_Text_Hex"),
width: HEX_WIDTH,
height: 24,
listeners: [

30
src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js

@ -13,11 +13,13 @@ import {
map,
isEmptyString,
range,
DOM
DOM,
i18nText
} from "@/core";
import { SimpleColorPickerEditor } from "./editor.colorpicker.simple";
import { ColorPickerEditor } from "./editor.colorpicker";
import { SmallTextEditor } from "@/widget/editor/editor.text.small.js";
import { TextEditor } from "@/widget/editor/editor.text";
const RGB_WIDTH = 32,
HEX_WIDTH = 70,
@ -46,20 +48,20 @@ export class SimpleHexColorPickerEditor extends Widget {
height: 20,
});
const checker = (v) => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const checker = v => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const Ws = map(range(0, 3), () => {
return {
type: SmallTextEditor.xtype,
cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
errorText: i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true,
value: 255,
width: RGB_WIDTH,
height: 24,
listeners: [
{
eventName: BI.TextEditor.EVENT_CHANGE,
eventName: TextEditor.EVENT_CHANGE,
action: () => {
this._checkEditors();
if (this.R.isValid() && this.G.isValid() && this.B.isValid()) {
@ -67,7 +69,7 @@ export class SimpleHexColorPickerEditor extends Widget {
this.fireEvent(SimpleColorPickerEditor.EVENT_CHANGE);
}
},
},
}
],
};
});
@ -88,7 +90,7 @@ export class SimpleHexColorPickerEditor extends Widget {
cls: "color-picker-editor-display bi-card bi-border",
height: 22,
width: 22,
ref: (_ref) => {
ref: _ref => {
this.colorShow = _ref;
},
},
@ -101,13 +103,13 @@ export class SimpleHexColorPickerEditor extends Widget {
},
{
type: SmallTextEditor.xtype,
ref: (_ref) => {
ref: _ref => {
this.hexEditor = _ref;
},
cls: "color-picker-editor-input bi-border-radius",
validationChecker: this._hexChecker,
allowBlank: true,
errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"),
errorText: i18nText("BI-Color_Picker_Error_Text_Hex"),
width: HEX_WIDTH,
height: 24,
listeners: [
@ -124,13 +126,13 @@ export class SimpleHexColorPickerEditor extends Widget {
this.fireEvent(ColorPickerEditor.EVENT_CHANGE);
}
},
},
}
],
},
RGB[0],
{
el: extend(Ws[0], {
ref: (_ref) => {
ref: _ref => {
this.R = _ref;
},
}),
@ -139,7 +141,7 @@ export class SimpleHexColorPickerEditor extends Widget {
RGB[1],
{
el: extend(Ws[1], {
ref: (_ref) => {
ref: _ref => {
this.G = _ref;
},
}),
@ -148,16 +150,16 @@ export class SimpleHexColorPickerEditor extends Widget {
RGB[2],
{
el: extend(Ws[2], {
ref: (_ref) => {
ref: _ref => {
this.B = _ref;
},
}),
rgap: -5,
width: RGB_WIDTH,
},
}
],
},
},
}
],
};
}

18
src/case/colorchooser/colorpicker/editor.colorpicker.js

@ -12,10 +12,12 @@ import {
isEmptyString,
isNumeric,
isNull,
DOM
DOM,
i18nText
} from "@/core";
import { Label, IconButton } from "@/base";
import { SmallTextEditor } from "@/widget/editor/editor.text.small.js";
import { TextEditor } from "@/widget/editor/editor.text";
const RGB_WIDTH = 32;
@ -58,19 +60,19 @@ export class ColorPickerEditor extends Widget {
})
);
const checker = (v) => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const checker = v => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const Ws = createWidgets([{}, {}, {}], {
type: SmallTextEditor.xtype,
cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
errorText: i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true,
value: 255,
width: RGB_WIDTH,
height: 20,
});
each(Ws, (i, w) => {
w.on(BI.TextEditor.EVENT_CHANGE, () => {
w.on(TextEditor.EVENT_CHANGE, () => {
this._checkEditors();
if (checker(this.storeValue.r) && checker(this.storeValue.g) && checker(this.storeValue.b)) {
this.colorShow.element.css("background-color", this.getValue());
@ -89,7 +91,7 @@ export class ColorPickerEditor extends Widget {
height: 16,
iconWidth: 16,
iconHeight: 16,
title: BI.i18nText("BI-Basic_Auto"),
title: i18nText("BI-Basic_Auto"),
});
this.none.on(IconButton.EVENT_CHANGE, () => {
const value = this.getValue();
@ -104,7 +106,7 @@ export class ColorPickerEditor extends Widget {
height: 16,
iconWidth: 16,
iconHeight: 16,
title: BI.i18nText("BI-Transparent_Color"),
title: i18nText("BI-Transparent_Color"),
});
this.transparent.on(IconButton.EVENT_CHANGE, () => {
const value = this.getValue();
@ -157,14 +159,14 @@ export class ColorPickerEditor extends Widget {
el: this.none,
width: 16,
lgap: 5,
},
}
],
},
left: 10,
right: 10,
top: 0,
bottom: 0,
},
}
],
});
}

12
src/case/colorchooser/colorpicker/editor.colorpicker.simple.js

@ -11,10 +11,12 @@ import {
createWidgets,
each,
isEmptyString,
DOM
DOM,
i18nText
} from "@/core";
import { Label } from "@/base";
import { SmallTextEditor } from "@/widget/editor/editor.text.small.js";
import { TextEditor } from "@/widget/editor/editor.text";
const RGB_WIDTH = 32;
@ -56,19 +58,19 @@ export class SimpleColorPickerEditor extends Widget {
})
);
const checker = (v) => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const checker = v => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const Ws = createWidgets([{}, {}, {}], {
type: SmallTextEditor.xtype,
cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
errorText: i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true,
value: 255,
width: RGB_WIDTH,
height: 20,
});
each(Ws, (i, w) => {
w.on(BI.TextEditor.EVENT_CHANGE, () => {
w.on(TextEditor.EVENT_CHANGE, () => {
this._checkEditors();
if (this.R.isValid() && this.G.isValid() && this.B.isValid()) {
this.colorShow.element.css("background-color", this.getValue());
@ -113,7 +115,7 @@ export class SimpleColorPickerEditor extends Widget {
{
el: this.B,
width: RGB_WIDTH,
},
}
],
});
}

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

@ -1,10 +1,10 @@
import { shortcut, extend } from "@/core";
import { shortcut, extend, i18nText, each, isWidget, createWidget } from "@/core";
import { PopupView } from "@/base/layer/layer.popup";
import { Label } from "@/base/single/label/label";
@shortcut()
export class BubblePopupView extends PopupView {
static xtype = "bi.text_bubble_bar_popup_view";
static xtype = "bi.bubble_popup_view";
static EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON";
static EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON";
@ -26,7 +26,7 @@ export class BubblePopupView extends PopupView {
text: o.text,
whiteSpace: "normal",
textAlign: "left",
ref: (_ref) => {
ref: _ref => {
this.text = _ref;
},
};
@ -36,3 +36,112 @@ export class BubblePopupView extends PopupView {
this.text.setText(v || this.options.text);
}
}
@shortcut()
export class BubblePopupBarView extends BubblePopupView {
static xtype = "bi.bubble_bar_popup_view";
static EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON";
_defaultConfig () {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-bubble-bar-popup-view",
buttons: [{
value: false,
text: i18nText("BI-Basic_Cancel"),
level: "ignore",
}, {
text: i18nText(i18nText("BI-Basic_OK")),
value: true,
}],
innerVgap: 16,
innerHgap: 16,
});
}
_createToolBar () {
const o = this.options;
const items = [];
each(o.buttons, (i, buttonOpt) => {
if (isWidget(buttonOpt)) {
items.push({
el: buttonOpt,
lgap: 12,
});
} else {
items.push({
el: extend({
type: "bi.button",
height: 24,
handler: v => {
this.fireEvent(BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, v);
},
}, buttonOpt),
lgap: 12,
});
}
});
return createWidget({
type: "bi.right_vertical_adapt",
innerVgap: o.innerVgap,
innerHgap: o.innerHgap,
items,
});
}
_createContent () {
return this.options.el;
}
_createView () {
const o = this.options;
const view = createWidget({
type: "bi.vertical",
items: [this._createContent()],
cls: "bar-popup-container",
hgap: o.innerHgap,
tgap: o.innerVgap,
});
view.element.css("min-height", o.minHeight);
return view;
}
}
@shortcut()
export class TextBubblePopupBarView extends BubblePopupBarView {
static xtype = "bi.text_bubble_bar_popup_view";
static EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON";
_defaultConfig () {
const config = super._defaultConfig(...arguments);
return extend(config, {
baseCls: `${config.baseCls} bi-text-bubble-bar-popup-view`,
text: "",
});
}
_createContent () {
const o = this.options;
return {
type: "bi.label",
text: o.text,
whiteSpace: "normal",
textAlign: "left",
ref: _ref => {
this.text = _ref;
},
};
}
populate (v) {
this.text.setText(v || this.options.text);
}
}

4
src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js

@ -1,4 +1,4 @@
import { HorizontalFillLayout, shortcut, find, i18nText, isNotEmptyString, VerticalAdaptLayout } from "@/core";
import { HorizontalFillLayout, shortcut, find, i18nText, isNotEmptyString, VerticalAdaptLayout, Func } from "@/core";
import { SearchTextValueComboPopup } from "./popup.searchtextvalue";
import { ButtonGroup, Trigger, Searcher, IconButton } from "@/base";
import { TriggerIconButton } from "../../button";
@ -69,7 +69,7 @@ export class SearchTextValueTrigger extends Trigger {
},
onSearch(obj, callback) {
const keyword = obj.keyword;
const finding = BI.Func.getSearchResult(o.items, keyword);
const finding = Func.getSearchResult(o.items, keyword);
const matched = finding.match,
find = finding.find;
callback(matched, find);

8
src/case/layer/layer.multipopup.js

@ -1,10 +1,10 @@
import { ButtonGroup, TextButton, PopupView } from "@/base";
import { CenterLayout, shortcut, extend, i18nText, each, createWidget, createItems } from "@/core";
import { CenterLayout, shortcut, extend, i18nText, each, createWidget, createItems, SIZE_CONSANTS } from "@/core";
/**
* 下拉框弹出层的多选版本toolbar带有若干按钮, zIndex在1000w
* @class BI.MultiPopupView
* @extends BI.Widget
* @class MultiPopupView
* @extends Widget
*/
@shortcut()
@ -38,7 +38,7 @@ export class MultiPopupView extends PopupView {
this.buttongroup = createWidget({
type: ButtonGroup.xtype,
cls: "list-view-toolbar bi-high-light bi-split-top",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
items: createItems(text, {
type: TextButton.xtype,
once: false,

4
src/case/layer/layer.panel.js

@ -4,8 +4,8 @@ import { MultiPopupView } from "./layer.multipopup";
/**
* 可以理解为MultiPopupView和Panel两个面板的结合体
* @class BI.PopupPanel
* @extends BI.MultiPopupView
* @class PopupPanel
* @extends MultiPopupView
*/
@shortcut()

4
src/case/layer/pane.list.js

@ -24,8 +24,8 @@ import { Pane, ButtonGroup } from "@/base";
* list面板
*
* Created by GUY on 2015/10/30.
* @class BI.ListPane
* @extends BI.Pane
* @class ListPane
* @extends Pane
*/
@shortcut()

39
src/case/pager/pager.all.count.js

@ -10,7 +10,8 @@ import {
createWidget,
parseInt,
HorizontalAlign,
isNotEmptyObject
isNotEmptyObject,
i18nText
} from "@/core";
import { SmallTextEditor } from "@/widget/editor/editor.text.small";
import { TextEditor } from "@/widget/editor/editor.text";
@ -52,7 +53,7 @@ export class AllCountPager extends Widget {
hgap: 4,
vgap: 0,
value: curr,
errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
errorText: i18nText("BI-Please_Input_Positive_Integer"),
width: 40,
height: 24,
invisible: pages <= 1,
@ -78,8 +79,8 @@ export class AllCountPager extends Widget {
prev: {
type: IconButton.xtype,
value: "prev",
title: BI.i18nText("BI-Previous_Page"),
warningTitle: BI.i18nText("BI-Current_Is_First_Page"),
title: i18nText("BI-Previous_Page"),
warningTitle: i18nText("BI-Current_Is_First_Page"),
height: 22,
width: 22,
cls: `bi-border bi-border-radius all-pager-prev bi-list-item-select2 ${pagerIconCls.preCls}`,
@ -87,8 +88,8 @@ export class AllCountPager extends Widget {
next: {
type: IconButton.xtype,
value: "next",
title: BI.i18nText("BI-Next_Page"),
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"),
title: i18nText("BI-Next_Page"),
warningTitle: i18nText("BI-Current_Is_Last_Page"),
height: 22,
width: 22,
cls: `bi-border bi-border-radius all-pager-next bi-list-item-select2 ${pagerIconCls.nextCls}`,
@ -142,17 +143,17 @@ export class AllCountPager extends Widget {
_getPagerIconCls() {
const { pagerDirection } = this.options;
switch (pagerDirection) {
case "horizontal":
return {
preCls: "row-pre-page-h-font ",
nextCls: "row-next-page-h-font ",
};
case "vertical":
default:
return {
preCls: "column-pre-page-h-font ",
nextCls: "column-next-page-h-font ",
};
case "horizontal":
return {
preCls: "row-pre-page-h-font ",
nextCls: "row-next-page-h-font ",
};
case "vertical":
default:
return {
preCls: "column-pre-page-h-font ",
nextCls: "column-next-page-h-font ",
};
}
}
@ -170,7 +171,7 @@ export class AllCountPager extends Widget {
{
type: Label.xtype,
height,
text: BI.i18nText("BI-Basic_Total"),
text: i18nText("BI-Basic_Total"),
ref: _ref => {
this.prevText = _ref;
},
@ -191,7 +192,7 @@ export class AllCountPager extends Widget {
{
type: Label.xtype,
height,
text: BI.i18nText("BI-Tiao_Data"),
text: i18nText("BI-Tiao_Data"),
textAlign: "left",
},
isNotEmptyObject(rowInfoObject) ? rowInfoObject : null

54
src/case/pager/pager.detail.js

@ -20,8 +20,8 @@ import { Label, ButtonGroup } from "@/base";
* 分页控件
*
* Created by GUY on 2015/8/31.
* @class BI.DetailPager
* @extends BI.Widget
* @class DetailPager
* @extends Widget
*/
@shortcut()
@ -233,21 +233,21 @@ export class DetailPager extends Widget {
if (type === Events.CLICK) {
const v = this.button_group.getValue()[0];
switch (v) {
case "first":
this.currPage = 1;
break;
case "last":
this.currPage = pages;
break;
case "prev":
this.currPage--;
break;
case "next":
this.currPage++;
break;
default:
this.currPage = v;
break;
case "first":
this.currPage = 1;
break;
case "last":
this.currPage = pages;
break;
case "prev":
this.currPage--;
break;
case "next":
this.currPage++;
break;
default:
this.currPage = v;
break;
}
jump.apply(this, [
{
@ -308,16 +308,16 @@ export class DetailPager extends Widget {
getValue() {
const val = this.button_group.getValue()[0];
switch (val) {
case "prev":
return -1;
case "next":
return 1;
case "first":
return MIN;
case "last":
return MAX;
default:
return val;
case "prev":
return -1;
case "next":
return 1;
case "first":
return MIN;
case "last":
return MAX;
default:
return val;
}
}

22
src/case/pager/pager.direction.js

@ -1,12 +1,12 @@
import { AbsoluteLayout, HorizontalLayout, shortcut, Widget, extend, emptyFn, createWidget } from "@/core";
import { AbsoluteLayout, HorizontalLayout, shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core";
import { Label, Pager, IconButton } from "@/base";
/**
* 显示页码的分页控件
*
* Created by GUY on 2016/6/30.
* @class BI.DirectionPager
* @extends BI.Widget
* @class DirectionPager
* @extends Widget
*/
@shortcut()
@ -103,8 +103,8 @@ export class DirectionPager extends Widget {
prev: {
type: IconButton.xtype,
value: "prev",
title: BI.i18nText("BI-Up_Page"),
warningTitle: BI.i18nText("BI-Current_Is_First_Page"),
title: i18nText("BI-Up_Page"),
warningTitle: i18nText("BI-Current_Is_First_Page"),
height: 22,
width: 22,
cls: "bi-border bi-border-radius direction-pager-prev column-pre-page-h-font bi-list-item-select2",
@ -112,8 +112,8 @@ export class DirectionPager extends Widget {
next: {
type: IconButton.xtype,
value: "next",
title: BI.i18nText("BI-Down_Page"),
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"),
title: i18nText("BI-Down_Page"),
warningTitle: i18nText("BI-Current_Is_Last_Page"),
height: 22,
width: 22,
cls: "bi-border bi-border-radius direction-pager-next column-next-page-h-font bi-list-item-select2",
@ -165,8 +165,8 @@ export class DirectionPager extends Widget {
prev: {
type: IconButton.xtype,
value: "prev",
title: BI.i18nText("BI-Left_Page"),
warningTitle: BI.i18nText("BI-Current_Is_First_Page"),
title: i18nText("BI-Left_Page"),
warningTitle: i18nText("BI-Current_Is_First_Page"),
height: 22,
width: 22,
cls: "bi-border bi-border-radius direction-pager-prev row-pre-page-h-font bi-list-item-select2",
@ -174,8 +174,8 @@ export class DirectionPager extends Widget {
next: {
type: IconButton.xtype,
value: "next",
title: BI.i18nText("BI-Right_Page"),
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"),
title: i18nText("BI-Right_Page"),
warningTitle: i18nText("BI-Current_Is_Last_Page"),
height: 22,
width: 22,
cls: "bi-border bi-border-radius direction-pager-next row-next-page-h-font bi-list-item-select2",

5
src/case/tree/tree.level.js

@ -11,7 +11,8 @@ import {
createWidget,
VerticalLayout,
Controller,
Events
Events,
SIZE_CONSANTS
} from "@/core";
import { ButtonTree, CustomTree } from "@/base";
import { TreeExpander } from "./treeexpander/tree.expander";
@ -45,7 +46,7 @@ export class LevelTree extends Widget {
each(nodes, (i, node) => {
const extend = {
layer,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
isFirstNode: i === 0,
isLastNode: i === nodes.length - 1,
};

6
src/case/tree/treeexpander/tree.expander.popup.js

@ -1,4 +1,4 @@
import { Controller, createWidget, pixFormat, shortcut, VerticalLayout, Widget } from "@/core";
import { Controller, createWidget, pixFormat, shortcut, VerticalLayout, Widget, SIZE_CONSANTS, STYLE_CONSTANTS } from "@/core";
@shortcut()
export class TreeExpanderPopup extends Widget {
@ -17,7 +17,7 @@ export class TreeExpanderPopup extends Widget {
render() {
const self = this;
const { el, value, layer, showLine, isLastNode } = this.options;
const offset = BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2;
const offset = SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2;
this.popupView = createWidget(
{
@ -38,7 +38,7 @@ export class TreeExpanderPopup extends Widget {
return {
type: VerticalLayout.xtype,
cls: showLine && !isLastNode ? (BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "line solid" : "line") : "",
cls: showLine && !isLastNode ? (STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "line solid" : "line") : "",
scrolly: null,
items: [this.popupView],
};

6
src/case/ztree/list/listtreeview.js

@ -5,8 +5,8 @@ import { extend, isNotNull, concat, each, shortcut } from "@/core";
* author: windy
* 继承自treeView, 此树的父子节点的勾选状态互不影响, 此树不会有半选节点
* 返回value格式为[["A"], ["A", "a"]]表示勾选了A且勾选了a
* @class BI.ListTreeView
* @extends BI.TreeView
* @class ListTreeView
* @extends TreeView
*/
@shortcut()
@ -93,7 +93,7 @@ export class Listtreeview extends TreeView {
_transMapToArray(treeMap) {
const array = [];
BI.each(treeMap, key => {
each(treeMap, key => {
const item = key.split(this._constants.SPLIT);
array.push(item);
});

4
src/case/ztree/parttree.js

@ -5,8 +5,8 @@ import { TreeView } from "./treeview";
/**
* guy
* 局部树两个请求树 第一个请求构造树第二个请求获取节点
* @class BI.PartTree
* @extends BI.AsyncTree
* @class PartTree
* @extends AsyncTree
*/
@shortcut()

10
src/case/ztree/tree.display.js

@ -1,11 +1,11 @@
import { extend, shortcut } from "@/core";
import { extend, shortcut, each, i18nText } from "@/core";
import { TreeView } from "./treeview";
/**
* guy
* 异步树
* @class BI.DisplayTree
* @extends BI.TreeView
* @class DisplayTree
* @extends TreeView
*/
@shortcut()
@ -50,11 +50,11 @@ export class DisplayTree extends TreeView {
_dealWidthNodes(nodes) {
nodes = super._dealWidthNodes(...arguments);
BI.each(nodes, (i, node) => {
each(nodes, (i, node) => {
node.isParent = node.isParent || node.parent;
if (node.text == null) {
if (node.count > 0) {
node.text = `${node.value}(${BI.i18nText("BI-Basic_Altogether")}${node.count}${BI.i18nText(
node.text = `${node.value}(${i18nText("BI-Basic_Altogether")}${node.count}${i18nText(
"BI-Basic_Count"
)})`;
}

8
src/case/ztree/tree.list.display.js

@ -1,11 +1,11 @@
import { Listtreeview } from "./list/listtreeview";
import { each, shortcut } from "@/core";
import { each, shortcut, i18nText } from "@/core";
/**
* guy
* 异步树
* @class BI.ListListDisplayTree
* @extends BI.TreeView
* @class ListListDisplayTree
* @extends TreeView
*/
@shortcut()
@ -59,7 +59,7 @@ export class ListDisplayTree extends Listtreeview {
node.isParent = node.isParent || node.parent;
if (node.text == null) {
if (node.count > 0) {
node.text = `${node.value}(${BI.i18nText("BI-Basic_Altogether")}${node.count}${BI.i18nText(
node.text = `${node.value}(${i18nText("BI-Basic_Altogether")}${node.count}${i18nText(
"BI-Basic_Count"
)})`;
}

8
src/case/ztree/treeview.js

@ -21,7 +21,9 @@ import {
VerticalLayout,
Layout,
DefaultLayout,
some
some,
Widget,
STYLE_CONSTANTS
} from "@/core";
import { Msg, Pane, LoadingBar, Text } from "@/base";
@ -81,7 +83,7 @@ export class TreeView extends Pane {
this.tree = createWidget({
type: Layout.xtype,
element: `<ul id='${this.id}' class='ztree${
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? " solid'" : "'"
STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? " solid'" : "'"
}></ul>`,
});
createWidget({
@ -408,7 +410,7 @@ export class TreeView extends Pane {
}
)
);
const fragment = BI.Widget._renderEngine.createElement("<div>");
const fragment = Widget._renderEngine.createElement("<div>");
fragment.append(text.element[0]);
newNode.text = fragment.html();
// // 处理标红

31
src/core/4.widget.js

@ -9,6 +9,9 @@
import { isFunction, isArray, each, extend, isPlainObject, isNull, uniqueId, isWidget, isWidthOrHeight, isKey, remove, any, isNotNull } from "./2.base";
import { OB } from "./3.ob";
import { Providers, _lazyCreateWidget } from "./5.inject";
import { DOM } from "./utils";
import { Events, emptyFn, pixFormat } from "./constant";
import { Plugin } from "./6.plugin";
const cancelAnimationFrame =
_global.cancelAnimationFrame ||
@ -186,7 +189,7 @@ export class Widget extends OB {
callLifeHook(this, "beforeMount");
this._mount();
callLifeHook(this, "mounted");
this.fireEvent(BI.Events.MOUNT);
this.fireEvent(Events.MOUNT);
} else {
this._mount();
}
@ -251,7 +254,7 @@ export class Widget extends OB {
this._watchers = this._watchers || [];
const watcher = new Fix.Watcher(null, () => getter.call(this, this), (handler && (v => {
handler.call(this, this, v);
})) || BI.emptyFn, extend({ deep: true }, options));
})) || emptyFn, extend({ deep: true }, options));
this._watchers.push(() => {
watcher.teardown();
});
@ -291,14 +294,14 @@ export class Widget extends OB {
_initElementWidth() {
const o = this.options;
if (isWidthOrHeight(o.width)) {
this.element.css("width", BI.pixFormat(o.width));
this.element.css("width", pixFormat(o.width));
}
}
_initElementHeight() {
const o = this.options;
if (isWidthOrHeight(o.height)) {
this.element.css("height", BI.pixFormat(o.height));
this.element.css("height", pixFormat(o.height));
}
}
@ -366,7 +369,7 @@ export class Widget extends OB {
const render = isFunction(this.options.render) ? this.options.render : (workerMode ? (this.$render || this.render) : this.render);
let els = render && render.call(this);
els = this.options.configRender ? this.options.configRender.call(this, els) : els;
els = BI.Plugin.getRender(this.options.type, els);
els = Plugin.getRender(this.options.type, els);
if (isPlainObject(els)) {
els = [els];
}
@ -436,7 +439,7 @@ export class Widget extends OB {
if (lifeHook !== false && !this.__async) {
callLifeHook(this, "_mounted");
callLifeHook(this, "mounted");
this.fireEvent(BI.Events.MOUNT);
this.fireEvent(Events.MOUNT);
}
predicate && predicate(this);
}
@ -569,7 +572,7 @@ export class Widget extends OB {
setVisible(visible) {
this._innerSetVisible(visible);
this.fireEvent(BI.Events.VIEW, visible);
this.fireEvent(Events.VIEW, visible);
}
setValid(valid) {
@ -613,7 +616,7 @@ export class Widget extends OB {
throw new Error("组件:组件名已存在,不能进行添加");
}
widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () {
widget.on(Events.DESTROY, function () {
// TODO: self待删
remove(self._children, this);
});
@ -760,7 +763,7 @@ export class Widget extends OB {
_unMount() {
this._assetMounted();
this.__destroy();
this.fireEvent(BI.Events.UNMOUNT);
this.fireEvent(Events.UNMOUNT);
this.purgeListeners();
}
@ -785,7 +788,7 @@ export class Widget extends OB {
if (this._parent) {
this._parent.removeWidget(this);
}
BI.DOM.hang([this]);
DOM.hang([this]);
}
empty () {
@ -800,7 +803,7 @@ export class Widget extends OB {
}
// if (this.options.vdom) {
// const vnode = this._renderVNode();
// BI.patchVNode(this.vnode, vnode);
// patchVNode(this.vnode, vnode);
// this.vnode = vnode;
// return;
// }
@ -841,8 +844,8 @@ export class Widget extends OB {
} else {
this.element.destroy();
}
this.fireEvent(BI.Events.UNMOUNT);
this.fireEvent(BI.Events.DESTROY);
this.fireEvent(Events.UNMOUNT);
this.fireEvent(Events.DESTROY);
this._purgeRef();
this.purgeListeners();
}
@ -1082,7 +1085,7 @@ export function mount(widget, container, predicate, hydrate) {
});
// 将新的dom树属性(事件等)patch到已存在的dom上
const c = Widget._renderEngine.createElement;
BI.DOM.patchProps(widget.element, c(c(container).children()[0]));
DOM.patchProps(widget.element, c(c(container).children()[0]));
const triggerLifeHook = w => {
w.beforeMount && w.beforeMount();

25
src/core/5.inject.js

@ -1,6 +1,9 @@
import { isFunction, isNull, isNotNull, isArray, each, isWidget, extend, init, isEmpty, remove } from "./2.base";
import { OB } from "./3.ob";
import { Widget } from "./4.widget";
import { Plugin } from "./6.plugin";
import { aspect } from "./structure";
import { Events } from "./constant";
const moduleInjection = {}, moduleInjectionMap = {
components: {},
@ -158,7 +161,7 @@ const runConfigFunction = (type, configFn) => {
fn(providers[type]);
continue;
}
BI.Plugin.configWidget(type, fn, conf.opt);
Plugin.configWidget(type, fn, conf.opt);
}
};
@ -197,7 +200,7 @@ export function config(type, configFn, opt) {
}
export function getReference(type, fn) {
return BI.Plugin.registerObject(type, fn);
return Plugin.registerObject(type, fn);
}
const actions = {};
@ -268,7 +271,7 @@ function callPoint(inst, types) {
for (const action in points[type]) {
const bfns = points[type][action].before;
if (bfns) {
BI.aspect.before(inst, action, (function (bfns) {
aspect.before(inst, action, (function (bfns) {
return function () {
for (let i = 0, len = bfns.length; i < len; i++) {
try {
@ -282,7 +285,7 @@ function callPoint(inst, types) {
}
const afns = points[type][action].after;
if (afns) {
BI.aspect.after(inst, action, (function (afns) {
aspect.after(inst, action, (function (afns) {
return function () {
for (let i = 0, len = afns.length; i < len; i++) {
try {
@ -462,23 +465,23 @@ export function createWidget(item, options, context, lazy) {
return item;
}
if (el) {
w = BI.Plugin.getWidget(elType, el);
w = Plugin.getWidget(elType, el);
const wType = (w.type && w.type.xtype) || w.type;
if (wType === elType) {
if (BI.Plugin.hasObject(elType)) {
if (Plugin.hasObject(elType)) {
if (!w.listeners || isArray(w.listeners)) {
w.listeners = (w.listeners || []).concat([{
eventName: BI.Events.MOUNT,
eventName: Events.MOUNT,
action: () => {
BI.Plugin.getObject(elType, this);
Plugin.getObject(elType, this);
},
}]);
} else {
w.listeners[BI.Events.MOUNT] = [
w.listeners[Events.MOUNT] = [
() => {
BI.Plugin.getObject(elType, this);
Plugin.getObject(elType, this);
}
].concat(w.listeners[BI.Events.MOUNT] || []);
].concat(w.listeners[Events.MOUNT] || []);
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save