Forms: Add support for form hotkeys

Adds JavaScript support to monitor keypresses or mouse events
of forms with the classes .form-hotkey-enter or form-hotkey-double-click,
and trigger the click event of the button with the CSS class
.btn-hotkey-default.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-11-25 01:32:22 -04:00
parent 8e896a54f9
commit e72b4e82a3
4 changed files with 25 additions and 9 deletions
@@ -217,6 +217,7 @@ class MayanApp {
this.setupAJAXPeriodicWorkers();
this.setupAJAXSpinner();
this.setupAutoSubmit();
this.setupFormHotkeys();
this.setupFullHeightResizing();
this.setupItemsSelector();
this.setupNavbarCollapse();
@@ -271,6 +272,21 @@ class MayanApp {
});
}
setupFormHotkeys () {
$('body').on('keypress', '.form-hotkey-enter', function (e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
$(this).find('.btn-hotkey-default').click();
return false;
} else {
return true;
}
});
$('body').on('dblclick', '.form-hotkey-double-click', function (e) {
$(this).find('.btn-hotkey-default').click();
return false;
});
}
setupFullHeightResizing () {
var self = this;