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 additional plugins 580 if( $(this).is('.fbx-btn-transition') ){ 581 return false; 582 } 583 584 // for woocommerce 585 if( $(this).parent('.description_tab, .reviews_tab').length || $(this).not('[class^="infinite"]').closest('.woocommerce').length ){ 586 if( !$(this).closest('.menu-item').length ){ 587 return false; 588 } 589 } 590 591 return true; 592 }); 593 594 if( this.anchor_link.length ){ 595 this.menu_anchor = $('#infinite-main-menu, #infinite-bullet-anchor'); 596 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'); 597 598 this.init(); 599 } 600 } 601 infinite_anchor.prototype = { 602 603 init: function(){ 604 605 var t = this; 606 607 t.animate_anchor(); 608 t.scroll_section(); 609 610 // init bullet anchor height 611 t.menu_anchor.filter('#infinite-bullet-anchor').each(function(){ 612 $(this).css('margin-top', - t.menu_anchor.height() / 2).addClass('infinite-init'); 613 }); 614 615 // initialize if the page hash exists 616 // wait for all element to initialize ( eg. flexslider ) 617 var url_hash = window.location.hash; 618 if( url_hash ){ 619 setTimeout(function(){ 620 621 var current_menu = t.menu_anchor.find('a[href*="' + url_hash + '"]'); 622 if( !current_menu.is('.current-menu-item, .current-menu-ancestor') ){ 623 current_menu.addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor'); 624 625 $(window).trigger('infinite-navigation-slider-bar-init'); 626 } 627 628 t.scroll_to(url_hash, false, 300); 629 }, 500); 630 } 631 632 }, 633 634 animate_anchor: function(){ 635 636 var t = this; 637 638 // home anchor 639 t.home_anchor.on('click', function(){ 640 641 if( window.location.href == this.href ){ 642 $('html, body').animate({ scrollTop: 0 }, { duration: 1500, easing: 'easeOutQuart' }); 643 return false; 644 } 645 646 }); 647 648 // normal anchor 649 t.anchor_link.on('click', function() { 650 if( location.hostname == this.hostname && location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') ){ 651 if( $(this).closest('#infinite-main-menu').length ){ 652 $(this).parent().addClass('current-menu-item').siblings().removeClass('current-menu-item'); 653 $(window).trigger('infinite-navigation-slider-bar-init'); 654 } 655 return t.scroll_to(this.hash, true); 656 } 657 }); 658 659 }, // animate anchor 660 661 scroll_to: function( hash, redirect, duration ){ 662 663 // start scrolling 664 if( hash == '#infinite-top-anchor' ){ 665 var scroll_position = 0; 666 }else{ 667 668 var target = $(hash); 669 670 if( target.length ){ 671 var scroll_position = target.offset().top; 672 } 673 } 674 675 if( typeof(scroll_position) != 'undefined' ){ 676 677 // offset for wordpress admin bar 678 scroll_position = scroll_position - parseInt($('html').css('margin-top')); 679 680 // offset for fixed nav bar 681 if( infinite_display == 'mobile-portrait' || infinite_display == 'mobile-landscape' ){ 682 scroll_position = scroll_position - 75; 683 }else if( typeof(window.infinite_anchor_offset) != 'undefined' && !isNaN(window.infinite_anchor_offset) ){ 684 scroll_position = scroll_position - parseInt(window.infinite_anchor_offset); 685 } 686 687 if( scroll_position < 0 ) scroll_position = 0; 688 689 $('html, body').animate({ scrollTop: scroll_position }, { duration: 1500, easing: 'easeOutQuart', queue: false }); 690 691 return false; 692 693 }else if( redirect ){ 694 695 window.location.href = $('body').attr('data-home-url') + hash; 696 697 return false; 698 } 699 700 }, // scroll to 701 702 scroll_section: function(){ 703 704 var t = this; 705 706 // have anchor in anchor menu 707 var menu_link_anchor = this.menu_anchor.find('a[href*="#"]').not('[href="#"]'); 708 if( !menu_link_anchor.length ){ return; } 709 710 // get anchor section 711 var home_anchor_section = $('#infinite-page-wrapper'); 712 var anchor_section = home_anchor_section.find('div[id], section[id]'); 713 if( !anchor_section.length ){ return; } 714 715 // add data for faster query 716 menu_link_anchor.each(function(){ 717 if( $(this).closest('.sub-menu').length == 0 && $(this.hash).length ){ 718 $(this).attr('data-anchor', this.hash); 719 } 720 }); 721 722 // check section on scroll event 723 $(window).scroll(function(){ 724 725 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ) return; 726 727 if( t.home_anchor.length && $(window).scrollTop() <= home_anchor_section.offset().top ){ 728 729 t.home_anchor.each(function(){ 730 if( $(this).hasClass('infinite-bullet-anchor-link') ){ 731 $(this).addClass('current-menu-item').siblings().removeClass('current-menu-item'); 732 $(this).parent('.infinite-bullet-anchor').attr('data-anchor-section', 'infinite-home'); 733 }else if( !$(this).parent('.current-menu-item, .current-menu-ancestor').length ){ 734 $(this).parent().addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor');
735 $(window).trigger('infinite-navigation-slider-bar-init'); 736 } 737 }); 738 739 }else{ 740 var section_position = $(window).scrollTop() + ($(window).height() / 2); 741 742 anchor_section.each(function(){ 743 if( $(this).css('display') == 'none' ) return; 744 745 var top_offset_pos = $(this).offset().top; 746 747 if( (section_position > top_offset_pos) && (section_position < top_offset_pos + $(this).outerHeight()) ){ 748 var section_id = $(this).attr('id'); 749 menu_link_anchor.filter('[data-anchor="#' + section_id + '"]').each(function(){ 750 if( $(this).hasClass('infinite-bullet-anchor-link') ){ 751 $(this).addClass('current-menu-item').siblings().removeClass('current-menu-item'); 752 $(this).parent('.infinite-bullet-anchor').attr('data-anchor-section', section_id); 753 }else if( $(this).parent('li.menu-item').length && !$(this).parent('li.menu-item').is('.current-menu-item, .current-menu-ancestor') ){ 754 $(this).parent('li.menu-item').addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor'); 755 $(window).trigger('infinite-navigation-slider-bar-init'); 756 } 757 }); 758 759 return false; 760 } 761 762 }); 763 } 764 765 }); 766 767 } // scroll section 768 769 }; 770 771 var infinite_sticky_navigation = function(){ 772 773 var t = this; 774 775 // get navigation 776 t.sticky_nav = $('.infinite-with-sticky-navigation .infinite-sticky-navigation'); 777 t.mobile_menu = $('#infinite-mobile-header'); 778 779 // set the anchor offset 780 if( t.sticky_nav.hasClass('infinite-sticky-navigation-height') ){ 781 window.infinite_anchor_offset = t.sticky_nav.outerHeight(); 782 $(window).resize(function(){ 783 window.infinite_anchor_offset = t.sticky_nav.outerHeight(); 784 }); 785 }else if( t.sticky_nav.attr('data-navigation-offset') ){ 786 window.infinite_anchor_offset = parseInt(t.sticky_nav.attr('data-navigation-offset')); 787 }else if( t.sticky_nav.length ){ 788 window.infinite_anchor_offset = 75; 789 } 790 791 // init the sticky navigation 792 if( t.sticky_nav.length ){ 793 t.init(); 794 } 795 796 if( t.mobile_menu.hasClass('infinite-sticky-mobile-navigation') ){ 797 t.style_mobile_slide(); 798 $(window).trigger('infinite-set-sticky-mobile-navigation'); 799 } 800 801 } 802 infinite_sticky_navigation.prototype = { 803 804 init: function(){ 805 806 var t = this; 807 808 if( t.sticky_nav.hasClass('infinite-style-fixed') ){ 809 t.style_fixed(); 810 }else if( t.sticky_nav.hasClass('infinite-style-slide') ){ 811 t.style_slide(); 812 } 813 814 $(window).trigger('infinite-set-sticky-navigation'); 815 }, 816 817 style_fixed: function(){ 818 819 var t = this; 820 var placeholder = $('<div class="infinite-sticky-menu-placeholder" ></div>'); 821 822 $(window).on('scroll infinite-set-sticky-navigation', function(){ 823 824 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ) return; 825 826 var page_offset = parseInt($('html').css('margin-top')); 827 828 if( !t.sticky_nav.hasClass('infinite-fixed-navigation') ){ 829 830 if( $(window).scrollTop() + page_offset > t.sticky_nav.offset().top ){ 831 if( !t.sticky_nav.hasClass('infinite-without-placeholder') ){ 832 placeholder.height(t.sticky_nav.outerHeight()); 833 } 834 placeholder.insertAfter(t.sticky_nav); 835 $('body').append(t.sticky_nav); 836 t.sticky_nav.addClass('infinite-fixed-navigation'); 837 838 setTimeout(function(){ t.sticky_nav.addClass('infinite-animate-fixed-navigation'); }, 10); 839 setTimeout(function(){ 840 t.sticky_nav.css('height', ''); 841 $(window).trigger('infinite-navigation-slider-bar-animate'); 842 }, 200); 843 } 844 }else{ 845 846 if( $(window).scrollTop() + page_offset <= placeholder.offset().top ){ 847 if( !t.sticky_nav.hasClass('infinite-without-placeholder') ){ 848 t.sticky_nav.height(placeholder.height()); 849 } 850 t.sticky_nav.insertBefore(placeholder); 851 t.sticky_nav.removeClass('infinite-fixed-navigation'); 852 placeholder.remove(); 853 854 setTimeout(function(){ t.sticky_nav.removeClass('infinite-animate-fixed-navigation'); }, 10); 855 setTimeout(function(){ 856 t.sticky_nav.css('height', '');
857 $(window).trigger('infinite-navigation-slider-bar-animate'); 858 }, 200); 859 } 860 } 861 }); 862 863 }, // style_fixed 864 865 style_slide: function(){ 866 867 var t = this; 868 var placeholder = $('<div class="infinite-sticky-menu-placeholder" ></div>'); 869 870 $(window).on('scroll infinite-set-sticky-navigation', function(){ 871 872 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ){ return; } 873 874 var page_offset = parseInt($('html').css('margin-top')); 875 876 if( !t.sticky_nav.hasClass('infinite-fixed-navigation') ){ 877 878 if( $(window).scrollTop() + page_offset > t.sticky_nav.offset().top + t.sticky_nav.outerHeight() + 200 ){ 879 880 if( !t.sticky_nav.hasClass('infinite-without-placeholder') ){ 881 placeholder.height(t.sticky_nav.outerHeight()); 882 } 883 placeholder.insertAfter(t.sticky_nav); 884 t.sticky_nav.css('display', 'none'); 885 886 $('body').append(t.sticky_nav); 887 t.sticky_nav.addClass('infinite-fixed-navigation infinite-animate-fixed-navigation'); 888 t.sticky_nav.slideDown(200); 889 $(window).trigger('infinite-navigation-slider-bar-animate'); 890 } 891 }else{ 892 893 if( $(window).scrollTop() + page_offset <= placeholder.offset().top + placeholder.height() + 200 ){ 894 var clone = t.sticky_nav.clone(); 895 clone.insertAfter(t.sticky_nav); 896 clone.slideUp(200, function(){ $(this).remove(); }); 897 898 t.sticky_nav.insertBefore(placeholder); 899 placeholder.remove(); 900 t.sticky_nav.removeClass('infinite-fixed-navigation infinite-animate-fixed-navigation'); 901 t.sticky_nav.css('display', 'block'); 902 903 $(window).trigger('infinite-navigation-slider-bar-animate'); 904 } 905 } 906 }); 907 908 }, // style_slide 909 910 style_mobile_slide: function(){ 911 912 var t = this; 913 var placeholder = $('<div class="infinite-sticky-mobile-placeholder" ></div>'); 914 915 $(window).on('scroll infinite-set-sticky-mobile-navigation', function(){ 916 917 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' || infinite_display == 'tablet' ){ 918 919 var page_offset = parseInt($('html').css('margin-top')); 920 921 if( !t.mobile_menu.hasClass('infinite-fixed-navigation') ){ 922 if( $(window).scrollTop() + page_offset > t.mobile_menu.offset().top + t.mobile_menu.outerHeight() + 200 ){ 923 placeholder.height(t.mobile_menu.outerHeight()).insertAfter(t.mobile_menu); 924 $('body').append(t.mobile_menu); 925 t.mobile_menu.addClass('infinite-fixed-navigation'); 926 t.mobile_menu.css('display', 'none').slideDown(200); 927 } 928 }else{ 929 if( $(window).scrollTop() + page_offset <= placeholder.offset().top + placeholder.height() + 200 ){ 930 var clone = t.mobile_menu.clone(); 931 clone.insertAfter(t.mobile_menu); 932 clone.slideUp(200, function(){ $(this).remove(); }); 933 934 t.mobile_menu.insertBefore(placeholder); 935 placeholder.remove(); 936 t.mobile_menu.removeClass('infinite-fixed-navigation'); 937 t.mobile_menu.css('display', 'block'); 938 } 939 } 940 } 941 942 }); 943 944 }, // style_slide 945 946 }; 947 948 var infinite_font_resize = function(){ 949 950 this.heading_font = $('h1, h2, h3, h4, h5, h6'); 951 952 this.init(); 953 954 } 955 infinite_font_resize.prototype = { 956 957 init: function(){ 958 959 var t = this; 960 961 t.resize(); 962 $(window).on('resize', infinite_throttling(function(){ 963 t.resize(); 964 }, 100)); 965 966 }, 967 968 resize: function(){ 969 970 var t = this; 971 972 if( infinite_display == 'mobile-landscape' || infinite_display == 'mobile-portrait' ){ 973 974 t.heading_font.each(function(){ 975 if( parseInt($(this).css('font-size')) > 40 ){ 976 if( !$(this).attr('data-orig-font') ){ 977 $(this).attr('data-orig-font', $(this).css('font-size')); 978 } 979 980 $(this).css('font-size', '40px'); 981 } 982 }); 983 984 // return font to normal 985 }else{ 986 987 t.heading_font.filter('[data-orig-font]').each(function(){ 988 $(this).css('font-size', $(this).attr('data-orig-font')); 989 }); 990 991 } 992 } 993 994 }; 995 996 // tourmaster lightbox 997 function infinite_lightbox( content ){ 998 999 var lightbox_wrap = $('<div class="infinite-lightbox-wrapper" ></div>').hide(); 1000 var lightbox_content_wrap = $('<div class="infinite-lightbox-content-cell" ></div>'); 1001 lightbox_wrap.append(lightbox_content_wrap); 1002 lightbox_content_wrap.wrap($('<div class="infinite-lightbox-content-row" ></div>')); 1003 1004 lightbox_content_wrap.append(content); 1005 1006 var scrollPos = $(window).scrollTop(); 1007 $('html').addClass('infinite-lightbox-on'); 1008 $('body').append(lightbox_wrap); 1009 lightbox_wrap.fadeIn(300); 1010 1011 // do a lightbox action 1012 lightbox_wrap.on('click', '.infinite-lightbox-close', function(){ 1013 $('html').removeClass('infinite-lightbox-on'); 1014 $(window).scrollTop(scrollPos); 1015 lightbox_wrap.fadeOut(300, function(){ 1016 $(this).remove(); 1017 }); 1018 }); 1019 1020 } // infinite_lightbox 1021 1022 //////////////////////////////// 1023 // starting running the script 1024 //////////////////////////////// 1025 $(document).ready(function(){ 1026 1027 // resize font on mobile 1028 new infinite_font_resize(); 1029 1030 // init main navigation menu 1031 $('#infinite-main-menu, #infinite-right-menu, #infinite-mobile-menu, #infinite-top-bar-menu').each(function(){ 1032 if( $(this).hasClass('infinite-overlay-menu') ){ 1033 new infinite_overlay_menu( $(this) ); 1034 }else if( $(this).hasClass('infinite-mm-menu-wrap') ){ 1035 $(this).infinite_mobile_menu(); 1036 }else{ 1037 new infinite_sf_menu( $(this) ); 1038 } 1039 }); 1040 1041 $('#infinite-top-search, #infinite-mobile-top-search').each(function(){ 1042 1043 var search_wrap = $(this).siblings('.infinite-top-search-wrap'); 1044 search_wrap.appendTo('body'); 1045 1046 // bind click button 1047 $(this).on('click', function(){ 1048 search_wrap.fadeIn(200, function(){ 1049 $(this).addClass('infinite-active'); 1050 }); 1051 }); 1052 1053 // bind close button 1054 search_wrap.find('.infinite-top-search-close').on('click', function(){ 1055 search_wrap.fadeOut(200, function(){ 1056 $(this).addClass('infinite-active'); 1057 }); 1058 }); 1059 1060 // bind search button 1061 search_wrap.find('.search-submit').on('click', function(){ 1062 if( search_wrap.find('.search-field').val().length == 0 ){ 1063 return false;
1064 } 1065 }); 1066 }); 1067 1068 $('#infinite-main-menu-cart, #infinite-mobile-menu-cart').each(function(){ 1069 1070 $(this).on({ 1071 mouseenter: function(){ 1072 $(this).addClass('infinite-active infinite-animating'); 1073 }, 1074 mouseleave: function(){ 1075 var menu_cart = $(this); 1076 menu_cart.removeClass('infinite-active'); 1077 setTimeout(function(){ 1078 menu_cart.removeClass('infinite-animating'); 1079 }, 400) 1080 } 1081 }); 1082 }); 1083 1084 // woocommerce top bar cart 1085 if( typeof(wc_add_to_cart_params) != 'undefined' ){ 1086 $('body').on('added_to_cart', function(){ 1087 $.ajax({ 1088 type: 'POST', 1089 url: wc_add_to_cart_params.ajax_url, 1090 data: { 'action': 'top_bar_woocommerce_cart' }, 1091 dataType: 'json', 1092 error: function(jqXHR, textStatus, errorThrown){ 1093 console.log(jqXHR, textStatus, errorThrown); 1094 }, 1095 success: function(data){ 1096 if( typeof(data['title']) != 'undefined' ){ 1097 $('.infinite-top-cart-title').replaceWith(data['title']); 1098 } 1099 if( typeof(data['cart-items']) != 'undefined' ){ 1100 $('.infinite-top-cart-item-wrap').replaceWith(data['cart-items']); 1101 } 1102 } 1103 }); 1104 }); 1105 } 1106 1107 1108 // infinite 1109 $('#infinite-dropdown-infinite-flag').hover(function(){ 1110 $(this).children('.infinite-dropdown-infinite-list').fadeIn(200); 1111 }, function(){ 1112 $(this).children('.infinite-dropdown-infinite-list').fadeOut(200); 1113 }); 1114 1115 // additional space for header transparent 1116 $('.infinite-header-boxed-wrap, .infinite-header-background-transparent, .infinite-navigation-bar-wrap.infinite-style-transparent').each(function(){ 1117 var header_transparent = $(this); 1118 var header_transparent_sub = $('.infinite-header-transparent-substitute'); 1119 1120 header_transparent_sub.height(header_transparent.outerHeight()); 1121 $(window).on('load resize', function(){ 1122 header_transparent_sub.height(header_transparent.outerHeight()); 1123 }); 1124 }); 1125 1126 // full screen for 404 not found 1127 $('body.error404, body.search-no-results').each(function(){ 1128 1129 var wrap = $(this).find('#infinite-full-no-header-wrap'); 1130 var body_wrap_offset = parseInt($(this).children('.infinite-body-outer-wrapper').children('.infinite-body-wrapper').css('margin-bottom')); 1131 1132 var padding = ($(window).height() - wrap.offset().top - wrap.outerHeight() - body_wrap_offset) / 2; 1133 if( padding > 0 ){ 1134 wrap.css({ 'padding-top': padding, 'padding-bottom': padding }); 1135 } 1136 1137 $(window).on('load resize', function(){ 1138 wrap.css({ 'padding-top': 0, 'padding-bottom': 0 }); 1139 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 }); 1145 1146 // back to top button 1147 var back_to_top = $('#infinite-footer-back-to-top-button'); 1148 if( back_to_top.length ){ 1149 $(window).on('scroll', function(){ 1150 if( $(window).scrollTop() > 300 ){ 1151 back_to_top.addClass('infinite-scrolled'); 1152 }else{ 1153 back_to_top.removeClass('infinite-scrolled'); 1154 } 1155 }); 1156 } 1157 1158 // page preload 1159 $('body').children('#infinite-page-preload').each(function(){ 1160 var page_preload = $(this); 1161 var animation_time = parseInt(page_preload.attr('data-animation-time')); 1162 1163 $('a[href]').not('[href^="#"], [target="_blank"], .gdlr-core-js, .strip, .sf-with-ul, .remove, .ajax_add_to_cart, .comment-reply-link').on('click', function(e){ 1164 if( e.which != 1 || $(this).hasClass('infinite-no-preload') || e.ctrlKey ) return; 1165 1166 if( $(this).prop("hash") && $($(this).prop("hash")).length ) return; 1167 1168 if( window.location.href != this.href ){ 1169 page_preload.addClass('infinite-out').fadeIn(animation_time); 1170 } 1171 }); 1172 1173 $(window).on('load', function(){ 1174 page_preload.fadeOut(animation_time); 1175 }); 1176 }); 1177 1178 // single nav style 2 sync height 1179 $('body.infinite-blog-style-2 .infinite-single-nav-area').each(function(){ 1180 var max_height; 1181 var single_nav_2 = $(this).children(); 1182 1183 max_height = 0; 1184 single_nav_2.css('min-height', '0px'); 1185 single_nav_2.each(function(){ 1186 if( max_height < $(this).outerHeight() ){ 1187 max_height = $(this).outerHeight(); 1188 } 1189 }); 1190 single_nav_2.css('min-height', max_height); 1191 1192 $(window).resize(function(){ 1193 max_height = 0; 1194 single_nav_2.css('min-height', '0px'); 1195 single_nav_2.each(function(){ 1196 if( max_height < $(this).outerHeight() ){ 1197 max_height = $(this).outerHeight(); 1198 } 1199 }); 1200 single_nav_2.css('min-height', max_height); 1201 }); 1202 }); 1203 1204 // lightbox popup 1205 $('[data-infinite-lb]').click(function(){ 1206 var lb_content = $(this).siblings('[data-infinite-lb-id="' + $(this).attr('data-infinite-lb') + '"]'); 1207 infinite_lightbox(lb_content.clone()); 1208 }); 1209 1210 // float social 1211 $('#infinite-float-social').each(function(){ 1212 var float_social_item = $(this);
1213 var pb_body = $('.gdlr-core-page-builder-body'); 1214 1215 var footer = $('footer'); 1216 var content_area = $('.infinite-page-wrapper'); 1217 var content_offset = 0; 1218 content_offset += parseInt($('html').css('margin-top')); 1219 1220 $(window).on('scroll float-social', function(){ 1221 1222 1223 // display 1224 if( float_social_item.hasClass('infinite-display-after-title') ){ 1225 var blog_offset = 0; 1226 content_area.children('.infinite-blog-title-wrap').each(function(){ blog_offset = $(this).outerHeight(); }); 1227 1228 if( float_social_item.offset().top >= content_area.offset().top + blog_offset - content_offset ){ 1229 float_social_item.animate({'opacity': 1}, {duration: 100, queue: false}); 1230 }else{ 1231 float_social_item.animate({'opacity': 0}, {duration: 100, queue: false}); 1232 } 1233 } 1234 1235 // section 1236 var section = ''; 1237 var fs_pos = $(window).scrollTop() + $(window).height() / 2; 1238 1239 if( fs_pos > footer.offset().top ){ 1240 section = 'footer'; 1241 }else{ 1242 pb_body.children().each(function(){ 1243 if( !$(this).attr('data-float-social') ) return; 1244 1245 if( fs_pos > $(this).offset().top && fs_pos < $(this).offset().top + $(this).outerHeight() ){ 1246 section = $(this).attr('data-float-social'); 1247 } 1248 }); 1249 } 1250 1251 float_social_item.attr('data-section', section); 1252 }); 1253 $(window).on('load', function(){ 1254 $(window).trigger('float-social'); 1255 }); 1256 }); 1257 1258 }); 1259 1260 // fix back button for preload 1261 $(window).on('pageshow', function(event) { 1262 if( event.originalEvent.persisted ){ 1263 $('body').children('#infinite-page-preload').each(function(){ 1264 $(this).fadeOut(400); 1265 }); 1266 } 1267 }); 1268 1269 $(window).on('load', function(){ 1270 1271 // fixed footer 1272 $('#infinite-fixed-footer').each(function(){ 1273 var fixed_footer = $(this); 1274 var placeholder = $('<div class="infinite-fixed-footer-placeholder" ></div>'); 1275 1276 placeholder.insertBefore(fixed_footer); 1277 placeholder.height(fixed_footer.outerHeight()); 1278 $('body').css('min-height', $(window).height() - parseInt($('html').css('margin-top'))); // for safari 1279 $(window).resize(function(){ 1280 placeholder.height(fixed_footer.outerHeight()); 1281 $('body').css('min-height', $(window).height() - parseInt($('html').css('margin-top'))); 1282 }); 1283 }); 1284 1285 // side navigation bar 1286 new infinite_header_side_nav( $('#infinite-header-side-nav') ); 1287 1288 // sticky navigation 1289 new infinite_sticky_navigation(); 1290 1291 // anchoring 1292 new infinite_anchor(); 1293 1294 // update woocommerce data 1295 $('body').not('.woocommerce-cart').trigger('added_to_cart'); 1296 }); 1297 1298})(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.