From 4d56c4f129f1536a09ba6ac050d48540a5f23574 Mon Sep 17 00:00:00 2001 From: chaos0156 <429018715@qq.com> Date: Mon, 15 Aug 2022 14:16:32 +0800 Subject: [PATCH] KERNEL-12408 --- .eslintrc | 3 ++- src/base/list/__test__/listview.test.js | 3 +-- src/base/list/virtualgrouplist.js | 7 ++++--- src/base/list/virtuallist.js | 7 ++++--- src/base/pager/pager.js | 1 - src/base/single/0.single.js | 12 +++++++----- src/base/single/1.text.js | 8 +++++--- src/base/single/text.pure.js | 5 +++-- 8 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.eslintrc b/.eslintrc index 41426aa36..1d4331f4b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,7 +31,8 @@ "rules": { "no-param-reassign": "off", "quotes": [2, "double"], - "comma-dangle": ["error", "never"] // 多行对象字面量中要求拖尾逗号 + "comma-dangle": ["error", "always"], // 多行对象字面量中要求拖尾逗号 + "no-empty":["error", { "allowEmptyCatch": true }] } }, { "files": ["webpack/*.js", "./*.js", "lib/**/*.js", "lib/*.js", "./bin/*.js", "./bin/**/*.js"], diff --git a/src/base/list/__test__/listview.test.js b/src/base/list/__test__/listview.test.js index 4be8993c5..adeb87dfb 100644 --- a/src/base/list/__test__/listview.test.js +++ b/src/base/list/__test__/listview.test.js @@ -6,7 +6,6 @@ // TODO 展示类控件测什么没想好标记一下 describe("ListView && VirtualList", function () { - /** * test_author_windy */ @@ -45,4 +44,4 @@ describe("ListView && VirtualList", function () { }); a.destroy(); }); -}); \ No newline at end of file +}); diff --git a/src/base/list/virtualgrouplist.js b/src/base/list/virtualgrouplist.js index 2dc5f97a5..c18344a12 100644 --- a/src/base/list/virtualgrouplist.js +++ b/src/base/list/virtualgrouplist.js @@ -88,10 +88,11 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { var minContentHeight = o.scrollTop + height + o.overscanHeight; var index = (this.renderedIndex + 1) * o.blockSize, cnt = this.renderedIndex + 1; var lastHeight; - var getElementHeight = function () { + function getElementHeight () { return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height(); - }; - while ((lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight()) < minContentHeight && index < o.items.length) { + } + lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight(); + while (lastHeight < minContentHeight && index < o.items.length) { var items = o.items.slice(index, index + o.blockSize); this.container[self.renderedIndex === -1 ? "populate" : "addItems"](items.map(function (item, i) { return o.itemFormatter(item, index + i); diff --git a/src/base/list/virtuallist.js b/src/base/list/virtuallist.js index 7ae32143a..83a0d38de 100644 --- a/src/base/list/virtuallist.js +++ b/src/base/list/virtuallist.js @@ -71,10 +71,11 @@ BI.VirtualList = BI.inherit(BI.Widget, { var minContentHeight = o.scrollTop + height + o.overscanHeight; var index = (this.renderedIndex + 1) * o.blockSize, cnt = this.renderedIndex + 1; var lastHeight; - var getElementHeight = function () { + function getElementHeight() { return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.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); this.container.addItems(items.map(function (item, i) { return o.itemFormatter(item, index + i); diff --git a/src/base/pager/pager.js b/src/base/pager/pager.js index 64ea9a942..c19d3e348 100644 --- a/src/base/pager/pager.js +++ b/src/base/pager/pager.js @@ -41,7 +41,6 @@ BI.Pager = BI.inherit(BI.Widget, { }, render: function () { - var self = this; this.currPage = BI.result(this.options, "curr"); // 翻页太灵敏 // this._lock = false; diff --git a/src/base/single/0.single.js b/src/base/single/0.single.js index 47dc6718f..e271cb5ad 100644 --- a/src/base/single/0.single.js +++ b/src/base/single/0.single.js @@ -15,13 +15,14 @@ var delayingTooltips; BI.Single = BI.inherit(BI.Widget, { _defaultConfig: function () { var conf = BI.Single.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { readonly: false, title: null, warningTitle: null, tipType: null, // success或warning - belowMouse: false, // title是否跟随鼠标 - enableHover: false + belowMouse: false, // title是否跟随鼠标 + enableHover: false, }); }, @@ -70,7 +71,7 @@ BI.Single = BI.inherit(BI.Widget, { || BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) { this.enableHover({ belowMouse: o.belowMouse, - container: o.container + container: o.container, }); } }, @@ -136,7 +137,6 @@ BI.Single = BI.inherit(BI.Widget, { } } }, 500); - }); this.element.on("mouseleave.title" + this.getName(), function (e) { self._e = null; @@ -193,6 +193,7 @@ BI.Single = BI.inherit(BI.Widget, { if (BI.isFunction(title)) { return title(); } + return title; }, @@ -201,6 +202,7 @@ BI.Single = BI.inherit(BI.Widget, { if (BI.isFunction(title)) { return title(); } + return title; }, @@ -222,6 +224,6 @@ BI.Single = BI.inherit(BI.Widget, { this.showTimeout = null; } BI.Tooltips.remove(this.getName()); - } + }, }); BI.shortcut("bi.single", BI.Single); diff --git a/src/base/single/1.text.js b/src/base/single/1.text.js index 4a22bf531..2f0fabb0a 100644 --- a/src/base/single/1.text.js +++ b/src/base/single/1.text.js @@ -45,13 +45,13 @@ }); } if (BI.isWidthOrHeight(o.height)) { - this.element.css({lineHeight: BI.isNumber(o.height) ? (o.height / BI.pixRatio + BI.pixUnit) : o.height}); + this.element.css({ lineHeight: BI.isNumber(o.height) ? (o.height / BI.pixRatio + BI.pixUnit) : o.height }); } if (BI.isWidthOrHeight(o.lineHeight)) { - this.element.css({lineHeight: BI.isNumber(o.lineHeight) ? (o.lineHeight / BI.pixRatio + BI.pixUnit) : o.lineHeight}); + this.element.css({ lineHeight: BI.isNumber(o.lineHeight) ? (o.lineHeight / BI.pixRatio + BI.pixUnit) : o.lineHeight }); } if (BI.isWidthOrHeight(o.maxWidth)) { - this.element.css({maxWidth: BI.isNumber(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth}); + this.element.css({ maxWidth: BI.isNumber(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth }); } this.element.css({ textAlign: o.textAlign, @@ -108,6 +108,7 @@ _getShowText: function () { var o = this.options; var text = BI.isFunction(o.text) ? o.text() : o.text; + return BI.isKey(text) ? BI.Text.formatText(text + "") : text; }, @@ -165,6 +166,7 @@ text = formatters[i](text); } } + return text; }; BI.shortcut("bi.text", BI.Text); diff --git a/src/base/single/text.pure.js b/src/base/single/text.pure.js index 7c4d93c0c..07a201369 100644 --- a/src/base/single/text.pure.js +++ b/src/base/single/text.pure.js @@ -5,7 +5,7 @@ BI.PureText = BI.inherit(BI.Widget, { props: { - tagName: null + tagName: null, }, render: function () { @@ -27,6 +27,7 @@ if (!BI.isKey(text)) { return ""; } + return BI.Text.formatText(text + ""); }, @@ -38,7 +39,7 @@ setText: function (text) { this.options.text = BI.isNotNull(text) ? text : ""; this.element.__textKeywordMarked__(this._getShowText()); - } + }, }); BI.shortcut("bi.pure_text", BI.PureText); }());