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. 16
      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: [ items: [
{ {
type: "bi.border", 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", cls: "bi-card",
items: { items: {
north: { north: {

5
src/base/single/button/button.basic.js

@ -11,9 +11,6 @@ BI.BasicButton = BI.inherit(BI.Single, {
return BI.extend(conf, { return BI.extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), _baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""),
// el: {} // 可以通过el来创建button元素 // el: {} // 可以通过el来创建button元素
attributes: {
tabIndex: 1
},
value: "", value: "",
stopEvent: false, stopEvent: false,
stopPropagation: false, stopPropagation: false,
@ -412,10 +409,8 @@ BI.BasicButton = BI.inherit(BI.Single, {
BI.BasicButton.superclass._setEnable.apply(this, arguments); BI.BasicButton.superclass._setEnable.apply(this, arguments);
if (enable === true) { if (enable === true) {
this.element.removeClass("base-disabled disabled"); this.element.removeClass("base-disabled disabled");
this.element.attr("tabIndex", 1);
} else if (enable === false) { } else if (enable === false) {
this.element.addClass("base-disabled disabled"); this.element.addClass("base-disabled disabled");
this.element.removeAttr("tabIndex");
} }
if (!enable) { if (!enable) {
if (this.options.shadow) { 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); var conf = BI.Button.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""), baseCls: (conf.baseCls || "") + " bi-button" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""),
attributes: {
tabIndex: 1
},
minWidth: (props.block === true || props.clear === true) ? 0 : 80, minWidth: (props.block === true || props.clear === true) ? 0 : 80,
height: 24, height: 24,
shadow: props.clear !== true, 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) { setText: function (text) {
BI.Button.superclass.setText.apply(this, arguments); BI.Button.superclass.setText.apply(this, arguments);
this.text.setText(text); 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 () { setValue: function () {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
@ -75,13 +82,6 @@ BI.IconTextItem = BI.inherit(BI.BasicButton, {
return this.text.getText(); 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 () { doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments); 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 () { setValue: function () {
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments); this.text.setValue.apply(this.text, arguments);
@ -71,13 +78,6 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
return this.text.getText(); 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 () { doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments); 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 () { _defaultConfig: function () {
return BI.extend(BI.MultiSelectItem.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectItem.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-multi-select-item", extraCls: "bi-multi-select-item",
attributes: {
tabIndex: 1
},
height: 24, height: 24,
logic: { logic: {
dynamic: false 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 () { doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, },

16
src/case/button/item.singleselect.icontext.js

@ -8,6 +8,9 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.SingleSelectIconTextItem.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.SingleSelectIconTextItem.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-single-select-icon-text-item bi-list-item-active", extraCls: "bi-single-select-icon-text-item bi-list-item-active",
attributes: {
tabIndex: 1
},
iconCls: "", iconCls: "",
height: 24 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 () { isSelected: function () {
return this.text.isSelected(); return this.text.isSelected();
}, },
@ -49,10 +61,6 @@ BI.SingleSelectIconTextItem = BI.inherit(BI.Single, {
unRedMark: function () { unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
},
doClick: function () {
BI.SingleSelectIconTextItem.superclass.doClick.apply(this, arguments);
} }
}); });

12
src/case/button/item.singleselect.js

@ -2,6 +2,9 @@ BI.SingleSelectItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.SingleSelectItem.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.SingleSelectItem.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-single-select-item bi-list-item-active", extraCls: "bi-single-select-item bi-list-item-active",
attributes: {
tabIndex: 1
},
hgap: 10, hgap: 10,
height: 24, height: 24,
textAlign: "left" 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 () { doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments); 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 () { _defaultConfig: function () {
return BI.extend(BI.SingleSelectRadioItem.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.SingleSelectRadioItem.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-single-select-radio-item", extraCls: "bi-single-select-radio-item",
attributes: {
tabIndex: 1
},
logic: { logic: {
dynamic: false 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 () { doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments); this.text.doRedMark.apply(this.text, arguments);
}, },

12
src/case/button/switch.js

@ -9,6 +9,9 @@ BI.Switch = BI.inherit(BI.BasicButton, {
props: { props: {
extraCls: "bi-switch", extraCls: "bi-switch",
attributes: {
tabIndex: 1
},
height: 20, height: 20,
width: 44, width: 44,
logic: { 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) { setSelected: function (v) {
BI.Switch.superclass.setSelected.apply(this, arguments); BI.Switch.superclass.setSelected.apply(this, arguments);
this.layout.attr("items")[0].left = v ? 28 : 4; this.layout.attr("items")[0].left = v ? 28 : 4;

Loading…
Cancel
Save