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_on_desktop = $menu.attr('data-sticky-desktop'); 183 var sticky_expand = $menu.attr('data-sticky-expand'); 184 var sticky_expand_mobile = $menu.attr('data-sticky-expand-mobile'); 185 var sticky_offset = parseInt($menu.attr('data-sticky-offset')); 186 var sticky_hide_until_scroll_up = $menu.attr('data-sticky-hide'); 187 var sticky_hide_until_scroll_up_tolerance = parseInt($menu.attr('data-sticky-hide-tolerance')); 188 var sticky_hide_until_scroll_up_offset = parseInt($menu.attr('data-sticky-hide-offset')); 189 var sticky_menu_offset_top; 190 var sticky_menu_offset_left; 191 var sticky_menu_width; 192 var sticky_menu_width_round_up; 193 var sticky_menu_height; 194 var is_stuck = false;
195 var admin_bar_height = 0; 196 var last_scroll_top = 0; 197 var saved_scroll_top = 0; 198 var is_vertical = $menu.hasClass('mega-menu-vertical') || $menu.hasClass('mega-menu-accordion'); 199 200 plugin.isDesktopView = function() { 201 return Math.max(window.outerWidth, $(window).width()) >= breakpoint; // account for scrollbars 202 }; 203 204 var sticky_hide_until_scroll_up_enabled = function() { 205 return $menu.hasClass('mega-menu-horizontal') && sticky_hide_until_scroll_up == "true"; 206 } 207 208 var sticky_enabled = function() { 209 if ( plugin.isDesktopView() ) { 210 return sticky_on_desktop === 'true'; 211 } else { 212 return sticky_on_mobile === 'true'; 213 } 214 215 return false; 216 }; 217 218 plugin.calculate_menu_position = function() { 219 sticky_menu_offset_top = $wrap.offset().top; 220 221 if ($('body').hasClass('admin-bar') && $("#wpadminbar").is(":visible") && $("#wpadminbar").css('top') == '0px' && $("#wpadminbar").css('position') == 'fixed') { 222 admin_bar_height = $('#wpadminbar').height(); 223 sticky_menu_offset_top = sticky_menu_offset_top - admin_bar_height; 224 } 225 226 if (sticky_offset < 0) { 227 sticky_menu_offset_top = sticky_menu_offset_top + sticky_offset; 228 } else { 229 sticky_menu_offset_top = sticky_menu_offset_top - sticky_offset; 230 } 231 232 sticky_menu_offset_left = $menu.parent().offset().left; 233 sticky_menu_width = window.getComputedStyle($wrap[0]).width; 234 sticky_menu_width_round_up = Math.ceil(parseFloat(sticky_menu_width)); 235 sticky_menu_height = $wrap.height(); 236 }; 237 238 plugin.stick_menu = function() { 239 is_stuck = true; 240 241 var total_offset = parseInt(admin_bar_height, 10) + parseInt(sticky_offset, 10); 242 243 if (sticky_offset < 0) { 244 total_offset = parseInt(admin_bar_height, 10); 245 } 246 247 var placeholder = $("<div />").addClass("mega-sticky-wrapper").css({ 248 'height' : sticky_menu_height + 'px', 249 'position' :'static' 250 }); 251 252 $wrap.addClass('mega-sticky').wrap(placeholder).css({ 253 'margin-top' : total_offset + 'px' 254 }); 255 256 $menu.css({ 257 'margin-left' : sticky_menu_offset_left + 'px', 258 'max-width' : sticky_menu_width_round_up + 'px' 259 }); 260 261 if (is_vertical || sticky_expand === 'false') { 262 $wrap.css({ 263 'margin-left' : '0', 264 'margin-right' : '0', 265 'width' : sticky_menu_width_round_up + 'px', 266 'left' : sticky_menu_offset_left + 'px' 267 }); 268 269 $menu.css({ 270 'margin-left' : '0' 271 }); 272 } 273 274 if ( $(window).width() <= breakpoint ) { 275 276 $wrap.css({ 277 'margin-left' : '', 278 'margin-right' : '', 279 'width' : '', 280 'left' : '' 281 }); 282 283 $menu.css({ 284 'max-width' : '', 285 'margin-left' : '', 286 'left' : '', 287 'width' : '' 288 }); 289 290 if (sticky_expand_mobile === 'false') { 291 $wrap.css({ 292 'width' : sticky_menu_width_round_up + 'px' 293 }); 294 } 295 } 296 297 $wrap.delay(0).queue(function(next){ 298 $(this).addClass('mega-stuck'); 299 next(); 300 }); 301 }; 302 303 plugin.unstick_menu = function() { 304 is_stuck = false; 305 306 $wrap.removeClass('mega-sticky').removeClass('mega-hide').removeClass('mega-reveal').unwrap().css({ 307 'margin' : '', 308 'width' : '', 309 'left': '' 310 }); 311 312 $wrap.delay(0).queue(function(next){ 313 $(this).removeClass('mega-stuck'); 314 next(); 315 }); 316 317 $menu.css({ 318 'margin-left' : '', 319 'max-width' : '', 320 'left' : '', 321 'width' : '' 322 }); 323 }; 324 325 plugin.mega_sticky_on_scroll = function(){ 326 if ( ! sticky_enabled() ) { 327 return; 328 } 329 330 var scroll_top = $(window).scrollTop(); 331 332 if (scroll_top > sticky_menu_offset_top) { 333 if (!is_stuck) { 334 plugin.stick_menu(); 335 } 336 } else { 337 if (is_stuck) { 338 plugin.unstick_menu(); 339 } 340 } 341 }; 342 343 var mega_hide_on_scroll_up = function() { 344 if (sticky_hide_until_scroll_up_enabled()) { 345 346 if ( $menu.data("view") === "mobile" && $('.mega-menu-toggle', $wrap).hasClass('mega-menu-open') ) { 347 return; 348 } 349 350 var scroll_top = $(window).scrollTop(); 351 352 if ( last_scroll_top > 0 ) { 353 // Only hide once scrolling. Show menu when refreshing page. 354 $wrap.addClass('mega-hide'); 355 } 356 357 if ( scroll_top < sticky_hide_until_scroll_up_offset ) { 358 $wrap.addClass('mega-reveal'); 359 } 360 361 saved_scroll_top = last_scroll_top; 362 363 if (scroll_top < last_scroll_top) { 364 // scroll up 365 if (saved_scroll_top - scroll_top > sticky_hide_until_scroll_up_tolerance) { 366 $wrap.addClass('mega-reveal'); 367 } 368 } else { 369 // scroll down 370 if (scroll_top - saved_scroll_top > sticky_hide_until_scroll_up_tolerance) { 371 $wrap.removeClass('mega-reveal'); 372 } 373 } 374 375 last_scroll_top = scroll_top; 376 } 377 } 378 379 plugin.mega_sticky_on_resize = function() { 380 if ($('input', $wrap).is(':focus')) { 381 return; 382 } 383 384 if ( sticky_enabled() ) { 385 if (is_stuck) { 386 plugin.unstick_menu(); 387 plugin.calculate_menu_position(); 388 plugin.stick_menu(); 389 } else { 390 plugin.calculate_menu_position(); 391 plugin.mega_sticky_on_scroll(); 392 } 393 } else { 394 if (is_stuck) { 395 plugin.unstick_menu(); 396 } 397 } 398 }; 399 400 plugin.init = function() { 401 plugin.calculate_menu_position(); 402 plugin.mega_sticky_on_scroll(); 403 404 var $window = $(window); 405 406 $window.scroll(function() { 407 plugin.mega_sticky_on_scroll(); 408 mega_hide_on_scroll_up(); 409 }); 410 411 var windowWidth = $window.width(); 412 413 $window.resize(function() { 414 if ($window.width() != windowWidth) { 415 windowWidth = $window.width(); 416 plugin.mega_sticky_on_resize(); 417 } 418 }); 419 }; 420 421 plugin.init(); 422 }; 423 424 $.fn.maxmegamenu_sticky = function(options) { 425 426 return this.each(function() { 427 if (undefined === $(this).data('maxmegamenu_sticky')) { 428 var plugin = new $.maxmegamenu_sticky(this, options); 429 $(this).data('maxmegamenu_sticky', plugin); 430 } 431 }); 432 433 }; 434 435 $(window).on('load', function (e) { 436 $(".mega-menu[data-sticky-enabled]").maxmegamenu_sticky(); 437 }); 438 439})(jQuery); 440 441/** 442 * Handle tabbed functionality 443 */ 444(function($) { 445 $(function() { 446 447 var calculate_tabbed_sub_menu_widths = function( menu_item ) { 448 var menu = menu_item.parents('.mega-menu'); 449 450 if( $(menu.attr('data-panel-inner-width')).length > 0 ) { 451 if ( menu.data("view") === "desktop" ) { 452 $('> ul.mega-sub-menu', menu_item).each(function() { 453 var tab_content = $(this); 454 var parent_submenu_content_width = parseInt(tab_content.width()); 455 var parent_submenu_left_padding = parseInt(tab_content.css('paddingLeft')); 456 var tabs_width = $(this).find('a.mega-menu-link').first().outerWidth(); 457 458 $('> li.mega-menu-item > ul.mega-sub-menu', $(this)).each(function() { 459 $(this).css('width', parent_submenu_content_width - tabs_width + 'px'); 460 $(this).css('left', parent_submenu_left_padding + tabs_width + 'px'); 461 }); 462 }); 463 } else { 464 $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function() { 465 $(this).css('width', ''); 466 $(this).css('left', ''); 467 }); 468 } 469 } 470 } 471 472 var calculate_tabbed_sub_menu_heights = function( menu_item ) { 473 var menu = menu_item.parents('.mega-menu'); 474 var max_height = 0; 475 476 if ( menu.data("view") === "desktop" ) { 477 478 $('> ul.mega-sub-menu', menu_item).css('minHeight', ''); 479 480 $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function() { 481 var tab_content = $(this); 482 var this_height = parseInt(tab_content.css('height')); 483 484 if (this_height > max_height) { 485 max_height = this_height; 486 } 487 }); 488 489 var border_top_width = parseInt($('> ul.mega-sub-menu', menu_item).css('borderLeftWidth'),10); 490 var border_bottom_width = parseInt($('> ul.mega-sub-menu', menu_item).css('borderBottomWidth'),10); 491 492 $('> ul.mega-sub-menu', menu_item).css('minHeight', max_height + border_bottom_width + border_top_width); 493 } else { 494 $('> ul.mega-sub-menu', menu_item).css('minHeight', ''); 495 } 496 } 497 498 var $window = $(window); 499 500 var windowWidth = $window.width(); 501 502 $window.resize(function() { 503 if ($window.width() != windowWidth) { 504 calculate_tabbed_sub_menu_widths($('li.mega-menu-tabbed')); 505 calculate_tabbed_sub_menu_heights($('li.mega-menu-tabbed')); 506 } 507 }); 508 509 $('li.mega-menu-tabbed').on('open_panel', function() { 510 var menu = $(this).parents('.mega-menu'); 511 var menu_item = $(this); 512 513 $("> ul.mega-sub-menu", $(this)).promise().done(function(){ 514 calculate_tabbed_sub_menu_widths( menu_item ); 515 calculate_tabbed_sub_menu_heights( menu_item ); 516 }); 517 518 if ( menu.data('view') == 'desktop' ) { 519 if ($('> ul.mega-sub-menu > li.mega-menu-item-has-children.mega-toggle-on', menu_item).length == 0 ) { 520 $('> ul.mega-sub-menu > li.mega-menu-item-has-children', menu_item).first().addClass('mega-toggle-on'); 521 } 522 } 523 524 $('li.mega-menu-tabbed').on('close_panel', function() { 525 $(".mega-toggle-on", menu).removeClass("mega-toggle-on"); 526 }); 527 }); 528 }); 529})(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.