1import browser from "../plugins/$.browser.min.js" 2 3var device = { 4 5 init: function() { 6 7 // Find out the current browser 8 9 if ($.browser.name) { 10 var browserVersion = parseInt($.browser.version); 11 var browserName = $.browser.name; 12 if (browserVersion) { 13 $('body').addClass('browser-' + browserName); 14 $('body').addClass('browser-' + browserName + '-' + browserVersion); 15 } 16 if ($.browser.platform) { 17 $('body').addClass('platform-' + $.browser.platform); 18 } 19 if ($.browser.platform == 'iphone' || $.browser.platform == 'ipad') { 20 $('body').addClass('platform-ios'); 21 } 22 } 23 24 // Find out if this is the Android default browser and add a class to the body 25 // This is NOT a very good way of testing for this browser, but there does not seem to be a conclusive way to do it 26 var nua = navigator.userAgent; 27 var is_android_default_browser = ((nua.indexOf('Mozilla/5.0') > -1 && nua.indexOf('Android ') > -1 && nua.indexOf('AppleWebKit') > -1) && !(nua.indexOf('Chrome') > -1)); 28 if (is_android_default_browser) { 29 $('body').addClass('browser-android-internet'); 30 } 31 32 // Find outo if this is a high res device and add a class to the body 33 // This allows us to change graphics to high-res versions on compatible devices 34 if (window.devicePixelRatio > 1) { 35 $('body').addClass('device-highres'); 36 } 37 38 if (window.galleries.device.handheld()) { 39 $('body').addClass('device-handheld'); 40 } else { 41 $('body').addClass('device-desktop'); 42 } 43 44 // Detect support for AR 45 var test_anchor = document.createElement("a"); 46 if ($.browser.name && $.browser.name == 'safari' && test_anchor.relList.supports("ar")) { 47 $('body').addClass('ar-supported'); 48 } 49 }, 50 51 handheld: function() { 52 53 /* Detect mobile device */ 54 return ( 55 //Uncomment to force for testing 56 //true || 57 58 //Dev mode 59 (window.location.search.indexOf("?handheld=1") != -1) || 60 //Detect iPhone 61 (navigator.platform.indexOf("iPhone") != -1) || 62 //Detect iPod 63 (navigator.platform.indexOf("iPod") != -1) || 64 //Detect iPad 65 (navigator.platform.indexOf("iPad") != -1) || 66 //Detect iPad ios 13+ 67 (navigator.platform.indexOf("MacIntel") != -1 && navigator.maxTouchPoints > 1) || 68 //Detect Android 69 (navigator.userAgent.toLowerCase().indexOf("android") != -1) || 70 //Detect Surface (ARM chip version e.g. low powered tablets) will also detect other windows tablets with the same chip 71 (navigator.userAgent.toLowerCase().indexOf("arm;") != -1 && navigator.userAgent.toLowerCase().indexOf("windows nt") != -1) || 72 //Detect Opera Mini 73 (navigator.userAgent.toLowerCase().indexOf("opera mini") != -1) || 74 //Detect Blackberry 75 (navigator.userAgent.toLowerCase().indexOf("blackberry") != -1) || 76 //Detect webos 77 (navigator.userAgent.toLowerCase().indexOf("webos") != -1) || 78 //Detect iemobile (old version of windows phone) 79 (navigator.userAgent.toLowerCase().indexOf("iemobile") != -1) 80 ); 81 82 } 83 84} 85 86window.galleries = window.galleries || {}; 87window.galleries.device = device; 88export default device;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.