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-李振飞 1 year 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. 74
      src/base/combination/combo.js
  6. 35
      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. 29
      src/base/combination/searcher.js
  11. 41
      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. 4
      src/base/layer/layer.drawer.js
  18. 28
      src/base/layer/layer.popover.js
  19. 45
      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. 17
      src/base/pager/pager.js
  25. 48
      src/base/single/1.text.js
  26. 4
      src/base/single/a/a.js
  27. 22
      src/base/single/bar/bar.loading.js
  28. 39
      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. 31
      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. 12
      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. 10
      src/case/checkbox/check.first.treenode.js
  73. 10
      src/case/checkbox/check.last.treenode.js
  74. 10
      src/case/checkbox/check.mid.treenode.js
  75. 10
      src/case/checkbox/check.treenode.js
  76. 16
      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. 17
      src/case/pager/pager.all.count.js
  90. 4
      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"}], // 多行对象字面量中要求拖尾逗号 "comma-dangle": ["error", { "arrays": "never", "objects": "always-multiline"}], // 多行对象字面量中要求拖尾逗号
"no-var": 2, "no-var": 2,
"prefer-const": 2, "prefer-const": 2,
"indent": ["error", 4], "indent": ["error", 4, { "SwitchCase": 1 }],
"no-use-before-define": 0, "no-use-before-define": 0,
"eqeqeq": 0 "eqeqeq": 0
} }

12
src/base/1.pane.js

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

11
src/base/collection/collection.js

@ -16,7 +16,8 @@ import {
invert, invert,
min, min,
max, max,
nextTick nextTick,
DOM
} from "@/core"; } from "@/core";
import { Label } from "../single"; import { Label } from "../single";
@ -24,8 +25,8 @@ import { Label } from "../single";
* CollectionView * CollectionView
* *
* Created by GUY on 2016/1/15. * Created by GUY on 2016/1/15.
* @class BI.CollectionView * @class CollectionView
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()
@ -376,11 +377,11 @@ export class CollectionView extends Widget {
} }
_getMaxScrollLeft() { _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() { _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) { _populate(items) {

88
src/base/combination/bubble.js

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

74
src/base/combination/combo.js

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

35
src/base/combination/expander.js

@ -8,7 +8,9 @@ import {
each, each,
debounce, debounce,
isNull, isNull,
createWidget createWidget,
Events,
EVENT_RESPONSE_TIME
} from "@/core"; } from "@/core";
import { ButtonGroup } from "./group.button"; import { ButtonGroup } from "./group.button";
@ -17,10 +19,9 @@ import { ButtonGroup } from "./group.button";
* 某个可以展开的节点 * 某个可以展开的节点
* *
* Created by GUY on 2015/9/10. * Created by GUY on 2015/9/10.
* @class BI.Expander * @class Expander
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()
export class Expander extends Widget { export class Expander extends Widget {
static xtype = "bi.expander"; static xtype = "bi.expander";
@ -60,21 +61,21 @@ export class Expander extends Widget {
}); });
this.expander.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => { this.expander.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
if (this.isEnabled() && this.isValid()) { if (this.isEnabled() && this.isValid()) {
if (type === BI.Events.EXPAND) { if (type === Events.EXPAND) {
this._popupView(); this._popupView();
} }
if (type === BI.Events.COLLAPSE) { if (type === Events.COLLAPSE) {
this._hideView(); this._hideView();
} }
if (type === BI.Events.EXPAND) { if (type === Events.EXPAND) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args); this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.fireEvent(Expander.EVENT_EXPAND); this.fireEvent(Expander.EVENT_EXPAND);
} }
if (type === BI.Events.COLLAPSE) { if (type === Events.COLLAPSE) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args); this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.isViewVisible() && this.fireEvent(Expander.EVENT_COLLAPSE); this.isViewVisible() && this.fireEvent(Expander.EVENT_COLLAPSE);
} }
if (type === BI.Events.CLICK) { if (type === Events.CLICK) {
this.fireEvent(Expander.EVENT_TRIGGER_CHANGE, value, obj); this.fireEvent(Expander.EVENT_TRIGGER_CHANGE, value, obj);
} }
} }
@ -130,7 +131,7 @@ export class Expander extends Widget {
this.expander.isValid() this.expander.isValid()
) { ) {
this._popupView(); this._popupView();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, "", this.expander); this.fireEvent(Controller.EVENT_CHANGE, Events.EXPAND, "", this.expander);
this.fireEvent(Expander.EVENT_EXPAND); this.fireEvent(Expander.EVENT_EXPAND);
} }
}, },
@ -143,7 +144,7 @@ export class Expander extends Widget {
toggle toggle
) { ) {
this._hideView(); this._hideView();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", this.expander); this.fireEvent(Controller.EVENT_CHANGE, Events.COLLAPSE, "", this.expander);
this.fireEvent(Expander.EVENT_COLLAPSE); this.fireEvent(Expander.EVENT_COLLAPSE);
} }
} }
@ -166,7 +167,7 @@ export class Expander extends Widget {
if (this.isExpanded()) { if (this.isExpanded()) {
this.fireEvent( this.fireEvent(
Controller.EVENT_CHANGE, Controller.EVENT_CHANGE,
BI.Events.EXPAND, Events.EXPAND,
"", "",
this.expander this.expander
); );
@ -174,7 +175,7 @@ export class Expander extends Widget {
} else { } else {
this.fireEvent( this.fireEvent(
Controller.EVENT_CHANGE, Controller.EVENT_CHANGE,
BI.Events.COLLAPSE, Events.COLLAPSE,
"", "",
this.expander this.expander
); );
@ -183,7 +184,7 @@ export class Expander extends Widget {
} }
} }
}, },
BI.EVENT_RESPONSE_TIME, EVENT_RESPONSE_TIME,
{ {
leading: true, leading: true,
trailing: false, trailing: false,
@ -223,7 +224,7 @@ export class Expander extends Widget {
); );
this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => { this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
this.fireEvent(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()); // self.setValue(self.getValue());
this.fireEvent(Expander.EVENT_CHANGE, value, obj); this.fireEvent(Expander.EVENT_CHANGE, value, obj);
} }
@ -270,8 +271,8 @@ export class Expander extends Widget {
populate(items) { populate(items) {
// this._assertPopupView(); // this._assertPopupView();
this.popupView && this.popupView.populate.apply(this.popupView, arguments); this.popupView && this.popupView.populate(...arguments);
this.expander.populate && this.expander.populate.apply(this.expander, arguments); this.expander.populate && this.expander.populate(...arguments);
} }
_setEnable(arg) { _setEnable(arg) {

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

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

61
src/base/combination/loader.js

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

19
src/base/combination/navigation.js

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

29
src/base/combination/searcher.js

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

41
src/base/combination/switcher.js

@ -8,7 +8,10 @@ import {
createWidget, createWidget,
each, each,
debounce, debounce,
isNull isNull,
Events,
Direction,
EVENT_RESPONSE_TIME
} from "@/core"; } from "@/core";
import { ButtonGroup } from "./group.button"; import { ButtonGroup } from "./group.button";
import { Maskers } from "@/base/0.base"; import { Maskers } from "@/base/0.base";
@ -18,8 +21,8 @@ import { Maskers } from "@/base/0.base";
* 切换显示或隐藏面板 * 切换显示或隐藏面板
* *
* Created by GUY on 2015/11/2. * Created by GUY on 2015/11/2.
* @class BI.Switcher * @class Switcher
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()
@ -40,7 +43,7 @@ export class Switcher extends Widget {
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
baseCls: "bi-switcher", baseCls: "bi-switcher",
direction: BI.Direction.Top, direction: Direction.Top,
trigger: "click", trigger: "click",
toggle: true, toggle: true,
el: {}, el: {},
@ -61,21 +64,21 @@ export class Switcher extends Widget {
}); });
this.switcher.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => { this.switcher.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
if (this.isEnabled() && this.isValid()) { if (this.isEnabled() && this.isValid()) {
if (type === BI.Events.EXPAND) { if (type === Events.EXPAND) {
this._popupView(); this._popupView();
} }
if (type === BI.Events.COLLAPSE) { if (type === Events.COLLAPSE) {
this._hideView(); this._hideView();
} }
if (type === BI.Events.EXPAND) { if (type === Events.EXPAND) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args); this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.fireEvent(Switcher.EVENT_EXPAND); this.fireEvent(Switcher.EVENT_EXPAND);
} }
if (type === BI.Events.COLLAPSE) { if (type === Events.COLLAPSE) {
this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args); this.fireEvent(Controller.EVENT_CHANGE, type, value, obj, ...args);
this.isViewVisible() && this.fireEvent(Switcher.EVENT_COLLAPSE); this.isViewVisible() && this.fireEvent(Switcher.EVENT_COLLAPSE);
} }
if (type === BI.Events.CLICK) { if (type === Events.CLICK) {
this.fireEvent(Switcher.EVENT_TRIGGER_CHANGE, value, obj); this.fireEvent(Switcher.EVENT_TRIGGER_CHANGE, value, obj);
} }
} }
@ -123,14 +126,14 @@ export class Switcher extends Widget {
e => { e => {
if (this.isEnabled() && this.switcher.isEnabled()) { if (this.isEnabled() && this.switcher.isEnabled()) {
this._popupView(); this._popupView();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.EXPAND, "", this.switcher); this.fireEvent(Controller.EVENT_CHANGE, Events.EXPAND, "", this.switcher);
this.fireEvent(Switcher.EVENT_EXPAND); this.fireEvent(Switcher.EVENT_EXPAND);
} }
}, },
() => { () => {
if (this.isEnabled() && this.switcher.isEnabled() && toggle) { if (this.isEnabled() && this.switcher.isEnabled() && toggle) {
this._hideView(); this._hideView();
this.fireEvent(Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", this.switcher); this.fireEvent(Controller.EVENT_CHANGE, Events.COLLAPSE, "", this.switcher);
this.fireEvent(Switcher.EVENT_COLLAPSE); this.fireEvent(Switcher.EVENT_COLLAPSE);
} }
} }
@ -148,7 +151,7 @@ export class Switcher extends Widget {
if (this.isExpanded()) { if (this.isExpanded()) {
this.fireEvent( this.fireEvent(
Controller.EVENT_CHANGE, Controller.EVENT_CHANGE,
BI.Events.EXPAND, Events.EXPAND,
"", "",
this.switcher this.switcher
); );
@ -156,7 +159,7 @@ export class Switcher extends Widget {
} else { } else {
this.fireEvent( this.fireEvent(
Controller.EVENT_CHANGE, Controller.EVENT_CHANGE,
BI.Events.COLLAPSE, Events.COLLAPSE,
"", "",
this.switcher this.switcher
); );
@ -165,7 +168,7 @@ export class Switcher extends Widget {
} }
} }
}, },
BI.EVENT_RESPONSE_TIME, EVENT_RESPONSE_TIME,
{ {
leading: true, leading: true,
trailing: false, trailing: false,
@ -206,11 +209,11 @@ export class Switcher extends Widget {
); );
this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => { this.popupView.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
this.fireEvent(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); this.fireEvent(Switcher.EVENT_CHANGE, value, obj);
} }
}); });
if (direction !== BI.Direction.Custom && !adapter) { if (direction !== Direction.Custom && !adapter) {
createWidget({ createWidget({
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
scrolly: false, scrolly: false,
@ -250,12 +253,12 @@ export class Switcher extends Widget {
_populate() { _populate() {
this._assertPopupView(); this._assertPopupView();
this.popupView.populate.apply(this.popupView, arguments); this.popupView.populate(...arguments);
} }
populate(items) { populate(items) {
this._populate.apply(this, arguments); this._populate(...arguments);
this.switcher.populate && this.switcher.populate.apply(this.switcher, arguments); this.switcher.populate && this.switcher.populate(...arguments);
} }
_setEnable(arg) { _setEnable(arg) {

11
src/base/combination/tab.js

@ -12,7 +12,8 @@ import {
isFunction, isFunction,
contains, contains,
any, any,
isEqual isEqual,
LogicFactory
} from "@/core"; } from "@/core";
/** /**
@ -58,10 +59,10 @@ export class Tab extends Widget {
{ {
element: this, element: this,
}, },
BI.LogicFactory.createLogic( LogicFactory.createLogic(
BI.LogicFactory.createLogicTypeByDirection(direction), LogicFactory.createLogicTypeByDirection(direction),
extend({}, logic, { 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() { populate() {
const card = this.layout.getShowingCard(); const card = this.layout.getShowingCard();
if (card) { 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 { ButtonGroup } from "./group.button";
import { shortcut, Widget, extend, isArray, each, isFunction, deepContains, concat, any, contains } from "@/core"; import { shortcut, extend, isArray, each, isFunction, deepContains, concat, any, contains } from "@/core";
/**
* Created by GUY on 2015/8/10.
* @class BI.ButtonTree
* @extends BI.ButtonGroup
*/
@shortcut() @shortcut()
export class ButtonTree extends ButtonGroup { 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() @shortcut()
export class Context extends Widget { export class Context extends Widget {
@ -10,7 +10,7 @@ export class Context extends Widget {
const self = this, const self = this,
o = this.options; o = this.options;
if (o.context) { if (o.context) {
this.context = BI.useContext(o.context); this.context = useContext(o.context);
} }
this.widget = createWidget((o.items[0] || o.el)(this.context), { this.widget = createWidget((o.items[0] || o.el)(this.context), {
element: this, element: this,
@ -23,7 +23,7 @@ export class Context extends Widget {
__initWatch() { __initWatch() {
super.__initWatch.call(this); super.__initWatch.call(this);
const o = this.options; const o = this.options;
BI.watch(this.context, o.context, o.watch); watch(this.context, o.context, o.watch);
} }
setValue(v) { setValue(v) {

33
src/base/foundation/message.js

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

15
src/base/grid/grid.js

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

4
src/base/layer/layer.drawer.js

@ -13,8 +13,8 @@ import { Label, IconButton } from "../single";
/** /**
* Popover弹出层 * Popover弹出层
* @class BI.Popover * @class Popover
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()

28
src/base/layer/layer.popover.js

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

45
src/base/layer/layer.popup.js

@ -10,13 +10,18 @@ import {
Controller, Controller,
createWidget, createWidget,
createItems, createItems,
clamp clamp,
Direction,
zIndex_popup,
pixFormat,
LogicFactory,
Events
} from "@/core"; } from "@/core";
/** /**
* 下拉框弹出层, zIndex在1000w * 下拉框弹出层, zIndex在1000w
* @class BI.PopupView * @class PopupView
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()
@ -46,7 +51,7 @@ export class PopupView extends Widget {
innerVgap: 0, innerVgap: 0,
innerHgap: 0, innerHgap: 0,
showArrow: false, showArrow: false,
direction: BI.Direction.Top, // 工具栏的方向 direction: Direction.Top, // 工具栏的方向
stopEvent: false, // 是否停止mousedown、mouseup事件 stopEvent: false, // 是否停止mousedown、mouseup事件
stopPropagation: false, // 是否停止mousedown、mouseup向上冒泡 stopPropagation: false, // 是否停止mousedown、mouseup向上冒泡
logic: { logic: {
@ -97,9 +102,9 @@ export class PopupView extends Widget {
} }
this.element this.element
.css({ .css({
"z-index": BI.zIndex_popup, "z-index": zIndex_popup,
"min-width": BI.pixFormat(minWidth), "min-width": pixFormat(minWidth),
"max-width": BI.pixFormat(maxWidth), "max-width": pixFormat(maxWidth),
}) })
.bind({ click: fn }); .bind({ click: fn });
@ -114,7 +119,7 @@ export class PopupView extends Widget {
this.view.on(Controller.EVENT_CHANGE, (type, ...args) => { this.view.on(Controller.EVENT_CHANGE, (type, ...args) => {
this.fireEvent(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); this.fireEvent(PopupView.EVENT_CHANGE);
} }
}); });
@ -124,8 +129,8 @@ export class PopupView extends Widget {
{ {
element: this, element: this,
}, },
BI.LogicFactory.createLogic( LogicFactory.createLogic(
BI.LogicFactory.createLogicTypeByDirection(direction), LogicFactory.createLogicTypeByDirection(direction),
extend({}, logic, { extend({}, logic, {
scrolly: false, scrolly: false,
lgap, lgap,
@ -134,16 +139,16 @@ export class PopupView extends Widget {
bgap, bgap,
vgap, vgap,
hgap, hgap,
items: BI.LogicFactory.createLogicItemsByDirection( items: LogicFactory.createLogicItemsByDirection(
direction, direction,
extend( extend(
{ {
cls: `list-view-outer bi-card list-view-shadow${primary ? " bi-primary" : ""}`, cls: `list-view-outer bi-card list-view-shadow${primary ? " bi-primary" : ""}`,
}, },
BI.LogicFactory.createLogic( LogicFactory.createLogic(
BI.LogicFactory.createLogicTypeByDirection(direction), LogicFactory.createLogicTypeByDirection(direction),
extend({}, logic, { extend({}, logic, {
items: BI.LogicFactory.createLogicItemsByDirection( items: LogicFactory.createLogicItemsByDirection(
direction, direction,
this.tool, this.tool,
this.tab, this.tab,
@ -202,11 +207,11 @@ export class PopupView extends Widget {
const { el, value, minHeight, innerVgap, innerHgap } = this.options; const { el, value, minHeight, innerVgap, innerHgap } = this.options;
this.button_group = createWidget(el, { type: ButtonGroup.xtype, value }); this.button_group = createWidget(el, { type: ButtonGroup.xtype, value });
this.button_group.element.css({ this.button_group.element.css({
"min-height": BI.pixFormat(minHeight), "min-height": pixFormat(minHeight),
"padding-top": BI.pixFormat(innerVgap), "padding-top": pixFormat(innerVgap),
"padding-bottom": BI.pixFormat(innerVgap), "padding-bottom": pixFormat(innerVgap),
"padding-left": BI.pixFormat(innerHgap), "padding-left": pixFormat(innerHgap),
"padding-right": BI.pixFormat(innerHgap), "padding-right": pixFormat(innerHgap),
}); });
return this.button_group; return this.button_group;
@ -497,7 +502,7 @@ export class PopupView extends Widget {
const resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap; const resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap;
this.view.resetHeight this.view.resetHeight
? this.view.resetHeight(resetHeight) ? this.view.resetHeight(resetHeight)
: this.view.element.css({ "max-height": BI.pixFormat(resetHeight) }); : this.view.element.css({ "max-height": pixFormat(resetHeight) });
} }
setValue(selectedValues) { setValue(selectedValues) {

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

@ -1,13 +1,13 @@
import { ButtonGroup } from "../combination"; 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"; import { Pane } from "../1.pane";
/** /**
* 搜索面板 * 搜索面板
* *
* Created by GUY on 2015/9/28. * Created by GUY on 2015/9/28.
* @class BI.SearcherView * @class SearcherView
* @extends BI.Pane * @extends Pane
*/ */
@shortcut() @shortcut()
@ -20,8 +20,8 @@ export class SearcherView extends Pane {
return extend(conf, { return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-searcher-view bi-card`, baseCls: `${conf.baseCls || ""} bi-searcher-view bi-card`,
tipText: BI.i18nText("BI-No_Select"), tipText: i18nText("BI-No_Select"),
chooseType: BI.Selection.Single, chooseType: Selection.Single,
matcher: { matcher: {
// 完全匹配的构造器 // 完全匹配的构造器
@ -68,7 +68,7 @@ export class SearcherView extends Pane {
}); });
this.matcher.on(Controller.EVENT_CHANGE, (type, val, ob, ...args) => { this.matcher.on(Controller.EVENT_CHANGE, (type, val, ob, ...args) => {
this.fireEvent(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); 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.searcher.on(Controller.EVENT_CHANGE, (type, val, ob, ...args) => {
this.fireEvent(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(BI.SearcherView.EVENT_CHANGE, val, ob); 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. * Created by GUY on 2017/5/23.
* @class BI.ListView * @class ListView
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()
@ -66,7 +66,7 @@ export class ListView extends Widget {
}); });
let lastWidth = this.element.width(), let lastWidth = this.element.width(),
lastHeight = this.element.height(); lastHeight = this.element.height();
BI.ResizeDetector.addResizeListener(this, () => { ResizeDetector.addResizeListener(this, () => {
if (!this.element.is(":visible")) { if (!this.element.is(":visible")) {
return; return;
} }
@ -93,8 +93,8 @@ export class ListView extends Widget {
lastHeight = getElementHeight(); lastHeight = getElementHeight();
while (lastHeight < minContentHeight && index < items.length) { while (lastHeight < minContentHeight && index < items.length) {
const itemsArr = items.slice(index, index + blockSize); const itemsArr = items.slice(index, index + blockSize);
// eslint-disable-next-line no-loop-func
this.container.addItems( this.container.addItems(
// eslint-disable-next-line no-loop-func
itemsArr.map((item, i) => itemFormatter(item, index + i)), itemsArr.map((item, i) => itemFormatter(item, index + i)),
this this
); );
@ -148,7 +148,7 @@ export class ListView extends Widget {
} }
beforeDestroy() { beforeDestroy() {
BI.ResizeDetector.removeResizeListener(this); ResizeDetector.removeResizeListener(this);
this.restore(); 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"; import { VirtualGroup } from "../combination";
/** /**
* 同时用于virtualGroup和virtualList特性的虚拟列表 * 同时用于virtualGroup和virtualList特性的虚拟列表
* *
* Created by GUY on 2017/5/22. * Created by GUY on 2017/5/22.
* @class BI.VirtualList * @class VirtualList
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()
@ -89,7 +89,7 @@ export class VirtualGroupList extends Widget {
this.ticking = true; this.ticking = true;
} }
}); });
BI.ResizeDetector.addResizeListener(this, () => { ResizeDetector.addResizeListener(this, () => {
if (this.element.is(":visible")) { if (this.element.is(":visible")) {
this._calculateBlocksToRender(); this._calculateBlocksToRender();
} }
@ -112,8 +112,8 @@ export class VirtualGroupList extends Widget {
lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight(); lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight();
while (lastHeight < minContentHeight && index < items.length) { while (lastHeight < minContentHeight && index < items.length) {
const itemsArr = items.slice(index, index + blockSize); const itemsArr = items.slice(index, index + blockSize);
// eslint-disable-next-line no-loop-func
this.container[this.renderedIndex === -1 ? "populate" : "addItems"]( this.container[this.renderedIndex === -1 ? "populate" : "addItems"](
// eslint-disable-next-line no-loop-func
itemsArr.map((item, i) => itemFormatter(item, index + i)), itemsArr.map((item, i) => itemFormatter(item, index + i)),
this this
); );
@ -211,7 +211,7 @@ export class VirtualGroupList extends Widget {
} }
beforeDestroy() { beforeDestroy() {
BI.ResizeDetector.removeResizeListener(this); ResizeDetector.removeResizeListener(this);
this.restore(); 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. * Created by GUY on 2017/5/22.
* @class BI.VirtualList * @class VirtualList
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()
@ -68,7 +68,7 @@ export class VirtualList extends Widget {
o.scrollTop = this.element.scrollTop(); o.scrollTop = this.element.scrollTop();
this._calculateBlocksToRender(); this._calculateBlocksToRender();
}); });
BI.ResizeDetector.addResizeListener(this, () => { ResizeDetector.addResizeListener(this, () => {
if (this.element.is(":visible")) { if (this.element.is(":visible")) {
this._calculateBlocksToRender(); this._calculateBlocksToRender();
} }
@ -87,8 +87,8 @@ export class VirtualList extends Widget {
lastHeight = getElementHeight(); lastHeight = getElementHeight();
while (lastHeight < minContentHeight && index < items.length) { while (lastHeight < minContentHeight && index < items.length) {
const itemsArr = items.slice(index, index + blockSize); const itemsArr = items.slice(index, index + blockSize);
// eslint-disable-next-line no-loop-func
this.container.addItems( this.container.addItems(
// eslint-disable-next-line no-loop-func
itemsArr.map((item, i) => itemFormatter(item, index + i)), itemsArr.map((item, i) => itemFormatter(item, index + i)),
this this
); );
@ -220,7 +220,7 @@ export class VirtualList extends Widget {
} }
beforeDestroy() { beforeDestroy() {
BI.ResizeDetector.removeResizeListener(this); ResizeDetector.removeResizeListener(this);
this.restore(); this.restore();
} }
} }

17
src/base/pager/pager.js

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

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

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

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

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

@ -8,11 +8,22 @@ import {
createWidget, createWidget,
Widget, Widget,
isObject, isObject,
Controller Controller,
isIE,
getIEVersion,
nextTick,
isKey,
isNull,
DOM,
debounce,
KeyCode,
EVENT_RESPONSE_TIME,
Events,
Actions
} from "@/core"; } from "@/core";
import { BubbleCombo } from "@/case/combo/bubblecombo/combo.bubble"; import { BubbleCombo } from "@/case/combo/bubblecombo/combo.bubble";
import { Single } from "../0.single"; import { Single } from "../0.single";
import { BubblePopupView } from "@/case/combo/bubblecombo/popup.bubble"; import { BubblePopupView, BubblePopupBarView } from "@/case/combo/bubblecombo/popup.bubble";
/** /**
* guy * guy
@ -32,7 +43,7 @@ export class BasicButton extends Single {
return extend(conf, { return extend(conf, {
_baseCls: `${conf._baseCls || ""} bi-basic-button${conf.invalid ? "" : " cursor-pointer"}${ _baseCls: `${conf._baseCls || ""} bi-basic-button${conf.invalid ? "" : " cursor-pointer"}${
BI.isIE() && BI.getIEVersion() < 10 ? " hack" : "" isIE() && getIEVersion() < 10 ? " hack" : ""
}`, }`,
// el: {} // 可以通过el来创建button元素 // el: {} // 可以通过el来创建button元素
value: "", value: "",
@ -75,7 +86,7 @@ export class BasicButton extends Single {
this.setSelected(true); this.setSelected(true);
} }
// 延迟绑定事件,这样可以将自己绑定的事情优先执行 // 延迟绑定事件,这样可以将自己绑定的事情优先执行
BI.nextTick(() => { nextTick(() => {
!this.isDestroyed() && this.bindEvent(); !this.isDestroyed() && this.bindEvent();
}); });
super._initRef.apply(this, arguments); super._initRef.apply(this, arguments);
@ -167,8 +178,8 @@ export class BasicButton extends Single {
if (this.isOnce() && this.isSelected()) { if (this.isOnce() && this.isSelected()) {
return; return;
} }
if (BI.isKey(o.bubble) || isFunction(o.bubble)) { if (isKey(o.bubble) || isFunction(o.bubble)) {
if (BI.isNull(this.combo)) { if (isNull(this.combo)) {
let popup; let popup;
createWidget({ createWidget({
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
@ -195,7 +206,7 @@ export class BasicButton extends Single {
}, },
listeners: [ listeners: [
{ {
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, eventName: BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action: (...args) => { action: (...args) => {
const [v] = args; const [v] = args;
this.combo.hideView(); this.combo.hideView();
@ -259,7 +270,7 @@ export class BasicButton extends Single {
Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, e => { Widget._renderEngine.createElement(document).bind(`mouseup.${this.getName()}`, e => {
// if (e.button === 0) { // if (e.button === 0) {
if ( if (
BI.DOM.isExist(this) && DOM.isExist(this) &&
!hand.__isMouseInBounds__(e) && !hand.__isMouseInBounds__(e) &&
mouseDown === true && mouseDown === true &&
!selected !selected
@ -285,7 +296,7 @@ export class BasicButton extends Single {
}); });
hand.mouseup(e => { hand.mouseup(e => {
// if (e.button === 0) { // if (e.button === 0) {
if (BI.DOM.isExist(this) && mouseDown === true && selected === true) { if (DOM.isExist(this) && mouseDown === true && selected === true) {
clk(e); clk(e);
} }
mouseDown = false; mouseDown = false;
@ -332,7 +343,7 @@ export class BasicButton extends Single {
o.attributes && o.attributes &&
o.attributes.zIndex >= 0 && o.attributes.zIndex >= 0 &&
hand.keyup(e => { hand.keyup(e => {
if (e.keyCode === BI.KeyCode.ENTER) { if (e.keyCode === KeyCode.ENTER) {
clk(e); clk(e);
} }
}); });
@ -342,7 +353,7 @@ export class BasicButton extends Single {
// 之后的300ms点击无效 // 之后的300ms点击无效
const onClick = o.debounce const onClick = o.debounce
? BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { ? debounce(this._doClick, EVENT_RESPONSE_TIME, {
leading: true, leading: true,
trailing: false, trailing: false,
}) })
@ -373,12 +384,12 @@ export class BasicButton extends Single {
if (this.isValid()) { if (this.isValid()) {
const v = this.getValue(); const v = this.getValue();
o.handler.call(this, v, this, e); 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); this.fireEvent(BasicButton.EVENT_CHANGE, v, this);
if (o.action) { 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 { 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() { triggerCollapse() {
if (this.isOpened()) { if (this.isOpened()) {
this.setOpened(false); 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() { triggerExpand() {
if (!this.isOpened()) { if (!this.isOpened()) {
this.setOpened(true); 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 { 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"; import { BasicButton } from "../button.basic";
/** /**
@ -39,7 +39,7 @@ export class IconButton extends BasicButton {
height: o.iconHeight, height: o.iconHeight,
}); });
if (isNumber(o.height) && o.height > 0 && isNull(o.iconWidth) && isNull(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({ createWidget({
type: DefaultLayout.xtype, type: DefaultLayout.xtype,
element: this, 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 { Label, IconLabel } from "../../label";
import { BasicButton } from "../button.basic"; import { BasicButton } from "../button.basic";
@ -42,7 +42,7 @@ export class Button extends BasicButton {
return { return {
...conf, ...conf,
baseCls: `${conf.baseCls || ""} bi-button${BI.isIE() && BI.isIE9Below() ? " hack" : ""}`, baseCls: `${conf.baseCls || ""} bi-button${isIE() && isIE9Below() ? " hack" : ""}`,
attributes: { attributes: {
tabIndex: 1, tabIndex: 1,
}, },
@ -94,13 +94,13 @@ export class Button extends BasicButton {
// 如果 options 对应的属性为 true 则给元素添加 class // 如果 options 对应的属性为 true 则给元素添加 class
const classArr = ["block", "clear", "ghost", "plain", "loading", "light"]; const classArr = ["block", "clear", "ghost", "plain", "loading", "light"];
classArr.forEach(clz => { classArr.forEach(clz => {
if (BI.get(o, clz) === true) { if (get(o, clz) === true) {
this.element.addClass(clz); this.element.addClass(clz);
} }
}); });
if (o.minWidth > 0) { if (o.minWidth > 0) {
this.element.css({ "min-width": BI.pixFormat(o.minWidth) }); this.element.css({ "min-width": pixFormat(o.minWidth) });
} }
} }
@ -133,7 +133,7 @@ export class Button extends BasicButton {
maxTextWidth -= o.hgap * 2 + o.iconGap; maxTextWidth -= o.hgap * 2 + o.iconGap;
// 减去图标水平占位宽度 // 减去图标水平占位宽度
maxTextWidth -= iconInvisible || isVertical(o.iconPosition) ? 0 : this._const.iconWidth; 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({ this.text = createWidget({
type: Label.xtype, type: Label.xtype,
@ -141,8 +141,8 @@ export class Button extends BasicButton {
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
textAlign: o.textAlign, textAlign: o.textAlign,
textWidth, textWidth,
textHeight: BI.toPix(textHeight, hasBorder ? 2 : 0), textHeight: toPix(textHeight, hasBorder ? 2 : 0),
height: BI.toPix(lineHeight, hasBorder ? 2 : 0), height: toPix(lineHeight, hasBorder ? 2 : 0),
value: o.value, value: o.value,
title: null, title: null,
}); });
@ -160,8 +160,8 @@ export class Button extends BasicButton {
type: IconLabel.xtype, type: IconLabel.xtype,
cls: o.loading ? loadingCls : o.iconCls || o.icon, cls: o.loading ? loadingCls : o.iconCls || o.icon,
width: this._const.iconWidth, width: this._const.iconWidth,
height: BI.toPix(lineHeight, hasBorder ? 2 : 0), height: toPix(lineHeight, hasBorder ? 2 : 0),
lineHeight: BI.toPix(lineHeight, hasBorder ? 2 : 0), lineHeight: toPix(lineHeight, hasBorder ? 2 : 0),
// 不设置,自定义按钮无法居中 // 不设置,自定义按钮无法居中
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight, iconHeight: o.iconHeight,

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

@ -83,7 +83,7 @@ export class BlankIconTextIconItem extends BasicButton {
doClick() { doClick() {
super.doClick(...arguments); super.doClick(...arguments);
if (this.isValid()) { 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 { IconLabel, Label } from "../../label";
import { BasicButton } from "../button.basic"; import { BasicButton } from "../button.basic";
@ -19,7 +19,7 @@ export class IconTextItem extends BasicButton {
return extend(conf, { return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-icon-text-item`, baseCls: `${conf.baseCls || ""} bi-icon-text-item`,
direction: BI.Direction.Left, direction: Direction.Left,
iconWrapperWidth: null, iconWrapperWidth: null,
iconHeight: null, iconHeight: null,
iconWidth: null, iconWidth: null,

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

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

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

@ -12,7 +12,9 @@ import {
isNotEmptyString, isNotEmptyString,
isNotNull, isNotNull,
trim, trim,
isFunction isFunction,
Events,
DOM
} from "@/core"; } from "@/core";
import { Label } from "../label"; import { Label } from "../label";
import { Single } from "../0.single"; import { Single } from "../0.single";
@ -21,8 +23,8 @@ import { Bubbles } from "@/base/0.base";
/** /**
* *
* Created by GUY on 2016/1/18. * Created by GUY on 2016/1/18.
* @class BI.TextAreaEditor * @class TextAreaEditor
* @extends BI.Single * @extends Single
*/ */
@shortcut() @shortcut()
@ -84,10 +86,10 @@ export class TextAreaEditor extends Single {
this.content.element.on("input propertychange", e => { this.content.element.on("input propertychange", e => {
this._checkError(); this._checkError();
this._checkWaterMark(); 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); this.fireEvent(TextAreaEditor.EVENT_CHANGE);
if (isEmptyString(this.getValue())) { 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._focus();
this.fireEvent(TextAreaEditor.EVENT_FOCUS); this.fireEvent(TextAreaEditor.EVENT_FOCUS);
Widget._renderEngine.createElement(document).bind(`mousedown.${this.getName()}`, e => { 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()}`); Widget._renderEngine.createElement(document).unbind(`mousedown.${this.getName()}`);
this.content.element.blur(); this.content.element.blur();
} }
@ -199,7 +201,7 @@ export class TextAreaEditor extends Single {
this.content.element.addClass("textarea-editor-focus"); this.content.element.addClass("textarea-editor-focus");
this._checkWaterMark(); this._checkWaterMark();
if (isEmptyString(this.getValue())) { 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) { _setErrorVisible(b) {
const { errorText, adjustYOffset, adjustXOffset, offsetStyle } = this.options; const { adjustYOffset, adjustXOffset, offsetStyle } = this.options;
if (isFunction(errorText)) { if (isFunction(this.options.errorText)) {
errorText = errorText(trim(this.getValue())); this.options.errorText = this.options.errorText(trim(this.getValue()));
} }
if (!this.disabledError && isKey(errorText)) { if (!this.disabledError && isKey(this.options.errorText)) {
Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, { Bubbles[b ? "show" : "hide"](this.getName(), this.options.errorText, this, {
adjustYOffset, adjustYOffset,
adjustXOffset, adjustXOffset,
offsetStyle, offsetStyle,
@ -224,7 +226,7 @@ export class TextAreaEditor extends Single {
_defaultState() { _defaultState() {
if (isEmptyString(this.getValue())) { 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); this.fireEvent(TextAreaEditor.EVENT_EMPTY);
} }
} }
@ -257,9 +259,9 @@ export class TextAreaEditor extends Single {
extend({}, style, { extend({}, style, {
color: color:
style.color || style.color ||
BI.DOM.getContrastColor( DOM.getContrastColor(
BI.DOM.isRGBColor(style.backgroundColor) DOM.isRGBColor(style.backgroundColor)
? BI.DOM.rgb2hex(style.backgroundColor) ? DOM.rgb2hex(style.backgroundColor)
: 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"; import { Single } from "../0.single";
/** /**
* guy 表示一行数据通过position来定位位置的数据 * guy 表示一行数据通过position来定位位置的数据
* @class BI.Html * @class Html
* @extends BI.Single * @extends Single
*/ */
@shortcut() @shortcut()
@ -47,35 +47,35 @@ export class Html extends Single {
} = this.options; } = this.options;
if (hgap + lgap > 0) { if (hgap + lgap > 0) {
this.element.css({ this.element.css({
"padding-left": BI.pixFormat(hgap + lgap), "padding-left": pixFormat(hgap + lgap),
}); });
} }
if (hgap + rgap > 0) { if (hgap + rgap > 0) {
this.element.css({ this.element.css({
"padding-right": BI.pixFormat(hgap + rgap), "padding-right": pixFormat(hgap + rgap),
}); });
} }
if (vgap + tgap > 0) { if (vgap + tgap > 0) {
this.element.css({ this.element.css({
"padding-top": BI.pixFormat(vgap + tgap), "padding-top": pixFormat(vgap + tgap),
}); });
} }
if (vgap + bgap > 0) { if (vgap + bgap > 0) {
this.element.css({ this.element.css({
"padding-bottom": BI.pixFormat(vgap + bgap), "padding-bottom": pixFormat(vgap + bgap),
}); });
} }
if (isNumber(height)) { if (isNumber(height)) {
this.element.css({ lineHeight: BI.pixFormat(height) }); this.element.css({ lineHeight: pixFormat(height) });
} }
if (isNumber(lineHeight)) { if (isNumber(lineHeight)) {
this.element.css({ lineHeight: BI.pixFormat(lineHeight) }); this.element.css({ lineHeight: pixFormat(lineHeight) });
} }
if (isWidthOrHeight(maxWidth)) { if (isWidthOrHeight(maxWidth)) {
this.element.css({ maxWidth }); this.element.css({ maxWidth });
} }
if (isNumber(maxWidth)) { if (isNumber(maxWidth)) {
this.element.css({ maxWidth: BI.pixFormat(maxWidth) }); this.element.css({ maxWidth: pixFormat(maxWidth) });
} }
this.element.css({ this.element.css({
textAlign, textAlign,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,14 +1,14 @@
import { IconLabel, Label } from "../label"; import { IconLabel, Label } from "../label";
import { IconButton } from "../button"; 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"; import { Tip } from "./0.tip";
/** /**
* toast提示 * toast提示
* *
* Created by GUY on 2015/9/7. * Created by GUY on 2015/9/7.
* @class BI.Toast * @class Toast
* @extends BI.Tip * @extends Tip
*/ */
@shortcut() @shortcut()
@ -41,8 +41,8 @@ export class Toast extends Tip {
const { closable, level, autoClose, textHeight, text, hgap, vgap, innerHgap } = this.options; const { closable, level, autoClose, textHeight, text, hgap, vgap, innerHgap } = this.options;
const { closableMinWidth, minWidth, maxWidth, closableMaxWidth } = this._const; const { closableMinWidth, minWidth, maxWidth, closableMaxWidth } = this._const;
this.element.css({ this.element.css({
minWidth: BI.pixFormat(closable ? closableMinWidth : minWidth), minWidth: pixFormat(closable ? closableMinWidth : minWidth),
maxWidth: BI.pixFormat(closable ? closableMaxWidth : maxWidth), maxWidth: pixFormat(closable ? closableMaxWidth : maxWidth),
}); });
this.element.addClass(`toast-${level}`); this.element.addClass(`toast-${level}`);
function fn(e) { function fn(e) {
@ -118,7 +118,7 @@ export class Toast extends Tip {
return { return {
type: HorizontalLayout.xtype, type: HorizontalLayout.xtype,
horizontalAlign: BI.HorizontalAlign.Stretch, horizontalAlign: HorizontalAlign.Stretch,
items, items,
hgap, hgap,
vgap, 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 { Label } from "../label";
import { Tip } from "./0.tip"; import { Tip } from "./0.tip";
@ -6,8 +6,8 @@ import { Tip } from "./0.tip";
* title提示 * title提示
* *
* Created by GUY on 2015/9/7. * Created by GUY on 2015/9/7.
* @class BI.Tooltip * @class Tooltip
* @extends BI.Tip * @extends Tip
*/ */
@shortcut() @shortcut()
@ -80,7 +80,7 @@ export class Tooltip extends Tip {
} }
setWidth(width) { setWidth(width) {
this.element.width(BI.pixFormat(width - 2 * this._const.hgap)); this.element.width(pixFormat(width - 2 * this._const.hgap));
} }
setText(text) { setText(text) {

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

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

9
src/base/tree/customtree.js

@ -15,7 +15,8 @@ import {
isNotNull, isNotNull,
isNull, isNull,
createWidget, createWidget,
Controller Controller,
Events
} from "@/core"; } from "@/core";
/** /**
@ -23,8 +24,8 @@ import {
* 自定义树 * 自定义树
* *
* Created by GUY on 2015/9/7. * Created by GUY on 2015/9/7.
* @class BI.CustomTree * @class CustomTree
* @extends BI.Single * @extends Single
*/ */
@shortcut() @shortcut()
@ -131,7 +132,7 @@ export class CustomTree extends Widget {
}); });
this.tree.on(Controller.EVENT_CHANGE, (type, val, obj, ...args) => { this.tree.on(Controller.EVENT_CHANGE, (type, val, obj, ...args) => {
this.fireEvent(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); 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 { IconButton } from "@/base";
import { shortcut, extend } from "@/core"; import { shortcut, extend } from "@/core";
/**
* guy
* @extends BI.Single
* @type {*|void|Object}
*/
@shortcut() @shortcut()
export class HalfIconButton extends IconButton { export class HalfIconButton extends IconButton {
static xtype = "bi.half_icon_button"; 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 { CenterAdaptLayout, DefaultLayout, shortcut, extend } from "@/core";
import { BasicButton } from "@/base"; import { BasicButton } from "@/base";
/**
* guy
* @extends BI.Single
* @type {*|void|Object}
*/
@shortcut() @shortcut()
export class HalfButton extends BasicButton { export class HalfButton extends BasicButton {
static xtype = "bi.half_button"; 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"; import { VerticalAdaptLayout, CenterAdaptLayout, shortcut, extend, createWidget } from "@/core";
/** /**
@ -17,7 +17,7 @@ export class MultiSelectItem extends BasicButton {
attributes: { attributes: {
tabIndex: 1, tabIndex: 1,
}, },
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 26, iconWrapperWidth: 26,
}); });
} }
@ -39,7 +39,7 @@ export class MultiSelectItem extends BasicButton {
{ {
el: { el: {
type: Label.xtype, type: Label.xtype,
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
@ -56,13 +56,13 @@ export class MultiSelectItem extends BasicButton {
value: o.value, value: o.value,
py: o.py, py: o.py,
}, },
}, }
], ],
}; };
} }
// _setEnable: function (enable) { // _setEnable: function (enable) {
// BI.MultiSelectItem.superclass._setEnable.apply(this, arguments); // MultiSelectItem.superclass._setEnable.apply(this, arguments);
// if (enable === true) { // if (enable === true) {
// this.element.attr("tabIndex", 1); // this.element.attr("tabIndex", 1);
// } else if (enable === false) { // } else if (enable === false) {

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"; import { shortcut, extend, createWidget, Controller } from "@/core";
/** /**
* Created by GUY on 2016/2/2. * Created by GUY on 2016/2/2.
* *
* @class BI.SingleSelectIconTextItem * @class SingleSelectIconTextItem
* @extends BI.BasicButton * @extends BasicButton
*/ */
@shortcut() @shortcut()
export class SingleSelectIconTextItem extends Single { export class SingleSelectIconTextItem extends Single {
@ -18,7 +18,7 @@ export class SingleSelectIconTextItem extends Single {
tabIndex: 1, tabIndex: 1,
}, },
iconCls: "", 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 { Label, BasicButton } from "@/base";
import { shortcut, extend, createWidget } from "@/core"; import { shortcut, extend, createWidget, SIZE_CONSANTS } from "@/core";
@shortcut() @shortcut()
export class SingleSelectItem extends BasicButton { export class SingleSelectItem extends BasicButton {
@ -13,7 +13,7 @@ export class SingleSelectItem extends BasicButton {
tabIndex: 1, tabIndex: 1,
}, },
textHgap: 10, textHgap: 10,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
textAlign: "left", 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"; import { Radio, Label, BasicButton } from "@/base";
/** /**
@ -17,7 +17,7 @@ export class SingleSelectRadioItem extends BasicButton {
attributes: { attributes: {
tabIndex: 1, tabIndex: 1,
}, },
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 16, iconWrapperWidth: 16,
textHgap: 10, textHgap: 10,
}); });
@ -35,16 +35,16 @@ export class SingleSelectRadioItem extends BasicButton {
items: [ items: [
{ {
type: Radio.xtype, type: Radio.xtype,
ref: (_ref) => { ref: _ref => {
this.radio = _ref; this.radio = _ref;
}, },
}, }
], ],
}, },
{ {
el: { el: {
type: Label.xtype, type: Label.xtype,
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
@ -61,7 +61,7 @@ export class SingleSelectRadioItem extends BasicButton {
value: o.value, value: o.value,
py: o.py, py: o.py,
}, },
}, }
], ],
}; };
} }

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

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

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

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

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

@ -1,5 +1,5 @@
import { IconLabel, NodeButton } from "@/base"; import { IconLabel, NodeButton } from "@/base";
import { shortcut, extend } from "@/core"; import { shortcut, extend, STYLE_CONSTANTS } from "@/core";
@shortcut() @shortcut()
export class TreeNodeSwitcher extends NodeButton { export class TreeNodeSwitcher extends NodeButton {
@ -32,22 +32,22 @@ export class TreeNodeSwitcher extends NodeButton {
const options = this.options; const options = this.options;
if (options.layer === 0 && options.isFirstNode && options.isLastNode) { if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
// 只有一层,并且是第一个节点,并且是最后一个节点 // 只有一层,并且是第一个节点,并且是最后一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" return STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type1", "tree-expand-icon-type1"]; : ["tree-collapse-icon-type1", "tree-expand-icon-type1"];
} else if (options.layer === 0 && options.isFirstNode) { } 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-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type2", "tree-expand-icon-type2"]; : ["tree-collapse-icon-type2", "tree-expand-icon-type2"];
} else if (options.isLastNode) { } 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-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type4", "tree-expand-icon-type4"]; : ["tree-collapse-icon-type4", "tree-expand-icon-type4"];
} else { } 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-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type3", "tree-expand-icon-type3"]; : ["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 { 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"; import { TreeNodeSwitcher } from "@/case";
@shortcut() @shortcut()
@ -39,8 +39,6 @@ export class BasicTreeNode extends NodeButton {
isFirstNode, isFirstNode,
isLastNode, isLastNode,
keyword, keyword,
iconWidth,
iconHeight,
iconWrapperWidth, iconWrapperWidth,
iconCls, iconCls,
switcherIcon, switcherIcon,
@ -82,7 +80,7 @@ export class BasicTreeNode extends NodeButton {
// width: height, // width: height,
// cls: this.getLineCls(), // cls: this.getLineCls(),
// }, // },
// lgap: layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半 // lgap: layer * SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
// width: "", // width: "",
// }; // };
@ -103,7 +101,7 @@ export class BasicTreeNode extends NodeButton {
items: compact([ items: compact([
{ {
el: checkbox, el: checkbox,
lgap: layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半 lgap: layer * SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
width: iconWrapperWidth || height, width: iconWrapperWidth || height,
}, },
icon, 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"; import { TextButton, Label, BasicButton } from "@/base";
/**
* Created by Windy on 2018/2/1.
*/
@shortcut() @shortcut()
export class Switch extends BasicButton { export class Switch extends BasicButton {
static xtype = "bi.switch"; static xtype = "bi.switch";
@ -32,7 +27,7 @@ export class Switch extends BasicButton {
return { return {
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
ref: (_ref) => { ref: _ref => {
this.layout = _ref; this.layout = _ref;
}, },
items: [ items: [
@ -48,26 +43,26 @@ export class Switch extends BasicButton {
}, },
{ {
type: Label.xtype, type: Label.xtype,
text: BI.i18nText("BI-Basic_Simple_Open"), text: i18nText("BI-Basic_Simple_Open"),
cls: "content-tip", cls: "content-tip",
left: 8, left: 8,
top: tgap - 2, top: tgap - 2,
invisible: !(o.showTip && o.selected), invisible: !(o.showTip && o.selected),
ref: (_ref) => { ref: _ref => {
this.openTip = _ref; this.openTip = _ref;
}, },
}, },
{ {
type: Label.xtype, type: Label.xtype,
text: BI.i18nText("BI-Basic_Simple_Close"), text: i18nText("BI-Basic_Simple_Close"),
cls: "content-tip", cls: "content-tip",
right: 8, right: 8,
top: tgap - 2, top: tgap - 2,
invisible: !(o.showTip && !o.selected), invisible: !(o.showTip && !o.selected),
ref: (_ref) => { ref: _ref => {
this.closeTip = _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"; import { Icon, Label, BasicButton } from "@/base";
@shortcut() @shortcut()
@ -31,7 +31,7 @@ export class IconTreeLeafItem extends BasicButton {
type: Icon.xtype, type: Icon.xtype,
width: o.iconWidth, width: o.iconWidth,
height: o.iconHeight, height: o.iconHeight,
}, }
], ],
}); });
@ -47,9 +47,9 @@ export class IconTreeLeafItem extends BasicButton {
py: o.py, py: o.py,
keyword: o.keyword, keyword: o.keyword,
}); });
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = LogicFactory.createLogicTypeByDirection(Direction.Left);
const items = BI.LogicFactory.createLogicItemsByDirection( const items = LogicFactory.createLogicItemsByDirection(
BI.Direction.Left, Direction.Left,
{ {
width: 16, width: 16,
el: icon, el: icon,
@ -63,7 +63,7 @@ export class IconTreeLeafItem extends BasicButton {
{ {
element: this, element: this,
}, },
BI.LogicFactory.createLogic( LogicFactory.createLogic(
type, type,
extend(o.logic, { extend(o.logic, {
items, items,

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

@ -1,11 +1,7 @@
import { IconTreeLeafItem } from "./item.icon.treeleaf"; 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"; import { BasicButton } from "@/base";
/**
* @class BI.MultiLayerIconTreeLeafItem
* @extends BI.BasicButton
*/
@shortcut() @shortcut()
export class MultiLayerIconTreeLeafItem extends BasicButton { export class MultiLayerIconTreeLeafItem extends BasicButton {
static xtype = "bi.multilayer_icon_tree_leaf_item"; static xtype = "bi.multilayer_icon_tree_leaf_item";
@ -42,7 +38,7 @@ export class MultiLayerIconTreeLeafItem extends BasicButton {
}); });
this.item.on(Controller.EVENT_CHANGE, (...args) => { this.item.on(Controller.EVENT_CHANGE, (...args) => {
const [type] = args; const [type] = args;
if (type === BI.Events.CLICK) { if (type === Events.CLICK) {
// 本身实现click功能 // 本身实现click功能
return; 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"; import { NodeButton, Label, IconLabel } from "@/base";
@shortcut() @shortcut()
@ -34,16 +34,11 @@ export class BasicTreeItem extends NodeButton {
textRgap, textRgap,
text, text,
value, value,
isFirstNode,
isLastNode,
py, py,
keyword, keyword,
iconWidth,
iconHeight,
iconCls, iconCls,
} = this.options; } = this.options;
const indent = { const indent = {
el: { el: {
type: Layout.xtype, type: Layout.xtype,
@ -51,7 +46,7 @@ export class BasicTreeItem extends NodeButton {
width: height, width: height,
cls: this.getLineCls(), cls: this.getLineCls(),
}, },
lgap: layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半 lgap: layer * SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
width: "", width: "",
}; };
@ -101,11 +96,11 @@ export class BasicTreeItem extends NodeButton {
if (options.layer === 0 && options.isFirstNode && options.isLastNode) { if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
return ""; return "";
} else if (options.layer === 0 && options.isFirstNode) { } else if (options.layer === 0 && options.isFirstNode) {
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) { } 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 { } 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"; import { TextItem, BasicButton } from "@/base";
/** /**
@ -9,7 +9,7 @@ export class CalendarDateItem extends BasicButton {
props() { props() {
return { return {
baseCls: "bi-calendar-date-item", 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, getShortDayName,
getOffsetDate, getOffsetDate,
isNotEmptyString, isNotEmptyString,
parseInt parseInt,
SIZE_CONSANTS
} from "@/core"; } from "@/core";
import { CalendarDateItem } from "./calendar.date.item"; import { CalendarDateItem } from "./calendar.date.item";
@ -140,7 +141,7 @@ export class Calendar extends Widget {
const items = map(this._getWeekLabel(), (i, value) => { const items = map(this._getWeekLabel(), (i, value) => {
return { return {
type: Label.xtype, type: Label.xtype,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
text: value, text: value,
}; };
}); });
@ -168,7 +169,7 @@ export class Calendar extends Widget {
columns: 7, columns: 7,
rows: 6, rows: 6,
columnSize: [1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7], 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, Controller,
makeArray, makeArray,
map, map,
isNotEmptyString isNotEmptyString,
SIZE_CONSANTS
} from "@/core"; } from "@/core";
/** /**
@ -105,7 +106,7 @@ export class YearCalendar extends Widget {
columns: 2, columns: 2,
rows: 6, rows: 6,
columnSize: [1 / 2, 1 / 2], 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", whiteSpace: "normal",
once: false, once: false,
forceSelected: true, forceSelected: true,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
width: 45, width: 45,
value: td.text, value: td.text,
disabled: td.disabled, disabled: td.disabled,

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

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

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

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

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

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

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

@ -14,7 +14,9 @@ import {
filter, filter,
isArray, isArray,
Cache, Cache,
Queue Queue,
i18nText,
emptyFn
} from "@/core"; } from "@/core";
import { Label, Combo, TextItem } from "@/base"; import { Label, Combo, TextItem } from "@/base";
import { PopupPanel } from "../layer"; import { PopupPanel } from "../layer";
@ -37,7 +39,7 @@ export class HexColorChooserPopup extends Widget {
props = { props = {
baseCls: "bi-color-chooser-popup", baseCls: "bi-color-chooser-popup",
width: 300, width: 300,
recommendColorsGetter: BI.emptyFn, // 推荐色获取接口 recommendColorsGetter: emptyFn, // 推荐色获取接口
simple: false, // 简单模式, popup中没有自动和透明 simple: false, // 简单模式, popup中没有自动和透明
}; };
@ -108,7 +110,7 @@ export class HexColorChooserPopup extends Widget {
items: [ items: [
{ {
type: Label.xtype, type: Label.xtype,
text: BI.i18nText("BI-Basic_Recommend_Color"), text: i18nText("BI-Basic_Recommend_Color"),
textAlign: "left", textAlign: "left",
height: 24, height: 24,
}, },
@ -195,12 +197,12 @@ export class HexColorChooserPopup extends Widget {
textAlign: "center", textAlign: "center",
height: 24, height: 24,
textLgap: 10, textLgap: 10,
text: `${BI.i18nText("BI-Basic_More")}...`, text: `${i18nText("BI-Basic_More")}...`,
}, },
popup: { popup: {
type: PopupPanel.xtype, type: PopupPanel.xtype,
buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")], buttons: [i18nText("BI-Basic_Cancel"), i18nText("BI-Basic_Save")],
title: BI.i18nText("BI-Custom_Color"), title: i18nText("BI-Custom_Color"),
el: { el: {
type: CustomColorChooser.xtype, type: CustomColorChooser.xtype,
value: o.value, value: o.value,
@ -216,7 +218,7 @@ export class HexColorChooserPopup extends Widget {
minWidth: 227, minWidth: 227,
listeners: [ listeners: [
{ {
eventName: BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON, eventName: PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON,
action: (index, ...args) => { action: (index, ...args) => {
switch (index) { switch (index) {
case 0: case 0:

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

@ -17,7 +17,8 @@ import {
count, count,
filter, filter,
isNotEmptyString, isNotEmptyString,
isArray isArray,
i18nText
} from "@/core"; } from "@/core";
import { ColorPickerEditor, ColorPicker } from "./colorpicker"; import { ColorPickerEditor, ColorPicker } from "./colorpicker";
@ -91,8 +92,8 @@ export class ColorChooserPopup extends Widget {
const panel = createWidget({ const panel = createWidget({
type: PopupPanel.xtype, type: PopupPanel.xtype,
buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")], buttons: [i18nText("BI-Basic_Cancel"), i18nText("BI-Basic_Save")],
title: BI.i18nText("BI-Custom_Color"), title: i18nText("BI-Custom_Color"),
el: this.customColorChooser, el: this.customColorChooser,
stopPropagation: false, stopPropagation: false,
bgap: -1, bgap: -1,
@ -113,7 +114,7 @@ export class ColorChooserPopup extends Widget {
textAlign: "center", textAlign: "center",
height: 24, height: 24,
textLgap: 10, textLgap: 10,
text: `${BI.i18nText("BI-Basic_More")}...`, text: `${i18nText("BI-Basic_More")}...`,
}, },
popup: panel, popup: panel,
}); });
@ -121,7 +122,7 @@ export class ColorChooserPopup extends Widget {
this.more.on(Combo.EVENT_AFTER_POPUPVIEW, () => { this.more.on(Combo.EVENT_AFTER_POPUPVIEW, () => {
this.customColorChooser.setValue(this.getValue()); 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) { switch (index) {
case 0: case 0:
this.more.hideView(); this.more.hideView();
@ -154,7 +155,7 @@ export class ColorChooserPopup extends Widget {
left: 10, left: 10,
right: 10, right: 10,
top: 5, top: 5,
}, }
], ],
}, },
height: 29, height: 29,
@ -169,7 +170,7 @@ export class ColorChooserPopup extends Widget {
right: 10, right: 10,
top: 5, top: 5,
bottom: 5, bottom: 5,
}, }
], ],
}, },
height: 60, height: 60,
@ -177,7 +178,7 @@ export class ColorChooserPopup extends Widget {
{ {
el: this.more, el: this.more,
height: 24, height: 24,
}, }
], ],
}, },
left: 0, left: 0,
@ -198,7 +199,7 @@ export class ColorChooserPopup extends Widget {
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}, }
], ],
}; };
} }
@ -234,7 +235,7 @@ export class ColorChooserPopup extends Widget {
value: color, value: color,
}; };
}); });
count(colors.length, 8, (i) => { count(colors.length, 8, i => {
items.push({ items.push({
value: "", value: "",
disabled: true, 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"; import { IconButton, Trigger } from "@/base";
/** /**
@ -29,7 +29,7 @@ export class ColorChooserTrigger extends Trigger {
super._init(...arguments); super._init(...arguments);
this.colorContainer = createWidget({ this.colorContainer = createWidget({
type: Layout.xtype, type: Layout.xtype,
cls: `color-chooser-trigger-content${BI.isIE9Below && BI.isIE9Below() ? " hack" : ""}`, cls: `color-chooser-trigger-content${isIE9Below && isIE9Below() ? " hack" : ""}`,
}); });
const down = createWidget({ 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 { IconChangeButton } from "../button";
import { Label, IconButton, Trigger } from "@/base"; import { Label, IconButton, Trigger } from "@/base";
@ -52,7 +52,7 @@ export class LongColorChooserTrigger extends Trigger {
textAlign: "left", textAlign: "left",
hgap: 5, hgap: 5,
height: 18, 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.changeIcon.setVisible(true);
this.label.setVisible(true); this.label.setVisible(true);
this.changeIcon.setIcon("auto-color-icon"); 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") { } else if (color === "transparent") {
this.colorContainer.element.css("background-color", ""); this.colorContainer.element.css("background-color", "");
this.changeIcon.setVisible(true); this.changeIcon.setVisible(true);
this.label.setVisible(true); this.label.setVisible(true);
this.changeIcon.setIcon("trans-color-icon"); this.changeIcon.setIcon("trans-color-icon");
this.label.setText(BI.i18nText("BI-Transparent_Color")); this.label.setText(i18nText("BI-Transparent_Color"));
} else { } else {
this.colorContainer.element.css({ "background-color": color }); this.colorContainer.element.css({ "background-color": color });
this.changeIcon.setVisible(false); this.changeIcon.setVisible(false);

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

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

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

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

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

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

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

@ -11,10 +11,12 @@ import {
createWidgets, createWidgets,
each, each,
isEmptyString, isEmptyString,
DOM DOM,
i18nText
} from "@/core"; } from "@/core";
import { Label } from "@/base"; import { Label } from "@/base";
import { SmallTextEditor } from "@/widget/editor/editor.text.small.js"; import { SmallTextEditor } from "@/widget/editor/editor.text.small.js";
import { TextEditor } from "@/widget/editor/editor.text";
const RGB_WIDTH = 32; 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([{}, {}, {}], { const Ws = createWidgets([{}, {}, {}], {
type: SmallTextEditor.xtype, type: SmallTextEditor.xtype,
cls: "color-picker-editor-input bi-border-radius", cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker, validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true, allowBlank: true,
value: 255, value: 255,
width: RGB_WIDTH, width: RGB_WIDTH,
height: 20, height: 20,
}); });
each(Ws, (i, w) => { each(Ws, (i, w) => {
w.on(BI.TextEditor.EVENT_CHANGE, () => { w.on(TextEditor.EVENT_CHANGE, () => {
this._checkEditors(); this._checkEditors();
if (this.R.isValid() && this.G.isValid() && this.B.isValid()) { if (this.R.isValid() && this.G.isValid() && this.B.isValid()) {
this.colorShow.element.css("background-color", this.getValue()); this.colorShow.element.css("background-color", this.getValue());
@ -113,7 +115,7 @@ export class SimpleColorPickerEditor extends Widget {
{ {
el: this.B, el: this.B,
width: RGB_WIDTH, 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 { PopupView } from "@/base/layer/layer.popup";
import { Label } from "@/base/single/label/label"; import { Label } from "@/base/single/label/label";
@shortcut() @shortcut()
export class BubblePopupView extends PopupView { 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_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON";
static EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON"; static EVENT_CHANGE = "EVENT_CLICK_TOOLBAR_BUTTON";
@ -26,7 +26,7 @@ export class BubblePopupView extends PopupView {
text: o.text, text: o.text,
whiteSpace: "normal", whiteSpace: "normal",
textAlign: "left", textAlign: "left",
ref: (_ref) => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
}; };
@ -36,3 +36,112 @@ export class BubblePopupView extends PopupView {
this.text.setText(v || this.options.text); 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 { SearchTextValueComboPopup } from "./popup.searchtextvalue";
import { ButtonGroup, Trigger, Searcher, IconButton } from "@/base"; import { ButtonGroup, Trigger, Searcher, IconButton } from "@/base";
import { TriggerIconButton } from "../../button"; import { TriggerIconButton } from "../../button";
@ -69,7 +69,7 @@ export class SearchTextValueTrigger extends Trigger {
}, },
onSearch(obj, callback) { onSearch(obj, callback) {
const keyword = obj.keyword; const keyword = obj.keyword;
const finding = BI.Func.getSearchResult(o.items, keyword); const finding = Func.getSearchResult(o.items, keyword);
const matched = finding.match, const matched = finding.match,
find = finding.find; find = finding.find;
callback(matched, find); callback(matched, find);

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

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

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

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

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

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

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

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

4
src/case/pager/pager.detail.js

@ -20,8 +20,8 @@ import { Label, ButtonGroup } from "@/base";
* 分页控件 * 分页控件
* *
* Created by GUY on 2015/8/31. * Created by GUY on 2015/8/31.
* @class BI.DetailPager * @class DetailPager
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()

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"; import { Label, Pager, IconButton } from "@/base";
/** /**
* 显示页码的分页控件 * 显示页码的分页控件
* *
* Created by GUY on 2016/6/30. * Created by GUY on 2016/6/30.
* @class BI.DirectionPager * @class DirectionPager
* @extends BI.Widget * @extends Widget
*/ */
@shortcut() @shortcut()
@ -103,8 +103,8 @@ export class DirectionPager extends Widget {
prev: { prev: {
type: IconButton.xtype, type: IconButton.xtype,
value: "prev", value: "prev",
title: BI.i18nText("BI-Up_Page"), title: i18nText("BI-Up_Page"),
warningTitle: BI.i18nText("BI-Current_Is_First_Page"), warningTitle: i18nText("BI-Current_Is_First_Page"),
height: 22, height: 22,
width: 22, width: 22,
cls: "bi-border bi-border-radius direction-pager-prev column-pre-page-h-font bi-list-item-select2", 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: { next: {
type: IconButton.xtype, type: IconButton.xtype,
value: "next", value: "next",
title: BI.i18nText("BI-Down_Page"), title: i18nText("BI-Down_Page"),
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), warningTitle: i18nText("BI-Current_Is_Last_Page"),
height: 22, height: 22,
width: 22, width: 22,
cls: "bi-border bi-border-radius direction-pager-next column-next-page-h-font bi-list-item-select2", 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: { prev: {
type: IconButton.xtype, type: IconButton.xtype,
value: "prev", value: "prev",
title: BI.i18nText("BI-Left_Page"), title: i18nText("BI-Left_Page"),
warningTitle: BI.i18nText("BI-Current_Is_First_Page"), warningTitle: i18nText("BI-Current_Is_First_Page"),
height: 22, height: 22,
width: 22, width: 22,
cls: "bi-border bi-border-radius direction-pager-prev row-pre-page-h-font bi-list-item-select2", 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: { next: {
type: IconButton.xtype, type: IconButton.xtype,
value: "next", value: "next",
title: BI.i18nText("BI-Right_Page"), title: i18nText("BI-Right_Page"),
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), warningTitle: i18nText("BI-Current_Is_Last_Page"),
height: 22, height: 22,
width: 22, width: 22,
cls: "bi-border bi-border-radius direction-pager-next row-next-page-h-font bi-list-item-select2", 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, createWidget,
VerticalLayout, VerticalLayout,
Controller, Controller,
Events Events,
SIZE_CONSANTS
} from "@/core"; } from "@/core";
import { ButtonTree, CustomTree } from "@/base"; import { ButtonTree, CustomTree } from "@/base";
import { TreeExpander } from "./treeexpander/tree.expander"; import { TreeExpander } from "./treeexpander/tree.expander";
@ -45,7 +46,7 @@ export class LevelTree extends Widget {
each(nodes, (i, node) => { each(nodes, (i, node) => {
const extend = { const extend = {
layer, layer,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: SIZE_CONSANTS.LIST_ITEM_HEIGHT,
isFirstNode: i === 0, isFirstNode: i === 0,
isLastNode: i === nodes.length - 1, 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() @shortcut()
export class TreeExpanderPopup extends Widget { export class TreeExpanderPopup extends Widget {
@ -17,7 +17,7 @@ export class TreeExpanderPopup extends Widget {
render() { render() {
const self = this; const self = this;
const { el, value, layer, showLine, isLastNode } = this.options; 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( this.popupView = createWidget(
{ {
@ -38,7 +38,7 @@ export class TreeExpanderPopup extends Widget {
return { return {
type: VerticalLayout.xtype, 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, scrolly: null,
items: [this.popupView], items: [this.popupView],
}; };

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

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

4
src/case/ztree/parttree.js

@ -5,8 +5,8 @@ import { TreeView } from "./treeview";
/** /**
* guy * guy
* 局部树两个请求树 第一个请求构造树第二个请求获取节点 * 局部树两个请求树 第一个请求构造树第二个请求获取节点
* @class BI.PartTree * @class PartTree
* @extends BI.AsyncTree * @extends AsyncTree
*/ */
@shortcut() @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"; import { TreeView } from "./treeview";
/** /**
* guy * guy
* 异步树 * 异步树
* @class BI.DisplayTree * @class DisplayTree
* @extends BI.TreeView * @extends TreeView
*/ */
@shortcut() @shortcut()
@ -50,11 +50,11 @@ export class DisplayTree extends TreeView {
_dealWidthNodes(nodes) { _dealWidthNodes(nodes) {
nodes = super._dealWidthNodes(...arguments); nodes = super._dealWidthNodes(...arguments);
BI.each(nodes, (i, node) => { each(nodes, (i, node) => {
node.isParent = node.isParent || node.parent; node.isParent = node.isParent || node.parent;
if (node.text == null) { if (node.text == null) {
if (node.count > 0) { 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" "BI-Basic_Count"
)})`; )})`;
} }

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

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

8
src/case/ztree/treeview.js

@ -21,7 +21,9 @@ import {
VerticalLayout, VerticalLayout,
Layout, Layout,
DefaultLayout, DefaultLayout,
some some,
Widget,
STYLE_CONSTANTS
} from "@/core"; } from "@/core";
import { Msg, Pane, LoadingBar, Text } from "@/base"; import { Msg, Pane, LoadingBar, Text } from "@/base";
@ -81,7 +83,7 @@ export class TreeView extends Pane {
this.tree = createWidget({ this.tree = createWidget({
type: Layout.xtype, type: Layout.xtype,
element: `<ul id='${this.id}' class='ztree${ element: `<ul id='${this.id}' class='ztree${
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? " solid'" : "'" STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? " solid'" : "'"
}></ul>`, }></ul>`,
}); });
createWidget({ 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]); fragment.append(text.element[0]);
newNode.text = fragment.html(); 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 { isFunction, isArray, each, extend, isPlainObject, isNull, uniqueId, isWidget, isWidthOrHeight, isKey, remove, any, isNotNull } from "./2.base";
import { OB } from "./3.ob"; import { OB } from "./3.ob";
import { Providers, _lazyCreateWidget } from "./5.inject"; import { Providers, _lazyCreateWidget } from "./5.inject";
import { DOM } from "./utils";
import { Events, emptyFn, pixFormat } from "./constant";
import { Plugin } from "./6.plugin";
const cancelAnimationFrame = const cancelAnimationFrame =
_global.cancelAnimationFrame || _global.cancelAnimationFrame ||
@ -186,7 +189,7 @@ export class Widget extends OB {
callLifeHook(this, "beforeMount"); callLifeHook(this, "beforeMount");
this._mount(); this._mount();
callLifeHook(this, "mounted"); callLifeHook(this, "mounted");
this.fireEvent(BI.Events.MOUNT); this.fireEvent(Events.MOUNT);
} else { } else {
this._mount(); this._mount();
} }
@ -251,7 +254,7 @@ export class Widget extends OB {
this._watchers = this._watchers || []; this._watchers = this._watchers || [];
const watcher = new Fix.Watcher(null, () => getter.call(this, this), (handler && (v => { const watcher = new Fix.Watcher(null, () => getter.call(this, this), (handler && (v => {
handler.call(this, this, v); handler.call(this, this, v);
})) || BI.emptyFn, extend({ deep: true }, options)); })) || emptyFn, extend({ deep: true }, options));
this._watchers.push(() => { this._watchers.push(() => {
watcher.teardown(); watcher.teardown();
}); });
@ -291,14 +294,14 @@ export class Widget extends OB {
_initElementWidth() { _initElementWidth() {
const o = this.options; const o = this.options;
if (isWidthOrHeight(o.width)) { if (isWidthOrHeight(o.width)) {
this.element.css("width", BI.pixFormat(o.width)); this.element.css("width", pixFormat(o.width));
} }
} }
_initElementHeight() { _initElementHeight() {
const o = this.options; const o = this.options;
if (isWidthOrHeight(o.height)) { 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); const render = isFunction(this.options.render) ? this.options.render : (workerMode ? (this.$render || this.render) : this.render);
let els = render && render.call(this); let els = render && render.call(this);
els = this.options.configRender ? this.options.configRender.call(this, els) : els; 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)) { if (isPlainObject(els)) {
els = [els]; els = [els];
} }
@ -436,7 +439,7 @@ export class Widget extends OB {
if (lifeHook !== false && !this.__async) { if (lifeHook !== false && !this.__async) {
callLifeHook(this, "_mounted"); callLifeHook(this, "_mounted");
callLifeHook(this, "mounted"); callLifeHook(this, "mounted");
this.fireEvent(BI.Events.MOUNT); this.fireEvent(Events.MOUNT);
} }
predicate && predicate(this); predicate && predicate(this);
} }
@ -569,7 +572,7 @@ export class Widget extends OB {
setVisible(visible) { setVisible(visible) {
this._innerSetVisible(visible); this._innerSetVisible(visible);
this.fireEvent(BI.Events.VIEW, visible); this.fireEvent(Events.VIEW, visible);
} }
setValid(valid) { setValid(valid) {
@ -613,7 +616,7 @@ export class Widget extends OB {
throw new Error("组件:组件名已存在,不能进行添加"); throw new Error("组件:组件名已存在,不能进行添加");
} }
widget._setParent && widget._setParent(this); widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () { widget.on(Events.DESTROY, function () {
// TODO: self待删 // TODO: self待删
remove(self._children, this); remove(self._children, this);
}); });
@ -760,7 +763,7 @@ export class Widget extends OB {
_unMount() { _unMount() {
this._assetMounted(); this._assetMounted();
this.__destroy(); this.__destroy();
this.fireEvent(BI.Events.UNMOUNT); this.fireEvent(Events.UNMOUNT);
this.purgeListeners(); this.purgeListeners();
} }
@ -785,7 +788,7 @@ export class Widget extends OB {
if (this._parent) { if (this._parent) {
this._parent.removeWidget(this); this._parent.removeWidget(this);
} }
BI.DOM.hang([this]); DOM.hang([this]);
} }
empty () { empty () {
@ -800,7 +803,7 @@ export class Widget extends OB {
} }
// if (this.options.vdom) { // if (this.options.vdom) {
// const vnode = this._renderVNode(); // const vnode = this._renderVNode();
// BI.patchVNode(this.vnode, vnode); // patchVNode(this.vnode, vnode);
// this.vnode = vnode; // this.vnode = vnode;
// return; // return;
// } // }
@ -841,8 +844,8 @@ export class Widget extends OB {
} else { } else {
this.element.destroy(); this.element.destroy();
} }
this.fireEvent(BI.Events.UNMOUNT); this.fireEvent(Events.UNMOUNT);
this.fireEvent(BI.Events.DESTROY); this.fireEvent(Events.DESTROY);
this._purgeRef(); this._purgeRef();
this.purgeListeners(); this.purgeListeners();
} }
@ -1082,7 +1085,7 @@ export function mount(widget, container, predicate, hydrate) {
}); });
// 将新的dom树属性(事件等)patch到已存在的dom上 // 将新的dom树属性(事件等)patch到已存在的dom上
const c = Widget._renderEngine.createElement; 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 => { const triggerLifeHook = w => {
w.beforeMount && w.beforeMount(); 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 { isFunction, isNull, isNotNull, isArray, each, isWidget, extend, init, isEmpty, remove } from "./2.base";
import { OB } from "./3.ob"; import { OB } from "./3.ob";
import { Widget } from "./4.widget"; import { Widget } from "./4.widget";
import { Plugin } from "./6.plugin";
import { aspect } from "./structure";
import { Events } from "./constant";
const moduleInjection = {}, moduleInjectionMap = { const moduleInjection = {}, moduleInjectionMap = {
components: {}, components: {},
@ -158,7 +161,7 @@ const runConfigFunction = (type, configFn) => {
fn(providers[type]); fn(providers[type]);
continue; 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) { export function getReference(type, fn) {
return BI.Plugin.registerObject(type, fn); return Plugin.registerObject(type, fn);
} }
const actions = {}; const actions = {};
@ -268,7 +271,7 @@ function callPoint(inst, types) {
for (const action in points[type]) { for (const action in points[type]) {
const bfns = points[type][action].before; const bfns = points[type][action].before;
if (bfns) { if (bfns) {
BI.aspect.before(inst, action, (function (bfns) { aspect.before(inst, action, (function (bfns) {
return function () { return function () {
for (let i = 0, len = bfns.length; i < len; i++) { for (let i = 0, len = bfns.length; i < len; i++) {
try { try {
@ -282,7 +285,7 @@ function callPoint(inst, types) {
} }
const afns = points[type][action].after; const afns = points[type][action].after;
if (afns) { if (afns) {
BI.aspect.after(inst, action, (function (afns) { aspect.after(inst, action, (function (afns) {
return function () { return function () {
for (let i = 0, len = afns.length; i < len; i++) { for (let i = 0, len = afns.length; i < len; i++) {
try { try {
@ -462,23 +465,23 @@ export function createWidget(item, options, context, lazy) {
return item; return item;
} }
if (el) { if (el) {
w = BI.Plugin.getWidget(elType, el); w = Plugin.getWidget(elType, el);
const wType = (w.type && w.type.xtype) || w.type; const wType = (w.type && w.type.xtype) || w.type;
if (wType === elType) { if (wType === elType) {
if (BI.Plugin.hasObject(elType)) { if (Plugin.hasObject(elType)) {
if (!w.listeners || isArray(w.listeners)) { if (!w.listeners || isArray(w.listeners)) {
w.listeners = (w.listeners || []).concat([{ w.listeners = (w.listeners || []).concat([{
eventName: BI.Events.MOUNT, eventName: Events.MOUNT,
action: () => { action: () => {
BI.Plugin.getObject(elType, this); Plugin.getObject(elType, this);
}, },
}]); }]);
} else { } 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