1(function ($) { 2 'use strict'; 3 4 $('.megamenu-parent').each(function(index, el) { 5 var megamenu_parent = $(this); 6 var megamenu = $(megamenu_parent).children('.sub-menu'); 7 var megamenu_columns_count = megamenu.children('.megamenu-column').length; 8 9 // Get predefined in menu width for megamenu using data-width attribute 10 var megamenu_width = megamenu_parent.attr('data-width'); 11 var megamenu_left = ''; 12 var megamenu_parent_itemwidth = 0; 13 14 // change .sub-menu to .megamenu-submenu to get rid of standard styling 15 $(megamenu).attr('class', '').addClass('megamenu-sub-menu'); 16 $(megamenu).find('.sub-menu').each(function(){ 17 // change .sub-menu to .megamenu-inner-sub-menu 18 $(this).attr('class', '').addClass('megamenu-inner-sub-menu'); 19 }); 20 21 // add some css helper classes 22 $(megamenu).find('.megamenu-column').each(function(){ 23 $(this).find('.megamenu-inner-sub-menu .megamenu-heading').eq(0).addClass('first-submenu-header'); 24 }); 25 26 if ( megamenu_width === '' ) { 27 megamenu_width = 260*megamenu_columns_count; // Set default dropdown width value 28 } 29 30 if ( megamenu_width === 'full' ) { 31 // megamenu_width = '100%'; // Set full width dropdown 32 33 megamenu_left = '0'; 34 // Set megamenu dropdown width 35 megamenu.css({ 36 width: '100%', 37 'margin-left': megamenu_left 38 }); 39 40 } else { 41 megamenu_parent_itemwidth = $(megamenu_parent).outerWidth(); 42 megamenu_left = parseInt(megamenu_width,10)/2*(-1) + megamenu_parent_itemwidth/2; 43 44 megamenu.css({ 45 width: megamenu_width + 'px', 46 'margin-left': megamenu_left + 'px' 47 }); 48 } 49 50 megamenu_parent.addClass('megamenu-columns-'+megamenu_columns_count); 51 52 // make sure mega menu dropdown doesn't go out of screen 53 var window_width = jQuery(window).width(); 54 var megamenu_parent_offset = $(megamenu_parent).offset(); 55 56 if (megamenu_width != 'full') { 57 // if screen size is smaller than megamenu panel 58 if ( ( window_width < megamenu_width ) || 0 > ( megamenu_parent_offset.left - megamenu_width) ) { 59 // make mega menu full width 60 $(this).addClass('mm-width-full'); 61 megamenu_left = '0'; 62 megamenu.css({ 63 width: '100%', 64 'margin-left': megamenu_left 65 }); 66 } else if ( window_width < ( megamenu_parent_offset.left + ( megamenu_parent_itemwidth / 2 ) + megamenu_width / 2 ) ) { 67 // if megamenu comes out of the screen on the right 68 $(megamenu_parent).addClass('dropdown-align-right'); 69 megamenu.css({ 70 'margin-left': '0', 71 'right': '0', 72 'left': 'auto' 73 }); 74 } 75 } 76 }); 77 78 79})(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.