/** * 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, headerMobileFixed = ($headerOuterEl.is('[data-mobile-fixed="1"]')) ? 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 = [], parallaxItemsArr = [], $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.scrollY || $window.scrollTop(); }, scrollPosRAF: function() { nectarDOMInfo.scrollTop = window.scrollY || $window.scrollTop(); requestAnimationFrame(nectarDOMInfo.scrollPosRAF); }, bindEvents: function() { if (!nectarDOMInfo.usingMobileBrowser) { $window.on('scroll', function() { nectarDOMInfo.scrollTop = nectarDOMInfo.scrollPosMouse(); }); document.addEventListener("mousemove", function(e) { nectarDOMInfo.clientX = e.clientX; nectarDOMInfo.clientY = e.clientY; }); } else { requestAnimationFrame(nectarDOMInfo.scrollPosRAF); } $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; } }; window.nectarDOMInfo = nectarDOMInfo; /** * Nectar State. * * @since 13.0 */ var nectarState = { materialOffCanvasOpen: false, materialSearchOpen: false, permanentTransHeader: ( $headerOuterEl.is('[data-permanent-transparent="1"]') ) ? true : false, animatedScrolling: false, preventScroll: false, mobileHeader: '' } /** * Debounced resize event * * @since 2.0 */ function smartResizeInit() { fullWidthContentColumns(); if (!nectarDOMInfo.usingMobileBrowser) { parallaxRowsBGCals(); } headerSpace(); OCM_overflowState(); showOnLeftSubMenu(); inlineMegaMenuPos(); } /** * Orientation change event. * * @since 13.0 */ function orientationChangeInit() { parallaxRowsBGCals(); } /** * 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 () { var autorotate = ($that.find('ul').is('[data-d-autorotate="true"]')) ? false : true; $that.flexslider({ animation: 'fade', smoothHeight: false, animationSpeed: 500, useCSS: false, touch: true, slideshow: autorotate, }); //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.initialCalc = false; this.bgElSelector = ''; this.$dragEl = ''; this.$viewEl = ''; this.$closeEl = ''; this.lerpDamp = 0.18; this.createMarkup(); this.setup(); this.mouseBind(); } NectarIconMouseFollow.prototype.setup = function() { if( this.iconType === 'post-grid-images' ) { this.viewportTracking(); } }; NectarIconMouseFollow.prototype.viewportTracking = function() { var that = this; if( 'IntersectionObserver' in window ) { var options = { rootMargin: '0px', threshold: 0 } this.observer = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if ( entry.isIntersecting ) { that.$el.addClass('active'); that.$el.find( that.bgElSelector ).css('visibility','visible'); that.activeViewRAF = true; } else { that.$el.find( that.bgElSelector ).css('visibility','hidden'); that.activeViewRAF = false; } }); }, options); this.observer.observe(this.$el[0]); } }; NectarIconMouseFollow.prototype.createMarkup = function() { var that = this; 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' ) { this.activeViewRAF = true; if( $('.nectar-view-indicator').length == 0 ) { var $usingBoxedClass = ($('body > #boxed').length > 0) ? ' in-boxed' : ''; $('body').append('
'); if( this.iconType !== 'gallery-zoom-indicator' ) { $('.nectar-view-indicator span').text( $('.nectar-post-grid').attr('data-indicator-text') ); } this.$viewEl = $('.nectar-view-indicator'); // initial calc. setTimeout(function(){ that.lastY = nectarDOMInfo.clientY; that.lastX = nectarDOMInfo.clientX; that.viewRAF(); },100); } 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' ) { this.activeViewRAF = true; this.bgElSelector = (!this.$el.hasClass('nectar-category-grid')) ? '.nectar-post-grid-item-bg-wrap' : '.nectar-category-grid-item-bg'; if( !this.$el.hasClass('mouse-move-bound') ) { this.$viewEl = this.$el.find( this.bgElSelector ); this.$el.addClass('mouse-move-bound'); this.viewRAF(); } else { this.$viewEl = this.$el.find( this.bgElSelector ); 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'); var $iconColor = (that.$el.is('[data-touch-icon-color]')) ? 'color-' + that.$el.attr('data-touch-icon-color') : ''; that.$dragEl.removeClass('color-dark').removeClass('color-light').removeClass('color-default'); that.$dragEl.addClass($iconColor); }); that.$el.find('.flickity-viewport').on('mouseleave', function() { that.$dragEl.removeClass('visible'); }); // Handle product links. that.$el.find('.product-add-to-cart a').on('mouseenter', function() { that.$dragEl.removeClass('visible'); }); that.$el.find('.product-add-to-cart a').on('mouseleave', function() { that.$dragEl.addClass('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 links. $('body').on('mouseenter', '.nectar_team_member_overlay .bio-inner a', function() { that.$closeEl.removeClass('visible'); }); $('body').on('mouseleave', '.nectar_team_member_overlay .bio-inner 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[0].style.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); if( this.activeViewRAF ) { for(var i=0; i < this.$viewEl.length; i++) { this.$viewEl[i].style.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()) ); var captionHeight = ( $(this).find('.item-meta').length > 0 ) ? $(this).find('.item-meta').outerHeight() : 0; $(this).css({ 'height': (dimensions.height + captionHeight) + '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, $setGallerySizeBool = true, $imagesLoaded = true, $flickCellAlign = 'center'; // Fixed Text Style. 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; } // Controls. 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; var $flickity_stored_autoplay = false; if ($(this).is('[data-autoplay]') && $(this).attr('data-autoplay') == 'true') { $flickity_autoplay = true; $flickity_stored_autoplay = 5000; 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')); $flickity_stored_autoplay = $flickity_autoplay; } } } 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; // Centered cells. if($(this).is('[data-centered-cells="true"]')) { $groupCellsBool = 1; } // 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]').length > 0) ? 1 : false; if( $(this).find('img[data-flickity-lazyload]').length > 0 && $(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' || $(this).hasClass('nectar-simple-slider') ) { $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 } } if( $(this).is('[data-format="fixed_text_content_fullwidth"]') && $(this).parents('.full-width-content.wpb_row').length > 0 ) { $(this).parents('.full-width-content.wpb_row') .removeClass('full-width-content') .addClass('full-width-section'); } // Nectar Simple Slider if( $(this).hasClass('nectar-simple-slider') ) { $flickity_adaptive_height = false; $paginationBool = false; $nextPrevArrowBool = false; $setGallerySizeBool = false; $wrapAround = false; $imagesLoaded = false; $flcikAttr = 0.022; if( $(this).attr('data-pagination') == 'true') { $paginationBool = true; } if( $(this).attr('data-wrap') == 'true') { $wrapAround = true; } } $flickitySliders[i] = new Flickity('.nectar-flickity.instance-' + i, { setGallerySize: $setGallerySizeBool, contain: $flickContainBool, draggable: $frontEndEditorDrag, lazyLoad: $lazyload, imagesLoaded: $imagesLoaded, 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, wrapAround: $wrapAround, accessibility: false, arrowShape: $arrowShape }); // Simple Slider Arrows if( $that.attr('data-arrows') == 'true' ) { if( $that.find('.flickity-prev-next-button').length == 0 ) { $that.append(''); $that.append(''); // Previous. $that.find('.flickity-prev-next-button.previous').on( 'click', function() { if( $wrapAround === false && $flickitySliders[i].selectedIndex == 0 && ( $flickitySliders[i].isAnimating == false || typeof $flickitySliders[i].isAnimating === 'undefined') ) { // Nudge. var currentX = $flickitySliders[i].x; anime({ targets: $flickitySliders[i], x: currentX + 100, duration: 350, easing: 'easeOutCubic' }); $flickitySliders[i].startAnimation(); } $flickitySliders[i].previous(); }); // Next. $that.find('.flickity-prev-next-button.next').on( 'click', function() { // Nudge. if( $wrapAround === false && $flickitySliders[i].selectedIndex == $flickitySliders[i].slides.length - 1 && $flickitySliders[i].isAnimating == false) { // Nudge. var currentX = $flickitySliders[i].x; anime({ targets: $flickitySliders[i], x: currentX - 100, duration: 350, easing: 'easeOutCubic' }); $flickitySliders[i].startAnimation(); } $flickitySliders[i].next(); }); } } // End Simple Slider Arrows. // Simple Slider Lazy Load. if( $that.find('[data-nectar-img-src]').length > 0 ) { var waypoint = new Waypoint({ element: $that, handler: function () { $that.find('[data-nectar-img-src]').each(function() { var entry = $(this)[0]; var imgSrc = entry.getAttribute('data-nectar-img-src'); entry.style.backgroundImage = "url('" + imgSrc + "')"; entry.classList.add('loaded'); }); waypoint.destroy(); }, offset: '95%' }); } // Simple Slider Parallax if( $(this).hasClass('nectar-simple-slider') && $(this).is('[data-parallax="true"]') ) { var slides = $(this).find('.cell'); var j = i; // limit time between slide changes when wrapping. if( $wrapAround === true ) { $that.find('.flickity-prev-next-button').on('click', function () { $that.addClass('disabled-nav'); setTimeout(function(){ $that.removeClass('disabled-nav'); },500); }); } // parallax effect. $flickitySliders[i].on('scroll', function () { $.each( $flickitySliders[i].slides, function(i,slide) { var imageBG = slides[i].querySelector('.bg-layer'); var content = slides[i].querySelector('.inner'); var flkty = $flickitySliders[j]; var x = 0; if( 0 === i ) { x = Math.abs( flkty.x ) > flkty.slidesWidth ? ( flkty.slidesWidth + flkty.x + flkty.slides[flkty.slides.length - 1 ].outerWidth + slide.target ) : ( slide.target + flkty.x ); } else if( i === flkty.slides.length - 1 ) { x = Math.abs( flkty.x ) + flkty.slides[i].outerWidth < flkty.slidesWidth ? ( slide.target - flkty.slidesWidth + flkty.x - flkty.slides[i].outerWidth ) : ( slide.target + flkty.x ); } else { x = slide.target + flkty.x; } imageBG.style.transform = 'translate3d(' + x * ( -1 / 2 ) + 'px,0,0)'; content.style.transform = 'translate3d(' + x * ( -1 / 4 ) + 'px,0,0)'; }); }); } // Simple Slider Pagination if( $(this).hasClass('nectar-simple-slider') && true == $paginationBool ) { $(this).find('.flickity-page-dots li').append(''); if( $flickity_stored_autoplay ) { $(this).find('.flickity-page-dots li circle.time').css('transition', 'stroke-dashoffset '+ (parseInt($flickity_stored_autoplay) + 100) +'ms linear, stroke 0.2s ease'); $(this).find('.flickity-page-dots li:first').addClass('no-trans'); setTimeout(function() { $that.find('.flickity-page-dots li:first').removeClass('no-trans'); },60); $flickitySliders[i].on('select', function (event) { $flickitySliders[i].playPlayer(); }); $flickitySliders[i].on('dragEnd', function (event) { $flickitySliders[i].playPlayer(); $that.find('.flickity-page-dots .is-selected').removeClass('no-trans'); }); $flickitySliders[i].on('dragStart', function (event) { $that.find('.flickity-page-dots .is-selected').addClass('no-trans'); }); } } // 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) { if( !nectarDOMInfo.usingMobileBrowser ) { $window.on('resize',setNectarCarouselFlkEH); } else { window.addEventListener("orientationchange", setNectarCarouselFlkEH); } } var handleCaptions = ( $('.wpb_gallery_slidesflickity_static_height_style .item-meta').length > 0 ) ? true : false; if( handleCaptions ) { $window.on('resize', setNectarFlickityCaptions); setNectarFlickityCaptions(); } } /** * Flickity equal height helper. * * @since 7.0 */ function setNectarCarouselFlkEH() { $('.nectar-carousel.nectar-flickity:not(.masonry)').each(function () { nectarCarouselFlkEH($(this)); }); } /** * Flickity captions calculcations * * @since 12.2 */ function setNectarFlickityCaptions() { $('.wpb_gallery_slidesflickity_static_height_style .item-meta').each(function() { $(this).css({ 'width': $(this).parent().find('img').width() }); }); } /** * 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: 500, 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:not(.nectar-megamenu-menu-item), #header-outer:not([data-format="menu-left-aligned"]):not([data-format="centered-logo-between-menu-alt"]) .sf-menu.buttons li.megamenu') .removeClass('nectar-megamenu-menu-item') .removeClass('megamenu'); // Centered menu bottom bar forced megamenu values. $('#header-outer[data-format="centered-menu-bottom-bar"] .right-side .sf-menu li.nectar-megamenu-menu-item') .removeClass('align-left') .removeClass('align-middle') .addClass('align-right'); $('#header-outer[data-format="centered-menu-bottom-bar"] .left-side .sf-menu li.nectar-megamenu-menu-item') .removeClass('align-right') .removeClass('align-middle') .addClass('align-left'); $('#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-outer nav .megamenu .sub-menu a.sf-with-ul .sf-sub-indicator, #header-outer .megamenu .sub-menu a .sf-sub-indicator').remove(); // Megamenu bg $('.sf-menu > .nectar-megamenu-menu-item > a .menu-title-text .megamenu-bg-lazy[data-bg-src]').each(function() { var parentLI = $(this).parents('.nectar-megamenu-menu-item'); var bgImgSrc = $(this).attr('data-bg-src'); var bgImgAlign = $(this).attr('data-align').replace( '_', ' '); parentLI.find('> ul').css({ 'background-position': bgImgAlign, 'background-image': 'url("' + bgImgSrc + '")' }); $(this).remove(); }); $('.sf-menu > .nectar-megamenu-menu-item > ul > li > a .menu-title-text .megamenu-col-bg-lazy[data-bg-src]').each(function() { var parentLI = $(this).closest('.menu-item'); var bgImgSrc = $(this).attr('data-bg-src'); var bgImgAlign = $(this).attr('data-align').replace( '_', ' '); parentLI.css({ 'background-position': bgImgAlign, 'background-image': 'url("' + bgImgSrc + '")' }); $(this).remove(); }); // Blank title megamenu columns. $('#header-outer nav > ul > li.megamenu > ul.sub-menu > li > a').each(function () { if ($(this).text() == '-' || $(this).text() == '–' || $(this).parent().hasClass('hide-title')) { $(this).remove(); } }); } // Lazy load nectar menu images. if( 'IntersectionObserver' in window ) { var options = { rootMargin: '0px', threshold: 0 } var menuObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if ( entry.isIntersecting ) { var lazyItem = entry.target; lazyItem.classList.add('loaded'); var lazySrc = lazyItem.getAttribute('data-menu-img-src'); if( lazySrc ) { lazyItem.setAttribute( 'src', lazySrc ); lazyItem.removeAttribute('data-menu-img-src'); } menuObserver.unobserve(lazyItem); } }); }, options); var lazyMenuIcons = [].slice.call(document.querySelectorAll('.nectar-menu-icon-img[data-menu-img-src], #header-outer .nectar-ext-menu-item .image-layer')); lazyMenuIcons.forEach(function(lazyItem) { menuObserver.observe(lazyItem); }); } else { // fallback. $('.sf-menu .nectar-menu-icon-img[data-menu-img-src]').each(function() { $(this).attr('src',$(this).attr('data-menu-img-src')); $(this).removeAttr('data-menu-img-src'); }); $('.nectar-ext-menu-item .image-layer').addClass('loaded'); } // Icon markup. $('.sub-menu .nectar-menu-icon, .sub-menu .nectar-menu-icon-img, .off-canvas-menu-container > ul > li > a .nectar-menu-icon, .off-canvas-menu-container > ul > li > a .nectar-menu-icon-img').each(function() { var $parent = $(this).parent(); var $icon = $(this).detach(); if( $parent.parents('.nectar-ext-menu-item').length == 0 ) { $parent.wrapInner(''); $parent.addClass('nectar-menu-item-with-icon'); } $parent.prepend($icon); }); // Badge Labels. $('#slide-out-widget-area:not(.fullscreen) .nectar-menu-label').each(function(){ if($(this).parents('.nectar-ext-menu-item').length == 0 ) { $(this).closest('a').addClass('nectar-menu-item-with-icon'); } }); // OCM Remove Ext menu items option. if( window.nectarOptions && window.nectarOptions.ocm_remove_ext_menu_items && window.nectarOptions.ocm_remove_ext_menu_items == 'remove_images' ) { $('.off-canvas-menu-container .title[class*="inherit-h"], #mobile-menu .title[class*="inherit-h"]').removeClass(function (index, className) { return (className.match(/(^|\s)inherit-h\S+/g) || []).join(' '); }); $('.off-canvas-menu-container .nectar-ext-menu-item .image-layer-outer, #mobile-menu .nectar-ext-menu-item .image-layer-outer').remove(); $('.off-canvas-menu-container .nectar-ext-menu-item .menu-item-desc').removeClass('menu-item-desc').addClass('item_desc'); $('.off-canvas-menu-container .nectar-ext-menu-item .inner-content > .title').each(function(){ if( $(this).find('.menu-title-text').length == 0 ) { $(this).removeClass('title').addClass('menu-title-text'); } }); } // Desc class for OCM for added submenu spacing $('.off-canvas-menu-container .item_desc').each(function() { var $parent = $(this).parents('.menu-item'); $parent.addClass('nectar-extra-menu-item-spacing'); }); // Desc class for OCM for different flex alignment. $('.off-canvas-menu-container .nectar-menu-icon, .off-canvas-menu-container .nectar-menu-icon-img').each(function() { var $parent = $(this).parent(); if( $parent.find('.item_desc').length > 0 || $parent.find('.nav_desc').length > 0 ) { $parent.addClass('nectar-menu-item-with-desc'); } }); // Deactivate hide header until needed effect on phone. if (nectarDOMInfo.usingMobileBrowser && $('#header-outer[data-remove-fixed="1"]').length == 0) { $body.attr('data-hhun', '0'); } inlineMegaMenuPos(); } function inlineMegaMenuPos() { // Left aligned items. $('nav:not(.left-side):not(.right-side) .sf-menu > .nectar-megamenu-menu-item.align-left:not(.width-100)').each(function() { var $parentEl = $(this); var $headerContainer = $('header#top > .container > .row'); var $submenu = $(this).find('> ul.sub-menu'); if( $parentEl ) { // Change into center positioning. if( $submenu.width() + $parentEl.offset().left > nectarDOMInfo.winW ) { $(this).addClass('align-middle'); return true; } // Set left positioning. $(this).find('> ul.sub-menu').css({ 'right': $headerContainer.width() - ( ($parentEl.offset().left + $parentEl.width()) - $headerContainer.offset().left ) - $(this).find('> ul.sub-menu').width() + $parentEl.width(), 'left': 'auto' }); $(this).removeClass('align-middle'); } }); // Right aligned items. $('nav:not(.left-side):not(.right-side) .sf-menu > .nectar-megamenu-menu-item.align-right:not(.width-100)').each(function() { var $parentEl = $(this); var $headerContainer = $('header#top > .container > .row'); var $submenu = $(this).find('> ul.sub-menu'); if( $parentEl ) { // Change into center positioning. if( ($parentEl.offset().left + $parentEl.width() - $submenu.width()) < 0 ) { $(this).addClass('align-middle'); return true; } $(this).find('> ul.sub-menu').css({ 'right': $headerContainer.width() - ( ($parentEl.offset().left + $parentEl.width()) - $headerContainer.offset().left ), 'left': 'auto' }); $(this).removeClass('align-middle'); } }); // Center aligned items. $('nav:not(.left-side):not(.right-side) .sf-menu > .nectar-megamenu-menu-item.align-middle:not(.width-100)').each(function() { var $parentEl = $(this); var $headerContainer = $('header#top > .container > .row'); var $submenu = $(this).find('> ul.sub-menu'); if( $parentEl ) { var headerContainerW = $headerContainer.width(), headerContainerOffsetL = $headerContainer.offset().left, menuItemOffsetL = $parentEl.offset().left, menuItemW = $parentEl.width(), megaMenuW = $submenu.width(); // Default center align. $submenu.css({ 'right': headerContainerW - ( (menuItemOffsetL + menuItemW) - headerContainerOffsetL ) - megaMenuW/2 + menuItemW/2, 'left': 'auto' }); var megaMenuOffset = $submenu.offset(); // Overflowing left. if(megaMenuOffset.left < 0) { $submenu.css({ 'right': 'auto', 'left': '0px' }); } // Overflowing right. else if( megaMenuOffset.left + megaMenuW > nectarDOMInfo.winW ) { $submenu.css({ 'right': '0px', 'left': 'auto' }); } } }); } /** * 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:not(.left-side):not(.right-side) > ul > li.megamenu:not(.width-50):not(.width-75) > .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('