1(function($) { 2 'use strict'; 3 4 var $window = $(window); 5 6 $(document).ready(function() { 7 // Mega menu 8 var windowWidth = $window.width(); 9 if (windowWidth >= 768) { 10 responsiveMegaMenu(); 11 } 12 }); 13 14 function responsiveMegaMenu() { 15 renderMegaMenuWidth(); 16 17 if ($window.width() < 767) { 18 $('.megamenu').css({ display: 'block' }); 19 $('#site-navigation .megamenu-parent').find('.megamenu .children, .megamenu .sub-menu').css({ width: 'auto' }); 20 } else { 21 $('.megamenu').css({ display: 'flex' }); 22 $('ul.megamenu > li').addClass('focus'); 23 } 24 } 25 26 function renderMegaMenuWidth() { 27 let class_prefix = 'responsive-megamenu-width-'; 28 let $parent = $('#site-navigation .responsive-megamenu-parent'); 29 30 $parent.each(function() { 31 var idValue = $(this).attr('id'); 32 let menuIDClass = '.' + idValue; 33 34 $(menuIDClass).hover( 35 function() { 36 // Content Width 37 if ($(menuIDClass + '.responsive-megamenu-parent').hasClass(class_prefix + 'content')) { 38 let $siteHeader = $('.responsive-site-header-wrap .container > .site-header-row'), 39 $menuWidth = $siteHeader.width(), 40 $menuPosition = $siteHeader.offset(), 41 $menuItemPosition = $(this).offset(), 42 $positionLeft = $menuItemPosition.left - $menuPosition.left; 43 44 $(this).find('.responsive-megamenu').css({ left: '-' + $positionLeft + 'px', width: $menuWidth }); 45 46 let $megaSubMenuOffset = $(this).find('.responsive-megamenu').offset(); 47 let $tabWidth = $(this).find('.responsive-megamenu > li').width(); 48 49 $(this).find('.responsive-megamenu .children, .responsive-megamenu .sub-menu').offset({ top: $megaSubMenuOffset.top }); 50 $(this).find('.responsive-megamenu .children, .responsive-megamenu .sub-menu').css({ width: $tabWidth }); 51 } 52 53 // Menu Container 54 if ($(menuIDClass + '.responsive-megamenu-parent').hasClass(class_prefix + 'menu-container')) { 55 let $siteHeader = $('.responsive-site-header-wrap .container #header-menu'), 56 $menuWidth = $siteHeader.width(), 57 $menuPosition = $siteHeader.offset(), 58 $menuItemPosition = $(this).offset(), 59 $positionLeft = $menuItemPosition.left - $menuPosition.left; 60 61 $(this).find('.responsive-megamenu').css({ left: '-' + $positionLeft + 'px', width: $menuWidth }); 62 $(this).find('.responsive-megamenu .children, .responsive-megamenu .sub-menu').css({ width: 'auto' }); 63 } 64 65 // Full Width 66 if ($(menuIDClass + '.responsive-megamenu-parent').hasClass(class_prefix + 'full')) { 67 let $containerRow = $('.responsive-site-header-wrap .container > .site-header-row'), 68 $siteHeader = $('#masthead.site-header'), 69 $menuWidth = $siteHeader.width(), 70 $menuPosition = $siteHeader.offset(), 71 $menuItemPosition = $(this).offset(), 72 $positionLeft = $menuItemPosition.left - $menuPosition.left; 73 74 $(this).find('.responsive-full-megamenu-wrapper').css({ left: '-' + $positionLeft + 'px', width: $menuWidth }); 75 76 let $tabWidth = $(this).find('.responsive-megamenu > li').width(); 77 78 $(this).find('.responsive-megamenu.sub-menu').css({ position: 'unset', width: $containerRow.width(), margin: '0 auto' }); 79 $(this).find('.responsive-megamenu .children, .responsive-megamenu .sub-menu').css({ width: $tabWidth }); 80 } 81 82 // Full Stretched Width 83 if ($(menuIDClass + '.responsive-megamenu-parent').hasClass(class_prefix + 'full-stretched')) { 84 let $siteHeader = $('#masthead.site-header'), 85 $menuWidth = $siteHeader.width(), 86 $menuPosition = $siteHeader.offset(), 87 $menuItemPosition = $(this).offset(), 88 $positionLeft = $menuItemPosition.left - $menuPosition.left; 89 90 $(this).find('.responsive-megamenu').css({ left: '-' + $positionLeft + 'px', width: $menuWidth }); 91 92 let $tabWidth = $(this).find('.responsive-megamenu > li').width(); 93 94 $(this).find('.responsive-megamenu .children, .responsive-megamenu .sub-menu').css({ width: $tabWidth }); 95 } 96 97 // Custom Width 98 if ($(menuIDClass + '.responsive-megamenu-parent').hasClass(class_prefix + 'custom')) { 99 let $siteHeader = $('.responsive-site-header-wrap .container #header-menu'), 100 $menuWidth = $siteHeader.width(); 101 102 let customWidth = $('#site-navigation ' + menuIDClass + '.responsive-megamenu-parent').data('custom-width'); 103 customWidth = (typeof customWidth !== 'undefined') ? customWidth : 600; 104 105 let renderedWidth = Math.abs(customWidth - $menuWidth); 106 107 $(this).find('.responsive-megamenu').css({ left: '-' + renderedWidth + 'px', width: customWidth }); 108 109 let $tabWidth = $(this).find('.responsive-megamenu > li').width(); 110 111 $(this).find('.responsive-megamenu .children, .responsive-megamenu .sub-menu').css({ width: $tabWidth }); 112 } 113 }, 114 function() { 115 if ($(menuIDClass + '.responsive-megamenu-parent').hasClass(class_prefix + 'full')) { 116 $(this).find('.responsive-megamenu.sub-menu').css({ position: 'absolute' }); 117 } 118 $(this).find('.responsive-megamenu').css({ left: '-99999em' }); 119 } 120 ); 121 }); 122 } 123 124})(jQuery);
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.