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 $(".max-mega-menu").on("after_mega_menu_init", function() { 18 $('li.mega-menu-megamenu').on('open_panel', function() { 19 $('.mega-sub-menu [data-image-swap-url]', $(this) ).not(['data-preloaded']).each( function() { 20 $('<img/>')[0].src = $(this).attr('data-image-swap-url'); 21 $(this).attr('data-preloaded', 'true'); 22 }); 23 }); 24 25 $('.mega-sub-menu [data-image-swap-url]').hoverIntent({ 26 over: function () { 27 var placeholder = $(this).closest(".mega-menu-megamenu").find(".widget_maxmegamenu_image_swap img.mega-placeholder"); 28 var new_src = $(this).attr('data-image-swap-url'); 29 placeholder.attr('src', new_src); 30 }, 31 out: function() {} 32 }); 33 }); 34 35})(jQuery); 36 37/** 38 * Searchbox jQuery plugin 39 */ 40(function($) { 41 "use strict"; 42 43 $.maxmegamenu_searchbox = function(form, options) { 44 45 var plugin = this; 46 var form = $(form); 47 var $menu = form.parents('.max-mega-menu'); 48 var $wrap = $menu.parent(); 49 var breakpoint = $menu.attr('data-breakpoint'); 50 var input = $('input[type=text]', form); 51 var icon = $('.search-icon', form); 52 53 plugin.isDesktopView = function() { 54 return Math.max(window.outerWidth, $(window).width()) >= breakpoint; // account for scrollbars 55 }; 56 57 plugin.monitorView = function() { 58 if (typeof $menu.data("view") === 'undefined') { 59 if (plugin.isDesktopView()) { 60 $menu.data("view", "desktop"); 61 } else { 62 $menu.data("view", "mobile"); 63 } 64 } 65 66 plugin.checkWidth(); 67 68 $(window).resize(function() { 69 plugin.checkWidth(); 70 }); 71 }; 72 73 plugin.checkWidth = function() { 74 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); 75 76 if ( $menu.data("view") === "mobile" ) { 77 var placeholder = expanding_search.attr('data-placeholder'); 78 expanding_search.attr('placeholder', placeholder); 79 } 80 81 if ( $menu.data("view") === "desktop" ) { 82 expanding_search.attr('placeholder', ''); 83 } 84 }; 85 86 plugin.close_search = function() { 87 input.val(""); 88 input.attr('placeholder', ''); 89 form.removeClass('mega-search-open'); 90 form.addClass('mega-search-closed'); 91 } 92 93 plugin.open_search = function() { 94 input.attr('placeholder', input.attr('data-placeholder')); 95 form.removeClass('mega-search-closed'); 96 form.addClass('mega-search-open'); 97 } 98 99 plugin.detect_background_click = function() { 100 var dragging = false; 101 102 $(document).on({ 103 "touchmove": function(e) { dragging = true; }, 104 "touchstart": function(e) { dragging = false; } 105 }); 106 107 $(document).on("click touchend", function(e) { // hide menu when clicked away from 108 if ( form.parent().hasClass('mega-static') ) { 109 return; 110 } 111 if ( ! dragging && ! $(e.target).closest(".max-mega-menu li").length && ! $(e.target).closest(".mega-menu-toggle").length ) { 112 plugin.close_search(); 113 } 114 dragging = false; 115 }); 116 } 117 118 plugin.init_replacements_search = function() { 119 120 input.val(""); 121 122 if ( $menu.data("view") === "mobile" ) { 123 $(".search-icon", $menu).on('click', function(e) { 124 $(this).parents(".mega-search").submit(); 125 }); 126 } 127 128 if ( $menu.data("view") === "desktop" ) { 129 input.on('focus', function(e) { 130 if (! form.parent().hasClass('mega-static') && form.hasClass('mega-search-closed') && $wrap.hasClass('mega-keyboard-navigation') ) { 131 plugin.open_search(); 132 } 133 }); 134 135 input.on('blur', function(e) { 136 if (! form.parent().hasClass('mega-static') && form.hasClass('mega-search-open') && $wrap.hasClass('mega-keyboard-navigation') ) { 137 plugin.close_search(); 138 } 139 }); 140 141 icon.on('click', function(e) { 142 if (form.parent().hasClass('mega-static') ) { 143 form.submit(); 144 return; 145 } 146 147 if (form.hasClass('mega-search-closed')) { 148 plugin.open_search(); 149 input.focus(); 150 } else if ( input.val() == '' ) { 151 plugin.close_search(); 152 } else { 153 form.submit(); 154 } 155 }); 156 } 157 }; 158 159 plugin.monitorView(); 160 plugin.init_replacements_search(); 161 plugin.detect_background_click(); 162 }; 163 164 $.fn.maxmegamenu_searchbox = function(options) { 165 return this.each(function() { 166 if (undefined === $(this).data('maxmegamenu_searchbox')) { 167 var plugin = new $.maxmegamenu_searchbox(this, options); 168 $(this).data('maxmegamenu_searchbox', plugin); 169 } 170 }); 171 }; 172 173 $(function() { 174 $(".max-mega-menu .mega-search").maxmegamenu_searchbox(); 175 }); 176})(jQuery); 177 178 179/** 180 * Searchbox jQuery plugin 181 */ 182(function($) { 183 "use strict"; 184 185 $.maxmegamenu_toggle_searchbox = function(form, options) { 186 187 var plugin = this; 188 var form = $(form); 189 var $wrap = form.parents('.mega-menu-wrap'); 190 var input = $("input[type=text]", form); 191 var icon = $(".search-icon", form); 192 193 plugin.open_search = function() { 194 input.attr('placeholder', input.attr('data-placeholder')); 195 form.removeClass('mega-search-closed'); 196 form.addClass('mega-search-open'); 197 } 198 199 plugin.close_search = function() { 200 input.attr('placeholder', ''); 201 form.removeClass('mega-search-open'); 202 form.addClass('mega-search-closed'); 203 } 204 205 plugin.init_toggle_search = function() { 206 207 input.val(""); 208 209 input.on('focus', function(e) { 210 if (! form.parent().hasClass('mega-static') && form.hasClass('mega-search-closed') && $wrap.hasClass('mega-keyboard-navigation') ) { 211 plugin.open_search(); 212 } 213 }); 214 215 input.on('blur', function(e) { 216 if ( ! form.parent().hasClass('mega-static') && form.hasClass('mega-search-open') && $wrap.hasClass('mega-keyboard-navigation') ) { 217 plugin.close_search(); 218 } 219 }); 220 221 icon.on('click', function(e) { 222 if (form.hasClass('static') ) { 223 form.submit(); 224 } else if (form.hasClass('mega-search-closed')) { 225 input.focus(); 226 plugin.open_search(); 227 } else if ( input.val() == '' ) { 228 plugin.close_search(); 229 } else { 230 form.submit(); 231 } 232 }); 233 234 }; 235 236 plugin.init_toggle_search(); 237 238 }; 239 240 $.fn.maxmegamenu_toggle_searchbox = function(options) { 241 return this.each(function() { 242 if (undefined === $(this).data('maxmegamenu_toggle_searchbox')) { 243 var plugin = new $.maxmegamenu_toggle_searchbox(this, options); 244 $(this).data('maxmegamenu_toggle_searchbox', plugin); 245 } 246 }); 247 }; 248 249 $(function() { 250 $(".mega-menu-toggle .mega-search").maxmegamenu_toggle_searchbox(); 251 }); 252})(jQuery); 253 254/** 255 * Sticky jQuery Plugin 256 */ 257(function($) { 258 259 "use strict"; 260 261 $.maxmegamenu_sticky = function(menu, options) { 262 var plugin = this; 263 var $menu = $(menu); 264 var $wrap = $menu.parent(); 265 var breakpoint = $menu.attr('data-breakpoint'); 266 var sticky_on_mobile = $menu.attr('data-sticky-mobile'); 267 var sticky_on_desktop = $menu.attr('data-sticky-desktop'); 268 var sticky_expand = $menu.attr('data-sticky-expand'); 269 var sticky_expand_mobile = $menu.attr('data-sticky-expand-mobile'); 270 var sticky_offset = isNaN(parseInt($menu.attr('data-sticky-offset'))) ? 0 : parseInt($menu.attr('data-sticky-offset')); 271 var sticky_hide_until_scroll_up = $menu.attr('data-sticky-hide'); 272 var sticky_hide_until_scroll_up_tolerance = isNaN(parseInt($menu.attr('data-sticky-hide-tolerance'))) ? 0 : parseInt($menu.attr('data-sticky-hide-tolerance')); 273 var sticky_hide_until_scroll_up_offset = isNaN(parseInt($menu.attr('data-sticky-hide-offset'))) ? 0 : parseInt($menu.attr('data-sticky-hide-offset')); 274 var sticky_transition = $menu.attr('data-sticky-transition'); 275 var sticky_menu_offset_top; 276 var sticky_menu_offset_left; 277 var sticky_menu_width; 278 var sticky_menu_width_round_up; 279 var sticky_menu_height; 280 var is_stuck = false;
281 var admin_bar_height = 0; 282 var last_scroll_top = 0; 283 var saved_scroll_top = 0; 284 var is_vertical = $menu.hasClass('mega-menu-vertical') || $menu.hasClass('mega-menu-accordion'); 285 286 plugin.isDesktopView = function() { 287 return Math.max(window.outerWidth, $(window).width()) >= breakpoint; // account for scrollbars 288 }; 289 290 var sticky_hide_until_scroll_up_enabled = function() { 291 return $menu.hasClass('mega-menu-horizontal') && sticky_hide_until_scroll_up == "true"; 292 } 293 294 var sticky_enabled = function() { 295 if ( plugin.isDesktopView() ) { 296 return sticky_on_desktop === 'true'; 297 } else { 298 return sticky_on_mobile === 'true'; 299 } 300 301 return false; 302 }; 303 304 plugin.calculate_menu_position = function() { 305 sticky_menu_offset_top = $wrap.offset().top; 306 307 if ($('body').hasClass('admin-bar') && $("#wpadminbar").is(":visible") && $("#wpadminbar").css('top') == '0px' && $("#wpadminbar").css('position') == 'fixed') { 308 admin_bar_height = $('#wpadminbar').height(); 309 sticky_menu_offset_top = sticky_menu_offset_top - admin_bar_height; 310 } 311 312 if (sticky_offset < 0) { 313 sticky_menu_offset_top = sticky_menu_offset_top + sticky_offset; 314 } else { 315 sticky_menu_offset_top = sticky_menu_offset_top - sticky_offset; 316 } 317 318 sticky_menu_offset_left = $menu.parent().offset().left; 319 sticky_menu_width = window.getComputedStyle($wrap[0]).width; 320 sticky_menu_width_round_up = Math.ceil(parseFloat(sticky_menu_width)); 321 sticky_menu_height = $wrap.height(); 322 }; 323 324 plugin.stick_menu = function() { 325 is_stuck = true; 326 327 var total_offset = parseInt(admin_bar_height, 10) + parseInt(sticky_offset, 10); 328 329 if (sticky_offset < 0) { 330 total_offset = parseInt(admin_bar_height, 10); 331 } 332 333 var placeholder = $("<div />").addClass("mega-sticky-wrapper").css({ 334 'height' : sticky_menu_height + 'px', 335 'position' :'static' 336 }); 337 338 $wrap.addClass('mega-sticky').wrap(placeholder).css({ 339 'margin-top' : total_offset + 'px' 340 }); 341 342 $menu.css({ 343 'max-width' : sticky_menu_width_round_up + 'px' 344 }); 345 346 if (sticky_menu_offset_left > 0) { 347 $menu.css({ 348 'margin-left' : sticky_menu_offset_left + 'px' 349 }); 350 } 351 352 if (is_vertical || sticky_expand === 'false') { 353 $wrap.css({ 354 'margin-left' : '0', 355 'margin-right' : '0', 356 'width' : sticky_menu_width_round_up + 'px', 357 'left' : sticky_menu_offset_left + 'px' 358 }); 359 360 $menu.css({ 361 'margin-left' : '0' 362 }); 363 } 364 365 if ( $(window).width() <= breakpoint ) { 366 $wrap.css({ 367 'width' : sticky_menu_width_round_up + 'px' 368 }); 369 370 if (sticky_expand_mobile === 'true') { 371 $wrap.css({ 372 'margin-left' : '', 373 'margin-right' : '', 374 'width' : '', 375 'left' : '' 376 }); 377 378 $menu.css({ 379 'max-width' : '', 380 'margin-left' : '', 381 'width' : '', 382 'left' : '' 383 }); 384 } 385 } 386 387 $wrap.delay(0).queue(function(next){ 388 $(this).addClass('mega-stuck'); 389 next(); 390 }); 391 }; 392 393 plugin.unstick_menu = function(doing_resize) { 394 doing_resize = doing_resize || false; 395 is_stuck = false; 396 397 $wrap.removeClass('mega-sticky').removeClass('mega-hide').removeClass('mega-reveal').css({ 398 'margin' : '', 399 'width' : '', 400 'left': '' 401 }); 402 403 if ( ! doing_resize ) { // this class is used for the height transition, do not remove it if we are simply resizing the window 404 $wrap.delay(0).queue(function(next){ 405 $(this).removeClass('mega-stuck'); 406 next(); 407 }); 408 } 409 410 $menu.css({ 411 'margin-left' : '', 412 'max-width' : '', 413 'left' : '', 414 'width' : '' 415 }); 416 417 if (sticky_transition == 'true' && ! doing_resize ) {
418 var delay = 250; // allows the transiton to complete before unwrapping the menu 419 } else { 420 var delay = 0; 421 } 422 423 $wrap.delay(delay).queue(function(next){ 424 $(this).unwrap(); 425 next(); 426 }); 427 }; 428 429 plugin.mega_sticky_on_scroll = function(){ 430 if ( ! sticky_enabled() ) { 431 return; 432 } 433 434 var scroll_top = $(window).scrollTop(); 435 436 if (scroll_top > sticky_menu_offset_top) { 437 if (!is_stuck) { 438 plugin.stick_menu(); 439 } 440 } else { 441 if (is_stuck) { 442 plugin.unstick_menu(); 443 } 444 } 445 }; 446 447 var mega_hide_on_scroll_up = function() { 448 if (sticky_hide_until_scroll_up_enabled()) { 449 450 if ( $menu.data("view") === "mobile" && $('.mega-menu-toggle', $wrap).hasClass('mega-menu-open') ) { 451 return; 452 } 453 454 var scroll_top = $(window).scrollTop(); 455 456 if ( scroll_top < sticky_hide_until_scroll_up_offset ) { 457 $wrap.removeClass('mega-hide'); 458 } 459 460 saved_scroll_top = last_scroll_top; 461 462 if (scroll_top < last_scroll_top) { 463 // scroll up 464 if (saved_scroll_top - scroll_top > sticky_hide_until_scroll_up_tolerance) { 465 $wrap.removeClass('mega-hide'); 466 } 467 } else { 468 // scroll down 469 if (scroll_top - saved_scroll_top > sticky_hide_until_scroll_up_tolerance) { 470 $wrap.addClass('mega-hide'); 471 } 472 } 473 474 last_scroll_top = scroll_top; 475 } 476 } 477 478 plugin.mega_sticky_on_resize = function() { 479 if ($('input', $wrap).is(':focus')) { 480 return; 481 } 482 483 if ( sticky_enabled() ) { 484 if (is_stuck) { 485 plugin.unstick_menu(true); 486 plugin.calculate_menu_position(); 487 plugin.stick_menu(); 488 } else { 489 plugin.calculate_menu_position(); 490 plugin.mega_sticky_on_scroll(); 491 } 492 } else { 493 if (is_stuck) { 494 plugin.unstick_menu(); 495 } 496 } 497 }; 498 499 plugin.init = function() { 500 plugin.calculate_menu_position(); 501 plugin.mega_sticky_on_scroll(); 502 503 $('.mega-menu-accordion li.mega-menu-item').on('open_panel', function() { 504 plugin.calculate_menu_position(); 505 }); 506 507 var $window = $(window); 508 509 $window.scroll(function() { 510 plugin.mega_sticky_on_scroll(); 511 mega_hide_on_scroll_up(); 512 }); 513 514 var windowWidth = $window.width(); 515 var resizeTimer; 516 517 $window.resize(function() { 518 clearTimeout(resizeTimer); 519 resizeTimer = setTimeout(function(){ 520 windowWidth = $window.width(); 521 plugin.mega_sticky_on_resize(); 522 }, 100); 523 }); 524 }; 525 526 plugin.init(); 527 }; 528 529 $.fn.maxmegamenu_sticky = function(options) { 530 531 return this.each(function() { 532 if (undefined === $(this).data('maxmegamenu_sticky')) { 533 var plugin = new $.maxmegamenu_sticky(this, options); 534 $(this).data('maxmegamenu_sticky', plugin); 535 } 536 }); 537 538 }; 539 540 $(window).on('load', function (e) { 541 $(".mega-menu[data-sticky-enabled]").maxmegamenu_sticky(); 542 }); 543 544})(jQuery); 545 546/** 547 * Handle tabbed functionality 548 */ 549(function($) { 550 $(function() { 551 552 var calculate_tabbed_sub_menu_widths = function( menu_item ) { 553 var menu = menu_item.parents('.max-mega-menu'); 554 555 if( $(menu.attr('data-panel-inner-width')).length > 0 ) { 556 if ( menu.data("view") === "desktop" ) { 557 $('> ul.mega-sub-menu', menu_item).each(function() { 558 var tab_content = $(this); 559 var parent_submenu_content_width = parseInt(tab_content.width()); 560 var parent_submenu_left_padding = parseInt(tab_content.css('paddingLeft')); 561 var tabs_width = $(this).find('a.mega-menu-link').first().outerWidth(); 562 563 $('> li.mega-menu-item > ul.mega-sub-menu', $(this)).each(function() { 564 $(this).css('width', parent_submenu_content_width - tabs_width + 'px'); 565 $(this).css('left', parent_submenu_left_padding + tabs_width + 'px'); 566 }); 567 }); 568 } else { 569 $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function() { 570 $(this).css('width', ''); 571 $(this).css('left', ''); 572 }); 573 } 574 } 575 } 576 577 var calculate_tabbed_sub_menu_heights = function( menu_item ) { 578 579 var menu = menu_item.parents('.max-mega-menu'); 580 var max_height = 0; 581 582 if ( menu.data("view") === "desktop" ) { 583 584 $('> ul.mega-sub-menu', menu_item).css('minHeight', ''); 585 586 $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function() { 587 var tab_content = $(this); 588 var this_height = parseInt(tab_content.css('height')); 589 590 if (this_height > max_height) { 591 max_height = this_height; 592 } 593 }); 594 595 var border_top_width = parseInt($('> ul.mega-sub-menu', menu_item).css('borderTopWidth'),10); 596 var border_bottom_width = parseInt($('> ul.mega-sub-menu', menu_item).css('borderBottomWidth'),10); 597 598 $('> ul.mega-sub-menu', menu_item).css('minHeight', max_height + border_bottom_width + border_top_width); 599 } else { 600 $('> ul.mega-sub-menu', menu_item).css('minHeight', ''); 601 } 602 } 603 604 var $window = $(window); 605 606 var windowWidth = $window.width(); 607 608 $window.resize(function() { 609 if ($window.width() != windowWidth) { 610 calculate_tabbed_sub_menu_widths($('li.mega-menu-tabbed')); 611 calculate_tabbed_sub_menu_heights($('li.mega-menu-tabbed')); 612 } 613 }); 614 615 $('li.mega-menu-tabbed, li.mega-menu-tabbed li.mega-collapse-children').on('open_panel', function() { 616 var menu = $(this).parents('.max-mega-menu'); 617 var menu_item = $(this).closest(".mega-menu-tabbed"); 618 619 calculate_tabbed_sub_menu_widths( menu_item ); 620 621 $(">
621 ul.mega-sub-menu", $(this)).promise().done(function(){ // wait until slide animation has completed 622 calculate_tabbed_sub_menu_heights( menu_item ); 623 }); 624 625 if ( menu.data('view') == 'desktop' ) { 626 if ($('> ul.mega-sub-menu > li.mega-menu-item-has-children.mega-toggle-on', menu_item).length == 0 ) { 627 628 629 if ( $('> ul.mega-sub-menu > li.mega-current-menu-item', menu_item).length ) { 630 $('> ul.mega-sub-menu > li.mega-current-menu-item', menu_item).first().addClass('mega-toggle-on'); 631 } else if ( $('> ul.mega-sub-menu > li.mega-current-menu-ancestor', menu_item).length ) { 632 $('> ul.mega-sub-menu > li.mega-current-menu-ancestor', menu_item).first().addClass('mega-toggle-on'); 633 } 634 635 636 if ($('> ul.mega-sub-menu > li.mega-toggle-on', menu_item).length == 0 ) { 637 $('> ul.mega-sub-menu > li.mega-menu-item-has-children', menu_item).first().addClass('mega-toggle-on'); 638 } 639 } 640 641 $('li.mega-menu-tabbed').on('close_panel', function() { 642 $(".mega-toggle-on", menu).removeClass("mega-toggle-on"); 643 }); 644 } 645 646 $('li.mega-menu-tabbed li.mega-collapse-children').on('close_panel', function() { 647 var menu_item = $(this).closest(".mega-menu-tabbed"); 648 649 $("> ul.mega-sub-menu", $(this)).promise().done(function(){ // wait until slide animation has completed 650 calculate_tabbed_sub_menu_heights( menu_item ); 651 }); 652 }); 653 }); 654 }); 655})(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.