https://hammersmithlondon.co.uk/wp-content/themes/kadabra_consumer/assets/js/jquery.mega-menu.run.js
1(function($){ 2 var $window = $(window); 3 $.runMegaMenu = function() { 4 $("nav.mega-menu") 5 .accessibleMegaMenu({ 6 /* prefix for generated unique id attributes, which are required 7 to indicate aria-owns, aria-controls and aria-labelledby */ 8 uuidPrefix: "accessible-megamenu", 9 /* css class used to define the megamenu styling */ 10 menuClass: "nav-menu", 11 /* css class for a top-level navigation item in the megamenu */ 12 topNavItemClass: "nav-item", 13 /* css class for a megamenu panel */ 14 panelClass: "sub-nav", 15 /* css class for a group of items within a megamenu panel */ 16 panelGroupClass: "sub-nav-group", 17 /* css class for the hover state */ 18 hoverClass: "hover", 19 /* css class for the focus state */ 20 focusClass: "focus", 21 /* css class for the open state */ 22 openClass: "open" 23 }) 24 .on('megamenu:open', function(e, el) { 25 if ($window.width() <= screen_medium) return false; 26 27 var $menu = $(this), 28 $el = $(el), 29 $sub_nav; 30 31 if ($el.is('.main-menu-link.open') && $el.siblings('div.sub-nav').length>0) { 32 $sub_nav = $el.siblings('div.sub-nav') 33 } else if ($el.is('div.sub-nav')) { 34 $sub_nav = $el; 35 $el = $sub_nav.siblings('.main-menu-link'); 36 } else { 37 return true; 38 } 39 40 $sub_nav.removeAttr('style').removeClass('sub-nav-onecol'); 41 42 var w_width = $window.width(); 43 var sub_nav_width = $sub_nav.width(); 44 var sub_nav_offset = $el.offset().left - $menu.offset().left; 45 var left = 0, offset; 46 var test = $menu.parent().offset().left - $menu.offset().left; 47 48 if (sub_nav_width > w_width) { 49 $sub_nav 50 .css({ 51 'max-width': w_width 52 }) 53 .addClass('sub-nav-onecol'); 54 55 sub_nav_width = $sub_nav.width(); 56 } 57 58 59 offset = Math.floor( (sub_nav_width - $el.width()) / 2 ); 60 left = sub_nav_offset - offset; 61 if ( left < test ) left = test; 62 63 $sub_nav.css('left', left); 64 65 }); 66 }; 67 68 $.cloneMenuItems = function() { 69 var main_mega_menu = $('#main_mega_menu'); 70 var more_menu_item = $('<li id="nav-menu-item-more" class="menu-item-more mega-menu-item nav-item menu-item-depth-0 has-submenu" style="display: none">\n\ 71 <a class="menu-link main-menu-link" href="#"><span class="item-title">More</span></a>\n\ 72 <div class="sub-nav">\n\ 73 <ul class="menu-depth-1 sub-menu sub-nav-group"></ul>\n\ 74 </div></li>'); 75 76 $('> ul > li', main_mega_menu).each(function() { 77 $('> div.sub-nav > ul', more_menu_item).append($(this).clone().hide().removeClass('current-menu-parent current-menu-ancestor current-menu-item')); 78 }); 79 80 81 var depth_reg = /(menu-item-|menu-)depth-(\d+)/; 82 $('ul, li', more_menu_item).each(function() { 83 var depth = depth_reg.exec($(this).attr('class')); 84 if (depth != null) { 85 var old_depth = depth[2]; 86 var new_depth = parseInt(old_depth) + 1; 87 88 $(this).removeClass(depth[0]).addClass(depth[0].replace(old_depth, new_depth)); 89 } 90 }); 91 92 // 2-й ÑÑÐ¾Ð²ÐµÐ½Ñ 93 $('> div.sub-nav > ul > li', more_menu_item).addClass('sub-nav-item').children('a').removeClass('main-menu-link').addClass('sub-menu-link'); 94 95 // 3-й ÑÑÐ¾Ð²ÐµÐ½Ñ 96 $('> div.sub-nav > ul > li > div.sub-nav > ul', more_menu_item).unwrap().removeClass('sub-menu sub-nav-group').addClass('sub-sub-menu'); 97 98 $('> ul', main_mega_menu).append(more_menu_item); 99 } 100 101 $.hideShowMenuItems = function() { 102 var main_mega_menu = $('#main_mega_menu').parent('.header-col'); 103 var main_mena_menu_width = main_mega_menu.width(); 104 var items_width = 0; 105 var nav_menu_item_more = $('#nav-menu-item-more'); 106 107 $('nav > ul > li', main_mega_menu).each(function() { 108 var menu_item = $(this); 109 110 if (menu_item.hasClass('menu-item-more')) { 111 return false; 112 } 113 114 if (menu_item.is(':visible')) { 115 items_width += menu_item.outerWidth(true); 116 } 117 118 if (items_width > main_mena_menu_width) { 119 menu_item.prev().hide().end().hide(); 120 121 nav_menu_item_more.find('#'+menu_item.prev().attr('id')).show(); 122 nav_menu_item_more.find('#'+menu_item.attr('id')).show(); 123 124 if (!nav_menu_item_more.is(':visible')) { 125 nav_menu_item_more.show(); 126 } 127 } else { 128 var first_hidden_menu_item = $('nav > ul > li:hidden:first', main_mega_menu); 129 if (main_mena_menu_width - items_width > first_hidden_menu_item.outerWidth(true)) { 130 first_hidden_menu_item.show(); 131 nav_menu_item_more.find('#'+first_hidden_menu_item.attr('id')).hide(); 132 } 133 } 134 }); 135 136 if ($('nav > ul > li.mega-menu-item:hidden', main_mega_menu).length === 0) { 137 nav_menu_item_more.hide(); 138 } 139 } 140})(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.