[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
This commit is contained in:
committed by
Adrien Dieudonne
parent
9831ed08fe
commit
78b9dad560
@@ -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/>', {
|
||||
|
||||
@@ -34,6 +34,20 @@ var config = {
|
||||
* @type Boolean
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user