/*-----------------------------------------------------------------------------------
Theme Name: Foxic eCommerce Template
Author: BigSteps
Author URI: http://themeforest.net/user/bigsteps
-----------------------------------------------------------------------------------*/
"use strict";
window.THEME = {};
function mostrarWa(){
if($('#textoWa').css('display')=='none'){
$("#imgWa").attr("src","images/waocultar.png");}
else{
$("#imgWa").attr("src","images/wamostrar.png");
}
$('#textoWa').slideToggle();
}
// Youtube API
function onYouTubeIframeAPIReady() {
THEME.Video.loadVideos();
}
(function ($) {
var calcScrollWidth = function calcScrollWidth() {
var html = $('
');
$body.append(html);
var w = html[0].offsetWidth - html[0].clientWidth;
$(html).remove();
return w;
};
var setVH = function setVH() {
var vh = window.innerHeight * 0.01;
$('html').css('--vh', vh + 'px');
$('html').css('--scrollW', scrollWidth + 'px');
};
var random = function random(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
};
THEME.Video = function () {
var mobileBreikpoint = 575;
var iosMobileAutoplay = true;
var autoplayCheckComplete = false;
var playOnClickChecked = false;
var playOnClick = false;
var youtubeLoaded = false;
var videos = {};
var videoPlayers = [];
var videoOptions = {
ratio: 16 / 9,
scrollAnimationDuration: 400,
playerVars: {
iv_load_policy: 3,
modestbranding: 1,
autoplay: 0,
controls: 0,
wmode: 'opaque',
branding: 0,
autohide: 0,
rel: 0,
playsinline: 1
},
events: {
onReady: onPlayerReady,
onStateChange: onPlayerChange
}
};
var classes = {
playing: 'video-is-playing',
paused: 'video-is-paused',
loading: 'video-is-loading',
loaded: 'video-is-loaded',
backgroundVideoWrapper: 'video-background-wrapper',
videoWithImage: 'video--image_with_play',
backgroundVideo: 'video--background',
userPaused: 'is-paused',
supportsAutoplay: 'autoplay',
supportsNoAutoplay: 'no-autoplay',
wrapperMinHeight: 'video-section-wrapper--min-height'
};
var selectors = {
section: '.video-section',
videoWrapper: '.video-section-wrapper',
playVideoBtn: '.video-control__play',
closeVideoBtn: '.video-control__close-wrapper',
pauseVideoBtn: '.video-control__pause'
};
function keepScale(slider) {
var $bnsliderNoScale = slider;
var wW = $(window).width();
if ($bnsliderNoScale.hasClass("keep-scale") && !$bnsliderNoScale.hasClass("bnslider--fullheight")) {
$bnsliderNoScale.css({
'height': '',
'min-height': ''
});
var bnrH;
if (wW <= mobileBreikpoint && parseInt($bnsliderNoScale.attr('data-start-mwidth')) > 0 && parseInt($bnsliderNoScale.attr('data-start-mheight')) > 0) {
var bnrH = parseInt($bnsliderNoScale.attr('data-start-mheight'), 10) / parseInt($bnsliderNoScale.attr('data-start-mwidth'), 10) * wW;
$bnsliderNoScale.css({
'height': bnrH + 'px',
'min-height': bnrH + 'px'
});
} else if (parseInt($bnsliderNoScale.attr('data-start-width')) > 0 && parseInt($bnsliderNoScale.attr('data-start-height')) > 0) {
var bnrH = parseInt($bnsliderNoScale.attr('data-start-height'), 10) / parseInt($bnsliderNoScale.attr('data-start-width'), 10) * wW;
if ($bnsliderNoScale.closest("div[class^='col-'],div[class*=' col-']").length) {
var colW = $bnsliderNoScale.closest("div[class^='col-'],div[class*=' col-']").width() * 100 / wW;
bnrH = bnrH * colW / 100;
} else if ($bnsliderNoScale.closest(".holder.boxed").length) {
var colW = $bnsliderNoScale.closest(".container").width() * 100 / wW;
bnrH = bnrH * colW / 100;
}
$bnsliderNoScale.css({
'height': bnrH + 'px',
'min-height': bnrH + 'px'
});
} else return false;
}
}
function init($video) {
if (!$video.length) {
return;
}
$video.closest(selectors.videoWrapper).find('.bnslider-text').each(function () {
var $this = $(this),
thisInlineStyle = '';
var thisStyle = $this.data();
for (var data in thisStyle) {
if (data == 'fontcolor') {
thisInlineStyle += 'color:' + $this.data('fontcolor') + ';';
}
if (data == 'fontfamily') {
thisInlineStyle += 'font-family:' + $this.data('fontfamily') + ';';
}
if (data == 'fontsize') {
thisInlineStyle += 'font-size:' + $this.data('fontsize') + 'px;';
}
if (data == 'fontline') {
thisInlineStyle += 'line-height:' + $this.data('fontline') + 'em;';
}
if (data == 'fontweight') {
thisInlineStyle += 'font-weight:' + $this.data('fontweight') + ';';
}
if (data == 'bgcolor') {
thisInlineStyle += 'background-color:' + $this.data('bgcolor') + ';';
}
if (data == 'otherstyle') {
thisInlineStyle += $this.data("otherstyle") + ';';
}
}
if (thisInlineStyle.length > 0) {
$this.attr('style', thisInlineStyle).addClass('data-ini');
}
});
$video.closest(selectors.videoWrapper).each(function (index, el) {
keepScale($(el));
});
videos[$video.attr('id')] = {
id: $video.attr('id'),
videoId: $video.data('id'),
type: $video.data('type'),
status: $video.data('type') === 'image_with_play' ? 'closed' : 'background',
$video: $video,
$videoWrapper: $video.closest(selectors.videoWrapper),
$section: $video.closest(selectors.section),
controls: $video.data('type') === 'background' ? 0 : 1
};
if (!youtubeLoaded) {
var tag = document.createElement('script');
tag.src = 'https://www.youtube.com/iframe_api';
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
playOnClickCheck();
}
function customPlayVideo(playerId) {
if (!playOnClickChecked && !playOnClick) {
return;
}
if (playerId && typeof videoPlayers[playerId].playVideo === 'function') {
privatePlayVideo(playerId);
}
}
function pauseVideo(playerId) {
if (videoPlayers[playerId] && typeof videoPlayers[playerId].pauseVideo === 'function') {
videoPlayers[playerId].pauseVideo();
}
}
function loadVideos() {
for (var key in videos) {
if (videos.hasOwnProperty(key)) {
createPlayer(key);
}
}
initEvents();
youtubeLoaded = true;
}
function editorLoadVideo(key) {
if (!youtubeLoaded) {
return;
}
createPlayer(key);
initEvents();
}
function privatePlayVideo(id, clicked) {
var videoData = videos[id];
var player = videoPlayers[id];
var $videoWrapper = videoData.$videoWrapper;
if (playOnClick) {
setAsPlaying(videoData);
} else if (clicked || autoplayCheckComplete) {
$videoWrapper.removeClass(classes.loading);
setAsPlaying(videoData);
player.playVideo();
return;
} else {
player.playVideo();
}
}
function setAutoplaySupport(supported) {
var supportClass = supported ? classes.supportsAutoplay : classes.supportsNoAutoplay;
$(document.documentElement).removeClass(classes.supportsAutoplay).removeClass(classes.supportsNoAutoplay).addClass(supportClass);
if (!supported) {
playOnClick = true;
}
autoplayCheckComplete = true;
}
function playOnClickCheck() {
if (playOnClickChecked) {
return;
}
if (isMobile()) {
playOnClick = true;
}
if (playOnClick) {
setAutoplaySupport(false);
}
playOnClickChecked = true;
}
function onPlayerReady(evt) {
evt.target.setPlaybackQuality('hd1080');
var videoData = getVideoOptions(evt);
playOnClickCheck();
$('#' + videoData.id).attr('tabindex', '-1');
sizeBackgroundVideos();
if ($('#' + videoData.id).attr('data-mute') == 'true') {
evt.target.mute();
}
if (videoData.type === 'background') {
privatePlayVideo(videoData.id);
}
videoData.$videoWrapper.addClass(classes.loaded);
}
function onPlayerChange(evt) {
var videoData = getVideoOptions(evt);
videoData.$videoWrapper.find('.video__loader').addClass('d-none');
if (videoData.status === 'background' && !isMobile() && !autoplayCheckComplete && (evt.data === YT.PlayerState.PLAYING || evt.data === YT.PlayerState.BUFFERING)) {
setAutoplaySupport(true);
autoplayCheckComplete = true;
videoData.$videoWrapper.removeClass(classes.loading);
}
switch (evt.data) {
case YT.PlayerState.ENDED:
setAsFinished(videoData);
break;
case YT.PlayerState.PAUSED:
setTimeout(function () {
if (evt.target.getPlayerState() === YT.PlayerState.PAUSED) {
setAsPaused(videoData);
}
}, 200);
break;
}
}
function setAsFinished(videoData) {
switch (videoData.type) {
case 'background':
videoPlayers[videoData.id].seekTo(0);
break;
case 'image_with_play':
closeVideo(videoData.id);
toggleExpandVideo(videoData.id, false);
break;
}
}
function setAsPlaying(videoData) {
var $videoWrapper = videoData.$videoWrapper;
var $pauseButton = $videoWrapper.find(selectors.pauseVideoBtn);
$videoWrapper.removeClass(classes.loading);
if ($pauseButton.hasClass(classes.userPaused)) {
$pauseButton.removeClass(classes.userPaused);
}
if (videoData.status === 'background') {
return;
}
$('#' + videoData.id).attr('tabindex', '0');
if (videoData.type === 'image_with_play') {
$videoWrapper.removeClass(classes.paused).addClass(classes.playing);
}
setTimeout(function () {
$videoWrapper.find(selectors.closeVideoBtn).focus();
}, videoOptions.scrollAnimationDuration);
}
function setAsPaused(videoData) {
var $videoWrapper = videoData.$videoWrapper;
if (videoData.type === 'image_with_play') {
if (videoData.status === 'closed') {
$videoWrapper.removeClass(classes.paused);
} else {
$videoWrapper.addClass(classes.paused);
}
}
$videoWrapper.removeClass(classes.playing);
}
function closeVideo(playerId) {
var videoData = videos[playerId];
var $videoWrapper = videoData.$videoWrapper;
var classesToRemove = [classes.paused, classes.playing].join(' ');
if (isMobile()) {
$videoWrapper.removeAttr('style');
}
$('#' + videoData.id).attr('tabindex', '-1');
videoData.status = 'closed';
switch (videoData.type) {
case 'image_with_play':
videoPlayers[playerId].stopVideo();
setAsPaused(videoData);
break;
case 'background':
videoPlayers[playerId].mute();
setBackgroundVideo(playerId);
break;
}
$videoWrapper.removeClass(classesToRemove);
}
function getVideoOptions(evt) {
var id = evt.target.getIframe().id;
return videos[id];
}
function toggleExpandVideo(playerId, expand) {
var video = videos[playerId];
var elementTop = video.$videoWrapper.offset().top;
var $playButton = video.$videoWrapper.find(selectors.playVideoBtn);
var offset = 0;
var newHeight = 0;
if (isMobile()) {
video.$videoWrapper.parent().toggleClass('page-width', !expand);
}
if (expand) {
if (isMobile()) {
newHeight = $(window).width() / videoOptions.ratio;
} else {
newHeight = video.$videoWrapper.width() / videoOptions.ratio;
}
offset = ($(window).height() - newHeight) / 2;
video.$videoWrapper.removeClass(classes.wrapperMinHeight).animate({ height: newHeight }, 600);
if (!(isMobile() && Shopify.designMode)) {
$('html, body').animate({
scrollTop: elementTop - offset
}, videoOptions.scrollAnimationDuration);
}
} else {
if (isMobile()) {
newHeight = video.$videoWrapper.data('mobile-height');
} else {
newHeight = video.$videoWrapper.data('desktop-height');
}
video.$videoWrapper.height(video.$videoWrapper.width() / videoOptions.ratio).animate({ height: newHeight }, 600);
setTimeout(function () {
video.$videoWrapper.addClass(classes.wrapperMinHeight);
}, 600);
$playButton.focus();
}
}
function togglePause(playerId) {
var $pauseButton = videos[playerId].$videoWrapper.find(selectors.pauseVideoBtn);
var paused = $pauseButton.hasClass(classes.userPaused);
if (paused) {
$pauseButton.removeClass(classes.userPaused);
customPlayVideo(playerId);
} else {
$pauseButton.addClass(classes.userPaused);
pauseVideo(playerId);
}
$pauseButton.attr('aria-pressed', !paused);
}
function startVideoOnClick(playerId) {
var video = videos[playerId];
video.$videoWrapper.addClass(classes.loading);
video.status = 'open';
switch (video.type) {
case 'image_with_play':
privatePlayVideo(playerId, true);
break;
case 'background':
unsetBackgroundVideo(playerId, video);
videoPlayers[playerId].unMute();
privatePlayVideo(playerId, true);
break;
}
}
function sizeBackgroundVideos() {
$('.video-section-wrapper').each(function (index, el) {
keepScale($(el));
});
$('[data-type="background"]').each(function (index, el) {
sizeBackgroundVideo($(el));
});
}
function sizeBackgroundVideo($videoPlayer) {
if (!youtubeLoaded) {
return;
}
if (isMobile()) {
$videoPlayer.removeAttr('style');
} else {
var $videoWrapper = $videoPlayer.closest(selectors.videoWrapper);
var videoWidth = $videoWrapper.width();
var playerWidth = $videoPlayer.width();
var desktopHeight = $videoWrapper.height();
var desktopHeightMax = Math.ceil(videoWidth / videoOptions.ratio);
if (videoWidth / videoOptions.ratio < desktopHeight) {
playerWidth = Math.ceil(desktopHeight * videoOptions.ratio);
$videoPlayer.width(playerWidth).height(desktopHeight).css({
left: (videoWidth - playerWidth) / 2,
top: 0
});
} else {
$videoPlayer.width(videoWidth).height(desktopHeightMax).css({
left: 0,
top: (desktopHeight - desktopHeightMax) / 2
});
}
$videoPlayer.prepareTransition();
$videoWrapper.addClass(classes.loaded);
}
}
function unsetBackgroundVideo(playerId) {
$('#' + playerId).removeClass(classes.backgroundVideo).addClass(classes.videoWithImage);
videos[playerId].$videoWrapper.removeClass(classes.backgroundVideoWrapper).addClass(classes.playing);
videos[playerId].status = 'open';
}
function setBackgroundVideo(playerId) {
$('#' + playerId).removeClass(classes.videoWithImage).addClass(classes.backgroundVideo);
videos[playerId].$videoWrapper.addClass(classes.backgroundVideoWrapper);
videos[playerId].status = 'background';
sizeBackgroundVideo($('#' + playerId));
}
function isMobile() {
var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
return iOS;
}
function resizeVideo() {
if (!youtubeLoaded) return;
var key;
var fullscreen = window.innerHeight === screen.height;
sizeBackgroundVideos();
if (isMobile() && !iosMobileAutoplay) {
for (key in videos) {
if (videos.hasOwnProperty(key)) {
if (videos[key].$videoWrapper.hasClass(classes.playing)) {
if (!fullscreen) {
pauseVideo(key);
setAsPaused(videos[key]);
}
}
videos[key].$videoWrapper.height($(document).width() / videoOptions.ratio);
}
}
setAutoplaySupport(false);
} else {
setAutoplaySupport(true);
for (key in videos) {
if (videos[key].$videoWrapper.find('.' + classes.videoWithImage).length) {
continue;
}
videoPlayers[key].playVideo();
setAsPlaying(videos[key]);
}
}
}
function initEvents() {
$(document).on('click.videoPlayer', selectors.playVideoBtn, function (evt) {
var playerId = $(evt.currentTarget).data('controls');
var player = videoPlayers[playerId];
startVideoOnClick(playerId);
player.playVideo();
evt.preventDefault();
if ($(evt.currentTarget).hasClass('is-started')) {
$(evt.currentTarget).removeClass('is-started');
}
});
$(document).on('click.videoPlayer', '.video-control__pause-mobile', function (evt) {
var playerId = $(evt.currentTarget).data('controls');
var player = videoPlayers[playerId];
player.pauseVideo();
evt.preventDefault();
});
$(document).on('click.videoPlayer', selectors.pauseVideoBtn, function (evt) {
var playerId = $(evt.currentTarget).data('controls');
togglePause(playerId);
});
}
function createPlayer(key) {
var args = $.extend({}, videoOptions, videos[key]);
args.playerVars.controls = args.controls;
args.playerVars.start = $('#' + videos[key].id).data('start');
videoPlayers[key] = new YT.Player(key, args);
}
function removeEvents() {
$(document).off('.videoPlayer');
$(window).off('.videoPlayer');
}
return {
init: init,
editorLoadVideo: editorLoadVideo,
loadVideos: loadVideos,
playVideo: customPlayVideo,
pauseVideo: pauseVideo,
removeEvents: removeEvents,
resizeVideo: resizeVideo
};
}();
THEME.special = {
init: function init() {
this.simulateEventsDemo();
this.setLanguage();
this.scrollNextSection();
if ($('.js-circle-loader-ajax').length) this.collectionLoader();
},
simulateEventsDemo: function simulateEventsDemo() {
$(document).on('click', '.js-prd-setdata', function () {
THEME.checkOutModal.setData($(this).data('product'));
});
$(document).on('click', '.js-prd-seterror', function () {
THEME.checkOutModal.setError($(this).data('error'));
});
$(document).on('click', '.js-select-adddata', function () {
THEME.selectModal.setData($(this).data('product'));
});
$(document).on('click', '.js-select-seterror', function () {
THEME.selectModal.setError($(this).data('error'));
});
$(document).on('click', '.js-select-status', function () {
alert(THEME.selectModal.getStatus());
});
},
collectionLoader: function collectionLoader() {
$(document).on('lazyloaded', '.has-infinite-scroll .js-circle-loader-ajax', function () {
$('.js-circle-loader-ajax').trigger('click');
});
},
setLanguage: function setLanguage() {
$('.js-currencies').find('a').on('click', function (e) {
var $this = $(this),
selected = $this.attr('data-value');
$this.closest('li').siblings().removeClass('active').end().closest('li').addClass('active');
$this.closest('.dropdn').find('.js-dropdn-select-current').html(selected);
$this.closest('form').find("input[name='currency']").val(selected);
$this.closest('form').submit();
e.preventDefault();
});
},
scrollNextSection: function scrollNextSection() {
function goToByScroll($section) {
var top = $section.offset().top,
h = $('.hdr-content-sticky').length ? $('.hdr-content-sticky').height() : 0;
if ($('.bnr-wrap', $section).length) {
top = $('.bnr-wrap', $section).offset().top;
}
$('html,body').animate({
scrollTop: top - h - 20
}, 300, function () {
if (!$body.hasClass('has-sticky')) {
$('html,body').animate({
scrollTop: top - 20
}, 50);
}
});
}
$('.js-scroll-to-next-section').on('click', function (e) {
if ($(this).attr('href') == '#') {
e.preventDefault();
$(this).blur();
var $next = $(this).closest('.shopify-section').next('.shopify-section');
if ($next.length) goToByScroll($next);
}
});
}
};
THEME.initialization = {
init: function init() {
this.removePreloader(1000);
this.checkDevice();
this.animations();
this.parallaxImage();
this.wishlist();
if ($('iframe').length) this.responsiveVideo();
if ($('table').length) this.tableAddClass();
this.removeEmptyParent('.prd-block_info_item > .two-column');
this.removeEmptyLinked('.colorswatch-label', 'ul');
if ($('.bnslider').length) this.mainSlider('.bnslider');
if ($('.bnslider .video').length) this.videoBannerInit('.bnslider .video');
if ($('.mobilemenu-content').length) this.hideBeforeLoad('.mobilemenu-content', 1000);
if ($('.js-filter-col').length) this.hideEmptyFilters('.js-filter-col', '.sidebar-block_content', '.filter-toggle');
if ($('.js-filter-col-horizontal').length) this.hideEmptyFiltersH('.js-filter-col-horizontal', '.sidebar-block_content', '.filter-toggle');
if ($('.product-tab').length) this.productTab('.product-tab');
this.accordionSetActive();
if ($('.collapsed-mobile').length) this.footerCollapse('.collapsed-mobile');
if ($('.qty-input').length) this.qtyInput();
if ($('[data-toggle="tooltip"]').length) this.tooltipIni('[data-toggle="tooltip"]', '.prd-block [data-toggle="tooltip"]');
if ($('.js-countdown').length) this.countdown('.js-countdown');
if ($('.js-newslettermodal').length) this.newsletterModal('.js-newslettermodal', '#newsLetterCheckBox');
if ($('.js-popupPromo').length) this.promoPopup('.js-popupPromo');
if ($('.page-content').length) this.setFullHeight('.page-content');
if ($('.bnslider--fullheight').length) this.setFullHeightSlider('.bnslider--fullheight');
if ($('#productAccordion').length) this.openAccordion('#productAccordion');
if ($('.js-simple-filter').length) this.simpleFilters('.js-simple-filter');
if ($('.fixed-scroll').length) this.compensateScrollBar('.fixed-scroll');
if ($('[data-hover-bgcolor]').length) this.hoverColor();
if ($('.js-scroll-to').length) this.scrollToTarget('.js-scroll-to');
this.agreementCheckbox();
if ($('.prd-block_accordion').length) this.tabScroll('.prd-block_accordion');
if ($('.js-video-content').length) this.videoContent('.js-video-content');
if ($('[data-toggle=popover]').length) this.popoverHtml('[data-toggle=popover]');
if ($('.brand-grid').length) this.brandsShowMore();
if ($('.js-color-hover-brand-grid').length) this.brandsColorHover();
if ($('.parallaxed').length) this.parallaxImage();
},
wishlist: function wishlist() {
var WishlistPage = {
options: {
wishlistGrid: '[data-wishlist-grid]'
},
init: function init(options) {
$.extend(this.options, options);
this._handlers(this);
},
_handlers: function _handlers(that) {
$(document).on('click', '.js-add-wishlist', function (e) {
$(this).closest('.prd, .prd-block_info').addClass('prd--in-wishlist');
e.preventDefault();
});
$(document).on('click', '.js-remove-wishlist', function (e) {
var $product = $(this).closest('.prd, .prd-block_info'),
$grid = $('.prd-grid--wishlist');
if ($grid.length) {
$grid.addClass('disable-actions');
anime({
targets: $product[0],
opacity: 0,
duration: 300,
easing: 'linear',
complete: function complete() {
$product.remove();
$product.removeClass('prd--in-wishlist');
$grid.removeClass('disable-actions');
if ($grid.children().length == 0) {
var $empty = $('.js-empty-wishlist');
if ($empty.length) {
$empty.removeClass('d-none');
anime({
targets: $empty[0],
opacity: 1,
duration: 300,
easing: 'linear'
});
}
}
}
});
} else {
$product.removeClass('prd--in-wishlist');
}
e.preventDefault();
});
}
};
var wishlistPage = Object.create(WishlistPage);
wishlistPage.init();
},
parallaxImage: function parallaxImage() {
function parallaxed(image, e) {
var amountMovedX = e.clientX * -0.3 / 8,
amountMovedY = e.clientY * -0.3 / 8,
x = $(image);
for (var i = 0; i < x.length; i++) {
x[i].style.transform = 'translate(' + amountMovedX + 'px,' + amountMovedY + 'px)';
}
}
$('.parallaxed').on('mousemove', function (event) {
parallaxed(this, event);
});
},
brandsColorHover: function brandsColorHover() {
var $grid = $('.js-color-hover-brand-grid');
$grid.on('mouseenter', 'a', function (e) {
$(this).closest('.js-color-hover-brand-grid').find('img').addClass('grayscale');
$(this).find('img').removeClass('grayscale');
}).on('mouseleave', 'a', function (e) {
$(this).closest('.js-color-hover-brand-grid').find('img').removeClass('grayscale');
});
},
brandsShowMore: function brandsShowMore() {
var $btn = $('.js-brands-show-more');
if (isMobile & !$btn.hasClass('showLess')) {
$('.brand-grid .js-hidden').hide().removeClass('visuallyhidden');
} else {
$('.brand-grid .js-hidden').show().removeClass('visuallyhidden');
}
if (!$btn.hasClass('is-init')) {
$('.js-brands-show-more').addClass('is-init');
$('.js-brands-show-more').on('click', function (e) {
$(this).closest('.holder').find('.js-hidden').fadeToggle(250);
$(this).toggleClass('showLess').blur();
e.preventDefault();
});
}
},
popoverHtml: function popoverHtml(popover) {
$document.on('click', function (event) {
var $target = $(event.target);
if ($target.closest(popover).length) {
var $btn = $target.closest(popover);
$(popover).not($btn).popover('hide').removeClass('active');
} else if ($target.closest('.popover').length) {
event.stopPropagation();
} else {
$(popover).popover('hide').removeClass('active');
}
});
$(popover).on('click', function () {
$(this).toggleClass('active');
});
$(popover).each(function () {
var $parent = $(this).closest('.lookbook-bnr');
if ($parent.length) {
$(this).popover({
html: true,
content: function content() {
return $(this).next('.js-popover-content').html();
},
animation: true,
trigger: 'click',
container: $parent,
sanitize: false,
delay: { "show": 100, "hide": 300 },
template: '
'
});
}
});
},
videoBannerInit: function videoBannerInit(video) {
$(video).each(function () {
var $el = $(this);
THEME.Video.init($el);
THEME.Video.editorLoadVideo($el.attr('id'));
});
},
videoContent: function videoContent(video) {
var $videoStopBtn = $('.js-video-stop'),
$videoPlayBtn = $('.js-video-play');
$videoPlayBtn.on('click', function () {
var $video = $(this).closest('.js-video-wrap').find(video);
$video.get(0).play();
$video.parent().addClass('is-playing').removeClass('is-paused');
});
$videoStopBtn.on('click', function () {
var $video = $(this).closest('.js-video-wrap').find(video);
$video.get(0).pause();
$video.parent().addClass('is-paused').removeClass('is-playing');
});
},
tabScroll: function tabScroll(accordion) {
$('.collapse', $(accordion)).on('show.bs.collapse', function (e) {
var $panel = $(this).closest('.panel');
var $open = $($(this).data('parent')).find('.collapse.show');
var additionalOffset = 0;
var top = $body.hasClass('has-hdr_sticky') ? $('.hdr').outerHeight() : 0;
var bottomOffset = h - ($panel.offset().top - $window.scrollTop() + $(this).height());
var scroll = $window.scrollTop() - bottomOffset + top;
if ($(this).height() > h - top) {
scroll = $panel.offset().top - additionalOffset - top;
}
if ($panel.prevAll().filter($open.closest('.panel')).length !== 0) {
additionalOffset = $open.height();
}
if (bottomOffset < 0) {
$('html,body').animate({
scrollTop: scroll
}, 500);
}
});
},
agreementCheckbox: function agreementCheckbox() {
function checkAgreement($obj) {
var $this = $obj;
if ($this.is(':checked')) {
$($this.data('button')).each(function () {
$(this).removeClass('disabled').addClass('enabled');
$(this).prop('disabled', false);
});
} else {
$($this.data('button')).each(function () {
$(this).addClass('disabled').removeClass('enabled');
$(this).prop('disabled', true);
});
}
}
$('.js-agreement-checkbox').each(function () {
checkAgreement($(this));
});
$('.js-agreement-checkbox').on('change', function () {
checkAgreement($(this));
});
},
mainSlider: function mainSlider(slider) {
var mainSlider = function mainSlider(el) {
var MainSlider = {
options: {
slider: el,
arrowsplace: '.bnslider-arrows > div',
dotsplace: '.bnslider-dots',
wrapper: '.bnslider-wrapper',
videoStopBtn: '.js-video-slider-stop',
videoPlayBtn: '.js-video-slider-play'
},
init: function init() {
this._setHeight();
this._sizeBackgroundVideos();
this._animate();
},
reinit: function reinit() {
this._setHeight();
this._sizeBackgroundVideos();
},
_animate: function _animate() {
var that = this,
$slider = $(that.options.slider),
media = $slider.find(that.options.media),
videoStopBtn = that.options.videoStopBtn,
videoPlayBtn = that.options.videoPlayBtn,
$wrapper = $slider.closest(that.options.wrapper),
arrowsplace = $wrapper.find(that.options.arrowsplace),
dotsplace = $wrapper.find(that.options.dotsplace),
animatedText = "[class^='bnslider-text'],[class*=' bnslider-text'],.btn-wrap",
$textBlock = $(animatedText, $slider);
$textBlock.each(function () {
var $this = $(this),
thisInlineStyle = '';
var thisStyle = $this.data();
for (var data in thisStyle) {
if (data == 'fontcolor') {
thisInlineStyle += 'color:' + $this.data('fontcolor') + ';';
}
if (data == 'fontfamily') {
thisInlineStyle += 'font-family:' + $this.data('fontfamily') + ';';
}
if (data == 'fontsize') {
thisInlineStyle += 'font-size:' + $this.data('fontsize') + 'px;';
}
if (data == 'fontline') {
thisInlineStyle += 'line-height:' + $this.data('fontline') + 'em;';
}
if (data == 'fontweight') {
thisInlineStyle += 'font-weight:' + $this.data('fontweight') + ';';
}
if (data == 'bgcolor') {
thisInlineStyle += 'background-color:' + $this.data('bgcolor') + ';';
}
if (data == 'otherstyle') {
thisInlineStyle += $this.data("otherstyle") + ';';
}
}
if (thisInlineStyle.length > 0) {
$this.attr('style', thisInlineStyle).addClass('data-ini');
}
});
function splitLetter(text) {
var $textWrapper = $(text);
$textWrapper.addClass('text-nowrap');
if ($textWrapper.find('span').length) {
$textWrapper.find('span').each(function () {
var $this = $(this),
style = $this.attr('style');
$this.html($this.html().replace(/([^\x00-\x80]|\w)/g, "
$&"));
$this.contents().unwrap();
});
} else $textWrapper.html($textWrapper.html().replace(/([^\x00-\x80]|\w)/g, "
$&"));
}
function doAnimations(elements, first) {
if (first) {
$('.bnslider-first-slide').removeClass('bnslider-first-slide');
return false;
}
elements.each(function () {
var $this = $(this);
var animationDelay = $this.data('animation-delay');
var animationType = $this.data('animation');
if (animationType == 'fadeInDown') {
anime({
targets: this,
opacity: [0, 1],
translateY: ['-200%', '0'],
easing: 'easeInOutSine',
duration: 500,
delay: animationDelay
});
} else if (animationType == 'fadeInUp') {
anime({
targets: this,
opacity: [0, 1],
translateY: ['200%', '0'],
easing: 'easeInOutSine',
duration: 500,
delay: animationDelay
});
} else if (animationType == 'fadeInLeft') {
anime({
targets: this,
opacity: [0, 1],
translateX: ['-200%', '0'],
easing: 'easeInOutSine',
duration: 600,
delay: animationDelay
});
} else if (animationType == 'fadeInRight') {
anime({
targets: this,
opacity: [0, 1],
translateX: ['200%', '0'],
easing: 'easeInOutSine',
duration: 600,
delay: animationDelay
});
} else if (animationType == 'fadeIn') {
anime({
targets: this,
opacity: [0, 1],
easing: 'easeInOutSine',
duration: 600,
delay: animationDelay
});
} else if (animationType == 'zoomIn') {
anime({
targets: this,
opacity: [0, 1],
scale: [.5, 1],
easing: 'easeInOutQuad',
duration: 400,
delay: animationDelay
});
} else if (animationType == 'fromLeftRubber') {
anime({
targets: [this.getElementsByClassName('circle_decor')],
opacity: [0, .75],
translateX: ['-200%', '0'],
rotate: 400,
duration: 4000,
delay: animationDelay
});
} else if (animationType == 'fromRightRubber') {
anime({
targets: [this.getElementsByClassName('circle_decor')],
opacity: [0, .75],
translateX: ['200%', '0'],
rotate: 400,
duration: 4000,
delay: animationDelay
});
} else if (animationType == 'flipY') {
anime({
targets: this,
opacity: [0, 1],
rotateY: [180, 0],
easing: 'easeInOutQuad',
duration: 500,
delay: animationDelay
});
} else if (animationType == 'flipX') {
anime({
targets: this,
opacity: [0, 1],
rotateX: [180, 0],
easing: 'easeInOutQuad',
duration: 500,
delay: animationDelay
});
} else if (animationType == 'fx1') {
splitLetter(this);
anime.timeline({ loop: false }).add({
targets: [this.getElementsByClassName('letter')],
translateY: [-100, 0],
opacity: [.5, 1],
easing: "easeOutExpo",
duration: 650,
delay: function delay(el, i) {
return animationDelay + 60 * i;
}
});
} else if (animationType == 'fx2') {
splitLetter(this);
anime.timeline({ loop: false }).add({
targets: [this.getElementsByClassName('letter')],
translateX: [40, 0],
translateZ: 0,
opacity: [0, 1],
duration: 800,
delay: function delay(el, i) {
return animationDelay + 60 * i;
}
});
} else if (animationType == 'fx3') {
splitLetter(this);
anime.timeline({ loop: false }).add({
targets: [this.getElementsByClassName('letter')],
translateY: ["1.1em", 0],
translateZ: 0,
duration: 1000,
delay: function delay(el, i) {
return animationDelay + 60 * i;
}
});
} else if (animationType == 'fx4') {
splitLetter(this);
anime.timeline({ loop: false }).add({
targets: [this.getElementsByClassName('letter')],
opacity: [0, 1],
easing: "easeInOutQuad",
duration: 1400,
delay: function delay(el, i) {
return animationDelay + 100 * (i + 1);
}
});
} else if (animationType == 'fx5') {
splitLetter(this);
anime.timeline({ loop: false }).add({
targets: [this.getElementsByClassName('letter')],
easing: 'easeOutElastic',
duration: 1200,
translateY: function translateY(el, i) {
return i % 2 === 0 ? ['-100%', '0%'] : ['100%', '0%'];
},
delay: function delay(el, i) {
return animationDelay + 50 * (i + 1);
}
});
} else if (animationType == 'fx6') {
splitLetter(this);
anime.timeline({ loop: false }).add({
targets: [this.getElementsByClassName('letter')],
rotateY: [-90, 0],
duration: 1000,
delay: function delay(el, i) {
return animationDelay + 50 * (i + 1);
}
});
} else if (animationType == 'fx7') {
var textWrapper = this.getElementsByClassName('bnslider-text-inside')[0];
var bg = [this.getElementsByClassName('bnslider-text-bg')];
splitLetter(textWrapper);
anime.timeline({ loop: false }).add({
targets: [this.getElementsByClassName('letter')],
duration: 650,
easing: 'easeOutQuint',
opacity: [0, 1],
translateX: function translateX(el, i) {
return [-1 * el.offsetLeft, 0];
},
delay: function delay(el, i) {
return animationDelay + 450 + (el.parentNode.children.length - i - 1) * 30;
}
});
anime.timeline({ loop: false }).add({
targets: bg,
translateX: ['0'],
duration: 0
}).add({
targets: bg,
easing: 'easeInOutCubic',
scaleX: [0, 1],
duration: 400,
delay: animationDelay
}).add({
targets: bg,
easing: 'easeInOutCubic',
translateX: ['0', '110%'],
duration: 400
});
}
});
}
function startInit($firstAnimatingElements) {
setTimeout(function () {
$('[data-animation]', $slider).css({ 'opacity': 1 });
doAnimations($firstAnimatingElements, true);
if ($slider.data('autoplay') == true) {
$slider.slick('slickPlay');
}
}, 1000);
}
$('.bnslider-slide', $slider).each(function () {
if ($(this).data('autoplay') == true) {
$(this).addClass('is-playing');
}
});
$slider.on('init', function (slick) {
slick = $(slick.currentTarget);
var $currentSlide = slick.find('.slick-current'),
$firstAnimatingElements = $('[data-animation]', $currentSlide);
if (isMobile) {
if (!$('.bnslider-image-mobile', $currentSlide).find('img').length) {
startInit($firstAnimatingElements);
} else {
$('.bnslider-image-mobile', $currentSlide).one('lazyloaded', function () {
startInit($firstAnimatingElements);
});
}
} else {
if (!$('.bnslider-image', $currentSlide).find('img').length) {
startInit($firstAnimatingElements);
} else {
$('.bnslider-image', $currentSlide).one('lazyloaded', function () {
startInit($firstAnimatingElements);
});
}
}
var status = $currentSlide.data('autoplay') == true ? "play" : "pause";
if ($currentSlide.find('video').length) {
setTimeout(function () {
if (status == "play") {
var playPromise = $currentSlide.find('video')[0].play();
if (playPromise !== undefined) {
playPromise.then(function () {
controlVideo(slick, status);
}).catch(function (error) {
console.info('autoplay blocked');
controlVideo(slick, 'pause');
});
}
} else {
controlVideo(slick, 'pause');
}
}, 100);
} else if ($currentSlide.find('iframe').length) {
if (status == "play") {
controlVideo($slider, "play", true);
}
}
});
$slider.on('afterChange', function (e, slick) {
slick = $(slick.$slider);
var $currentSlide = slick.find('.slick-current'),
status = $currentSlide.data('autoplay') == true && !$currentSlide.hasClass('is-custom-paused') || $currentSlide.hasClass('is-custom-playing') ? "play" : "pause",
$animatingElements = $currentSlide.find('[data-animation]');
controlVideo(slick, status);
});
$slider.on('beforeChange', function (event, slick, currentSlide, nextSlide) {
slick = $(slick.$slider);
var $nextSlide = $slider.find('.bnslider-slide[data-slick-index="' + nextSlide + '"]'),
$animatingElements = $nextSlide.find('[data-animation]');
$slider.slick('slickPlay');
controlVideo(slick, "pause");
doAnimations($animatingElements);
$slider.find('svg').css({ 'opacity': 0, 'transform': '' });
});
$slider.slick({
appendArrows: arrowsplace,
appendDots: dotsplace,
accessibility: true,
arrows: true,
dots: true,
fade: true,
draggable: true,
touchThreshold: 20,
autoplay: false,
autoplaySpeed: $slider.data('speed')
});
function playerSend(player, command) {
if (player == null || command == null) return;
player.contentWindow.postMessage(JSON.stringify(command), "*");
}
function controlVideo(slick, control, button) {
var video = void 0,
currentSlide = slick.find(".slick-current"),
slideType = currentSlide.data("video-type"),
player = currentSlide.find("iframe").get(0),
userConrol = button;
if (userConrol) currentSlide.addClass('userControl');
if (slideType === "youtube") {
switch (control) {
case "play":
playerSend(player, {
"event": "command",
"func": "mute"
});
playerSend(player, {
"event": "command",
"func": "playVideo"
});
currentSlide.addClass('is-playing').removeClass('is-paused');
if (userConrol) currentSlide.addClass('is-custom-playing').removeClass('is-custom-paused');
break;
case "pause":
playerSend(player, {
"event": "command",
"func": "pauseVideo"
});
currentSlide.removeClass('is-playing').addClass('is-paused');
if (userConrol) currentSlide.removeClass('is-custom-playing').addClass('is-custom-paused');
break;
}
} else if (slideType === "video") {
video = currentSlide.find("video").get(0);
if (video != null) {
if (control === "play") {
video.play();
currentSlide.addClass('is-playing').removeClass('is-paused');
if (userConrol) currentSlide.addClass('is-custom-playing').removeClass('is-custom-paused');
} else {
video.pause();
currentSlide.removeClass('is-playing').addClass('is-paused');
if (userConrol) currentSlide.removeClass('is-custom-playing').addClass('is-custom-paused');
}
}
}
}
$(videoPlayBtn).on('click', function () {
var $this = $(this);
if ($this.hasClass('btn')) {
if (!$this.hasClass('is-play')) {
controlVideo($slider, "play", true);
$this.addClass('is-play');
} else {
controlVideo($slider, "pause", true);
$this.removeClass('is-play');
}
} else {
controlVideo($slider, "play", true);
}
});
$(videoStopBtn).on('click', function () {
controlVideo($slider, "pause", true);
});
},
_sizeBackgroundVideos: function _sizeBackgroundVideos() {
function sizeBackgroundVideo($slide) {
if ($slide.hasClass('slick-cloned')) {
return;
}
var $player = $slide.find('iframe'),
videoOptionsRatio = 16 / 9,
slideWidth = $slide.width(),
playerWidth = $player.width(),
playerHeight = $slide.height();
if (slideWidth / videoOptionsRatio < playerHeight) {
playerWidth = Math.ceil(playerHeight * videoOptionsRatio);
if ($('body').hasClass('rtl')) {
$player.width(playerWidth).height(playerHeight).css({
right: (slideWidth - playerWidth) / 2,
top: 0
});
} else {
$player.width(playerWidth).height(playerHeight).css({
left: (slideWidth - playerWidth) / 2,
top: 0
});
}
} else {
playerHeight = Math.ceil(slideWidth / videoOptionsRatio);
$player.width(slideWidth).height(playerHeight).css({
left: 0,
right: '',
top: (playerHeight - playerHeight) / 2
});
}
}
$(this.options.slider).find('[data-video-type="youtube"]').each(function (index, el) {
sizeBackgroundVideo($(el));
});
},
_setHeight: function _setHeight() {
var $slider = $(this.options.slider);
keepScale($slider);
function keepScale(slider) {
var $bnsliderNoScale = slider;
var wW = $(window).width();
var mobileBreikpoint = 575;
if ($bnsliderNoScale.hasClass("keep-scale") && !$bnsliderNoScale.hasClass("bnslider--fullheight")) {
$bnsliderNoScale.css({
'height': '',
'min-height': ''
});
var bnrH;
if (wW <= mobileBreikpoint && parseInt($bnsliderNoScale.attr('data-start-mwidth')) > 0 && parseInt($bnsliderNoScale.attr('data-start-mheight')) > 0) {
var bnrH = parseInt($bnsliderNoScale.attr('data-start-mheight'), 10) / parseInt($bnsliderNoScale.attr('data-start-mwidth'), 10) * wW;
$bnsliderNoScale.css({
'height': bnrH + 'px',
'min-height': bnrH + 'px'
});
} else if (parseInt($bnsliderNoScale.attr('data-start-width')) > 0 && parseInt($bnsliderNoScale.attr('data-start-height')) > 0) {
var bnrH = parseInt($bnsliderNoScale.attr('data-start-height'), 10) / parseInt($bnsliderNoScale.attr('data-start-width'), 10) * wW;
if ($bnsliderNoScale.closest("div[class^='col-'],div[class*=' col-']").length) {
var colW = $bnsliderNoScale.closest("div[class^='col-'],div[class*=' col-']").width() * 100 / wW;
bnrH = bnrH * colW / 100;
} else if ($bnsliderNoScale.closest(".holder.boxed").length) {
var colW = $bnsliderNoScale.closest(".container").width() * 100 / wW;
bnrH = bnrH * colW / 100;
}
$bnsliderNoScale.css({
'height': bnrH + 'px',
'min-height': bnrH + 'px'
});
} else return false;
}
}
}
};
THEME.mainslider[el] = Object.create(MainSlider);
THEME.mainslider[el].init();
};
THEME.mainslider = {};
$(slider).each(function () {
var $el = $(this);
if ($el.hasClass('video-section-wrapper')) return false;
var bnslider = "#" + $el.attr('id');
mainSlider(bnslider);
});
},
initDelay: function initDelay() {
if ($('[data-fontratio]').length) this.flowtype();
if ($('.bnslider').length) this.sliderTextTopShift();
if ($('.js-back-to-top').length) this.backToTop('.js-back-to-top');
},
resizeSvgRect: function resizeSvgRect() {
$('svg > rect').each(function () {
var $rect = $(this),
$container = $rect.closest('.form-control-wrap');
$rect.attr('width', $container.width());
});
},
removePreloader: function removePreloader(delay) {
setTimeout(function () {
$body.addClass('no-loader').removeClass('ready');
}, delay);
setTimeout(function () {
$('.body-loader').remove();
}, delay + 1000);
},
checkDevice: function checkDevice() {
var isTouchDevice = 'ontouchstart' in window || navigator.msMaxTouchPoints;
if (navigator.userAgent.indexOf('Windows') > 0) {
$body.addClass('win');
isTouchDevice = false;
}
if (isTouchDevice) {
$body.addClass('touch');
$('html').addClass('touch');
swipemode = true;
}
if (navigator.userAgent.indexOf('Mac') > 0) {
$body.addClass('mac');
}
if (navigator.userAgent.match(/Android/)) {
$body.addClass('android');
}
if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > -1) {
$body.addClass('ie');
$('[data-srcset]').each(function () {
var img = $(this).attr('data-srcset');
$(this).attr('data-src', img);
});
$('[data-bgset]').each(function () {
var img = $(this).attr('data-bgset');
$(this).css('backgroundImage', 'url(' + img + ')');
});
}
},
animations: function animations() {
if ($('#morphing').length) {
var morphing = anime({
targets: '#morphing .p',
d: [{ value: 'M102.415 0.213527C130.863 2.47687 147.861 29.1238 165.824 51.3646C184.061 73.9452 208.291 96.5524 203.349 125.186C198.223 154.882 170.474 174.504 142.619 185.81C117.091 196.172 89.4629 192.662 64.2006 181.665C37.3147 169.962 10.5522 153.227 2.70559 124.905C-5.49916 95.2906 5.82269 64.1385 24.9965 40.1606C44.0991 16.2717 71.9772 -2.20802 102.415 0.213527Z' }, { value: 'M85.5803 0.0257094C113.027 0.686367 135.69 17.7373 153.924 38.3289C173.847 60.8277 195.211 87.2464 188.86 116.659C182.461 146.295 151.822 161.123 124.576 174.25C97.3846 187.35 66.591 202.297 39.7448 188.498C13.3189 174.916 8.32449 141.215 3.2131 111.87C-1.45393 85.0772 -3.11404 56.8126 12.9963 34.9367C29.7713 12.1583 57.3593 -0.653592 85.5803 0.0257094Z' }, { value: 'M93.5441 2.30824C127.414 -1.02781 167.142 -4.63212 188.625 21.7114C210.22 48.1931 199.088 86.5178 188.761 119.068C179.736 147.517 162.617 171.844 136.426 186.243C108.079 201.828 73.804 212.713 44.915 198.152C16.4428 183.802 6.66731 149.747 1.64848 118.312C-2.87856 89.9563 1.56309 60.9032 19.4066 38.3787C37.3451 15.7342 64.7587 5.14348 93.5441 2.30824Z' }],
easing: 'easeInOutSine',
duration: 10000,
direction: 'alternate',
loop: true
});
}
},
hoverColor: function hoverColor() {
if (!$body.hasClass('touch')) {
$document.on('mouseenter', '[data-hover-bgcolor]', function (e) {
var $this = $(e.target),
color = $this.attr('data-hover-bgcolor') ? $this.attr('data-hover-bgcolor') : '';
$this.css({
'background-color': color
});
}).on('mouseleave', '[data-hover-bgcolor]', function (e) {
var $this = $(e.target),
color = $this.attr('data-bgcolor') ? $this.attr('data-bgcolor') : '';
$this.css({
'background-color': color
});
});
$document.on('mouseenter', '[data-hover-color]', function (e) {
var $this = $(e.target),
color = $this.attr('data-hover-color') ? $this.attr('data-hover-color') : '';
$this.css({
'color': color
});
}).on('mouseleave', '[data-color]', function (e) {
var $this = $(e.target),
color = $this.attr('data-color') ? $this.attr('data-color') : '';
$this.css({
'color': color
});
});
$document.on('mouseenter', '.bnr-wrap', function (e) {
if ($(e.target).hasClass('.bnr-wrap')) {
$(e.target).find('.btn').addClass('hovered');
} else {
$(e.target).closest('.bnr-wrap').find('.btn').addClass('hovered');
}
}).on('mouseleave', '.bnr-wrap', function (e) {
if ($(e.target).hasClass('.bnr-wrap')) {
$(e.target).find('.btn').removeClass('hovered');
} else {
$(e.target).closest('.bnr-wrap').find('.btn').removeClass('hovered');
}
});
}
},
tableAddClass: function tableAddClass() {
$('table').each(function () {
if (!$(this).parent().hasClass('table-responsive')) {
$(this).addClass('table').wrap('
');
}
});
},
responsiveVideo: function responsiveVideo() {
$('iframe').each(function () {
if (!$(this).closest('.bnslider').length && !$(this).parent().hasClass('embed-responsive') && this.src.indexOf('youtube') != -1) {
$(this).wrap('
');
}
});
},
compensateScrollBar: function compensateScrollBar(el) {
$(el).css({
width: 'calc(100% + ' + scrollWidth + 'px)'
});
},
scrollOnLoad: function scrollOnLoad() {
var $elem = $($(location).attr('href').split('#')[1]);
if ($elem.length) {
setTimeout(function () {
var speed = $body.height() / 3 > 500 ? $body.height() / 3 : 500;
var wHeight = $window.height() < $elem.height() * 2 ? 0 : $window.height() - $elem.height() * 2,
offsetTop = $elem.offset().top - wHeight;
$('html,body').animate({
scrollTop: offsetTop
}, speed);
}, 500);
}
},
simpleFilters: function simpleFilters(el) {
if ($(el).length) {
THEME.simplefilters = {
default: {
gallery: '.js-simple-filter',
galleryItem: '.js-simple-filter-item',
filterLabel: '.js-simple-filter-label'
},
init: function init(options) {
$.extend(this.default, options);
var that = this,
$gallery = $(this.default.gallery);
$gallery.each(function () {
var $gallery = $(this),
$galleryItem = $(that.default.galleryItem, $gallery),
$filterLabel = $(that.default.filterLabel, $gallery),
activeStart = void 0;
that._handlers($filterLabel, $galleryItem, $gallery);
$filterLabel.each(function () {
var $this = $(this),
selectedCategory = $this.attr('data-filter'),
count = '
' + $gallery.find(selectedCategory).length + '';
$this.append(count);
if ($this.hasClass('active')) {
$galleryItem.filter(selectedCategory).fadeIn(0).addClass('isvisible');
activeStart = true;
} else {
$galleryItem.fadeIn(0).addClass('isvisible');
}
});
if (!activeStart) $filterLabel.first().trigger('click');
that._clickFirst($gallery);
});
},
_clickFirst: function _clickFirst($gallery) {
if ($('.faq-item', $gallery).length) {
$('.panel-heading.active', $gallery).find('.panel-title').trigger('click');
$('.faq-item.isvisible', $gallery).first().find('.panel-title').trigger('click');
}
},
_handlers: function _handlers($filterLabel, $galleryItem, $gallery) {
var that = this;
$filterLabel.on('click', function (e) {
var $this = $(this),
selectedCategory = $this.attr('data-filter');
if ($this.hasClass('active')) {
return false;
} else {
$this.siblings().removeClass('active');
$this.addClass('active');
}
if (!selectedCategory) {
$galleryItem.fadeIn(0).addClass('isvisible');
} else {
$galleryItem.filter(':not(' + selectedCategory + ')').fadeOut(0).removeClass('isvisible');
$galleryItem.filter(selectedCategory).fadeIn(0).addClass('isvisible');
}
that._clickFirst($gallery);
e.preventDefault();
});
},
reinit: function reinit() {
this.init();
return this;
}
};
THEME.simplefilters.init();
}
},
imageLoadedProductPage: function imageLoadedProductPage(image) {
$(image).each(function () {
var $this = $(this);
if ($this.closest('.prd')) $this.find('img').css({
opacity: 0
});
$this.imagesLoaded(function () {
$this.addClass('loaded');
$this.find('img').animate({
opacity: 1
}, 200);
});
});
},
imageLoaded: function imageLoaded(image, carousel) {
var $imageL = $(image);
if (carousel) {
$imageL = image;
}
$imageL.each(function () {
var $this = $(this);
if ($('.prd-img-area', $this).length) {
$('.prd-img-area', $this).imagesLoaded(function () {
$this.addClass('loaded');
});
} else {
$this.imagesLoaded(function () {
$this.addClass('loaded');
});
}
});
},
removeEmpty: function removeEmpty(selector) {
$(selector).each(function () {
var $this = $(this);
if (!$.trim($this.html()).length) $this.remove();
});
},
removeEmptyParent: function removeEmptyParent(selector) {
$(selector).each(function () {
var $this = $(this);
if (!$.trim($this.html()).length) {
$this.parent().remove();
} else $this.parent().removeClass('d-none');
});
},
removeEmptyLinked: function removeEmptyLinked(target, empty) {
$(target).each(function () {
var $this = $(this),
$empty = $this.find(empty);
if (!$.trim($empty.html()).length) $this.remove();
});
},
setFullHeight: function setFullHeight(el) {
if ($(el).length) {
THEME.setfullheight = {
default: {
holder: '.page-content, .page404-bg',
header: '.hdr-wrap',
footer: '.page-footer'
},
init: function init(options) {
$.extend(this.default, options);
var that = this;
$(that.default.holder).each(function () {
var $this = $(this),
wh = $window.height();
if ($(that.default.header).length && $(that.default.footer).length) {
$this.css({
'min-height': wh - $(that.default.header).outerHeight() - $(that.default.footer).outerHeight() - parseInt($(that.default.footer).css('marginTop')) + 'px'
});
} else if ($(that.default.header).length) {
$this.css({
'min-height': wh - $(that.default.header).outerHeight() + 'px'
});
} else if ($(that.default.footer).length) {
$this.css({
'min-height': wh - $(that.default.footer).outerHeight() - parseInt($(that.default.footer).css('marginTop')) + 'px'
});
}
});
},
reinit: function reinit() {
this.init();
return this;
}
};
THEME.setfullheight.init();
}
},
setFullHeightSlider: function setFullHeightSlider(el) {
if ($(el).length) {
THEME.setfullheightslider = {
default: {
slider: '.bnslider--fullheight',
header: '.hdr',
footer: '.footer-style-5'
},
init: function init(options) {
$.extend(this.default, options);
var that = this;
$(that.default.slider).each(function () {
var $this = $(this),
wh = $window.height(),
$header = $(that.default.header),
$footer = $(that.default.footer);
if ($header.length) {
wh = wh - $header.outerHeight();
}
if ($footer.length) {
wh = wh - $footer.outerHeight();
}
$this.css({
'min-height': wh + 'px'
});
});
},
reinit: function reinit() {
this.init();
return this;
}
};
THEME.setfullheightslider.init();
}
},
backToTop: function backToTop(button) {
function scrollToTop() {
$body.addClass('blockSticky');
$('html').addClass('scroll-auto');
var speed = $window.scrollTop() / 5 > 500 ? $window.scrollTop() / 5 : 500;
if (isMobile) {
speed = speed / 2;
}
$('html, body').animate({
scrollTop: 0
}, speed, function () {
$body.removeClass('blockSticky');
$('html').removeClass('scroll-auto');
});
$body.hasClass('has-hdr_sticky') ? THEME.stickyheader.destroySticky() : false;
}
if ($(button).length) {
var $button = $(button),
windowH = $window.height();
if ($window.scrollTop() > windowH / 2) {
$button.addClass('is-visible');
}
$window.on('scroll', function () {
if ($(this).scrollTop() > h / 2) {
$button.addClass('is-visible');
} else {
$button.removeClass('is-visible');
}
});
$button.on('click', function (e) {
scrollToTop();
e.preventDefault();
});
}
},
promoPopup: function promoPopup(modal) {
!function (t) {
var e = {};!function () {
var o,
n = t.requestAnimationFrame || t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || t.oRequestAnimationFrame || t.msRequestAnimationFrame || function (e) {
t.setTimeout(e, 1e3 / 60);
},
i = { particleCount: 50, angle: 90, spread: 45, startVelocity: 45, decay: .9, ticks: 200, x: .5, y: .5, zIndex: 100, colors: ["#26ccff", "#a25afd", "#ff5e7e", "#88ff5a", "#fcff42", "#ffa62d", "#ff36ff"] };function r() {}function l(t, e, o) {
return n = t && null != t[e] ? t[e] : i[e], (r = o) ? r(n) : n;var n, r;
}function a(t) {
return parseInt(t, 16);
}function c(t) {
t.width = document.documentElement.clientWidth, t.height = document.documentElement.clientHeight;
}function s(t) {
var e,
o,
n = t.angle * (Math.PI / 180),
i = t.spread * (Math.PI / 180);return { x: t.x, y: t.y, wobble: 10 * Math.random(), velocity: .5 * t.startVelocity + Math.random() * t.startVelocity, angle2D: -n + (.5 * i - Math.random() * i), tiltAngle: Math.random() * Math.PI, color: (e = t.color, o = String(e).replace(/[^0-9a-f]/gi, ""), o.length < 6 && (o = o[0] + o[0] + o[1] + o[1] + o[2] + o[2]), { r: a(o.substring(0, 2)), g: a(o.substring(2, 4)), b: a(o.substring(4, 6)) }), tick: 0, totalTicks: t.ticks, decay: t.decay, random: Math.random() + 5, tiltSin: 0, tiltCos: 0, wobbleX: 0, wobbleY: 0 };
}function u(o, i, l) {
var a = i.slice(),
s = o.getContext("2d"),
u = o.width,
d = o.height;function m() {
u = d = null;
}var f,
h = (f = function f(e) {
n(function i() {
u || d || (c(o), u = o.width, d = o.height), s.clearRect(0, 0, u, d), (a = a.filter(function (t) {
return function (t, e) {
e.x += Math.cos(e.angle2D) * e.velocity, e.y += Math.sin(e.angle2D) * e.velocity + 3, e.wobble += .1, e.velocity *= e.decay, e.tiltAngle += .1, e.tiltSin = Math.sin(e.tiltAngle), e.tiltCos = Math.cos(e.tiltAngle), e.random = Math.random() + 5, e.wobbleX = e.x + 10 * Math.cos(e.wobble), e.wobbleY = e.y + 10 * Math.sin(e.wobble);var o = e.tick++ / e.totalTicks,
n = e.x + e.random * e.tiltCos,
i = e.y + e.random * e.tiltSin,
r = e.wobbleX + e.random * e.tiltCos,
l = e.wobbleY + e.random * e.tiltSin;return t.fillStyle = "rgba(" + e.color.r + ", " + e.color.g + ", " + e.color.b + ", " + (1 - o) + ")", t.beginPath(), t.moveTo(Math.floor(e.x), Math.floor(e.y)), t.lineTo(Math.floor(e.wobbleX), Math.floor(i)), t.lineTo(Math.floor(r), Math.floor(l)), t.lineTo(Math.floor(n), Math.floor(e.wobbleY)), t.closePath(), t.fill(), e.tick < e.totalTicks;
}(s, t);
})).length ? n(i) : (t.removeEventListener("resize", m), l(), e());
});
}, e.exports.Promise ? new e.exports.Promise(f) : (f(r), null));return t.addEventListener("resize", m, !1), { addFettis: function addFettis(t) {
return a = a.concat(t), h;
}, canvas: o, promise: h };
}e.exports = function (t) {
for (var e, n, i, r = l(t, "particleCount", Math.floor), a = l(t, "angle", Number), d = l(t, "spread", Number), m = l(t, "startVelocity", Number), f = l(t, "decay", Number), h = l(t, "colors"), b = l(t, "ticks", Number), y = l(t, "zIndex", Number), g = ((e = l(t, "origin", Object)).x = l(e, "x", Number), e.y = l(e, "y", Number), e), M = r, p = [], x = o ? o.canvas : (n = y, c(i = document.createElement("canvas")), i.style.position = "fixed", i.style.top = "0px", i.style.left = "0px", i.style.pointerEvents = "none", i.style.zIndex = n, i), v = x.width * g.x, w = x.height * g.y; M--;) {
p.push(s({ x: v, y: w, angle: a, spread: d, startVelocity: m, color: h[M % h.length], ticks: b, decay: f }));
}return o ? o.addFettis(p) : (document.body.appendChild(x), (o = u(x, p, function () {
o = null, document.body.removeChild(x);
})).promise);
}, e.exports.Promise = t.Promise || null;
}(), t.confetti = e.exports;
}(window);
var $promoPopup = $(modal);
function checkCookie() {
if ($.cookie('foxicPromoPopup') != 'yes' || $promoPopup.attr('data-expires') == '0' || $('body').hasClass('demo')) {
openPromoPopup();
}
}
function openPromoPopup() {
var pause = $promoPopup.attr('data-pause') > 0 ? $promoPopup.attr('data-pause') : 2000,
src = $promoPopup.attr('data-src');
setTimeout(function () {
$.fancybox.open([{
src: src,
type: 'ajax',
btnTpl: {
smallBtn: ''
},
baseTpl: '
"
}], {
buttons: ['close'],
touch: false,
afterShow: function afterShow() {
var effect = $promoPopup.attr('data-effect');
if (effect == 'confetti') {
var i;
(function () {
var colors = ['#f0771a', '#ffffff', '#a83ae5'];
for (i = 0; i < 3; i++) {
setTimeout(function () {
confetti({
particleCount: 100,
spread: 50 + i * 15,
colors: colors,
zIndex: 1000
});
}, 500 * i);
}
})();
} else if (effect == 'snow') {
var duration = 7 * 1000;
var animationEnd = Date.now() + duration;
var skew = 1;
(function frame() {
var timeLeft = animationEnd - Date.now();
var ticks = Math.max(200, 500 * (timeLeft / duration));
skew = Math.max(0.8, skew - 0.001);
confetti({
particleCount: 1,
startVelocity: 0,
ticks: ticks,
gravity: 0.5,
zIndex: 1000,
origin: {
x: Math.random(),
y: Math.random() * skew - 0.2
},
colors: ['#ffffff'],
shapes: ['circle']
});
if (timeLeft > 0) {
requestAnimationFrame(frame);
}
})();
} else if (effect == 'fireworks') {
var end = Date.now() + 5 * 1000;
var colors = ['#ffffff', '#f83f81'];
(function frame() {
confetti({
particleCount: 2,
angle: 60,
spread: 55,
origin: {
x: 0
},
colors: colors,
zIndex: 1000
});
confetti({
particleCount: 2,
angle: 120,
spread: 55,
origin: {
x: 1
},
colors: colors,
zIndex: 1000
});
if (Date.now() < end) {
requestAnimationFrame(frame);
}
})();
}
}
});
}, pause);
}
$(document).on('click', '.js-popup-promo-close', function () {
$.cookie('foxicPromoPopup', 'yes', {
expires: parseInt($promoPopup.attr('data-expires'), 10)
});
parent.jQuery.fancybox.getInstance().close();
});
checkCookie();
},
newsletterModal: function newsletterModal(modal, checkbox) {
if ($('body').hasClass('newslettermodal-error')) {
setTimeout(function () {
$.fancybox.open([{
src: '.js-newslettermodal',
type: 'inline',
btnTpl: {
smallBtn: '
'
}
}], {
buttons: ['close'],
touch: false,
afterClose: function afterClose() {
$.cookie('foxicNewsLetter', 'yes', {
expires: parseInt($newsletter.attr('data-expires'), 10)
});
}
});
}, 1000);
}
var $newsletter = $(modal),
$checkBox = $(checkbox);
if ($newsletter.attr('data-only-index') == 'true' && !$('body[class*="page-index"]').length) {
return false;
}
function checkCookie() {
if ($.cookie('foxicNewsLetter') != 'yes' || $newsletter.attr('data-expires') == '0' || $('body').hasClass('demo')) {
openNewsletterPopup();
}
}
function openNewsletterPopup() {
var pause = $newsletter.attr('data-pause') > 0 ? $newsletter.attr('data-pause') : 2000;
setTimeout(function () {
if ($newsletter.hasClass('modal-info-content')) {
$.fancybox.open([{
src: modal,
type: 'inline',
btnTpl: {
smallBtn: '
'
}
}], {
buttons: ['close'],
touch: false,
afterClose: function afterClose() {
$.cookie('foxicNewsLetter', 'yes', {
expires: parseInt($newsletter.attr('data-expires'), 10)
});
}
});
} else {
$newsletter.removeClass('d-none').addClass('opened');
anime({
targets: modal,
translateY: ['100%', '0%'],
easing: 'spring(1, 80, 10, 0)',
duration: 300,
complete: function complete() {
if ($newsletter.find('svg').length) THEME.initialization.resizeSvgRect();
}
});
}
}, pause);
setTimeout(function () {
if ($('body').hasClass('newslettermodal-off')) {
$.cookie('foxicNewsLetter', 'yes', {
expires: parseInt($newsletter.attr('data-expires'), 10)
});
}
}, pause * 2);
}
$document.on('click', '.js-popup-newsletter-close', function () {
$.cookie('foxicNewsLetter', 'yes', {
expires: parseInt($newsletter.attr('data-expires'), 10)
});
$newsletter.removeClass('opened');
anime({
targets: modal,
translateY: ['0%', '100%'],
easing: 'spring(1, 80, 10, 0)',
duration: 300
});
});
var uri = window.location.toString();
if (uri.indexOf("?customer_posted=true") > 0) {
$.cookie('foxicNewsLetter', 'yes', {
expires: parseInt($newsletter.attr('data-expires'), 10)
});
} else {
checkCookie();
}
},
hideEmptyFilters: function hideEmptyFilters(columnFilter, filter, mobFilter) {
if (!$(columnFilter).find(filter).length) {
$(columnFilter).addClass('d-none');
$(mobFilter).addClass('d-none');
}
},
hideEmptyFiltersH: function hideEmptyFiltersH(columnFilter, filter, mobFilter) {
if (!$(columnFilter).find(filter).length) {
$(columnFilter).addClass('d-none');
$(mobFilter).addClass('d-none');
}
},
sliderTextTopShift: function sliderTextTopShift() {
THEME.slidertexttopshift = {
default: {
header: '.hdr-wrap .hdr',
text: '.bnslider-text-content-flex'
},
init: function init(options) {
$.extend(this.default, options);
if (!isMobile && !$('.aside').length) {
if ($('.hdr-transparent').length) {
$(this.default.header).addClass('visible');
$(this.default.text).css({
'padding-top': $(this.default.header).outerHeight() * .85
});
}
} else {
$(this.default.text).css({
'padding-top': ''
});
}
return this;
},
reinit: function reinit() {
this.init();
return this;
}
};
THEME.slidertexttopshift.init();
},
hideBeforeLoad: function hideBeforeLoad(el, timeOut) {
$(el).css('visibility', 'hidden');
setTimeout(function () {
$(el).css('visibility', '').addClass('loaded');
}, timeOut);
},
countdown: function countdown(_countdown) {
function removeCountdown($countdown) {
if ($countdown.closest('.js-countdown-wrap').length) {
$countdown.closest('.js-countdown-wrap').remove();
} else $countdown.remove();
}
$(_countdown).each(function () {
var $countdown = $(this),
promoperiod = void 0,
isActual = false,
timeLocale = ['DAYS', 'HRS', 'MIN', 'SEC'];
if ($body.data('time-locale')) {
timeLocale = $body.data('time-locale').split('/');
}
if ($countdown.attr('data-promoperiod')) {
promoperiod = parseInt($countdown.attr('data-promoperiod'), 10);
isActual = promoperiod > 0;
promoperiod = new Date().getTime() + promoperiod;
}
if ($countdown.attr('data-countdown')) {
promoperiod = $countdown.attr('data-countdown');
isActual = Date.parse(promoperiod) - Date.parse(new Date()) > 0;
}
if (isActual) {
$countdown.countdown(promoperiod, function (event) {
$countdown.html(event.strftime('
%D' + timeLocale[0] + '' + '
%H' + timeLocale[1] + '' + '
%M' + timeLocale[2] + '' + '
%S' + timeLocale[3] + ''));
}).on('finish.countdown', function () {
removeCountdown($countdown);
});
} else {
removeCountdown($countdown);
}
if ($countdown.closest('.js-countdown-wrap').length) {
$countdown.closest('.js-countdown-wrap').addClass('countdown-init');
}
});
},
productTab: function productTab(tab) {
var $tabs = $(tab),
setCurrent = false;
$tabs.tabCollapse({
accordion: true,
tabsClass: 'd-none d-lg-flex',
accordionClass: 'panel-group--style2 d-lg-none'
});
$('.panel-title').each(function () {
if ($(this).children().length < 2) {
$(this).append('
');
}
});
$('a', $tabs).each(function () {
var $this = $(this);
if ($this.parent('li').is('.active')) {
var curTab = $this.attr('href');
$(curTab).addClass('active');
setCurrent = true;
}
});
if (!setCurrent) {
$('li:first-child a', $tabs).tab('show');
}
},
accordionSetActive: function accordionSetActive() {
$body.on('show.bs.collapse', '.panel-collapse', function (e) {
$(e.currentTarget).siblings('.panel-heading').addClass('active');
}).on('hide.bs.collapse', '.panel-collapse', function (e) {
$(e.currentTarget).siblings('.panel-heading').removeClass('active');
});
if (w < maxLG) {
setTimeout(function () {
$('.panel-group').each(function () {
if ($(this).closest('.holder').data('open-mobile')) {
var $first = $(this).find('.panel').first();
$first.find('.panel-heading').addClass('active');
$first.find('.panel-heading a').removeClass('collapsed');
$first.find('.panel-collapse').addClass('show');
}
});
}, 1000);
}
},
openAccordion: function openAccordion(accordion) {
if ($(accordion).find('.panel-heading.active')) return false;
$(accordion).find('.panel-body').each(function () {
var $this = $(this);
if (!$.trim($this.html()).length) $this.closest('.panel').remove();
}).promise().done($(accordion).find('.panel:first-child').find('.panel-title > a').trigger('click'));
},
flowtype: function flowtype() {
THEME.flowtype = {
default: {
maximum: 9999,
minimum: 1,
maxFont: 9999,
minFont: 1
},
init: function init(bnr) {
var that = this;
$(bnr).each(function () {
var $this = $(this);
$this.imagesLoaded(function () {
var fontratio = Math.round($this.attr('data-fontratio') * 100) / 100;
if (fontratio > 0) {
that._changes($this, fontratio);
}
if ($this.find('.js-bnr-caption-carousel').length) {
$this.find('.js-bnr-caption-carousel').each(function () {
$(this).slick({
autoplay: true,
arrows: false,
dots: false,
slidesToShow: 1,
draggable: false,
infinite: true,
pauseOnHover: false,
swipe: false,
touchMove: false,
vertical: true,
speed: 1000,
autoplaySpeed: 2000,
useTransform: true,
cssEase: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)'
});
});
}
});
});
},
hide: function hide(bnr) {
var that = this;
$(bnr).each(function () {
$(this).removeClass('fontratio-calc');
});
},
hideCaption: function hideCaption(bnr) {
$(bnr).each(function () {
$(this).find('.bnr-caption').css({ 'opacity': 0 });
});
},
showCaption: function showCaption(bnr) {
$(bnr).each(function () {
$(this).find('.bnr-caption').css({ 'opacity': 1 });
});
},
reinit: function reinit(bnr) {
var that = this;
$(bnr).each(function () {
var $this = $(this),
fontratio = Math.round($this.attr('data-fontratio') * 100) / 100;
$this.removeClass('fontratio-calc');
if (fontratio > 0) {
that._changes($this, fontratio);
}
});
},
_changes: function _changes(el, fontRatio) {
var $el = $(el),
elw = $el.width(),
width = elw > this.default.maximum ? this.default.maximum : elw < this.default.minimum ? this.default.minimum : elw,
fontBase = width / fontRatio,
fontSize = fontBase > this.default.maxFont ? this.default.maxFont : fontBase < this.default.minFont ? this.default.minFont : fontBase;
setTimeout(function () {
$el.css('font-size', fontSize + 'px').addClass('fontratio-calc');
}, 100);
}
};
THEME.flowtype.init('.bnr[data-fontratio]');
},
footerCollapse: function footerCollapse(el) {
$('.footer-block').each(function () {
if (!$(this).hasClass('collapsed-mobile')) {
$(this).parent().addClass('col-no-collapsed');
}
});
$.fn.footerCollapse = function () {
var $collapsed = this;
$('.title', $collapsed).on('click', function (e) {
e.preventDefault;
$(this).closest('.collapsed-mobile').toggleClass('open');
});
};
$(el).footerCollapse();
},
qtyInput: function qtyInput() {
$.fn.textWidth = function (text, font) {
if (!$.fn.textWidth.fakeEl) $.fn.textWidth.fakeEl = $('
').hide().appendTo(document.body);
$.fn.textWidth.fakeEl.text(text || this.val() || this.text() || this.attr('placeholder')).css('font', font || this.css('font'));
return $.fn.textWidth.fakeEl.width();
};
$document.on('click', '.js-qty-button', function (e) {
var $this = $(e.target),
input = $this.parent().find('.qty-input'),
v = $this.hasClass('decrease') ? input.val() - 1 : input.val() * 1 + 1,
min = input.attr('data-min') ? input.attr('data-min') : 1,
max = input.attr('data-max') ? input.attr('data-max') : false,
inputWidth = void 0;
if (v >= min) {
if (!max == false && v > max) {
return false;
} else input.val(v);
}
inputWidth = input.textWidth();
input.css({ width: inputWidth + 10 });
e.preventDefault();
});
$document.on('input', '.qty-input', function (e) {
var input = $(e.target),
min = input.attr('data-min') ? input.attr('data-min') : 1,
max = input.attr('data-max') ? input.attr('data-max') : 1000,
v = Math.round(input.val()),
inputWidth = 0;
if (v > max) {
input.val(max);
} else if (v < min) {
input.val(min);
}
inputWidth = input.textWidth();
input.css({ width: inputWidth + 10 });
});
},
tooltipIni: function tooltipIni(tooltip) {
if (!isMobile) {
$(tooltip).each(function () {
var $this = $(this);
$this.tooltip({
animation: false,
trigger: 'hover',
placement: $this.attr('data-placement')
});
});
$('[data-toggle="tooltip"]').on('shown.bs.tooltip', function () {
if ($('.tooltip').hasClass('bs-tooltip-right')) {
$('.tooltip').addClass('tooltipright');
} else if ($('.tooltip').hasClass('bs-tooltip-left')) {
$('.tooltip').addClass('tooltipleft');
} else if ($('.tooltip').hasClass('bs-tooltip-top')) {
$('.tooltip').addClass('tooltiptop');
} else if ($('.tooltip').hasClass('bs-tooltip-bottom')) {
$('.tooltip').addClass('tooltipbottom');
}
});
}
},
modalCountDown: function modalCountDown(modal) {
var $modal = $(modal);
if ($modal.length) {
var counter = void 0;
$modal.on('hidden.bs.modal', function () {
var $modal = $(this);
if ($modal.attr('data-interval') > 0) {
$('.count', $modal).html('').fadeOut();
clearInterval(counter);
}
});
$modal.on('shown.bs.modal', function () {
var interval = 0,
$modal = $(this);
if ($modal.attr('data-interval') > 0) {
interval = $modal.attr('data-interval');
}
var count = interval / 1000;
if (count > 0) {
$('.modal--countdown', $modal).show();
$('.count', $modal).html(count).fadeIn();
counter = setInterval(function modalCount() {
if (count > 0) {
count -= 1;
$('.count', $modal).html(count);
} else {
$modal.modal('hide').removeData('bs.modal');
clearInterval(counter);
}
}, 1000);
}
});
}
},
scrollToDiv: function scrollToDiv(el, speed) {
var $header = $('.hdr'),
$el = $(el),
speedScroll = speed ? speed : 300;
if ($el.length) {
$('html,body').animate({
scrollTop: $el.offset().top - $header.height()
}, speedScroll);
}
},
scrollToTarget: function scrollToTarget(link) {
var header = '.hdr';
function goToByScroll(id) {
id = id.replace('link", "');
$('html,body').animate({
scrollTop: $(id).offset().top - $(header).height()
}, 500);
}
$(link).on('click', function (e) {
e.preventDefault();
$(this).blur();
goToByScroll($(this).attr('href'));
});
}
};
THEME.header = {
init: function init() {
this.headerDrop();
this.megaMenu();
this.mmobilePush();
this.searchAutoFill('.js-search-autofill', 'a', '.search-input');
this.searchInput('.search-input');
this.dropdnSelect('.js-dropdn-select');
},
dropdnSelect: function dropdnSelect(link) {
$(link).on('click', 'a', function (e) {
var selected = $(this).text();
$(this).closest('li').siblings().removeClass('active').end().closest('li').addClass('active');
$(this).closest('.dropdn').find('.js-dropdn-select-current').html(selected);
e.preventDefault();
});
},
promoTopline: function promoTopline(topline, close) {
var $topline = $(topline),
$close = $(close),
speed = 300,
timeout = 1000;
if ($('.hdr-mobile-style2').length && isMobile) {
speed = 100;
timeout = 0;
}
function checkCookie() {
if ($.cookie('THEMEPromoTopLine') != 'yes') {
setTimeout(function () {
$topline.slideDown(speed, function () {
promoToplineHeight = $topline.outerHeight();
if ($body.hasClass('has-hdr_sticky')) THEME.stickyheader.setHeaderHeight();
});
}, timeout);
} else {
$topline.slideUp(0);
promoToplineHeight = 0;
if ($body.hasClass('has-hdr_sticky')) THEME.stickyheader.setHeaderHeight();
}
}
$close.on('click', function () {
if ($body.hasClass('demo')) {
$topline.slideUp(speed);
promoToplineHeight = 0;
if ($body.hasClass('has-hdr_sticky')) THEME.stickyheader.setHeaderHeight();
} else {
$.cookie('THEMEPromoTopLine', 'yes', {
expires: parseInt($topline.attr('data-expires'), 10)
});
checkCookie();
}
});
checkCookie();
},
searchAutoFill: function searchAutoFill(parent, link, target) {
$(parent).find(link).on('click', function (e) {
if ($(target).val() == $(this).html()) {
return false;
}
$(target).val($(this).html()).focus().trigger('keyup');
e.preventDefault();
});
},
searchInput: function searchInput(input) {
$(input).on('input', function () {
!$(this).val() ? $(this).addClass('input-empty') : $(this).removeClass('input-empty');
});
},
megaMenu: function megaMenu() {
THEME.megamenu = {
defaults: {
header: '.hdr',
menu: '.mmenu-js',
submenu: '.mmenu-submenu',
toggleMenu: '.toggleMenu',
simpleDropdn: '.mmenu-item--simple',
megaDropdn: '.mmenu-item--mega',
headerCart: '.minicart-js',
headerCartToggleBtn: '.minicart-link',
headerCartDropdn: '.minicart-drop',
dropdn: '.dropdn',
titleHeight: 50
},
init: function init(options) {
$.extend(this.defaults, options);
if ($(this.defaults.menu).length) {
this._handlers(this);
if ($(this.defaults.menu).find('.menu-label').length) {
$(this.defaults.menu).addClass('mmenu--withlabels');
}
}
},
_handlers: function _handlers(menu) {
function setMaxHeight(wHeight, submenu) {
if ($menu.hasClass('mmenu--vertical')) return false;
if (submenu.length) {
var maxH = $body.hasClass('has-sticky') ? wHeight - $('.hdr-content-sticky').outerHeight() : wHeight - submenu.prev().offset().top - submenu.prev().outerHeight();
submenu.children(':first').css({
'max-height': maxH + 'px'
});
}
}
function clearMaxHeight() {
$submenu.each(function () {
var $this = $(this);
$this.css({
'max-height': ''
});
});
}
var $menu = $(menu.defaults.menu),
submenu = menu.defaults.submenu,
$submenu = $(menu.defaults.submenu, $menu),
$header = $(menu.defaults.header),
$toggleMenu = $(menu.defaults.toggleMenu),
megaDropdnClass = menu.defaults.megaDropdn,
simpleDropdnClass = menu.defaults.simpleDropdn,
vertical = menu.defaults.vertical,
$headerCart = $(menu.defaults.headerCart),
$headerCartToggleBtn = $headerCart.find(menu.defaults.headerCartToggleBtn),
$headerCartDropdn = $headerCart.find(menu.defaults.headerCartDropdn),
$dropdn = $(menu.defaults.dropdn, $header),
timer = void 0;
$menu.on('mouseenter.mmenu', megaDropdnClass + '> a,' + simpleDropdnClass + '> a', function () {
var $this = $(this);
timer = setTimeout(function () {
$submenu = $this.next(submenu);
setMaxHeight($window.height(), $submenu);
$submenu.scrollTop(0);
$this.parent('li').addClass('hovered');
$submenu.find('.mmenu-col').each(function (i) {
var $this = $(this);
anime({
targets: $this[0],
opacity: [0, 1],
translateY: ['80px', '0'],
translateZ: 0,
translateX: 0,
easing: 'cubicBezier(0.165, 0.84, 0.44, 1)',
duration: 650,
delay: i * 100,
complete: function complete() {
$this.css({ 'transform': 'none' });
}
});
});
if ($headerCartDropdn.hasClass('opened')) {
$headerCartToggleBtn.trigger('click');
}
$dropdn.each(function () {
var $this = $(this);
if ($this.hasClass('is-hovered')) {
$('>a', $this).trigger('click');
}
});
}, 200);
}).on('mouseleave.mmenu', megaDropdnClass + ',' + simpleDropdnClass, function () {
var $this = $(this);
clearTimeout(timer);
clearMaxHeight();
$this.removeClass('hovered');
});
$toggleMenu.on('click', function (e) {
var $this = this;
$header.toggleClass('open');
$this.toggleClass('open');
$menu.addClass('disable').delay(1000).queue(function () {
$this.removeClass('disable').dequeue();
});
e.preventDefault();
});
$('li', $submenu).on('mouseenter', function () {
var $this = $(this).addClass('hovered');
if ($('> a .mmenu-preview', $this).length) {
var $ul = $this.closest('ul'),
$img = $('.mmenu-preview', $this);
$ul.css({
'min-width': '',
'overflow': ''
});
$ul.css({
'min-width': 454,
'overflow': 'hidden'
});
$ul.append($img.clone());
}
if ($('> .submenu-link-image', $this).length) {
var $elm = $('> .submenu-link-image', $this),
isXvisible = $body.hasClass('rtl') ? $elm.offset().left >= 0 : $elm.offset().left + $elm.width() <= w,
isYvisible = h + $window.scrollTop() - ($elm.offset().top + $elm.outerHeight());
if (!isXvisible) {
$elm.addClass('to-right');
} else {
$elm.removeClass('to-right');
}
if (isYvisible < 0) {
$elm.css({
'margin-top': isYvisible + 'px'
});
}
} else if ($('ul', $this).length) {
var _$elm = $('.mmenu-submenu', $this).length ? $('.mmenu-submenu', $this) : $('ul:first', $this),
_isXvisible = 0,
_isYvisible = 0;
if ($this.closest('.mmenu-item--mega').length && $this.parent().hasClass('submenu-list')) {
if (!$body.hasClass('rtl')) {
_$elm.css({
top: $this.offset().top - $this.closest('.mmenu-submenu').offset().top,
left: $this.offset().left + $this.outerWidth()
});
} else {
_$elm.css({
top: $this.offset().top - $this.closest('.mmenu-submenu').offset().top,
left: $this.offset().left - _$elm.outerWidth()
});
}
}
_isXvisible = $body.hasClass('rtl') ? _$elm.offset().left >= 0 : _$elm.offset().left + _$elm.width() <= w;
_isYvisible = h + $window.scrollTop() - (_$elm.offset().top + _$elm.outerHeight());
if (!_isXvisible) {
$this.addClass('to-right');
} else {
$this.removeClass('to-right');
}
if (_isYvisible < 0) {
_$elm.css({
'margin-top': _isYvisible + 'px'
});
}
}
}).on('mouseleave', function () {
var $elm = $('.mmenu-submenu', this).length ? $('.mmenu-submenu', this) : $('ul:first', this);
var $this = $(this).removeClass('to-right').removeClass('hovered');
$('.submenu-link-image', $(this)).removeClass('to-right');
if ($('> a .mmenu-preview', $this).length) {
var $ul = $this.closest('ul');
$ul.css({
'min-width': '',
'overflow': ''
});
$ul.find('>.mmenu-preview').remove();
}
$elm.css({
'margin-top': ''
});
if (!$this.closest('.sub-level').length) {
$elm.closest('.mmenu-submenu').removeClass('mmenu--not-hide').css({
'padding-right': ''
});
}
if ($('.submenu-link-image', $this).length) {
$('.submenu-link-image', $this).css({
'margin-top': ''
});
}
});
}
};
THEME.megamenu.init();
},
mobileMenu: function mobileMenu() {
THEME.mobilemenu = {
defaults: {
mobilemenu: '.mobilemenu',
toggleMenu: '.mobilemenu-toggle',
search: '.search_container_desktop',
searchOpenMobile: '.search_container_mobile',
mobileMenuScroll: '.mobilemenu-scroll'
},
init: function init(options) {
$.extend(this.defaults, options);
var obj = {
$mobilemenu: $(this.defaults.mobilemenu),
$toggleMenu: $(this.defaults.toggleMenu),
$lang: $(this.defaults.lang),
$currency: $(this.defaults.currency),
$langMobile: $(this.defaults.langMobile),
$currencyMobile: $(this.defaults.currencyMobile),
$search: $(this.defaults.search),
$searchOpenMobile: $(this.defaults.searchOpenMobile)
};
$.extend(this.defaults, obj);
if (this.defaults.$mobilemenu.length) {
this._handlers(this);
}
},
_handlers: function _handlers() {
var _ = this.defaults,
$scroll = $(_.$mobilemenu);
$(_.mobileMenuScroll).perfectScrollbar();
_.$toggleMenu.on('click.mobileMenu', function () {
_.$mobilemenu.toggleClass('active');
_.$toggleMenu.toggleClass('active');
$body.toggleClass('slidemenu-open');
if (isMobile) {
if ($body.hasClass('slidemenu-open')) {
bodyScrollLock.disableBodyScroll($scroll);
} else {
bodyScrollLock.clearAllBodyScrollLocks();
}
}
return false;
});
_.$mobilemenu.on('click.mobileMenu', function (e) {
if ($(e.target).is(_.$mobilemenu)) {
_.$mobilemenu.toggleClass('active');
_.$toggleMenu.toggleClass('active');
$body.toggleClass('slidemenu-open');
if (isMobile) bodyScrollLock.clearAllBodyScrollLocks();
e.preventDefault();
}
});
}
};
THEME.mobilemenu.init();
},
mmobilePush: function mmobilePush() {
THEME.mobilemenupush = {
defaults: {
initElem: ".mobilemenu",
menuTitle: "Menu",
curItem: 0,
curLevel: 0
},
init: function init(options) {
$.extend(this.defaults, options);
var that = this,
$mmenu = $(that.defaults.initElem);
if ($mmenu.length && isMobile) {
$mmenu.data('init', true);
that._clickHandlers();
that._updateMenuTitle();
$('.nav-wrapper').css({
"height": $('.nav-wrapper ul.nav').outerHeight()
});
}
},
reinit: function reinit() {
if (!$(this.defaults.initElem).data('init') == true) {
this.init();
} else {
this._setHeigth();
}
},
_setHeigth: function _setHeigth() {
$('.nav-wrapper').css({
"height": $('mmenu-submenu-active .nav-level-' + (this.defaults.curLevel + 1)).outerHeight()
});
},
_clickHandlers: function _clickHandlers() {
var that = this,
$mmenu = $(that.defaults.initElem);
$mmenu.on('click', 'a', function (e) {
if ($(e.target).parent('li').find('ul').length) {
e.preventDefault();
that.defaults.curItem = $(this).parent();
that._updateActiveMenu();
}
});
$mmenu.on('click', '.nav-toggle', function () {
that._updateActiveMenu('back');
});
$mmenu.on('click', '.nav-viewall', function (e) {
e.stopPropagation();
location.href = $(this).attr('href');
});
},
_updateActiveMenu: function _updateActiveMenu(direction) {
var that = this;
that._slideMenu(direction);
if (direction === 'back') {
var curItem = that.defaults.curItem;
setTimeout(function () {
curItem.removeClass('mmenu-submenu-open mmenu-submenu-active');
}, 300);
that.defaults.curItem = that.defaults.curItem.parent().closest('li');
curItem.addClass('mmenu-submenu-open mmenu-submenu-active');
that._updateMenuTitle();
} else {
that.defaults.curItem.addClass('mmenu-submenu-open mmenu-submenu-active');
that._updateMenuTitle();
}
},
_updateMenuTitle: function _updateMenuTitle() {
var that = this,
title = that.defaults.menuTitle,
$mmenu = $(that.defaults.initElem),
link = '';
if (that.defaults.curLevel > 0) {
title = that.defaults.curItem.children('a').html();
link = that.defaults.curItem.children('a').attr('href') ? that.defaults.curItem.children('a').attr('href') : '';
$mmenu.find('.nav-toggle').addClass('back-visible');
} else {
$mmenu.find('.nav-toggle').removeClass('back-visible');
}
$('.nav-title').html(title);
$('.nav-viewall').attr('href', link);
},
_updateHeight: function _updateHeight() {
var that = this,
$mmenu = $(that.defaults.initElem);
if (that.defaults.curLevel > 0) {
that.defaults.curItem.children('ul').css({
"padding-top": $mmenu.find('.nav-toggle').outerHeight()
});
$('.nav-wrapper').css({
"height": that.defaults.curItem.children('ul').outerHeight()
});
} else {
$('.nav-wrapper').css({
"height": $('.nav-wrapper .nav-level-1').outerHeight()
});
}
},
_slideMenu: function _slideMenu(direction) {
var that = this,
$mmenu = $(that.defaults.initElem);
if (direction === 'back') {
that.defaults.curLevel = that.defaults.curLevel > 0 ? that.defaults.curLevel - 1 : 0;
setTimeout(function () {
that._updateHeight();
}, 300);
} else {
that.defaults.curLevel += 1;
setTimeout(function () {
that._updateHeight();
}, 100);
}
if (!$('body').hasClass('rtl')) {
$mmenu.children('ul').css({
"transform": "translateX(-" + that.defaults.curLevel * 100 + "%)"
});
} else {
$mmenu.children('ul').css({
"transform": "translateX(" + that.defaults.curLevel * 100 + "%)"
});
}
}
};
THEME.mobilemenupush.init({
initElem: ".js-push-mbmenu .nav-wrapper"
});
},
headerDrop: function headerDrop() {
THEME.headerdrop = {
defaults: {
header: '.hdr',
dropLink: '.js-dropdn-link, .js-open-drop',
dropLinkParent: '.dropdn',
dropClose: '.js-dropdn-close',
dropContent: '.dropdn-content',
dropContentScroll: '.js-dropdn-content-scroll',
overlay: '.drop-overlay',
popupCheckCart: '.popup-addedtocart_actions',
stickyOffset: 10
},
init: function init(options) {
$.extend(this.defaults, options);
this.reinitHeight();
this._handlers();
},
reinit: function reinit() {
this.reinitHeight();
this._handlers();
return this;
},
_handlers: function _handlers() {
var that = this,
$dropLink = $(that.defaults.dropLink),
$dropLinkParent = $dropLink.closest(that.defaults.dropLinkParent),
$dropClose = $(that.defaults.dropClose),
$scroll = $(that.defaults.dropContentScroll),
$popupCheckCart = $(that.defaults.popupCheckCart);
$(that.defaults.dropContentScroll).perfectScrollbar();
if (isMobile) {
if (!$dropLink.data('mclick')) {
$dropClose.off('.dropdn');
$dropLink.off('.dropdn');
$dropLinkParent.off('.dropdn');
$document.off('.dropdn');
$window.off('.dropdn');
$dropLink.on('click.dropdn', function (e) {
bodyScrollLock.disableBodyScroll($scroll);
var $this = $(this),
$panel = $($this.data('panel')).length ? $($this.data('panel')) : $this.next();
if ($this.closest('.js-popupAddToCart').length) {
THEME.selectModal && THEME.selectModal.ifOpened() && THEME.selectModal.close();
THEME.checkOutModal && THEME.checkOutModal.ifOpened() && THEME.checkOutModal.close();
THEME.selectSticky && THEME.selectSticky.hide();
$.fancybox.close();
}
if ($this.closest('.mobilemenu').length) {
$this.parent().toggleClass('is-hovered');
} else if ($panel.length) {
if ($this.parent().hasClass('is-hovered')) {
$this.parent().removeClass('is-hovered');
$panel.removeClass('is-opened');
$body.removeClass('blockSticky');
} else {
$dropLink.parent().removeClass('is-hovered');
$this.parent().addClass('is-hovered');
$panel.addClass('is-opened');
$body.addClass('blockSticky');
}
if ($this.parent().hasClass('dropdn_search')) {
setTimeout(function () {
$this.next().find('.search-input').focus();
}, 100);
}
}
e.preventDefault();
e.stopPropagation();
});
$dropLinkParent.on('click.dropdn', function (e) {
var $this = $(e.target);
if (!$this.closest('.dropdn-content').length && $('.header-side-panel').find('.is-opened').length && !$this.closest('.mobilemenu').length) {
$dropLinkParent.removeClass('is-hovered');
$('.header-side-panel').find('.is-opened').removeClass('is-opened');
$body.removeClass('blockSticky');
e.preventDefault();
}
});
$dropClose.on('click.dropdn', function (e) {
if (!$(this).closest('.mobilemenu').length) {
$dropLink.parent().removeClass('is-hovered');
$('.header-side-panel').find('.is-opened').removeClass('is-opened');
$body.removeClass('blockSticky');
bodyScrollLock.clearAllBodyScrollLocks();
}
e.preventDefault();
});
$dropLink.data('mclick', true);
$dropLink.removeData('click');
}
} else {
if ($dropLinkParent.closest('.dropdn_fullheight')) {
$dropLinkParent.find('.dropdn-content-block').perfectScrollbar();
}
if (!$dropLink.data('click')) {
$dropClose.off('.dropdn');
$dropLink.off('.dropdn');
$dropLinkParent.on('.dropdn');
$dropLinkParent.off('.dropdn');
$dropLink.on('click.dropdn', function (e) {
var $this = $(this),
$panel = $($this.data('panel')).length ? $($this.data('panel')) : $this.next();
if ($this.closest('.js-popupAddToCart').length) {
THEME.selectModal && THEME.selectModal.ifOpened() && THEME.selectModal.close();
THEME.checkOutModal && THEME.checkOutModal.ifOpened() && THEME.checkOutModal.close();
THEME.selectSticky && THEME.selectSticky.hide();
$.fancybox.close();
}
if ($panel.length) {
if ($('.header-side-panel').find('.is-opened').length) {
$('.header-side-panel').find('.is-opened').removeClass('is-opened');
}
if ($this.parent().hasClass('is-hovered')) {
$this.parent().removeClass('is-hovered');
$panel.removeClass('is-opened');
setTimeout(function () {
$this.next().find('.search-input').focus().val('');
}, 500);
} else {
$dropLink.parent().removeClass('is-hovered');
$this.parent().addClass('is-hovered');
$panel.addClass('is-opened');
$this.next().css({
'max-height': that._getDropHeight($this) + 'px',
'top': that._getDropPos($this) + 'px'
});
if ($this.closest('.dropdn_fullheight').length) {
$this.next().css({
'height': that._getDropHeight($this) + 'px'
});
}
$this.next().find('.search-input').focus();
}
e.preventDefault();
e.stopPropagation();
}
});
$document.on('click.dropdn', function (e) {
var $this = $(e.target);
if (!$this.closest('.dropdn-content').length) {
if ($popupCheckCart.hasClass('is-hovered')) $popupCheckCart.removeClass('is-hovered');
if ($('.header-side-panel').find('.is-opened').length) {
$dropLinkParent.removeClass('is-hovered');
$('.header-side-panel').find('.is-opened').removeClass('is-opened');
} else if ($dropLinkParent.hasClass('is-hovered')) {
$dropLinkParent.removeClass('is-hovered');
$dropLink.next().css({
'height': '',
'max-height': ''
});
setTimeout(function () {
if ($this.next().find('.search-input').length) {
$this.next().find('.search-input').val('');
}
}, 500);
}
}
});
$dropClose.on('click.dropdn', function (e) {
var $this = $(e.target);
$dropLink.parent().removeClass('is-hovered');
$('.header-side-panel').find('.is-opened').removeClass('is-opened');
if ($popupCheckCart.hasClass('is-hovered')) $popupCheckCart.removeClass('is-hovered');
$dropLink.next().css({
'height': '',
'max-height': ''
});
setTimeout(function () {
$this.next().find('.search-input').val('');
}, 500);
THEME.selectSticky && THEME.selectSticky.show();
e.preventDefault();
});
$dropLink.data('click', true);
$dropLink.removeData('mclick');
}
}
},
_getDropHeight: function _getDropHeight(dropdn) {
var dropH = void 0,
yPos = void 0,
$parent = dropdn.closest('.container');
if ($parent.length && dropdn.closest('.dropdn_fullheight,.dropdn_fullwidth').length) {
if (!$('.hdr-content-sticky').length) {
yPos = $parent.outerHeight() + $parent.offset().top - $window.scrollTop();
if (yPos < 0) {
yPos = 0;
}
} else {
yPos = 0;
}
}
dropH = h - yPos;
return dropH;
},
_getDropPos: function _getDropPos(dropdn) {
var that = this,
$header = $(that.defaults.header),
$parent = dropdn.closest('.container'),
yPos = void 0;
if ($parent.length) {
if (dropdn.closest('.dropdn_fullheight').length) {
yPos = 0;
} else if (dropdn.closest('.dropdn_fullwidth').length) {
if (dropdn.closest('.hdr-content-sticky').length) {
yPos = $('.hdr-content-sticky').outerHeight();
} else if (dropdn.closest('.hdr-navline').length) {
yPos = $parent.outerHeight() + $parent.offset().top;
} else if ($header.hasClass('hdr-style4') || $header.hasClass('hdr-style7')) {
yPos = $parent.outerHeight() + $('.hdr-navline').outerHeight();
} else yPos = $parent.outerHeight();
}
}
return yPos;
},
reinitHeight: function reinitHeight() {
var that = this,
$this = $(that.defaults.dropLinkParent);
$this.each(function () {
var _ = $(this).find(that.defaults.dropContent);
if (!isMobile) {
if (!$('.hdr-content-sticky').length) {
_.css({
'max-height': that._getDropHeight(_.prev()) + 'px',
'top': that._getDropPos(_.prev()) + 'px'
});
if (_.closest('.dropdn_fullheight').length) {
_.css({
'height': that._getDropHeight(_.prev()) + 'px'
});
}
} else {
_.css({
'max-height': that._getDropHeight(_.prev()) + 'px',
'top': that._getDropPos(_.prev()) + 'px'
});
if (_.closest('.dropdn_fullheight').length) {
_.css({
'height': that._getDropHeight(_.prev()) + 'px'
});
}
}
}
});
}
};
THEME.headerdrop.init();
},
stickyHeaderInit: function stickyHeaderInit(el) {
if ($(el).length) {
THEME.stickyheader = {
defaults: {
header: '.hdr',
headerSticky: '.hdr-content-sticky',
headerM: '.hdr-mobile',
headerD: '.hdr-desktop',
hdrNav: '.nav-holder',
stickyNav: '.nav-holder-s',
mobileMenu: '.mmenu',
promoTopline: '.promo-topline',
drops: '.hdr-content-sticky .dropdn-content',
stickyCollision: '.js-sticky-collision',
offset: 500
},
init: function init(options) {
$.extend(this.defaults, options);
if ($(this.defaults.headerSticky).length) {
$body.addClass('has-hdr_sticky');
}
if (!isMobile && !$body.hasClass('has-sticky')) {
this._setHeigth();
}
this._setScroll();
if ($(this.defaults.stickyNav).length) {
$(this.defaults.hdrNav).children().clone(true).appendTo(this.defaults.stickyNav);
}
if (!isMobile) {
this._multirow();
this._multirowS();
}
return this;
},
reinit: function reinit() {
if (!$(this.defaults.header).length) return false;
$window.off('scroll.stickyHeader');
if (!isMobile && !$body.hasClass('has-sticky')) {
this._setHeigth();
}
if (!isMobile) {
this._multirow();
this._multirowS();
}
this._setScroll();
return this;
},
_multirow: function _multirow() {
if ($(this.defaults.hdrNav).height() > 60) {
$(this.defaults.header).addClass('mmenu-multirow');
} else $(this.defaults.header).removeClass('mmenu-multirow');
},
_multirowS: function _multirowS() {
if ($body.hasClass('has-hdr_sticky')) {
if ($(this.defaults.stickyNav).height() > 60) {
$(this.defaults.headerSticky).addClass('mmenu-multirow-s');
} else $(this.defaults.headerSticky).removeClass('mmenu-multirow-s');
}
},
destroySticky: function destroySticky() {
this._removeSticky();
},
_setScroll: function _setScroll() {
var that = this,
offset = that.defaults.offset + $(that.defaults.headerSticky).outerHeight(),
checkColission = !isMobile || $(that.defaults.stickyCollision).length ? true : false;
function isCollapsed(el1, el2) {
if (!$body.hasClass('has-sticky')) return false;
if (el1.offset().top < el2.offset().top + el2.height()) {
return true;
} else return false;
}
function scrollEvents() {
if ($body.hasClass('blockSticky')) return false;
var st = $window.scrollTop();
if (st > offset) {
if (!$body.hasClass('has-sticky')) {
that._setSticky();
}
} else {
if ($body.hasClass('has-sticky')) {
that._removeSticky();
}
}
}
$window.on('scroll.stickyHeader', function () {
if ($body.hasClass('blockSticky')) return false;
scrollEvents();
if (isMobile) return false;
if (checkColission) {
$(that.defaults.stickyCollision).each(function () {
var $this = $(this),
h = parseInt($(that.defaults.headerSticky).outerHeight(), 10);
if (isCollapsed($this, $(that.defaults.headerSticky))) {
$this.addClass('is-collision');
if ($this.hasClass('js-filter-col')) {
h = h + 40;
$this.css({
"-webkit-transform": "translate3d(0," + h + "px,0)",
"-ms-transform": "translate3d(0," + h + "px,0)",
"transform": "translate3d(0," + h + "px,0)",
"padding-bottom": h + "px"
});
} else {
$this.children().css({
"-webkit-transform": "translate3d(0," + h + "px,0)",
"-ms-transform": "translate3d(0," + h + "px,0)",
"transform": "translate3d(0," + h + "px,0)",
"padding-bottom": h + "px"
});
}
} else {
$this.removeClass('is-collision');
if ($this.hasClass('js-filter-col')) {
$this.css({
"-webkit-transform": "translate3d(0,0,0)",
"-ms-transform": "translate3d(0,0,0)",
"transform": "translate3d(0,0,0)",
"padding-bottom": ""
});
} else {
$this.children().css({
"-webkit-transform": "translate3d(0,0,0)",
"-ms-transform": "translate3d(0,0,0)",
"transform": "translate3d(0,0,0)",
"padding-bottom": ""
});
}
}
});
}
});
scrollEvents();
return this;
},
_setTop: function _setTop() {
var that = this,
top = $('.js-hdr-top:visible').outerHeight();
$(that.defaults.header).css({
'top': 0 - top
});
$(that.defaults.drops).css({
'top': top
});
},
_setSticky: function _setSticky() {
var that = this;
$body.addClass('has-sticky');
$(that.defaults.header).find('.is-hovered .dropdn-link').each(function () {
if (!$(this).closest('.dropdn_fullheight').length) {
$(this).trigger('click');
}
});
},
_removeSticky: function _removeSticky() {
$body.removeClass('has-sticky');
},
_setHeigth: function _setHeigth() {
var $header = $(this.defaults.header),
$hdrNav = $(this.defaults.hdrNav);
$hdrNav.css({
'height': ''
});
$header.css({
'height': ''
});
if (!$body.hasClass('has-sticky')) {
$hdrNav.css({
'height': $hdrNav.outerHeight()
});
} else {
$body.removeClass('has-sticky');
}
return this;
}
};
THEME.stickyheader.init();
} else {
THEME.stickyheader = {
defaults: {
header: '.hdr',
hdrNav: '.hdr-nav'
},
init: function init(options) {
$.extend(this.defaults, options);
this._multirow();
return this;
},
reinit: function reinit() {
this._multirow();
return this;
},
_multirow: function _multirow() {
if (isMobile) return false;
if ($(this.defaults.hdrNav).outerHeight() > 60) {
$(this.defaults.header).addClass('mmenu-multirow');
} else $(this.defaults.header).removeClass('mmenu-multirow');
}
};
THEME.stickyheader.init();
}
}
};
THEME.modals = {
init: function init() {
this.quickView();
this.checkOut();
this.addToWishlist('.js-label-wishlist');
this.selectModal();
this.formNotifications();
this.infoModals();
this.loaderHorizontal();
this.loaderHorizontalSm();
this.loaderCategory();
this.loaderTab();
},
infoModals: function infoModals() {
$('.modal-info-link').fancybox({
type: 'inline',
buttons: ['close'],
touch: false,
backFocus: false,
btnTpl: {
smallBtn: '
'
}
});
},
formNotifications: function formNotifications() {
setTimeout(function () {
if ($('.js-form-notification').length) {
$.fancybox.open([{
src: '.js-form-notification',
type: 'inline',
btnTpl: {
smallBtn: '
'
}
}], {
buttons: ['close'],
touch: false,
afterClose: function afterClose() {
var uri = window.location.toString();
if (uri.indexOf("?") > 0) {
var clean_uri = uri.substring(0, uri.indexOf("?"));
window.history.replaceState({}, document.title, clean_uri);
}
if ($('.js-form-notification .js-scroll-to').length) {
THEME.initialization.scrollToTarget('.js-scroll-to');
$('.js-form-notification .js-scroll-to').trigger('click');
}
}
});
}
if ($('.js-form-contact-notification').length) {
$.fancybox.open([{
src: '.js-form-contact-notification',
type: 'inline',
btnTpl: {
smallBtn: '
'
}
}], {
buttons: ['close'],
touch: false,
afterClose: function afterClose() {
var uri = window.location.toString();
if (uri.indexOf("?") > 0) {
var clean_uri = uri.substring(0, uri.indexOf("?"));
window.history.replaceState({}, document.title, clean_uri);
}
}
});
}
}, 1000);
},
quickView: function quickView() {
THEME.quickView = {
init: function init(options) {
var that = this,
$modalQuickView = $('#modalQuickView');
var $mainCarousel = $('.js-product-main-carousel-qw'),
$prwCarousel = $('.js-product-previews-carousel-qw');
$document.on('click', '.js-prd-quickview', function (e) {
var src = $(this).data('src');
$.fancybox.open({
src: src,
backFocus: false,
type: 'ajax',
image: {
preload: true
},
afterShow: function afterShow() {
THEME.product.productPageGallery(true);
THEME.product.swatchToggle('#modalQuickView .prd-color.swatches');
setTimeout(function () {
$('.quickview-gallery').css({ 'opacity': '1' });
}, 500);
if ($('.js-product-previews-carousel-qw').length) {
$('.js-product-previews-carousel-qw').slick('setPosition');
}
THEME.initialization.countdown('#modalQuickView .js-countdown');
THEME.productPage.visitorsNow();
THEME.initialization.tooltipIni($('#modalQuickView [data-toggle="tooltip"]'));
that._setScroll();
if (isMobile) bodyScrollLock.disableBodyScroll($modalQuickView);
},
beforeShow: function beforeShow() {
THEME.selectModal && THEME.selectModal.ifOpened() && THEME.selectModal.close();
THEME.checkOutModal && THEME.checkOutModal.ifOpened() && THEME.checkOutModal.close();
THEME.selectSticky && THEME.selectSticky.hide();
$body.addClass('fancybox--under-modals');
},
beforeClose: function beforeClose() {
$('.zoom-container').remove();
THEME.productpagegallery_qw.destroy();
delete THEME.productpagegallery_qw;
},
afterClose: function afterClose() {
THEME.selectSticky ? THEME.selectSticky.show() : false;
THEME.productpagegallery ? THEME.productpagegallery.reinitZoom() : false;
$body.removeClass('fancybox--under-modals');
if (isMobile) bodyScrollLock.enableBodyScroll($modalQuickView);
},
touch: false,
btnTpl: {
smallBtn: '
'
},
baseTpl: '"
});
e.preventDefault();
});
},
reinit: function reinit() {
if (this.ifOpened()) {
$('#modalQuickView .quickview-info').perfectScrollbar('destroy');
$('#modalQuickView .prd-block').perfectScrollbar('destroy');
$('#modalQuickView .quickview-info').css({ 'height': '' });
$('#modalQuickView .prd-block').css({ 'height': '' });
this._setScroll();
}
},
ifOpened: function ifOpened() {
if ($('#modalQuickView').length && $('#modalQuickView').closest('.fancybox-is-open').length) {
return true;
} else {
return false;
}
},
_setScroll: function _setScroll() {
if (w > maxMD) {
if ($('.modal-quickview--classic').length) {
var h = $('#modalQuickView .quickview-info')[0].scrollHeight;
$('#modalQuickView .quickview-info').css({ 'min-height': h, 'height': h });
} else {
$('#modalQuickView .quickview-info').css({ 'height': $('.modal--quickview').height() });
}
$('#modalQuickView .quickview-info').perfectScrollbar();
} else {
$('#modalQuickView .prd-block').css({ 'height': $('.modal--quickview').height() });
$('#modalQuickView .prd-block').perfectScrollbar();
}
$('.js-product-previews-carousel-qw').slick('setPosition');
}
};
THEME.quickView.init();
},
checkOut: function checkOut() {
THEME.checkOutModal = {
defaults: {
popup: '.js-popupAddToCart',
popupAlt: ['.js-stickyAddToCart', '.js-popupSelectOptions'],
button: '.js-prd-addtocart',
closePopup: '.js-popupAddToCart-close',
title: '.popup-addedtocart_title',
imageWrap: '.popup-addedtocart_image',
image: '.popup-addedtocart_image > img, .popup-addedtocart_image > span > img',
error: '.popup-addedtocart_error_message'
},
init: function init(options) {
$.extend(this.defaults, options);
var that = this,
$popup = $(that.defaults.popup);
if ($popup.length) {
that._handlers();
}
},
reinit: function reinit() {
if (!$(this.defaults.popup).hasClass('closed')) {
this._setHeigth();
}
},
setData: function setData(data) {
var that = this,
$popup = $(this.defaults.popup);
$popup.removeClass('has-error');
$(this.defaults.title, $popup).empty().html('' + data.name + '');
$(this.defaults.title, $popup).attr('href', data.url);
$(this.defaults.imageWrap, $popup).attr('href', data.url);
$(this.defaults.image, $popup).fadeTo(0, 0).attr('src', '');
if (data.path) {
if (data.path.indexOf('no-image') == -1) {
$(this.defaults.image, $popup).attr('src', data.path);
} else {
$(this.defaults.image, $popup).attr('src', data.main_image);
}
}
if (data.aspect_ratio > 0) {
$(this.defaults.imageWrap, $popup).find('.image-container').css({
'padding-bottom': 1 / data.aspect_ratio * 100 + "%"
});
}
$(this.defaults.imageWrap, $popup).imagesLoaded(function () {
anime({
targets: that.defaults.image,
opacity: 1,
duration: 1000
});
});
$(this.defaults.image, $popup).parent().attr('href', data.url);
$(this.defaults.error, $popup).empty().html(data.error_message);
if (!$popup.hasClass('closed')) {
this.open();
}
},
setError: function setError(error) {
var $popup = $(this.defaults.popup);
$popup.addClass('has-error');
$(this.defaults.error, $popup).empty().html(error);
if (!$popup.hasClass('closed')) {
this.open();
}
},
ifOpened: function ifOpened() {
return $(this.defaults.popup).hasClass('closed') ? false : true;
},
_correctHeight: function _correctHeight() {
var that = this,
h = $(that.defaults.popup).find('.container').outerHeight();
anime({
targets: that.defaults.popup,
height: {
value: h + 'px'
},
duration: 100,
easing: 'linear'
});
},
_setHeigth: function _setHeigth() {
var $popup = $(this.defaults.popup),
popupAlt = this.defaults.popupAlt,
h = $popup.find('.container').outerHeight();
for (var i = 0; i < popupAlt.length; ++i) {
if (!$(popupAlt[i]).hasClass('closed') && $(popupAlt[i]).length) {
h += $(popupAlt[i]).find('.container').outerHeight();
}
}
$popup.removeClass('closed');
$('.js-pn').css({
'margin-bottom': h + 20 + 'px'
});
},
_handlers: function _handlers() {
var that = this,
$popup = $(that.defaults.popup);
$(document).on('click', that.defaults.button, function (e) {
var product_data = $(this).data('product');
if (!$popup.hasClass('closed')) {
that.close();
setTimeout(function () {
that.setData(product_data);
that.open();
}, 500);
} else {
that.setData(product_data);
that.open();
}
e.preventDefault();
});
$(document).on('click', that.defaults.closePopup, function (e) {
that.close();
e.preventDefault();
});
},
open: function open() {
var that = this,
$popup = $(that.defaults.popup),
$qty = $popup.find('.qty-input'),
h = $popup.find('.container').outerHeight(),
duration = 300;
$popup.removeClass('closed');
$qty.val($qty.data('min'));
that._setHeigth();
anime({
targets: that.defaults.popup,
easing: 'linear',
duration: duration,
delay: 500,
height: {
value: h + 'px'
}
});
if ($popup.attr('data-close')) {
that.timer = setTimeout(function () {
that.close();
}, $popup.attr('data-close'));
}
},
close: function close() {
var that = this,
$popup = $(that.defaults.popup),
popupAlt = $(that.defaults.popupAlt),
duration = 300,
h = 0;
for (var i = 0; i < popupAlt.length; ++i) {
if (!$(popupAlt[i]).hasClass('closed') && $(popupAlt[i]).length) {
h += $(popupAlt[i]).find('.container').outerHeight();
}
}
$popup.addClass('closed');
$popup.data('variant-id', '');
$('.js-pn').css({
'margin-bottom': h + 20 + 'px'
});
clearTimeout(that.timer);
anime({
targets: that.defaults.popup,
easing: 'linear',
duration: duration,
height: {
value: '0px'
},
complete: function complete() {
$(that.defaults.imageWrap, $popup).find('.image-container').css({
'padding-bottom': ''
});
}
});
}
};
THEME.checkOutModal.init();
},
selectModal: function selectModal() {
function createSelect(el) {
var SelectModal = {
defaults: {
popup: '.js-popupSelectOptions',
popupAlt: ['.js-stickyAddToCart', '.js-popupAddToCart'],
button: '.js-select-add-to-cart',
closePopup: '.js-popupSelectOptions-close',
title: '.sticky-addcart_title',
imageWrap: '.sticky-addcart_image',
image: '.sticky-addcart_image img',
imageLink: '.sticky-addcart_image a',
imageZoom: '.js-popupSelectOptions-zoom a',
error: '.sticky-addcart_error_message',
options: '.sticky-addcart_options_select',
priceActual: '.sticky-addcart_price--actual',
priceOld: '.sticky-addcart_price--old',
sticky: false
},
init: function init(options) {
$.extend(this.defaults, options);
var that = this,
$popup = $(that.defaults.popup);
if ($popup.length) {
that._handlers();
}
},
reinit: function reinit() {
if (!$(this.defaults.popup).hasClass('closed')) {
this._setHeigth();
}
},
_setProduct: function _setProduct(data) {
var that = this,
$popup = $(this.defaults.popup);
$popup.removeClass('has-error');
if (data) {
$(that.defaults.title, $popup).find('a').empty().html('' + data.name + '');
$(that.defaults.title, $popup).find('a').attr('href', data.url);
if (data.path.indexOf('no-image') == -1) {
$(that.defaults.image, $popup).attr('src', data.path);
} else {
$(that.defaults.image, $popup).attr('src', data.main_image);
}
if ($(that.defaults.imageZoom).length) {
if (data.path_image_big.indexOf('no-image') == -1) {
$(that.defaults.imageZoom, $popup).attr('href', data.path_image_big);
} else {
$(that.defaults.imageZoom, $popup).attr('href', data.main_image_big);
}
$(that.defaults.imageZoom, $popup).data('caption', data.name);
} else $(that.defaults.imageLink, $popup).attr('href', data.url);
$(that.defaults.error, $popup).empty().html(data.error_message);
$(that.defaults.priceActual, $popup).empty().html(data.price_actual);
if (data.price_old && parseInt(data.price_old.replace(/[^0-9]/g, '')) > parseInt(data.price_actual.replace(/[^0-9]/g, ''))) {
$(that.defaults.priceOld, $popup).empty().html(data.price_old);
} else $(that.defaults.priceOld, $popup).empty();
}
},
_setFormData: function _setFormData(data) {
var that = this,
$popup = $(this.defaults.popup);
if (data) {
var $btn = $('.btn', $popup);
$btn.data('variant-id', data.id);
$btn.data('product', data);
if (that.defaults.sticky) {
$btn.html(js_helper.strings.addToCart);
$btn.attr('aria-disabled', false);
}
}
},
setData: function setData(data) {
var that = this,
$popup = $(this.defaults.popup);
that._setProduct(data);
$(that.defaults.options, $popup).find('option').remove();
$.each(data.variants, function (key, value) {
var option_status = '';
if (!value.disabled) option_status = 'disabled';
$(that.defaults.options, $popup).append($('