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