summaryrefslogtreecommitdiff
path: root/addons/barcodes/static
diff options
context:
space:
mode:
authorRomeo Fragomeli <rfr@odoo.com>2019-10-17 13:54:53 +0000
committerAdrien Dieudonne <adr@odoo.com>2019-10-18 12:59:08 +0000
commit78b9dad560aec804bf67eb7e656443bac9caefbf (patch)
tree7c06a9bdf4af77313c5f2dc78e5bdd66ba48d480 /addons/barcodes/static
parent9831ed08fe60f36244e8e941012ca6866cab3e16 (diff)
[REF] web,barcodes: simplify mobile device detection
In this commit, we introduce "isMobileDevice". Do not confuse with isMobile. isMobile: A frequent use case is to have a different render in 'mobile' mode, meaning when the screen is small. This flag (boolean) is true when the size is XS/VSM/SM. It is also updated dynamically. isMobileDevice: Mobile device detection using userAgent. This flag doesn't depend on the size/resolution of the screen. It targets mobile devices which suggests that there is a virtual keyboard. Task ID: 2090202
Diffstat (limited to 'addons/barcodes/static')
-rw-r--r--addons/barcodes/static/src/js/barcode_events.js10
1 files changed, 2 insertions, 8 deletions
diff --git a/addons/barcodes/static/src/js/barcode_events.js b/addons/barcodes/static/src/js/barcode_events.js
index 5fcd68ac680..b07cf7bd19b 100644
--- a/addons/barcodes/static/src/js/barcode_events.js
+++ b/addons/barcodes/static/src/js/barcode_events.js
@@ -1,6 +1,7 @@
odoo.define('barcodes.BarcodeEvents', function(require) {
"use strict";
+var config = require('web.config');
var core = require('web.core');
var mixins = require('web.mixins');
var session = require('web.session');
@@ -46,14 +47,7 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
$(_.bind(this.start, this, false));
// Mobile device detection
- var isMobile = navigator.userAgent.match(/Android/i) ||
- navigator.userAgent.match(/webOS/i) ||
- navigator.userAgent.match(/iPhone/i) ||
- navigator.userAgent.match(/iPad/i) ||
- navigator.userAgent.match(/iPod/i) ||
- navigator.userAgent.match(/BlackBerry/i) ||
- navigator.userAgent.match(/Windows Phone/i);
- this.isChromeMobile = isMobile && navigator.userAgent.match(/Chrome/i);
+ this.isChromeMobile = config.device.isMobileDevice && navigator.userAgent.match(/Chrome/i);
// Creates an input who will receive the barcode scanner value.
this.$barcodeInput = $('<input/>', {