summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/barcodes/static/src/js/barcode_events.js10
-rw-r--r--addons/web/static/src/js/services/config.js14
2 files changed, 16 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/>', {
diff --git a/addons/web/static/src/js/services/config.js b/addons/web/static/src/js/services/config.js
index 8412c1319a8..91c3f1c764c 100644
--- a/addons/web/static/src/js/services/config.js
+++ b/addons/web/static/src/js/services/config.js
@@ -35,6 +35,20 @@ var config = {
*/
isMobile: null,
/**
+ * 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.
+ *
+ * @return {boolean}
+ */
+ isMobileDevice: 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),
+ /**
* Mapping between the numbers 0,1,2,3,4,5,6 and some descriptions
*/
SIZES: { XS: 0, VSM: 1, SM: 2, MD: 3, LG: 4, XL: 5, XXL: 6 },