1$(document).ready(function () { 2 html = document.querySelector('html'); 3 html.classList.remove("no-js"); 4 // Basic functions to add relevant classes to html tag 5 viewport(); 6 device(); 7 touchEnabled(); 8 9 // menu = new Navigation(document.querySelector('.navigation')); 10 11 12 isMobile = false; 13 14 if (html.classList.contains('mobile')) { 15 isMobile = true; 16 } 17 18 // Cookie banner behaviour 19 // if (document.querySelector('.cookie-banner')) { 20 // new CookieBanner(document.querySelector('.cookie-banner')); 21 // } 22 23 // Language switcher 24 // if (document.querySelector('.language-selector')) { 25 // new LanguageSelector(document.querySelector('.language-selector')); 26 // } 27 28 // Search result page behaviour 29 searchResultPages = document.querySelectorAll('.search-result-item.js-listing-result'); 30 if (searchResultPages.length > 0) { 31 for (let i = 0; i < searchResultPages.length; i++) { 32 new SearchResultPage(searchResultPages[i]); 33 } 34 } 35 36 // Feedback form behaviour 37 // if (document.querySelector('.feedback-form')) { 38 // new FeedbackForm(document.querySelector('.feedback-form')); 39 // } 40 var resizeId; 41 $(window).resize(function() { 42 clearTimeout(resizeId); 43 resizeId = setTimeout(doneResizing, 500); 44 }); 45}); 46 47function doneResizing(){ 48 device(); 49 viewport(); 50 51 wasMobile = isMobile; 52 53 html.classList.contains('mobile') ? isMobile = true : isMobile = false; 54 55 // if (wasMobile != isMobile) { 56 // isMobile ? menu.closeDesktopSearch() : menu.closeMobileMenu(); 57 // } 58} 59 60// Basic classes to add relevant classes to html tag 61function classRemove(element, classes) { 62 classes.forEach(function (clas) { 63 element.classList.remove(clas); 64 }); 65} 66 67function viewport() { 68 var width = document.body.clientWidth, 69 viewport = 'default'; 70 71 if (width >= 1344) { 72 viewport = 'desktop-wide'; 73 74 } 75 if (width < 1344) { 76 viewport = 'desktop-compact'; 77 78 } 79 if (width < 1024) { 80 viewport = 'tablet-portrait'; 81 82 } 83 if (width < 768) { 84 viewport = 'mobile-landscape'; 85 86 } 87 if (width < 481) { 88 viewport = 'mobile-portrait'; 89 90 } 91 92 classRemove(html, ['default', 'desktop-compact', 'tablet-portrait', 'mobile-landscape', 'mobile-portrait']); 93 html.classList.add(viewport); 94 95 return viewport; 96} 97 98function device() { 99 var device = 'desktop'; 100 switch (viewport()) { 101 case 'desktop-compact': 102 device = 'desktop'; 103 if (touchEnabled()) { 104 device = 'tablet'; 105 } 106 break; 107 case 'tablet-portrait': 108 device = 'tablet'; 109 break; 110 case 'mobile-landscape': 111 case 'mobile-portrait': 112 device = 'mobile'; 113 break; 114 } 115 classRemove(html, ['mobile', 'tablet', 'tablet-portrait', 'desktop']); 116 html.classList.add(device); 117 118 return device; 119} 120 121function touchEnabled() { 122 if ('ontouchstart' in window || 'onmsgesturechange' in window) { 123 html.classList.add('touchenabled'); 124 return true; 125 } 126 html.classList.remove('touchenabled'); 127 return false; 128} 129 130 131// function navigation() { 132// menu = null; 133// delete menu; 134 135// // reinitiate menu 136// menu = new Navigation(document.querySelector('.navigation')); 137// }
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.