1/** 2 * @package WordPress Plugin 3 * @subpackage CMSMasters Mega Menu 4 * @version 1.2.9 5 * 6 * Mega Menu Script 7 * Created by CMSMasters 8 * 9 */ 10 11 12var header = jQuery('#header .header_mid_inner'), 13 nav = jQuery('#navigation'); 14 15if(nav.length > 0) { 16 var nav_left = nav.offset().left, 17 mega = nav.find('> li.menu-item-mega'), 18 header_width = header.width(), 19 firstRun = true, 20 rtl = jQuery('html').attr('dir'); 21 22 23 jQuery(document).ready(function() { 24 cmsmastersMegaMenu(); 25 } ); 26 27 28 jQuery(window).on('debouncedresize', function () { 29 setTimeout(function () { 30 cmsmastersMegaMenu(); 31 }, 150); 32 } ); 33 34 35 jQuery(window).on('debouncedscroll', function () { 36 cmsmastersMegaMenu(); 37 } ); 38} 39 40function cmsmastersMegaMenu() { 41 var win_width = jQuery(window).width(), 42 new_header_width = header.width(), 43 header_pad_left = Number(header.css('padding-left').replace('px', '')), 44 header_left = header.offset().left + header_pad_left, 45 header_right = header_left + new_header_width, 46 new_nav_left = nav.offset().left; 47 48 49 if ( 50 firstRun || 51 new_header_width !== header_width || 52 new_nav_left !== nav_left 53 ) { 54 mega.each(function () { 55 var li = jQuery(this), 56 full = li.hasClass('menu-item-mega-fullwidth'), 57 drop_right = li.hasClass('menu-item-dropdown-right'), 58 li_left = li.offset().left, 59 mega = li.find('> div'); 60 61 62 if (mega.length === 1) { 63 var mega_width = mega.outerWidth(), 64 mega_left = mega.offset().left, 65 mega_right = mega_left + mega_width; 66 67 68 if (full) { 69 mega.css( { 70 width : new_header_width + 'px', 71 right : 'auto', 72 left : '-' + (li_left - header_left) + 'px' 73 } ); 74 75 76 } else { 77 if (mega_width >= new_header_width) { 78 li.addClass('menu-item-mega-fullwidth menu-item-mega-dynamic-fullwidth').find('> div').css( { 79 width : new_header_width + 'px', 80 right : 'auto', 81 left : '-' + ((typeof(rtl) === 'undefined') ? (li_left - header_left) : (mega_right - header_right)) + 'px' 82 } ); 83 84 85 } else { 86 if (drop_right) { 87 if (typeof(rtl) === 'undefined') { 88 if (mega_left < header_left) { 89 mega.css( { 90 right : 'auto', 91 left : '-' + (li_left - header_left) + 'px' 92 } ); 93 } 94 } else { 95 if (mega_right > header_right) { 96 mega.css( { 97 left : '-' + (mega_right - header_right) + 'px' 98 } ); 99 } 100 } 101 } else { 102 if (typeof(rtl) === 'undefined') { 103 if (mega_right > header_right) { 104 mega.css( { 105 left : '-' + (mega_right - header_right) + 'px' 106 } ); 107 } else if (mega_left < header_left) { 108 mega.css( { 109 left : '-' + (li_left - header_left) + 'px' 110 } ); 111 } 112 } else { 113 if (mega_left < header_left) { 114 mega.css( { 115 right : 'auto', 116 left : '-' + (li_left - header_left) + 'px' 117 } ); 118 } 119 } 120 } 121 } 122 } 123 124 125 if (win_width < 1008) { 126 mega.css( { 127 width : '', 128 right : '', 129 left : '' 130 } ); 131 132 133 mega.find('a').each(function () { 134 var a_style = jQuery(this).attr('style'), 135 span_tag = jQuery(this).find('span'); 136 137 138 jQuery(this).removeAttr('style').attr('data-style', a_style); 139 140 141 span_tag.each(function () { 142 var span_style = jQuery(this).attr('style'); 143 144 145 jQuery(this).removeAttr('style').attr('data-style', span_style); 146 } ); 147 } ); 148 } else { 149 mega.find('a').each(function () { 150 var a_style = jQuery(this).attr('data-style'), 151 span_tag = jQuery(this).find('span'); 152 153 154 jQuery(this).removeAttr('data-style').attr('style', a_style); 155 156 157 span_tag.each(function () { 158 var span_style = jQuery(this).attr('data-style'); 159 160 161 jQuery(this).removeAttr('data-style').attr('style', span_style); 162 } ); 163 } ); 164 } 165 } 166 } ); 167 168 169 nav_left = new_nav_left; 170 } 171 172 173 firstRun = false; 174} 175 176 177function cmsmastersMegaMenuDestroy() { 178 mega.each(function () { 179 var li = jQuery(this), 180 mega = li.find('> div'); 181 182 183 mega.css( { 184 width : '', 185 right : '', 186 left : '' 187 } ); 188 } ); 189 190 191 firstRun = true; 192} 193
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.