1jQuery(document).ready(function ($) { 2 function initMegaMenu($megaMenuContainer) { 3 const triggerId = $megaMenuContainer.attr('data-trigger-id'); 4 const feature = $megaMenuContainer.attr('data-feature') || 'click'; 5 6 console.log('MMM Menu Initialize:', { triggerId, feature }); 7 8 if (!triggerId) return; 9 10 // Hem ID hem de Class olarak aynı anda ara 11 let $trigger = $('#' + triggerId + ', .' + triggerId); 12 13 console.log('MMM Trigger Search result:', { 14 found: $trigger.length, 15 selector: '#' + triggerId + ', .' + triggerId 16 }); 17 18 if (!$trigger.length) { 19 console.warn('MMM: Trigger element not found for', triggerId); 20 return; 21 } 22 23 const $triggerLink = $trigger.find('> a'); 24 const $gridContainer = $megaMenuContainer.find('.servicemenu-grid'); 25 const $menuColumn1 = $gridContainer.find('.menu-column-1'); 26 const $menuColumn2 = $gridContainer.find('.menu-column-2'); 27 const $menuColumn3 = $gridContainer.find('.menu-column-3'); 28 const $dynamicContentArea = $gridContainer.find('.dynamic-content-area'); 29 const $closeButton = $megaMenuContainer.find('.mmm-close-button'); 30 31 const $fullMenu = $menuColumn1.find('ul.mmm-full-menu').clone(); 32 $menuColumn1.find('ul.sub-menu').remove(); 33 34 let hoverTimeout; 35 36 function openMenu($currentTrigger) { 37 console.log('MMM Opening Menu...'); 38 // EÄer diÄer menüler açıksa onları kapat 39 $('.servicemenu.is-open').not($megaMenuContainer).removeClass('is-open'); 40 41 $megaMenuContainer.addClass('is-open'); 42 43 // Scroll engelini herhangi bir menü açıksa aktif tut 44 $('body, html').addClass('mmm-no-scroll'); 45 46 const $header = $currentTrigger.closest('.elementor-sticky, header.elementor-location-header, header'); 47 let headerBottomOffset = 0; 48 49 if ($header.length) { 50 // Daha hassas ölçüm için getBoundingClientRect kullanalım 51 const rect = $header[0].getBoundingClientRect(); 52 headerBottomOffset = rect.bottom; 53 console.log('MMM Header found (Precise):', { rectTop: rect.top, rectBottom: rect.bottom, headerBottomOffset }); 54 } else { 55 console.log('MMM Header NOT found, using default top: 0'); 56 } 57 58 $megaMenuContainer.css({ 59 'top': '0px', 60 'height': '83vh' 61 }); 62 63 resetMenus(); 64 } 65 66 function closeMenu() { 67 console.log('MMM Closing Menu...'); 68 $megaMenuContainer.removeClass('is-open'); 69 // Sadece tüm menüler kapandıysa scroll engelini kaldır 70 if ($('.servicemenu.is-open').length === 0) { 71 $('body, html').removeClass('mmm-no-scroll'); 72 } 73 } 74 75 if (feature === 'hover') { 76 $trigger.on('mouseenter', function () { 77 console.log('MMM Trigger MouseEnter'); 78 clearTimeout(hoverTimeout); 79 openMenu($(this)); 80 }).on('mouseleave', function () { 81 console.log('MMM Trigger MouseLeave'); 82 hoverTimeout = setTimeout(function () { 83 if (!$megaMenuContainer.is(':hover')) { 84 closeMenu(); 85 } else { 86 console.log('MMM MouseLeave: Menu is hovered, staying open'); 87 } 88 }, 300); // 300ms daha güvenli 89 }); 90 91 $megaMenuContainer.on('mouseenter', function () { 92 console.log('MMM Container MouseEnter'); 93 clearTimeout(hoverTimeout); 94 }).on('mouseleave', function () { 95 console.log('MMM Container MouseLeave'); 96 hoverTimeout = setTimeout(function () { 97 if (!$trigger.is(':hover')) { 98 closeMenu(); 99 } else { 100 console.log('MMM MouseLeave: Trigger is hovered, staying open'); 101 } 102 }, 300); 103 }); 104 } 105 106 // Tetikleyici tıklama (Click her zaman çalıÅsın veya sadece click modunda) 107 $trigger.on('click', function (e) { 108 console.log('MMM Trigger Clicked', { feature }); 109 if (feature === 'click') { 110 e.preventDefault(); 111 e.stopPropagation(); 112 113 if ($megaMenuContainer.hasClass('is-open')) { 114 closeMenu(); 115 } else { 116 openMenu($(this)); 117 } 118 } else if (feature === 'hover' && $(window).width() <= 1024) { 119 // Mobilde hover yerine click çalıÅsın 120 e.preventDefault(); 121 e.stopPropagation(); 122 if ($megaMenuContainer.hasClass('is-open')) { 123 closeMenu(); 124 } else { 125 openMenu($(this)); 126 } 127 } 128 }); 129 130 // Menü dıÅına veya menü içine tıklamada kapanmayı yönet 131 $megaMenuContainer.on('click', function (e) { 132 // Linklere tıklamada stopPropagation yapma, navigasyona izin ver 133 if ($(e.target).closest('a').length === 0) { 134 e.stopPropagation(); 135 } 136 }); 137 138 function resetMenus() { 139 $menuColumn1.find('a.is-active').removeClass('is-active'); 140 $menuColumn2.find('.mmm-menu-content-wrapper, .mmm-column-header').empty().parent().hide(); 141 $menuColumn3.find('.mmm-menu-content-wrapper, .mmm-column-header').empty().parent().hide(); 142 $gridContainer.removeClass('level-2-active level-3-active'); 143 $dynamicContentArea.show(); 144 $dynamicContentArea.find('.dynamic-content').hide(); 145 $dynamicContentArea.find('.dynamic-content[data-level="0"]').show(); 146 } 147 148 $closeButton.on('click', function (e) { 149 e.preventDefault(); 150 closeMenu(); 151 $trigger.removeClass('elementor-menu-item--active-dropdown active'); 152 }); 153 154 // Yardımcı fonksiyon: İçeriÄi çöz (Åablon veya Ãzel HTML)
155 function resolveContent(templateId, customContent) { 156 if (templateId) { 157 const $tpl = $('.dynamic-content[data-template-id="' + templateId + '"]'); 158 if ($tpl.length) return $tpl.html(); 159 } 160 return customContent || ''; 161 } 162 163 // Yardımcı fonksiyon: Liste öÄelerini iÅle 164 function processListItems($container) { 165 $container.find('li').each(function () { 166 const $li = $(this); 167 const templateId = $li.data('template-id'); 168 const customContent = $li.data('custom-content'); 169 const contentHtml = resolveContent(templateId, customContent); 170 171 if (contentHtml) { 172 $li.empty().append(contentHtml); 173 } 174 }); 175 } 176 177 // Sütun 1 tıklama 178 $menuColumn1.on('click', 'li > a', function (e) { 179 const $clickedLi = $(this).closest('li'); 180 const _origLi = $fullMenu.find('#' + $clickedLi.attr('id')); 181 const _hasSubMenu = _origLi.find('> ul.sub-menu'); 182 183 // Alt menusu olmayan ogelerde dogrudan linke git 184 if (_hasSubMenu.length === 0) { 185 const directUrl = $clickedLi.data('url') || $(this).attr('href'); 186 if (directUrl && directUrl !== '#' && directUrl !== 'javascript:void(0);') { 187 closeMenu(); 188 window.location.href = directUrl; 189 return; 190 } 191 } 192 193 e.preventDefault(); 194 e.stopPropagation(); 195 const templateId = $clickedLi.data('template-id'); 196 const customContent = $clickedLi.data('custom-content'); 197 198 $menuColumn1.find('a.is-active').removeClass('is-active'); 199 $(this).addClass('is-active'); 200 $menuColumn3.find('.mmm-menu-content-wrapper, .mmm-column-header').empty().parent().hide(); 201 202 const originalLi = $fullMenu.find('#' + $clickedLi.attr('id')); 203 const $submenu = originalLi.find('> ul.sub-menu'); 204 205 // Sütun için sadece customContent, templateId'yi dinamik alana saklıyoruz 206 207 if ($submenu.length > 0) { 208 const clickedTitle = $(this).find('.mmm-title').text(); 209 const url = $clickedLi.data('url'); 210 211 let headerTitleHtml = clickedTitle; 212 if (url && url !== '#' && url !== 'javascript:void(0);') { 213 headerTitleHtml = '<a href="' + url + '">' + clickedTitle + '</a>'; 214 } 215 216 $menuColumn2.find('.mmm-column-header').html('<h4 class="h4">' + headerTitleHtml + '</h4><i class="fa-solid fa-chevron-right"></i>'); 217 218 const $clonedSubmenu = $submenu.clone(); 219 $clonedSubmenu.find('ul.sub-menu').remove(); 220 221 const $wrapper = $menuColumn2.find('.mmm-menu-content-wrapper').empty().append($clonedSubmenu); 222 processListItems($wrapper); 223 224 $menuColumn2.show(); 225 $gridContainer.addClass('level-2-active').removeClass('level-3-active'); 226 } else { 227 $menuColumn2.find('.mmm-menu-content-wrapper, .mmm-column-header').empty(); 228 $menuColumn2.hide(); 229 $gridContainer.removeClass('level-2-active level-3-active'); 230 } 231 232 // ANA MENà ÅABLONU: Eskisi gibi dynamic-content-area'da göster 233 if (templateId) { 234 const $targetTemplate = $dynamicContentArea.find('.dynamic-content[data-template-id="' + templateId + '"]'); 235 if ($targetTemplate.length) { 236 $dynamicContentArea.find('.dynamic-content').hide(); 237 $targetTemplate.show(); 238 $dynamicContentArea.show(); 239 } else { 240 $dynamicContentArea.hide(); 241 } 242 } else { 243 $dynamicContentArea.hide(); 244 } 245 }); 246 247 // Sütun 2 tıklama 248 $menuColumn2.on('click', 'li > a', function (e) { 249 const $clickedLi = $(this).closest('li'); 250 const templateId = $clickedLi.data('template-id'); 251 const customContent = $clickedLi.data('custom-content'); 252 253 $menuColumn2.find('li.active-path').removeClass('active-path'); 254 $clickedLi.addClass('active-path'); 255 256 const clickedTitle = $(this).text(); 257 258 // Tıklanan öÄenin alt menüsünü $fullMenu'den bul 259 const originalLi = $fullMenu.find('#' + $clickedLi.attr('id')); 260 const $submenu = originalLi.find('> ul.sub-menu'); 261 262 if ($submenu.length > 0) { 263 e.preventDefault(); 264 e.stopPropagation(); 265 const clickedSubTitle = $(this).find('.mmm-title').text() || clickedTitle; 266 const url = $clickedLi.data('url'); 267 268 let headerTitleHtml = clickedSubTitle; 269 if (url && url !== '#' && url !== 'javascript:void(0);') { 270 headerTitleHtml = '<a href="' + url + '">' + clickedSubTitle + '</a>'; 271 } 272 273 $menuColumn3.find('.mmm-column-header').html('<h4 class="h4">' + headerTitleHtml + '</h4><i class="fa-solid fa-chevron-right"></i>'); 274 275 const $clonedSubmenu = $submenu.clone(); 276 $clonedSubmenu.find('ul.sub-menu').remove(); 277 278 const $wrapper = $menuColumn3.find('.mmm-menu-content-wrapper').empty().append($clonedSubmenu); 279 processListItems($wrapper); 280 281 $menuColumn3.show(); 282 $gridContainer.addClass('level-3-active'); 283 } else { 284 $menuColumn3.find('.mmm-menu-content-wrapper, .mmm-column-header').empty().parent().hide(); 285 $gridContainer.removeClass('level-3-active'); 286 // Alt menüsü yoksa direkt linke git 287 const directUrl = $clickedLi.data('url') || $(this).attr('href'); 288 if (directUrl && directUrl !== '#' && directUrl !== 'javascript:void(0);') { 289 closeMenu(); 290 window.location.href = directUrl; 291 return; 292 } 293 } 294 295 // Kolon 2'de tıklandıÄında dinamik içeriÄi gizle 296 $dynamicContentArea.hide(); 297 }); 298 299 // Sütun 3 tıklama 300 $menuColumn3.on('click', 'li > a', function (e) { 301 // Sadece diÄer sütunlar gibi davranmasını ve dynamic-content'i gizlemesini saÄla 302 $dynamicContentArea.hide(); 303 }); 304 305 $megaMenuContainer.data('close-fn', closeMenu); 306 } 307 308 // Her menü konteyneri için baÅlat 309 $('.servicemenu').each(function () { 310 initMegaMenu($(this)); 311 }); 312 313 // DıÅarı tıklandıÄında menüleri kapat 314 $(document).on('click', function () { 315 $('.servicemenu.is-open').each(function () { 316 const closeFn = $(this).data('close-fn'); 317 if (typeof closeFn === 'function') { 318 closeFn(); 319 } else { 320 $(this).removeClass('is-open'); 321 $('body, html').removeClass('mmm-no-scroll'); 322 } 323 }); 324 }); 325});
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.