Browse Source

fixup! fixup! fixup! [ADD] Backport functionality from 12.0 to web_keyboard_navigation module.

pull/1119/head
George Daramouskas 5 years ago
parent
commit
03bce7eaed
No known key found for this signature in database GPG Key ID: 5B4EF742F8CD859C
  1. 25
      web_keyboard_navigation/README.rst
  2. 25
      web_keyboard_navigation/static/src/js/web_keyboard_navigation.js

25
web_keyboard_navigation/README.rst

@ -6,22 +6,23 @@
web_keyboard_navigation
==============================
This module was written to extend the functionality of ... to support ...
and allow you to ...
This module was written to extend the functionality of the Web Client to
support easier navigation and allow you to use the Alt key in order to get
some shortcuts shown on your client.
Installation
============
To install this module, you need to:
#. do this ...
Follow the usual procedure for your version of Odoo.
Configuration
=============
To configure this module, you need to:
#. go to ...
No configuration can take place at this point.
Usage
=====
@ -30,20 +31,14 @@ To use this module, you need to:
#. go to ...
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162
163
164
186
210
225
258/11.0
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162
Known issues / Roadmap
======================
* None
* Allow customization of the keys.
Bug Tracker
===========
@ -82,3 +77,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.
**This module is a backport from Odoo SA and as such, it is not included in the
OCA CLA. That means we do not have a copy of the copyright on it like all other
OCA modules.

25
web_keyboard_navigation/static/src/js/web_keyboard_navigation.js

@ -1,5 +1,5 @@
odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
require) {
require) {
"use strict";
var BrowserDetection = require('web.BrowserDetection');
@ -12,7 +12,7 @@ odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
'A',
'C',
'H',
'J',
'J',
'K',
'L',
'N',
@ -22,7 +22,7 @@ odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
'E',
'F',
'D',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
];
var KeyboardNavigationMixin = {
@ -32,7 +32,7 @@ odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
},
init: function () {
this._super()
this._super();
this._areAccessKeyVisible = false;
this.BrowserDetection = new BrowserDetection();
},
@ -44,7 +44,7 @@ odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
var overlay = $(_.str.sprintf(
"<div class='o_web_accesskey_overlay'>%s</div>",
$(elem).attr('accesskey').toUpperCase()));
var $overlayParent;
var $overlayParent = null;
if (elem.tagName.toUpperCase() === "INPUT") {
$overlayParent = $(elem).parent();
} else {
@ -75,7 +75,7 @@ odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
_setAccessKeyOnTopNavigation: function () {
this.$el.find(
'.o_menu_sections>li>a').each(function (number, item) {
'.o_menu_sections>li>a').each(function (number, item) {
item.accessKey = number + 1;
});
},
@ -104,7 +104,7 @@ odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
this._setAccessKeyOnTopNavigation();
var usedAccessKey = this._getAllUsedAccessKeys();
var buttonsWithoutAccessKey = this.$el.find(
'button.btn:visible')
'button.btn:visible')
.not('[accesskey]')
.not('[disabled]')
.not('[tabindex="-1"]');
@ -112,8 +112,8 @@ odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
var buttonString = [elem.innerText, elem.title,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"].join('');
for (var letterIndex = 0;
letterIndex < buttonString.length;
letterIndex++) {
letterIndex < buttonString.length;
letterIndex++) {
var candidateAccessKey = buttonString[
letterIndex].toUpperCase();
if (candidateAccessKey >= 'A' &&
@ -134,8 +134,9 @@ odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
});
this._addAccessKeyOverlays();
}
if (this.BrowserDetection.isOsMac())
if (this.BrowserDetection.isOsMac()) {
return;
}
if (keyDownEvent.altKey &&
!keyDownEvent.ctrlKey &&
keyDownEvent.key.length === 1) {
@ -168,9 +169,9 @@ odoo.define('web_keyboard_navigation.KeyboardNavigationMixin', function (
return false;
}
}
}
}
else {
var numberKey;
var numberKey = null;
if (keyDownEvent.originalEvent.code &&
keyDownEvent.originalEvent.code.indexOf(
'Digit') === 0) {

Loading…
Cancel
Save