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