From c1c225eff2e3fa4289ff7d75590f76f39d23816d Mon Sep 17 00:00:00 2001 From: Romeo Fragomeli Date: Mon, 26 Apr 2021 12:11:07 +0000 Subject: [PATCH] [IMP] web: add the detection of iPadOS Before this commit, the iPad with iPadOS was not detected as 'isMobileDevice'. Now the detection is more accurate. --- addons/web/static/src/js/services/config.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/services/config.js b/addons/web/static/src/js/services/config.js index 6c576c351bb..dde878f102d 100644 --- a/addons/web/static/src/js/services/config.js +++ b/addons/web/static/src/js/services/config.js @@ -14,6 +14,11 @@ const bus = new Bus(); * this file someday. */ +const maxTouchPoints = navigator.maxTouchPoints || 1; +const isAndroid = /Android/i.test(navigator.userAgent); +const isIOS = /(iPad|iPhone|iPod)/i.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && maxTouchPoints > 1); +const isOtherMobileDevice = /(webOS|BlackBerry|Windows Phone)/i.test(navigator.userAgent); + var config = { device: { /** @@ -52,13 +57,7 @@ var config = { * * @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), + isMobileDevice: isAndroid || isIOS || isOtherMobileDevice, /** * Mapping between the numbers 0,1,2,3,4,5,6 and some descriptions */