1(function($){ 2 3 /** 4 * Helper class for frontend theme logic. 5 * 6 * @since 1.0 7 * @class FLTheme 8 */ 9 FLTheme = { 10 11 /** 12 * Initializes all frontend theme logic. 13 * 14 * @since 1.0 15 * @method init 16 */ 17 init: function() 18 { 19 this._bind(); 20 }, 21 22 /** 23 * Initializes and binds all frontend events. 24 * 25 * @since 1.0 26 * @access private 27 * @method _bind 28 */ 29 _bind: function() 30 { 31 var self = this; 32 33 // Nav Toggles 34 $('.navbar-toggle').on('click', this.navbarToggleClick); 35 36 // Top Nav Drop Downs 37 if($('.fl-page-bar-nav ul.sub-menu').length != 0) { 38 this._setupDropDowns(); 39 this._enableTopNavDropDowns(); 40 } 41 42 // Page Nav Drop downs 43 if($('.fl-page-nav ul.sub-menu').length != 0) { 44 $(window).on('resize.fl-page-nav-sub-menu', $.throttle(500, this._enablePageNavDropDowns)); 45 this._setupDropDowns(); 46 this._enablePageNavDropDowns(); 47 } 48 49 // Current menu item initializes or click 50 if($('.fl-page-nav ul.menu').length != 0) { 51 $('.fl-page-nav ul.menu').find('.menu-item').on('click', '> a[href*="#"]:not([href="#"])', this._setupCurrentNavItem); 52 this._setupCurrentNavItem(); 53 } 54 55 // Nav Search 56 if($('.fl-page-nav-search').length != 0) { 57 $('.fl-page-nav-search a.fa-search').on('click', this._toggleNavSearch); 58 } 59 60 // Nav vertical 61 if($('.fl-nav-vertical').length != 0) { 62 $(window).on('resize', $.throttle(500, this._navVertical)); 63 this._navVertical(); 64 } 65 66 // Nav vertical right & boxed layout 67 if($('.fl-fixed-width.fl-nav-vertical-right').length != 0) { 68 $(window).on('resize', $.throttle(500, this._updateVerticalRightPos)); 69 this._updateVerticalRightPos(); 70 } 71 72 // Centered inline logo 73 if($('.fl-page-nav-centered-inline-logo').length != 0) { 74 $(window).on('resize', $.throttle(500, this._centeredInlineLogo)); 75 this._centeredInlineLogo(); 76 } 77 78 // Nav Left 79 if($('body.fl-nav-left').length != 0) { 80 $(window).on('resize', $.throttle(500, this._navLeft)); 81 this._navLeft(); 82 } 83 84 // Shrink Header 85 if( ($('body.fl-shrink').length != 0) && !($('html.fl-builder-edit').length != 0) ) { 86 $(window).on('resize', $.throttle(500, this._shrinkHeaderEnable)); 87 this._shrinkHeaderInit(); 88 this._shrinkHeaderEnable(); 89 } 90 91 // Fixed Header (Fade In) 92 if($('.fl-page-header-fixed').length != 0) { 93 $(window).on('resize.fl-page-header-fixed', $.throttle(500, this._enableFixedHeader)); 94 this._enableFixedHeader(); 95 } 96 97 // Fixed Header (Fixed) 98 if( ($('body.fl-fixed-header').length != 0) && !($('html.fl-builder-edit').length != 0) ) { 99 $(window).on('resize', $.throttle(500, this._fixedHeader)); 100 this._fixedHeader(); 101 } 102 103 // Hide Header Until Scroll 104 if( ($('body.fl-scroll-header').length != 0) && !($('html.fl-builder-edit').length != 0) ) { 105 $(window).on('resize', $.throttle(500, this._scrollHeader)); 106 this._scrollHeader(); 107 } 108 109 // Mega Menu (Primary Nav) 110 if($('.fl-page-header-primary').find( 'li.mega-menu' ).length != 0) { 111 $(window).on('resize', $.throttle(500, this._megaMenu)); 112 this._megaMenu(); 113 } 114 115 // Mega Menu (Fixed) 116 if($('.fl-page-header-fixed').length != 0) { 117 $(window).on('scroll.fl-mega-menu-on-scroll', $.throttle(500, this._megaMenuOnScroll)); 118 $(window).on('resize.fl-mega-menu-on-scroll', $.throttle(500, this._megaMenuOnScroll)); 119 } 120 121 // Headers not be fixed when the builder is active 122 if($('html.fl-builder-edit').length != 0) { 123 this._fixedHeadersWhenBuilderActive(); 124 } 125 126 // Responsive Nav Layout 127 if ( $( 'body.fl-nav-mobile-offcanvas' ).length != 0 && ! $( 'html.fl-builder-edit' ).length != 0 ) { 128 $(window).on('resize', $.throttle(500, this._setupMobileNavLayout)); 129 this._setupMobileNavLayout(); 130 this._toggleMobileNavLayout(); 131 } 132 133 // Close Dropdown or Flyout Menu 134 $( 'body' ).on( 'click', this.closeMenu ); 135 136 // Close Dropdown or Flyout Menu when tabbing out from the last menu item. 137 $( '.fl-theme-menu > li:last-child' ).on( 'focusout', function (e) { 138 if ( undefined === $(e.relatedTarget)[0] || 'nav-link' !== $(e.relatedTarget)[0].className) { 139 self.closeMenu( e ); 140 } 141 }); 142 143 // Footer parallax effect 144 if($('.fl-full-width.fl-footer-effect').length != 0) { 145 $(window).on('resize', $.throttle(500, this._footerEffect)); 146 this._footerEffect(); 147 } 148 149 // Go to Top 150 if($('body.fl-scroll-to-top').length != 0) {
151 this._toTop(); 152 } 153 154 // Lightbox 155 if(typeof $('body').magnificPopup != 'undefined') { 156 this._enableLightbox(); 157 } 158 159 // FitVids 160 if(typeof $.fn.fitVids != 'undefined' && !$('body').hasClass('fl-builder')) { 161 this._enableFitVids(); 162 } 163 FLTheme._navBackiosFix(); 164 165 // Smooth scrolling. 166 this._initSmoothScroll() 167 }, 168 169 /** 170 * Checks to see if the current device is mobile. 171 * 172 * @since 1.5.1 173 * @access private 174 * @method _isMobile 175 * @return {Boolean} 176 */ 177 _isMobile: function() 178 { 179 if ( ( 'ontouchstart' in window ) || ( navigator.maxTouchPoints > 0 ) || ( navigator.msMaxTouchPoints > 0 ) ) { 180 return true; 181 } 182 183 return /Mobile|Android|Silk\/|Kindle|BlackBerry|Opera Mini|Opera Mobi|webOS/i.test( navigator.userAgent ); 184 }, 185 186 /** 187 * Initializes retina images. 188 * 189 * @since 1.0 190 * @access private 191 * @method _initRetinaImages 192 */ 193 _initRetinaImages: function() 194 { 195 var pixelRatio = !!window.devicePixelRatio ? window.devicePixelRatio : 1; 196 197 if ( pixelRatio > 1 ) { 198 $( 'img[data-retina]' ).each( FLTheme._convertImageToRetina ); 199 } 200 }, 201 202 /** 203 * Converts an image to retina. 204 * 205 * @since 1.0 206 * @access private 207 * @method _convertImageToRetina 208 */ 209 _convertImageToRetina: function() 210 { 211 var image = $( this ), 212 tmpImage = new Image(), 213 src = image.attr( 'src' ), 214 retinaSrc = image.data( 'retina' ) 215 216 // check for cloudflare 217 if( typeof src == 'undefined') { 218 src = image.data( 'cfsrc' ) 219 } 220 221 // still no src, bail. 222 if( typeof src == 'undefined') { 223 return false; 224 } 225 226 var type = src.split('.').pop(); 227 228 if ( '' != retinaSrc ) { 229 230 tmpImage.onload = function() { 231 var width = tmpImage.width, 232 height = tmpImage.height; 233 234 if ( 'svg' == type ) { 235 width = image.width(); 236 height = image.height(); 237 } 238 239 //image.css( 'max-height', height ); 240 image.width( width ); 241 image.attr( 'src', retinaSrc ); 242 }; 243 244 tmpImage.src = src; 245 } 246 }, 247 248 /** 249 * Mobile Header Logo. 250 * 251 * @since 1.7 252 * @access private 253 * @method _initMobileHeaderLogo 254 */ 255 _initMobileHeaderLogo: function() 256 { 257 this._enableMobileLogo(); 258 $( window ).on( 'resize', $.proxy( this._enableMobileLogo, this ) ); 259 }, 260 261 /** 262 * Enable Mobile Logo. 263 * 264 * @since 1.7 265 * @access private 266 * @method _enableMobileLogo 267 */ 268 _enableMobileLogo: function() 269 { 270 var win = $( window ), 271 logoWrap = $( '.fl-page-header-logo' ), 272 logos = logoWrap.find( 'img[data-mobile]' ), 273 image = null, 274 mobileSrc = null, 275 tmpImage = null; 276 277 if ( 0 === logos.length ) { 278 return; 279 } 280 281 $( logos ).each( function(){ 282 tmpImage = new Image(); 283 image = $( this ); 284 src = image.attr( 'src' ); 285 width = image.data( 'width' ); 286 height = image.data( 'height' ); 287 mobileSrc = image.data( 'mobile' ); 288 mobileWidth = image.data( 'mobile-width' ); 289 mobileHeight = image.data( 'mobile-height' ) 290 291 image.attr( 'src', '' ); 292 image.attr( 'data-src', src ); 293 294 if ( win.width() < window.themeopts.mobile_breakpoint ) { 295 296 if ( '' != mobileSrc ) { 297 tmpImage.onload = function() { 298 image.attr( 'src', mobileSrc ); 299 image.attr( 'width', mobileWidth ); 300 image.attr( 'height', mobileHeight ); 301 image.css( 'width', '' ); 302 }; 303 tmpImage.src = src; 304 image.show(); 305 } 306 } 307 else { 308 if ( 'undefined' !== typeof image.data('src') ) { 309 image.attr( 'src', image.data('src') ); 310 image.attr( 'width', width ); 311 image.attr( 'height', height ); 312 image.css( 'width', width ); 313 } 314 } 315 }); 316 }, 317 318 /** 319 * Toggles a collapsed navbar when the toggle button is 320 * clicked and the current framework is the bootstrap base. 321 * 322 * @since 1.7 323 * @param {Object} e 324 */ 325 navbarToggleClick: function( e ) { 326 var menuType = $('body').hasClass('fl-nav-mobile-offcanvas') ? 'flyout' : 'dropdown'; 327 328 if ( 'dropdown' === menuType ) { 329 var navBar = $(e.target).closest('.fl-page-nav'), 330 targetPanel = navBar.find('.fl-page-nav-collapse'); 331 332 targetPanel.toggleClass('collapse'); 333 targetPanel.toggleClass('in'); 334 335 } else if ( 'flyout' === menuType ) { 336 337 $( '.fl-page' ).toggleClass( 'fl-nav-offcanvas-active' ); 338 339 } 340 341 e.stopPropagation(); 342 }, 343 344 /** 345 * Closes Dropdown or Flyout Menu when clicked anywhere on the page. 346 * 347 * @since 1.7.9 348 * @param {Object} e 349 */ 350 closeMenu: function (e) { 351 var menuType = $( 'body' ).hasClass( 'fl-nav-mobile-offcanvas' ) ? 'flyout' : 'dropdown', 352 isDropdownMenuActive = $( '.fl-page-nav-collapse' ).hasClass( 'in' ), 353 isFlyoutMenuActive = $( '.fl-page' ).hasClass( 'fl-nav-offcanvas-active' ), 354 isMaxMegaMenu = $( e.target ).is( '.mega-toggle-animated-inner, .mega-menu-toggle-animated-block, .mega-toggle-animated-box, .mega-toggle-blocks-right' ), 355 pageNav; 356 357 if ( undefined === e || undefined === e.target || isMaxMegaMenu ) { 358 return; 359 } 360 361 if ( 'dropdown' === menuType && isDropdownMenuActive ) { 362 pageNav = $( '.navbar-collapse.in' ).closest( '.fl-page-nav' ); 363 pageNav.find( '.navbar-toggle' ).trigger( 'click' ); 364 } else if ( 'flyout' === menuType && isFlyoutMenuActive) { 365 $( '.fl-offcanvas-close' ).trigger( 'click' ); 366 } 367 }, 368 369 /** 370 * Initializes drop down nav logic. 371 * 372 * @since 1.0 373 * @access private 374 * @method _setupDropDowns 375 */ 376 _setupDropDowns: function() 377 { 378 $('ul.sub-menu').each(function(){ 379 $( this ).closest( 'li' ).find('a').first().attr( 'aria-haspopup', 'true' ); 380 }); 381 }, 382 383 /** 384 * Initializes drop down menu logic for top bar navs. 385 * 386 * @since 1.0 387 * @access private 388 * @method _enableTopNavDropDowns 389 */ 390 _enableTopNavDropDowns: function() 391 { 392 var nav = $('.fl-page-bar-nav'), 393 navItems = nav.find(' > li'), 394 subToggles = nav.find('> li').has('> ul.sub-menu').find('.fl-submenu-toggle-icon'); 395 396 if ( FLTheme._isMobile() ) { 397 if( false !== /iPhone|iPad/i.test( navigator.userAgent ) ) { 398 navItems.hover(FLTheme._navItemMouseover, FLTheme._navItemMouseout); 399 } 400 else { 401 navItems.hover(function(){}, FLTheme._navItemMouseout); 402 subToggles.on('click', FLTheme._navSubMenuToggleClick); 403 } 404 } 405 else { 406 navItems.hover(FLTheme._navItemMouseover, FLTheme._navItemMouseout); 407 } 408 }, 409 410 /** 411 * Fixes an ios quirk, if we have a dropdown menu and a user clicks 'back' 412 * the menu will stay open, ios does not reparse js when you click back. 413 * This method detects that back has been clicked by looking for event.persisted 414 * 415 * @since 1.6.2 416 * @method _navBackiosFix 417 */ 418 _navBackiosFix: function() { 419 ipad = (navigator.userAgent.match('iPhone|iPad') !== null && $('.menu-item-has-children').length > 0) ? true : false;
420 if( false !== ipad ) { 421 window.onpageshow = function(event) { 422 if (event.persisted) { 423 window.location.reload() 424 } 425 } 426 } 427 }, 428 429 /** 430 * Initializes builder smooth scrolling. 431 * 432 * @since 1.7.6 433 * @return void 434 */ 435 _initSmoothScroll: function() { 436 // Bail if builder doesn't exist. 437 if ('undefined' === typeof FLBuilderLayout) { 438 return; 439 } 440 441 // if scroll is disabled globally via filter do not scroll. 442 if ('undefined' !== typeof window.themeopts.smooth && 'disabled' === window.themeopts.smooth) { 443 return; 444 } 445 var targetId = location.hash; 446 targetId = targetId.replace( /(:|\!|\.|\[|\]|,|=|@|\/)/g, "\\$1" ); 447 if (targetId && $( targetId ).length) { 448 setTimeout(function() { 449 window.scrollTo(0, 0); 450 FLBuilderLayout._scrollToElement( $(targetId) ); 451 }, 1); 452 } 453 }, 454 455 /** 456 * Initializes drop down menu logic for the main nav for primary and fixed header. 457 * 458 * @since 1.0 459 * @access private 460 * @method _enablePageNavDropDowns 461 */ 462 _enablePageNavDropDowns: function() 463 { 464 var pageNav = $('.fl-page-header'); 465 466 pageNav.each( FLTheme._enablePageNavDropDown ); 467 }, 468 469 /** 470 * Callback logic for each main header nav dropdown 471 * 472 * @since 1.6 473 * @access private 474 * @method _enablePageNavDropDown 475 */ 476 _enablePageNavDropDown: function() 477 { 478 var pageNav = $(this), 479 nav = pageNav.find('.fl-page-nav .fl-page-nav-collapse'), 480 navItems = nav.find('ul li'), 481 subToggles = nav.find('li').has('> ul.sub-menu').find('> a'), 482 toggleIcon = nav.find('li').has('> ul.sub-menu').find('.fl-submenu-toggle-icon'), 483 subMenus = nav.find('> ul > li').has('ul.sub-menu'); 484 485 if( $( '.fl-page-nav .navbar-toggle' ).is( ':visible' ) ) { 486 navItems.off('mouseenter mouseleave'); 487 488 // Toggle submenu 489 if ( $( 'body' ).hasClass( 'fl-submenu-toggle' ) ) { 490 subMenus = nav.find('> ul li').has('ul.sub-menu'); 491 } 492 subMenus.find('> a').off().on('click', FLTheme._navItemClickMobile); 493 subMenus.find('.fl-submenu-toggle-icon').off().on('click', FLTheme._navItemClickMobile); 494 495 nav.find('.menu').on('click', '.menu-item > a[href*="#"]', FLTheme._toggleForMobile); 496 subToggles.off('click', FLTheme._navSubMenuToggleClick); 497 } 498 else { 499 nav.find('a').off('click', FLTheme._navItemClickMobile); 500 nav.find('a').off('click', FLTheme._toggleForMobile); 501 nav.find('.fl-submenu-toggle-icon').off('click', FLTheme._navItemClickMobile); 502 nav.removeClass('in').addClass('collapse'); 503 navItems.removeClass('fl-mobile-sub-menu-open'); 504 navItems.find('a').width(0).width('auto'); 505 506 if ( FLTheme._isMobile() ) { 507 navItems.hover(function(){}, FLTheme._navItemMouseout); 508 subToggles.on('click', FLTheme._navSubMenuToggleClick); 509 } 510 else { 511 navItems.keydown( function(e){ 512 if ( 9 === e.keyCode ) { 513 el = $(this) 514 focused = el.find(':focus') 515 if( focused.parent().is(':last-child') ) { 516 sub = focused.parent().find('ul.sub-menu').first() 517 mega = focused.parent().parent().parent().parent().parent().hasClass('mega-menu') 518 mega_last = focused.parent().parent().parent().is(':last-child' ) 519 520 if ( sub.length > 0 ) { 521 sub.trigger('mouseenter') 522 } else { 523 if ( ! mega || mega_last ) { 524 el.trigger('mouseleave') 525 } 526 } 527 } 528 parent = focused.closest('ul.sub-menu').parent() 529 if ( ! parent.hasClass('fl-sub-menu-open') ) { 530 focused.trigger('mouseenter') 531 } 532 } 533 } ); 534 navItems.hover(FLTheme._navItemMouseover, FLTheme._navItemMouseout); 535 } 536 } 537 }, 538 539 /** 540 * Callback for when an item in a nav is clicked on mobile. 541 * 542 * @since 1.0 543 * @access private 544 * @method _navItemClickMobile 545 * @param {Object} e The event object. 546 */ 547 _navItemClickMobile: function(e) 548 { 549 var nav = $(this).closest('.fl-page-nav-collapse'), 550 parent = $(this).closest('li'), 551 href = $(this).attr('href'), 552 subMenu = parent.find( 'ul.sub-menu' ), 553 toggle = $(e.target).hasClass('fl-submenu-toggle-icon'), 554 subChildren = null; 555 556 if( href && '#' !== href ) { 557 var targetId = href.split('#')[1]; 558 if ( $('body').find('#'+ targetId).length > 0 && parent.hasClass( 'fl-mobile-sub-menu-open' ) ) { 559 el = $(this).parent().closest('nav').find( '.navbar-toggle') 560 el.trigger('click'); 561 if ( 'undefined' !== typeof FLBuilderLayout && ( 'undefined' === typeof window.themeopts.smooth && 'disabled' !== window.themeopts.smooth ) ) { 562 setTimeout(function() { 563 window.scrollTo(0, 0); 564 FLBuilderLayout._scrollToElement( $('#'+ targetId) ); 565 }, 1); 566 } 567 } 568 } 569 570 if( ( '#' == href || toggle ) && parent.hasClass( 'fl-mobile-sub-menu-open' ) ) { 571 e.preventDefault(); 572 parent.removeClass('fl-mobile-sub-menu-open'); 573 subMenu.hide(); 574 } 575 else if(!parent.hasClass('fl-mobile-sub-menu-open')) { 576 577 e.preventDefault(); 578 parent.addClass('fl-mobile-sub-menu-open'); 579 580 if ( toggle && 0 === $('.fl-submenu-toggle').length ) { 581 subChildren = subMenu.find( 'li.menu-item-has-children' ); 582 subChildren.addClass('fl-mobile-sub-menu-open'); 583 } 584 585 subMenu.fadeIn(200); 586 } 587 588 if ( $( '.fl-nav-collapse-menu' ).length != 0 ) { 589 nav.find( 'li.fl-mobile-sub-menu-open' ) 590 .not( $(this).parents( '.fl-mobile-sub-menu-open' ) ) 591 .not( subChildren ) 592 .removeClass( 'fl-mobile-sub-menu-open' ) 593 .find( 'ul.sub-menu' ).hide(); 594 } 595 596 e.stopPropagation(); 597 }, 598 599 /** 600 * Setup and callback for nav item link that exists on a page. 601 * 602 * @since 1.5.3 603 * @access private 604 * @method _setupCurrentNavItem 605 * @param {Object|Null} e The event object. 606 */ 607 _setupCurrentNavItem: function(e) 608 { 609 var nav = $('.fl-page-nav .navbar-nav'), 610 targetId = typeof e !== 'undefined' ? $(e.target).prop('hash') : window.location.hash, 611 targetId = targetId.replace( /(:|\!|\.|\[|\]|,|=|@|\/)/g, "\\$1" ),
612 currentLink = targetId.length ? nav.find('a[href*=\\' + targetId + ']:not([href=\\#])') : null, 613 closeButton = nav.closest('.fl-page-nav').find('.fl-offcanvas-close'); 614 615 if ( currentLink != null && $('body').find(targetId).length > 0 ) { 616 $( '.current-menu-item' ).removeClass( 'current-menu-item' ); 617 currentLink.parent().addClass('current-menu-item'); 618 619 if ( closeButton ) { 620 closeButton.trigger( 'click' ); 621 } 622 } 623 }, 624 625 626 /** 627 * Callback for when the mouse leaves an item 628 * in a nav at desktop sizes. 629 * 630 * @since 1.0 631 * @access private 632 * @method _navItemMouseover 633 */ 634 _navItemMouseover: function() 635 { 636 if($(this).find('ul.sub-menu').length === 0) { 637 return; 638 } 639 640 var li = $(this), 641 parent = li.parent(), 642 subMenu = li.find('ul.sub-menu'), 643 subMenuWidth = subMenu.width(), 644 subMenuPos = 0, 645 winWidth = $(window).width(), 646 spacerPos = 0, 647 subMenuTopPos = 0; 648 649 if(li.closest('.fl-sub-menu-right').length !== 0) { 650 li.addClass('fl-sub-menu-right'); 651 } 652 else if($('body').hasClass('rtl')) { 653 654 subMenuPos = parent.is('ul.sub-menu') ? 655 parent.offset().left - subMenuWidth: 656 li.offset().left - subMenuWidth; 657 658 if(subMenuPos <= 0) { 659 li.addClass('fl-sub-menu-right'); 660 } 661 } 662 else { 663 664 subMenuPos = parent.is('ul.sub-menu') ? 665 parent.offset().left + (subMenuWidth * 2) : 666 li.offset().left + subMenuWidth; 667 668 if(subMenuPos > winWidth) { 669 li.addClass('fl-sub-menu-right'); 670 } 671 } 672 673 li.addClass('fl-sub-menu-open'); 674 675 if ( ! li.hasClass('hide-heading') ) { 676 subMenu.hide(); 677 subMenu.stop().fadeIn(200); 678 } 679 680 FLTheme._hideNavSearch(); 681 682 // Mega menu hover fix 683 if ( li.closest( '.fl-page-nav-collapse' ).length !== 0 && li.hasClass( 'mega-menu' ) ) { 684 685 if ( li.find( '.mega-menu-spacer' ).length > 0 ) { 686 return; 687 } 688 689 subMenu.first().before( '<div class="mega-menu-spacer"></div>' ); 690 spacerPos = li.find( '.mega-menu-spacer' ).offset().top; 691 subMenuTopPos = subMenu.first().offset().top; 692 li.find( '.mega-menu-spacer' ).css('padding-top', Math.floor( parseInt(subMenuTopPos - spacerPos) ) + 'px' ); 693 } 694 }, 695 696 /** 697 * Callback for when the mouse leaves an item 698 * in a nav at desktop sizes. 699 * 700 * @since 1.0 701 * @access private 702 * @method _navItemMouseout 703 */ 704 _navItemMouseout: function() 705 { 706 var li = $(this), 707 subMenu = li.find('ul.sub-menu'); 708 709 710 if ( ! li.hasClass('hide-heading') ) { 711 subMenu.stop().fadeOut({ 712 duration: 200, 713 done: FLTheme._navItemMouseoutComplete 714 }); 715 } 716 else { 717 FLTheme._navItemMouseoutComplete(); 718 } 719 }, 720 721 /** 722 * Callback for when the mouse finishes leaving an item 723 * in a nav at desktop sizes. 724 * 725 * @since 1.0 726 * @access private 727 * @method _navItemMouseoutComplete 728 */ 729 _navItemMouseoutComplete: function() 730 { 731 var li = $(this).parent(); 732 733 li.removeClass('fl-sub-menu-open'); 734 li.removeClass('fl-sub-menu-right'); 735 736 if ( li.find( '.mega-menu-spacer' ).length > 0 ) { 737 li.find( '.mega-menu-spacer' ).remove(); 738 } 739 740 $(this).show(); 741 }, 742 743 /** 744 * Callback for when a submenu toggle is clicked on mobile. 745 * 746 * @since 1.5.1 747 * @access private 748 * @method _navSubToggleClick 749 * @param {Object} e The event object. 750 */ 751 _navSubMenuToggleClick: function( e ) 752 { 753 var li = $( this ).closest( 'li' ).eq( 0 ); 754 755 if ( ! li.hasClass( 'fl-sub-menu-open' ) ) { 756 FLTheme._navItemMouseover.apply( li[0] ); 757 758 e.preventDefault(); 759 } 760 }, 761 762 /** 763 * Logic for the menu item when clicked on mobile. 764 * 765 * @since 1.5.3 766 * @return void 767 */ 768 _toggleForMobile: function( e ){ 769 var nav = $('.fl-page-nav .fl-page-nav-collapse'), 770 href = $(this).attr('href'), 771 hasSubmenu = $(this).closest('li').hasClass( 'menu-item-has-children' ); 772 773 if ( href !== '#' ) { 774 var targetId = href.split('#')[1]; 775 776 if ( $('body').find('#'+ targetId).length > 0 && !hasSubmenu ) { 777 /** 778 * Make sure bootstrap collapse is available before using it. 779 */ 780 if ( ! $.isFunction(nav.collapse) ) { 781 el = $(this).parent().closest('nav').find( '.navbar-toggle') 782 el.trigger('click') 783 } else { 784 nav.collapse('hide'); 785 } 786 } 787 } 788 }, 789 790 /** 791 * Shows or hides the nav search form. 792 * 793 * @since 1.0 794 * @access private 795 * @method _toggleNavSearch 796 */ 797 _toggleNavSearch: function(e) 798 { 799 var form = $('.fl-page-nav-search form'); 800 801 e.preventDefault(); 802 803 if(form.is(':visible')) { 804 form.stop().fadeOut(200); 805 } 806 else { 807 form.stop().fadeIn(200); 808 $('body').on('click.fl-page-nav-search', FLTheme._hideNavSearch); 809 $('.fl-page-nav-search .fl-search-input').focus(); 810 } 811 }, 812 813 /** 814 * Hides the nav search form. 815 * 816 * @since 1.0 817 * @access private 818 * @method _hideNavSearch 819 * @param {Object} e (Optional) An event object. 820 */ 821 _hideNavSearch: function(e) 822 { 823 var form = $('.fl-page-nav-search form'); 824 825 if(e !== undefined) { 826 if($(e.target).closest('.fl-page-nav-search').length > 0) { 827 return; 828 } 829 } 830 831 form.stop().fadeOut(200); 832 833 $('body').off('click.fl-page-nav-search'); 834 }, 835 836 /** 837 * Nav Vertical 838 * 839 * @since 1.5 840 * @access private 841 * @method _navVertical 842 */ 843 _navVertical: function() 844 { 845 var win = $(window); 846 847 848 if(win.width() >= window.themeopts.medium_breakpoint && $('.fl-page-header-primary').hasClass('fl-page-nav-toggle-visible-always')){ 849 $('body').toggleClass('fl-nav-vertical'); 850 851 if( $('body').hasClass('fl-nav-vertical-left') ) { 852 $('body').toggleClass('fl-nav-vertical-left'); 853 } 854 855 if( $('body').hasClass('fl-nav-vertical-right') ) { 856 $('body').toggleClass('fl-nav-vertical-right'); 857 } 858 } 859 }, 860 861 /** 862 * Right position fix for right navigation on boxed layout 863 * 864 * @since 1.5 865 * @access private 866 * @method _updateVerticalRightPos 867 */ 868 _updateVerticalRightPos: function() 869 { 870 var win = $(window).width(), 871 flpage = $('.fl-page').width(), 872 vericalRightPos = ( (win - flpage) / 2 ); 873 874 $('.fl-page-header-vertical').css('right', vericalRightPos); 875 }, 876 877 /** 878 * Nav Left 879 * 880 * @since 1.5 881 * @access private 882 * @method _navLeft 883 */ 884 _navLeft: function() 885 { 886 var win = $(window); 887 888 if(win.width() < window.themeopts.medium_breakpoint || $('.fl-page-header-primary').hasClass('fl-page-nav-toggle-visible-always')) { 889 $('.fl-page-header-primary .fl-page-logo-wrap').insertBefore('.fl-page-header-primary .fl-page-nav-col'); 890 } 891 if(win.width() >= window.themeopts.medium_breakpoint && !$('.fl-page-header-primary').hasClass('fl-page-nav-toggle-visible-always')) { 892 $('.fl-page-header-primary .fl-page-nav-col').insertBefore('.fl-page-header-primary .fl-page-logo-wrap'); 893 } 894 895 if($('.fl-page-header-fixed').length != 0 && ! $('.fl-page-header-fixed').hasClass('fl-page-nav-toggle-visible-always') ) { 896 $('.fl-page-header-fixed .fl-page-fixed-nav-wrap').insertBefore('.fl-page-header-fixed .fl-page-logo-wrap'); 897 } 898 }, 899 900 /** 901 * Initialize header shrinking. 902 * 903 * @since 1.5.2 904 * @access private 905 * @method _shrinkHeaderInit 906 */ 907 _shrinkHeaderInit: function() 908 { 909 var distanceY = $(window).scrollTop(), 910 shrinkOn = 250, 911 header = $( '.fl-page-header' ); 912 913 $( 'body' ).addClass( 'fl-shrink-header-enabled' ); 914 915 if ('scrollRestoration' in history) { 916 history.scrollRestoration = 'manual'; 917 } 918 919 $('.fl-page-header-logo').imagesLoaded(function(){ 920 var logo = $( '.fl-logo-img' ), 921 logoForHeight = $( '.fl-page-header-logo:visible .fl-logo-img' ).first(); 922 923 if ( ! logoForHeight.length ) { 924 logoForHeight = logo.first(); 925 } 926 927 var logoHeight = logoForHeight.length ? logoForHeight.height() : 0; 928 929 if ( 'undefined' !== typeof logoForHeight.data('origHeight') ) { 930 logoHeight = parseInt( logoForHeight.data('origHeight') ); 931 } 932 if ( ! logoHeight && logo.length ) { 933 logoHeight = parseInt( logo.first().data('origHeight') ) || 46; 934 } 935 936 logo.css( 'max-height', logoHeight ); 937 938 setTimeout( function() { 939 $('.fl-page-header').addClass( 'fl-shrink-header-transition' ); 940 941 // Shrink on page load 942 if ( distanceY > shrinkOn ) { 943 header.addClass( 'fl-shrink-header' ); 944 } 945 else { 946 header.removeClass( 'fl-shrink-header' ); 947 } 948 }, 100 ); 949 }); 950 }, 951 952 /** 953 * Enable or disable header shrinking. 954 * 955 * @since 1.5 956 * @access private 957 * @method _shrinkHeaderEnable 958 */ 959 _shrinkHeaderEnable: function() 960 { 961 var win = $( window ); 962 963 if ( win.width() >= window.themeopts.medium_breakpoint ) { 964 965 var header = $('.fl-page-header'), 966 headerHeight = header.outerHeight(), 967 topbar = $('.fl-page-bar'), 968 topbarHeight = 0, 969 totalHeaderHeight = 0; 970 971 if( topbar.length != 0 ) { 972 topbarHeight += topbar.outerHeight(); 973 totalHeaderHeight = topbarHeight + headerHeight; 974 975 if ( $( 'body.admin-bar' ).length != 0 ) { 976 topbarHeight += 32; 977 }
978 header.css( 'top' , topbarHeight ); 979 } 980 else { 981 totalHeaderHeight = headerHeight; 982 } 983 984 // Fix: Themer parts layout inserted before header. 985 if ( header.prevAll( '.fl-builder-content' ).length > 0 ) { 986 FLTheme._initThemerLayoutFix(); 987 988 totalHeaderHeight = topbar.outerHeight(); 989 } 990 991 if ( $('.fl-header-padding-top-custom').length === 0 ) { 992 $( '.fl-page' ).css( 'padding-top', totalHeaderHeight ); 993 } 994 995 $( win ).on( 'scroll.fl-shrink-header', FLTheme._shrinkHeader ); 996 } 997 else { 998 $('.fl-page-header').css('top', 0); 999 $( '.fl-page' ).css( 'padding-top', 0 ); 1000 $( win ).off( 'scroll.fl-shrink-header' ); 1001 } 1002 }, 1003 1004 /** 1005 * Shrink the header. 1006 * 1007 * @since 1.5.1 1008 * @access private 1009 * @method _shrinkHeader 1010 */ 1011 _shrinkHeader: function() 1012 { 1013 var distanceY = $( this ).scrollTop(), 1014 shrinkOn = 250, 1015 header = $( '.fl-page-header' ), 1016 logo = null; 1017 1018 $('.fl-page-header-logo').imagesLoaded(function(){ 1019 logo = $( '.fl-logo-img' ); 1020 1021 var logoForHeight = $( '.fl-page-header-logo:visible .fl-logo-img' ).first(); 1022 1023 if ( ! logoForHeight.length ) { 1024 logoForHeight = logo.first(); 1025 } 1026 1027 var origHeight = logoForHeight.length ? logoForHeight.height() : ( logo.first().data('origHeight') || 46 ); 1028 1029 if ( 'undefined' === typeof logo.data('origHeight') ) { 1030 logo.data( 'origHeight', origHeight ); 1031 1032 if ( logoForHeight.length && ! logoForHeight.is( logo.first() ) ) { 1033 logoForHeight.data( 'origHeight', origHeight ); 1034 } 1035 } 1036 1037 if ( distanceY > shrinkOn ) { 1038 header.addClass( 'fl-shrink-header' ); 1039 } 1040 else { 1041 header.removeClass( 'fl-shrink-header' ); 1042 } 1043 1044 if ( 'undefined' !== typeof header.data( 'original-top' ) ) { 1045 FLTheme._fixThemerLayoutOnScroll(); 1046 } 1047 }); 1048 }, 1049 1050 /** 1051 * Fixed Header (Fixed) 1052 * 1053 * @since 1.5 1054 * @access private 1055 * @method _fixedHeader 1056 */ 1057 _fixedHeader: function() 1058 { 1059 var win = $(window), 1060 header = $('.fl-page-header'), 1061 headerHeight = 0, 1062 totalHeaderHeight = 0, 1063 bar = $('.fl-page-bar'), 1064 barHeight = 0; 1065 1066 if(win.width() >= window.themeopts.medium_breakpoint) { 1067 1068 headerHeight = header.outerHeight(); 1069 1070 if( bar.length != 0 ) { 1071 1072 barHeight = bar.outerHeight(); 1073 totalHeaderHeight = barHeight + headerHeight; 1074 1075 if($('body.admin-bar').length != 0) { 1076 barHeight += 32; 1077 } 1078 1079 if($('html.fl-builder-edit').length != 0) { 1080 var topbarHeight = topbarHeight+11; 1081 } 1082 1083 header.css('top', barHeight); 1084 } 1085 else { 1086 totalHeaderHeight = headerHeight; 1087 } 1088 1089 // Fix: Themer parts layout. 1090 if ( header.prevAll( '.fl-builder-content' ).length > 0 ) { 1091 FLTheme._initThemerLayoutFix(); 1092 totalHeaderHeight = bar.outerHeight(); 1093 1094 $( win ).on( 'scroll.fl-fixed-header', FLTheme._fixThemerLayoutOnScroll ); 1095 } 1096 1097 if($('body.fl-scroll-header').length === 0 && $('.fl-header-padding-top-custom').length === 0 ) { 1098 $('.fl-page').css('padding-top', totalHeaderHeight); 1099 } 1100 1101 $( win ).trigger( 'scroll' ); 1102 } 1103 else { 1104 $('.fl-page-header').css('top', 0); 1105 $('.fl-page').css('padding-top', 0); 1106 $( win ).off( 'scroll.fl-fixed-header' ); 1107 } 1108 }, 1109 1110 /** 1111 * Fixed Header (Fade In) 1112 * 1113 * Enables the fixed header if the window is wide enough. 1114 * 1115 * @since 1.0 1116 * @access private 1117 * @method _enableFixedHeader 1118 */ 1119 _enableFixedHeader: function() 1120 { 1121 var win = $(window); 1122 1123 if(win.width() < window.themeopts.medium_breakpoint) { 1124 win.off('scroll.fl-page-header-fixed'); 1125 $('.fl-page-header-fixed').hide(); 1126 } 1127 else { 1128 win.on('scroll.fl-page-header-fixed', FLTheme._toggleFixedHeader); 1129 } 1130 }, 1131 1132 /** 1133 * Fix the Themer parts layout that are hooks into `fl_page_open`. 1134 * 1135 * @since 1.7 1136 * @access private 1137 * @method _fixThemerLayout 1138 */ 1139 _initThemerLayoutFix: function() { 1140 var header = $('.fl-page-header'), 1141 themerLayouts = header.prevAll( '.fl-builder-content' ), 1142 themerlayoutHeight = 0; 1143 1144 if ( ! themerLayouts.length ) { 1145 return; 1146 } 1147 1148 header.css('position', 'initial'); 1149 1150 $.each( themerLayouts, function() { 1151 themerlayoutHeight += $( this ).outerHeight(); 1152 }); 1153 1154 header.data( 'original-top', themerlayoutHeight ); 1155 }, 1156 1157 /** 1158 * Fix the Themer parts layout on scroll. 1159 * 1160 * @since 1.7 1161 * @access private 1162 * @method _fixThemerLayout 1163 */ 1164 _fixThemerLayoutOnScroll: function() { 1165 var distanceY = $( window ).scrollTop(), 1166 header = $( '.fl-page-header' ), 1167 headerTop = header.data( 'original-top' ); 1168 1169 if ( 'undefined' === typeof headerTop ) { 1170 return; 1171 } 1172 1173 if ( distanceY >= headerTop ) { 1174 header.css( 'position', 'fixed' ); 1175 } 1176 else { 1177 header.css( 'position', 'initial' ); 1178 } 1179 1180 // Fix animations. 1181 if ( 'undefined' != typeof Waypoint ) { 1182 Waypoint.refreshAll(); 1183 } 1184 }, 1185 1186 /** 1187 * Shows or hides the fixed header based on the 1188 * window's scroll position. 1189 * 1190 * @since 1.0 1191 * @access private 1192 * @method _toggleFixedHeader 1193 */ 1194 _toggleFixedHeader: function() 1195 { 1196 var win = $(window), 1197 fixed = $('.fl-page-header-fixed'), 1198 fixedVisible = fixed.is(':visible'), 1199 header = $('.fl-page-header-primary'), 1200 headerHidden = false;
1201 1202 if ( 0 === header.length ) { 1203 headerHidden = win.scrollTop() > 200; 1204 } 1205 else { 1206 headerHidden = win.scrollTop() > header.height() + header.offset().top; 1207 } 1208 1209 if(headerHidden && !fixedVisible) { 1210 fixed.stop().fadeIn(200); 1211 } 1212 else if(!headerHidden && fixedVisible) { 1213 fixed.stop().hide(); 1214 } 1215 }, 1216 1217 /** 1218 * Adds logo as nav item for "centered inline logo" header layout. 1219 * 1220 * @since 1.5 1221 * @access private 1222 * @method _centeredInlineLogo 1223 */ 1224 _centeredInlineLogo: function() 1225 { 1226 var win = $(window), 1227 $logo = $( '.fl-page-nav-centered-inline-logo .fl-page-header-logo' ).eq( 0 ), 1228 $inline_logo = $( '.fl-logo-centered-inline .fl-page-header-logo' ), 1229 $nav = $( '.fl-page-nav-centered-inline-logo .fl-page-nav .navbar-nav' ), 1230 nav_li_length = $nav.children('li').length, 1231 logo_li_location = Math.round( nav_li_length / 2 ) - 1, 1232 $header_row = $( '.fl-page-nav-centered-inline-logo .fl-page-header-row' ); 1233 1234 if(win.width() >= window.themeopts.medium_breakpoint && $inline_logo.length < 1 && !$('.fl-page-header-primary').hasClass('fl-page-nav-toggle-visible-always')) { 1235 1236 if( $logo.hasClass( 'fl-inline-logo-left' ) && nav_li_length % 2 != 0 ) { 1237 $nav.children( 'li:nth( '+logo_li_location+' )' ).before( '<li class="fl-logo-centered-inline"></li>' ); 1238 } else { 1239 $nav.children( 'li:nth( '+logo_li_location+' )' ).after( '<li class="fl-logo-centered-inline"></li>' ); 1240 } 1241 1242 $nav.children( '.fl-logo-centered-inline' ).append( $logo ); 1243 } 1244 1245 if(win.width() < window.themeopts.medium_breakpoint) { 1246 $( '.fl-logo-centered-inline' ).remove(); 1247 1248 if ( $header_row.children( '.fl-page-header-logo').length < 1 ) { 1249 $header_row.prepend( $inline_logo ); 1250 } 1251 } 1252 }, 1253 1254 /** 1255 * Hide Header Until Scroll 1256 * 1257 * @since 1.5 1258 * @access private 1259 * @method _scrollHeader 1260 */ 1261 _scrollHeader: function() 1262 { 1263 var win = $(window), 1264 header = null, 1265 distance = $('.fl-page-header-primary').data('fl-distance'), 1266 headerHeight = 0; 1267 1268 if($('.fl-page-bar').length != 0 ) { 1269 header = $('.fl-page-header-primary, .fl-page-bar'); 1270 } 1271 else { 1272 header = $('.fl-page-header-primary'); 1273 } 1274 1275 if(win.width() >= window.themeopts.medium_breakpoint) { 1276 win.on('scroll.fl-show-header-on-scroll', function () { 1277 if ($(this).scrollTop() > distance) { 1278 header.addClass('fl-show'); 1279 } 1280 else { 1281 header.removeClass('fl-show'); 1282 1283 // Offcanvas nav layout fix. 1284 if ( $('.fl-responsive-nav-enabled').length ) { 1285 headerHeight = $('.fl-page-header-primary').height() * 2; 1286 1287 if ( $('.fl-page-bar').length != 0 ) { 1288 headerHeight += $('.fl-page-bar').height(); 1289 } 1290 1291 if ( 'undefined' !== typeof $( '.fl-nav-offcanvas-collapse' ).css('top') ) { 1292 headerHeight += parseInt( $( '.fl-nav-offcanvas-collapse' ).css('top') ); 1293 } 1294 } 1295 1296 if ( $( '.fl-nav-offcanvas-active' ).length && headerHeight > 0 ) { 1297 $( '.fl-nav-offcanvas-collapse' ).css({ 1298 'transform' : 'translateY(' + headerHeight + 'px)', 1299 '-ms-transform' : 'translateY(' + headerHeight + 'px)', 1300 '-webkit-transform' : 'translateY(' + headerHeight + 'px)' 1301 }); 1302 } 1303 } 1304 }); 1305 } 1306 else { 1307 win.off('scroll.fl-show-header-on-scroll'); 1308 $( '.fl-nav-offcanvas-collapse' ).css('transform', ''); 1309 } 1310 }, 1311 1312 /** 1313 * Mega Menu 1314 * 1315 * @see _isResponsiveNavEnabled 1316 * @since 1.5 1317 * @access private 1318 * @method _megaMenu 1319 */ 1320 _megaMenu: function() 1321 { 1322 var win = $(window), 1323 pageHeaderMenu = $('.fl-page-header'), 1324 menuContainer = pageHeaderMenu.find('.fl-page-header-container'), 1325 menuWidthLimit = menuContainer.outerWidth(), 1326 megaItem = null, 1327 megaItems = null, 1328 megaContentWidth = 0; 1329 1330 pageHeaderMenu.find( 'li.mega-menu, li.mega-menu-disabled' ).each(function(){ 1331 megaItem = $(this); 1332 megaContentWidth = megaItem.find('> ul.sub-menu').outerWidth(); 1333 1334 if ( typeof megaItem.data('megamenu-width') !== 'undefined' ) { 1335 megaContentWidth = megaItem.data('megamenu-width'); 1336 } 1337 1338 if( ( megaItem.hasClass('mega-menu') && menuWidthLimit < megaContentWidth ) || FLTheme._isResponsiveNavEnabled() ) { 1339 megaItem.data('megamenu-width', megaContentWidth); 1340 1341 // Fixed width issue on window resize 1342 if ( FLTheme._isResponsiveNavEnabled() ) { 1343 megaItem.find('> ul.sub-menu').css('display', 'block'); 1344 } 1345 1346 megaItem.removeClass('mega-menu'); 1347 if (!megaItem.hasClass('mega-menu-disabled')) { 1348 megaItem.addClass('mega-menu-disabled'); 1349 } 1350 } 1351 else if ( megaItem.hasClass('mega-menu-disabled') && menuWidthLimit >= megaContentWidth ) { 1352 // Reset sub-menu display style 1353 megaItem.find('> ul.sub-menu').css('display', ''); 1354 1355 megaItem.removeClass('mega-menu-disabled'); 1356 if (!megaItem.hasClass('mega-menu')) { 1357 megaItem.addClass('mega-menu'); 1358 } 1359 megaItem.addClass( 'mega-menu-items-' + megaItem.children( 'ul' ).children( 'li' ).length ); 1360 } 1361 }); 1362 1363 1364 }, 1365 1366 /** 1367 * Mega Menu - Fixed Header 1368 * 1369 * @since 1.5 1370 * @access private 1371 * @method _megaMenuOnScroll 1372 */ 1373 _megaMenuOnScroll: function() 1374 { 1375 var win = $(window), 1376 pageHeaderFixed = $('.fl-page-header-fixed'), 1377 menuContainer = pageHeaderFixed.find('.fl-page-header-container'), 1378 fixedVisible = pageHeaderFixed.is(':visible'), 1379 megaItem = null, 1380 megaMenuContent = null; 1381 1382 if ( fixedVisible ) { 1383 pageHeaderFixed.find( 'li.mega-menu' ).each(function(){ 1384 megaItem = $(this); 1385 megaMenuContent = megaItem.find('> ul.sub-menu'); 1386 1387 // Disable mega menu if it's off screen 1388 if(menuContainer.outerWidth() < megaMenuContent.outerWidth()) { 1389 megaItem.removeClass('mega-menu'); 1390 if (!megaItem.hasClass('mega-menu-disabled')) { 1391 megaItem.addClass('mega-menu-disabled'); 1392 } 1393 } 1394 else { 1395 megaItem.removeClass('mega-menu-disabled'); 1396 if (!megaItem.hasClass('mega-menu')) { 1397 megaItem.addClass('mega-menu'); 1398 } 1399 1400 megaItem.addClass( 'mega-menu-items-' + megaItem.children( 'ul' ).children( 'li' ).length ); 1401 } 1402 }); 1403 1404 win.off('scroll.fl-mega-menu-on-scroll'); 1405 win.off('resize.fl-mega-menu-on-scroll'); 1406 } 1407 }, 1408 1409 /** 1410 * Fixed headers not be fixed when the builder is active 1411 * 1412 * @since 1.5.2 1413 * @access private 1414 * @method _fixedHeadersWhenBuilderActive 1415 */ 1416 _fixedHeadersWhenBuilderActive: function() 1417 { 1418 if($('body.fl-shrink').length != 0) { 1419 $('body').removeClass('fl-shrink'); 1420 } 1421 1422 if($('body.fl-fixed-header').length != 0) { 1423 $('body').removeClass('fl-fixed-header'); 1424 } 1425 1426 if($('body.fl-scroll-header').length != 0) { 1427 $('body').removeClass('fl-scroll-header'); 1428 } 1429 }, 1430 1431 /** 1432 * Responsive Nav Layout 1433 * 1434 * @since 1.7 1435 * @access private 1436 * @method _setupMobileNavLayout 1437 */ 1438 _setupMobileNavLayout: function() 1439 { 1440 var win = $( window ), 1441 button = $( 'button.navbar-toggle' ), 1442 header = $( '.fl-page-header:not(.fl-page-header-fixed)' ), 1443 navBar = header.find( '.fl-page-nav-collapse' ), 1444 pageWrap = $( '.fl-page' ), 1445 navBarTop = 0, 1446 navHeight = win.height(), 1447 pushOpacity = $( 'body').hasClass( 'fl-offcanvas-push-opacity-left' ) || $( 'body').hasClass( 'fl-offcanvas-push-opacity-right' ), 1448 logoPos = header.find( '.fl-page-header-logo' ).offset(); 1449 1450 if ( FLTheme._isResponsiveNavEnabled() && button.is( ':visible' ) ) { 1451 $( 'body' ).addClass( 'fl-responsive-nav-enabled' ); 1452 1453 button.attr( 'data-toggle', 'offcanvas'); 1454 navBar.addClass( 'fl-nav-offcanvas-collapse'); 1455 1456 if ( 0 === navBar.find( '.fl-button-close' ).length ) { 1457 navBar.prepend( '<div class="fl-button-close"><button class="fl-offcanvas-close" aria-label="Close Menu"><i class="fas fa-times"></i></button></div>' ); 1458 } 1459 1460 if ( pushOpacity && 0 === $( '.fl-offcanvas-opacity' ).length ) { 1461 pageWrap.append( '<div class="fl-offcanvas-opacity"></div>' ); 1462 } 1463 1464 if ( pageWrap.height() > win.height() ) { 1465 navHeight = $( document ).height(); 1466 1467 if ( $( 'body.fl-shrink' ).length != 0 ) { 1468 navHeight = navHeight - header.height(); 1469 } 1470 } 1471 1472 if ( $( 'body.admin-bar' ).length != 0 ) { 1473 navBarTop = $( '#wpadminbar' ).height(); 1474 navHeight = navHeight - navBarTop; 1475 } 1476 1477 if ( $( '.fl-page-bar' ).length != 0 && ! $( '.fl-page-header' ).hasClass( 'fl-page-nav-toggle-button' ) ) {
1478 navBarTop = navBarTop + ($( '.fl-page-bar' ).height() + 1); 1479 } 1480 1481 if ( $('.fl-scroll-header').length && win.width() >= window.themeopts.medium_breakpoint ) { 1482 navBar.css('top', pageWrap.offset().top - navBarTop + 'px' ); 1483 } 1484 else { 1485 navBar.css('top', ''); 1486 } 1487 1488 } 1489 else { 1490 button.attr( 'data-toggle', 'collapse'); 1491 navBar.removeClass( 'fl-nav-offcanvas-collapse'); 1492 navBar.find( '.fl-button-close' ).remove(); 1493 navBar.css( 'height', '' ); 1494 navBar.css( 'top', '' ); 1495 pageWrap.removeClass( 'fl-nav-offcanvas-active' ); 1496 $( 'body' ).find( '.fl-offcanvas-opacity' ).remove(); 1497 $( 'body' ).removeClass( 'fl-responsive-nav-enabled' ); 1498 } 1499 }, 1500 1501 /** 1502 * Toggle the Responsive Nav Layout 1503 * 1504 * @since 1.7 1505 * @access private 1506 * @method _toggleMobileNavLayout 1507 */ 1508 _toggleMobileNavLayout: function() 1509 { 1510 1511 $( '.fl-page-nav' ).on( 'click', '.fl-offcanvas-close', function(e){ 1512 $( '.fl-page' ).toggleClass( 'fl-nav-offcanvas-active' ); 1513 e.stopPropagation(); 1514 }); 1515 1516 }, 1517 1518 /** 1519 * Apply footer height as margin-bottom value for fl-page class 1520 * 1521 * @since 1.5 1522 * @access private 1523 * @method _footerEffect 1524 */ 1525 _footerEffect: function() 1526 { 1527 if ( $( window ).width() >= window.themeopts.mobile_breakpoint ) { 1528 $( '.fl-page' ).css( 'margin-bottom', $( '.fl-page-footer-wrap' ).height() ); 1529 } 1530 else { 1531 $( '.fl-page' ).css( 'margin-bottom', 0 ); 1532 } 1533 }, 1534 1535 /** 1536 * Go to Top 1537 * 1538 * @since 1.5 1539 * @access private 1540 * @method _toTop 1541 */ 1542 _toTop: function() 1543 { 1544 var buttons = $('#fl-to-top'); 1545 1546 buttons.each(function(){ 1547 $(this).click(function(){ 1548 $('html,body').animate({ scrollTop: 0 }, 'linear'); 1549 return false; 1550 }); 1551 }); 1552 1553 $(window).scroll(function(){ 1554 if( $(this).scrollTop() > window.themeopts.scrollTopPosition ) { 1555 buttons.fadeIn(); 1556 } else { 1557 buttons.fadeOut(); 1558 } 1559 }); 1560 }, 1561 1562 /** 1563 * Initializes the lightbox. 1564 * 1565 * @since 1.0 1566 * @access private 1567 * @method _enableLightbox 1568 */ 1569 _enableLightbox: function() 1570 { 1571 var body = $('body'); 1572 1573 if ( 'disabled' === window.themeopts.lightbox ) { 1574 return; 1575 } 1576 1577 // Only works on NON bb pages/posts 1578 if( !body.hasClass('fl-builder') && !body.hasClass('woocommerce')) { 1579 1580 $('.fl-content a').filter(function() { 1581 return /\.(png|jpg|jpeg|gif|webp)(\?.*)?$/i.test(this.href); 1582 }).magnificPopup({ 1583 closeBtnInside: false, 1584 type: 'image', 1585 gallery: { 1586 enabled: true 1587 } 1588 }); 1589 } 1590 1591 if( ( body.hasClass('fl-builder') || body.hasClass( 'fl-theme-builder-singular' ) ) && !body.hasClass('woocommerce') ) { 1592 $('.fl-rich-text a, .fl-module-fl-post-content a').filter(function() { 1593 return /\.(png|jpg|jpeg|gif|webp)(\?.*)?$/i.test(this.href); 1594 }).magnificPopup({ 1595 closeBtnInside: false, 1596 type: 'image', 1597 gallery: { 1598 enabled: true 1599 } 1600 }); 1601 } 1602 }, 1603 1604 /** 1605 * Initializes the fitVids 1606 * 1607 * @since 1.5.2 1608 * @access private 1609 * @method _enableFitVids 1610 */ 1611 _enableFitVids: function() 1612 { 1613 $('.fl-post-content').fitVids(); 1614 }, 1615 1616 /** 1617 * Check to see if responsive nav is enabled for the current window width 1618 * 1619 * @since 1.6.2 1620 * @access private 1621 * @method _isResponsiveNavEnabled 1622 */ 1623 _isResponsiveNavEnabled: function() 1624 { 1625 var win = $(window); 1626 enabled = false; 1627 1628 if ( ( $( '.fl-page-nav-toggle-visible-always' ).length > 0 ) 1629 || ( $( '.fl-page-nav-toggle-visible-medium-mobile' ).length > 0 && win.width() < window.themeopts.medium_breakpoint ) 1630 || ( $( '.fl-page-nav-toggle-visible-mobile' ).length > 0 && win.width() < window.themeopts.mobile_breakpoint ) 1631 ) { 1632 enabled = true; 1633 } 1634 1635 return enabled; 1636 } 1637 }; 1638 1639 $(function(){ 1640 FLTheme.init(); 1641 }); 1642 1643 // Mobile Logo 1644 if ( ! ( $( 'html.fl-builder-edit' ).length !== 0 ) ) { 1645 FLTheme._initMobileHeaderLogo(); 1646 } 1647 FLTheme._initRetinaImages(); 1648 1649})(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.