From 3e6f88cab147b7435851a02bc0e2aabd7e631387 Mon Sep 17 00:00:00 2001 From: chaos0156 <429018715@qq.com> Date: Mon, 15 Aug 2022 17:13:00 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-12408:base=E4=B8=ADeslint=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc | 3 +- src/base/collection/collection.js | 6 +-- src/base/combination/bubble.js | 4 +- src/base/combination/expander.js | 4 +- src/base/combination/group.button.js | 2 +- src/base/combination/group.combo.js | 2 +- src/base/combination/group.virtual.js | 2 +- src/base/combination/loader.js | 6 +-- src/base/combination/navigation.js | 2 +- src/base/combination/tab.js | 2 +- src/base/foundation/message.js | 6 +-- src/base/grid/grid.js | 6 +-- src/base/layer/layer.drawer.js | 2 +- src/base/layer/layer.popover.js | 2 +- src/base/layer/layer.popup.js | 10 ++--- src/base/single/1.text.js | 6 +-- src/base/single/button/button.basic.js | 35 ++++++++++-------- src/base/single/button/button.node.js | 5 ++- .../node/__test__/icontexticonnode.test.js | 12 +++--- .../button/node/__test__/icontextnode.test.js | 12 +++--- .../button/node/__test__/texticonnode.test.js | 12 +++--- .../button/node/__test__/textnode.test.js | 15 +++----- .../single/button/node/icontexticonnode.js | 15 ++++---- src/base/single/button/node/icontextnode.js | 13 ++++--- src/base/single/button/node/texticonnode.js | 13 ++++--- src/base/single/button/node/textnode.js | 9 +++-- src/base/single/editor/editor.js | 23 ++++++------ src/base/single/editor/editor.multifile.js | 11 +++--- src/base/single/html/__test__/html.test.js | 9 ++--- src/base/single/html/html.js | 24 ++++++------ src/base/single/icon/icon.js | 5 ++- .../single/iframe/__test__/iframe.test.js | 5 +-- src/base/single/iframe/iframe.js | 7 ++-- src/base/single/img/__test__/img.test.js | 5 +-- src/base/single/img/img.js | 7 ++-- .../single/input/checkbox/checkbox.image.js | 7 ++-- src/base/single/input/checkbox/checkbox.js | 11 +++--- src/base/single/input/input.js | 37 ++++++++++--------- src/base/single/input/radio/radio.image.js | 7 ++-- src/base/single/input/radio/radio.js | 11 +++--- src/base/single/tip/0.tip.js | 2 +- src/base/tree/customtree.js | 2 +- 42 files changed, 194 insertions(+), 185 deletions(-) diff --git a/.eslintrc b/.eslintrc index a0374a47e..70d386082 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,7 +31,8 @@ "rules": { "no-param-reassign": "off", "quotes": [2, "double"], - "comma-dangle": ["error", { "arrays": "never", "objects": "always"}], // 多行对象字面量中要求拖尾逗号 + "comma-dangle": ["error", { "arrays": "never", "objects": "always-multiline"}] // 多行对象字面量中要求拖尾逗号 + // "no-empty": ["error",{"allowEmptyCatch":"true"}] } }, { "files": ["webpack/*.js", "./*.js", "lib/**/*.js", "lib/*.js", "./bin/*.js", "./bin/**/*.js"], diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index f6bbcc774..0ad681faa 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -282,7 +282,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { var minY = BI.max(topBorder); var maxY = BI.min(bottomBorder); - this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY, }; + this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; } }, @@ -341,7 +341,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { if (this.options.overflowX !== !!b) { this.options.overflowX = !!b; BI.nextTick(function () { - self.element.css({ overflowX: b ? "auto" : "hidden", }); + self.element.css({ overflowX: b ? "auto" : "hidden" }); }); } }, @@ -351,7 +351,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { if (this.options.overflowY !== !!b) { this.options.overflowY = !!b; BI.nextTick(function () { - self.element.css({ overflowY: b ? "auto" : "hidden", }); + self.element.css({ overflowY: b ? "auto" : "hidden" }); }); } }, diff --git a/src/base/combination/bubble.js b/src/base/combination/bubble.js index 0e8a79673..d4c240b17 100644 --- a/src/base/combination/bubble.js +++ b/src/base/combination/bubble.js @@ -85,7 +85,7 @@ element: this, }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { items: [ - { el: this.combo, } + { el: this.combo } ], })))); o.isDefaultInit && (this._assertPopupView()); @@ -260,7 +260,7 @@ scrolly: false, element: this.options.container || this, items: [ - { el: this.popupView, } + { el: this.popupView } ], }); this._rendered = true; diff --git a/src/base/combination/expander.js b/src/base/combination/expander.js index 5e99dacbd..60b3dd471 100644 --- a/src/base/combination/expander.js +++ b/src/base/combination/expander.js @@ -65,7 +65,7 @@ BI.Expander = BI.inherit(BI.Widget, { scrolly: false, element: this, items: [ - { el: this.expander, } + { el: this.expander } ], }); o.isDefaultInit && this._assertPopupView(); @@ -171,7 +171,7 @@ BI.Expander = BI.inherit(BI.Widget, { scrolly: false, element: this, items: [ - { el: this.popupView, } + { el: this.popupView } ], }); this._rendered = true; diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index aa73851a6..49d56167c 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -203,7 +203,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { items = this._packageItems(items, this._packageBtns(this.buttons)); } - this.layouts = BI.createWidget(BI.extend({ element: this, }, this._packageLayout(items))); + this.layouts = BI.createWidget(BI.extend({ element: this }, this._packageLayout(items))); }, setNotSelectedValue: function (v) { diff --git a/src/base/combination/group.combo.js b/src/base/combination/group.combo.js index 1b77ddc3a..2f8b0c72e 100644 --- a/src/base/combination/group.combo.js +++ b/src/base/combination/group.combo.js @@ -15,7 +15,7 @@ BI.ComboGroup = BI.inherit(BI.Widget, { isNeedAdjustHeight: false, isNeedAdjustWidth: false, - el: { type: "bi.text_button", text: "", value: "", }, + el: { type: "bi.text_button", text: "", value: "" }, items: [], popup: { diff --git a/src/base/combination/group.virtual.js b/src/base/combination/group.virtual.js index a6f481a9d..40e7c09f4 100644 --- a/src/base/combination/group.virtual.js +++ b/src/base/combination/group.virtual.js @@ -132,7 +132,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, { this.options.items = items; items = this._packageBtns(items); if (!this.layouts) { - this.layouts = BI.createWidget(BI.extend({ element: this, }, this._packageLayout(items))); + this.layouts = BI.createWidget(BI.extend({ element: this }, this._packageLayout(items))); } else { this.layouts.populate(items, { context: this, diff --git a/src/base/combination/loader.js b/src/base/combination/loader.js index a666fda1a..cf548b024 100644 --- a/src/base/combination/loader.js +++ b/src/base/combination/loader.js @@ -38,7 +38,7 @@ BI.Loader = BI.inherit(BI.Widget, { _prevLoad: function () { var self = this, o = this.options; this.prev.setLoading(); - o.itemsCreator.apply(this, [{ times: --this.times, }, function () { + o.itemsCreator.apply(this, [{ times: --this.times }, function () { self.prev.setLoaded(); self.prependItems.apply(self, arguments); }]); @@ -47,7 +47,7 @@ BI.Loader = BI.inherit(BI.Widget, { _nextLoad: function () { var self = this, o = this.options; this.next.setLoading(); - o.itemsCreator.apply(this, [{ times: ++this.times, }, function () { + o.itemsCreator.apply(this, [{ times: ++this.times }, function () { self.next.setLoaded(); self.addItems.apply(self, arguments); }]); @@ -170,7 +170,7 @@ BI.Loader = BI.inherit(BI.Widget, { _populate: function (items) { var self = this, o = this.options; if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) { - o.itemsCreator.apply(this, [{ times: 1, }, function () { + o.itemsCreator.apply(this, [{ times: 1 }, function () { if (arguments.length === 0) { throw new Error("参数不能为空"); } diff --git a/src/base/combination/navigation.js b/src/base/combination/navigation.js index 5004a660e..971ec9ba9 100644 --- a/src/base/combination/navigation.js +++ b/src/base/combination/navigation.js @@ -23,7 +23,7 @@ BI.Navigation = BI.inherit(BI.Widget, { render: function () { var self = this, o = this.options; - this.tab = BI.createWidget(this.options.tab, { type: "bi.button_group", }); + this.tab = BI.createWidget(this.options.tab, { type: "bi.button_group" }); this.cardMap = {}; this.showIndex = 0; this.layout = BI.createWidget({ diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index 196c90850..fe5904804 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -23,7 +23,7 @@ BI.Tab = BI.inherit(BI.Widget, { render: function () { var self = this, o = this.options; if (BI.isObject(o.tab)) { - this.tab = BI.createWidget(this.options.tab, { type: "bi.button_group", }); + this.tab = BI.createWidget(this.options.tab, { type: "bi.button_group" }); this.tab.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); diff --git a/src/base/foundation/message.js b/src/base/foundation/message.js index 76d82f5e5..380e12039 100644 --- a/src/base/foundation/message.js +++ b/src/base/foundation/message.js @@ -21,7 +21,7 @@ BI.Msg = ((function () { // BI.Msg.prompt(title, message, value, callback, min_width); }, toast: function (message, options, context) { - BI.isString(options) && (options = { level: options, }); + BI.isString(options) && (options = { level: options }); options = options || {}; context = context || BI.Widget._renderEngine.createElement("body"); var level = options.level || "common"; @@ -40,7 +40,7 @@ BI.Msg = ((function () { BI.remove(toastStack, toast.element); var _height = BI.SIZE_CONSANTS.TOAST_TOP; BI.each(toastStack, function (i, element) { - element.css({ "top": _height, }); + element.css({ "top": _height }); _height += element.outerHeight() + 10; }); callback(); @@ -61,7 +61,7 @@ BI.Msg = ((function () { }], }); toastStack.push(toast.element); - toast.element.css({ "margin-left": -1 * toast.element.outerWidth() / 2, }); + toast.element.css({ "margin-left": -1 * toast.element.outerWidth() / 2 }); toast.element.removeClass("bi-message-leave").addClass("bi-message-enter"); autoClose && BI.delay(function () { diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index dc6e8506d..81853b77a 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -258,7 +258,7 @@ BI.GridView = BI.inherit(BI.Widget, { this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; - this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY, }; + this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; } }, @@ -333,7 +333,7 @@ BI.GridView = BI.inherit(BI.Widget, { if (this.options.overflowX !== !!b) { this.options.overflowX = !!b; BI.nextTick(function () { - self.element.css({ overflowX: b ? "auto" : "hidden", }); + self.element.css({ overflowX: b ? "auto" : "hidden" }); }); } }, @@ -343,7 +343,7 @@ BI.GridView = BI.inherit(BI.Widget, { if (this.options.overflowY !== !!b) { this.options.overflowY = !!b; BI.nextTick(function () { - self.element.css({ overflowY: b ? "auto" : "hidden", }); + self.element.css({ overflowY: b ? "auto" : "hidden" }); }); } }, diff --git a/src/base/layer/layer.drawer.js b/src/base/layer/layer.drawer.js index af6eb98c2..23ef8b8c5 100644 --- a/src/base/layer/layer.drawer.js +++ b/src/base/layer/layer.drawer.js @@ -227,7 +227,7 @@ BI.Drawer = BI.inherit(BI.Widget, { }, setZindex: function (zindex) { - this.element.css({ "z-index": zindex, }); + this.element.css({ "z-index": zindex }); }, destroyed: function () { diff --git a/src/base/layer/layer.popover.js b/src/base/layer/layer.popover.js index a6caefd85..2a4453472 100644 --- a/src/base/layer/layer.popover.js +++ b/src/base/layer/layer.popover.js @@ -222,7 +222,7 @@ BI.Popover = BI.inherit(BI.Widget, { }, setZindex: function (zindex) { - this.element.css({ "z-index": zindex, }); + this.element.css({ "z-index": zindex }); }, destroyed: function () { diff --git a/src/base/layer/layer.popup.js b/src/base/layer/layer.popup.js index d4291ef95..ef7d55749 100644 --- a/src/base/layer/layer.popup.js +++ b/src/base/layer/layer.popup.js @@ -62,12 +62,12 @@ BI.PopupView = BI.inherit(BI.Widget, { "z-index": BI.zIndex_popup, "min-width": BI.isNumeric(o.minWidth) ? (o.minWidth / BI.pixRatio + BI.pixUnit) : o.minWidth, "max-width": BI.isNumeric(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth, - }).bind({ click: fn, }); + }).bind({ click: fn }); this.element.bind("mousewheel", fn); - o.stopPropagation && this.element.bind({ mousedown: fn, mouseup: fn, mouseover: fn, }); - o.stopEvent && this.element.bind({ mousedown: stop, mouseup: stop, mouseover: stop, }); + o.stopPropagation && this.element.bind({ mousedown: fn, mouseup: fn, mouseover: fn }); + o.stopEvent && this.element.bind({ mousedown: stop, mouseup: stop, mouseover: stop }); this.tool = this._createTool(); this.tab = this._createTab(); this.view = this._createView(); @@ -133,7 +133,7 @@ BI.PopupView = BI.inherit(BI.Widget, { _createView: function () { var o = this.options; - this.button_group = BI.createWidget(o.el, { type: "bi.button_group", value: o.value, }); + this.button_group = BI.createWidget(o.el, { type: "bi.button_group", value: o.value }); this.button_group.element.css({ "min-height": BI.isNumeric(o.minHeight) ? (o.minHeight / BI.pixRatio + BI.pixUnit) : o.minHeight, "padding-top": o.innerVgap / BI.pixRatio + BI.pixUnit, @@ -411,7 +411,7 @@ BI.PopupView = BI.inherit(BI.Widget, { toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0); var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap; this.view.resetHeight ? this.view.resetHeight(resetHeight) : - this.view.element.css({ "max-height": resetHeight / BI.pixRatio + BI.pixUnit, }); + this.view.element.css({ "max-height": resetHeight / BI.pixRatio + BI.pixUnit }); }, setValue: function (selectedValues) { diff --git a/src/base/single/1.text.js b/src/base/single/1.text.js index 123df54a3..50aebf841 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, diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index 9ade43edb..8fa304890 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -8,6 +8,7 @@ BI.BasicButton = BI.inherit(BI.Single, { _defaultConfig: function () { var conf = BI.BasicButton.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { _baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), // el: {} // 可以通过el来创建button元素 @@ -21,10 +22,10 @@ BI.BasicButton = BI.inherit(BI.Single, { disableSelected: false, // 使能选中 shadow: false, - isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 + isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 trigger: null, handler: BI.emptyFn, - bubble: null + bubble: null, }); }, @@ -63,11 +64,11 @@ BI.BasicButton = BI.inherit(BI.Single, { _createShadow: function () { var self = this, o = this.options; - var assertMask = function () { + function assertMask() { if (!self.$mask) { self.$mask = BI.createWidget(BI.isObject(o.shadow) ? o.shadow : {}, { type: "bi.layout", - cls: "bi-button-mask" + cls: "bi-button-mask", }); self.$mask.invisible(); BI.createWidget({ @@ -78,11 +79,11 @@ BI.BasicButton = BI.inherit(BI.Single, { left: 0, right: 0, top: 0, - bottom: 0 - }] + bottom: 0, + }], }); } - }; + } this.element.mouseup(function () { if (!self._hover && !o.isShadowShowingOnSelected) { @@ -223,7 +224,7 @@ BI.BasicButton = BI.inherit(BI.Single, { // 之后的300ms点击无效 var onClick = BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { "leading": true, - "trailing": false + "trailing": false, }); function ev(e) { @@ -257,7 +258,7 @@ BI.BasicButton = BI.inherit(BI.Single, { }, el: { type: "bi.layout", - height: "100%" + height: "100%", }, popup: { type: "bi.text_bubble_bar_popup_view", @@ -272,21 +273,21 @@ BI.BasicButton = BI.inherit(BI.Single, { if (v) { onClick.apply(self, arguments); } - } - }] + }, + }], }, listeners: [{ eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, action: function () { popup.populate(getBubble()); - } - }] + }, + }], }, left: 0, right: 0, bottom: 0, - top: 0 - }] + top: 0, + }], }); } if (self.combo.isViewVisible()) { @@ -294,6 +295,7 @@ BI.BasicButton = BI.inherit(BI.Single, { } else { self.combo.showView(); } + return; } onClick.apply(self, arguments); @@ -304,6 +306,7 @@ BI.BasicButton = BI.inherit(BI.Single, { if (BI.isFunction(bubble)) { return bubble(); } + return bubble; } }, @@ -436,7 +439,7 @@ BI.BasicButton = BI.inherit(BI.Single, { empty: function () { BI.Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); BI.BasicButton.superclass.empty.apply(this, arguments); - } + }, }); BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE"; BI.shortcut("bi.basic_button", BI.BasicButton); diff --git a/src/base/single/button/button.node.js b/src/base/single/button/button.node.js index 8e17a4ea5..744cfe28f 100644 --- a/src/base/single/button/button.node.js +++ b/src/base/single/button/button.node.js @@ -9,9 +9,10 @@ BI.NodeButton = BI.inherit(BI.BasicButton, { _defaultConfig: function () { var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { _baseCls: (conf._baseCls || "") + " bi-node", - open: false + open: false, }); }, @@ -51,6 +52,6 @@ BI.NodeButton = BI.inherit(BI.BasicButton, { this.setOpened(true); this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); } - } + }, }); BI.shortcut("bi.node_button", BI.NodeButton); diff --git a/src/base/single/button/node/__test__/icontexticonnode.test.js b/src/base/single/button/node/__test__/icontexticonnode.test.js index ae2a8fbb4..b76324283 100644 --- a/src/base/single/button/node/__test__/icontexticonnode.test.js +++ b/src/base/single/button/node/__test__/icontexticonnode.test.js @@ -4,13 +4,12 @@ */ describe("IconTextIconNodeTest", function () { - /** * test_author_kobi */ it("setText", function () { var iconTextIconNode = BI.Test.createWidget({ - type: "bi.icon_text_icon_node" + type: "bi.icon_text_icon_node", }); iconTextIconNode.setText("AAA"); expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); @@ -34,7 +33,7 @@ describe("IconTextIconNodeTest", function () { */ it("setValue", function () { var iconTextIconNode = BI.Test.createWidget({ - type: "bi.icon_text_icon_node" + type: "bi.icon_text_icon_node", }); iconTextIconNode.setValue("AAA"); expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); @@ -48,7 +47,7 @@ describe("IconTextIconNodeTest", function () { var iconTextIconNode = BI.Test.createWidget({ type: "bi.icon_text_icon_node", value: "AAA", - readonly: true + readonly: true, }); iconTextIconNode.setValue("BBB"); expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); @@ -61,7 +60,7 @@ describe("IconTextIconNodeTest", function () { it("getValue", function () { var iconTextIconNode = BI.Test.createWidget({ type: "bi.icon_text_icon_node", - value: "AAA" + value: "AAA", }); expect(iconTextIconNode.getValue()).to.equal("AAA"); iconTextIconNode.destroy(); @@ -91,7 +90,7 @@ describe("IconTextIconNodeTest", function () { text: "AAA", handler: function () { this.setText("click"); - } + }, }); BI.nextTick(function () { iconTextIconNode.element.click(); @@ -100,5 +99,4 @@ describe("IconTextIconNodeTest", function () { done(); }); }); - }); diff --git a/src/base/single/button/node/__test__/icontextnode.test.js b/src/base/single/button/node/__test__/icontextnode.test.js index 2319e23e2..25b6ebc9f 100644 --- a/src/base/single/button/node/__test__/icontextnode.test.js +++ b/src/base/single/button/node/__test__/icontextnode.test.js @@ -4,13 +4,12 @@ */ describe("IconTextNodeTest", function () { - /** * test_author_kobi */ it("setText", function () { var iconTextNode = BI.Test.createWidget({ - type: "bi.icon_text_node" + type: "bi.icon_text_node", }); iconTextNode.setText("AAA"); expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); @@ -34,7 +33,7 @@ describe("IconTextNodeTest", function () { */ it("setValue", function () { var iconTextNode = BI.Test.createWidget({ - type: "bi.icon_text_node" + type: "bi.icon_text_node", }); iconTextNode.setValue("AAA"); expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); @@ -48,7 +47,7 @@ describe("IconTextNodeTest", function () { var iconTextNode = BI.Test.createWidget({ type: "bi.icon_text_node", value: "AAA", - readonly: true + readonly: true, }); iconTextNode.setValue("BBB"); expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); @@ -61,7 +60,7 @@ describe("IconTextNodeTest", function () { it("getValue", function () { var iconTextNode = BI.Test.createWidget({ type: "bi.icon_text_node", - value: "AAA" + value: "AAA", }); expect(iconTextNode.getValue()).to.equal("AAA"); iconTextNode.destroy(); @@ -91,7 +90,7 @@ describe("IconTextNodeTest", function () { text: "AAA", handler: function () { this.setText("click"); - } + }, }); BI.nextTick(function () { iconTextNode.element.click(); @@ -100,5 +99,4 @@ describe("IconTextNodeTest", function () { done(); }); }); - }); diff --git a/src/base/single/button/node/__test__/texticonnode.test.js b/src/base/single/button/node/__test__/texticonnode.test.js index 9eb4ec2db..1523f8ce6 100644 --- a/src/base/single/button/node/__test__/texticonnode.test.js +++ b/src/base/single/button/node/__test__/texticonnode.test.js @@ -4,13 +4,12 @@ */ describe("TextIconNodeTest", function () { - /** * test_author_kobi */ it("setText", function () { var textIconNode = BI.Test.createWidget({ - type: "bi.text_icon_node" + type: "bi.text_icon_node", }); textIconNode.setText("AAA"); expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); @@ -34,7 +33,7 @@ describe("TextIconNodeTest", function () { */ it("setValue", function () { var textIconNode = BI.Test.createWidget({ - type: "bi.text_icon_node" + type: "bi.text_icon_node", }); textIconNode.setValue("AAA"); expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); @@ -48,7 +47,7 @@ describe("TextIconNodeTest", function () { var textIconNode = BI.Test.createWidget({ type: "bi.text_icon_node", value: "AAA", - readonly: true + readonly: true, }); textIconNode.setValue("BBB"); expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); @@ -61,7 +60,7 @@ describe("TextIconNodeTest", function () { it("getValue", function () { var textIconNode = BI.Test.createWidget({ type: "bi.text_icon_node", - value: "AAA" + value: "AAA", }); expect(textIconNode.getValue()).to.equal("AAA"); textIconNode.destroy(); @@ -91,7 +90,7 @@ describe("TextIconNodeTest", function () { text: "AAA", handler: function () { this.setText("click"); - } + }, }); BI.nextTick(function () { textIconNode.element.click(); @@ -100,5 +99,4 @@ describe("TextIconNodeTest", function () { done(); }); }); - }); diff --git a/src/base/single/button/node/__test__/textnode.test.js b/src/base/single/button/node/__test__/textnode.test.js index 5674ae263..7b78bbb6b 100644 --- a/src/base/single/button/node/__test__/textnode.test.js +++ b/src/base/single/button/node/__test__/textnode.test.js @@ -4,13 +4,12 @@ */ describe("TextNodeTest", function () { - /** * test_author_kobi */ it("setText", function () { var textNode = BI.Test.createWidget({ - type: "bi.text_node" + type: "bi.text_node", }); textNode.setText("AAA"); expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); @@ -24,7 +23,7 @@ describe("TextNodeTest", function () { var textNode = BI.Test.createWidget({ type: "bi.text_node", text: "AAA", - whiteSpace: "normal" + whiteSpace: "normal", }); expect(textNode.getText()).to.equal("AAA"); textNode.destroy(); @@ -35,7 +34,7 @@ describe("TextNodeTest", function () { */ it("setValue", function () { var textNode = BI.Test.createWidget({ - type: "bi.text_node" + type: "bi.text_node", }); textNode.setValue("AAA"); expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); @@ -49,7 +48,7 @@ describe("TextNodeTest", function () { var textNode = BI.Test.createWidget({ type: "bi.text_node", value: "AAA", - readonly: true + readonly: true, }); textNode.setValue("BBB"); expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); @@ -62,7 +61,7 @@ describe("TextNodeTest", function () { it("getValue", function () { var textNode = BI.Test.createWidget({ type: "bi.text_node", - value: "AAA" + value: "AAA", }); expect(textNode.getValue()).to.equal("AAA"); textNode.destroy(); @@ -92,7 +91,7 @@ describe("TextNodeTest", function () { text: "AAA", handler: function () { this.setText("click"); - } + }, }); BI.nextTick(function () { textNode.element.click(); @@ -101,6 +100,4 @@ describe("TextNodeTest", function () { done(); }); }); - - }); diff --git a/src/base/single/button/node/icontexticonnode.js b/src/base/single/button/node/icontexticonnode.js index 13d967425..7569490eb 100644 --- a/src/base/single/button/node/icontexticonnode.js +++ b/src/base/single/button/node/icontexticonnode.js @@ -8,6 +8,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { _defaultConfig: function () { var conf = BI.IconTextIconNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node", iconCls1: "close-ha-font", @@ -17,7 +18,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { textHgap: 0, textVgap: 0, textLgap: 0, - textRgap: 0 + textRgap: 0, }); }, @@ -33,7 +34,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { width: o.leftIconWrapperWidth || o.height, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, }, { el: { type: "bi.label", @@ -48,16 +49,16 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, keyword: o.keyword, - height: o.height - } + height: o.height, + }, }, { type: "bi.icon_label", cls: o.iconCls2, width: o.rightIconWrapperWidth || o.height, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight - }] + iconHeight: o.iconHeight, + }], }; }, @@ -92,7 +93,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, { getText: function () { return this.text.getText(); - } + }, }); BI.IconTextIconNode.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.icon_text_icon_node", BI.IconTextIconNode); diff --git a/src/base/single/button/node/icontextnode.js b/src/base/single/button/node/icontextnode.js index 5c9f1a4ca..16383cc7d 100644 --- a/src/base/single/button/node/icontextnode.js +++ b/src/base/single/button/node/icontextnode.js @@ -8,6 +8,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { _defaultConfig: function () { var conf = BI.IconTextNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-icon-text-node", cls: "close-ha-font", @@ -16,7 +17,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { textHgap: 0, textVgap: 0, textLgap: 0, - textRgap: 0 + textRgap: 0, }); }, @@ -32,7 +33,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { width: o.iconWrapperWidth || o.height, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, }, { el: { type: "bi.label", @@ -48,9 +49,9 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, keyword: o.keyword, - height: o.height - } - }] + height: o.height, + }, + }], }; }, @@ -85,7 +86,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { unRedMark: function () { this.text.unRedMark.apply(this.text, arguments); - } + }, }); BI.IconTextNode.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.icon_text_node", BI.IconTextNode); diff --git a/src/base/single/button/node/texticonnode.js b/src/base/single/button/node/texticonnode.js index 6671c19a1..01167b009 100644 --- a/src/base/single/button/node/texticonnode.js +++ b/src/base/single/button/node/texticonnode.js @@ -7,6 +7,7 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, { _defaultConfig: function () { var conf = BI.TextIconNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-text-icon-node", cls: "close-ha-font", @@ -15,7 +16,7 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, { textHgap: 0, textVgap: 0, textLgap: 0, - textRgap: 0 + textRgap: 0, }); }, @@ -40,16 +41,16 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, keyword: o.keyword, - height: o.height - } + height: o.height, + }, }, { type: "bi.icon_label", cls: o.iconCls, width: o.iconWrapperWidth || o.height, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight - }] + iconHeight: o.iconHeight, + }], }; }, @@ -84,7 +85,7 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, { unRedMark: function () { this.text.unRedMark.apply(this.text, arguments); - } + }, }); BI.TextIconNode.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.text_icon_node", BI.TextIconNode); diff --git a/src/base/single/button/node/textnode.js b/src/base/single/button/node/textnode.js index 74974456c..6ecaa3fbf 100644 --- a/src/base/single/button/node/textnode.js +++ b/src/base/single/button/node/textnode.js @@ -9,6 +9,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, { _defaultConfig: function () { var conf = BI.TextNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-text-node", textAlign: "left", @@ -16,7 +17,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, { textHgap: 0, textVgap: 0, textLgap: 0, - textRgap: 0 + textRgap: 0, }); }, @@ -27,7 +28,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, { element: this, textAlign: o.textAlign, whiteSpace: o.whiteSpace, - textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight, + textHeight: o.whiteSpace === "nowrap" ? o.height : o.textHeight, height: o.height, hgap: o.textHgap, vgap: o.textVgap, @@ -36,7 +37,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, { text: o.text, value: o.value, keyword: o.keyword, - py: o.py + py: o.py, }); }, @@ -71,7 +72,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, { getText: function () { return this.text.getText(); - } + }, }); BI.TextNode.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.text_node", BI.TextNode); diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 5322124d9..ac9e779e9 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -38,7 +38,7 @@ BI.Editor = BI.inherit(BI.Single, { watermark: o.watermark, validationChecker: o.validationChecker, quitChecker: o.quitChecker, - allowBlank: o.allowBlank + allowBlank: o.allowBlank, })); this.editor.element.css({ width: "100%", @@ -46,7 +46,7 @@ BI.Editor = BI.inherit(BI.Single, { border: "none", outline: "none", padding: "0", - margin: "0" + margin: "0", }); var items = [{ @@ -60,19 +60,19 @@ BI.Editor = BI.inherit(BI.Single, { left: 0, right: 0, top: 0, - bottom: 0 - }] + bottom: 0, + }], }, left: o.hgap + o.lgap, right: o.hgap + o.rgap, top: o.vgap + o.tgap, - bottom: o.vgap + o.bgap + bottom: o.vgap + o.bgap, }]; BI.createWidget({ type: "bi.absolute", element: this, - items: items + items: items, }); this.setWaterMark(this.options.watermark); @@ -159,6 +159,7 @@ BI.Editor = BI.inherit(BI.Single, { }); this.element.click(function (e) { e.stopPropagation(); + return false; }); if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { @@ -194,7 +195,7 @@ BI.Editor = BI.inherit(BI.Single, { height: o.height - 2 * o.vgap - o.tgap, hgap: 2, whiteSpace: "nowrap", - textAlign: "left" + textAlign: "left", }); this.watermark.element.bind({ mousedown: function (e) { @@ -204,7 +205,7 @@ BI.Editor = BI.inherit(BI.Single, { self.editor.isEditing() && self.editor.blur(); } e.stopEvent(); - } + }, }); this.watermark.element.bind("click", function (e) { if (self.isEnabled()) { @@ -240,7 +241,6 @@ BI.Editor = BI.inherit(BI.Single, { }, setWaterMark: function (v) { - this.options.watermark = v; if (BI.isNull(this.watermark)) { @@ -269,7 +269,7 @@ BI.Editor = BI.inherit(BI.Single, { } if (!this.disabledError && BI.isKey(errorText)) { BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, { - adjustYOffset: o.simple ? 1 : 2 + adjustYOffset: o.simple ? 1 : 2, }); this._checkToolTip(); } @@ -332,6 +332,7 @@ BI.Editor = BI.inherit(BI.Single, { if (!this.isValid()) { return BI.trim(this.editor.getLastValidValue()); } + return BI.trim(this.editor.getValue()); }, @@ -345,7 +346,7 @@ BI.Editor = BI.inherit(BI.Single, { destroyed: function () { BI.Bubbles.remove(this.getName()); - } + }, }); BI.Editor.EVENT_CHANGE = "EVENT_CHANGE"; BI.Editor.EVENT_FOCUS = "EVENT_FOCUS"; diff --git a/src/base/single/editor/editor.multifile.js b/src/base/single/editor/editor.multifile.js index ae0d5e0a9..21765474d 100644 --- a/src/base/single/editor/editor.multifile.js +++ b/src/base/single/editor/editor.multifile.js @@ -9,12 +9,13 @@ BI.MultifileEditor = BI.inherit(BI.Widget, { _defaultConfig: function () { var conf = BI.MultifileEditor.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-multifile-editor", multiple: false, maxSize: -1, // 1024 * 1024 accept: "", - url: "" + url: "", }); }, @@ -57,13 +58,13 @@ BI.MultifileEditor = BI.inherit(BI.Widget, { el: { type: "bi.adaptive", scrollable: false, - items: [this.file] + items: [this.file], }, top: 0, right: 0, left: 0, - bottom: 0 - }] + bottom: 0, + }], }); }, @@ -104,7 +105,7 @@ BI.MultifileEditor = BI.inherit(BI.Widget, { reset: function () { this._reset(); - } + }, }); BI.MultifileEditor.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultifileEditor.EVENT_UPLOADSTART = "EVENT_UPLOADSTART"; diff --git a/src/base/single/html/__test__/html.test.js b/src/base/single/html/__test__/html.test.js index 2d599ecd7..1414b1e59 100644 --- a/src/base/single/html/__test__/html.test.js +++ b/src/base/single/html/__test__/html.test.js @@ -5,14 +5,13 @@ */ describe("HtmlTest", function () { - /** * test_author_windy */ it("html_h1", function () { var a = BI.Test.createWidget({ type: "bi.html", - text: "

在bi.html标签中使用html原生标签

" + text: "

在bi.html标签中使用html原生标签

", }); expect(a.element.find("h1").length).to.equal(1); a.destroy(); @@ -32,11 +31,11 @@ describe("HtmlTest", function () { highLight: true, hgap: 10, vgap: 10, - handler: BI.emptyFn + handler: BI.emptyFn, }); a.setValue("DDDDD"); - a.setStyle({"background-color": "red"}); + a.setStyle({ "background-color": "red" }); expect(a.text.element.css("background-color")).to.equal("rgb(255, 0, 0)"); a.destroy(); }); -}); \ No newline at end of file +}); diff --git a/src/base/single/html/html.js b/src/base/single/html/html.js index af88bac2c..9abbb2149 100644 --- a/src/base/single/html/html.js +++ b/src/base/single/html/html.js @@ -25,43 +25,43 @@ BI.Html = BI.inherit(BI.Single, { var self = this, o = this.options; if (o.hgap + o.lgap > 0) { this.element.css({ - "padding-left": (o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit + "padding-left": (o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit, }); } if (o.hgap + o.rgap > 0) { this.element.css({ - "padding-right": (o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit + "padding-right": (o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit, }); } if (o.vgap + o.tgap > 0) { this.element.css({ - "padding-top": (o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit + "padding-top": (o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit, }); } if (o.vgap + o.bgap > 0) { this.element.css({ - "padding-bottom": (o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit + "padding-bottom": (o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit, }); } if (BI.isNumber(o.height)) { - this.element.css({lineHeight: o.height / BI.pixRatio + BI.pixUnit}); + this.element.css({ lineHeight: o.height / BI.pixRatio + BI.pixUnit }); } if (BI.isNumber(o.lineHeight)) { - this.element.css({lineHeight: o.lineHeight / BI.pixRatio + BI.pixUnit}); + this.element.css({ lineHeight: o.lineHeight / BI.pixRatio + BI.pixUnit }); } if (BI.isWidthOrHeight(o.maxWidth)) { - this.element.css({maxWidth: o.maxWidth}); + this.element.css({ maxWidth: o.maxWidth }); } this.element.css({ textAlign: o.textAlign, whiteSpace: o.whiteSpace, - textOverflow: o.whiteSpace === 'nowrap' ? "ellipsis" : "", - overflow: o.whiteSpace === "nowrap" ? "" : "auto" + textOverflow: o.whiteSpace === "nowrap" ? "ellipsis" : "", + overflow: o.whiteSpace === "nowrap" ? "" : "auto", }); if (o.handler) { this.text = BI.createWidget({ type: "bi.layout", - tagName: "span" + tagName: "span", }); this.text.element.click(function () { o.handler(self.getValue()); @@ -69,7 +69,7 @@ BI.Html = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.default", element: this, - items: [this.text] + items: [this.text], }); } else { this.text = this; @@ -108,7 +108,7 @@ BI.Html = BI.inherit(BI.Single, { BI.Html.superclass.setText.apply(this, arguments); this.options.text = text; this.text.element.html(text); - } + }, }); BI.shortcut("bi.html", BI.Html); diff --git a/src/base/single/icon/icon.js b/src/base/single/icon/icon.js index 112ea539a..916206bbd 100644 --- a/src/base/single/icon/icon.js +++ b/src/base/single/icon/icon.js @@ -6,9 +6,10 @@ BI.Icon = BI.inherit(BI.Single, { _defaultConfig: function () { var conf = BI.Icon.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { tagName: "i", - baseCls: (conf.baseCls || "") + " x-icon b-font horizon-center display-block" + baseCls: (conf.baseCls || "") + " x-icon b-font horizon-center display-block", }); }, @@ -16,6 +17,6 @@ BI.Icon = BI.inherit(BI.Single, { if (BI.isIE9Below && BI.isIE9Below()) { this.element.addClass("hack"); } - } + }, }); BI.shortcut("bi.icon", BI.Icon); diff --git a/src/base/single/iframe/__test__/iframe.test.js b/src/base/single/iframe/__test__/iframe.test.js index 8e99a48a0..9a9049ebc 100644 --- a/src/base/single/iframe/__test__/iframe.test.js +++ b/src/base/single/iframe/__test__/iframe.test.js @@ -5,13 +5,12 @@ */ describe("IframeTest", function () { - /** * test_author_windy */ it("directionPager", function () { var a = BI.Test.createWidget({ - type: "bi.iframe" + type: "bi.iframe", }); a.setSrc("http://www.baidu.com"); a.setName("testIFrame"); @@ -20,4 +19,4 @@ describe("IframeTest", function () { expect(a.getName(), "testIFrame"); a.destroy(); }); -}); \ No newline at end of file +}); diff --git a/src/base/single/iframe/iframe.js b/src/base/single/iframe/iframe.js index a7137fa58..e2df49e25 100644 --- a/src/base/single/iframe/iframe.js +++ b/src/base/single/iframe/iframe.js @@ -7,6 +7,7 @@ BI.Iframe = BI.inherit(BI.Single, { _defaultConfig: function (config) { var conf = BI.Iframe.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { tagName: "iframe", baseCls: (conf.baseCls || "") + " bi-iframe", @@ -14,7 +15,7 @@ BI.Iframe = BI.inherit(BI.Single, { name: "", attributes: {}, width: "100%", - height: "100%" + height: "100%", }); }, @@ -31,7 +32,7 @@ BI.Iframe = BI.inherit(BI.Single, { this.options.attributes = BI.extend({ frameborder: 0, src: o.src, - name: o.name + name: o.name, }, this.options.attributes); }, @@ -51,7 +52,7 @@ BI.Iframe = BI.inherit(BI.Single, { getName: function () { return this.options.name; - } + }, }); BI.shortcut("bi.iframe", BI.Iframe); diff --git a/src/base/single/img/__test__/img.test.js b/src/base/single/img/__test__/img.test.js index d16ca92d8..95c892b58 100644 --- a/src/base/single/img/__test__/img.test.js +++ b/src/base/single/img/__test__/img.test.js @@ -5,7 +5,6 @@ */ describe("ImgTest", function () { - /** * test_author_windy */ @@ -13,11 +12,11 @@ describe("ImgTest", function () { var a = BI.Test.createWidget({ type: "bi.img", iconWidth: 36, - iconHeight: 36 + iconHeight: 36, }); a.setSrc("test.png"); expect(a.element.attr("src")).to.equal("test.png"); expect(a.getSrc()).to.equal("test.png"); a.destroy(); }); -}); \ No newline at end of file +}); diff --git a/src/base/single/img/img.js b/src/base/single/img/img.js index aa90aaf40..ca715fb79 100644 --- a/src/base/single/img/img.js +++ b/src/base/single/img/img.js @@ -9,13 +9,14 @@ BI.Img = BI.inherit(BI.Single, { _defaultConfig: function (config) { var conf = BI.Img.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { tagName: "img", baseCls: (conf.baseCls || "") + " bi-img display-block", src: "", attributes: config.src ? { src: config.src } : {}, width: "100%", - height: "100%" + height: "100%", }); }, @@ -23,7 +24,7 @@ BI.Img = BI.inherit(BI.Single, { BI.Img.superclass._initProps.apply(this, arguments); var o = this.options; this.options.attributes = BI.extend({ - src: o.src + src: o.src, }, this.options.attributes); }, @@ -34,7 +35,7 @@ BI.Img = BI.inherit(BI.Single, { getSrc: function () { return this.options.src; - } + }, }); BI.shortcut("bi.img", BI.Img); diff --git a/src/base/single/input/checkbox/checkbox.image.js b/src/base/single/input/checkbox/checkbox.image.js index dc1703567..0400f6530 100644 --- a/src/base/single/input/checkbox/checkbox.image.js +++ b/src/base/single/input/checkbox/checkbox.image.js @@ -6,6 +6,7 @@ BI.ImageCheckbox = BI.inherit(BI.IconButton, { _defaultConfig: function () { var conf = BI.ImageCheckbox.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-image-checkbox check-box-icon", selected: false, @@ -13,10 +14,10 @@ BI.ImageCheckbox = BI.inherit(BI.IconButton, { width: 16, height: 16, iconWidth: 16, - iconHeight: 16 + iconHeight: 16, }); - } + }, }); BI.ImageCheckbox.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE; -BI.shortcut("bi.image_checkbox", BI.ImageCheckbox); \ No newline at end of file +BI.shortcut("bi.image_checkbox", BI.ImageCheckbox); diff --git a/src/base/single/input/checkbox/checkbox.js b/src/base/single/input/checkbox/checkbox.js index 4a72f431f..b25d743e8 100644 --- a/src/base/single/input/checkbox/checkbox.js +++ b/src/base/single/input/checkbox/checkbox.js @@ -12,11 +12,12 @@ BI.Checkbox = BI.inherit(BI.BasicButton, { width: 14, height: 14, iconWidth: 14, - iconHeight: 14 + iconHeight: 14, }, render: function () { var self = this, o = this.options; + return { type: "bi.center_adapt", items: [{ @@ -26,8 +27,8 @@ BI.Checkbox = BI.inherit(BI.BasicButton, { }, cls: "checkbox-content", width: o.iconWidth, - height: o.iconHeight - }] + height: o.iconHeight, + }], }; }, @@ -42,7 +43,7 @@ BI.Checkbox = BI.inherit(BI.BasicButton, { doClick: function () { BI.Checkbox.superclass.doClick.apply(this, arguments); - if(this.isValid()) { + if (this.isValid()) { this.fireEvent(BI.Checkbox.EVENT_CHANGE); } }, @@ -54,7 +55,7 @@ BI.Checkbox = BI.inherit(BI.BasicButton, { } else { this.checkbox.element.removeClass("bi-high-light-background"); } - } + }, }); BI.Checkbox.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index e868a5747..8f20bddbb 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -7,12 +7,13 @@ BI.Input = BI.inherit(BI.Single, { _defaultConfig: function () { var conf = BI.Input.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-input display-block overflow-dot", tagName: "input", validationChecker: BI.emptyFn, quitChecker: BI.emptyFn, // 按确定键能否退出编辑 - allowBlank: false + allowBlank: false, }); }, @@ -27,15 +28,15 @@ BI.Input = BI.inherit(BI.Single, { }, BI.EVENT_RESPONSE_TIME); var _clk = BI.debounce(BI.bind(this._click, this), BI.EVENT_RESPONSE_TIME, { "leading": true, - "trailing": false + "trailing": false, }); this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, { "leading": true, - "trailing": false + "trailing": false, }); this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, { "leading": true, - "trailing": false + "trailing": false, }); this.element .keydown(function (e) { @@ -86,7 +87,7 @@ BI.Input = BI.inherit(BI.Single, { this.element.addClass("bi-input-focus"); this._checkValidationOnValueChange(); this._isEditing = true; - if (this.getValue() == "") { + if (this.getValue() === "") { this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this); this.fireEvent(BI.Input.EVENT_EMPTY); } @@ -139,7 +140,7 @@ BI.Input = BI.inherit(BI.Single, { this._checkValidationOnValueChange(); } if (this.isValid() && BI.trim(this.getValue()) !== "") { - if (BI.trim(this.getValue()) !== this._lastValue && (!this._start || this._lastValue == null || this._lastValue === "") + if (BI.trim(this.getValue()) !== this._lastValue && (!this._start || BI.isNull(this._lastValue) || this._lastValue === "") || (this._pause === true && !/(\s|\u00A0)$/.test(this.getValue()))) { this._start = true; this._pause = false; @@ -147,7 +148,7 @@ BI.Input = BI.inherit(BI.Single, { this.fireEvent(BI.Input.EVENT_START); } } - if (keyCode == BI.KeyCode.ENTER) { + if (BI.isEqual(keyCode, BI.KeyCode.ENTER)) { if (this.isValid() || this.options.quitChecker.apply(this, [BI.trim(this.getValue())]) !== false) { this.blur(); this.fireEvent(BI.Input.EVENT_ENTER); @@ -155,20 +156,20 @@ BI.Input = BI.inherit(BI.Single, { this.fireEvent(BI.Input.EVENT_RESTRICT); } } - if (keyCode == BI.KeyCode.SPACE) { + if (BI.isEqual(keyCode, BI.KeyCode.SPACE)) { this.fireEvent(BI.Input.EVENT_SPACE); } - if (keyCode == BI.KeyCode.BACKSPACE && this._lastValue == "") { + if (BI.isEqual(keyCode, BI.KeyCode.BACKSPACE) && this._lastValue === "") { this.fireEvent(BI.Input.EVENT_REMOVE); } - if (keyCode == BI.KeyCode.BACKSPACE || keyCode == BI.KeyCode.DELETE) { + if (BI.isEqual(keyCode, BI.KeyCode.BACKSPACE) || BI.isEqual(keyCode, BI.KeyCode.DELETE)) { this.fireEvent(BI.Input.EVENT_BACKSPACE); } this.fireEvent(BI.Input.EVENT_KEY_DOWN, arguments); // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 var lastValue = this._lastValue; - if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ + if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) { this._valueChange(); } if (BI.isEndWithBlank(this.getValue())) { @@ -185,7 +186,7 @@ BI.Input = BI.inherit(BI.Single, { // 初始状态 _defaultState: function () { - if (this.getValue() == "") { + if (this.getValue() === "") { this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this); this.fireEvent(BI.Input.EVENT_EMPTY); } @@ -199,7 +200,7 @@ BI.Input = BI.inherit(BI.Single, { this.fireEvent(BI.Input.EVENT_CHANGE); this._lastSubmitValue = BI.trim(this.getValue()); } - if (this.getValue() == "") { + if (this.getValue() === "") { this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this); this.fireEvent(BI.Input.EVENT_EMPTY); } @@ -209,14 +210,16 @@ BI.Input = BI.inherit(BI.Single, { _checkValidationOnValueChange: function (callback) { var self = this, o = this.options; var v = this.getValue(); - if (o.allowBlank === true && BI.trim(v) == "") { + if (o.allowBlank === true && BI.trim(v) === "") { this.setValid(true); callback && callback(); + return; } - if (BI.trim(v) == "") { + if (BI.trim(v) === "") { this.setValid(false); callback && callback(); + return; } var checker = o.validationChecker.apply(this, [BI.trim(v)]); @@ -224,7 +227,7 @@ BI.Input = BI.inherit(BI.Single, { checker.then(function (validate) { self.setValid(validate !== false); callback && callback(); - }) + }); } else { this.setValid(checker !== false); callback && callback(); @@ -306,7 +309,7 @@ BI.Input = BI.inherit(BI.Single, { _setEnable: function (b) { BI.Input.superclass._setEnable.apply(this, [b]); this.element[0].disabled = !b; - } + }, }); BI.Input.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/base/single/input/radio/radio.image.js b/src/base/single/input/radio/radio.image.js index e362592e4..f9d870f63 100644 --- a/src/base/single/input/radio/radio.image.js +++ b/src/base/single/input/radio/radio.image.js @@ -6,6 +6,7 @@ BI.ImageRadio = BI.inherit(BI.IconButton, { _defaultConfig: function () { var conf = BI.ImageRadio.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-radio radio-icon", selected: false, @@ -13,16 +14,16 @@ BI.ImageRadio = BI.inherit(BI.IconButton, { width: 16, height: 16, iconWidth: 16, - iconHeight: 16 + iconHeight: 16, }); }, doClick: function () { BI.ImageRadio.superclass.doClick.apply(this, arguments); - if(this.isValid()) { + if (this.isValid()) { this.fireEvent(BI.ImageRadio.EVENT_CHANGE); } - } + }, }); BI.ImageRadio.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE; diff --git a/src/base/single/input/radio/radio.js b/src/base/single/input/radio/radio.js index f17e79e9e..d842196ae 100644 --- a/src/base/single/input/radio/radio.js +++ b/src/base/single/input/radio/radio.js @@ -12,11 +12,12 @@ BI.Radio = BI.inherit(BI.BasicButton, { width: 14, height: 14, iconWidth: 14, - iconHeight: 14 + iconHeight: 14, }, render: function () { var self = this, o = this.options; + return { type: "bi.center_adapt", items: [{ @@ -26,8 +27,8 @@ BI.Radio = BI.inherit(BI.BasicButton, { self.radio = _ref; }, width: o.iconWidth, - height: o.iconHeight - }] + height: o.iconHeight, + }], }; }, @@ -42,7 +43,7 @@ BI.Radio = BI.inherit(BI.BasicButton, { doClick: function () { BI.Radio.superclass.doClick.apply(this, arguments); - if(this.isValid()) { + if (this.isValid()) { this.fireEvent(BI.Radio.EVENT_CHANGE); } }, @@ -54,7 +55,7 @@ BI.Radio = BI.inherit(BI.BasicButton, { } else { this.radio.element.removeClass("bi-high-light-background"); } - } + }, }); BI.Radio.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/base/single/tip/0.tip.js b/src/base/single/tip/0.tip.js index a57d90a2f..a13240d8b 100644 --- a/src/base/single/tip/0.tip.js +++ b/src/base/single/tip/0.tip.js @@ -18,6 +18,6 @@ BI.Tip = BI.inherit(BI.Single, { _init: function () { BI.Tip.superclass._init.apply(this, arguments); - this.element.css({ zIndex: this.options.zIndex, }); + this.element.css({ zIndex: this.options.zIndex }); }, }); diff --git a/src/base/tree/customtree.js b/src/base/tree/customtree.js index 9b2cf1b6a..c20af875a 100644 --- a/src/base/tree/customtree.js +++ b/src/base/tree/customtree.js @@ -47,7 +47,7 @@ BI.CustomTree = BI.inherit(BI.Widget, { el: { value: node.value, }, - popup: { type: "bi.custom_tree", }, + popup: { type: "bi.custom_tree" }, }, BI.deepClone(o.expander), { id: node.id, pId: node.pId,