;(function ($, window, document, undefined) { 'use strict'; $(window).on('load', function () { if ($('.spinner-preloader-wrap').length) { $('.spinner-preloader-wrap').fadeOut(500); } if ($('.preloader-text').length) { $('.preloader-text').fadeOut(500); } if ($('.preloader-wrap').length) { $('.preloader-wrap').fadeOut(500); } }); $('body').fitVids({ignore: '.vimeo-video, .youtube-simple-wrap iframe, .iframe-video.for-btn iframe, .post-media.video-container iframe'}); /*=================================*/ /* 01 - VARIABLES */ /*=================================*/ var swipers = [], winW, winH, winScr, _isresponsive, smPoint = 768, mdPoint = 992, lgPoint = 1200, addPoint = 1600, _ismobile = navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i), pageCalculateHeight; /*=================================*/ /* 02 - PAGE CALCULATIONS */ /*=================================*/ /** * * PageCalculations function * @since 1.0.0 * @version 1.0.1 * @var winW * @var winH * @var winS * @var pageCalculations * @var onEvent **/ if (typeof pageCalculations !== 'function') { var winW, winH, winS, pageCalculations, onEvent = window.addEventListener; pageCalculations = function (func) { winW = window.innerWidth; winH = window.innerHeight; winS = document.body.scrollTop; if (!func) return; onEvent('load', func, true); // window onload onEvent('resize', func, true); // window resize onEvent("orientationchange", func, false); // window orientationchange }// end pageCalculations pageCalculations(function () { pageCalculations(); }); } // body slider function bodySlider() { if($('.bg_slider .body-gridrotate').length){ $('.bg_slider .body-gridrotate').gridrotator({ rows : 1, // number of columns columns : 1, w1200 : { rows : 1, columns : 1 }, w992 : { rows : 1, columns : 1 }, w510 : { rows : 1, columns : 1 }, w480 : { rows : 1, columns : 1 }, w320 : { rows : 1, columns : 1 }, step : 1, maxStep : 1, animType : 'fadeInOut', animSpeed : 1000, interval : 9000, }); } if($('body.bg_slider').length) { var $el = $('#footer'); $('.main-wrapper > .container').wrap('
'); $el.clone(true).appendTo('.main-wrapper > .phoxy-main-content'); $el.remove(); var adminBar = 0; var wH = $(window).height(); var hH = $('.header_top_bg').not('.header_trans-fixed, .fixed-header').outerHeight() || 0; if ($('#wpadminbar').length && ($('.header_top_bg').not('.header_trans-fixed, .fixed-header').length && !$('.header_top_bg').not('.not-fixed-menu').length)) { adminBar = $('#wpadminbar').outerHeight(); } $('.phoxy-main-content').css({ 'min-height': wH - $('.header_top_bg').outerHeight()*2 - 20, 'margin-top': hH + 10 + adminBar, 'margin-bottom': $('.header_top_bg').outerHeight() + 10 }); var footer = $('#footer'); var paddValue = footer.outerHeight(); footer.bind('heightChange', function () { if (!$("#footer.fix-bottom").length && $("#footer.footer-parallax").length) { $('.main-wrapper > .phoxy-main-content').css('margin-bottom', paddValue); } else if (!$("#footer.fix-bottom").length) { $('.main-wrapper > .phoxy-main-content').css('padding-bottom', paddValue); } }); footer.trigger('heightChange'); } } $(window).on('load', function () { bodySlider(); }); /*Full height banner*/ function topBannerHeight() { var headerH = $('.header_top_bg').not('.header_trans-fixed, .fixed-header').outerHeight() || 0; var footerH = $('#footer').not('.fix-bottom').outerHeight() || 0; var windowH = $(window).height(); var offsetTop; var adminbarH; if ($('#wpadminbar').length) { offsetTop = headerH + $('#wpadminbar').outerHeight(); } else { offsetTop = headerH; } if ($('#wpadminbar').length && $('.header_trans-fixed').length) { adminbarH = $('#wpadminbar').outerHeight(); } else { adminbarH = 0; } $('.full-height-window').css('min-height', (windowH - offsetTop) + adminbarH + 'px'); $('.full-height-window-hard').css('height', (windowH - offsetTop) + adminbarH + 'px'); $('.full-window-hard').css('height', (windowH - offsetTop - footerH) + adminbarH + 'px'); $('.middle-height-window-hard').css('height', (windowH - offsetTop) - 50 + adminbarH + 'px'); $('body, .main-wrapper').css('min-height', $(window).height()); } /* IF TOUCH DEVICE */ function isTouchDevice() { return 'ontouchstart' in document.documentElement; } function shopisotope() { if ($('.woocommerce.archive .products').length) { var self = $('.woocommerce.archive .products'); var layoutM = 'masonry'; self.isotope({ itemSelector: '.product', layoutMode: layoutM, masonry: { columnWidth: '.product', 'gutter': 30 } }); } if ($('.wpb_wrapper .woocommerce .products').length) { var self = $('.wpb_wrapper .woocommerce .products'); var layoutM = 'masonry'; self.isotope({ itemSelector: '.product', layoutMode: layoutM, masonry: { columnWidth: '.product', 'gutter': 30 } }); } } $(window).on('load', function() { $("img[data-lazy-src]").foxlazy(); wpc_add_img_bg('.s-img-switch'); }); $(window).on('load resize orientationchange', function() { shopisotope(); }); /*=================================*/ /* SWIPER SLIDER */ /*=================================*/ function initSwiper() { var initIterator = 0; $('.swiper-container').each(function () { var $t = $(this); var index = 'swiper-unique-id-' + initIterator; $t.addClass('swiper-' + index + ' initialized').attr('id', index); $t.parent().find('.swiper-pagination').addClass('swiper-pagination-' + index); $t.parent().find('.swiper-button-next').addClass('swiper-button-next-' + index); $t.parent().find('.swiper-button-prev').addClass('swiper-button-prev-' + index); var setThumb = function (activeIndex, slidesNum) { var url_thumb, leftClick = $t.find('.slider-click.left'), rightClick = $t.find('.slider-click.right'), slidesNum = slidesNum, activeIndexLeft, activeIndexRight; if (loopVar === 1) { if (activeIndex < 1) { leftClick.removeClass('disabled').find('.left').text(slidesNum); leftClick.find('.right').text(slidesNum); } else { leftClick.removeClass('disabled').find('.left').text(activeIndex); leftClick.find('.right').text(slidesNum); } if (activeIndex == slidesNum - 1) { rightClick.removeClass('disabled').find('.left').text('1'); rightClick.find('.right').text(slidesNum); } else { rightClick.removeClass('disabled').find('.left').text(activeIndex + 2); rightClick.find('.right').text(slidesNum); } } else { if (activeIndex < 1) { leftClick.addClass('disabled'); } else { leftClick.removeClass('disabled').find('.left').text(activeIndex); leftClick.find('.right').text(slidesNum); } if (activeIndex == slidesNum - 1) { rightClick.addClass('disabled'); } else { rightClick.removeClass('disabled').find('.left').text(activeIndex + 2); rightClick.find('.right').text(slidesNum); } } }; if (isTouchDevice() && $t.data('mode') == 'vertical') { $t.attr('data-noswiping', 1); $(this).find('.swiper-slide').addClass('swiper-no-swiping'); } var autoPlayVar = parseInt($t.attr('data-autoplay'), 10); var mode = $t.attr('data-mode'); var effect = $t.attr('data-effect') ? $t.attr('data-effect') : 'slide'; var paginationType = $t.attr('data-pagination-type'); var loopVar = parseInt($t.attr('data-loop'), 10); var noSwipingVar = parseInt($t.attr('data-noSwiping'), 10); var mouse = parseInt($t.attr('data-mouse'), 10); var speedVar = parseInt($t.attr('data-speed'), 10); var centerVar = parseInt($t.attr('data-center'), 10); var spaceBetweenVar = parseInt($t.attr('data-space'), 10); var slidesPerView = parseInt($t.attr('data-slidesPerView'), 10) ? parseInt($t.attr('data-slidesPerView'), 10) : 'auto'; var breakpoints = {}; var responsive = $t.attr('data-responsive'); if ($('.album_swiper').length && $(window).width() < 768) { loopVar = 1; } else { loopVar = parseInt($t.attr('data-loop'), 10); } if (responsive == 'responsive') { slidesPerView = $t.attr('data-add-slides'); var lg = $t.attr('data-lg-slides') ? $t.attr('data-lg-slides') : $t.attr('data-add-slides'); var md = $t.attr('data-md-slides') ? $t.attr('data-md-slides') : $t.attr('data-add-slides'); var sm = $t.attr('data-sm-slides') ? $t.attr('data-sm-slides') : $t.attr('data-add-slides'); var xs = $t.attr('data-xs-slides') ? $t.attr('data-xs-slides') : $t.attr('data-add-slides'); breakpoints = { 768: { slidesPerView: xs }, 992: { slidesPerView: sm }, 1200: { slidesPerView: md }, 1600: { slidesPerView: lg } }; } var titles = []; $t.find('.swiper-slide').each(function () { titles.push($(this).data('title')); }); if ($t.hasClass('swiper-album')) { breakpoints = { 480: { slidesPerView: 1 }, 767: { slidesPerView: 3, centeredSlides: false }, 991: { slidesPerView: 4 }, 1600: { slidesPerView: 5 } }; } swipers['swiper-' + index] = new Swiper('.swiper-' + index, { pagination: '.swiper-pagination-' + index, paginationType: paginationType, paginationBulletRender: function (swiper, index, className) { if ($t.parent('.banner-slider-wrap.vertical_custom_elements').length || $t.parent('.banner-slider-wrap.vertical').length || $t.parent('.product-slider-wrapper').length) { var title = titles[index]; if (index < 9) return '' + title + '' + ('0' + (index + 1)) + ''; return '' + title + '' + (index + 1) + ''; } else { return ''; } }, direction: mode || 'horizontal', slidesPerView: slidesPerView, breakpoints: breakpoints, centeredSlides: centerVar, noSwiping: noSwipingVar, noSwipingClass: 'swiper-no-swiping', paginationClickable: true, spaceBetween: spaceBetweenVar, containerModifierClass: 'swiper-container-', // NEW slideClass: 'swiper-slide', slideActiveClass: 'swiper-slide-active', slideDuplicateActiveClass: 'swiper-slide-duplicate-active', slideVisibleClass: 'swiper-slide-visible', slideDuplicateClass: 'swiper-slide-duplicate', slideNextClass: 'swiper-slide-next', slideDuplicateNextClass: 'swiper-slide-duplicate-next', slidePrevClass: 'swiper-slide-prev', slideDuplicatePrevClass: 'swiper-slide-duplicate-prev', wrapperClass: 'swiper-wrapper', bulletClass: 'swiper-pagination-bullet', bulletActiveClass: 'swiper-pagination-bullet-active', buttonDisabledClass: 'swiper-button-disabled', paginationCurrentClass: 'swiper-pagination-current', paginationTotalClass: 'swiper-pagination-total', paginationHiddenClass: 'swiper-pagination-hidden', paginationProgressbarClass: 'swiper-pagination-progressbar', paginationClickableClass: 'swiper-pagination-clickable', // NEW paginationModifierClass: 'swiper-pagination-', // NEW lazyLoadingClass: 'swiper-lazy', lazyStatusLoadingClass: 'swiper-lazy-loading', lazyStatusLoadedClass: 'swiper-lazy-loaded', lazyPreloaderClass: 'swiper-lazy-preloader', notificationClass: 'swiper-notification', preloaderClass: 'preloader', zoomContainerClass: 'swiper-zoom-container', loop: loopVar, speed: speedVar, autoplay: autoPlayVar, effect: effect, mousewheelControl: mouse, nextButton: '.swiper-button-next-' + index, prevButton: '.swiper-button-prev-' + index, iOSEdgeSwipeDetection: true, onInit: function (swiper) { if ($t.closest('.product-slider-wrapper') && $(window).width() < 1024) { $t.find('.swiper-slide').addClass('swiper-no-swiping'); } else { $t.find('.swiper-slide').removeClass('swiper-no-swiping'); } if (winW > 1024 && $t.find(".slider-click").length) { $t.find(".slider-click").each(function () { var arrow = $(this); $(document).on("mousemove", function (event) { var arrow_parent = arrow.parent(), parent_offset = arrow_parent.offset(), pos_left = Math.min(event.pageX - parent_offset.left, arrow_parent.width()), pos_top = event.pageY - parent_offset.top; arrow.css({ 'left': pos_left, 'top': pos_top }); }); }); } var totalSlides = $('.swiper-slide:not(.swiper-slide-duplicate)').length; if ($('.full_screen_slider').length) { setThumb(swiper.realIndex, totalSlides); } }, onSlideChangeEnd: function (swiper) { var totalSlides = $('.swiper-slide:not(.swiper-slide-duplicate)').length; var activeIndex = (loopVar === 1) ? swiper.realIndex : swiper.activeIndex; if ($('.full_screen_slider').length) { setThumb(swiper.realIndex, totalSlides); } }, onSlideChangeStart: function (swiper) { var totalSlides = $('.swiper-slide:not(.swiper-slide-duplicate)').length; var activeIndex = (loopVar == 1) ? swiper.realIndex : swiper.activeIndex; if ($('.full_screen_slider').length) { setThumb(swiper.realIndex, totalSlides); } swiper.startAutoplay(); } }); initIterator++; }); } $('.slider-click.left').on('click', function () { swipers['swiper-' + $(this).parent().parent().parent().find('.full_screen_slider').attr('id')].slidePrev(); swipers['swiper-' + $(this).parent().parent().parent().find('.full_screen_slider').attr('id')].startAutoplay(); }); $('.slider-click.right').on('click', function () { swipers['swiper-' + $(this).parent().parent().parent().find('.full_screen_slider').attr('id')].slideNext(); swipers['swiper-' + $(this).parent().parent().parent().find('.full_screen_slider').attr('id')].startAutoplay(); }); /*=================================*/ /* MAIN WRAPPER */ /*=================================*/ function calcPaddingMainWrapper() { var footer = $('#footer'); var paddValue = footer.outerHeight(); footer.bind('heightChange', function () { if (!$("#footer.fix-bottom").length && $("#footer.footer-parallax").length) { $('body:not(.bg_slider) .main-wrapper').css('margin-bottom', paddValue); } else if (!$("#footer.fix-bottom").length) { $('body:not(.bg_slider) .main-wrapper').css('padding-bottom', paddValue); } }); footer.trigger('heightChange'); } if ($(".animsition").length) { $(".animsition").animsition({ inClass: 'fade-in', outClass: 'fade-out', inDuration: 2000, outDuration: 800, loading: true, loadingParentElement: 'body', //animsition wrapper element loadingClass: 'animsition-loading', unSupportCss: ['animation-duration', '-webkit-animation-duration', '-o-animation-duration' ], overlay: false, overlayClass: 'animsition-overlay-slide', overlayParentElement: 'body' }); } /*=================================*/ /* FOOTER WIDGETS HEIGHT */ /*=================================*/ function footerWidgetsHeight() { if ($('#footer .sidebar-item').length) { $('#footer .widg').each(function () { var layoutM = 'masonry'; $(this).isotope({ itemSelector: '.sidebar-item', layoutMode: layoutM, masonry: { columnWidth: '.sidebar-item' } }); }); } } /*=================================*/ /* PORTFOLIO ITEM */ /*=================================*/ function portfolioAlbum() { if ($('.portfolio .block_item_0').length) { $('.portfolio .wpb_wrapper').each(function () { var layoutM = 'masonry'; $(this).isotope({ itemSelector: '.block_item_0', layoutMode: layoutM, masonry: { columnWidth: '.block_item_0' } }); }); } } /*=================================*/ /* ADD IMAGE ON BACKGROUND */ /*=================================*/ function wpc_add_img_bg(img_sel, parent_sel) { if (!img_sel) { return false; } var $parent, $imgDataHidden, _this; $(img_sel).each(function () { _this = $(this); $imgDataHidden = _this.data('s-hidden'); $parent = _this.closest(parent_sel); $parent = $parent.length ? $parent : _this.parent(); $parent.css('background-image', 'url(' + this.src + ')').addClass('s-back-switch'); if ($imgDataHidden) { _this.css('visibility', 'hidden'); _this.show(); } else { _this.hide(); } }); } // Canvas wrap function canvasWrap() { $('canvas:not(.scene--full)').wrap(''); } // SEARCH POPUP $('.open-search').on('click', function () { $('body').css('overflow', 'hidden'); $('.site-search').addClass('open'); }); $('.close-search').on('click', function () { $('body').css('overflow', ''); $('.site-search').removeClass('open'); }); /*=================================*/ /* ASIDE MENU */ /*=================================*/ function toggleAsideMenu() { // ASIDE MENU NAVIGATION $('.aside-nav').on('click', function () { $('.aside-menu').toggleClass('active-menu'); $('.topmenu').toggleClass('active-menu'); return false; }); var dataTop = $('.main-wrapper').data('top'); if ($(window).width() > 991 && !$('body').hasClass('mob-main-menu') || $(window).width() > 1024 && $('body').hasClass('mob-main-menu')) { $('.main-wrapper').on('click', function (e) { if (!e.target.closest('.aside-menu')) { $('.sub-menu-open').slideUp(400); } }); $('.aside-menu .menu-item-has-children a').addClass('hide-drop'); $('.aside-menu .menu-item a').on('click', function () { if ($(this).parent().hasClass('menu-item-has-children')) { if ($(this).hasClass('hide-drop')) { if ($(this).closest('.sub-menu').length) { $(this).removeClass('hide-drop').next('.sub-menu').slideDown(400).removeClass('sub-menu-open'); $(this).parent().siblings().find('.sub-menu').slideUp(400).addClass('sub-menu-open'); } else { $('.menu-item-has-children a').addClass('hide-drop').next('.sub-menu').hide(100).removeClass('sub-menu-open'); $(this).removeClass('hide-drop').next('.sub-menu').slideToggle(400).toggleClass('sub-menu-open'); } } else { console.log(1); $(this).addClass('hide-drop').next('.sub-menu').hide(100).find('.menu-item-has-children a').addClass('hide-drop').next('.sub-menu').hide(100); $(this).next('.sub-menu').removeClass('sub-menu-open'); } } }); } else { $('.menu-item-has-children a').removeClass('hide-drop'); } if ($('.aside-fix').length && $(window).width() > dataTop) { var logoWidth = $('.logo span, .logo img').outerWidth(); $('.logo').css('top', logoWidth + 'px'); } } /*=================================*/ /* MOBILE MENU */ /*=================================*/ $('.mob-nav').on('click', function (e) { e.preventDefault(); $('html').addClass('no-scroll sidebar-open').height(window.innerHeight + 'px'); }); $('.mob-nav-close').on('click', function (e) { e.preventDefault(); $('html').removeClass('no-scroll sidebar-open').height('auto'); // setTimeout(function (){ // $(window).resize(); // }, 500); }); function fixedMobileMenu() { var headerHeight = $('.header_top_bg').not('.header_trans-fixed').outerHeight(); var offsetTop; var dataTop = $('.main-wrapper').data('top'); var adminbarHeight = $('#wpadminbar').outerHeight(); if ($('#wpadminbar').length) { offsetTop = adminbarHeight + headerHeight; $('.header_top_bg').css('margin-top', adminbarHeight); } else { offsetTop = headerHeight; } if ($(window).width() <= dataTop) { $('.main-wrapper').css('padding-top', offsetTop + 'px'); } else { $('.main-wrapper').css('padding-top', '0'); } if ($('#wpadminbar').length && $(window).width() < 768) { $('#wpadminbar').css({ 'position': 'fixed', 'top': '0' }) } } function menuArrows() { var mobW = $('.main-wrapper').attr('data-top'); if (($(window).width() <= mobW)) { if (!$('.menu-item-has-children i').length) { $('header .menu-item-has-children').append(''); $('header .menu-item-has-children i').addClass('hide-drop'); } $('header .menu-item i').on('click', function () { if ($(this).parent().hasClass('menu-item-has-children') && !$(this).hasClass('animation')) { $(this).addClass('animation'); if ($(this).hasClass('hide-drop')) { if ($(this).closest('.sub-menu').length) { $(this).removeClass('hide-drop').prev('.sub-menu').slideToggle(400); } else { $('.menu-item-has-children i').addClass('hide-drop').next('.sub-menu').hide(100); $(this).removeClass('hide-drop').prev('.sub-menu').slideToggle(400); } } else { $(this).addClass('hide-drop').prev('.sub-menu').hide(100).find('.menu-item-has-children a').addClass('hide-drop').prev('.sub-menu').hide(100); } } setTimeout(removeClass, 400); function removeClass() { $('header .menu-item i').removeClass('animation'); } }); } else { $('header .menu-item-has-children i').remove(); } } /*=================================*/ /* ANIMATION */ /*=================================*/ $.fn.isInViewport = function (offsetB) { var elementTop = $(this).offset().top; var elementBottom = elementTop + $(this).outerHeight(); var viewportTop = $(window).scrollTop(); var viewportBottom = viewportTop + $(window).height() - offsetB; return elementBottom > viewportTop && elementTop < viewportBottom; }; function addAnimation() { if ($('.headings-wrap').length && $('.headings-wrap').hasClass('load-fade')) { var headings = $('.headings-wrap.load-fade').find('.headings'); headings.each(function () { var animationClass = 'animation'; var elements = $(this).children(); var headingOffsetB; if ($(window).width() > 1024) { headingOffsetB = 50; } else { headingOffsetB = 0; } if (elements.isInViewport(headingOffsetB)) { elements.addClass(animationClass); } else { elements.removeClass(animationClass); } }); } if ($('.portfolio-grid').length || $('.portfolio-masonry').length) { $('.portfolio-grid, .portfolio-masonry').each(function () { if ($(window).scrollTop() >= $(this).offset().top - $(window).height() * .8) { $(this).addClass('animation'); } }); } } function addTransition() { if ($('.headings-wrap').length && $('.headings-wrap').hasClass('load-fade')) { var headings = $('.headings-wrap.load-fade').find('.headings'); headings.each(function () { var elements = $(this).children(); for (var i = 0; i < $(this).children().length; i++) { elements.eq(i).addClass('fade-up transition-' + i); } }); } } /*=================================*/ /* HEADER SCROLL */ /*=================================*/ $(window).on('scroll', function () { if ($(this).scrollTop() >= 150) { if ($('.header_top_bg.header_trans-fixed').length) { $('.header_top_bg.header_trans-fixed').not('.fixed-dark').addClass('bg-fixed-color'); $('.fixed-dark').addClass('bg-fixed-dark'); $('.logo-hover').show(); $('.main-logo').hide(); } } else { if ($('.header_top_bg.header_trans-fixed').length) { $('.header_top_bg.header_trans-fixed').not('.fixed-dark').removeClass('bg-fixed-color'); $('.fixed-dark').removeClass('bg-fixed-dark'); $('.logo-hover').hide(); $('.main-logo').show(); } } }); /*=================================*/ /* ABOUT SECTION */ /*=================================*/ $('.about-hamburger').on('click', function () { $('.about-mob-section-wrap').toggleClass('open'); $(window).resize(); }); /*=================================*/ /* BLOG */ /*=================================*/ /* MAGNIFIC POPUP VIDEO */ function popupVideo() { if ($('.blog .video-content-blog').length || $('.single-post .video-content-blog').length) { $('.play').each(function () { $(this).magnificPopup({ disableOn: 700, type: 'iframe', mainClass: 'mfp-fade', removalDelay: 160, preloader: false, fixedContentPos: true, fixedBgPos: true }); }); } } // image slider // --------------------------------- if ($('.img-slider').length) { $('.img-slider .slides').each(function () { $(this).slick({ fade: true, autoplay: true, speed: 500, dots: false, prevArrow: "