Browse Source

Merge pull request #138008 in DEC/fineui from master to feature/x

* commit 'd8ad79eef254581e7496eb1db99b0910643e1204':
  KERNEL-12408 chore: base中eslint修改
  KERNEL-12408 chore: base/layer中eslint修改
  KERNEL-12408 chore: base/combination中eslint修改
  chore:base中eslint修改
master
superman 2 years ago
parent
commit
f4d8369a5a
  1. 3
      .eslintrc
  2. 1
      src/base/collection/__test__/collection.test.js
  3. 28
      src/base/collection/collection.js
  4. 14
      src/base/combination/bubble.js
  5. 8
      src/base/combination/combo.js
  6. 6
      src/base/combination/expander.js
  7. 22
      src/base/combination/group.button.js
  8. 7
      src/base/combination/group.virtual.js
  9. 4
      src/base/combination/loader.js
  10. 3
      src/base/combination/navigation.js
  11. 12
      src/base/combination/searcher.js
  12. 2
      src/base/combination/switcher.js
  13. 2
      src/base/combination/tab.js
  14. 25
      src/base/combination/tree.button.js
  15. 2
      src/base/foundation/__test__/message.test.js
  16. 10
      src/base/foundation/message.js
  17. 1
      src/base/grid/__test__/grid.test.js
  18. 4
      src/base/grid/grid.js
  19. 1
      src/base/layer/__test__/layer.popover.test.js
  20. 7
      src/base/layer/layer.drawer.js
  21. 3
      src/base/layer/layer.popover.js
  22. 44
      src/base/layer/layer.popup.js
  23. 1
      src/base/layer/layer.searcher.js
  24. 10
      src/base/list/listview.js
  25. 1
      src/base/list/virtualgrouplist.js
  26. 6
      src/base/list/virtuallist.js
  27. 2
      src/base/tree/customtree.js

3
.eslintrc

@ -2,7 +2,8 @@
"env": { "env": {
"browser": true, "browser": true,
"node": true, "node": true,
"es6": true "es6": true,
"jest": true
}, },
"globals": { "globals": {
"window": true, "window": true,

1
src/base/collection/__test__/collection.test.js

@ -5,7 +5,6 @@
*/ */
describe("CollectionTest", function () { describe("CollectionTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */

28
src/base/collection/collection.js

@ -58,7 +58,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (o.overflowY === false) { if (o.overflowY === false) {
scrollable = false; scrollable = false;
} else { } else {
scrollable = "y" scrollable = "y";
} }
} else { } else {
if (o.overflowY === false) { if (o.overflowY === false) {
@ -101,10 +101,10 @@ BI.CollectionView = BI.inherit(BI.Widget, {
for (var index = 0, len = o.items.length; index < len; index++) { for (var index = 0, len = o.items.length; index < len; index++) {
var cellMetadatum = o.cellSizeAndPositionGetter(index); var cellMetadatum = o.cellSizeAndPositionGetter(index);
if (cellMetadatum.height == null || isNaN(cellMetadatum.height) || if (BI.isNull(cellMetadatum.height) || isNaN(cellMetadatum.height) ||
cellMetadatum.width == null || isNaN(cellMetadatum.width) || BI.isNull(cellMetadatum.width) || isNaN(cellMetadatum.width) ||
cellMetadatum.x == null || isNaN(cellMetadatum.x) || BI.isNull(cellMetadatum.x) || isNaN(cellMetadatum.x) ||
cellMetadatum.y == null || isNaN(cellMetadatum.y)) { BI.isNull(cellMetadatum.y) || isNaN(cellMetadatum.y)) {
throw Error(); throw Error();
} }
@ -124,16 +124,18 @@ BI.CollectionView = BI.inherit(BI.Widget, {
_cellRenderers: function (height, width, x, y) { _cellRenderers: function (height, width, x, y) {
this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y); this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y);
return this._cellGroupRenderer(); return this._cellGroupRenderer();
}, },
_cellGroupRenderer: function () { _cellGroupRenderer: function () {
var self = this, o = this.options; var self = this;
var rendered = []; var rendered = [];
BI.each(this._lastRenderedCellIndices, function (i, index) { BI.each(this._lastRenderedCellIndices, function (i, index) {
var cellMetadata = self._sectionManager.getCellMetadata(index); var cellMetadata = self._sectionManager.getCellMetadata(index);
rendered.push(cellMetadata); rendered.push(cellMetadata);
}); });
return rendered; return rendered;
}, },
@ -167,16 +169,16 @@ BI.CollectionView = BI.inherit(BI.Widget, {
var topMap = BI.invert(tops); var topMap = BI.invert(tops);
// 存储上下左右四个边界 // 存储上下左右四个边界
var leftBorder = {}, rightBorder = {}, topBorder = {}, bottomBorder = {}; var leftBorder = {}, rightBorder = {}, topBorder = {}, bottomBorder = {};
var assertMinBorder = function (border, offset) { function assertMinBorder(border, offset) {
if (border[offset] == null) { if (BI.isNull(border[offset])) {
border[offset] = Number.MAX_VALUE; border[offset] = Number.MAX_VALUE;
} }
}; }
var assertMaxBorder = function (border, offset) { function assertMaxBorder(border, offset) {
if (border[offset] == null) { if (BI.isNull(border[offset])) {
border[offset] = 0; border[offset] = 0;
} }
}; }
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
var datum = childrenToDisplay[i]; var datum = childrenToDisplay[i];
var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1]; var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1];
@ -213,7 +215,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
left: datum.x, left: datum.x,
top: datum.y, top: datum.y,
_left: datum.x, _left: datum.x,
_top: datum.y, _top: datum.y
// _width: datum.width, // _width: datum.width,
// _height: datum.height // _height: datum.height
}); });

14
src/base/combination/bubble.js

@ -6,6 +6,7 @@
BI.Bubble = BI.inherit(BI.Widget, { BI.Bubble = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Bubble.superclass._defaultConfig.apply(this, arguments); var conf = BI.Bubble.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-popper", baseCls: (conf.baseCls || "") + " bi-popper",
attributes: { attributes: {
@ -36,7 +37,7 @@
el: {}, el: {},
popup: {}, popup: {},
comboClass: "bi-combo-popup", comboClass: "bi-combo-popup",
hoverClass: "bi-combo-hover", hoverClass: "bi-combo-hover"
}); });
}, },
@ -104,14 +105,14 @@
_initPullDownAction: function () { _initPullDownAction: function () {
var self = this, o = this.options; var self = this, o = this.options;
var evs = (this.options.trigger || "").split(","); var evs = (this.options.trigger || "").split(",");
var st = function (e) { function st (e) {
if (o.stopEvent) { if (o.stopEvent) {
e.stopEvent(); e.stopEvent();
} }
if (o.stopPropagation) { if (o.stopPropagation) {
e.stopPropagation(); e.stopPropagation();
} }
}; }
var enterPopup = false; var enterPopup = false;
@ -217,6 +218,8 @@
} }
}); });
break; break;
default:
break;
} }
}); });
}, },
@ -229,7 +232,7 @@
_assertPopupView: function () { _assertPopupView: function () {
var self = this, o = this.options; var self = this, o = this.options;
if (this.popupView == null) { if (BI.isNull(this.popupView)) {
this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, { this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, {
type: "bi.bubble_popup_view", type: "bi.bubble_popup_view",
showArrow: o.showArrow, showArrow: o.showArrow,
@ -286,6 +289,7 @@
return; return;
} }
this._hideView(e); this._hideView(e);
return true; return true;
}, },
@ -319,7 +323,7 @@
}, },
_popupView: function (e) { _popupView: function (e) {
var self = this, o = this.options; var o = this.options;
this._assertPopupViewRender(); this._assertPopupViewRender();
this.fireEvent(BI.Bubble.EVENT_BEFORE_POPUPVIEW); this.fireEvent(BI.Bubble.EVENT_BEFORE_POPUPVIEW);
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下 // popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下

8
src/base/combination/combo.js

@ -1,6 +1,7 @@
!(function () { !(function () {
var needHideWhenAnotherComboOpen = {}; var needHideWhenAnotherComboOpen = {};
var currentOpenedCombos = {}; var currentOpenedCombos = {};
/** /**
* @class BI.Combo * @class BI.Combo
* @extends BI.Widget * @extends BI.Widget
@ -11,6 +12,7 @@
}, },
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""), baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""),
attributes: { attributes: {
@ -107,7 +109,7 @@
_assertPopupView: function () { _assertPopupView: function () {
var self = this, o = this.options; var self = this, o = this.options;
if (this.popupView == null) { if (BI.isNull(this.popupView)) {
this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, { this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, {
type: "bi.popup_view", type: "bi.popup_view",
showArrow: o.showArrow, showArrow: o.showArrow,
@ -280,10 +282,12 @@
delete p.adaptHeight; delete p.adaptHeight;
p.dir = "right"; p.dir = "right";
break; break;
default:
break;
} }
if ("adaptHeight" in p) { if ("adaptHeight" in p) {
this.resetListHeight(p["adaptHeight"]); this.resetListHeight(p.adaptHeight);
} }
var width = this.combo.element.outerWidth(); var width = this.combo.element.outerWidth();
var height = this.combo.element.outerHeight(); var height = this.combo.element.outerHeight();

6
src/base/combination/expander.js

@ -126,6 +126,8 @@ BI.Expander = BI.inherit(BI.Widget, {
})); }));
} }
break; break;
default:
break;
} }
}); });
}, },
@ -136,7 +138,7 @@ BI.Expander = BI.inherit(BI.Widget, {
_assertPopupView: function () { _assertPopupView: function () {
var self = this, o = this.options; var self = this, o = this.options;
if (this.popupView == null) { if (BI.isNull(this.popupView)) {
this.popupView = BI.createWidget(this.options.popup, { this.popupView = BI.createWidget(this.options.popup, {
type: "bi.button_group", type: "bi.button_group",
cls: "expander-popup", cls: "expander-popup",
@ -255,6 +257,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (this.expander.options.id === id) { if (this.expander.options.id === id) {
return this.expander; return this.expander;
} }
return this.popupView && this.popupView.getNodeById(id); return this.popupView && this.popupView.getNodeById(id);
}, },
@ -262,6 +265,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (this.expander.getValue() === value) { if (this.expander.getValue() === value) {
return this.expander; return this.expander;
} }
return this.popupView && this.popupView.getNodeByValue(value); return this.popupView && this.popupView.getNodeByValue(value);
}, },

22
src/base/combination/group.button.js

@ -42,7 +42,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}, },
_createBtns: function (items) { _createBtns: function (items) {
var o = this.options;
return BI.createWidgets(BI.createItems(items, { return BI.createWidgets(BI.createItems(items, {
type: "bi.text_button" type: "bi.text_button"
}), this); }), this);
@ -66,6 +65,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
case BI.ButtonGroup.CHOOSE_TYPE_NONE: case BI.ButtonGroup.CHOOSE_TYPE_NONE:
self.setValue([]); self.setValue([]);
break; break;
default:
break;
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj);
@ -95,15 +96,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}); });
}); });
} }
return btns; return btns;
}, },
_packageSimpleItems: function (btns) { _packageSimpleItems: function (btns) {
var o = this.options; var o = this.options;
return BI.map(o.items, function (i, item) { return BI.map(o.items, function (i, item) {
if (BI.stripEL(item) === item) { if (BI.stripEL(item) === item) {
return btns[i]; return btns[i];
} }
return BI.extend({}, item, { return BI.extend({}, item, {
el: btns[i] el: btns[i]
}); });
@ -122,12 +126,14 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
lay = BI.formatEL(lay.items[0]).el; lay = BI.formatEL(lay.items[0]).el;
} }
lay.items = items; lay.items = items;
return layout; return layout;
}, },
// 如果是一个简单的layout // 如果是一个简单的layout
_isSimpleLayout: function () { _isSimpleLayout: function () {
var o = this.options; var o = this.options;
return BI.isArray(o.layouts) ? (o.layouts.length === 1 && !BI.isArray(o.items[0])) : true; return BI.isArray(o.layouts) ? (o.layouts.length === 1 && !BI.isArray(o.items[0])) : true;
}, },
@ -140,12 +146,12 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}, },
prependItems: function (items) { prependItems: function (items) {
var o = this.options;
var btns = this._btnsCreator.apply(this, arguments); var btns = this._btnsCreator.apply(this, arguments);
this.buttons = BI.concat(btns, this.buttons); this.buttons = BI.concat(btns, this.buttons);
if (this._isSimpleLayout() && this.layouts && this.layouts.prependItems) { if (this._isSimpleLayout() && this.layouts && this.layouts.prependItems) {
this.layouts.prependItems(btns); this.layouts.prependItems(btns);
return; return;
} }
@ -154,13 +160,13 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}, },
addItems: function (items) { addItems: function (items) {
var o = this.options;
var btns = this._btnsCreator.apply(this, arguments); var btns = this._btnsCreator.apply(this, arguments);
this.buttons = BI.concat(this.buttons, btns); this.buttons = BI.concat(this.buttons, btns);
// 如果是一个简单的layout // 如果是一个简单的layout
if (this._isSimpleLayout() && this.layouts && this.layouts.addItems) { if (this._isSimpleLayout() && this.layouts && this.layouts.addItems) {
this.layouts.addItems(btns); this.layouts.addItems(btns);
return; return;
} }
@ -257,6 +263,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
v.push(item.getValue()); v.push(item.getValue());
} }
}); });
return v; return v;
}, },
@ -267,6 +274,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
v.push(item.getValue()); v.push(item.getValue());
} }
}); });
return v; return v;
}, },
@ -285,6 +293,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
btns.push(item); btns.push(item);
} }
}); });
return btns; return btns;
}, },
@ -295,6 +304,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
btns.push(item); btns.push(item);
} }
}); });
return btns; return btns;
}, },
@ -303,9 +313,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
BI.any(this.buttons, function (i, item) { BI.any(this.buttons, function (i, item) {
if (item.isEnabled() && item.getValue() === value) { if (item.isEnabled() && item.getValue() === value) {
index = i; index = i;
return true; return true;
} }
}); });
return index; return index;
}, },
@ -314,9 +326,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
BI.any(this.buttons, function (i, item) { BI.any(this.buttons, function (i, item) {
if (item.isEnabled() && item.options.id === id) { if (item.isEnabled() && item.options.id === id) {
node = item; node = item;
return true; return true;
} }
}); });
return node; return node;
}, },
@ -325,9 +339,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
BI.any(this.buttons, function (i, item) { BI.any(this.buttons, function (i, item) {
if (item.isEnabled() && item.getValue() === value) { if (item.isEnabled() && item.getValue() === value) {
node = item; node = item;
return true; return true;
} }
}); });
return node; return node;
}, },

7
src/base/combination/group.virtual.js

@ -29,9 +29,10 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
var o = this.options; var o = this.options;
var map = this.buttonMap = {}; var map = this.buttonMap = {};
var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts]; var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts];
for (var i = layouts.length - 1; i > 0; i--) { for (let i = layouts.length - 1; i > 0; i--) {
items = BI.map(items, function (k, it) { items = BI.map(items, function (k, it) {
var el = BI.stripEL(it); var el = BI.stripEL(it);
return BI.extend({}, layouts[i], { return BI.extend({}, layouts[i], {
items: [ items: [
BI.extend({}, layouts[i].el, { BI.extend({}, layouts[i].el, {
@ -47,6 +48,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
}); });
}); });
} }
return items; return items;
}, },
@ -60,6 +62,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
lay = BI.formatEL(lay.items[0]).el; lay = BI.formatEL(lay.items[0]).el;
} }
lay.items = items; lay.items = items;
return layout; return layout;
}, },
@ -93,6 +96,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
} }
} }
}); });
return v; return v;
}, },
@ -119,6 +123,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
} }
} }
}); });
return v; return v;
}, },

4
src/base/combination/loader.js

@ -122,6 +122,7 @@ BI.Loader = BI.inherit(BI.Widget, {
if (BI.isNumber(o.count)) { if (BI.isNumber(o.count)) {
return this.count < o.count; return this.count < o.count;
} }
return !!o.hasPrev.apply(this, [{ return !!o.hasPrev.apply(this, [{
times: this.times, times: this.times,
count: this.count count: this.count
@ -133,6 +134,7 @@ BI.Loader = BI.inherit(BI.Widget, {
if (BI.isNumber(o.count)) { if (BI.isNumber(o.count)) {
return this.count < o.count; return this.count < o.count;
} }
return !!o.hasNext.apply(this, [{ return !!o.hasNext.apply(this, [{
times: this.times, times: this.times,
count: this.count count: this.count
@ -175,6 +177,7 @@ BI.Loader = BI.inherit(BI.Widget, {
self.populate.apply(self, arguments); self.populate.apply(self, arguments);
o.onLoaded(); o.onLoaded();
}]); }]);
return false; return false;
} }
this.options.items = items; this.options.items = items;
@ -195,6 +198,7 @@ BI.Loader = BI.inherit(BI.Widget, {
this.prev.invisible(); this.prev.invisible();
} }
} }
return true; return true;
}, },

3
src/base/combination/navigation.js

@ -45,6 +45,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
cardCreator: function (v) { cardCreator: function (v) {
var card = o.cardCreator(v); var card = o.cardCreator(v);
self.cardMap[v] = card; self.cardMap[v] = card;
return card; return card;
}, },
afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardCreated: BI.bind(this.afterCardCreated, this),
@ -54,7 +55,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
if (BI.isFunction(o.showIndex)) { if (BI.isFunction(o.showIndex)) {
this.__watch(o.showIndex, function (context, newValue) { this.__watch(o.showIndex, function (context, newValue) {
self.setSelect(newValue); self.setSelect(newValue);
}) });
} }
}, },

12
src/base/combination/searcher.js

@ -82,6 +82,8 @@ BI.Searcher = BI.inherit(BI.Widget, {
self._pauseSearch(); self._pauseSearch();
} }
break; break;
default:
break;
} }
}); });
}, },
@ -109,6 +111,8 @@ BI.Searcher = BI.inherit(BI.Widget, {
values.push(obj.getValue()); values.push(obj.getValue());
o.adapter && o.adapter.setValue(values); o.adapter && o.adapter.setValue(values);
break; break;
default:
break;
} }
} }
self.fireEvent(BI.Searcher.EVENT_CHANGE, value, obj); self.fireEvent(BI.Searcher.EVENT_CHANGE, value, obj);
@ -140,7 +144,6 @@ BI.Searcher = BI.inherit(BI.Widget, {
}, },
_pauseSearch: function () { _pauseSearch: function () {
var o = this.options, name = this.getName();
this._stop = true; this._stop = true;
BI.nextTick(function (name) { BI.nextTick(function (name) {
BI.Maskers.hide(name); BI.Maskers.hide(name);
@ -153,7 +156,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
}, },
_stopSearch: function () { _stopSearch: function () {
var o = this.options, name = this.getName(); var name = this.getName();
this._stop = true; this._stop = true;
BI.Maskers.hide(name); BI.Maskers.hide(name);
if (this._isSearching === true) { if (this._isSearching === true) {
@ -175,6 +178,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
this.popupView.populate(find, match, keyword); this.popupView.populate(find, match, keyword);
o.isAutoSync && o.adapter && o.adapter.getValue && this.popupView.setValue(o.adapter.getValue()); o.isAutoSync && o.adapter && o.adapter.getValue && this.popupView.setValue(o.adapter.getValue());
self.fireEvent(BI.Searcher.EVENT_SEARCHING); self.fireEvent(BI.Searcher.EVENT_SEARCHING);
return; return;
} }
this.popupView.loading && this.popupView.loading(); this.popupView.loading && this.popupView.loading();
@ -203,6 +207,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
if (BI.isEmptyString(res[res.length - 1])) { if (BI.isEmptyString(res[res.length - 1])) {
res = res.slice(0, res.length - 1); res = res.slice(0, res.length - 1);
} }
return BI.isNull(res) ? "" : res[res.length - 1]; return BI.isNull(res) ? "" : res[res.length - 1];
} }
}, },
@ -246,6 +251,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
hasMatched: function () { hasMatched: function () {
this._assertPopupView(); this._assertPopupView();
return this.popupView.hasMatched(); return this.popupView.hasMatched();
}, },
@ -288,8 +294,8 @@ BI.Searcher = BI.inherit(BI.Widget, {
if (BI.isNull(this.popupView)) { if (BI.isNull(this.popupView)) {
return o.popup.value; return o.popup.value;
} }
return this.popupView.getValue();
return this.popupView.getValue();
}, },
populate: function (result, searchResult, keyword) { populate: function (result, searchResult, keyword) {

2
src/base/combination/switcher.js

@ -265,6 +265,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
if (this.switcher.attr("id") === id) { if (this.switcher.attr("id") === id) {
return this.switcher; return this.switcher;
} }
return this.popupView && this.popupView.getNodeById(id); return this.popupView && this.popupView.getNodeById(id);
}, },
@ -272,6 +273,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
if (this.switcher.getValue() === value) { if (this.switcher.getValue() === value) {
return this.switcher; return this.switcher;
} }
return this.popupView && this.popupView.getNodeByValue(value); return this.popupView && this.popupView.getNodeByValue(value);
}, },

2
src/base/combination/tab.js

@ -112,7 +112,7 @@ BI.Tab = BI.inherit(BI.Widget, {
}, },
removeTab: function (cardname) { removeTab: function (cardname) {
var self = this, o = this.options; var self = this;
BI.any(this.cardMap, function (name, card) { BI.any(this.cardMap, function (name, card) {
if (BI.isEqual(name, (cardname + ""))) { if (BI.isEqual(name, (cardname + ""))) {
self.layout.deleteCardByName(name); self.layout.deleteCardByName(name);

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

@ -16,6 +16,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (!BI.isFunction(item.setSelected)) { if (!BI.isFunction(item.setSelected)) {
item.setNotSelectedValue(v); item.setNotSelectedValue(v);
return; return;
} }
if (BI.deepContains(v, item.getValue())) { if (BI.deepContains(v, item.getValue())) {
@ -31,6 +32,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (BI.isFunction(item.setEnabledValue)) { if (BI.isFunction(item.setEnabledValue)) {
item.setEnabledValue(v); item.setEnabledValue(v);
return; return;
} }
if (BI.deepContains(v, item.getValue())) { if (BI.deepContains(v, item.getValue())) {
@ -46,6 +48,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (!BI.isFunction(item.setSelected)) { if (!BI.isFunction(item.setSelected)) {
item.setValue(v); item.setValue(v);
return; return;
} }
if (BI.deepContains(v, item.getValue())) { if (BI.deepContains(v, item.getValue())) {
@ -61,12 +64,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
v = BI.concat(v, item.getNotSelectedValue()); v = BI.concat(v, item.getNotSelectedValue());
return; return;
} }
if (item.isEnabled() && item.isSelected && !item.isSelected()) { if (item.isEnabled() && item.isSelected && !item.isSelected()) {
v.push(item.getValue()); v.push(item.getValue());
} }
}); });
return v; return v;
}, },
@ -75,12 +80,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
v = BI.concat(v, item.getValue()); v = BI.concat(v, item.getValue());
return; return;
} }
if (item.isEnabled() && item.isSelected && item.isSelected()) { if (item.isEnabled() && item.isSelected && item.isSelected()) {
v.push(item.getValue()); v.push(item.getValue());
} }
}); });
return v; return v;
}, },
@ -89,12 +96,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
btns = btns.concat(item.getSelectedButtons()); btns = btns.concat(item.getSelectedButtons());
return; return;
} }
if (item.isSelected && item.isSelected()) { if (item.isSelected && item.isSelected()) {
btns.push(item); btns.push(item);
} }
}); });
return btns; return btns;
}, },
@ -103,12 +112,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
btns = btns.concat(item.getNotSelectedButtons()); btns = btns.concat(item.getNotSelectedButtons());
return; return;
} }
if (item.isSelected && !item.isSelected()) { if (item.isSelected && !item.isSelected()) {
btns.push(item); btns.push(item);
} }
}); });
return btns; return btns;
}, },
@ -118,12 +129,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
leaves = leaves.concat(item.getAllLeaves()); leaves = leaves.concat(item.getAllLeaves());
return; return;
} }
if (item.isEnabled()) { if (item.isEnabled()) {
leaves.push(item); leaves.push(item);
} }
}); });
return leaves; return leaves;
}, },
@ -133,9 +146,11 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
var vs = item.getValue(); var vs = item.getValue();
if (item.isEnabled() && (vs === value || BI.contains(vs, value))) { if (item.isEnabled() && (vs === value || BI.contains(vs, value))) {
index = i; index = i;
return true; return true;
} }
}); });
return index; return index;
}, },
@ -145,14 +160,17 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
if (item.isEnabled()) { if (item.isEnabled()) {
if (item.attr("id") === id) { if (item.attr("id") === id) {
node = item; node = item;
return true; return true;
} else if (BI.isFunction(item.getNodeById)) { } else if (BI.isFunction(item.getNodeById)) {
if (node = item.getNodeById(id)) { node = item.getNodeById(id);
if (node) {
return true; return true;
} }
} }
} }
}); });
return node; return node;
}, },
@ -161,15 +179,18 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.any(this.buttons, function (i, item) { BI.any(this.buttons, function (i, item) {
if (item.isEnabled()) { if (item.isEnabled()) {
if (BI.isFunction(item.getNodeByValue)) { if (BI.isFunction(item.getNodeByValue)) {
if (node = item.getNodeByValue(value)) { node = item.getNodeByValue(value);
if (node) {
return true; return true;
} }
} else if (item.attr("value") === value) { } else if (item.attr("value") === value) {
node = item; node = item;
return true; return true;
} }
} }
}); });
return node; return node;
} }
}); });

2
src/base/foundation/__test__/message.test.js

@ -4,7 +4,6 @@
* Created by windy on 2020/3/9 * Created by windy on 2020/3/9
*/ */
describe("MessageTest", function () { describe("MessageTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
@ -44,4 +43,3 @@ describe("MessageTest", function () {
expect(body.find(".bi-toast").length).to.equal(1); expect(body.find(".bi-toast").length).to.equal(1);
}); });
}); });

10
src/base/foundation/message.js

@ -3,8 +3,7 @@
* 弹出提示消息框用于模拟阻塞操作通过回调函数实现 * 弹出提示消息框用于模拟阻塞操作通过回调函数实现
* @class BI.Msg * @class BI.Msg
*/ */
BI.Msg = function () { BI.Msg = ((function () {
var $mask, $pop; var $mask, $pop;
var messageShows = []; var messageShows = [];
@ -69,6 +68,7 @@ BI.Msg = function () {
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);
return function () { return function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
toast.destroy?.(); toast.destroy?.();
@ -92,14 +92,14 @@ BI.Msg = function () {
right: 0, right: 0,
bottom: 0 bottom: 0
}).appendTo("body"); }).appendTo("body");
var close = function () { function close () {
messageShows[messageShows.length - 1].destroy(); messageShows[messageShows.length - 1].destroy();
messageShows.pop(); messageShows.pop();
if (messageShows.length === 0) { if (messageShows.length === 0) {
$mask.remove(); $mask.remove();
$mask = null; $mask = null;
} }
}; }
var controlItems = []; var controlItems = [];
if (hasCancel === true) { if (hasCancel === true) {
controlItems.push({ controlItems.push({
@ -231,4 +231,4 @@ BI.Msg = function () {
messageShows[messageShows.length] = BI.createWidget(conf); messageShows[messageShows.length] = BI.createWidget(conf);
} }
}; };
}(); })());

1
src/base/grid/__test__/grid.test.js

@ -4,7 +4,6 @@
* Created by windy on 2020/3/20 * Created by windy on 2020/3/20
*/ */
describe("GridTest", function () { describe("GridTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */

4
src/base/grid/grid.js

@ -61,7 +61,7 @@ BI.GridView = BI.inherit(BI.Widget, {
if (o.overflowY === false) { if (o.overflowY === false) {
scrollable = false; scrollable = false;
} else { } else {
scrollable = "y" scrollable = "y";
} }
} else { } else {
if (o.overflowY === false) { if (o.overflowY === false) {
@ -279,7 +279,7 @@ BI.GridView = BI.inherit(BI.Widget, {
}, },
_populate: function (items) { _populate: function (items) {
var self = this, o = this.options; var o = this.options;
this._reRange(); this._reRange();
if (items && items !== this.options.items) { if (items && items !== this.options.items) {
this.options.items = items; this.options.items = items;

1
src/base/layer/__test__/layer.popover.test.js

@ -5,7 +5,6 @@
*/ */
describe("PopoverTest", function () { describe("PopoverTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */

7
src/base/layer/layer.drawer.js

@ -144,6 +144,8 @@ BI.Drawer = BI.inherit(BI.Widget, {
top: "100%" top: "100%"
}); });
break; break;
default:
break;
} }
}, },
@ -172,6 +174,8 @@ BI.Drawer = BI.inherit(BI.Widget, {
top: "calc(100% - " + size.height + "px)" top: "calc(100% - " + size.height + "px)"
}); });
break; break;
default:
break;
} }
callback && callback(); callback && callback();
}); });
@ -180,7 +184,6 @@ BI.Drawer = BI.inherit(BI.Widget, {
hide: function (callback) { hide: function (callback) {
var self = this, o = this.options; var self = this, o = this.options;
requestAnimationFrame(function () { requestAnimationFrame(function () {
var size = self._getSuitableSize();
switch (o.placement) { switch (o.placement) {
case "right": case "right":
self.element.css({ self.element.css({
@ -202,6 +205,8 @@ BI.Drawer = BI.inherit(BI.Widget, {
top: "100%" top: "100%"
}); });
break; break;
default:
break;
} }
setTimeout(callback, 300); setTimeout(callback, 300);
}); });

3
src/base/layer/layer.popover.js

@ -157,7 +157,6 @@ BI.Popover = BI.inherit(BI.Widget, {
// mounted之后绑定事件 // mounted之后绑定事件
mounted: function () { mounted: function () {
var self = this; var self = this;
var o = this.options;
this.dragger.element.mousedown(function (e) { this.dragger.element.mousedown(function (e) {
var pos = self.element.offset(); var pos = self.element.offset();
self.startX = pos.left; self.startX = pos.left;
@ -168,7 +167,7 @@ BI.Popover = BI.inherit(BI.Widget, {
_getSuitableBodyHeight: function (height) { _getSuitableBodyHeight: function (height) {
var o = this.options; var o = this.options;
var c = this._constant;
return BI.clamp(height, 0, BI.Widget._renderEngine.createElement("body")[0].clientHeight - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap); return BI.clamp(height, 0, BI.Widget._renderEngine.createElement("body")[0].clientHeight - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap);
}, },

44
src/base/layer/layer.popup.js

@ -50,12 +50,14 @@ BI.PopupView = BI.inherit(BI.Widget, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
var fn = function (e) { function fn (e) {
e.stopPropagation(); e.stopPropagation();
}, stop = function (e) { }
function stop (e) {
e.stopEvent(); e.stopEvent();
return false; return false;
}; }
this.element.css({ this.element.css({
"z-index": BI.zIndex_popup, "z-index": BI.zIndex_popup,
"min-width": BI.isNumeric(o.minWidth) ? (o.minWidth / BI.pixRatio + BI.pixUnit) : o.minWidth, "min-width": BI.isNumeric(o.minWidth) ? (o.minWidth / BI.pixRatio + BI.pixUnit) : o.minWidth,
@ -108,7 +110,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
type: "bi.absolute", type: "bi.absolute",
cls: "bi-bubble-arrow-wrapper", cls: "bi-bubble-arrow-wrapper",
items: [{ items: [{
el: this.arrow, el: this.arrow
}] }]
}); });
// 因为三角符号的原因位置变大了,需要占位 // 因为三角符号的原因位置变大了,需要占位
@ -121,7 +123,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
items: [{ items: [{
el: this.arrowWrapper, el: this.arrowWrapper,
left: 0, left: 0,
top: 0, top: 0
}, { }, {
el: this.placeholder el: this.placeholder
}] }]
@ -139,6 +141,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
"padding-left": o.innerHgap / BI.pixRatio + BI.pixUnit, "padding-left": o.innerHgap / BI.pixRatio + BI.pixUnit,
"padding-right": o.innerHgap / BI.pixRatio + BI.pixUnit "padding-right": o.innerHgap / BI.pixRatio + BI.pixUnit
}); });
return this.button_group; return this.button_group;
}, },
@ -147,6 +150,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
if (false === o.tool) { if (false === o.tool) {
return; return;
} }
return BI.createWidget(o.tool); return BI.createWidget(o.tool);
}, },
@ -155,6 +159,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
if (o.tabs.length === 0) { if (o.tabs.length === 0) {
return; return;
} }
return BI.createWidget({ return BI.createWidget({
type: "bi.center", type: "bi.center",
cls: "list-view-tab", cls: "list-view-tab",
@ -218,7 +223,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
top: o.tgap + o.vgap, top: o.tgap + o.vgap,
left: 0, left: 0,
right: "", right: "",
bottom: "", bottom: ""
}; };
placeholderStyle = { placeholderStyle = {
left: 0, left: 0,
@ -237,7 +242,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
top: o.bgap + o.vgap, top: o.bgap + o.vgap,
left: "", left: "",
right: 0, right: 0,
bottom: "", bottom: ""
}; };
placeholderStyle = { placeholderStyle = {
left: 0, left: 0,
@ -257,14 +262,14 @@ BI.PopupView = BI.inherit(BI.Widget, {
bottom: o.bgap + o.vgap, bottom: o.bgap + o.vgap,
left: 0, left: 0,
right: "", right: "",
top: "", top: ""
}; };
placeholderStyle = { placeholderStyle = {
left: 0, left: 0,
right: 0, right: 0,
height: this._const.TRIANGLE_LENGTH, height: this._const.TRIANGLE_LENGTH,
top: "", top: "",
bottom: -this._const.TRIANGLE_LENGTH, bottom: -this._const.TRIANGLE_LENGTH
}; };
break; break;
case "top,left": case "top,left":
@ -276,14 +281,14 @@ BI.PopupView = BI.inherit(BI.Widget, {
bottom: o.bgap + o.vgap, bottom: o.bgap + o.vgap,
right: 0, right: 0,
left: "", left: "",
top: "", top: ""
}; };
placeholderStyle = { placeholderStyle = {
left: 0, left: 0,
right: 0, right: 0,
height: this._const.TRIANGLE_LENGTH, height: this._const.TRIANGLE_LENGTH,
top: "", top: "",
bottom: -this._const.TRIANGLE_LENGTH, bottom: -this._const.TRIANGLE_LENGTH
}; };
break; break;
case "left": case "left":
@ -296,7 +301,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
right: o.rgap + o.hgap, right: o.rgap + o.hgap,
top: 0, top: 0,
bottom: "", bottom: "",
left: "", left: ""
}; };
placeholderStyle = { placeholderStyle = {
top: 0, top: 0,
@ -315,7 +320,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
right: o.rgap + o.hgap, right: o.rgap + o.hgap,
bottom: 0, bottom: 0,
top: "", top: "",
left: "", left: ""
}; };
placeholderStyle = { placeholderStyle = {
top: 0, top: 0,
@ -335,7 +340,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
left: o.lgap + o.hgap, left: o.lgap + o.hgap,
top: 0, top: 0,
bottom: "", bottom: "",
right: "", right: ""
}; };
placeholderStyle = { placeholderStyle = {
top: 0, top: 0,
@ -354,7 +359,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
left: o.lgap + o.hgap, left: o.lgap + o.hgap,
bottom: 0, bottom: 0,
top: "", top: "",
right: "", right: ""
}; };
placeholderStyle = { placeholderStyle = {
top: 0, top: 0,
@ -372,8 +377,15 @@ BI.PopupView = BI.inherit(BI.Widget, {
break; break;
case "innerLeft": case "innerLeft":
break; break;
default:
break;
} }
this.element.removeClass("left").removeClass("right").removeClass("top").removeClass("bottom").addClass(direction); this.element
.removeClass("left")
.removeClass("right")
.removeClass("top")
.removeClass("bottom")
.addClass(direction);
this.arrow.element.css(style); this.arrow.element.css(style);
this.arrowWrapper.element.css(wrapperStyle); this.arrowWrapper.element.css(wrapperStyle);
this.placeholder.element.css(placeholderStyle); this.placeholder.element.css(placeholderStyle);

1
src/base/layer/layer.searcher.js

@ -9,6 +9,7 @@
BI.SearcherView = BI.inherit(BI.Pane, { BI.SearcherView = BI.inherit(BI.Pane, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.SearcherView.superclass._defaultConfig.apply(this, arguments); var conf = BI.SearcherView.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.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: BI.i18nText("BI-No_Select"),

10
src/base/list/listview.js

@ -21,13 +21,13 @@ BI.ListView = BI.inherit(BI.Widget, {
}, },
init: function () { init: function () {
var self = this;
this.renderedIndex = -1; this.renderedIndex = -1;
this.cache = {}; this.cache = {};
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: "bi.vertical", type: "bi.vertical",
items: [BI.extend({ items: [BI.extend({
@ -72,10 +72,11 @@ BI.ListView = BI.inherit(BI.Widget, {
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0; var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0;
var cnt = this.renderedIndex + 1; var cnt = this.renderedIndex + 1;
var lastHeight; var lastHeight;
var getElementHeight = function () { function getElementHeight () {
return self.container.element.height(); return self.container.element.height();
}; }
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) { lastHeight = getElementHeight();
while ((lastHeight) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize); var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items.map(function (item, i) { this.container.addItems(items.map(function (item, i) {
return o.itemFormatter(item, index + i); return o.itemFormatter(item, index + i);
@ -93,7 +94,6 @@ BI.ListView = BI.inherit(BI.Widget, {
}, },
_calculateBlocksToRender: function () { _calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf(); this._renderMoreIf();
}, },

1
src/base/list/virtualgrouplist.js

@ -27,6 +27,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: "bi.vertical", type: "bi.vertical",
items: [{ items: [{

6
src/base/list/virtuallist.js

@ -20,13 +20,13 @@ BI.VirtualList = BI.inherit(BI.Widget, {
}, },
init: function () { init: function () {
var self = this;
this.renderedIndex = -1; this.renderedIndex = -1;
this.cache = {}; this.cache = {};
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this;
return { return {
type: "bi.vertical", type: "bi.vertical",
items: [{ items: [{
@ -45,7 +45,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
ref: function () { ref: function () {
self.bottomBlank = this; self.bottomBlank = this;
} }
}], }]
}; };
}, },

2
src/base/tree/customtree.js

@ -68,6 +68,7 @@ BI.CustomTree = BI.inherit(BI.Widget, {
} }
var args = Array.prototype.slice.call(arguments, 0); var args = Array.prototype.slice.call(arguments, 0);
args[0].node = node; args[0].node = node;
return o.itemsCreator.apply(self, args); return o.itemsCreator.apply(self, args);
}; };
BI.isNull(item.popup.el) && (item.popup.el = BI.deepClone(o.el)); BI.isNull(item.popup.el) && (item.popup.el = BI.deepClone(o.el));
@ -76,6 +77,7 @@ BI.CustomTree = BI.inherit(BI.Widget, {
items.push(node); items.push(node);
} }
}); });
return items; return items;
}, },

Loading…
Cancel
Save