From ca119b93c9559bc79d1153e0b6636d9da24598a2 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 31 Jan 2022 00:01:54 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=8C=89=E9=92=AE=E6=94=AF=E6=8C=81en?= =?UTF-8?q?ter=E9=94=AE=E7=A1=AE=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/foundation/message.js | 25 +++++++++++++++++++ src/base/single/button/button.basic.js | 5 ---- src/base/single/button/buttons/button.js | 12 +++++++++ .../single/button/listitem/icontextitem.js | 14 +++++------ src/base/single/button/node/icontextnode.js | 14 +++++------ src/case/button/item.multiselect.js | 12 +++++++++ src/case/button/item.singleselect.icontext.js | 18 +++++++++---- src/case/button/item.singleselect.js | 12 +++++++++ src/case/button/item.singleselect.radio.js | 12 +++++++++ src/case/button/switch.js | 12 +++++++++ 10 files changed, 112 insertions(+), 24 deletions(-) diff --git a/src/base/foundation/message.js b/src/base/foundation/message.js index 9653995c3..860449ab4 100644 --- a/src/base/foundation/message.js +++ b/src/base/foundation/message.js @@ -133,6 +133,31 @@ BI.Msg = function () { items: [ { type: "bi.border", + attributes: { + tabIndex: 1 + }, + mounted: function () { + this.element.keyup(function (e) { + if (e.keyCode === BI.KeyCode.ENTER) { + close(); + if (BI.isFunction(callback)) { + callback.apply(null, [true]); + } + } else if (e.keyCode === BI.KeyCode.ESCAPE) { + close(); + if (hasCancel === true) { + if (BI.isFunction(callback)) { + callback.apply(null, [false]); + } + } + } + }); + try { + this.element.focus(); + } catch (e) { + + } + }, cls: "bi-card", items: { north: { diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index 5640dea30..e3d8a1493 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -11,9 +11,6 @@ BI.BasicButton = BI.inherit(BI.Single, { return BI.extend(conf, { _baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), // el: {} // 可以通过el来创建button元素 - attributes: { - tabIndex: 1 - }, value: "", stopEvent: false, stopPropagation: false, @@ -412,10 +409,8 @@ BI.BasicButton = BI.inherit(BI.Single, { BI.BasicButton.superclass._setEnable.apply(this, arguments); if (enable === true) { this.element.removeClass("base-disabled disabled"); - this.element.attr("tabIndex", 1); } else if (enable === false) { this.element.addClass("base-disabled disabled"); - this.element.removeAttr("tabIndex"); } if (!enable) { if (this.options.shadow) { diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 4337a9540..0863d0935 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -16,6 +16,9 @@ BI.Button = BI.inherit(BI.BasicButton, { var conf = BI.Button.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""), + attributes: { + tabIndex: 1 + }, minWidth: (props.block === true || props.clear === true) ? 0 : 80, height: 24, shadow: props.clear !== true, @@ -125,6 +128,15 @@ BI.Button = BI.inherit(BI.BasicButton, { } }, + _setEnable: function (enable) { + BI.Button.superclass._setEnable.apply(this, arguments); + if (enable === true) { + this.element.attr("tabIndex", 1); + } else if (enable === false) { + this.element.removeAttr("tabIndex"); + } + }, + setText: function (text) { BI.Button.superclass.setText.apply(this, arguments); this.text.setText(text); diff --git a/src/base/single/button/listitem/icontextitem.js b/src/base/single/button/listitem/icontextitem.js index 648b98381..44f83f376 100644 --- a/src/base/single/button/listitem/icontextitem.js +++ b/src/base/single/button/listitem/icontextitem.js @@ -57,6 +57,13 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, { })))); }, + doClick: function () { + BI.IconTextItem.superclass.doClick.apply(this, arguments); + if (this.isValid()) { + this.fireEvent(BI.IconTextItem.EVENT_CHANGE, this.getValue(), this); + } + }, + setValue: function () { if (!this.isReadOnly()) { this.text.setValue.apply(this.text, arguments); @@ -75,13 +82,6 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, { return this.text.getText(); }, - doClick: function () { - BI.IconTextItem.superclass.doClick.apply(this, arguments); - if (this.isValid()) { - this.fireEvent(BI.IconTextItem.EVENT_CHANGE, this.getValue(), this); - } - }, - doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, diff --git a/src/base/single/button/node/icontextnode.js b/src/base/single/button/node/icontextnode.js index 35e5757b8..deb2c73be 100644 --- a/src/base/single/button/node/icontextnode.js +++ b/src/base/single/button/node/icontextnode.js @@ -53,6 +53,13 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { })))); }, + doClick: function () { + BI.IconTextNode.superclass.doClick.apply(this, arguments); + if (this.isValid()) { + this.fireEvent(BI.IconTextNode.EVENT_CHANGE, this.getValue(), this); + } + }, + setValue: function () { if (!this.isReadOnly()) { this.text.setValue.apply(this.text, arguments); @@ -71,13 +78,6 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, { return this.text.getText(); }, - doClick: function () { - BI.IconTextNode.superclass.doClick.apply(this, arguments); - if (this.isValid()) { - this.fireEvent(BI.IconTextNode.EVENT_CHANGE, this.getValue(), this); - } - }, - doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, diff --git a/src/case/button/item.multiselect.js b/src/case/button/item.multiselect.js index 965363418..8a082a16b 100644 --- a/src/case/button/item.multiselect.js +++ b/src/case/button/item.multiselect.js @@ -7,6 +7,9 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { _defaultConfig: function () { return BI.extend(BI.MultiSelectItem.superclass._defaultConfig.apply(this, arguments), { extraCls: "bi-multi-select-item", + attributes: { + tabIndex: 1 + }, height: 24, logic: { dynamic: false @@ -55,6 +58,15 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { })))); }, + _setEnable: function (enable) { + BI.MultiSelectItem.superclass._setEnable.apply(this, arguments); + if (enable === true) { + this.element.attr("tabIndex", 1); + } else if (enable === false) { + this.element.removeAttr("tabIndex"); + } + }, + doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, diff --git a/src/case/button/item.singleselect.icontext.js b/src/case/button/item.singleselect.icontext.js index 1a70d4c01..e1a3e4f05 100644 --- a/src/case/button/item.singleselect.icontext.js +++ b/src/case/button/item.singleselect.icontext.js @@ -8,6 +8,9 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { _defaultConfig: function () { return BI.extend(BI.SingleSelectIconTextItem.superclass._defaultConfig.apply(this, arguments), { extraCls: "bi-single-select-icon-text-item bi-list-item-active", + attributes: { + tabIndex: 1 + }, iconCls: "", height: 24 }); @@ -35,6 +38,15 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { }); }, + _setEnable: function (enable) { + BI.SingleSelectIconTextItem.superclass._setEnable.apply(this, arguments); + if (enable === true) { + this.element.attr("tabIndex", 1); + } else if (enable === false) { + this.element.removeAttr("tabIndex"); + } + }, + isSelected: function () { return this.text.isSelected(); }, @@ -49,11 +61,7 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { unRedMark: function () { this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.SingleSelectIconTextItem.superclass.doClick.apply(this, arguments); } }); -BI.shortcut("bi.single_select_icon_text_item", BI.SingleSelectIconTextItem); \ No newline at end of file +BI.shortcut("bi.single_select_icon_text_item", BI.SingleSelectIconTextItem); diff --git a/src/case/button/item.singleselect.js b/src/case/button/item.singleselect.js index 8c5931f15..030dcff8f 100644 --- a/src/case/button/item.singleselect.js +++ b/src/case/button/item.singleselect.js @@ -2,6 +2,9 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { _defaultConfig: function () { return BI.extend(BI.SingleSelectItem.superclass._defaultConfig.apply(this, arguments), { extraCls: "bi-single-select-item bi-list-item-active", + attributes: { + tabIndex: 1 + }, hgap: 10, height: 24, textAlign: "left" @@ -25,6 +28,15 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, { }); }, + _setEnable: function (enable) { + BI.SingleSelectItem.superclass._setEnable.apply(this, arguments); + if (enable === true) { + this.element.attr("tabIndex", 1); + } else if (enable === false) { + this.element.removeAttr("tabIndex"); + } + }, + doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, diff --git a/src/case/button/item.singleselect.radio.js b/src/case/button/item.singleselect.radio.js index 0c6a55d3e..42c628247 100644 --- a/src/case/button/item.singleselect.radio.js +++ b/src/case/button/item.singleselect.radio.js @@ -7,6 +7,9 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { _defaultConfig: function () { return BI.extend(BI.SingleSelectRadioItem.superclass._defaultConfig.apply(this, arguments), { extraCls: "bi-single-select-radio-item", + attributes: { + tabIndex: 1 + }, logic: { dynamic: false }, @@ -51,6 +54,15 @@ BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { })))); }, + _setEnable: function (enable) { + BI.SingleSelectRadioItem.superclass._setEnable.apply(this, arguments); + if (enable === true) { + this.element.attr("tabIndex", 1); + } else if (enable === false) { + this.element.removeAttr("tabIndex"); + } + }, + doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, diff --git a/src/case/button/switch.js b/src/case/button/switch.js index 2fcbf2c8f..e88360266 100644 --- a/src/case/button/switch.js +++ b/src/case/button/switch.js @@ -9,6 +9,9 @@ BI.Switch = BI.inherit(BI.BasicButton, { props: { extraCls: "bi-switch", + attributes: { + tabIndex: 1 + }, height: 20, width: 44, logic: { @@ -58,6 +61,15 @@ BI.Switch = BI.inherit(BI.BasicButton, { }; }, + _setEnable: function (enable) { + BI.Switch.superclass._setEnable.apply(this, arguments); + if (enable === true) { + this.element.attr("tabIndex", 1); + } else if (enable === false) { + this.element.removeAttr("tabIndex"); + } + }, + setSelected: function (v) { BI.Switch.superclass.setSelected.apply(this, arguments); this.layout.attr("items")[0].left = v ? 28 : 4;