/** * Main Salient script file. * * @package Salient * @author ThemeNectar */ /* global jQuery */ /* global Waypoint */ /* global imagesLoaded */ /* global Flickity */ (function($, window, document) { "use strict"; // Theme vars. var $window = $(window), $body = $('body'), $offCanvasEl = $('#slide-out-widget-area'), $offCanvasBG = $('#slide-out-widget-area-bg'), $headerOuterEl = $('#header-outer'), $headerSecondaryEl = $('#header-secondary-outer'), $searchButtonEl = $('#header-outer #search-btn a'), $wpAdminBar = $('#wpadminbar'), $loadingScreenEl = $('#ajax-loading-screen'), $bodyBorderTop = $('.body-border-top'), $pageHeaderBG = $('#page-header-bg'), $footerOuterEl = $('#footer-outer'), $bodyBorderWidth = ($('.body-border-right').length > 0) ? $('.body-border-right').width() : 0, $logoHeight = ($headerOuterEl.is('[data-logo-height]')) ? parseInt($headerOuterEl.attr('data-logo-height')) : 30, headerPadding = ($headerOuterEl.is('[data-padding]')) ? parseInt($headerOuterEl.attr('data-padding')) : 28, logoShrinkNum = ($headerOuterEl.is('[data-shrink-num]')) ? $headerOuterEl.attr('data-shrink-num') : 6, condenseHeaderLayout = ($headerOuterEl.is('[data-condense="true"]')) ? true : false, usingLogoImage = ($headerOuterEl.is('[data-using-logo="1"]')) ? true : false, headerResize = ($headerOuterEl.is('[data-header-resize="1"]')) ? true : false, headerTransparent = ($headerOuterEl.is('[data-transparent-header="true"]')) ? true : false, headerLayoutFormat = ($body.is('[data-header-format]')) ? $body.attr('data-header-format') : 'default', headerHideUntilNeeded = ($body.is('[data-hhun]')) ? $body.attr('data-hhun') : '', $animationEasing = ($body.is('[data-cae]') && $body.attr('data-cae') !== 'swing' ) ? $body.attr('data-cae') : 'easeOutCubic', $animationDuration = ($body.is('[data-cad]')) ? $body.attr('data-cad') : '650', bypassAnimations = (!$body.is('[data-m-animate="1"]') && navigator.userAgent.match(/(Android|iPod|iPhone|iPad|BlackBerry|IEMobile|Opera Mini)/) ) ? true : false, $portfolio_containers = [], $svgIcons = [], $nectarCustomSliderRotate = [], $flickitySliders = [], flickityDragArr = [], viewIndicatorArr = [], iconMouseFollowArr = [], postGridImgMouseFollowArr = [], $fsProjectSliderArr = [], $wooFlickityCarousels = [], $liquidBG_EL = [], $testimonialSliders = [], $mouseParallaxScenes = [], $nectarMasonryBlogs = [], $standAnimatedColTimeout = [], $animatedSVGIconTimeout = [], $projectCarouselSliderArr = [], $nectarPostGridArr = [], $verticalScrollingTabs = [], $tabbedClickCount = 0, $fullscreenSelector = '', $fullscreenMarkupBool = false, $bodyBorderHeaderColorMatch = false, nectarBoxRoll = { animating: 'false', perspect: 'not-rolled' }, $nectarFullPage = { $usingFullScreenRows: false }, $svgResizeTimeout, $bodyBorderSizeToRemove; if( $bodyBorderTop.length > 0 ) { if ( $bodyBorderTop.css('background-color') == '#ffffff' && $body.attr('data-header-color') == 'light' || $bodyBorderTop.css('background-color') == 'rgb(255, 255, 255)' && $body.attr('data-header-color') == 'light' || $bodyBorderTop.css('background-color') == $headerOuterEl.attr('data-user-set-bg')) { $bodyBorderHeaderColorMatch = true; } } /** * Nectar DOM info helper. * * @since 9.0 */ var nectarDOMInfo = { usingMobileBrowser: (navigator.userAgent.match(/(Android|iPod|iPhone|iPad|BlackBerry|IEMobile|Opera Mini)/)) ? true : false, usingFrontEndEditor: (typeof window.vc_iframe === 'undefined') ? false : true, getWindowSize: function() { nectarDOMInfo.winH = window.innerHeight; nectarDOMInfo.winW = window.innerWidth; nectarDOMInfo.adminBarHeight = ($wpAdminBar.length > 0) ? $wpAdminBar.height() : 0; nectarDOMInfo.secondaryHeaderHeight = ($headerSecondaryEl.length > 0 && $headerSecondaryEl.css('display') != 'none') ? $headerSecondaryEl.outerHeight() : 0; nectarDOMInfo.footerOuterHeight = ($footerOuterEl.length > 0) ? $footerOuterEl.outerHeight() : 0; }, scrollTop: 0, clientX: 0, clientY: 0, scrollPosMouse: function() { return $window.scrollTop(); }, scrollPosRAF: function() { nectarDOMInfo.scrollTop = $window.scrollTop(); requestAnimationFrame(nectarDOMInfo.scrollPosRAF); }, bindEvents: function() { if (!nectarDOMInfo.usingMobileBrowser) { $window.on('scroll', function() { nectarDOMInfo.scrollTop = nectarDOMInfo.scrollPosMouse(); }); } else { requestAnimationFrame(nectarDOMInfo.scrollPosRAF); } document.addEventListener("mousemove", function(e) { nectarDOMInfo.clientX = e.clientX; nectarDOMInfo.clientY = e.clientY; }); $window.on('resize', nectarDOMInfo.getWindowSize); }, init: function() { // Re-cache WP admin bar after DOM ready $wpAdminBar = $('#wpadminbar'); // Get values and bind events this.getWindowSize(); this.scrollTop = this.scrollPosMouse(); this.bindEvents(); this.usingFrontEndEditor = (typeof window.vc_iframe === 'undefined') ? false : true; } }; /** * Debounced resize event * * @since 2.0 */ function smartResizeInit() { fullWidthContentColumns(); parallaxRowsBGCals(); headerSpace(); OCM_overflowState(); showOnLeftSubMenu(); } /** * Main resize event. * * @since 2.0 */ function resizeInit() { fullWidthSections(); fullWidthContentColumns(); addOrRemoveSF(); responsiveVideoIframes(); if (!nectarDOMInfo.usingMobileBrowser) { parallaxRowsBGCals(); } } /** * Flexslider plugin initialization. * * @since 5.0 */ function flexsliderInit() { $('.flex-gallery').each(function () { if (!$().flexslider) { return; } var $that = $(this); imagesLoaded($(this), function () { $that.flexslider({ animation: 'fade', smoothHeight: false, animationSpeed: 500, useCSS: false, touch: true }); //gallery slider add arrows $('.flex-gallery .flex-direction-nav li a.flex-next').html(''); $('.flex-gallery .flex-direction-nav li a.flex-prev').html(''); }); }); } /** * Icon follow. * * @since 11.0 */ function NectarIconMouseFollow($el, iconType) { this.lastX = nectarDOMInfo.clientX; this.lastY = nectarDOMInfo.clientY; this.$el = $el; this.iconType = iconType; this.timeout = false; this.overEl = false; this.$dragEl = ''; this.$viewEl = ''; this.$closeEl = ''; this.lerpDamp = 0.18; this.createMarkup(); this.mouseBind(); } NectarIconMouseFollow.prototype.createMarkup = function() { if( this.iconType === 'horizontal-movement' ) { if( $('.nectar-drag-indicator').length == 0 ) { var $usingBoxedClass = ($('body > #boxed').length > 0) ? ' in-boxed' : ''; $('body').append('
'); this.$dragEl = $('.nectar-drag-indicator'); this.dragRAF(); } else { this.$dragEl = $('.nectar-drag-indicator'); } } if( this.iconType === 'view-indicator' ) { if( $('.nectar-view-indicator').length == 0 ) { var $usingBoxedClass = ($('body > #boxed').length > 0) ? ' in-boxed' : ''; $('body').append('
'); $('.nectar-view-indicator span').text( $('.nectar-post-grid').attr('data-indicator-text') ); this.$viewEl = $('.nectar-view-indicator'); this.viewRAF(); } else { this.$viewEl = $('.nectar-view-indicator'); } } if( this.iconType === 'close-indicator' ) { if( $('.nectar-view-indicator').length == 0 ) { var $usingBoxedClass = ($('body > #boxed').length > 0) ? ' in-boxed' : ''; $('body').append('
'); this.$closeEl = $('.nectar-close-indicator'); this.closeRAF(); } else { this.$closeEl = $('.nectar-close-indicator'); } } if( this.iconType === 'post-grid-images' ) { if( !this.$el.hasClass('mouse-move-bound') ) { this.$viewEl = this.$el.find('.nectar-post-grid-item-bg-wrap'); this.$el.addClass('mouse-move-bound'); this.viewRAF(); } else { this.$viewEl = this.$el.find('.nectar-post-grid-item-bg-wrap'); this.viewRAF(); } } } NectarIconMouseFollow.prototype.mouseBind = function() { var that = this; if( this.iconType === 'horizontal-movement' ) { that.$el.find('.flickity-viewport').on('mouseenter', function() { that.$dragEl.addClass('visible'); }); that.$el.find('.flickity-viewport').on('mouseleave', function() { that.$dragEl.removeClass('visible'); }); } else if( this.iconType === 'close-indicator' ) { $('body').on('click','.team-member[data-style*="bio_fullscreen"]',function(){ if ($('.nectar_team_member_overlay:not(.open)').length > 0) { return; } that.$closeEl.addClass('visible'); that.$closeEl.find('.inner').addClass('visible'); }); $('body').on('click','.nectar_team_member_overlay:not(.animating)',function(){ that.$closeEl.removeClass('visible'); that.$closeEl.find('.inner').removeClass('visible'); }); // Handle social links. $('body').on('mouseenter', '.nectar_team_member_overlay .bottom_meta a', function() { that.$closeEl.removeClass('visible'); }); $('body').on('mouseleave', '.nectar_team_member_overlay .bottom_meta a', function() { that.$closeEl.addClass('visible'); }); } else if( this.iconType === 'view-indicator' ) { var $color = that.$el.attr('data-indicator-color'); var $style = that.$el.attr('data-indicator-style'); // unbind first. that.$el.find('.nectar-post-grid-item').off(); that.$el.find('.nectar-post-grid-item').on('mouseenter', function() { that.$viewEl.addClass('visible'); // Handle style class. that.$viewEl.attr('class', function(i, c){ return c.replace(/(^|\s)style-\S+/g, ''); }); that.$viewEl.addClass('style-'+$style); if( $style !== 'see-through' ) { that.$viewEl.find('.color-circle').css('background-color', $color); } clearTimeout(that.timeout); }); that.$el.find('.nectar-post-grid-item').on('mouseleave', function() { that.timeout = setTimeout(function(){ that.$viewEl.removeClass('visible'); },100); }); // Handle category links. that.$el.find('.nectar-post-grid-item .meta-category a').on('mouseenter', function() { that.$viewEl.removeClass('visible'); }); that.$el.find('.nectar-post-grid-item .meta-category a').on('mouseleave', function() { that.$viewEl.addClass('visible'); }); } else if( this.iconType === 'post-grid-images' ) { that.$el.on('mouseenter', function() { $(this).addClass('mouse-over'); }); that.$el.on('mouseleave', function() { $(this).removeClass('mouse-over'); }); } }; NectarIconMouseFollow.prototype.dragRAF = function() { this.lastY = linearInterpolate(this.lastY, nectarDOMInfo.clientY, this.lerpDamp); this.lastX = linearInterpolate(this.lastX, nectarDOMInfo.clientX, this.lerpDamp); this.$dragEl.css({ 'transform': 'translateX(' + this.lastX + 'px) translateY(' + this.lastY + 'px)' }); requestAnimationFrame(this.dragRAF.bind(this)); }; NectarIconMouseFollow.prototype.viewRAF = function() { this.lastY = linearInterpolate(this.lastY, nectarDOMInfo.clientY, this.lerpDamp); this.lastX = linearInterpolate(this.lastX, nectarDOMInfo.clientX, this.lerpDamp); this.$viewEl.css({ 'transform' : 'translateX(' + this.lastX + 'px) translateY(' + this.lastY + 'px)' }); requestAnimationFrame(this.viewRAF.bind(this)); }; NectarIconMouseFollow.prototype.closeRAF = function() { this.lastY = linearInterpolate(this.lastY, nectarDOMInfo.clientY, this.lerpDamp); this.lastX = linearInterpolate(this.lastX, nectarDOMInfo.clientX, this.lerpDamp); this.$closeEl.css({ 'transform': 'translateX(' + this.lastX + 'px) translateY(' + this.lastY + 'px)' }); requestAnimationFrame(this.closeRAF.bind(this)); }; /** * Flickity lazy image helper * * Needed to calculate the space which * lazy loaded images will eventually occupy. * * @since 11.0 */ function flickityLazyCalcs() { $('.wpb_gallery_slidesflickity_static_height_style .cell[data-lazy="true"]').each(function() { $(this).css({ 'height': '', 'width' : '' }); var heightAttr = parseInt($(this).find('img').attr('height')); var widthAttr = parseInt($(this).find('img').attr('width')); var dimensions = calculateAspectRatio( widthAttr, heightAttr, 2000, parseInt($(this).find('img').height()) ); $(this).css({ 'height': dimensions.height + 'px', 'width' : dimensions.width + 'px' }); }); } /** * Flickity lazy initialization. * * @since 11.0 */ function flickityLazyInit() { // Lazy assist. if( $('.wpb_gallery_slidesflickity_static_height_style .cell[data-lazy="true"]').length > 0 ) { flickityLazyCalcs(); $window.on('smartresize',flickityLazyCalcs); } } /** * Flickity plugin initialization. * * @since 7.0 */ function flickityInit() { if ($('.nectar-flickity:not(.masonry)').length == 0) { return false; } $flickitySliders = []; flickityDragArr = []; $('.nectar-flickity:not(.masonry)').each(function (i) { $(this).removeClass(function (index, className) { return (className.match(/(^|\s)instance-\S+/g) || []).join(' '); }); $(this).addClass('instance-' + i); var $freeScrollBool = ($(this).is('[data-free-scroll]') && $(this).attr('data-free-scroll') == 'true') ? true : false, $groupCellsBool = true, $flickContainBool = true, $flcikAttr = 0.025, $paginationBool = false, $nextPrevArrowBool = true, $flickCellAlign = 'center'; if ($(this).is('[data-format="fixed_text_content_fullwidth"]')) { $flickCellAlign = 'left'; $groupCellsBool = false; $flickContainBool = false; $flcikAttr = 0.02; if( $(this).parent().is('[data-alignment="right"]') ) { $flickCellAlign = 'right'; } } if ($freeScrollBool == true ) { $groupCellsBool = false; } if ($(this).attr('data-controls').length > 0 && $(this).attr('data-controls') == 'next_prev_arrows'|| $(this).attr('data-controls').length > 0 && $(this).attr('data-controls') == 'next_prev_arrows_overlaid') { $paginationBool = false; $nextPrevArrowBool = true; } else { $paginationBool = true; $nextPrevArrowBool = false; } if ($(this).attr('data-controls').length > 0 && $(this).attr('data-controls') == 'none') { $paginationBool = false; $nextPrevArrowBool = false; } var $flickity_autoplay = false; if ($(this).is('[data-autoplay]') && $(this).attr('data-autoplay') == 'true') { $flickity_autoplay = true; if ($(this).is('[data-autoplay-dur]') && $(this).attr('data-autoplay-dur').length > 0) { if (parseInt($(this).attr('data-autoplay-dur')) > 100 && parseInt($(this).attr('data-autoplay-dur')) < 30000) { $flickity_autoplay = parseInt($(this).attr('data-autoplay-dur')); } } } var $that = $(this); var $frontEndEditorDrag = ($('body.vc_editor').length > 0) ? false : true; var $frontEndEditorPause = ($('body.vc_editor').length > 0) ? true : false; var $arrowShape = ''; var $wrapAround = ( $(this).is('[data-wrap]') && $(this).attr('data-wrap') == 'no-wrap' ) ? false : true; // Adaptive height. var $flickity_adaptive_height = false; if( $(this).is('[data-adaptive-height="true"]') ) { $flickity_adaptive_height = true; } // Lazy load. var $lazyload = ($(this).find('img[data-flickity-lazyload]')) ? 1 : false; if( $(this).find('img[data-flickity-lazyload]') && $(this).is('[data-overflow="visible"]') && $(this).is('[data-wrap="no-wrap"]') ) { $lazyload = 2; } // RTL. var $flickity_rtl = ( $body.hasClass('rtl') ) ? true : false; // Arrow shape. if( $(this).attr('data-controls').length > 0 && $(this).attr('data-controls') == 'next_prev_arrows_overlaid' || $(this).attr('data-controls').length > 0 && $(this).attr('data-controls') == 'touch_total' ) { $arrowShape = { x0: 10, x1: 60, y1: 50, x2: 70, y2: 40, x3: 30 } } else { $arrowShape = { x0: 20, x1: 70, y1: 30, x2: 70, y2: 25, x3: 70 } } $flickitySliders[i] = new Flickity('.nectar-flickity.instance-' + i, { contain: $flickContainBool, draggable: $frontEndEditorDrag, lazyLoad: $lazyload, imagesLoaded: true, percentPosition: true, adaptiveHeight: $flickity_adaptive_height, cellAlign: $flickCellAlign, groupCells: $groupCellsBool, prevNextButtons: $nextPrevArrowBool, freeScroll: $freeScrollBool, pageDots: $paginationBool, resize: true, selectedAttraction: $flcikAttr, autoPlay: $flickity_autoplay, rightToLeft: $flickity_rtl, pauseAutoPlayOnHover: $frontEndEditorPause, setGallerySize: true, wrapAround: $wrapAround, accessibility: false, arrowShape: $arrowShape }); // Visualized total controls if( $(this).is('[data-controls="touch_total"]') ) { // Create markup. if( $(this).find('.visualized-total').length == 0 ) { if( $(this).parents('.full-width-content').length > 0 && $(this).parents('.vc_col-sm-12').length > 0 ) { $(this).append('
'); } else { $(this).append('
'); } } // Init drag indicator. if( !nectarDOMInfo.usingMobileBrowser ) { flickityDragArr[i] = new NectarIconMouseFollow($(this),'horizontal-movement'); $flickitySliders[i].on('dragMove', function (event, pointer) { nectarDOMInfo.clientY = pointer.clientY; nectarDOMInfo.clientX = pointer.clientX; }); $flickitySliders[i].on('pointerDown', function (event, pointer) { $('.nectar-drag-indicator').addClass('pointer-down'); }); $flickitySliders[i].on('pointerUp', function (event, pointer) { $('.nectar-drag-indicator').removeClass('pointer-down'); }); } var $totalImgs = $(this).find('.flickity-page-dots li').length; var $totalIndicator = $(this).find('.visualized-total span'); var $totalPosition = 1; var $totalWidth = $(this).find('.visualized-total').width(); $window.on('smartresize',function() { setTimeout(function() { $totalImgs = $that.find('.flickity-page-dots li').length; $totalWidth = $that.find('.visualized-total').width(); $totalPosition = ($totalWidth / $totalImgs) * $that.find('.flickity-page-dots .is-selected').index(); // Update pos on interaction. $totalIndicator.css('width', 100/$totalImgs + '%'); $totalIndicator.css({ 'x' : $totalPosition + 'px' }); },200); }); // Set initial total tracker width. setTimeout(function(){ $totalImgs = $that.find('.flickity-page-dots li').length; $totalWidth = $that.find('.visualized-total').width(); $totalIndicator.css('width', 100/$totalImgs + '%'); },200); $flickitySliders[i].on('change', function (event, progress) { $totalPosition = ($totalWidth / $totalImgs) * $that.find('.flickity-page-dots .is-selected').index(); // Update pos on interaction. $totalIndicator.css({ 'x' : $totalPosition + 'px' }); }); } // Fixed text content style if ($(this).is('[data-format="fixed_text_content_fullwidth"]') && !nectarDOMInfo.usingFrontEndEditor) { var $onMobileBrowser = nectarDOMInfo.usingMobileBrowser; $flickitySliders[i].on('scroll', function () { if ($onMobileBrowser) { return; } var $flkSlideWidth = $that.find('.cell').outerWidth() + 25, $leftHeaderSize = ($('body[data-header-format="left-header"]').length > 0 && $window.width() > 1000) ? 275 : 0, $extraWindowSpace = (($window.width() + $leftHeaderSize) - $that.parents('.main-content').width()) / 2; $extraWindowSpace += parseInt($that.css('margin-left')) + 2; $flickitySliders[i].slides.forEach(function (slide, j) { var $scaleAmt = 1, $translateXAmt = 0, $rotateAmt = 0, $slideZIndex = 10, $opacityAmt = 1, $slideOffset = $(slide.cells[0].element).offset().left, flkInstanceSlide = $('.nectar-flickity.instance-' + i + ' .cell:nth-child(' + (j + 1) + ')'); if ($slideOffset - $extraWindowSpace < 0 && $slideOffset - $extraWindowSpace > $flkSlideWidth * -1) { $scaleAmt = 1 + (($slideOffset - $extraWindowSpace) / 1500); $opacityAmt = 1 + (($slideOffset - $extraWindowSpace + 70) / 550); $translateXAmt = (($slideOffset - $extraWindowSpace)) * -1; $rotateAmt = (($slideOffset - $extraWindowSpace) / 25) * -1; } else { $scaleAmt = 1; $opacityAmt = 1; $translateXAmt = 0; $rotateAmt = 0; } if ($slideOffset + 5 - $extraWindowSpace < 0 && $slideOffset - $extraWindowSpace > $flkSlideWidth * -1) { $slideZIndex = 5; } else { $slideZIndex = 10; } flkInstanceSlide.css({ 'z-index': $slideZIndex }); flkInstanceSlide.find('.inner-wrap-outer').css({ 'transform': 'perspective(800px) translateX(' + $translateXAmt + 'px) rotateY(' + $rotateAmt + 'deg) translateZ(0)', 'opacity': $opacityAmt }); flkInstanceSlide.find('.inner-wrap').css({ 'transform': 'scale(' + $scaleAmt + ') translateZ(0)' }); }); }); } var $removeHiddenTimeout; var $removeMovingTimeout; $flickitySliders[i].on('dragStart', function () { clearTimeout($removeHiddenTimeout); clearTimeout($removeMovingTimeout); $that.addClass('is-dragging'); $that.addClass('is-moving'); $that.find('.flickity-prev-next-button').addClass('hidden'); }); $flickitySliders[i].on('dragEnd', function () { $that.removeClass('is-dragging'); $removeHiddenTimeout = setTimeout(function () { $that.removeClass('is-moving'); $that.find('.flickity-prev-next-button').removeClass('hidden'); }, 600); $removeMovingTimeout = setTimeout(function () { $that.removeClass('is-moving'); }, 300); }); $('.flickity-prev-next-button').on('click', function () { clearTimeout($removeHiddenTimeout); $(this).parents('.nectar-flickity') .find('.flickity-prev-next-button') .addClass('hidden'); $removeHiddenTimeout = setTimeout(function () { $that .find('.flickity-prev-next-button') .removeClass('hidden'); }, 600); }); // Images loaded. if ($that.hasClass('nectar-carousel')) { imagesLoaded($that, function () { nectarCarouselFlkEH($that); }); } }); // Resize event. var $usingNectarCarouselFlk = ($('.nectar-carousel.nectar-flickity:not(.masonry)').length > 0) ? true : false; if ($usingNectarCarouselFlk) { $window.on('resize',setNectarCarouselFlkEH); } } /** * Flickity equal height helper. * * @since 7.0 */ function setNectarCarouselFlkEH() { $('.nectar-carousel.nectar-flickity:not(.masonry)').each(function () { nectarCarouselFlkEH($(this)); }); } /** * Flickity equal height calculations. * * @since 7.0 */ function nectarCarouselFlkEH($slider_instance) { var $tallestSlideCol = 0; $slider_instance .find('.flickity-slider > .cell') .css('height', 'auto'); $slider_instance.find('.flickity-slider > .cell').each(function () { if( $(this).height() > $tallestSlideCol ) { $tallestSlideCol = $(this).height(); } }); if ($tallestSlideCol < 10) { $tallestSlideCol = 'auto'; } //set even height $slider_instance .find('.flickity-slider > .cell') .css('height', $tallestSlideCol + 'px'); } /** * twentytwenty plugin initialization. * * @since 7.0 */ function twentytwentyInit() { $('.twentytwenty-container').each(function () { var $that = $(this); if ($that.find('.twentytwenty-handle').length == 0) { $(this).imagesLoaded(function () { $that.twentytwenty(); }); } }); } /** * Superfish initialization and submenu functionality. * * @since 2.0 */ function initSF() { addOrRemoveSF(); if ($('body[data-header-format="left-header"]').length == 0) { var $disableHI; if (!($('#header-outer[data-megamenu-rt="1"]').length > 0 && $('#header-outer[data-transparent-header="true"]').length > 0)) { $disableHI = true; } else { $disableHI = false; } $(".sf-menu:not(.buttons)").superfish({ delay: 650, speed: 'fast', disableHI: $disableHI, speedOut: 'fast', animation: { opacity: 'show' } }); // Pull right/left menu $('#header-outer .sf-menu.buttons li.menu-item').on('mouseover',function(){ $(this).addClass('sfHover'); }); $('#header-outer .sf-menu.buttons li.menu-item').on('mouseleave',function(){ var $that = $(this); if( $that.is('.menu-item-has-children') ) { setTimeout(function () { if( !$that.is(':hover') ) { $that.removeClass('sfHover'); } }, 200); } else { $that.removeClass('sfHover'); } }); // Areas that do not use megamenu. $('#header-secondary-outer li.megamenu, .sf-menu.buttons li.megamenu').removeClass('megamenu'); $('#header-outer .sf-menu > li:not(.megamenu) > ul > li > ul').each(function () { if ($(this).offset().left + $(this).outerWidth() > $window.width()) { $(this).addClass('on-left-side'); $(this).find('ul').addClass('on-left-side'); } }); // Megamenu multi section per column title support. $('body:not([data-header-format="left-header"]) header#top nav > ul > li.megamenu > ul > li > ul > li:has("> ul")').addClass('has-ul'); // Full width megamenu. if ($('body[data-megamenu-width="full-width"]').length > 0 && $('ul.sub-menu').length > 0) { megamenuFullwidth(); $window.on('smartresize', megamenuFullwidth); $('header#top nav > ul > li.megamenu > .sub-menu').css('box-sizing', 'content-box'); } // Extra hover class for megamenu check. $('header#top nav > ul.sf-menu > li.menu-item').on('mouseenter', function () { $(this).addClass('menu-item-over'); }); $('header#top nav > ul.sf-menu > li.menu-item').on('mouseleave', function () { $(this).removeClass('menu-item-over'); }); // Remove arrows on mega menu item. $('header#top nav .megamenu .sub-menu a.sf-with-ul .sf-sub-indicator, header#top .megamenu .sub-menu a .sf-sub-indicator').remove(); // Blank title megamenu columns. $('header#top nav > ul > li.megamenu > ul.sub-menu > li > a').each(function () { if ($(this).text() == '-' || $(this).text() == '–' || $(this).parent().hasClass('hide-title')) { $(this).remove(); } }); } // Deactivate hide header until needed effect on phone. if (nectarDOMInfo.usingMobileBrowser && $('#header-outer[data-remove-fixed="1"]').length == 0) { $body.attr('data-hhun', '0'); } } /** * Calculates the "Header Mega Menu Width - Full screen width" theme option. * * @since 6.0 */ function megamenuFullwidth() { var $windowWidth = $window.width(); var $headerContainerWidth = $('header#top > .container').width(); $('header#top nav > ul > li.megamenu > .sub-menu').css({ 'padding-left': ($windowWidth - $headerContainerWidth) / 2 + 'px', 'padding-right': ($windowWidth + 2 - $headerContainerWidth) / 2 + 'px', 'width': $headerContainerWidth, 'left': '-' + ($windowWidth - $headerContainerWidth) / 2 + 'px' }); } /** * Hide main navigation on mobile. * * @since 2.0 */ function addOrRemoveSF() { if (nectarDOMInfo.winW < 1000 && $body.attr('data-responsive') == '1') { $body.addClass('mobile'); $('header#top nav').css('display', 'none'); } else { $body.removeClass('mobile'); $('header#top nav').css('display', ''); $('.slide-out-widget-area-toggle #toggle-nav .lines-button').removeClass('close'); } } /** * Calculates whether submenu needs to display aligned opposite (from lack of space). * * @since 2.0 */ function showOnLeftSubMenu() { // Show on left class for minimal styling. $('#header-outer .sf-menu > li:not(.megamenu) > ul > li > ul').each(function () { $(this).removeClass('on-left-side'); if ($(this).offset().left + $(this).outerWidth() > $window.width()) { $(this).addClass('on-left-side'); $(this).find('ul').addClass('on-left-side'); } else { $(this).removeClass('on-left-side'); $(this).find('ul').removeClass('on-left-side'); } }); } /** * Caroufredsel plugin initialization. * * @since 2.0 */ function standardCarouselInit() { if ($('.carousel').length == 0) { return; } if (typeof SalientRecentProjectsCarousel !== 'undefined') { $('ul.carousel.portfolio-items').each(function (i) { $projectCarouselSliderArr[i] = new SalientRecentProjectsCarousel($(this)); }); } $('ul.carousel:not(".clients"):not(.portfolio-items)').each(function () { var $that = $(this), maxCols = ($(this).parents('.carousel-wrap').attr('data-full-width') == 'true') ? 'auto' : 3, scrollNum = ($(this).parents('.carousel-wrap').attr('data-full-width') == 'true') ? 'auto' : '', colWidth = ($(this).parents('.carousel-wrap').attr('data-full-width') == 'true') ? 500 : 453, $autoplayBool = ($(this).attr('data-autorotate') == 'true') ? true : false, $themeSkin = true, $themeSkin2 = true; var scrollSpeed, easing; if ($('body.ascend').length > 0 && $(this).parents('.carousel-wrap').attr('data-full-width') != 'true' || $('body.material').length > 0 && $(this).parents('.carousel-wrap').attr('data-full-width') != 'true') { if ($(this).find('li').length % 3 === 0) { $themeSkin = true; $themeSkin2 = true; } else { $themeSkin = false; $themeSkin2 = true; } } else { $themeSkin = true; $themeSkin2 = true; } scrollSpeed = (parseInt($(this).attr('data-scroll-speed'))) ? parseInt($(this).attr('data-scroll-speed')) : 700; easing = ($(this).is('[data-easing]')) ? $(this).attr('data-easing') : 'linear'; var $element = $that; if ($that.find('img').length == 0) { $element = $body; } imagesLoaded($element, function () { $that.carouFredSel({ circular: $themeSkin, infinite: $themeSkin2, height: 'auto', responsive: true, items: { width: colWidth, visible: { min: 1, max: maxCols } }, swipe: { onTouch: true, onMouse: true, options: { excludedElements: "button, input, select, textarea, .noSwipe", tap: function (event, target) { if ($(target).attr('href') && !$(target).is('[target="_blank"]') && !$(target).is('[rel^="prettyPhoto"]') && !$(target).is('.magnific-popup') && !$(target).is('.magnific')) { window.open($(target).attr('href'), '_self'); } } }, onBefore: function () { // Hover effect. $that.find('.work-item').trigger('mouseleave'); $that.find('.work-item .work-info a').trigger('mouseup'); } }, scroll: { items: scrollNum, easing: easing, duration: scrollSpeed, onBefore: function () { if ($('body.ascend').length > 0 && $that.parents('.carousel-wrap').attr('data-full-width') != 'true' || $('body.material').length > 0 && $that.parents('.carousel-wrap').attr('data-full-width') != 'true') { $that.parents('.carousel-wrap') .find('.item-count .total') .html(Math.ceil($that.find('> li').length / $that.triggerHandler("currentVisible").length)); } }, onAfter: function () { if ($('body.ascend').length > 0 && $that.parents('.carousel-wrap').attr('data-full-width') != 'true' || $('body.material').length > 0 && $that.parents('.carousel-wrap').attr('data-full-width') != 'true') { $that.parents('.carousel-wrap') .find('.item-count .current') .html($that.triggerHandler('currentPage') + 1); $that.parents('.carousel-wrap') .find('.item-count .total') .html(Math.ceil($that.find('> li').length / $that.triggerHandler("currentVisible").length)); } } }, prev: { button: function () { return $that.parents('.carousel-wrap').find('.carousel-prev'); } }, next: { button: function () { return $that.parents('.carousel-wrap').find('.carousel-next'); } }, auto: { play: $autoplayBool } }, { transition: true }).animate({ 'opacity': 1 }, 1300); $that .parents('.carousel-wrap') .wrap('