Browse Source

KERNEL-13841 refactor:base文件es6化箭头函数和this代码优化

es6
Joker.Wang-王顺 2 years ago
parent
commit
3db612aa38
  1. 4
      src/base/grid/grid.js
  2. 4
      src/base/layer/layer.popover.js
  3. 2
      src/base/layer/layer.popup.js
  4. 10
      src/base/layer/layer.searcher.js
  5. 2
      src/base/list/virtualgrouplist.js
  6. 4
      src/base/pager/pager.js
  7. 2
      src/base/single/tip/tip.tooltip.js

4
src/base/grid/grid.js

@ -242,7 +242,7 @@ export default class GridView extends Widget {
addSet[i] = key; addSet[i] = key;
} }
}); });
BI.each(this.renderedKeys, function (i, key) { BI.each(this.renderedKeys, (i, key) => {
if (existSet[i]) { if (existSet[i]) {
return; return;
} }
@ -256,7 +256,7 @@ export default class GridView extends Widget {
this.renderedCells[index].el._destroy(); this.renderedCells[index].el._destroy();
}); });
const addedItems = []; const addedItems = [];
BI.each(addSet, function (index, key) { BI.each(addSet, (index, key) => {
addedItems.push(renderedCells[key[2]]); addedItems.push(renderedCells[key[2]]);
}); });
// 与listview一样, 给上下文 // 与listview一样, 给上下文

4
src/base/layer/layer.popover.js

@ -47,7 +47,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(function (deltaX, deltaY) { this.tracker = new BI.MouseMoveTracker((deltaX, deltaY) => {
const W = BI.Widget._renderEngine.createElement("body").width(); const W = BI.Widget._renderEngine.createElement("body").width();
const H = BI.Widget._renderEngine.createElement("body").height(); const H = BI.Widget._renderEngine.createElement("body").height();
this.startX += deltaX; this.startX += deltaX;
@ -164,7 +164,7 @@ export class Popover extends Widget {
} }
// mounted之后绑定事件 // mounted之后绑定事件
mounted() { mounted() {
this.dragger.element.mousedown(function (e) { this.dragger.element.mousedown((e) => {
if (this.options.draggable !== false) { if (this.options.draggable !== false) {
this.startX = this.element[0].offsetLeft; this.startX = this.element[0].offsetLeft;
this.startY = this.element[0].offsetTop; this.startY = this.element[0].offsetTop;

2
src/base/layer/layer.popup.js

@ -81,7 +81,7 @@ export default class PopupView extends Widget {
this.toolbar = this._createToolBar(); this.toolbar = this._createToolBar();
this.view.on(BI.Controller.EVENT_CHANGE, (type, ...args) => { this.view.on(BI.Controller.EVENT_CHANGE, (type, ...args) => {
this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, args]); this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, ...args]);
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
this.fireEvent(PopupView.EVENT_CHANGE); this.fireEvent(PopupView.EVENT_CHANGE);
} }

10
src/base/layer/layer.searcher.js

@ -38,7 +38,7 @@ export default class SearcherView extends Pane {
searcher: { searcher: {
type: "bi.button_group", type: "bi.button_group",
behaviors: { behaviors: {
redmark: function () { redmark: () => {
return true; return true;
}, },
}, },
@ -65,8 +65,8 @@ export default class SearcherView extends Pane {
}], }],
value, value,
}); });
this.matcher.on(BI.Controller.EVENT_CHANGE, (type, val, ob)=> { this.matcher.on(BI.Controller.EVENT_CHANGE, (type, val, ob, ...args) => {
this.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, val, ob, ...args]);
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
this.fireEvent(SearcherView.EVENT_CHANGE, val, ob); this.fireEvent(SearcherView.EVENT_CHANGE, val, ob);
} }
@ -94,8 +94,8 @@ export default class SearcherView extends Pane {
}], }],
value, value,
}); });
this.searcher.on(BI.Controller.EVENT_CHANGE, (type, val, ob)=> { this.searcher.on(BI.Controller.EVENT_CHANGE, (type, val, ob, ...args) => {
this.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, val, ob, ...args]);
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
this.fireEvent(BI.SearcherView.EVENT_CHANGE, val, ob); this.fireEvent(BI.SearcherView.EVENT_CHANGE, val, ob);
} }

2
src/base/list/virtualgrouplist.js

@ -71,7 +71,7 @@ export default class VirtualGroupList extends Widget {
this.element.scroll(() => { this.element.scroll(() => {
o.scrollTop = this.element.scrollTop(); o.scrollTop = this.element.scrollTop();
if (!this.ticking) { if (!this.ticking) {
requestAnimationFrame(function () { requestAnimationFrame(() => {
this._calculateBlocksToRender(); this._calculateBlocksToRender();
this.ticking = false; this.ticking = false;
}); });

4
src/base/pager/pager.js

@ -23,7 +23,7 @@ export default class Pager extends Widget {
dynamicShowFirstLast: false, // 是否动态显示首页、尾页 dynamicShowFirstLast: false, // 是否动态显示首页、尾页
dynamicShowPrevNext: false, // 是否动态显示上一页、下一页 dynamicShowPrevNext: false, // 是否动态显示上一页、下一页
pages: false, // 总页数 pages: false, // 总页数
curr: function () { curr: () => {
return 1; return 1;
}, // 初始化当前页 }, // 初始化当前页
groups: 0, // 连续显示分页数 groups: 0, // 连续显示分页数
@ -230,7 +230,7 @@ export default class Pager extends Widget {
this._populate(); this._populate();
this.fireEvent(Pager.EVENT_CHANGE, obj); this.fireEvent(Pager.EVENT_CHANGE, obj);
} }
this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, value, obj, args]); this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, value, obj, ...args]);
}); });
this.fireEvent(Pager.EVENT_AFTER_POPULATE); this.fireEvent(Pager.EVENT_AFTER_POPULATE);
} }

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

@ -51,7 +51,7 @@ export default class Tooltip extends Tip {
element: this, element: this,
hgap: this._const.hgap, hgap: this._const.hgap,
innerVgap: this._const.vgap, innerVgap: this._const.vgap,
items: BI.map(texts, function (i, text) { items: BI.map(texts, (i, text) => {
return { return {
type: "bi.label", type: "bi.label",
textAlign: textAlign, textAlign: textAlign,

Loading…
Cancel
Save