2025-11-24 20:48:12 +00:00
|
|
|
/**
|
|
|
|
|
* DEVICE DETECTION
|
|
|
|
|
* Detects real mobile devices vs desktop browser in mobile view
|
|
|
|
|
* Adds 'is-mobile-device' class to body for styling differences
|
2025-11-25 06:41:56 +00:00
|
|
|
* Now also considers viewport width to avoid hiding buttons in responsive mode at desktop sizes
|
2025-11-24 20:48:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function() {
|
2025-11-25 06:41:56 +00:00
|
|
|
function updateDeviceClass() {
|
|
|
|
|
// Check if user agent indicates a real mobile device
|
|
|
|
|
const isMobileDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
2025-11-24 20:48:12 +00:00
|
|
|
|
2025-11-25 06:41:56 +00:00
|
|
|
// Also check for touch support (additional indicator)
|
|
|
|
|
const hasTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
2025-11-24 20:48:12 +00:00
|
|
|
|
2025-11-25 06:41:56 +00:00
|
|
|
// Check viewport width - only consider it a mobile device if viewport is also mobile-sized
|
|
|
|
|
const isMobileViewport = window.innerWidth <= 900;
|
|
|
|
|
|
|
|
|
|
// Consider it a real mobile device if ALL three conditions are met:
|
|
|
|
|
// 1. Mobile user agent
|
|
|
|
|
// 2. Touch support
|
|
|
|
|
// 3. Mobile viewport width (≤900px)
|
|
|
|
|
// This prevents hiding buttons in responsive mode at desktop sizes
|
|
|
|
|
if (isMobileDevice && hasTouch && isMobileViewport) {
|
|
|
|
|
document.documentElement.classList.remove('is-desktop');
|
|
|
|
|
document.documentElement.classList.add('is-mobile-device');
|
|
|
|
|
} else {
|
|
|
|
|
document.documentElement.classList.remove('is-mobile-device');
|
|
|
|
|
document.documentElement.classList.add('is-desktop');
|
|
|
|
|
}
|
2025-11-24 20:48:12 +00:00
|
|
|
}
|
2025-11-25 06:41:56 +00:00
|
|
|
|
|
|
|
|
// Run on load
|
|
|
|
|
updateDeviceClass();
|
|
|
|
|
|
|
|
|
|
// Re-check on resize (for responsive mode testing)
|
|
|
|
|
window.addEventListener('resize', updateDeviceClass);
|
2025-11-24 20:48:12 +00:00
|
|
|
})();
|