1/** 2 * Gardentopia: hamburger menu & search overlay (breakpoint 1000px). 3 */ 4(function() { 5 'use strict'; 6 7 var menu = document.getElementById('gt-mobile-menu'); 8 var overlay = document.getElementById('gt-search-overlay'); 9 var hamburger = document.querySelector('.gt-hamburger'); 10 var menuClose = document.querySelector('.gt-mobile-close'); 11 var searchToggle = document.querySelector('.gt-search-toggle'); 12 var searchClose = document.querySelector('.gt-search-close'); 13 14 function openMenu() { 15 if (menu) { 16 menu.classList.add('is-open'); 17 menu.setAttribute('aria-hidden', 'false'); 18 if (hamburger) { 19 hamburger.setAttribute('aria-expanded', 'true'); 20 hamburger.querySelector('i').classList.remove('fa-bars'); 21 hamburger.querySelector('i').classList.add('fa-times'); 22 } 23 document.body.style.overflow = 'hidden'; 24 } 25 } 26 27 function closeMenu() { 28 if (menu) { 29 menu.classList.remove('is-open'); 30 menu.setAttribute('aria-hidden', 'true'); 31 if (hamburger) { 32 hamburger.setAttribute('aria-expanded', 'false'); 33 hamburger.querySelector('i').classList.add('fa-bars'); 34 hamburger.querySelector('i').classList.remove('fa-times'); 35 } 36 document.body.style.overflow = ''; 37 } 38 } 39 40 function openSearch() { 41 if (overlay) { 42 overlay.classList.add('is-open'); 43 overlay.setAttribute('aria-hidden', 'false'); 44 var field = overlay.querySelector('input[type="search"], #gt-search-field'); 45 if (field) { 46 field.focus(); 47 } 48 } 49 } 50 51 function closeSearch() { 52 if (overlay) { 53 overlay.classList.remove('is-open'); 54 overlay.setAttribute('aria-hidden', 'true'); 55 } 56 } 57 58 if (hamburger) { 59 hamburger.addEventListener('click', function() { 60 if (menu && menu.classList.contains('is-open')) { 61 closeMenu(); 62 } else { 63 openMenu(); 64 } 65 }); 66 } 67 if (menuClose) { 68 menuClose.addEventListener('click', closeMenu); 69 } 70 if (searchToggle) { 71 searchToggle.addEventListener('click', openSearch); 72 } 73 if (searchClose) { 74 searchClose.addEventListener('click', closeSearch); 75 } 76 77 if (overlay) { 78 overlay.addEventListener('click', function(e) { 79 if (e.target === overlay) { 80 closeSearch(); 81 } 82 }); 83 } 84 if (menu) { 85 menu.addEventListener('click', function(e) { 86 var panel = menu.querySelector('.gt-mobile-panel'); 87 if (e.target === menu || (panel && !panel.contains(e.target))) { 88 closeMenu(); 89 } 90 }); 91 } 92 93 document.addEventListener('keydown', function(e) { 94 if (e.key === 'Escape') { 95 closeMenu(); 96 closeSearch(); 97 } 98 }); 99 100 /* Weather by language â capital city (front page) */ 101 var weatherEl = document.getElementById('gt-weather-module'); 102 if (weatherEl) { 103 var restUrl = weatherEl.getAttribute('data-rest-url'); 104 var lang = weatherEl.getAttribute('data-lang') || ''; 105 var weatherTitle = weatherEl.getAttribute('data-weather-title') || 'Gardener Weather'; 106 var humidityLabel = weatherEl.getAttribute('data-humidity-label') || 'Humidity'; 107 var popLabel = weatherEl.getAttribute('data-pop-label') || 'Precipitation chance'; 108 var unavailableText = weatherEl.getAttribute('data-unavailable-text') || 'Weather is unavailable.'; 109 110 function renderWeather(data) { 111 if (!data || data.error) { 112 weatherEl.classList.remove('gt-weather-loading'); 113 weatherEl.classList.add('gt-weather-error'); 114 weatherEl.querySelector('.gt-weather-inner').innerHTML = '<span class="gt-weather-unavailable">' + unavailableText + '</span>'; 115 return; 116 } 117 var loc = (data.city || '') + (data.country ? ', ' + data.country : ''); 118 var html = '<div class="gt-weather-deco"><i class="fas ' + (data.icon_class || 'fa-sun') + '"></i></div>' + 119 '<div class="gt-weather-inner">' + 120 '<div class="gt-weather-head"><div><h4 class="gt-weather-label">' + weatherTitle + '</h4><div class="gt-weather-location">' + loc + '</div></div>' + 121 '<i class="fas ' + (data.icon_class || 'fa-sun') + ' gt-weather-icon"></i></div>' + 122 '<div class="gt-weather-temp">' + (data.temp != null ? data.temp + '°C' : 'â') + '</div>' + 123 '<div class="gt-weather-desc">' + (data.description || '') + '</div>' + 124 '<div class="gt-weather-extra">' + 125 '<div><span class="gt-weather-extra-label">' + humidityLabel + '</span><span class="gt-weather-extra-value">' + (data.humidity != null ? data.humidity + '%' : 'â') + '</span></div>' + 126 '<div><span class="gt-weather-extra-label">' + popLabel + '</span><span class="gt-weather-extra-value">' + (data.pop != null ? data.pop + '%' : 'â') + '</span></div>' + 127 '</div></div>'; 128 weatherEl.classList.remove('gt-weather-loading'); 129 weatherEl.querySelector('.gt-weather-inner').outerHTML = html; 130 } 131 132 var url = restUrl + (lang ? '?lang=' + encodeURIComponent(lang) : ''); 133 fetch(url).then(function(r) { return r.json(); }).then(renderWeather).catch(function() { 134 renderWeather({ error: true }); 135 }); 136 } 137 138 /* Back to top â bal alsó, kattintásra sima görgetés a tetejére */ 139 var backToTop = document.getElementById('gt-back-to-top'); 140 if (backToTop) { 141 backToTop.addEventListener('click', function(e) { 142 e.preventDefault(); 143 var target = document.getElementById('content'); 144 if (target) { 145 target.scrollIntoView({ behavior: 'smooth', block: 'start' }); 146 } 147 }); 148 function toggleBackToTop() { 149 if (window.pageYOffset > 300) { 150 backToTop.classList.add('visible'); 151 } else { 152 backToTop.classList.remove('visible'); 153 } 154 } 155 window.addEventListener('scroll', toggleBackToTop); 156 toggleBackToTop(); 157 } 158})();
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.