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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user