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