1(function($){ 2 "use strict"; 3 4 var infinite_display = 'desktop'; 5 if( typeof(window.matchMedia) == 'function' ){ 6 $(window).on('resize infinite-set-display', function(){ 7 if( window.matchMedia('(max-width: 419px)').matches ){ 8 infinite_display = 'mobile-portrait'; 9 }else if( window.matchMedia('(max-width: 767px)').matches ){ 10 infinite_display = 'mobile-landscape' 11 }else if( window.matchMedia('(max-width: 959px)').matches ){ 12 infinite_display = 'tablet' 13 }else{ 14 infinite_display = 'desktop'; 15 } 16 }); 17 $(window).trigger('infinite-set-display'); 18 }else{ 19 $(window).on('resize infinite-set-display', function(){ 20 if( $(window).innerWidth() <= 419 ){ 21 infinite_display = 'mobile-portrait'; 22 }else if( $(window).innerWidth() <= 767 ){ 23 infinite_display = 'mobile-landscape' 24 }else if( $(window).innerWidth() <= 959 ){ 25 infinite_display = 'tablet' 26 }else{ 27 infinite_display = 'desktop'; 28 } 29 }); 30 $(window).trigger('infinite-set-display'); 31 } 32 33 // ref : http://unscriptable.com/2009/03/20/debouncing-javascript-methods/ 34 // ensure 1 is fired 35 var infinite_debounce = function(func, threshold, execAsap){ 36 37 var timeout; 38 39 return function debounced(){ 40 41 var obj = this, args = arguments; 42 43 function delayed(){ 44 if( !execAsap ){ 45 func.apply(obj, args); 46 } 47 timeout = null; 48 }; 49 50 if( timeout ){ 51 clearTimeout(timeout); 52 }else if( execAsap ){ 53 func.apply(obj, args); 54 } 55 timeout = setTimeout(delayed, threshold); 56 }; 57 } 58 59 // reduce the event occurance 60 var infinite_throttling = function(func, threshold){ 61 62 var timeout; 63 64 return function throttled(){ 65 var obj = this, args = arguments; 66 67 function delayed(){ 68 func.apply(obj, args); 69 timeout = null; 70 }; 71 72 if( !timeout ){ 73 timeout = setTimeout(delayed, threshold); 74 } 75 }; 76 } 77 78 ///////////////////////// 79 // menu handle function 80 ///////////////////////// 81 var infinite_sf_menu = function( menu ){ 82 83 if( menu.length == 0 ) return; 84 85 this.main_menu = menu; 86 87 this.slide_bar = this.main_menu.children('.infinite-navigation-slide-bar'); 88 this.slide_bar_val = { width: 0, left: 0 }; 89 this.slide_bar_offset = '15'; 90 if( this.slide_bar.attr('data-size-offset') ){ 91 this.slide_bar_offset = parseInt(this.slide_bar.attr('data-size-offset')); 92 } 93 94 this.slide_bar_width = 0; 95 if( this.slide_bar.attr('data-width') ){ 96 this.slide_bar_width = parseInt(this.slide_bar.attr('data-width')); 97 } 98 99 this.current_menu = this.main_menu.children('.sf-menu').children('.current-menu-item, .current-menu-ancestor').children('a'); 100 101 this.init(); 102 103 } // infinite_sf_menu 104 105 infinite_sf_menu.prototype = { 106 107 init: function(){ 108 109 var t = this; 110 111 // sf menu mod 112 t.sf_menu_mod(); 113 114 // init superfish menu 115 if(typeof($.fn.superfish) == 'function'){ 116 t.main_menu.superfish({ delay: 400, speed: 'fast' }); 117 118 t.sf_menu_position(); 119 $(window).resize(infinite_debounce(function(){ 120 t.sf_menu_position(); 121 }, 300)); 122 } 123 124 // init the slidebar 125 if( t.slide_bar.length > 0 ){ 126 t.init_slidebar(); 127 } 128 129 }, // init 130 131 sf_menu_mod: function(){ 132 133 // create the mega menu script 134 this.main_menu.find('.sf-mega > ul').each(function(){ 135 var mega_content = $('<div></div>'); 136 var mega_row = $('<div class="sf-mega-section-wrap" ></div>'); 137 var mega_column_size = 0; 138 139 $(this).children('li').each(function(){ 140 var column_size = parseInt($(this).attr('data-size')); 141 if( mega_column_size + column_size <= 60 ){ 142 mega_column_size += column_size; 143 }else{ 144 mega_column_size = column_size; 145 mega_content.append(mega_row); 146 mega_row = $('<div class="sf-mega-section-wrap" ></div>'); 147 } 148 149 mega_row.append( $('<div class="sf-mega-section" ></div>') 150 .addClass('infinite-column-' + column_size) 151 .html( $('<div class="sf-mega-section-inner" ></div>') 152 .addClass($(this).attr('class')) 153 .attr('id', $(this).attr('id')) 154 .html($(this).html()) 155 ) 156 ); 157 }); 158 159 mega_content.append(mega_row); 160 $(this).replaceWith(mega_content.html()); 161 }); 162 163 }, // sf_menu_mod 164 165 sf_menu_position: function(){ 166 167 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ) return; 168 169 // submenu of normal menu 170 var body_wrapper = $('.infinite-body-wrapper'); 171 var sub_normal_menu = this.main_menu.find('.sf-menu > li.infinite-normal-menu .sub-menu'); 172 173 sub_normal_menu.css({display: 'block'}
173).removeClass('sub-menu-right sub-menu-left'); 174 sub_normal_menu.each(function(){ 175 if( $(this).offset().left + $(this).width() > body_wrapper.outerWidth() ){ 176 $(this).addClass('sub-menu-right'); 177 }else if( $(this).offset().left < 0 ){ 178 $(this).addClass('sub-menu-left'); 179 } 180 }); 181 sub_normal_menu.css({display: 'none'}); 182 183 // submenu of mega menu 184 this.main_menu.find('.sf-menu > li.infinite-mega-menu .sf-mega').each(function(){ 185 if( !$(this).hasClass('sf-mega-full') ){ 186 187 $(this).css({ display: 'block' }); 188 189 // set the position 190 $(this).css({ right: '', 'margin-left': -(($(this).width() - $(this).parent().outerWidth()) / 2) }); 191 192 // if exceed the screen 193 if( $(this).offset().left < 0 ){ 194 $(this).css({ left: 0, 'margin-left': '' }); 195 }else if( $(this).offset().left + $(this).width() > $(window).width() ){ 196 $(this).css({ right: 0, 'margin-left': '' }); 197 } 198 199 $(this).css({ display: 'none' }); 200 } 201 202 }); 203 204 }, // sf_menu_position 205 206 init_slidebar: function(){ 207 208 var t = this; 209 210 t.init_slidebar_pos(); 211 $(window).on('load', function(){ t.init_slidebar_pos(); }); 212 213 // animate slidebar 214 t.main_menu.children('.sf-menu').children('li').on({ 215 mouseenter: function(){ 216 var nav_element = $(this).children('a'); 217 218 if( nav_element.length > 0 ){ 219 220 if( t.slide_bar_width > 0 ){ 221 var sbw = t.slide_bar_width; 222 if( t.slide_bar.hasClass('infinite-left') ){ 223 var sbl = nav_element.position().left - t.slide_bar_offset; 224 }else{ 225 var sbl = nav_element.position().left + ((nav_element.outerWidth() - sbw)/2) - t.slide_bar_offset; 226 } 227 }else{ 228 var sbw = nav_element.outerWidth() + (2 * t.slide_bar_offset); 229 var sbl = nav_element.position().left - t.slide_bar_offset; 230 } 231 232 t.slide_bar.animate({ width: sbw, left: sbl }, { queue: false, duration: 250 }); 233 } 234 }, 235 mouseleave: function(){ 236 t.slide_bar.animate({ width: t.slide_bar_val.width, left: t.slide_bar_val.left }, { queue: false, duration: 250 }); 237 } 238 }); 239 240 // window resize event 241 $(window).on('resize', function(){ t.init_slidebar_pos(); }); 242 $(window).on('infinite-navigation-slider-bar-init', function(){ 243 t.current_menu = t.main_menu.children('.sf-menu').children('.current-menu-item, .current-menu-ancestor').children('a'); 244 t.animate_slidebar_pos(); 245 }); 246 $(window).on('infinite-navigation-slider-bar-animate', function(){ t.animate_slidebar_pos(); }); 247 248 }, // init_slidebar 249 250 init_slidebar_pos: function(){ 251 252 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ) return; 253 254 var t = this; 255 256 if( t.current_menu.length > 0 ){ 257 if( t.slide_bar_width > 0 ){ 258 var sbw = t.slide_bar_width; 259 if( t.slide_bar.hasClass('infinite-left') ){ 260 var sbl = t.current_menu.position().left - t.slide_bar_offset; 261 }else{ 262 var sbl = t.current_menu.position().left + ((t.current_menu.outerWidth() - sbw)/2) - t.slide_bar_offset; 263 } 264 }else{ 265 var sbw = t.current_menu.outerWidth() + (2 * t.slide_bar_offset); 266 var sbl = t.current_menu.position().left - t.slide_bar_offset; 267 } 268 t.slide_bar_val = { width: sbw, left: sbl }; 269 }else{ 270 t.slide_bar_val = { width: 0 } 271 272 var first_child = t.main_menu.children('ul').children('li:first-child'); 273 if( typeof(first_child.position()) != 'undefined' ){ 274 t.slide_bar_val.left = first_child.position().left; 275 }else{ 276 t.slide_bar_val.left = 0; 277 } 278 } 279 t.slide_bar.css({ width: t.slide_bar_val.width, left: t.slide_bar_val.left, display: 'block' }); 280 281 }, // set_slidebar_pos 282 animate_slidebar_pos: function(){ 283 284 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ) return; 285 286 var t = this; 287 288 if( t.current_menu.length > 0 ){ 289 if( t.slide_bar_width > 0 ){ 290 var sbw = t.slide_bar_width; 291 if( t.slide_bar.hasClass('infinite-left') ){ 292 var sbl = t.current_menu.position().left - t.slide_bar_offset; 293 }else{ 294 var sbl = t.current_menu.position().left + ((t.current_menu.outerWidth() - sbw)/2) - t.slide_bar_offset ; 295 } 296 }else{ 297 var sbw = t.current_menu.outerWidth() + (2 * t.slide_bar_offset); 298 var sbl = t.current_menu.position().left - t.slide_bar_offset; 299 } 300 t.slide_bar_val = { width: sbw, left: sbl }; 301 }else{ 302 t.slide_bar_val = { width: 0 } 303 304 var first_child = t.main_menu.children('ul').children('li:first-child'); 305 if( typeof(first_child.position()) != 'undefined' ){ 306 t.slide_bar_val.left = first_child.position().left; 307 }else{ 308 t.slide_bar_val.left = 0; 309 } 310 } 311 t.slide_bar.animate({ width: t.slide_bar_val.width, left: t.slide_bar_val.left }, { queue: false, duration: 250 }); 312 313 } // set_slidebar_pos 314 315 }; // infinite_sf_menu.prototype 316 317 ///////////////////////// 318 // mobile menu 319 ///////////////////////// 320 $.fn.infinite_mobile_menu = function( args ){ 321 322 var menu_button = $(this).siblings('.infinite-mm-menu-button'); 323 324 if( typeof(Mmenu) != 'undefined' ){ 325 326 // remove blank link for submenu 327 $(this).find('a[href="#"]').each(function(){ 328 var content = $(this).html(); 329 $('<span class="infinite-mm-menu-blank" ></span>').html(content).insertBefore($(this)); 330 $(this).remove(); 331 }); 332 333 // activate mmenu 334 var menu = new Mmenu($(this).get(0), { 335 navbar: { 336 title: '<span class="mmenu-custom-close" ></span>' 337 }, 338 offCanvas: {
339 position: $(this).attr('data-slide') 340 } 341 }, { 342 offCanvas: { 343 page: { 344 selector: ".infinite-body-outer-wrapper" 345 } 346 } 347 }); 348 349 var menu_api = menu.API; 350 351 if( menu_api ){ 352 // open close action 353 menu_button.on('click', function(){ 354 menu_api.open(); 355 }); 356 $(this).find('a').not('.mm-btn').on('click', function(){ 357 menu_api.close(); 358 }); 359 $(this).find('.mmenu-custom-close').on('click', function(){ 360 menu_api.close(); 361 }); 362 363 // add class active to button 364 menu_api.bind('open:after', function($panel){ 365 menu_button.addClass('infinite-active'); 366 }); 367 menu_api.bind('close:after', function($panel){ 368 menu_button.removeClass('infinite-active'); 369 }); 370 } 371 372 } 373 374 } 375 376 ///////////////////////// 377 // overlay menu 378 ///////////////////////// 379 var infinite_overlay_menu = function( menu ){ 380 381 this.menu = menu; 382 this.menu_button = menu.children('.infinite-overlay-menu-icon'); 383 this.menu_content = menu.children('.infinite-overlay-menu-content'); 384 this.menu_close = this.menu_content.children('.infinite-overlay-menu-close'); 385 386 this.init(); 387 } 388 infinite_overlay_menu.prototype = { 389 390 init: function(){ 391 392 var t = this; 393 394 // add transition delay for each menu 395 var delay_count = 0; 396 t.menu_content.appendTo('body'); 397 t.menu_content.find('ul.menu > li').each(function(){ 398 $(this).css('transition-delay', (delay_count * 150) + 'ms'); 399 400 delay_count++; 401 }); 402 403 // bind the menu button 404 t.menu_button.on('click', function(){ 405 $(this).addClass('infinite-active'); 406 407 t.menu_content.fadeIn(200, function(){ 408 $(this).addClass('infinite-active'); 409 }); 410 411 return false; 412 }); 413 414 // bind the menu close button 415 t.menu_close.on('click', function(){ 416 t.menu_button.removeClass('infinite-active'); 417 418 t.menu_content.fadeOut(400, function(){ 419 $(this).removeClass('infinite-active'); 420 }); 421 t.menu_content.find('.sub-menu').slideUp(200).removeClass('infinite-active'); 422 423 return false; 424 }); 425 426 // menu item click 427 t.menu_content.find('a').on('click', function(e){ 428 var sub_menu = $(this).siblings('.sub-menu'); 429 if( sub_menu.length > 0 ){ 430 if( !sub_menu.hasClass('infinite-active') ){ 431 var prev_active = sub_menu.closest('li').siblings().find('.sub-menu.infinite-active'); 432 if( prev_active.length > 0 ){ 433 prev_active.removeClass('infinite-active').slideUp(150); 434 sub_menu.delay(150).slideDown(400, 'easeOutQuart').addClass('infinite-active'); 435 }else{ 436 sub_menu.slideDown(400, 'easeOutQuart').addClass('infinite-active'); 437 } 438 439 $(this).addClass('infinite-no-preload'); 440 return false; 441 }else if( $(this).attr('href') == '#' ){ 442 sub_menu.removeClass('infinite-active').slideUp(150); 443 }else{ 444 $(this).removeClass('infinite-no-preload'); 445 } 446 }else{ 447 t.menu_close.trigger('click'); 448 } 449 }); 450 451 } 452 453 }; // infinite_overlay_menu.prototype 454 455 ///////////////////////// 456 // header side navigation 457 ///////////////////////// 458 var infinite_header_side_nav = function( side_nav ){ 459 460 if( side_nav.length == 0 ) return; 461 462 this.prev_scroll = 0; 463 464 this.side_nav = side_nav; 465 this.side_nav_content = side_nav.children(); 466 467 this.init(); 468 469 } // infinite_header_side_nav 470 471 infinite_header_side_nav.prototype = { 472 473 init: function(){ 474 475 var t = this; 476 477 t.init_nav_bar_element(); 478 479 $(window).resize(function(){ 480 t.init_nav_bar_element(); 481 }); 482 483 $(window).scroll(function(){ 484 485 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ) return; 486 487 // if content longer than screen height 488 if( t.side_nav.hasClass('infinite-allow-slide') ){ 489 490 var admin_bar_height = parseInt($('html').css('margin-top')); 491 var scroll_down = ($(window).scrollTop() > t.prev_scroll); 492 t.prev_scroll = $(window).scrollTop(); 493 494 // if scroll down 495 if( scroll_down ){ 496 497 if( !t.side_nav.hasClass('infinite-fix-bottom') ){ 498 if( t.side_nav.hasClass('infinite-fix-top') ){ 499 t.side_nav.css('top', t.side_nav.offset().top); 500 t.side_nav.removeClass('infinite-fix-top'); 501 502 }else if( $(window).height() + $(window).scrollTop() > t.side_nav_content.offset().top + t.side_nav_content.outerHeight() ){ 503 if( !t.side_nav.hasClass('infinite-fix-bottom') ){ 504 t.side_nav.addClass('infinite-fix-bottom'); 505 t.side_nav.css('top', ''); 506 } 507 } 508 } 509 510 // if scroll up 511 }else{ 512 513 if( !t.side_nav.hasClass('infinite-fix-top') ){ 514 if( t.side_nav.hasClass('infinite-fix-bottom') ){ 515 var top_pos = $(window).scrollTop() + ($(window).height() - admin_bar_height) - t.side_nav_content.outerHeight(); 516 t.side_nav.css('top', top_pos); 517 t.side_nav.removeClass('infinite-fix-bottom'); 518 519 }else if( $(window).scrollTop() + admin_bar_height < t.side_nav_content.offset().top ){ 520 if( !t.side_nav.hasClass('infinite-fix-top') ){ 521 t.side_nav.addClass('infinite-fix-top'); 522 t.side_nav.css('top', ''); 523 } 524 } 525 } 526 527 } 528 529 } 530 }); 531 532 }, 533 534 init_nav_bar_element: function(){ 535 536 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ) return; 537 538 var t = this; 539 var middle_pos = t.side_nav_content.children('.infinite-pos-middle').addClass('infinite-active'); 540 var bottom_pos = t.side_nav_content.children('.infinite-pos-bottom').addClass('infinite-active'); 541 542 // remove all additional space 543 t.side_nav_content.children('.infinite-pre-spaces').remove(); 544 545 // add class depends on the screen size/content 546 if( $(window).height() < t.side_nav_content.height() ){ 547 t.side_nav.addClass('infinite-allow-slide'); 548 }else{ 549 t.side_nav.removeClass('infinite-allow-slide infinite-fix-top infinite-fix-bottom').css('top', ''); 550 551 // set the middle position 552 if( t.side_nav.hasClass('infinite-style-middle') ){ 553 middle_pos.each(function(){ 554 var top_padding = parseInt($(this).css('padding-top')); 555 var prespace = ((t.side_nav.height() - (t.side_nav_content.height() - top_padding)) / 2) - top_padding; 556 557 if( prespace > 0 ){ 558 $('<div class="infinite-pre-spaces" ></div>').css('height', prespace).insertBefore($(this)); 559 } 560 });
561 } 562 563 // set the bottom position 564 bottom_pos.each(function(){ 565 var prespace = t.side_nav.height() - t.side_nav_content.height(); 566 567 if( prespace > 0 ){ 568 $('<div class="infinite-pre-spaces" ></div>').css('height', prespace).insertBefore($(this)); 569 } 570 }); 571 572 } 573 } 574 575 }; // infinite_sf_menu.prototype 576 577 ///////////////////////// 578 // anchoring 579 ///////////////////////// 580 581 var infinite_anchor = function(){ 582 583 this.anchor_link = $('a[href*="#"]').not('[href="#"]').filter(function(){ 584 585 // for mm-menu plugin 586 if( $(this).is('.infinite-mm-menu-button, .mm-btn, .mm-blocker, .mm-next, .mm-prev, .mm-title, .gdlr-core-ilightbox') ){ 587 return false; 588 } 589 590 // for google review plugin 591 if( $(this).is('') ){ 592 return false; 593 } 594 595 // for additional plugins 596 if( $(this).is('#cancel-comment-reply-link, .comment-reply-link, .fbx-btn-transition, .ti-header') ){ 597 return false; 598 }else if( $(this).parent('.clearButton').length ){ 599 return false; 600 } 601 602 // for woocommerce 603 if( $(this).is('[class*="wc-"]') ){ 604 return false; 605 } 606 if( $(this).parent('.description_tab, .reviews_tab').length || $(this).not('[class^="infinite"]').closest('.woocommerce').length ){ 607 if( !$(this).closest('.menu-item').length ){ 608 return false; 609 } 610 } 611 612 613 614 return true; 615 }); 616 617 if( this.anchor_link.length || window.location.hash.length ){ 618 this.menu_anchor = $('#infinite-main-menu, #infinite-bullet-anchor'); 619 this.home_anchor = this.menu_anchor.find('ul.sf-menu > li.current-menu-item > a, ul.sf-menu > li.current-menu-ancestor > a, .infinite-bullet-anchor-link.current-menu-item'); 620 621 this.init(); 622 } 623 } 624 infinite_anchor.prototype = { 625 626 init: function(){ 627 628 var t = this; 629 630 t.animate_anchor(); 631 t.scroll_section(); 632 633 // init bullet anchor height 634 t.menu_anchor.filter('#infinite-bullet-anchor').each(function(){ 635 $(this).css('margin-top', - t.menu_anchor.height() / 2).addClass('infinite-init'); 636 }); 637 638 // initialize if the page hash exists 639 // wait for all element to initialize ( eg. flexslider ) 640 var url_hash = window.location.hash; 641 if( url_hash ){ 642 setTimeout(function(){ 643 644 var current_menu = t.menu_anchor.find('a[href*="' + url_hash + '"]'); 645 if( !current_menu.is('.current-menu-item, .current-menu-ancestor') ){ 646 current_menu.addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor'); 647 648 $(window).trigger('infinite-navigation-slider-bar-init'); 649 } 650 651 t.scroll_to(url_hash, false, 300); 652 }, 500); 653 } 654 655 }, 656 657 animate_anchor: function(){ 658 659 var t = this; 660 661 // home anchor 662 t.home_anchor.on('click', function(){ 663 664 if( window.location.href == this.href ){ 665 $('html, body').animate({ scrollTop: 0 }, { duration: 1500, easing: 'easeOutQuart' }); 666 return false; 667 } 668 669 }); 670 671 // normal anchor 672 t.anchor_link.on('click', function() { 673 if( location.hostname == this.hostname && location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') ){ 674 if( $(this).closest('#infinite-main-menu').length ){ 675 $(this).parent().addClass('current-menu-item').siblings().removeClass('current-menu-item'); 676 $(window).trigger('infinite-navigation-slider-bar-init'); 677 } 678 return t.scroll_to(this.hash, true); 679 } 680 }); 681 682 }, // animate anchor 683 684 scroll_to: function( hash, redirect, duration ){ 685 686 // start scrolling 687 if( hash == '#infinite-top-anchor' ){ 688 var scroll_position = 0; 689 }else{ 690 691 var target = $(hash); 692 693 if( target.length ){ 694 var scroll_position = target.offset().top; 695 } 696 } 697 698 if( typeof(scroll_position) != 'undefined' ){ 699 700 // offset for wordpress admin bar 701 scroll_position = scroll_position - parseInt($('html').css('margin-top')); 702 703 // offset for fixed nav bar 704 if( infinite_display == 'mobile-portrait' || infinite_display == 'mobile-landscape' ){ 705 scroll_position = scroll_position - 75; 706 }else if( typeof(window.infinite_anchor_offset) != 'undefined' && !isNaN(window.infinite_anchor_offset) ){ 707 scroll_position = scroll_position - parseInt(window.infinite_anchor_offset); 708 } 709 710 if( scroll_position < 0 ) scroll_position = 0; 711 712 $(window).trigger('infinite-anchor-animate'); 713 $('html, body').animate({ scrollTop: scroll_position }, { duration: 1500, easing: 'easeOutQuart', queue: false }); 714 715 return false; 716 717 }else if( redirect ){ 718 719 window.location.href = $('body').attr('data-home-url') + hash; 720 721 return false; 722 } 723 724 }, // scroll to 725 726 scroll_section: function(){ 727 728 var t = this; 729 730 // have anchor in anchor menu 731 var menu_link_anchor = this.menu_anchor.find('a[href*="#"]').not('[href="#"]'); 732 if( !menu_link_anchor.length ){ return; } 733 734 // get anchor section 735 var home_anchor_section = $('#infinite-page-wrapper'); 736 // var anchor_section = home_anchor_section.find('div[id], section[id]'); 737 var anchor_section = home_anchor_section.find('[id]').filter(function(){ 738 var hashId = $(this).attr('id'); 739 if( menu_link_anchor.filter('a[href*="#' + hashId + '"]').length ){ 740 return true; 741 } 742 return false; 743 }); 744 if( !anchor_section.length ){ return; } 745 746 // add data for faster query 747 menu_link_anchor.each(function(){ 748 if( $(this).closest('.sub-menu').length == 0 && $(this.hash).length ){ 749 $(this).attr('data-anchor', this.hash); 750 } 751 }); 752 753 // check section on scroll event 754 $(window).scroll(function(){ 755 756 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ) return; 757 758 if( t.home_anchor.length && $(window).scrollTop() <= home_anchor_section.offset().top ){ 759 760 t.home_anchor.each(function(){ 761 if( $(this).hasClass('infinite-bullet-anchor-link') ){ 762 $(this).addClass('current-menu-item').siblings().removeClass('current-menu-item'); 763 $(this).parent('.infinite-bullet-anchor').attr('data-anchor-section', 'infinite-home'); 764 }else if( !$(this).parent('.current-menu-item, .current-menu-ancestor').length ){ 765 $(this).parent().addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor');
766 $(window).trigger('infinite-navigation-slider-bar-init'); 767 } 768 }); 769 770 }else{ 771 var section_position = $(window).scrollTop() + ($(window).height() / 2); 772 773 anchor_section.each(function(){ 774 if( $(this).css('display') == 'none' ) return; 775 776 var top_offset_pos = $(this).offset().top; 777 778 if( (section_position > top_offset_pos) && (section_position < top_offset_pos + $(this).outerHeight()) ){ 779 var section_id = $(this).attr('id'); 780 menu_link_anchor.filter('[data-anchor="#' + section_id + '"]').each(function(){ 781 if( $(this).hasClass('infinite-bullet-anchor-link') ){ 782 $(this).addClass('current-menu-item').siblings().removeClass('current-menu-item'); 783 $(this).parent('.infinite-bullet-anchor').attr('data-anchor-section', section_id); 784 }else if( $(this).parent('li.menu-item').length && !$(this).parent('li.menu-item').is('.current-menu-item, .current-menu-ancestor') ){ 785 $(this).parent('li.menu-item').addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor'); 786 $(window).trigger('infinite-navigation-slider-bar-init'); 787 } 788 }); 789 790 return false; 791 } 792 793 }); 794 } 795 796 }); 797 798 } // scroll section 799 800 }; 801 802 var infinite_sticky_navigation = function(){ 803 804 var t = this; 805 806 // get navigation 807 t.sticky_nav = $('.infinite-with-sticky-navigation .infinite-sticky-navigation'); 808 t.mobile_menu = $('#infinite-mobile-header'); 809 810 // set the anchor offset 811 if( t.sticky_nav.hasClass('infinite-sticky-navigation-height') ){ 812 window.infinite_anchor_offset = t.sticky_nav.outerHeight(); 813 $(window).resize(function(){ 814 window.infinite_anchor_offset = t.sticky_nav.outerHeight(); 815 }); 816 }else if( t.sticky_nav.attr('data-navigation-offset') ){ 817 window.infinite_anchor_offset = parseInt(t.sticky_nav.attr('data-navigation-offset')); 818 }else if( t.sticky_nav.length ){ 819 window.infinite_anchor_offset = 75; 820 } 821 822 // init the sticky navigation 823 if( t.sticky_nav.length ){ 824 t.init(); 825 } 826 827 if( t.mobile_menu.hasClass('infinite-sticky-mobile-navigation') ){ 828 t.style_mobile_slide(); 829 $(window).trigger('infinite-set-sticky-mobile-navigation'); 830 } 831 832 } 833 infinite_sticky_navigation.prototype = { 834 835 init: function(){ 836 837 var t = this; 838 839 if( t.sticky_nav.hasClass('infinite-style-fixed') ){ 840 t.style_fixed(); 841 }else if( t.sticky_nav.hasClass('infinite-style-slide') ){ 842 t.style_slide(); 843 } 844 845 $(window).trigger('infinite-set-sticky-navigation'); 846 }, 847 848 style_fixed: function(){ 849 850 var t = this; 851 var placeholder = $('<div class="infinite-sticky-menu-placeholder" ></div>'); 852 853 $(window).on('scroll infinite-set-sticky-navigation', function(){ 854 855 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ) return; 856 857 var page_offset = parseInt($('html').css('margin-top')); 858 859 if( !t.sticky_nav.hasClass('infinite-fixed-navigation') ){ 860 861 if( $(window).scrollTop() + page_offset > t.sticky_nav.offset().top ){ 862 if( !t.sticky_nav.hasClass('infinite-without-placeholder') ){ 863 placeholder.height(t.sticky_nav.outerHeight()); 864 } 865 placeholder.insertAfter(t.sticky_nav); 866 $('body').append(t.sticky_nav); 867 t.sticky_nav.addClass('infinite-fixed-navigation'); 868 869 setTimeout(function(){ t.sticky_nav.addClass('infinite-animate-fixed-navigation'); }, 10); 870 setTimeout(function(){ 871 t.sticky_nav.css('height', ''); 872 $(window).trigger('infinite-navigation-slider-bar-animate'); 873 }, 200); 874 } 875 }else{ 876 877 if( $(window).scrollTop() + page_offset <= placeholder.offset().top ){ 878 if( !t.sticky_nav.hasClass('infinite-without-placeholder') ){ 879 t.sticky_nav.height(placeholder.height()); 880 } 881 t.sticky_nav.insertBefore(placeholder); 882 t.sticky_nav.removeClass('infinite-fixed-navigation'); 883 placeholder.remove(); 884 885 setTimeout(function(){ t.sticky_nav.removeClass('infinite-animate-fixed-navigation'); }, 10); 886 setTimeout(function(){ 887 t.sticky_nav.css('height', '');
888 $(window).trigger('infinite-navigation-slider-bar-animate'); 889 }, 200); 890 } 891 } 892 }); 893 894 }, // style_fixed 895 896 style_slide: function(){ 897 898 var t = this; 899 var placeholder = $('<div class="infinite-sticky-menu-placeholder" ></div>'); 900 901 $(window).on('scroll infinite-set-sticky-navigation', function(){ 902 903 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ){ return; } 904 905 var page_offset = parseInt($('html').css('margin-top')); 906 907 if( !t.sticky_nav.hasClass('infinite-fixed-navigation') ){ 908 909 if( $(window).scrollTop() + page_offset > t.sticky_nav.offset().top + t.sticky_nav.outerHeight() + 200 ){ 910 911 if( !t.sticky_nav.hasClass('infinite-without-placeholder') ){ 912 placeholder.height(t.sticky_nav.outerHeight()); 913 } 914 placeholder.insertAfter(t.sticky_nav); 915 t.sticky_nav.css('display', 'none'); 916 917 $('body').append(t.sticky_nav); 918 t.sticky_nav.addClass('infinite-fixed-navigation infinite-animate-fixed-navigation'); 919 t.sticky_nav.slideDown(200); 920 $(window).trigger('infinite-navigation-slider-bar-animate'); 921 } 922 }else{ 923 924 if( $(window).scrollTop() + page_offset <= placeholder.offset().top + placeholder.height() + 200 ){ 925 var clone = t.sticky_nav.clone(); 926 clone.insertAfter(t.sticky_nav); 927 clone.slideUp(200, function(){ $(this).remove(); }); 928 929 t.sticky_nav.insertBefore(placeholder); 930 placeholder.remove(); 931 t.sticky_nav.removeClass('infinite-fixed-navigation infinite-animate-fixed-navigation'); 932 t.sticky_nav.css('display', 'block'); 933 934 $(window).trigger('infinite-navigation-slider-bar-animate'); 935 } 936 } 937 }); 938 939 }, // style_slide 940 941 style_mobile_slide: function(){ 942 943 var t = this; 944 var placeholder = $('<div class="infinite-sticky-mobile-placeholder" ></div>'); 945 946 $(window).on('scroll infinite-set-sticky-mobile-navigation', function(){ 947 948 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ){ 949 950 var page_offset = parseInt($('html').css('margin-top')); 951 952 if( !t.mobile_menu.hasClass('infinite-fixed-navigation') ){ 953 if( $(window).scrollTop() + page_offset > t.mobile_menu.offset().top + t.mobile_menu.outerHeight() + 200 ){ 954 placeholder.height(t.mobile_menu.outerHeight()).insertAfter(t.mobile_menu); 955 $('body').append(t.mobile_menu); 956 t.mobile_menu.addClass('infinite-fixed-navigation'); 957 t.mobile_menu.css('display', 'none').slideDown(200); 958 } 959 }else{ 960 if( $(window).scrollTop() + page_offset <= placeholder.offset().top + placeholder.height() + 200 ){ 961 var clone = t.mobile_menu.clone(); 962 clone.insertAfter(t.mobile_menu); 963 clone.slideUp(200, function(){ $(this).remove(); }); 964 965 t.mobile_menu.insertBefore(placeholder); 966 placeholder.remove(); 967 t.mobile_menu.removeClass('infinite-fixed-navigation'); 968 t.mobile_menu.css('display', 'block'); 969 } 970 } 971 } 972 973 }); 974 975 }, // style_slide 976 977 }; 978 979 var infinite_font_resize = function(){ 980 981 this.heading_font = $('h1, h2, h3, h4, h5, h6'); 982 983 this.init(); 984 985 } 986 infinite_font_resize.prototype = { 987 988 init: function(){ 989 990 var t = this; 991 992 t.resize(); 993 $(window).on('resize', infinite_throttling(function(){ 994 t.resize(); 995 }, 100)); 996 997 }, 998 999 resize: function(){ 1000 1001 var t = this; 1002 1003 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' ){ 1004 1005 t.heading_font.each(function(){ 1006 if( parseInt($(this).css('font-size')) > 40 ){ 1007 if( !$(this).attr('data-orig-font') ){ 1008 $(this).attr('data-orig-font', $(this).css('font-size')); 1009 } 1010 1011 $(this).css('font-size', '40px'); 1012 } 1013 }); 1014 1015 // return font to normal 1016 }else{ 1017 1018 t.heading_font.filter('[data-orig-font]').each(function(){ 1019 $(this).css('font-size', $(this).attr('data-orig-font')); 1020 }); 1021 1022 } 1023 } 1024 1025 }; 1026 1027 // tourmaster lightbox 1028 function infinite_lightbox( content ){ 1029 1030 var lightbox_wrap = $('<div class="infinite-lightbox-wrapper" ></div>').hide(); 1031 var lightbox_content_wrap = $('<div class="infinite-lightbox-content-cell" ></div>'); 1032 lightbox_wrap.append(lightbox_content_wrap); 1033 lightbox_content_wrap.wrap($('<div class="infinite-lightbox-content-row" ></div>')); 1034 1035 lightbox_content_wrap.append(content); 1036 1037 var scrollPos = $(window).scrollTop(); 1038 $('html').addClass('infinite-lightbox-on'); 1039 $('body').append(lightbox_wrap); 1040 lightbox_wrap.fadeIn(300); 1041 1042 // do a lightbox action 1043 lightbox_wrap.on('click', '.infinite-lightbox-close', function(){ 1044 $('html').removeClass('infinite-lightbox-on'); 1045 $(window).scrollTop(scrollPos); 1046 lightbox_wrap.fadeOut(300, function(){ 1047 $(this).remove(); 1048 }); 1049 }); 1050 1051 } // infinite_lightbox 1052 1053 //////////////////////////////// 1054 // starting running the script 1055 //////////////////////////////// 1056 $(document).ready(function(){ 1057 1058 // resize font on mobile 1059 new infinite_font_resize(); 1060 1061 // init main navigation menu 1062 $('#infinite-main-menu, #infinite-right-menu, #infinite-mobile-menu, #infinite-top-bar-menu').each(function(){ 1063 if( $(this).children('nav').hasClass('ubermenu') ) return; 1064 1065 if( $(this).hasClass('infinite-overlay-menu') ){ 1066 new infinite_overlay_menu( $(this) ); 1067 }else if( $(this).hasClass('infinite-mm-menu-wrap') ){ 1068 $(this).infinite_mobile_menu(); 1069 }else{ 1070 new infinite_sf_menu( $(this) ); 1071 } 1072 }); 1073 1074 $('#infinite-top-search, #infinite-mobile-top-search').each(function(){ 1075 1076 var search_wrap = $(this).siblings('.infinite-top-search-wrap'); 1077 search_wrap.appendTo('body'); 1078
1079 // bind click button 1080 $(this).on('click', function(){ 1081 search_wrap.fadeIn(200, function(){ 1082 $(this).addClass('infinite-active'); 1083 }); 1084 }); 1085 1086 // bind close button 1087 search_wrap.find('.infinite-top-search-close').on('click', function(){ 1088 search_wrap.fadeOut(200, function(){ 1089 $(this).addClass('infinite-active'); 1090 }); 1091 }); 1092 1093 // bind search button 1094 search_wrap.find('.search-submit').on('click', function(){ 1095 if( search_wrap.find('.search-field').val().length == 0 ){ 1096 return false; 1097 } 1098 }); 1099 }); 1100 1101 $('#infinite-main-menu-cart, #infinite-mobile-menu-cart').each(function(){ 1102 1103 $(this).on({ 1104 mouseenter: function(){ 1105 $(this).addClass('infinite-active infinite-animating'); 1106 }, 1107 mouseleave: function(){ 1108 var menu_cart = $(this); 1109 menu_cart.removeClass('infinite-active'); 1110 setTimeout(function(){ 1111 menu_cart.removeClass('infinite-animating'); 1112 }, 400) 1113 } 1114 }); 1115 }); 1116 1117 // woocommerce top bar cart 1118 if( typeof(wc_add_to_cart_params) != 'undefined' ){ 1119 $('body').on('added_to_cart updated_cart_totals wc_cart_emptied', function(){ 1120 $.ajax({
1121 type: 'POST', 1122 url: gdlr_core_pbf.ajax_url, 1123 data: { 'action': 'top_bar_woocommerce_cart' }, 1124 dataType: 'json', 1125 error: function(jqXHR, textStatus, errorThrown){ 1126 console.log(jqXHR, textStatus, errorThrown); 1127 }, 1128 success: function(data){ 1129 if( typeof(data['count']) != 'undefined' ){ 1130 $('.infinite-top-cart-count').html(data['count']).css('display', 'block'); 1131 } 1132 if( typeof(data['title']) != 'undefined' ){ 1133 $('.infinite-top-cart-title').replaceWith(data['title']); 1134 } 1135 if( typeof(data['cart-items']) != 'undefined' ){ 1136 $('.infinite-top-cart-item-wrap').replaceWith(data['cart-items']); 1137 } 1138 } 1139 }); 1140 }); 1141 } 1142 1143 1144 // infinite 1145 $('#infinite-dropdown-infinite-flag').hover(function(){ 1146 $(this).children('.infinite-dropdown-infinite-list').fadeIn(200); 1147 }, function(){ 1148 $(this).children('.infinite-dropdown-infinite-list').fadeOut(200); 1149 }); 1150 1151 // additional space for header transparent 1152 $('.infinite-header-boxed-wrap, .infinite-header-background-transparent, .infinite-navigation-bar-wrap.infinite-style-transparent').each(function(){ 1153 var header_transparent = $(this); 1154 var header_transparent_sub = $('.infinite-header-transparent-substitute'); 1155 1156 header_transparent_sub.height(header_transparent.outerHeight()); 1157 $(window).on('load resize', function(){ 1158 header_transparent_sub.height(header_transparent.outerHeight()); 1159 }); 1160 }); 1161 1162 // full screen for 404 not found 1163 $('body.error404, body.search-no-results').each(function(){ 1164 1165 var wrap = $(this).find('#infinite-full-no-header-wrap'); 1166 var body_wrap_offset = parseInt($(this).children('.infinite-body-outer-wrapper').children('.infinite-body-wrapper').css('margin-bottom')); 1167 1168 var padding = ($(window).height() - wrap.offset().top - wrap.outerHeight() - body_wrap_offset) / 2; 1169 if( padding > 0 ){ 1170 wrap.css({ 'padding-top': padding, 'padding-bottom': padding }); 1171 } 1172 1173 $(window).on('load resize', function(){ 1174 wrap.css({ 'padding-top': 0, 'padding-bottom': 0 }); 1175 padding = ($(window).height() - wrap.offset().top - wrap.outerHeight() - body_wrap_offset) / 2; 1176 if( padding > 0 ){ 1177 wrap.css({ 'padding-top': padding, 'padding-bottom': padding }); 1178 } 1179 }); 1180 }); 1181 1182 // back to top button 1183 var back_to_top = $('#infinite-footer-back-to-top-button'); 1184 if( back_to_top.length ){ 1185 $(window).on('scroll', function(){ 1186 if( $(window).scrollTop() > 300 ){ 1187 back_to_top.addClass('infinite-scrolled'); 1188 }else{ 1189 back_to_top.removeClass('infinite-scrolled'); 1190 } 1191 }); 1192 } 1193 1194 // page preload 1195 $('body').children('#infinite-page-preload').each(function(){ 1196 var page_preload = $(this); 1197 var animation_time = parseInt(page_preload.attr('data-animation-time')); 1198 1199 $('a[href]').not('[href^="tel:"], [href^="mailto:"], [href^="#"], [href^="mailto:"], [target="_blank"], .gdlr-core-js, .strip, .sf-with-ul, .remove, .ajax_add_to_cart, .comment-reply-link').on('click', function(e){ 1200 if( e.which != 1 || $(this).hasClass('infinite-no-preload') || e.ctrlKey || e.metaKey ) return; 1201 1202 if( $(this).closest('.modula').length ) return; 1203 1204 if( $(this).prop("hash") && $($(this).prop("hash")).length ) return; 1205 1206 if( window.location.href != this.href ){ 1207 page_preload.addClass('infinite-out').fadeIn(animation_time); 1208 } 1209 }); 1210 1211 $(window).on('load', function(){ 1212 page_preload.fadeOut(animation_time); 1213 }); 1214 }); 1215 1216 // single nav style 2 sync height 1217 $('body.infinite-blog-style-2 .infinite-single-nav-area').each(function(){ 1218 var max_height; 1219 var single_nav_2 = $(this).children(); 1220 1221 max_height = 0; 1222 single_nav_2.css('min-height', '0px'); 1223 single_nav_2.each(function(){ 1224 if( max_height < $(this).outerHeight() ){ 1225 max_height = $(this).outerHeight(); 1226 } 1227 }); 1228 single_nav_2.css('min-height', max_height); 1229 1230 $(window).resize(function(){ 1231 max_height = 0; 1232 single_nav_2.css('min-height', '0px'); 1233 single_nav_2.each(function(){ 1234 if( max_height < $(this).outerHeight() ){ 1235 max_height = $(this).outerHeight(); 1236 } 1237 }); 1238 single_nav_2.css('min-height', max_height); 1239 }); 1240 }); 1241 1242 // lightbox popup 1243 $('[data-infinite-lb]').click(function(){ 1244 var lb_content = $(this).siblings('[data-infinite-lb-id="' + $(this).attr('data-infinite-lb') + '"]'); 1245 infinite_lightbox(lb_content.clone()); 1246 }); 1247 1248 // float social 1249 $('#infinite-float-social').each(function(){ 1250 var float_social_item = $(this);
1251 var pb_body = $('.gdlr-core-page-builder-body'); 1252 1253 var footer = $('footer'); 1254 var content_area = $('.infinite-page-wrapper'); 1255 var content_offset = 0; 1256 content_offset += parseInt($('html').css('margin-top')); 1257 1258 $(window).on('scroll float-social', function(){ 1259 1260 1261 // display 1262 if( float_social_item.hasClass('infinite-display-after-title') ){ 1263 var blog_offset = 0; 1264 content_area.children('.infinite-blog-title-wrap').each(function(){ blog_offset = $(this).outerHeight(); }); 1265 1266 if( float_social_item.offset().top >= content_area.offset().top + blog_offset - content_offset ){ 1267 float_social_item.animate({'opacity': 1}, {duration: 100, queue: false}); 1268 }else{ 1269 float_social_item.animate({'opacity': 0}, {duration: 100, queue: false}); 1270 } 1271 } 1272 1273 // section 1274 var section = ''; 1275 var fs_pos = $(window).scrollTop() + $(window).height() / 2; 1276 1277 if( fs_pos > footer.offset().top ){ 1278 section = 'footer'; 1279 }else{ 1280 pb_body.children().each(function(){ 1281 if( !$(this).attr('data-float-social') ) return; 1282 1283 if( fs_pos > $(this).offset().top && fs_pos < $(this).offset().top + $(this).outerHeight() ){ 1284 section = $(this).attr('data-float-social'); 1285 } 1286 }); 1287 } 1288 1289 float_social_item.attr('data-section', section); 1290 }); 1291 $(window).on('load', function(){ 1292 $(window).trigger('float-social'); 1293 }); 1294 }); 1295 1296 // side content menu 1297 $('#infinite-side-content-menu').each(function(){ 1298 1299 var side_content_menu = $(this); 1300 var menu_button = $('.infinite-side-content-menu-button'); 1301 menu_button.on('click', function(){ 1302 side_content_menu.fadeIn(300); 1303 side_content_menu.addClass('infinite-active'); 1304 }); 1305 side_content_menu.on('click', '.infinite-side-content-menu-close', function(){ 1306 side_content_menu.removeClass('infinite-active'); 1307 side_content_menu.fadeOut(300); 1308 }); 1309 1310 }); 1311 1312 }); 1313 1314 // fix back button for preload 1315 $(window).on('pageshow', function(event) { 1316 $('body').children('#infinite-page-preload').each(function(){ 1317 $(this).fadeOut(400); 1318 }); 1319 }); 1320 1321 $(window).on('load', function(){ 1322
1323 // fixed footer 1324 $('#infinite-fixed-footer').each(function(){ 1325 var fixed_footer = $(this); 1326 var placeholder = $('<div class="infinite-fixed-footer-placeholder" ></div>'); 1327 1328 placeholder.insertBefore(fixed_footer); 1329 placeholder.height(fixed_footer.outerHeight()); 1330 $('body').css('min-height', $(window).height() - parseInt($('html').css('margin-top'))); // for safari 1331 $(window).resize(function(){ 1332 placeholder.height(fixed_footer.outerHeight()); 1333 $('body').css('min-height', $(window).height() - parseInt($('html').css('margin-top'))); 1334 }); 1335 }); 1336 1337 // side navigation bar 1338 new infinite_header_side_nav( $('#infinite-header-side-nav') ); 1339 1340 // sticky navigation 1341 new infinite_sticky_navigation(); 1342 1343 // anchoring 1344 new infinite_anchor(); 1345 1346 // update woocommerce data 1347 $('body').trigger('updated_cart_totals'); 1348 }); 1349 1350})(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.