summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core/misc.js
diff options
context:
space:
mode:
authorsed-odoo <sed@odoo.com>2018-08-22 15:40:21 +0200
committersed-odoo <sed@odoo.com>2018-08-24 10:49:30 +0200
commit4015c84633c2f0854181deb0dcfbb0c87f639d36 (patch)
tree68e77b1f14984307073e9d526baf7048160be315 /addons/web/static/src/js/core/misc.js
parent61d790d6e220aad7e7594795550d608378ef27bc (diff)
[FIX] web: Disable keyboard shortcuts on BlockUI
Related to the bug: 1874270 Purpose ======= Keyboard shortcuts working on BlockUI and can cause some issues when used. Specification ============= It should not work and should not be display while some process is being executed. - add function to remove the "accesskey" attributes to avoid the use of the access keys while the blockUI is enable. - add function to reset the "accesskey" attributes when the blockUI is disable. - add condition to avoid the "Alt" key to reattribute access keys.
Diffstat (limited to 'addons/web/static/src/js/core/misc.js')
-rw-r--r--addons/web/static/src/js/core/misc.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/addons/web/static/src/js/core/misc.js b/addons/web/static/src/js/core/misc.js
index be0f012752c..cd9a73ef22b 100644
--- a/addons/web/static/src/js/core/misc.js
+++ b/addons/web/static/src/js/core/misc.js
@@ -52,6 +52,29 @@ if ($.blockUI) {
}
+/**
+ * Remove the "accesskey" attributes to avoid the use of the access keys
+ * while the blockUI is enable.
+ */
+
+function blockAccessKeys() {
+ var elementWithAccessKey = [];
+ elementWithAccessKey = document.querySelectorAll('[accesskey]');
+ _.each(elementWithAccessKey, function (elem) {
+ elem.setAttribute("data-accesskey",elem.getAttribute('accesskey'));
+ elem.removeAttribute('accesskey');
+ });
+}
+
+function unblockAccessKeys() {
+ var elementWithDataAccessKey = [];
+ elementWithDataAccessKey = document.querySelectorAll('[data-accesskey]');
+ _.each(elementWithDataAccessKey, function (elem) {
+ elem.setAttribute('accesskey', elem.getAttribute('data-accesskey'));
+ elem.removeAttribute('data-accesskey');
+ });
+}
+
var throbbers = [];
function blockUI() {
@@ -60,6 +83,7 @@ function blockUI() {
throbbers.push(throbber);
throbber.appendTo($(".oe_blockui_spin_container"));
$(document.body).addClass('o_ui_blocked');
+ blockAccessKeys();
return tmp;
}
@@ -67,6 +91,7 @@ function unblockUI() {
_.invoke(throbbers, 'destroy');
throbbers = [];
$(document.body).removeClass('o_ui_blocked');
+ unblockAccessKeys();
return $.unblockUI.apply($, arguments);
}