diff options
| author | Romeo Fragomeli <rfr@odoo.com> | 2019-10-17 13:54:53 +0000 |
|---|---|---|
| committer | Adrien Dieudonne <adr@odoo.com> | 2019-10-18 12:59:08 +0000 |
| commit | 78b9dad560aec804bf67eb7e656443bac9caefbf (patch) | |
| tree | 7c06a9bdf4af77313c5f2dc78e5bdd66ba48d480 /addons/web/static/src/js | |
| parent | 9831ed08fe60f36244e8e941012ca6866cab3e16 (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/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/services/config.js | 14 |
1 files changed, 14 insertions, 0 deletions
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 }, |
