var SWIFT=SWIFT||{}; (function(){ "use strict"; SWIFT.page={ init: function (){ SWIFT.page.browserCheck(); if(body.hasClass('header-below-slider')&&jQuery('.home-slider-wrap').length > 0){ SWIFT.page.headerSlider(); } if(jQuery('#one-page-nav').length > 0){ SWIFT.page.onePageNav(); } if(jQuery('#sidebar-progress-menu').length > 0){ SWIFT.page.sidebarProgressMenu(); } if(jQuery('#back-to-top').length > 0){ $window.scroll(function(){ SWIFT.page.backToTop(); }); } if(body.hasClass('hero-content-split')){ SWIFT.page.heroContentSplit(); } if(jQuery('#sf-newsletter-bar').length > 0){ SWIFT.page.newsletterSubBar(); } if(jQuery('#wpadminbar').length > 0){ body.addClass('has-wpadminbar'); } if(jQuery('.recent-posts').length > 0){ SWIFT.recentPosts.init(); } if(jQuery('.sf-share-counts').length > 0){ SWIFT.page.shareCounts(); } SWIFT.page.wooFormFix(); if(jQuery('.track_order').length > 0){ SWIFT.page.trackOrderFormFix(); } SWIFT.page.moveModals(); jQuery('a[data-toggle="modal"]').on('click', function(){ setTimeout(function(){ SWIFT.map.init(); }, 300); return true; }); SWIFT.page.modalClose(); if(body.hasClass('single-post')){ var replyTitle=jQuery('#respond').find('h3'); var originalText=jQuery('#respond').find('h3').html(); replyTitle.addClass('spb-heading'); replyTitle.html(''+originalText+''); } SWIFT.page.smoothScrollLinks(); SWIFT.page.expandingAssets(); jQuery('.activity-time-since,.bp-secondary-action').on('click', function(e){ e.preventDefault(); jQuery('.viewer').css('display', 'none'); window.location=jQuery(this).attr('href'); }); jQuery('.love-it').on('click', function(){ SWIFT.page.loveIt(jQuery(this)); return false; }); if(jQuery('article').hasClass('single-post-fw-media-title')){ SWIFT.page.postMediaTitle(); } if(jQuery('article').hasClass('single-portfolio-poster')){ SWIFT.page.portMediaTitle(); } if(jQuery('.related-items').length > 0){ SWIFT.relatedPosts.init(); } SWIFT.page.lightbox(); if(isMobileAlt&&body.hasClass('mobile-two-click')){ SWIFT.page.mobileThumbLinkClick(); } if(body.hasClass('page-transitions')){ SWIFT.page.pageTransitions(); } SWIFT.page.directorySubmit(); SWIFT.page.mediaPlayer(); }, homePreloader: function(){ body.addClass('sf-preloader-done'); setTimeout(function(){ jQuery('#sf-home-preloader').fadeOut(300); }, 300); }, load: function(){ SWIFT.page.offsetCalc(); $window.smartresize(function(){ SWIFT.page.offsetCalc(); }); if(jQuery('.fancy-heading').length > 0){ SWIFT.page.fancyHeading(); } if(jQuery('.recent-posts').length > 0){ SWIFT.recentPosts.load(); } if(body.hasClass('hero-content-split')){ SWIFT.page.heroContentSplitResize(); } var windowWidth=$window.width(); setTimeout(function(){ if(( windowWidth >=1024&&body.hasClass('mhs-tablet-land')) || (windowWidth >=991&&body.hasClass('mhs-tablet-port')) || (windowWidth >=767&&body.hasClass('mhs-mobile'))){ var urlHash=document.location.toString(); if(urlHash.match('#')){ var hash=urlHash.split('#')[1]; if(jQuery('#' + hash).length > 0){ SWIFT.page.onePageNavGoTo('#' + hash); }} }}, 1000); }, browserCheck: function(){ jQuery.browser={}; jQuery.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()); jQuery.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()); jQuery.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()); jQuery.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()); jQuery.browser.msieMobile10=/iemobile\/10\.0/.test(navigator.userAgent.toLowerCase()); if(isMobileAlt){ body.addClass("mobile-browser"); }else{ body.addClass("standard-browser"); } if(isIEMobile){ body.addClass("ie-mobile"); } if(isAppleDevice){ body.addClass("apple-mobile-browser"); } if(body.hasClass("woocommerce-page")&&!body.hasClass("woocommerce")){ body.addClass("woocommerce"); } if(IEVersion&&IEVersion < 9){ body.addClass('browser-ie'); } var pattern=/MSIE\s([\d]+)/, ua=navigator.userAgent, matched=ua.match(pattern); if(matched){ body.addClass('browser-ie10'); } if(jQuery.browser.mozilla){ body.addClass('browser-ff'); } if(navigator.userAgent.search("Safari") >=0&&navigator.userAgent.search("Chrome") < 0){ body.addClass('browser-safari'); }}, offsetCalc: function(){ var adjustment=0; if(jQuery('#wpadminbar').length > 0){ adjustment=jQuery('#wpadminbar').height(); SWIFT.wpadminbarheight=jQuery('#wpadminbar').height(); } if(body.hasClass('sticky-header-enabled')&&!body.hasClass('sticky-header-transparent')&&jQuery('.sticky-header').is(':visible')){ adjustment +=jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height():jQuery('#header-section').height(); }else if(body.hasClass('mh-sticky')&&jQuery('#mobile-header').is(':visible')){ adjustment +=jQuery('#mobile-header').outerHeight(); } if(jQuery('.sticky-top-bar').length > 0){ adjustment +=jQuery('.sticky-top-bar').height() > 0 ? jQuery('.sticky-top-bar').height():jQuery('#top-bar').height(); } SWIFT.offset=adjustment; }, resizeHeadings: function(){ var h1FontSize=jQuery('h1:not(.logo-h1)').css('font-size'), h2FontSize=jQuery('h2:not(.caption-title)').css('font-size'); SWIFT.page.resizeHeadingsResize(h1FontSize, h2FontSize); $window.smartresize(function(){ SWIFT.page.resizeHeadingsResize(h1FontSize, h2FontSize); }); }, resizeHeadingsResize: function(h1FontSize, h2FontSize){ if($window.width() <=768){ if(h1FontSize){ h1FontSize=h1FontSize.replace("px", ""); var h1FontSizeMin=Math.floor(h1FontSize * 0.6); jQuery('h1:not(.logo-h1)').fitText(1, { minFontSize: h1FontSizeMin + 'px', maxFontSize: h1FontSize +'px' }).css('line-height', '120%'); } if(h2FontSize){ h2FontSize=h2FontSize.replace("px", ""); var h2FontSizeMin=Math.floor(h2FontSize * 0.6); jQuery('h2:not(.caption-title)').fitText(1, { minFontSize: h2FontSizeMin + 'px', maxFontSize: h2FontSize +'px' }).css('line-height', '120%'); }}else{ jQuery('h1:not(.logo-h1)').css('font-size', '').css('line-height', ''); jQuery('h2:not(.caption-title)').css('font-size', '').css('line-height', ''); }}, loveIt: function($this){ var locale=jQuery('#loveit-locale'), post_id=$this.data('post-id'), user_id=$this.data('user-id'), action='love_it'; if($this.hasClass('loved')){ action='unlove_it'; } if(locale.data('loggedin')=='false'&&Cookies.get('loved-' + post_id)){ action='unlove_it'; } var data={ action: action, item_id: post_id, user_id: user_id, love_it_nonce: locale.data('nonce') }; jQuery.post(locale.data('ajaxurl'), data, function(response){ var ajaxResponse=jQuery.trim(response), count_wrap, count; if(ajaxResponse=='loved'){ $this.addClass('loved'); count_wrap=$this.find('data.count'); count=count_wrap.text(); count_wrap.text(parseInt(count) + 1); if(locale.data('loggedin')=='false'){ Cookies.set('loved-' + post_id, 'yes', { expires: 1, path: '' }); }}else if(ajaxResponse=='unloved'){ $this.removeClass('loved'); count_wrap=$this.find('data.count'); count=count_wrap.text(); count_wrap.text(parseInt(count) - 1); if(locale.data('loggedin')=='false'){ Cookies.set('loved-' + post_id, 'no', { expires: 1, path: '' }); }}else{ alert(locale.data('error')); }}); }, stickyWidget: function(reset){ var stickyWidget=jQuery('.sticky-widget'), sidebar=stickyWidget.parent(), offset=24 + SWIFT.offset; SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset); if(reset){ SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); } $window.smartresize(function(){ jQuery('.inner-page-wrap').stickem().destroy(); SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset); }); if(sidebar.find('.mega-menu-accordion').length > 0){ jQuery('.sidebar .mega-menu-accordion .mega-menu-item-has-children').on('click', function(){ setTimeout(function(){ jQuery('.sidebar').each(function(){ if(!jQuery('.sticky-widget').hasClass('stickit')){ jQuery('.inner-page-wrap').stickem().destroy(); SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset); $window.scrollTop($window.scrollTop()+1); $window.scrollTop($window.scrollTop()-1); }}); }, 200); }); }}, initStickyWidget: function(stickyWidget, sidebar, offset){ var parent=".page-content"; if(body.hasClass('page')||body.hasClass('archive')||body.hasClass('home')||body.hasClass('search-results')||body.hasClass('error404')){ parent=".inner-page-wrap"; } jQuery('.inner-page-wrap').stickem({ item: '.sticky-widget', container: parent, offset: offset + 24, onStick: function(){ SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); }}); if(stickyWidget.find('.mega-menu-accordion').length > 0){ stickyWidget.find('.mega-menu-accordion').on('click', 'a.mega-menu-link', function(e){ setTimeout(function(){ SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); }, 500); }); }}, resizeStickyWidget: function(stickyWidget, sidebar){ var headerHeight=SWIFT.offset, content=jQuery('.content-wrap'), sidebarHeight=sidebar.find('.sidebar-widget-wrap').height(); if(body.hasClass('page')||body.hasClass('search-results')||body.hasClass('error404')){ content=jQuery('.page-content'); } stickyWidget.css('width', sidebar.width()).css('top', headerHeight + 30); sidebar.css('height', ''); var contentHeight=content.height(); if(contentHeight > sidebarHeight){ sidebar.css('height', contentHeight); }else{ sidebar.css('height', sidebarHeight); }}, expandingAssets: function(){ jQuery('.spb-row-expand-text').on('click', '', function(e){ e.preventDefault(); var expand=jQuery(this), expandRow=expand.next(); if(expandRow.hasClass('spb-row-expanding-open')&&!expandRow.hasClass('spb-row-expanding-active')){ expandRow.addClass('spb-row-expanding-open').addClass('spb-row-expanding-active').slideUp(800); setTimeout(function(){ expand.removeClass('row-open').find('span').text(expand.data('closed-text')); expandRow.css('display', 'block').removeClass('spb-row-expanding-open').removeClass('spb-row-expanding-active'); }, 800); }else if(!expandRow.hasClass('spb-row-expanding-active')){ expand.addClass('row-open').find('span').text(expand.data('open-text')); expandRow.css('display', 'none').addClass('spb-row-expanding-open').addClass('spb-row-expanding-active').slideDown(800); setTimeout(function(){ expandRow.removeClass('spb-row-expanding-active'); }, 800); }}); }, headerSlider: function(){ jQuery('#site-loading').css('display', 'block'); jQuery('.home-slider-wrap').css('position', 'fixed'); jQuery('#main-container').css('position', 'relative'); jQuery('#container').css('top', jQuery('.home-slider-wrap').height()); setTimeout(function(){ jQuery('#site-loading').fadeOut(1000); }, 250); $window.smartresize(function(){ jQuery('#container').css('top', jQuery('.home-slider-wrap').height()); }); jQuery('a#slider-continue').on('click', function(e){ e.preventDefault(); jQuery('html, body').stop().animate({ scrollTop: jQuery('#container').css('top') }, 1500, 'easeInOutExpo'); }); }, fancyHeading: function(){ var fancyHeading=jQuery('.fancy-heading'), fancyHeadingText=fancyHeading.find('.heading-text'), fancyHeadingTextHeight=fancyHeadingText.height(), fancyHeadingHeight=parseInt(fancyHeading.data('height'), 10), header=jQuery('.header-wrap'), headerHeight=0, spacerHeight=0; if(body.hasClass('header-naked-light')||body.hasClass('header-naked-dark')){ headerHeight=header.height(); } if(!fancyHeadingHeight){ fancyHeadingHeight=400; } if(fancyHeadingTextHeight > fancyHeadingHeight){ fancyHeadingHeight=fancyHeadingTextHeight + 120; } fancyHeadingHeight=fancyHeadingHeight + headerHeight; fancyHeadingText.vCenterTop(); if(fancyHeading.hasClass('page-heading-breadcrumbs')){ fancyHeading.find('#breadcrumbs').vCenter(); } var fancyHeadingAnimDelay=400; if(jQuery('#wpadminbar').length > 0){ spacerHeight=fancyHeadingHeight - jQuery('#wpadminbar').height(); } if(!fancyHeading.hasClass('fixed-height')){ fancyHeading.css('height', fancyHeadingHeight); } if(body.hasClass('app-header')&&jQuery('.page-heading-wrap-hidden').length===0){ jQuery('#header').transition({ opacity: 1 }, 600, 'easeOutCirc'); jQuery('.inner-container-wrap').transition({ marginTop: spacerHeight }, 800, 'easeOutCirc'); SWIFT.page.fancyHeadingResize(); $window.smartresize(function(){ SWIFT.page.fancyHeadingResize(); }); } setTimeout(function(){ fancyHeadingText.css('opacity', 1); }, fancyHeadingAnimDelay + 600); setTimeout(function(){ fancyHeading.addClass('animated'); }, fancyHeadingAnimDelay + 1000); if(parallaxScroll&&!isMobileAlt&&!body.hasClass('hero-content-split')){ $window.scroll(function(){ var scrollTop=$window.scrollTop(), realScrollTop=scrollTop, headingOffset=SWIFT.offset, opacityScale=400; if(!body.hasClass('app-header')){ scrollTop=scrollTop - headingOffset; } if(scrollTop < jQuery(document).height() - $window.height()){ if(scrollTop < 0){ scrollTop=0; } var blur=scrollTop / headingOffset * 4; fancyHeadingText.stop(true,true).css({ opacity: 1 - realScrollTop / opacityScale, '-webkit-filter': 'blur(' + (blur) + 'px)', '-moz-filter': 'blur(' + (blur) + 'px)', '-ms-filter': 'blur(' + (blur) + 'px)', '-o-filter': 'blur(' + (blur) + 'px)', 'filter': 'blur(' + (blur) + 'px)' }, 0); }}); }}, fancyHeadingResize: function(){ var fancyHeading=jQuery('.fancy-heading'), fancyHeadingHeight=parseInt(fancyHeading.data('height'), 10), fhHeight=parseInt(fancyHeading.data('img-height'), 10), fhWidth=parseInt(fancyHeading.data('img-width'), 10), innerContainer=jQuery('.inner-container-wrap'); if(fhWidth===0||fhHeight===0||$window.width() <=1024){ return; } var fhRatio=fhHeight / fhWidth; var currentHeight=fancyHeading.width() * fhRatio; if(currentHeight < fancyHeadingHeight){ fancyHeading.css('height', currentHeight); innerContainer.css('margin-top', currentHeight - SWIFT.wpadminbarheight); }else{ fancyHeading.css('height', fancyHeadingHeight); innerContainer.css('margin-top', fancyHeadingHeight - SWIFT.wpadminbarheight); }}, moveModals: function(){ jQuery(".modal").each(function(){ jQuery(this).appendTo("body"); }); }, modalClose: function(){ jQuery(".modal-backdrop, .modal .close, .modal .btn").on("click", function(){ jQuery(".modal iframe").each(function(){ var thisModal=jQuery(this); thisModal.attr("src", thisModal.attr("src")); }); }); }, smoothScrollLinks: function(){ jQuery('a.smooth-scroll-link').on('click', function(e){ var linkHref=jQuery(this).attr('href'), linkOffset=jQuery(this).data('offset') ? jQuery(this).data('offset'):0; if(linkHref&&linkHref.indexOf('#')===0){ var headerHeight=SWIFT.offset; SWIFT.isScrolling=true; jQuery('html, body').stop().animate({ scrollTop: jQuery(linkHref).offset().top - headerHeight + linkOffset }, 1000, 'easeInOutExpo', function(){ SWIFT.isScrolling=false; }); e.preventDefault(); }else{ return e; }}); }, onePageNav: function(){ var onePageNav=jQuery('#one-page-nav'), onePageNavType=onePageNav.hasClass('opn-arrows') ? "arrows":"standard", onePageNavItems="", pageSectionCount=0, mainContent=jQuery('.page-content'); mainContent.find('section.row').each(function(){ var linkID=jQuery(this).attr('id'), linkName=jQuery(this).data('rowname'); if(linkID&&linkName.length > 0&&jQuery(this).height() > 0){ onePageNavItems +='
'+pinContent+'
'; } if(pinLink!==""&&pinButtonText!==""){ html +=''; } html +='