;(function ($, window, document, undefined) {
'use strict';
$(window).on('load', function () {
if ($('.preloader-wrap').length) {
$('.preloader-wrap').fadeOut(500);
}
});
/*=================================*/
/* 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();
});
}
/*Full height banner*/
function topBannerHeight() {
var headerH = $('.header_top_bg').not('.header_trans-fixed, .fixed-header').outerHeight() || 0;
var windowH = $(window).outerHeight();
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');
$('.middle-height-window-hard').css('height', (windowH - offsetTop) * 0.8 + adminbarH + 'px');
$('body, .main-wrapper').css('min-height', $(window).height());
if($('body.error404 .unit').length){
var footer = $('#footer').length ? $('#footer').height() : 0;
$('.full-height-window').css('min-height', (windowH - offsetTop - footer - headerH) + adminbarH + 'px');
}
}
/* IF TOUCH DEVICE */
function isTouchDevice() {
return 'ontouchstart' in document.documentElement;
}
/*=================================*/
/* 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('.banner-slider-wrap.vertical-2').length || $t.parent('.product-slider-wrapper').length) {
var title = titles[index];
if (index < 9) return '' + ('0' + (index + 1)) + '';
return '' + (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);
}
if ($t.hasClass('js-change-color')) {
var activeSlide = $t.find('.swiper-slide-active');
if (activeSlide.data('content-color') == 'light') {
$t.closest('.product-slider-wrapper').addClass('product-slider-wrapper--light');
$t.closest('.banner-slider-wrap').addClass('content-light');
} else {
$t.closest('.product-slider-wrapper').removeClass('product-slider-wrapper--light');
$t.closest('.banner-slider-wrap').removeClass('content-light');
}
}
if ($t.hasClass('js-check-pagination')) {
var countSlide = $t.find('.swiper-pagination-bullet').length;
if (countSlide > 5) {
$t.addClass('js-calc-pagination');
}
}
if ($t.hasClass('js-calc-pagination')) {
var slide = $t.find('.swiper-pagination-bullet');
slide.removeClass('visible');
var countSlide = slide.length;
var index = $t.find('.swiper-pagination-bullet-active').index();
slide.eq(index).addClass('visible');
slide.eq(0).addClass('visible');
slide.eq(countSlide - 1).addClass('visible');
if (index > 1 && index < countSlide - 2) {
$t.find('.swiper-pagination').removeClass('start end').addClass('center');
slide.eq(index - 1).addClass('visible');
slide.eq(index + 1).addClass('visible');
} else if (index <= 1) {
$t.find('.swiper-pagination').removeClass('center end').addClass('start');
slide.eq(0).addClass('visible');
slide.eq(1).addClass('visible');
slide.eq(2).addClass('visible');
} else if (countSlide >= index - 2) {
$t.find('.swiper-pagination').removeClass('center start').addClass('end');
slide.eq(countSlide - 2).addClass('visible');
slide.eq(countSlide - 3).addClass('visible');
}
}
},
onSlideChangeEnd: function (swiper) {
if ($t.hasClass('js-change-color')) {
$t.closest('.banner-slider-wrap').removeClass('content-transition');
$t.closest('.product-slider-wrapper').removeClass('content-transition');
var activeSlide = $t.find('.swiper-slide-active');
if (activeSlide.data('content-color') == 'light') {
$t.closest('.product-slider-wrapper').addClass('product-slider-wrapper--light');
$t.closest('.banner-slider-wrap').addClass('content-light');
} else {
$t.closest('.product-slider-wrapper').removeClass('product-slider-wrapper--light');
$t.closest('.banner-slider-wrap').removeClass('content-light');
}
}
if ($t.hasClass('js-calc-pagination')) {
var slide = $t.find('.swiper-pagination-bullet');
slide.removeClass('visible');
var countSlide = slide.length;
var index = $t.find('.swiper-pagination-bullet-active').index();
slide.eq(index).addClass('visible');
slide.eq(0).addClass('visible');
slide.eq(countSlide - 1).addClass('visible');
if (index > 1 && index < countSlide - 2) {
$t.find('.swiper-pagination').removeClass('start end').addClass('center');
slide.eq(index - 1).addClass('visible');
slide.eq(index + 1).addClass('visible');
} else if (index <= 1) {
$t.find('.swiper-pagination').removeClass('center end').addClass('start');
slide.eq(0).addClass('visible');
slide.eq(1).addClass('visible');
slide.eq(2).addClass('visible');
} else if (countSlide >= index - 2) {
$t.find('.swiper-pagination').removeClass('center start').addClass('end');
slide.eq(countSlide - 2).addClass('visible');
slide.eq(countSlide - 3).addClass('visible');
}
}
},
onSlideChangeStart: function (swiper) {
var activeIndex = (loopVar == 1) ? swiper.realIndex : swiper.activeIndex;
if ($t.parent().find('.swiper-pagination-bullet').length) {
$t.parent().find('.swiper-pagination-bullet').removeClass('swiper-pagination-bullet-active').eq(activeIndex).addClass('swiper-pagination-bullet-active');
}
if ($t.hasClass('js-change-color')) {
$t.closest('.banner-slider-wrap').addClass('content-transition');
$t.closest('.product-slider-wrapper').addClass('content-transition');
}
}
});
(function verticalResponsive() {
if ($t.hasClass('swiper-container-vertical')) {
var breakpoints = [1600, 1200, 992, 768],
maxHeight = Math.max.apply(null, $t.find('.swiper-slide').map(function () {
return $(this).height();
}).get()),
swiperWrapper = $t.find('.swiper-wrapper');
if ($(window).width() < breakpoints[3]) {
$t.css({'height': maxHeight * $t.data('xs-slides')});
} else if ($(window).width() < breakpoints[2]) {
$t.css({'height': maxHeight * $t.data('sm-slides')});
} else if ($(window).width() < breakpoints[1]) {
$t.css({'height': maxHeight * $t.data('md-slides')});
} else {
$t.css({'height': maxHeight * $t.data('lg-slides')});
}
}
})();
if ($t.hasClass('swiper-container-horizontal') && $t.closest('.px-slider')) {
$t.closest('.vc_row[data-vc-full-width]').css({'overflow': 'visible'});
}
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();
});
/*=================================*/
/* SWIPER COLUMN */
/*=================================*/
var swiper = new Swiper('.swiper-container-column', {
slidesPerView: 3,
slidesPerColumn: 2,
spaceBetween: 30,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
});
/*=================================*/
/* ADD IMAGE ON BACKGROUND */
/*=================================*/
function wpc_add_img_bg(img_sel, color, parent_sel) {
if (!img_sel) {
return false;
}
var $parent, $imgDataHidden, _this, $src;
$(img_sel).each(function () {
_this = $(this);
$imgDataHidden = _this.data('s-hidden');
$parent = _this.closest(parent_sel);
$parent = $parent.length ? $parent : _this.parent();
if (color == 'dark' && $(this).attr('data-dark-src')) {
$src = $(this).attr('data-dark-src');
$src = $src.length > 0 ? $src : this.src;
} else {
$src = $(this).attr('data-light-src');
}
var src_change = color == 'dark' ? $(this).attr('data-lazy-src') : '';
if (color == 'dark' && src_change.length > 0) {
$(this).attr('data-light-src', src_change);
}
$(this).attr('data-lazy-src', $src);
// $parent.css('background-image', 'url(' + $src + ')').addClass('s-back-switch');
// if ($imgDataHidden) {
// _this.css('visibility', 'hidden');
// _this.show();
// }
// else {
// _this.hide();
// }
});
}
function switchLink (target, version) {
var $target = $(target);
$target.each(function(){
var href = version == 'dark' ? $(this).attr('data-href-dark') : $(this).attr('data-href-light');
if (version.length > 0) {
$(this).attr('href', href);
}
});
}
function switchImage (target, version) {
var $target = $(target);
$target.each(function(){
var src = version == 'dark' ? $(this).attr('data-dark-src') : $(this).attr('data-light-src');
var src_change = version == 'dark' ? $(this).attr('data-lazy-src') : '';
if (version == 'dark' && src_change.length > 0) {
$(this).attr('data-light-src', src_change);
}
if (src.length > 0) {
$(this).attr('data-lazy-src', src);
}
});
}
$('.js-version').on('click', function(e) {
if ($(this).attr('data-state') == 'light') {
$('body').addClass('dark');
wpc_add_img_bg('.s-img-switch', 'dark');
switchLink('.href-switch', 'dark');
switchImage('.image-switch', 'dark');
$(this).attr('data-state', 'dark');
$(this).text($(this).attr('data-light-text'));
} else {
$('body').removeClass('dark');
wpc_add_img_bg('.s-img-switch', 'light');
switchLink('.href-switch', 'light');
switchImage('.image-switch', 'light');
$(this).attr('data-state', 'light');
$(this).text($(this).attr('data-dark-text'));
}
$("img[data-lazy-src]").foxlazy();
})
/*=================================*/
/* LAZYLOAD */
/*=================================*/
$(window).on("load", function () {
$("img[data-lazy-src]").foxlazy();
});
/*=================================*/
/* 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 ($('.js-animation').length) {
var headings = $('.js-animation');
headings.each(function () {
var animationClass = 'animation';
var elements = $(this).find('.js-animation-item');
var headingOffsetB;
if ($(window).width() > 1024) {
headingOffsetB = 50;
} else {
headingOffsetB = 0;
}
if ($(this).isInViewport(headingOffsetB)) {
elements.addClass(animationClass);
}
});
}
}
function addTransition() {
if ($('.js-animation').length) {
var headings = $('.js-animation');
headings.each(function () {
var elements = $(this).find('.js-animation-item');
for (var i = 0; i < $(this).find('.js-animation-item').length; i++) {
elements.eq(i).addClass('transition-' + i);
}
});
}
}
/*=================================*/
/* HEADER SCROLL */
/*=================================*/
$(window).on('scroll', function () {
if ($(this).scrollTop() >= $('.header_top_bg.header_trans-fixed').outerHeight()) {
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();
$('.main-btn').hide();
$('.button-white').show();
}
} 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();
$('.main-btn').show();
$('.button-white').hide();
}
}
});
// isotope
var $grid = $('.demos-isotope.home').isotope({
itemSelector: '.demos-isotope__item',
layoutMode: 'masonry',
filter: '.home'
});
if ($('.demos-isotope:not(.home)').lenght) {
$('.demos-isotope:not(.home)').forEach(function () {
$(this).isotope({
itemSelector: '.demos-isotope__item',
layoutMode: 'masonry',
});
});
};
// filter items on button click
$('.filter-button-group').on( 'click', 'button', function() {
$(this).addClass('active').siblings().removeClass('active');
var filterValue = $(this).attr('data-filter');
$grid.isotope({ filter: filterValue });
});
// pageCalculations(function () {
// if (!window.enable_foxlazy) {
// // wpc_add_img_bg('.s-img-switch');
// }
// });
/* Copyright */
if ($('.pixxy_copyright_overlay').length) {
$(document).on('contextmenu', function (event) {
if ($('.pixxy_copyright_overlay').hasClass('copy')) {
event.preventDefault();
} else if (event.target.tagName != 'A') {
event.preventDefault();
}
$('.pixxy_copyright_overlay').addClass('active');
}).on('click', function () {
$('.pixxy_copyright_overlay').removeClass('active').removeAttr('style');
});
}
// over ride click link in menu
$('.a-btn-anchor').on('click', function(event) {
var pos = $($(this).attr('href')).offset().top - $('.header_trans-fixed').outerHeight();
$('body, html').animate({scrollTop: pos}, 500);
return false;
});
$(window).on('load', function () {
$('.js-tilt').tilt();
addTransition();
new WOW().init();
});
$(window).on('load resize', function () {
initSwiper();
topBannerHeight();
});
window.addEventListener("orientationchange", function () {
initSwiper();
topBannerHeight();
addAnimation();
});
$(window).on('load scroll resize', function () {
addAnimation();
});
if ($('.top-banner .images-wrap').length) {
if ($(window).width() > 991) {
$('.top-banner').each(function () {
var items = $(this).find('.images-wrap');
items.each(function () {
var id = $(this).attr('id');
var scene = document.getElementById(id);
var parallaxInstance = new Parallax(scene, {
relativeInput: false,
clipRelativeInput: false,
calibrationThreshold: 100,
calibrationDelay: 500,
supportDelay: 500,
calibrateX: true,
calibrateY: false,
invertX: true,
invertY: true,
limitX: false,
limitY: false,
scalarX: 5.0,
scalarY: 5.0,
frictionX: 0.1,
frictionY: 0,
originX: 0.5,
originY: 0.5,
hoverOnly: true
});
});
});
}
}
window.addEventListener('scroll', function () {
var h = window.innerHeight;
document.body.classList[
window.scrollY > h ? 'add': 'remove'
]('scrolled');
});
})(jQuery, window, document);