Bug #3385: Close confirmation dialogs with the enter key

This commit is contained in:
Carlos Martín committed 2016-07-04 18:09:27 +02:00
1 parent d93f13297f
commit 4f52867944
2 files changed
+21 -2

No files matched your search

@@ -58,6 +58,15 @@ define(function(require) {
}
function _setup(dialog) {
$(dialog).keypress(function (e) {
if (e.which == 13 || e.keyCode == 13) {
$('#confirm_proceed', dialog).click();
return false;
} else {
return true;
}
});
// Submit action is configured in sunstone.js since it's an action_button
return false;
}
@@ -88,8 +88,18 @@ define(function(require) {
function _setup(context) {
var that = this;
$(context).keypress(function (e) {
if (e.which == 13 || e.keyCode == 13) {
$('#' + DIALOG_ID + 'Form', context).submit();
return false;
} else {
return true;
}
});
$('#' + DIALOG_ID + 'Form', context).submit(function(e) {
if (that.params.buttons != undefined){
// With more than one button, skip
if (that.params.buttons != undefined && that.params.buttons.length > 1){
e.preventDefault();
return false;
}
@@ -97,7 +107,7 @@ define(function(require) {
Sunstone.getDialog(DIALOG_ID).hide();
if (that.params.submit != undefined){
that.params.submit(this);
that.params.submit[0](this);
}
return false;