Browse Source

Pull request #2459: chore: 按钮支持enter键确定

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit 'fa90d46fac546e50c1bf6c6bc859d9ea724582aa':
  chore: 按钮支持enter键确定
es6
guy 3 years ago
parent
commit
3ca7ee3a01
  1. 25
      src/base/foundation/message.js
  2. 5
      src/base/single/button/button.basic.js
  3. 12
      src/base/single/button/buttons/button.js
  4. 14
      src/base/single/button/listitem/icontextitem.js
  5. 14
      src/base/single/button/node/icontextnode.js
  6. 12
      src/case/button/item.multiselect.js
  7. 18
      src/case/button/item.singleselect.icontext.js
  8. 12
      src/case/button/item.singleselect.js
  9. 12
      src/case/button/item.singleselect.radio.js
  10. 12
      src/case/button/switch.js

25
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: {

5
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) {

12
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);

14
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);
},

14
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);
},

12
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);
},

18
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);
BI.shortcut("bi.single_select_icon_text_item", BI.SingleSelectIconTextItem);

12
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);
},

12
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);
},

12
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;

Loading…
Cancel
Save