????
| Current Path : /home2/morganrand/www/wp-content-bkp/themes/wanderfuls/js/ |
| Current File : /home2/morganrand/www/wp-content-bkp/themes/wanderfuls/js/functions.js |
/**
* Project: Wanderfuls WordPress Theme
* Description: Initialize all scripts and add custom js
* Author: TechBooth
* Theme URI: http://www.techbooth.in
* Author URI: http://www.techbooth.in
* License: Custom
* License URI: http://themeforest.net/licenses
* Version: 3.0.0
*/
(function ($) {
'use strict';
var tbTheme = {
/**
* Main init function
*
* @since 2.0.0
*/
init: function () {
this.config();
this.bindEvents();
},
/**
* Cache Elements
*
* @since 2.0.0
*/
config: function () {
this.config = {
$window: $(window),
$document: $(document),
$windowWidth: $(window).width(),
$windowHeight: $(window).height(),
$windowTop: $(window).scrollTop(),
$body: $('body'),
$mobileMenuBreakpoint: 960,
$siteHeader: null,
$siteHeaderHeight: 0,
$siteHeaderTop: 0,
$siteHeaderBottom: 0,
$siteLogo: null,
$siteLogoHeight: 0,
$siteLogoSrc: null,
$siteNavWrap: null,
$localScrollOffset: 0,
$localScrollSpeed: 600,
$localScrollArray: [],
$mobileMenuStyle: null,
$footerReveal: false,
$hasTopBar: false,
$hasHeaderOverlay: false,
$hasStickyHeader: false,
$stickyHeaderBreakPoint: 960,
$hasStickyMobileHeader: false,
$hasStickyTopBar: false,
$stickyTopBar: null,
$stickyTopBarHeight: 0,
$is_rtl: false,
$retinaLogo: null,
$isMobile: false,
$verticalHeaderActive: false,
};
},
/**
* Bind Events
*
* @since 2.0.0
*/
bindEvents: function () {
var self = this;
// Run on document ready
self.config.$document.on('ready', function () {
self.initUpdateConfig();
self.pageAnimations();
self.superFish();
self.megaMenusWidth();
self.mobileMenu();
self.navNoClick();
self.hideEditLink();
self.customMenuWidgetAccordion();
self.inlineHeaderLogo();
self.menuSearch();
self.headerCart();
self.backTopLink();
self.smoothCommentScroll();
self.tipsyTooltips();
self.customHovers();
self.toggleBar();
self.localScrollLinks();
self.customSelects();
self.skillbar();
self.milestone();
self.owlCarousel();
self.archiveMasonryGrids();
self.iLightbox();
self.wooSelects();
self.footerRevealLoadShow();
self.overlayHovers();
self.isotopeGrids();
});
// Run on Window Load
self.config.$window.on('load', function () {
// Functions
self.windowLoadUpdateConfig();
self.megaMenusTop();
self.flushDropdownsTop();
self.equalHeights();
self.footerRevealMainMargin();
self.overlayHeaderTopWrapPadding();
self.fadeIn();
self.parallax();
self.cartSearchDropdownsRelocate();
self.sliderPro();
// Delay functions if page animations are enabled
if ($.fn.animsition && tbLocalize.pageAnimation && tbLocalize.pageAnimationInDuration) {
setTimeout(function () {
self.stickyTopBar();
self.stickyHeader();
}, tbLocalize.pageAnimationInDuration);
} else {
self.stickyTopBar();
self.stickyHeader();
}
// Shrink header
self.stickyHeaderShrink();
// Scroll to hash
window.setTimeout(function () {
self.scrollToHash(self)
}, 500);
// Scroll to links on hashchange
self.config.$window.on('hashchange', function () {
self.scrollToHash(self);
});
});
// Run on "Smart" Window Resize
self.config.$window.resize(function () {
if (self.config.$window.width() != self.config.$windowWidth) {
self.resizeUpdateConfig();
self.megaMenusWidth();
self.overlayHeaderTopWrapPadding();
self.inlineHeaderLogo();
}
});
// Run on Scroll
self.config.$window.scroll(function () {
self.config.$windowTop = self.config.$window.scrollTop();
self.localScrollHighlight();
self.footerRevealScrollShow();
});
// On orientation change
self.config.$window.on('orientationchange', function () {
self.resizeUpdateConfig();
self.isotopeGrids();
self.archiveMasonryGrids();
self.inlineHeaderLogo();
});
// On Document click
self.config.$document.click(function () {
$('#searchform-dropdown, #searchform-header-replace').removeClass('show');
$('a.search-dropdown-toggle').parent('li').removeClass('active');
$('#toggle-bar-wrap').removeClass('active-bar');
var $toggle = $('a.toggle-bar-btn');
if ($toggle.length !== 0) {
$toggle.children('.fa').removeClass($toggle.data('icon-hover')).addClass($toggle.data('icon'));
}
});
},
/**
* Updates config on doc ready
*
* @since 3.0.0
*/
initUpdateConfig: function () {
// Mobile check
this.config.$isMobile = this.mobileCheck();
// Local scroll speed
if (tbLocalize.localScrollSpeed) {
this.config.$localScrollSpeed = parseInt(tbLocalize.localScrollSpeed);
}
// Define header
if ($('#site-header').length) {
this.config.$siteHeader = $('#site-header');
}
// Define logo
if ($('#site-logo img').length) {
this.config.$siteLogo = $('#site-logo img');
this.config.$siteLogoSrc = this.config.$siteLogo.attr('src');
}
// Site nav wrap
if ($('#site-navigation-wrap').length) {
this.config.$siteNavWrap = $('#site-navigation-wrap');
}
// Mobile menu style
if ($('#site-navigation-wrap').length) {
this.config.$mobileMenuStyle = tbLocalize.mobileMenuStyle;
}
// Define local scrolling links
this.config.$localScrollArray = this.localScrollLinksArray();
// Footer reveal
if ($('.footer-reveal').length && $('#wrap').length && $('#main').length) {
this.config.$footerReveal = true;
}
// Header overlay
if (this.config.$siteHeader && this.config.$siteHeader.hasClass('fix-overlay-header')) {
this.config.$hasHeaderOverlay = true;
}
// RTL
if (tbLocalize.isRTL) {
this.config.$isRTL = true;
}
// Top bar enabled
if ($('#top-bar-wrap').length) {
this.config.$hasTopBar = true;
if ($('#top-bar-wrap').hasClass('tb-top-bar-sticky')) {
this.config.$stickyTopBar = $('#top-bar-wrap');
}
}
// Local scroll speed
if (tbLocalize.localScrollSpeed) {
this.config.localScrollSpeed = parseInt(tbLocalize.localScrollSpeed);
}
// Sticky TopBar Init
if (this.config.$stickyTopBar) {
if (tbLocalize.hasStickyTopBarMobile || ( this.config.$windowWidth >= tbLocalize.stickyTopBarBreakPoint )) {
this.config.$hasStickyTopBar = true;
} else {
this.config.$hasStickyTopBar = false;
}
}
// Check if sticky is enabled for mobile
this.config.$hasStickyMobileHeader = tbLocalize.hasStickyMobileHeader;
// Sticky Header
if (tbLocalize.hasStickyHeader) {
if (tbLocalize.stickyHeaderBreakPoint) {
this.config.$stickyHeaderBreakPoint = tbLocalize.stickyHeaderBreakPoint;
}
if (this.config.$hasStickyMobileHeader || ( this.config.$windowWidth >= this.config.$stickyHeaderBreakPoint )) {
this.config.$hasStickyHeader = true;
} else {
this.config.$hasStickyHeader = false;
}
}
// Retina logo
if (typeof $tbRetinaLogo !== 'undefined' && window.devicePixelRatio >= 2) {
this.config.retinaLogo = $tbRetinaLogo;
}
// Disable Sticky header on mobile for toggle style mobile menu
if ('toggle' == this.config.$mobileMenuStyle) {
this.config.$hasStickyMobileHeader = false;
}
// Vertical header
if (this.config.$body.hasClass('tb-has-vertical-header')) {
this.config.$verticalHeaderActive = true;
}
// Remove active class from has-scroll links
var $links = $('.dropdown-menu a');
$links.each(function () {
var $this = $(this),
$ref = $this.attr('href');
if ($ref) {
if ($ref.indexOf('localscroll-') != -1) {
$this.parent('li.current-menu-item').removeClass('current-menu-item');
}
}
});
},
/**
* Updates config on window load
*
* @since 3.0.0
*/
windowLoadUpdateConfig: function () {
// Header bottom position
if (this.config.$siteHeader) {
var $siteHeaderTop = this.config.$siteHeader.offset().top;
this.config.$windowHeight = this.config.$window.height();
this.config.$siteHeaderHeight = this.config.$siteHeader.outerHeight();
this.config.$siteHeaderBottom = $siteHeaderTop + this.config.$siteHeaderHeight;
this.config.$siteHeaderTop = $siteHeaderTop;
if (this.config.$siteLogo) {
this.config.$siteLogoHeight = this.config.$siteLogo.height();
}
}
/* Window height must be larger then the height plus header height
if ( this.config.$document.height() < ( this.config.$windowHeight + this.config.$siteHeaderBottom ) ) {
this.config.$hasStickyHeader = false;
}*/
// Add Local scroll offset based on header height
this.config.$localScrollOffset = this.parseLocalScrollOffset();
},
/**
* Updates config whenever the window is resized
*
* @since 3.0.0
*/
resizeUpdateConfig: function () {
// Update main configs
this.config.$windowHeight = this.config.$window.height();
this.config.$windowWidth = this.config.$window.width();
this.config.$windowTop = this.config.$window.scrollTop();
// Update header height
if (this.config.$siteHeader) {
// reset sticky height
if ($('.tb-sticky-header-holder').length) {
$('.tb-sticky-header-holder').height('');
}
// Get header height
this.config.$siteHeaderHeight = this.config.$siteHeader.outerHeight();
// Re add sticky height
if ($('.tb-sticky-header-holder').length) {
$('.tb-sticky-header-holder').height(this.config.$siteHeaderHeight);
}
}
// Vertical Header
if (this.config.$windowWidth < 960) {
this.config.$verticalHeaderActive = false;
} else if (this.config.$body.hasClass('tb-has-vertical-header')) {
this.config.$verticalHeaderActive = true;
}
// Update Topbar sticky height
if (this.config.$stickyTopBar) {
this.config.$stickyTopBarHeight = this.config.$stickyTopBar.outerHeight();
$('.tb-sticky-top-bar-holder').height(this.config.$stickyTopBarHeight);
}
// Re-stick topbar but check for mobile first
if (this.config.$hasStickyTopBar) {
// Unstick first
this.stickyTopBar('unstick');
// Desktops or mobile enabled
if (tbLocalize.hasStickyTopBarMobile || ( this.config.$windowWidth >= tbLocalize.stickyTopBarBreakPoint )) {
this.config.$hasStickyTopBar = true;
this.stickyTopBar();
}
// Mobile
else if (!tbLocalize.hasStickyTopBarMobile) {
this.config.$hasStickyTopBar = false;
}
}
// Sticky Header (MUST CHECK tbLocalize.hasStickyHeader )
if (tbLocalize.hasStickyHeader) {
// Unstick first
this.stickyHeader('unstick');
this.stickyHeaderShrink('destroy');
// Desktops
if (this.config.$hasStickyMobileHeader || ( this.config.$windowWidth >= tbLocalize.stickyHeaderBreakPoint )) {
this.config.$hasStickyHeader = true;
this.stickyHeader();
this.stickyHeaderShrink();
}
// Mobile
else if (!this.config.$hasStickyMobileHeader) {
this.config.$hasStickyHeader = false;
}
}
// Local scroll offset => update last
this.config.$localScrollOffset = this.parseLocalScrollOffset();
},
/**
* Mobile Check
*
* @since 2.1.0
*/
mobileCheck: function () {
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
this.config.$body.addClass('tb-is-mobile-device');
return true;
}
},
/**
* Page Animations
*
* @since 2.1.0
*/
pageAnimations: function () {
if (!$.fn.animsition) {
return;
}
// Return if wrapper doesn't exist
if (!tbLocalize.pageAnimation) {
return;
}
// Run animsition
$('.animsition').animsition({
touchSupport: false,
inClass: tbLocalize.pageAnimationIn,
outClass: tbLocalize.pageAnimationOut,
inDuration: tbLocalize.pageAnimationInDuration,
outDuration: tbLocalize.pageAnimationOutDuration,
linkElement: 'a[href]:not([target="_blank"]):not([href^="#"]):not([href*="javascript"]):not([href*=".jpg"]):not([href*=".jpeg"]):not([href*=".gif"]):not([href*=".png"]):not([href*=".mov"]):not([href*=".swf"]):not([href*=".mp4"]):not([href*=".flv"]):not([href*=".avi"]):not([href*=".mp3"]):not([href^="mailto:"]):not([href*="?"]):not([href*="#localscroll"]):not([class="wcmenucart"])',
loading: true
});
},
/**
* Superfish menus
*
* @since 2.0.0
*/
superFish: function () {
if (!$.fn.superfish) {
return;
}
$('#site-navigation ul.sf-menu').superfish({
delay: tbLocalize.superfishDelay,
animation: {
opacity: 'show'
},
animationOut: {
opacity: 'hide'
},
speed: tbLocalize.superfishSpeed,
speedOut: tbLocalize.superfishSpeedOut,
cssArrows: false,
disableHI: false
});
},
/**
* MegaMenus Width
*
* @since 2.0.0
*/
megaMenusWidth: function () {
if (!this.config.$siteHeader || tbLocalize.siteHeaderStyle !== 'one') {
return;
}
var $siteNavigationWrap = $('#site-navigation-wrap'),
$headerContainerWidth = this.config.$siteHeader.find('.container').outerWidth(),
$navWrapWidth = $siteNavigationWrap.outerWidth(),
$siteNavigationWrapPosition = $siteNavigationWrap.css('right'),
$siteNavigationWrapPosition = parseInt($siteNavigationWrapPosition);
if ('auto' == $siteNavigationWrapPosition) {
$siteNavigationWrapPosition = 0;
}
var $megaMenuNegativeMargin = $headerContainerWidth - $navWrapWidth - $siteNavigationWrapPosition;
$('#site-navigation-wrap .megamenu > ul').css({
'width': $headerContainerWidth,
'margin-left': -$megaMenuNegativeMargin
});
},
/**
* MegaMenus Top Position
*
* @since 2.0.0
*/
megaMenusTop: function () {
if (!this.config.$siteHeaderHeight
|| !this.config.$siteNavWrap
|| !this.config.$siteHeader.hasClass('header-one')
|| $('#site-navigation-wrap').hasClass('tb-flush-dropdowns')
|| !this.config.$siteHeader.hasClass('header-one')
) {
return;
}
var $navHeight = this.config.$siteNavWrap.outerHeight(),
$megaMenuTop = this.config.$siteHeaderHeight - $navHeight;
$('#site-navigation-wrap .megamenu > ul').css({
'top': $megaMenuTop / 2 + $navHeight
});
},
/**
* FlushDropdowns top positioning
*
* @since 2.0.0
*/
flushDropdownsTop: function () {
if (!this.config.$siteHeaderHeight
|| !this.config.$siteNavWrap
|| !this.config.$siteNavWrap.hasClass('tb-flush-dropdowns')
) {
return;
}
var $navHeight = this.config.$siteNavWrap.outerHeight(),
$dropTop = this.config.$siteHeaderHeight - $navHeight;
$('#site-navigation-wrap .dropdown-menu > .menu-item-has-children > ul').css({
'top': $dropTop / 2 + $navHeight
});
},
/**
* Mobile Menu
*
* @since 2.0.0
*/
mobileMenu: function (event) {
var self = this;
// Sidr
if ('sidr' == this.config.$mobileMenuStyle && typeof tbLocalize.sidrSource !== 'undefined') {
var self = this;
// Add sidr
$('a.mobile-menu-toggle, li.mobile-menu-toggle > a').sidr({
name: 'sidr-main',
source: tbLocalize.sidrSource,
side: tbLocalize.sidrSide,
displace: tbLocalize.sidrDisplace,
speed: parseInt(tbLocalize.sidrSpeed),
renaming: true,
onOpen: function (name) {
// Prevent body scroll
self.config.$body.addClass('tb-noscroll');
// Declare useful vars
var $hasChildren = $('.sidr-class-menu-item-has-children');
// Add dropdown toggle (arrow)
$hasChildren.children('a').append('<span class="sidr-class-dropdown-toggle"></span>');
// Toggle dropdowns
$('.sidr-class-dropdown-toggle').on(self.config.$isMobile ? 'touchstart' : 'click', function (event) {
var $toggleParentLink = $(this).parent('a'),
$toggleParentLi = $toggleParentLink.parent('li'),
$allParentLis = $toggleParentLi.parents('li'),
$dropdown = $toggleParentLi.children('ul');
if (!$toggleParentLi.hasClass('active')) {
$hasChildren.not($allParentLis).removeClass('active').children('ul').slideUp('fast');
$toggleParentLi.addClass('active').children('ul').slideDown('fast');
} else {
$toggleParentLi.removeClass('active').children('ul').slideUp('fast');
}
return false;
});
// Add dark overlay to content
self.config.$body.append('<div class="tb-sidr-overlay tb-hidden"></div>');
$('.tb-sidr-overlay').fadeIn(tbLocalize.sidrSpeed);
// Bind scroll
$('#sidr-main').bind('mousewheel DOMMouseScroll', function (e) {
var e0 = e.originalEvent,
delta = e0.wheelDelta || -e0.detail;
this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
e.preventDefault();
});
// Close sidr when clicking toggle
$('a.sidr-class-toggle-sidr-close').on(self.config.$isMobile ? 'touchstart' : 'click', function (event) {
$.sidr('close', 'sidr-main');
return false;
});
// Close sidr when clicking on overlay
$('.tb-sidr-overlay').on(self.config.$isMobile ? 'touchstart' : 'click', function (event) {
$.sidr('close', 'sidr-main');
return false;
});
// Close on resize
self.config.$window.resize(function () {
if (self.config.$windowWidth >= self.config.$mobileMenuBreakpoint) {
$.sidr('close', 'sidr-main');
}
});
},
onClose: function (name) {
// Allow body scroll
self.config.$body.removeClass('tb-noscroll');
// Remove active dropdowns
$('.sidr-class-menu-item-has-children.active').removeClass('active').children('ul').hide();
// FadeOut overlay
$('.tb-sidr-overlay').fadeOut(tbLocalize.sidrSpeed, function () {
$(this).remove();
});
}
});
// Close when clicking local scroll link
$('li.sidr-class-local-scroll > a').click(function () {
var $target = $(this.hash);
$.sidr('close', 'sidr-main');
self.scrollTo($target);
return false;
});
}
// Toggle
else if ('toggle' == this.config.$mobileMenuStyle && this.config.$siteHeader) {
// Insert nav
if ($('#tb-mobile-menu-fixed-top').length) {
$('#tb-mobile-menu-fixed-top').append('<nav class="mobile-toggle-nav clr"></nav>');
} else {
$('<nav class="mobile-toggle-nav clr"></nav>').insertAfter(this.config.$siteHeader);
}
// Grab all content from menu and add into mobile-toggle-nav element
if ($('#mobile-menu-alternative').length) {
var mobileMenuContents = $('#mobile-menu-alternative .dropdown-menu').html();
} else {
var mobileMenuContents = $('#site-navigation .dropdown-menu').html();
}
$('.mobile-toggle-nav').html('<ul class="mobile-toggle-nav-ul">' + mobileMenuContents + '</ul>');
// Remove all styles
$('.mobile-toggle-nav-ul, .mobile-toggle-nav-ul *').children().each(function () {
var attributes = this.attributes;
$(this).removeAttr('style');
});
// Add classes where needed
$('.mobile-toggle-nav-ul').addClass('container');
// Show/Hide
$('.mobile-menu-toggle').on(self.config.$isMobile ? 'touchstart' : 'click', function (event) {
if (tbLocalize.animateMobileToggle) {
$('.mobile-toggle-nav').slideToggle('fast').toggleClass('visible');
} else {
$('.mobile-toggle-nav').toggle().toggleClass('visible');
}
return false;
});
// Close on resize
self.config.$window.resize(function () {
if (self.config.$windowWidth >= self.config.$mobileMenuBreakpoint && $('.mobile-toggle-nav').length) {
$('.mobile-toggle-nav').hide().removeClass('visible');
}
});
// Add search => not sure if I want to add yet...todo?
// $( '.mobile-toggle-nav' ).append( $( '#mobile-menu-search' ) );
}
// Full-screen overlay
else if ('full_screen' == this.config.$mobileMenuStyle && this.config.$siteHeader) {
// Style
var $style = tbLocalize.fullScreenMobileMenuStyle ? tbLocalize.fullScreenMobileMenuStyle : false;
// Insert new nav
self.config.$body.append('<div class="full-screen-overlay-nav clr ' + $style + '"><span class="full-screen-overlay-nav-close"></span><nav class="full-screen-overlay-nav-ul-wrapper"><ul class="full-screen-overlay-nav-ul"></ul></nav></div>');
// Grab all content from menu and add into mobile-toggle-nav element
if ($('#mobile-menu-alternative').length) {
var mobileMenuContents = $('#mobile-menu-alternative .dropdown-menu').html();
} else {
var mobileMenuContents = $('#site-navigation .dropdown-menu').html();
}
$('.full-screen-overlay-nav-ul').html(mobileMenuContents);
// Remove all styles
$('.full-screen-overlay-nav, .full-screen-overlay-nav *').children().each(function () {
var attributes = this.attributes;
$(this).removeAttr('style');
});
// Show
$('.mobile-menu-toggle').on(self.config.$isMobile ? 'touchstart' : 'click', function (event) {
$('.full-screen-overlay-nav').addClass('visible');
self.config.$body.addClass('tb-noscroll');
return false;
});
// Hide
$('.full-screen-overlay-nav-close').on(self.config.$isMobile ? 'touchstart' : 'click', function (event) {
$('.full-screen-overlay-nav').removeClass('visible');
self.config.$body.removeClass('tb-noscroll');
return false;
});
}
},
/**
* Prevent clickin on links
*
* @since 2.0.0
*/
navNoClick: function () {
$('li.nav-no-click > a, li.sidr-class-nav-no-click > a').live('click', function () {
return false;
});
},
/**
* Sticky Topbar
*
* @since 3.0.0
*/
stickyTopBar: function (event) {
// Return if no topbar
if (!this.config.$hasTopBar
|| !this.config.$hasStickyTopBar
|| !this.config.$stickyTopBar
) {
return;
}
// Declare vars
var self = this;
// Unstick the topbar
if ('unstick' == event && $('.tb-sticky-top-bar-holder').length) {
// Unstick
self.config.$stickyTopBar.unstick();
// Reset topbar height
self.config.$stickyTopBarHeight = $('#top-bar-wrap').outerHeight();
// Reset holder height
$('.tb-sticky-top-bar-holder').height('');
// Return
return;
}
// Stick the TopBar
if (self.config.$hasStickyTopBar && !$('.tb-sticky-top-bar-holder').length) {
// Offset the fixed mobile nav
var $mobileMenu = $('#tb-mobile-menu-fixed-top');
if ($mobileMenu.is(':visible')) {
var $topSpacing = $mobileMenu.outerHeight();
} else {
var $topSpacing = 0;
}
self.config.$stickyTopBar.sticky({
topSpacing: $topSpacing,
getWidthFrom: '#wrap',
responsiveWidth: true,
wrapperClassName: 'tb-sticky-top-bar-holder'
});
// Add topbar height to sticky wrapper
self.config.$stickyTopBar.on('sticky-start', function () {
$('.tb-sticky-top-bar-holder').height(self.config.$stickyTopBar.outerHeight());
});
}
},
/**
* Sticky Header
*
* @since 2.0.0
*/
stickyHeader: function (event) {
var self = this,
$fixedNav = $('.fixed-nav'),
$topSpacing = 0,
$mobileMenu = $('#tb-mobile-menu-fixed-top');
// Descroty sticky and sticky functions
if ('unstick' == event) {
if ($('.tb-sticky-header-holder').length) {
// Destroy shrink header
self.stickyHeaderShrink('resize_destroy');
// Destroy sticky header
$('#site-header.fixed-scroll').unstick();
// Set correct header height
$('.tb-sticky-header-holder').css('height', '');
// Return correct logo
var $logo = self.config.retinaLogo ? self.config.retinaLogo : self.config.$siteLogoSrc;
if ($logo) {
self.config.$siteLogo.attr('src', $logo);
}
}
if ($('.tb-sticky-menu-holder').length) {
$('.fixed-nav').unstick();
}
}
// Add Sticky
else {
// Sticky is disabled do nothing or header doesn't exist...return
if (!this.config.$siteHeader
|| !this.config.$hasStickyHeader
) {
return;
}
if (self.config.$hasStickyTopBar) {
$topSpacing = $topSpacing + self.config.$stickyTopBar.outerHeight()
}
if ($mobileMenu.is(':visible')) {
$topSpacing = $topSpacing + $mobileMenu.outerHeight();
}
// Already sticky do nothing
if ($('.tb-sticky-header-holder').length) {
return;
}
// Sticky header
if (self.config.$siteHeader.hasClass('fixed-scroll')) {
// Start sticky
self.config.$siteHeader.sticky({
topSpacing: $topSpacing,
getWidthFrom: '#wrap',
responsiveWidth: true,
wrapperClassName: 'tb-sticky-header-holder'
});
// Set header height
$('.tb-sticky-header-holder').height(self.config.$siteHeaderHeight);
// Sticky on start events
self.config.$siteHeader.on('sticky-start', function () {
// Sticky custom logo
if (self.config.$siteLogo
&& tbLocalize.stickyheaderCustomLogo
&& !self.config.$siteHeader.hasClass('tb-shrink-sticky-header')
) {
self.config.$siteLogo.attr('src', tbLocalize.stickyheaderCustomLogo);
}
});
// Sticky on end events
self.config.$siteHeader.on('sticky-end', function () {
// Return correct logo
if (!self.config.$siteHeader.hasClass('tb-shrink-sticky-header')) {
var $logo = self.config.retinaLogo ? self.config.retinaLogo : self.config.$siteLogoSrc;
if ($logo) {
self.config.$siteLogo.attr('src', $logo);
}
}
});
}
// Sticky nav
else if ($fixedNav.length) {
$fixedNav.sticky({
topSpacing: $topSpacing,
getWidthFrom: '#wrap',
responsiveWidth: true,
wrapperClassName: 'tb-sticky-menu-holder'
});
// Sticky on start events
$fixedNav.on('sticky-start', function () {
$('.tb-sticky-menu-holder').height($fixedNav.outerHeight());
});
}
}
},
/**
* Shrink sticky header
*
* @since 2.0.0
*/
stickyHeaderShrink: function (event) {
// Initial checks
if (!this.config.$siteHeader
|| !this.config.$siteHeader.hasClass('tb-shrink-sticky-header')
|| !$('.tb-sticky-header-holder').length
) {
return;
}
// Declare main vars
var self = this,
$siteHeaderInner = $('#site-header-inner'),
$ogTopPadding = $('#site-header-inner').css('padding-top'),
$ogBottomPadding = $('#site-header-inner').css('padding-bottom'),
$ogHeight = $siteHeaderInner.outerHeight(),
$shrunkHeight = 70,
$shrunkHeightLogo = parseInt(tbLocalize.shrinkHeaderLogoHeight),
$shrunkSpeed = 300;
// Destroy method
function destroy() {
if (self.config.$siteHeader.hasClass('tb-header-shrunk')) {
// Reset header height
$siteHeaderInner.stop(true, true).animate({
'height': $ogHeight,
'padding-top': $ogTopPadding,
'padding-bottom': $ogBottomPadding
}, {
duration: $shrunkSpeed,
queue: false
});
// Reset logo
var $logo = self.config.retinaLogo ? self.config.retinaLogo : self.config.$siteLogoSrc;
if ($logo) {
self.config.$siteLogo.attr('src', $logo);
}
// Reset logo height
if (self.config.$siteLogo) {
self.config.$siteLogo.stop(true, true).animate({
'height': self.config.$siteLogoHeight,
}, {
duration: $shrunkSpeed,
queue: false
});
}
// Get correct header height after animations are complete and re-position megamenus
setTimeout(function () {
self.config.$siteHeaderHeight = self.config.$siteHeader.outerHeight();
self.megaMenusTop();
self.flushDropdownsTop();
}, $shrunkSpeed);
// Remove shrunk class
self.config.$siteHeader.removeClass('tb-header-shrunk');
}
}
// Destroy event
if ('destroy' == event) {
destroy();
return;
}
// Resize destroy method - required since header height can change on window resize
function resizeDestroy() {
// Reset header height
$siteHeaderInner.css({
'height': '',
'padding-top': '',
'padding-bottom': '',
});
// Reset logo
var $logo = self.config.retinaLogo ? self.config.retinaLogo : self.config.$siteLogoSrc;
if ($logo) {
self.config.$siteLogo.attr('src', $logo);
}
// Reset logo height
if (self.config.$siteLogo) {
self.config.$siteLogo.css({
'height': self.config.$siteLogoHeight,
});
}
// Get correct header height and megaMenus top location
self.config.$siteHeaderHeight = self.config.$siteHeader.outerHeight();
self.megaMenusTop();
self.flushDropdownsTop();
// Remove shrunk class
self.config.$siteHeader.removeClass('tb-header-shrunk');
}
if ('resize_destroy' == event) {
resizeDestroy();
return;
}
// Get offset
var $offSet = tbLocalize.stickyShrinkOffset;
if (self.config.$siteHeaderBottom) {
$offSet = self.config.$siteHeaderBottom;
}
self.config.$window.scroll(function () {
// Sticky header disabled = must check on scroll
if (!self.config.$hasStickyHeader) {
return;
}
// Add shrink classes
if (self.config.$windowTop > $offSet) {
if (!self.config.$siteHeader.hasClass('tb-header-shrunk')) {
// Set header innner height
$siteHeaderInner.stop(true, true).animate({
'height': $shrunkHeight,
'padding-top': '0',
'padding-bottom': '0'
}, {
duration: $shrunkSpeed,
queue: false
});
// Set logo height
if (self.config.$siteLogo) {
self.config.$siteLogo.stop(true, true).animate({
'height': $shrunkHeightLogo
}, {
duration: $shrunkSpeed,
queue: false
});
}
// Sticky custom logo
if (self.config.$siteLogo && tbLocalize.stickyheaderCustomLogo) {
self.config.$siteLogo.attr('src', tbLocalize.stickyheaderCustomLogo);
}
// Get correct header height after animations are complete and re-position megamenus
setTimeout(function () {
self.config.$siteHeaderHeight = self.config.$siteHeader.outerHeight();
self.megaMenusTop();
self.flushDropdownsTop();
}, $shrunkSpeed);
// Add class to prevent events from running every time user scrolls
self.config.$siteHeader.addClass('tb-header-shrunk');
}
} else {
destroy(); // As a function so we can destroy when sticky is destroyed also
}
});
},
/**
* Overlay Header Topbar offset
*
* @since 2.0.0
*/
overlayHeaderTopWrapPadding: function () {
// Topbar offset
if (!this.config.$hasTopBar
|| !this.config.$hasHeaderOverlay
) {
return;
}
var $paddingEl = ( tbLocalize.mainLayout == 'boxed' ) ? $('#wrap') : $('#outer-wrap');
$($paddingEl).css({
'padding-top': $('#top-bar-wrap').outerHeight()
});
$('#site-header.overlay-header').css({
'top': $('#top-bar-wrap').outerHeight()
});
// Content padding offset..
var $offSetOverlayContent = $('.offset-overlay-header').first();
if ($offSetOverlayContent.length && this.config.$siteHeaderHeight) {
$offSetOverlayContent.css({
'padding-top': this.config.$siteHeaderHeight + 60
});
}
},
/**
* Header Search
*
* @since 2.0.0
*/
menuSearch: function () {
// Dropdown
if ('drop_down' == tbLocalize.menuSearchStyle) {
$('a.search-dropdown-toggle').click(function (event) {
$('#searchform-dropdown').toggleClass('show');
$('#searchform-dropdown input').focus();
$(this).parent('li').toggleClass('active');
$('div#current-shop-items-dropdown').removeClass('show');
$('li.wcmenucart-toggle-dropdown').removeClass('active');
return false;
});
$('#searchform-dropdown').click(function (event) {
event.stopPropagation();
});
}
// Overlay Modal
else if ('overlay' == tbLocalize.menuSearchStyle) {
if (!$.fn.leanerModal) {
return;
}
var $searchOverlayToggle = $('a.search-overlay-toggle');
$searchOverlayToggle.leanerModal({
id: '#searchform-overlay',
top: 100,
overlay: 0.8
});
$searchOverlayToggle.click(function () {
$('#site-searchform input').focus();
});
}
// Header Replace
else if ('header_replace' == tbLocalize.menuSearchStyle) {
var $headerReplace = $('#searchform-header-replace');
$('a.search-header-replace-toggle').click(function (event) {
$headerReplace.toggleClass('show');
$headerReplace.find('input').focus();
return false;
});
$('#searchform-header-replace-close').click(function () {
$headerReplace.removeClass('show');
return false;
});
$headerReplace.click(function (event) {
event.stopPropagation();
});
}
},
/**
* Header Cart
*
* @since 2.0.0
*/
headerCart: function () {
if ($('a.wcmenucart').hasClass('go-to-shop')) {
return;
}
// Drop-down
if ('drop_down' == tbLocalize.wooCartStyle) {
// Display cart dropdown
$('.toggle-cart-widget').click(function (event) {
$('#searchform-dropdown').removeClass('show');
$('a.search-dropdown-toggle').parent('li').removeClass('active');
$('div#current-shop-items-dropdown').toggleClass('show');
$(this).toggleClass('active');
return false;
});
// Hide cart dropdown
$('div#current-shop-items-dropdown').click(function (event) {
event.stopPropagation();
});
this.config.$document.click(function () {
$('div#current-shop-items-dropdown').removeClass('show');
$('li.wcmenucart-toggle-dropdown').removeClass('active');
});
// Prevent body scroll on current shop dropdown
$('#current-shop-items-dropdown').bind('mousewheel DOMMouseScroll', function (e) {
var e0 = e.originalEvent,
delta = e0.wheelDelta || -e0.detail;
this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
e.preventDefault();
});
}
// Modal
else if ('overlay' == tbLocalize.wooCartStyle) {
if (!$.fn.leanerModal) {
return;
}
$('.toggle-cart-widget').leanerModal({
id: '#current-shop-items-overlay',
top: 100,
overlay: 0.8
});
}
},
/**
* Relocate the cart and search dropdowns for specific header styles
*
* @since 2.0.0
*/
cartSearchDropdownsRelocate: function () {
// Get last menu item
var $lastMenuItem = $('#site-navigation .dropdown-menu > li:nth-last-child(1)');
// Validate first
if (this.config.$hasHeaderOverlay
|| !this.config.$siteHeader
|| !$lastMenuItem.length
|| !this.config.$siteHeader.hasClass('tb-reposition-cart-search-drops')
) {
return;
}
// Define search and cart elements
var $searchDrop = $('#searchform-dropdown'),
$shopDrop = $('#current-shop-items-dropdown');
// Get last menu item offset
var $lastMenuItemOffset = $lastMenuItem.position();
// Position search dropdown
if ($searchDrop.length) {
var $searchDropPosition = $lastMenuItemOffset.left - $searchDrop.outerWidth() + $lastMenuItem.width();
$searchDrop.css({
'right': 'auto',
'left': $searchDropPosition
});
}
// Position Woo dropdown
if ($shopDrop.length) {
var $shopDropPosition = $lastMenuItemOffset.left - $shopDrop.outerWidth() + $lastMenuItem.width();
$shopDrop.css({
'right': 'auto',
'left': $shopDropPosition
});
}
},
/**
* Hide post edit link
*
* @since 2.0.0
*/
hideEditLink: function () {
$('a.hide-post-edit').click(function () {
$('div.post-edit').hide();
return false;
});
},
/**
* Custom menu widget toggles
*
* @since 2.0.0
*/
customMenuWidgetAccordion: function () {
var self = this;
$('#main .widget_nav_menu .current-menu-ancestor').addClass('active').children('ul').show();
$('#main .widget_nav_menu').each(function () {
var $widgetMenu = $(this),
$hasChildren = $(this).find('.menu-item-has-children'),
$allSubs = $hasChildren.children('.sub-menu');
$hasChildren.each(function () {
$(this).addClass('parent');
var $links = $(this).children('a');
$links.on(self.config.$isMobile ? 'touchstart' : 'click', function (event) {
var $linkParent = $(this).parent('li'),
$allParents = $linkParent.parents('li');
if (!$linkParent.hasClass('active')) {
$hasChildren.not($allParents).removeClass('active').children('.sub-menu').slideUp('fast');
$linkParent.addClass('active').children('.sub-menu').slideDown('fast');
} else {
$linkParent.removeClass('active').children('.sub-menu').slideUp('fast');
}
return false;
});
});
});
},
/**
* Header 5 - Inline Logo
*
* @since 2.0.0
*/
inlineHeaderLogo: function () {
// Only needed for header style 5
if ('five' != tbLocalize.siteHeaderStyle) {
return;
}
var $headerLogo = $('#site-header-inner > .header-five-logo'),
$headerNav = $('#site-header-inner .navbar-style-five'),
$navLiCount = $headerNav.children('#site-navigation').children('ul').children('li').size(),
$navBeforeMiddleLi = Math.round($navLiCount / 2) - parseInt(tbLocalize.headerFiveSplitOffset),
$centeredLogo = $('.menu-item-logo .header-five-logo');
// Add logo into menu
if (this.config.$windowWidth >= this.config.$mobileMenuBreakpoint && $headerLogo.length && $headerNav.length) {
$('<li class="menu-item-logo"></li>').insertAfter($headerNav.find('#site-navigation > ul > li:nth( ' + $navBeforeMiddleLi + ' )'));
$headerLogo.appendTo($headerNav.find('.menu-item-logo'));
}
// Remove logo from menu and add to header
if (this.config.$windowWidth < this.config.$mobileMenuBreakpoint && $centeredLogo.length) {
$centeredLogo.prependTo($('#site-header-inner'));
$('.menu-item-logo').remove();
}
// Add display class to logo (hidden by default)
$headerLogo.addClass('display');
},
/**
* Back to top link
*
* @since 2.0.0
*/
backTopLink: function () {
var self = this,
$scrollTopLink = $('a#site-scroll-top');
if ($scrollTopLink.length) {
var $speed = tbLocalize.windowScrollTopSpeed ? tbLocalize.windowScrollTopSpeed : 2000,
$speed = parseInt($speed);
this.config.$window.scroll(function () {
if ($(this).scrollTop() > 100) {
$scrollTopLink.addClass('show');
} else {
$scrollTopLink.removeClass('show');
}
});
$scrollTopLink.on(self.config.$isMobile ? 'touchstart' : 'click', function (event) {
$('html, body').stop(true, true).animate({
scrollTop: 0
}, $speed);
return false;
});
}
},
/**
* Smooth Comment Scroll
*
* @since 2.0.0
*/
smoothCommentScroll: function () {
$('.single li.comment-scroll a').click(function (event) {
$('html, body').stop(true, true).animate({
scrollTop: $(this.hash).offset().top - 180
}, 'normal');
return false;
});
},
/**
* Tooltips
*
* @since 2.0.0
*/
tipsyTooltips: function () {
$('a.tooltip-left').tipsy({
fade: true,
gravity: 'e'
});
$('a.tooltip-right').tipsy({
fade: true,
gravity: 'w'
});
$('a.tooltip-up').tipsy({
fade: true,
gravity: 's'
});
$('a.tooltip-down').tipsy({
fade: true,
gravity: 'n'
});
},
/**
* Custom hovers using data attributes
*
* @since 2.0.0
*/
customHovers: function () {
$('.tb-data-hover').each(function () {
var $this = $(this),
$originalBg = $(this).css('backgroundColor'),
$originalColor = $(this).css('color'),
$hoverBg = $(this).attr('data-hover-background'),
$hoverColor = $(this).attr('data-hover-color');
$this.hover(function () {
if (CSSStyleDeclaration.prototype.setProperty !== 'undefined') {
if ($hoverBg) {
this.style.setProperty('background-color', $hoverBg, 'important');
}
if ($hoverColor) {
this.style.setProperty('color', $hoverColor, 'important');
}
} else {
if ($hoverBg) {
$this.css('background-color', $hoverBg);
}
if ($hoverColor) {
$this.css('color', $hoverColor);
}
}
}, function () {
if (CSSStyleDeclaration.prototype.setProperty !== 'undefined') {
if ($hoverBg) {
this.style.setProperty('background-color', $originalBg, 'important');
}
if ($hoverColor) {
this.style.setProperty('color', $originalColor, 'important');
}
} else {
if ($hoverBg && $originalBg) {
$this.css('background-color', $originalBg);
}
if ($hoverColor && $originalColor) {
$this.css('color', $originalColor);
}
}
});
});
},
/**
* Togglebar toggle
*
* @since 2.0.0
*/
toggleBar: function () {
var self = this,
$toggle = $('a.toggle-bar-btn');
if ($toggle.length) {
$toggle.on(self.config.$isMobile ? 'touchstart' : 'click', function (event) {
var $fa = $('.toggle-bar-btn').find('.fa');
$fa.toggleClass($toggle.data('icon'));
$fa.toggleClass($toggle.data('icon-hover'));
$('#toggle-bar-wrap').toggleClass('active-bar');
return false;
});
$('#toggle-bar-wrap').click(function (event) {
event.stopPropagation();
});
}
},
/**
* Skillbar
*
* @since 2.0.0
*/
skillbar: function () {
$('.vcex-skillbar').each(function () {
var $this = $(this);
$this.appear(function () {
$this.find('.vcex-skillbar-bar').animate({
width: $(this).attr('data-percent')
}, 800);
});
}, {
accX: 0,
accY: 0
});
},
/**
* Milestones
*
* @since 2.0.0
*/
milestone: function () {
$('.vcex-animated-milestone').each(function () {
$(this).appear(function () {
$(this).find('.vcex-milestone-time').countTo({
formatter: function (value, options) {
return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ',');
},
});
}, {
accX: 0,
accY: 0
});
});
},
/**
* Advanced Parallax
*
* @since 2.0.0
*/
parallax: function () {
$('.tb-parallax-bg').each(function () {
var $this = $(this);
$this.scrolly2().trigger('scroll');
$this.css({
'opacity': 1
});
});
},
/**
* Local Scroll Offset
*
* @since 2.0.0
*/
parseLocalScrollOffset: function () {
// Return custom offset
if (tbLocalize.localScrollOffset) {
return tbLocalize.localScrollOffset;
}
// Initial checks
if (!this.config.$siteHeader || this.config.$verticalHeaderActive) {
return 0;
}
// Define return var
var $offSet = 0;
// Fixed header
if (this.config.$siteHeaderHeight && this.config.$siteHeader.hasClass('fixed-scroll')) {
// Return 0 for small screens if mobile fixed header is disabled
if (!this.config.$hasStickyMobileHeader && this.config.$windowWidth <= tbLocalize.stickyHeaderBreakPoint) {
$offSet = 0;
}
// Return header height
else {
// Return shrink header height
if (this.config.$siteHeader.hasClass('tb-shrink-sticky-header')) {
$offSet = $offSet + 70;
}
// Return full header height
else {
$offSet = this.config.$siteHeaderHeight;
}
}
}
// Fixed Nav
else if ($('#site-navigation-wrap').hasClass('fixed-nav')) {
if (this.config.$windowWidth >= tbLocalize.stickyHeaderBreakPoint) {
$offSet = $offSet + $('#site-navigation-wrap').outerHeight();
}
}
// Add sticky topbar height offset
if (this.config.$hasStickyTopBar && this.config.$stickyTopBarHeight) {
$offSet = $offSet + this.config.$stickyTopBarHeight;
}
// Return offset
return $offSet;
},
/**
* Local scroll links array
*
* @since 2.0.0
*/
localScrollLinksArray: function () {
// Define array
var $array = []
// Return if no local-scroll links
if (!$('li.local-scroll').length) {
return $array;
}
var $links = $('#site-navigation li.local-scroll').children('a');
for (var i = 0; i < $links.length; i++) {
var $link = $links[i],
$hash = '#' + $($link).attr('href').replace(/^.*?(#|$)/, '');
if ($($hash).length) {
$array.push($hash);
}
}
// Return array of local scroll links
return $array;
},
/**
* Scroll to function
*
* @since 2.0.0
*/
scrollTo: function (hash, offset, callback) {
var self = this,
$target = $(hash);
// Target check
if ($target.length) {
// Get offset
var $offset = offset ? offset : $target.offset().top - self.config.$localScrollOffset;
// Mobile toggle Menu needs it's own code
if ($('.mobile-toggle-nav').length) {
if (tbLocalize.animateMobileToggle) {
$('.mobile-toggle-nav').slideUp('fast', function () {
$('.mobile-toggle-nav').removeClass('visible');
$('html,body').stop(true, true).animate({
scrollTop: $offset
}, self.config.$localScrollSpeed, function () {
if (tbLocalize.localScrollUpdateHash) {
window.location.hash = hash;
}
});
});
} else {
$('.mobile-toggle-nav').hide().removeClass('visible');
$('html,body').stop(true, true).animate({
scrollTop: $offset
}, self.config.$localScrollSpeed, function () {
if (tbLocalize.localScrollUpdateHash) {
window.location.hash = hash;
}
});
}
}
// Scroll to target
else {
$('html,body').stop(true, true).animate({
scrollTop: $offset
}, self.config.$localScrollSpeed, function () {
if (tbLocalize.localScrollUpdateHash) {
window.location.hash = hash;
}
});
}
}
},
/**
* Local Scroll link
*
* @since 2.0.0
*/
localScrollLinks: function () {
// Set global object to "self" var
var self = this;
// Local Scroll - Menu
$('li.local-scroll > a, .vcex-navbar-link.local-scroll').click(function () {
var $hash = this.hash;
self.scrollTo($hash);
return false;
});
// Local Scroll Anylink
$('.local-scroll-link').click(function () {
var $hash = this.hash;
self.scrollTo($hash);
return false;
});
// LocalScroll Woocommerce Reviews
$('body.single div.entry-summary a.woocommerce-review-link').click(function () {
var $hash = this.hash,
$target = $($hash);
if ($target.length) {
var $offset = $target.offset().top - self.config.$localScrollOffset - 20;
self.scrollTo($hash, $offset);
}
return false;
});
},
/**
* Local Scroll Highlight on scroll
*
* @since 2.0.0
*/
localScrollHighlight: function () {
// Get local scroll array
var self = this,
$localScrollArray = this.config.$localScrollArray;
// Return if there aren't any local scroll items
if ($localScrollArray.length === 0) {
return;
}
// Define vars
var $windowPos = this.config.$window.scrollTop(),
$windowHeight = this.config.$windowHeight,
$docHeight = this.config.$document.height();
// Highlight active items
for (var i = 0; i < $localScrollArray.length; i++) {
var $section = $localScrollArray[i];
if ($($section).length) {
var $divPos = $($section).offset().top - self.config.$localScrollOffset - 1,
$divHeight = $($section).outerHeight();
if ($windowPos >= $divPos && $windowPos < ( $divPos + $divHeight )) {
$("li.local-scroll a[href='" + $section + "']").parent('li').addClass('current-menu-item');
} else {
$("li.local-scroll a[href='" + $section + "']").parent('li').removeClass('current-menu-item');
}
}
}
// Highlight last item if at bottom of page
var $lastLink = $localScrollArray[$localScrollArray.length - 1];
if ($windowPos + $windowHeight == $docHeight) {
$('.local-scroll.current-menu-item').removeClass('current-menu-item');
$("li.local-scroll a[href='" + $lastLink + "']").parent('li').addClass('current-menu-item');
}
},
/**
* Scroll to Hash
*
* @since 2.0.0
*/
scrollToHash: function ($this) {
// Declare function vars
var self = $this,
$hash = location.hash;
// Scroll to hash
if ($hash.indexOf('localscroll-') != -1) {
// Set target
var $target = $hash.replace('localscroll-', '');
// Scroll to target
self.scrollTo($target);
return;
}
},
/**
* Equal heights function
*
* @since 2.0.0
*/
equalHeights: function () {
// Make sure equal heights function is defined
if (!$.fn.matchHeight) {
return;
}
// Add equal heights
$('.equal-height-column, .match-height-row .match-height-content, .vcex-feature-box-match-height .vcex-match-height, .equal-height-content, .match-height-grid .match-height-content, .blog-entry-equal-heights .blog-entry-inner, .tb-vc-row-columns-match-height .tb-vc-column-wrapper').matchHeight();
},
/**
* Footer Reveal Margin
*
* @since 2.0.0
*/
footerRevealMainMargin: function () {
if (this.config.$footerReveal) {
$('#wrap').css({
'margin-bottom': $('.footer-reveal').outerHeight()
});
}
},
/**
* Footer Reveal Display on Load
*
* @since 2.0.0
*/
footerRevealLoadShow: function () {
if (this.config.$footerReveal) {
if ($(window).height() > $('#wrap').height()) {
$('.footer-reveal').show().toggleClass('footer-reveal footer-reveal-visible');
}
}
},
/**
* Footer Reveal Display on Scroll
*
* @since 2.0.0
*/
footerRevealScrollShow: function () {
if (this.config.$footerReveal) {
if (this.config.$windowTop > $('#main').offset().top) {
if (!$('.footer-reveal').hasClass('visible')) {
$('.footer-reveal').show().addClass('visible');
}
} else {
if ($('.footer-reveal').hasClass('visible')) {
$('.footer-reveal').removeClass('visible').hide();
}
}
}
},
/**
* Custom Selects
*
* @since 2.0.0
*/
customSelects: function () {
$(tbLocalize.customSelects).customSelect({
customClass: 'theme-select'
});
},
/**
* FadeIn Elements
*
* @since 2.0.0
*/
fadeIn: function () {
$('.fade-in-image, .tb-show-on-load').addClass('no-opacity');
},
/**
* OwlCarousel
*
* @since 2.0.0
*/
owlCarousel: function () {
var self = this;
$('.tb-carousel').each(function () {
var $this = $(this),
$data = $this.data();
$this.owlCarousel({
animateIn: false,
animateOut: false,
lazyLoad: false,
smartSpeed: self.parseData($data.smartSpeed, tbLocalize.carouselSpeed),
rtl: self.config.$isRTL,
dots: $data.dots,
nav: $data.nav,
items: $data.items,
slideBy: $data.slideby,
center: $data.center,
loop: $data.loop,
margin: $data.margin,
autoplay: $data.autoplay,
autoplayTimeout: $data.autoplayTimeout,
navText: ['<span class="fa fa-chevron-left"><span>', '<span class="fa fa-chevron-right"></span>'],
responsive: {
0: {
items: $data.itemsMobilePortrait
},
480: {
items: $data.itemsMobileLandscape
},
768: {
items: $data.itemsTablet
},
960: {
items: $data.items
}
}
});
});
},
/**
* SliderPro
*
* @since 2.0.0
*/
sliderPro: function () {
// Set main object to self
var self = this;
// Loop through each slider
$('.tb-slider').each(function () {
// Declare vars
var $slider = $(this),
$data = $slider.data();
// Lets show things that were hidden to prevent flash
$('.tb-slider-slide, .tb-slider-thumbnails').css({
'opacity': 1,
'display': 'block'
});
// Get height based on first items to prevent animation on initial load
var $preloader = $('.tb-slider').prev('.tb-slider-preloaderimg'),
$height = $preloader.length ? $preloader.outerHeight() : null,
$heightAnimationDuration = self.parseData($data.heightAnimationDuration, 500);
// Run slider
$slider.sliderPro({
responsive: true,
width: '100%',
height: $height,
fade: self.parseData($data.fade, 600),
touchSwipe: self.parseData($data.touchSwipe, true),
fadeDuration: self.parseData($data.animationSpeed, 600),
slideAnimationDuration: self.parseData($data.animationSpeed, 600),
autoHeight: self.parseData($data.autoHeight, true),
heightAnimationDuration: $heightAnimationDuration,
arrows: self.parseData($data.arrows, true),
fadeArrows: self.parseData($data.fadeArrows, true),
autoplay: self.parseData($data.autoPlay, true),
autoplayDelay: self.parseData($data.autoPlayDelay, 5000),
buttons: self.parseData($data.buttons, true),
shuffle: self.parseData($data.shuffle, false),
orientation: self.parseData($data.direction, 'horizontal'),
loop: self.parseData($data.loop, false),
keyboard: false,
fullScreen: self.parseData($data.fullscreen, false),
slideDistance: self.parseData($data.slideDistance, 0),
thumbnailHeight: self.parseData($data.thumbnailHeight, 70),
thumbnailWidth: self.parseData($data.thumbnailWidth, 70),
thumbnailPointer: self.parseData($data.thumbnailPointer, false),
updateHash: self.parseData($data.updateHash, false),
thumbnailArrows: false,
fadeThumbnailArrows: false,
thumbnailTouchSwipe: true,
fadeCaption: self.parseData($data.fadeCaption, true),
captionFadeDuration: 500,
waitForLayers: true,
autoScaleLayers: true,
forceSize: 'none',
thumbnailPosition: 'bottom',
reachVideoAction: 'playVideo',
leaveVideoAction: 'pauseVideo',
endVideoAction: 'nextSlide',
init: function (event) {
$slider.prev('.tb-slider-preloaderimg').hide();
if ($slider.parent('.gallery-format-post-slider') && $('.blog-masonry-grid').length) {
setTimeout(function () {
$('.blog-masonry-grid').isotope('layout');
}, $heightAnimationDuration + 1);
}
},
gotoSlideComplete: function (event) {
if ($slider.parent('.gallery-format-post-slider') && $('.blog-masonry-grid').length) {
$('.blog-masonry-grid').isotope('layout');
}
}
});
});
// WooCommerce: Prevent clicking on Woo entry slider
$('.woo-product-entry-slider').click(function () {
return false;
});
},
/**
* Isotope Grids
*
* @since 2.0.0
*/
isotopeGrids: function () {
var self = this;
$('.vcex-isotope-grid').each(function () {
// Isotope layout
var $container = $(this);
$container.imagesLoaded(function () {
$container.isotope({
itemSelector: '.vcex-isotope-entry',
transformsEnabled: true,
isOriginLeft: self.config.$isRTL ? false : true,
transitionDuration: $container.data('transition-duration') ? $container.data('transition-duration') + 's' : '0.4s',
layoutMode: $container.data('layout-mode') ? $container.data('layout-mode') : 'masonry',
filter: $container.data('filter') ? $container.data('filter') : ''
});
});
// Filter links
var $filter = $container.prev('ul.vcex-filter-links');
if ($filter.length) {
var $filterLinks = $filter.find('a');
$filterLinks.click(function () {
var selector = $(this).attr('data-filter');
$container.isotope({
filter: selector
});
$(this).parents('ul').find('li').removeClass('active');
$(this).parent('li').addClass('active');
return false;
});
}
});
},
/**
* Isotope Grids
*
* @since 2.0.0
*/
archiveMasonryGrids: function () {
// Define main vars
var self = this,
$archives = $('.blog-masonry-grid,div.tb-row.portfolio-masonry,div.tb-row.portfolio-no-margins,div.tb-row.staff-masonry,div.tb-row.staff-no-margins');
// Loop through archives
$archives.each(function () {
var $this = $(this),
$data = $this.data(),
$transitionDuration = self.parseData($data.transitionDuration, '0.0'),
$layoutMode = self.parseData($data.layoutMode, 'masonry');
// Load isotope after images loaded
$this.imagesLoaded(function () {
$this.isotope({
itemSelector: '.isotope-entry',
transformsEnabled: true,
isOriginLeft: self.config.$isRTL ? false : true,
transitionDuration: $transitionDuration + 's'
});
});
});
},
/**
* iLightbox
*
* @since 2.0.0
*/
iLightbox: function () {
// Set main object to self
var self = this;
// Lightbox Standard
$('.tb-lightbox').each(function () {
var $this = $(this);
if (!$this.hasClass('tb-lightbox-group-item')) {
var $data = $this.data();
$this.iLightBox({
skin: self.parseData($data.skin, tbLocalize.iLightbox.skin),
controls: {
fullscreen: tbLocalize.iLightbox.controls.fullscreen
},
show: {
title: tbLocalize.iLightbox.show.title,
speed: parseInt(tbLocalize.iLightbox.show.speed)
},
hide: {
speed: parseInt(tbLocalize.iLightbox.hide.speed)
},
effects: {
reposition: true,
repositionSpeed: 200,
switchSpeed: 300,
loadedFadeSpeed: tbLocalize.iLightbox.effects.loadedFadeSpeed,
fadeSpeed: tbLocalize.iLightbox.effects.fadeSpeed
},
overlay: tbLocalize.iLightbox.overlay,
social: tbLocalize.iLightbox.social
});
}
});
// Lightbox Videos => OLD SCHOOL STUFF, keep for old customers
$('.tb-lightbox-video, .wpb_single_image.video-lightbox a, .tb-lightbox-autodetect, .tb-lightbox-autodetect a').each(function () {
var $this = $(this),
$data = $this.data();
$this.iLightBox({
smartRecognition: true,
skin: self.parseData($data.skin, tbLocalize.iLightbox.skin),
path: 'horizontal',
controls: {
fullscreen: tbLocalize.iLightbox.controls.fullscreen
},
show: {
title: tbLocalize.iLightbox.show.title,
speed: parseInt(tbLocalize.iLightbox.show.speed)
},
hide: {
speed: parseInt(tbLocalize.iLightbox.hide.speed)
},
effects: {
reposition: true,
repositionSpeed: 200,
switchSpeed: 300,
loadedFadeSpeed: tbLocalize.iLightbox.effects.loadedFadeSpeed,
fadeSpeed: tbLocalize.iLightbox.effects.fadeSpeed
},
overlay: tbLocalize.iLightbox.overlay,
social: tbLocalize.iLightbox.social
});
});
// Lightbox Galleries - NEW since 1.6.0
$('.lightbox-group').each(function () {
// Get lightbox data
var $this = $(this),
$item = $this.find('a.tb-lightbox-group-item'),
$data = $this.data();
// Start up lightbox
$item.iLightBox({
skin: self.parseData($data.skin, tbLocalize.iLightbox.skin),
path: self.parseData($data.path, tbLocalize.iLightbox.path),
infinite: true,
show: {
title: tbLocalize.iLightbox.show.title,
speed: parseInt(tbLocalize.iLightbox.show.speed)
},
hide: {
speed: parseInt(tbLocalize.iLightbox.hide.speed)
},
controls: {
arrows: self.parseData($data.arrows, tbLocalize.iLightbox.controls.arrows),
thumbnail: self.parseData($data.thumbnails, tbLocalize.iLightbox.controls.thumbnail),
fullscreen: tbLocalize.iLightbox.controls.fullscreen,
mousewheel: tbLocalize.iLightbox.controls.mousewheel
},
effects: {
reposition: true,
repositionSpeed: 200,
switchSpeed: 300,
loadedFadeSpeed: tbLocalize.iLightbox.effects.loadedFadeSpeed,
fadeSpeed: tbLocalize.iLightbox.effects.fadeSpeed
},
overlay: tbLocalize.iLightbox.overlay,
social: tbLocalize.iLightbox.social
});
});
// Lightbox Gallery with custom imgs
$('.tb-lightbox-gallery').on('click', function (event) {
// event.preventDefault(); // to fix customizer bug
var imagesArray = $(this).data('gallery').split(',');
if (imagesArray) {
$.iLightBox(imagesArray, {
skin: tbLocalize.iLightbox.skin,
path: 'horizontal',
infinite: true,
show: {
title: tbLocalize.iLightbox.show.title,
speed: parseInt(tbLocalize.iLightbox.show.speed)
},
hide: {
speed: parseInt(tbLocalize.iLightbox.hide.speed)
},
controls: {
arrows: tbLocalize.iLightbox.controls.arrows,
thumbnail: tbLocalize.iLightbox.controls.thumbnail,
fullscreen: tbLocalize.iLightbox.controls.fullscreen,
mousewheel: tbLocalize.iLightbox.controls.mousewheel
},
effects: {
reposition: true,
repositionSpeed: 200,
switchSpeed: 300,
loadedFadeSpeed: tbLocalize.iLightbox.effects.loadedFadeSpeed,
fadeSpeed: tbLocalize.iLightbox.effects.fadeSpeed
},
overlay: tbLocalize.iLightbox.overlay,
social: tbLocalize.iLightbox.social
});
}
return false;
});
},
/**
* Overlay Hovers
*
* @since 2.0.0
*/
overlayHovers: function () {
$('.overlay-parent-title-push-up').each(function () {
// Define vars
var $this = $(this),
$title = $this.find('.overlay-title-push-up'),
$child = $this.find('a'),
$img = $child.find('img'),
$titleHeight = $title.outerHeight();
// Create overlay after image is loaded to prevent issues
$this.imagesLoaded(function () {
// Position title
$title.css({
'bottom': -$titleHeight
});
// Add height to child
$child.css({
'height': $img.outerHeight()
});
// Position image
$img.css({
'position': 'absolute',
'top': '0',
'left': '0',
'width': '100%',
'height': '100%'
});
// Animate image on hover
$this.hover(function () {
$img.css({
'top': -20
});
$title.css({
'bottom': 0
});
}, function () {
$img.css({
'top': '0'
});
$title.css({
'bottom': -$titleHeight
});
});
});
});
},
/**
* WooCommerce Selects
*
* @since 2.0.0
*/
wooSelects: function () {
if ($.fn.select2 !== undefined) {
$('#calc_shipping_country').select2();
}
},
/**
* Parses data to check if a value is defined in the data attribute and if not returns the fallback
*
* @since 2.0.0
*/
parseData: function (val, fallback) {
return ( typeof val !== 'undefined' ) ? val : fallback;
}
}; // END tbTheme
// Start things up
tbTheme.init();
$.fn.extend({
followTo: function (elem, marginTop) {
var $this = $(this);
var $initialOffset = $this.offset().top;
var setPosition = function () {
if ($(window).scrollTop() > $initialOffset) {
if (elem.offset().top > ( $(window).scrollTop() + $this.outerHeight() + (marginTop / 2) )) {
$this.css({position: 'fixed', top: (marginTop + 30), right: 0});
}
else if (elem.offset().top <= ( $(window).scrollTop() + $this.outerHeight() - marginTop )) {
$this.css({position: 'relative', top: 0});
}
}
else if ($(window).scrollTop() <= $initialOffset) {
$this.css({position: 'relative', top: 0});
}
}
$(window).resize(function () {
setPosition();
});
$(window).scroll(function () {
setPosition();
});
}
});
if ($('.preview-img-listAQ').length != 0) {
if ($(window).width() <= 500) {
$('.preview-img-listAQ').followTo($('.breaker'), 60);
}
$(function () {
var wandImgDir = '/wp-content/uploads/2015/11/';
var wands = [
'burgundy',
'metallicburgundy',
'cabernet',
'metallicred',
'red',
'metallicpink',
'pink',
'azalea',
'coral',
'hotpink',
'tangerine',
'orange',
'peach',
'daffodil',
'lightyellow',
'limegreen',
'mint',
'emerald',
'teal',
'hunter',
'sage',
'seafoam',
'celedon',
'turquoise',
'aqua',
'babyblue',
'cornflower',
'periwinkle',
'royalblue',
'metallicblue',
'navy',
'purple',
'metallicpurple',
'lavender',
'metallichotpink',
'eggplant',
'brown',
'mustard',
'gold',
'irridescentwhite',
'ivory',
'white',
'silver',
'black'
];
$('.preview-link').click(function () {
var wandId = $(this).attr('id_node') - 1;
$("#wandswap").attr('src', wandImgDir+wands[wandId]+'-wand.jpg');
});
});
}
})(jQuery);