1/*jslint browser: true, white: true */ 2/*global console,jQuery,megamenu,window,navigator*/ 3 4/** 5 * EDD Ajax Cart 6 */ 7(function($) { 8 "use strict"; 9 10 $(function() { 11 $('body').on('edd_cart_item_added', function(event, data) { 12 $('.mega-menu-edd-cart-total').html(data.total); 13 $('.mega-menu-edd-cart-count').html(data.cart_quantity); 14 }); 15 }); 16 17})(jQuery); 18 19/** 20 * Searchbox jQuery plugin 21 */ 22(function($) { 23 "use strict"; 24 25 $.maxmegamenu_searchbox = function(menu, options) { 26 27 var plugin = this; 28 var $menu = $(menu); 29 var $wrap = $menu.parent(); 30 var breakpoint = $menu.attr('data-breakpoint'); 31 32 plugin.isDesktopView = function() { 33 return Math.max(window.outerWidth, $(window).width()) >= breakpoint; // account for scrollbars 34 }; 35 36 plugin.monitorView = function() { 37 if (typeof $menu.data("view") === 'undefined') { 38 if (plugin.isDesktopView()) { 39 $menu.data("view", "desktop"); 40 } else { 41 $menu.data("view", "mobile"); 42 } 43 } 44 45 plugin.checkWidth(); 46 47 $(window).resize(function() { 48 plugin.checkWidth(); 49 }); 50 }; 51 52 plugin.checkWidth = function() { 53 var expanding_search = $("li.mega-menu-item .mega-search.expand-to-left input[type=text], li.mega-menu-item .mega-search.expand-to-right input[type=text]", $menu); 54 55 if ( $menu.data("view") === "mobile" ) { 56 var placeholder = expanding_search.attr('data-placeholder'); 57 expanding_search.attr('placeholder', placeholder); 58 } 59 60 if ( $menu.data("view") === "desktop" ) { 61 expanding_search.attr('placeholder', ''); 62 } 63 }; 64 65 plugin.init_replacements_search = function() { 66 67 $(".mega-search", $menu).children('input[type=text]').val(""); 68 69 if ( $menu.data("view") === "mobile" ) { 70 $(".mega-search.expand-to-left .search-icon", $menu).on('click', function(e) { 71 $(this).parents(".mega-search").submit(); 72 }); 73 } else { 74 $(".mega-search input[type=text]", $menu).on('focus', function(e) { 75 var form = $(this).parents('.mega-search'); 76 77 if (! form.parent().hasClass('mega-static') && form.hasClass('mega-search-closed') && $menu.hasClass('mega-keyboard-navigation') ) { 78 $(this).attr('placeholder', $(this).attr('data-placeholder')); 79 form.removeClass('mega-search-closed'); 80 form.addClass('mega-search-open'); 81 } 82 }); 83 84 $(".mega-search input[type=text]", $menu).on('blur', function(e) { 85 var form = $(this).parents('.mega-search'); 86 87 if ( ! form.parent().hasClass('mega-static') && form.hasClass('mega-search-open') && $menu.hasClass('mega-keyboard-navigation') ) { 88 $(this).attr('placeholder', ''); 89 form.removeClass('mega-search-open'); 90 form.addClass('mega-search-closed'); 91 } 92 }); 93 94 $(".mega-search .search-icon", $menu).on('click', function(e) { 95 96 var input = $(this).parents('.mega-search').children('input[type=text]'); 97 var form = $(this).parents('.mega-search'); 98 99 if (form.parent().hasClass('mega-static') ) { 100 if (input.val() != '') { 101 form.submit(); 102 } 103 } else if (form.hasClass('mega-search-closed')) { 104 input.focus(); 105 input.attr('placeholder', input.attr('data-placeholder')); 106 form.removeClass('mega-search-closed'); 107 form.addClass('mega-search-open'); 108 } else if ( input.val() == '' ) { 109 form.addClass('mega-search-closed'); 110 form.removeClass('mega-search-open'); 111 input.attr('placeholder', ''); 112 } else { 113 form.submit(); 114 } 115 }); 116 } 117 }; 118 119 120 plugin.init_toggle_search = function() { 121 122 $(".mega-menu-toggle .mega-search", $wrap).children('input[type=text]').val(""); 123 124 $(".mega-menu-toggle .mega-search .search-icon", $wrap).on('click', function(e) { 125 126 var input = $(this).parents('.mega-search').children('input[type=text]'); 127 var form = $(this).parents('.mega-search'); 128 129 if (form.hasClass('static') ) { 130 form.submit(); 131 } else if (form.hasClass('mega-search-closed')) { 132 input.focus(); 133 input.attr('placeholder', input.attr('data-placeholder')); 134 form.removeClass('mega-search-closed'); 135 form.addClass('mega-search-open'); 136 } else if ( input.val() == '' ) { 137 form.addClass('mega-search-closed'); 138 form.removeClass('mega-search-open'); 139 input.attr('placeholder', ''); 140 } else { 141 form.submit(); 142 } 143 }); 144 145 }; 146 147 plugin.monitorView(); 148 plugin.init_replacements_search(); 149 plugin.init_toggle_search(); 150 151 }; 152 153 $.fn.maxmegamenu_searchbox = function(options) { 154 155 return this.each(function() { 156 if (undefined === $(this).data('maxmegamenu_searchbox')) { 157 var plugin = new $.maxmegamenu_searchbox(this, options); 158 $(this).data('maxmegamenu_searchbox', plugin); 159 } 160 }); 161 162 }; 163 164 $(function() { 165 $(".mega-menu").maxmegamenu_searchbox(); 166 }); 167})(jQuery); 168 169/** 170 * Sticky jQuery Plugin 171 */ 172(function($) { 173 174 "use strict"; 175 176 $.maxmegamenu_sticky = function(menu, options) { 177 var plugin = this; 178 var $menu = $(menu); 179 var $wrap = $menu.parent(); 180 var breakpoint = $menu.attr('data-breakpoint'); 181 var sticky_on_mobile = $menu.attr('data-sticky-mobile'); 182 var sticky_expand = $menu.attr('data-sticky-expand'); 183 var sticky_offset = parseInt($menu.attr('data-sticky-offset')); 184 var sticky_hide_until_scroll_up = $menu.attr('data-sticky-hide'); 185 var sticky_hide_until_scroll_up_tolerance = parseInt($menu.attr('data-sticky-hide-tolerance')); 186 var sticky_hide_until_scroll_up_offset = parseInt($menu.attr('data-sticky-hide-offset')); 187 var sticky_menu_offset_top; 188 var sticky_menu_offset_left; 189 var sticky_menu_width; 190 var sticky_menu_width_round_up; 191 var sticky_menu_height; 192 var is_stuck = false;
193 var admin_bar_height = 0; 194 var last_scroll_top = 0; 195 var saved_scroll_top = 0; 196 var is_vertical = $menu.hasClass('mega-menu-vertical') || $menu.hasClass('mega-menu-accordion'); 197 198 var sticky_hide_until_scroll_up_enabled = function() { 199 return $menu.hasClass('mega-menu-horizontal') && sticky_hide_until_scroll_up == "true"; 200 } 201 202 var sticky_enabled = function() { 203 return $(window).width() > breakpoint || sticky_on_mobile === 'true'; 204 }; 205 206 plugin.calculate_menu_position = function() { 207 sticky_menu_offset_top = $wrap.offset().top; 208 209 if ($('body').hasClass('admin-bar') && $("#wpadminbar").is(":visible") && $("#wpadminbar").css('top') == '0px') { 210 admin_bar_height = $('#wpadminbar').height(); 211 sticky_menu_offset_top = sticky_menu_offset_top - admin_bar_height; 212 } 213 214 if (sticky_offset < 0) { 215 sticky_menu_offset_top = sticky_menu_offset_top + sticky_offset; 216 } else { 217 sticky_menu_offset_top = sticky_menu_offset_top - sticky_offset; 218 } 219 220 sticky_menu_offset_left = $menu.parent().offset().left; 221 sticky_menu_width = window.getComputedStyle($wrap[0]).width; 222 sticky_menu_width_round_up = Math.ceil(parseFloat(sticky_menu_width)); 223 sticky_menu_height = $wrap.height(); 224 }; 225 226 plugin.stick_menu = function() { 227 is_stuck = true; 228 229 var total_offset = parseInt(admin_bar_height, 10) + parseInt(sticky_offset, 10); 230 231 if (sticky_offset < 0) { 232 total_offset = parseInt(admin_bar_height, 10); 233 } 234 235 var placeholder = $("<div />").addClass("mega-sticky-wrapper").css({ 236 'height' : sticky_menu_height + 'px', 237 'position' :'static' 238 }); 239 240 $wrap.addClass('mega-sticky').wrap(placeholder).css({ 241 'margin-top' : total_offset + 'px' 242 }); 243 244 $menu.css({ 245 'margin-left' : sticky_menu_offset_left + 'px', 246 'max-width' : sticky_menu_width_round_up + 'px' 247 }); 248 249 if (is_vertical || sticky_expand === 'false') { 250 $wrap.css({ 251 'margin-left' : '0', 252 'margin-right' : '0', 253 'width' : sticky_menu_width_round_up + 'px', 254 'left' : sticky_menu_offset_left + 'px' 255 }); 256 257 $menu.css({ 258 'margin-left' : '0' 259 }); 260 } 261 262 if ( sticky_expand === 'true' && $(window).width() <= breakpoint ) { 263 $menu.css({ 264 'max-width' : 'none', 265 'margin-left' : '0' 266 }); 267 } 268 269 $wrap.delay(0).queue(function(next){ 270 $(this).addClass('mega-stuck'); 271 next(); 272 }); 273 }; 274 275 plugin.unstick_menu = function() { 276 is_stuck = false; 277 278 $wrap.removeClass('mega-sticky').removeClass('mega-stuck').removeClass('mega-hide').removeClass('mega-reveal').unwrap().css({ 279 'margin' : '', 280 'width' : '', 281 'left': '' 282 }); 283 284 $menu.css({ 285 'margin-left' : '', 286 'max-width' : '' 287 }); 288 }; 289 290 plugin.mega_sticky_on_scroll = function(){ 291 if ( ! sticky_enabled() ) { 292 return; 293 } 294 295 var scroll_top = $(window).scrollTop(); 296 297 if (scroll_top > sticky_menu_offset_top) { 298 if (!is_stuck) { 299 plugin.stick_menu(); 300 } 301 } else { 302 if (is_stuck) { 303 plugin.unstick_menu(); 304 } 305 } 306 }; 307 308 var mega_hide_on_scroll_up = function() { 309 if (sticky_hide_until_scroll_up_enabled()) { 310 311 if ( $menu.data("view") === "mobile" && $('.mega-menu-toggle', $wrap).hasClass('mega-menu-open') ) { 312 return; 313 } 314 315 var scroll_top = $(window).scrollTop(); 316 317 if ( last_scroll_top > 0 ) { 318 // Only hide once scrolling. Show menu when refreshing page. 319 $wrap.addClass('mega-hide'); 320 } 321 322 if ( scroll_top < sticky_hide_until_scroll_up_offset ) { 323 $wrap.addClass('mega-reveal'); 324 } 325 326 saved_scroll_top = last_scroll_top; 327 328 if (scroll_top < last_scroll_top) { 329 // scroll up 330 if (saved_scroll_top - scroll_top > sticky_hide_until_scroll_up_tolerance) { 331 $wrap.addClass('mega-reveal'); 332 } 333 } else { 334 // scroll down 335 if (scroll_top - saved_scroll_top > sticky_hide_until_scroll_up_tolerance) { 336 $wrap.removeClass('mega-reveal'); 337 } 338 } 339 340 last_scroll_top = scroll_top; 341 } 342 } 343 344 plugin.mega_sticky_on_resize = function() { 345 if ($('input', $wrap).is(':focus')) { 346 return; 347 } 348 349 if ( sticky_enabled() ) { 350 if (is_stuck) { 351 plugin.unstick_menu(); 352 plugin.calculate_menu_position(); 353 plugin.stick_menu(); 354 } else { 355 plugin.calculate_menu_position(); 356 plugin.mega_sticky_on_scroll(); 357 } 358 } else { 359 if (is_stuck) { 360 plugin.unstick_menu(); 361 } 362 } 363 }; 364 365 plugin.init = function() { 366 plugin.calculate_menu_position(); 367 plugin.mega_sticky_on_scroll(); 368 369 var $window = $(window); 370 371 $window.scroll(function() { 372 plugin.mega_sticky_on_scroll(); 373 mega_hide_on_scroll_up(); 374 }); 375 376 var windowWidth = $window.width(); 377 378 $window.resize(function() { 379 if ($window.width() != windowWidth) { 380 windowWidth = $window.width(); 381 plugin.mega_sticky_on_resize(); 382 } 383 }); 384 }; 385 386 plugin.init(); 387 }; 388 389 $.fn.maxmegamenu_sticky = function(options) { 390 391 return this.each(function() { 392 if (undefined === $(this).data('maxmegamenu_sticky')) { 393 var plugin = new $.maxmegamenu_sticky(this, options); 394 $(this).data('maxmegamenu_sticky', plugin); 395 } 396 }); 397 398 }; 399 400 $(window).on('load', function (e) { 401 $(".mega-menu[data-sticky-enabled]").maxmegamenu_sticky(); 402 }); 403 404})(jQuery); 405 406/** 407 * Handle tabbed functionality 408 */ 409(function($) { 410 $(function() { 411 412 var calculate_tabbed_sub_menu_widths = function( menu_item ) { 413 var menu = menu_item.parents('.mega-menu'); 414 415 if( $(menu.attr('data-panel-inner-width')).length > 0 ) { 416 if ( menu.data("view") === "desktop" ) { 417 $('> ul.mega-sub-menu', menu_item).each(function() { 418 var tab_content = $(this); 419 var parent_submenu_content_width = parseInt(tab_content.width()); 420 var parent_submenu_left_padding = parseInt(tab_content.css('paddingLeft')); 421 var tabs_width = $(this).find('a.mega-menu-link').first().outerWidth(); 422 423 $('> li.mega-menu-item > ul.mega-sub-menu', $(this)).each(function() { 424 $(this).css('width', parent_submenu_content_width - tabs_width + 'px'); 425 $(this).css('left', parent_submenu_left_padding + tabs_width + 'px'); 426 }); 427 }); 428 } else { 429 $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function() { 430 $(this).css('width', ''); 431 $(this).css('left', ''); 432 }); 433 } 434 } 435 } 436 437 var calculate_tabbed_sub_menu_heights = function( menu_item ) { 438 var menu = menu_item.parents('.mega-menu'); 439 var max_height = 0; 440 441 if ( menu.data("view") === "desktop" ) { 442 443 $('> ul.mega-sub-menu', menu_item).css('minHeight', ''); 444 445 $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function() { 446 var tab_content = $(this); 447 var this_height = parseInt(tab_content.css('height')); 448 449 if (this_height > max_height) { 450 max_height = this_height; 451 } 452 }); 453 454 $('> ul.mega-sub-menu', menu_item).css('minHeight', max_height); 455 } else { 456 $('> ul.mega-sub-menu', menu_item).css('minHeight', ''); 457 } 458 } 459 460 var $window = $(window); 461 462 var windowWidth = $window.width(); 463 464 $window.resize(function() { 465 if ($window.width() != windowWidth) { 466 calculate_tabbed_sub_menu_widths($('li.mega-menu-tabbed')); 467 calculate_tabbed_sub_menu_heights($('li.mega-menu-tabbed')); 468 } 469 }); 470 471 $('li.mega-menu-tabbed').on('open_panel', function() { 472 var menu = $(this).parents('.mega-menu'); 473 var menu_item = $(this); 474 475 $("> ul.mega-sub-menu", $(this)).promise().done(function(){ 476 calculate_tabbed_sub_menu_widths( menu_item ); 477 calculate_tabbed_sub_menu_heights( menu_item ); 478 }); 479 480 if ( menu.data('view') == 'desktop' ) { 481 if ($('> ul.mega-sub-menu > li.mega-menu-item-has-children.mega-toggle-on', menu_item).length == 0 ) { 482 $('> ul.mega-sub-menu > li.mega-menu-item-has-children', menu_item).first().addClass('mega-toggle-on'); 483 } 484 } 485 486 $('li.mega-menu-tabbed').on('close_panel', function() { 487 $(".mega-toggle-on", menu).removeClass("mega-toggle-on"); 488 }); 489 }); 490 }); 491})(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.