summaryrefslogtreecommitdiff
path: root/addons/barcodes/static/src
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-03-25 10:05:27 +0000
committerChristophe Simonis <chs@odoo.com>2019-03-25 11:13:41 +0000
commit5df4746c9aa144e6e3fce44fea43dac1089a5c51 (patch)
treef4ce932a76563e26b8d131805d49b405fcf9ad8f /addons/barcodes/static/src
parent39e71353c5d58f7af6b3270911a24d98b73cad4e (diff)
parent230ad8c381e927025efabff0f5f8c2debc432249 (diff)
[MERGE] forward port branch saas-12.2 up to 230ad8c381e
closes odoo/odoo#32088 Signed-off-by: Christophe Simonis <chs@odoo.com>
Diffstat (limited to 'addons/barcodes/static/src')
-rw-r--r--addons/barcodes/static/src/js/barcode_events.js37
1 files changed, 17 insertions, 20 deletions
diff --git a/addons/barcodes/static/src/js/barcode_events.js b/addons/barcodes/static/src/js/barcode_events.js
index 22c23ece8c3..3f38ea38e37 100644
--- a/addons/barcodes/static/src/js/barcode_events.js
+++ b/addons/barcodes/static/src/js/barcode_events.js
@@ -56,20 +56,18 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
this.isChromeMobile = isMobile && navigator.userAgent.match(/Chrome/i);
// Creates an input who will receive the barcode scanner value.
- if (this.isChromeMobile) {
- this.$barcodeInput = $('<input/>', {
- name: 'barcode',
- type: 'text',
- css: {
- 'position': 'fixed',
- 'top': '50%',
- 'transform': 'translateY(-50%)',
- 'z-index': '-1',
- },
- });
- // Avoid to show autocomplete for a non appearing input
- this.$barcodeInput.attr('autocomplete', 'off');
- }
+ this.$barcodeInput = $('<input/>', {
+ name: 'barcode',
+ type: 'text',
+ css: {
+ 'position': 'fixed',
+ 'top': '50%',
+ 'transform': 'translateY(-50%)',
+ 'z-index': '-1',
+ },
+ });
+ // Avoid to show autocomplete for a non appearing input
+ this.$barcodeInput.attr('autocomplete', 'off');
this.__blurBarcodeInput = _.debounce(this._blurBarcodeInput, this.inputTimeOut);
},
@@ -220,7 +218,8 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
* @param {jQuery.Event} e keydown event
*/
_listenBarcodeScanner: function (e) {
- if (!$('input:text:focus, input[type=number]:focus, textarea:focus, [contenteditable]:focus').length) {
+ if ($(document.activeElement).not('input:text, textarea, [contenteditable], ' +
+ '[type="email"], [type="number"], [type="password"], [type="tel"]').length) {
$('body').append(this.$barcodeInput);
this.$barcodeInput.focus();
}
@@ -263,11 +262,9 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
* @private
*/
_blurBarcodeInput: function () {
- if (this.$barcodeInput) {
- // Close the virtual keyboard on mobile browsers
- // FIXME: actually we can't prevent keyboard from opening
- this.$barcodeInput.val('').blur();
- }
+ // Close the virtual keyboard on mobile browsers
+ // FIXME: actually we can't prevent keyboard from opening
+ this.$barcodeInput.val('').blur();
},
start: function(prevent_key_repeat){