diff --git a/js/beestat/touch.js b/js/beestat/touch.js new file mode 100644 index 0000000..29cab06 --- /dev/null +++ b/js/beestat/touch.js @@ -0,0 +1,38 @@ +/** + * Detect if the device is touch enabled. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent + * @return {boolean} Whether or not the device is touch enabled. + */ +beestat.touch = function() { + return true; + if (beestat.touch_ !== undefined) { + return beestat.touch_; + } + + let touch = false; + if ('maxTouchPoints' in navigator) { + touch = navigator.maxTouchPoints > 0; + } else if ('msMaxTouchPoints' in navigator) { + touch = navigator.msMaxTouchPoints > 0; + } else { + var mq = window.matchMedia && matchMedia('(pointer:coarse)'); + if (mq && mq.media === '(pointer:coarse)') { + touch = Boolean(mq.matches); + } else if ('orientation' in window) { + // Deprecated, but good fallback + touch = true; + } else { + // Only as a last resort, fall back to user agent sniffing + var UA = navigator.userAgent; + touch = ( + (/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i).test(UA) || + (/\b(Android|Windows Phone|iPad|iPod)\b/i).test(UA) + ); + } + } + + // Cache result + beestat.touch_ = touch; + return beestat.touch_; +}; diff --git a/js/js.php b/js/js.php index cd66ed0..75db081 100755 --- a/js/js.php +++ b/js/js.php @@ -37,6 +37,7 @@ if($setting->get('environment') === 'dev' || $setting->get('environment') === 'd echo '' . PHP_EOL; echo '' . PHP_EOL; echo '' . PHP_EOL; + echo '' . PHP_EOL; // Layer echo '' . PHP_EOL;