140 lines
3.4 KiB
JavaScript
140 lines
3.4 KiB
JavaScript
require('@assets/js/owl.carousel.js');
|
|
require('@static/jquery/jquery.tooltip.js');
|
|
|
|
import { cartboxSidebar } from '@assets[shared]/js/wpj.cartbox.js';
|
|
cartboxSidebar();
|
|
|
|
const $body = $('body');
|
|
|
|
// vypnout jQuery animace pro mobily
|
|
if ($(window).width() < 992) {
|
|
$.fx.off = true;
|
|
}
|
|
|
|
/*$.wpjImage('a[data-rel=gallery], [data-gallery]', {
|
|
zoom: {
|
|
enabled: false
|
|
}
|
|
});*/
|
|
|
|
/*$.wpjImage('a[data-image=360]', {
|
|
type: 'iframe',
|
|
mainClass: 'mfp-360'
|
|
});*/
|
|
|
|
// JS detection
|
|
$('html').removeClass('no-js');
|
|
|
|
// Touch detection
|
|
$body.on('touchstart', function() {
|
|
$('html').addClass('touch');
|
|
$('[data-responsive-switch]').removeClass('hidden-sm-up');
|
|
});
|
|
|
|
|
|
// Delegate .transition() calls to .animate()
|
|
// if the browser can't do CSS transitions.
|
|
if (!$.support.transition) {
|
|
$.fn.transition = $.fn.animate;
|
|
}
|
|
|
|
// Zobraz login
|
|
$('#login').login({
|
|
$link: '[data-login-link]'
|
|
});
|
|
|
|
$('[data-scrollto]').on('click', function(e) {
|
|
e.preventDefault();
|
|
const $target = $($(this).attr('href'));
|
|
wpj.domUtils.scrollTo($target);
|
|
return false;
|
|
});
|
|
|
|
/**
|
|
* Header submenu hover
|
|
*/
|
|
$("[data-nav='top'] .has-submenu").on({
|
|
mouseenter: function() {
|
|
var self = this;
|
|
setTimeout(function() {
|
|
if ($(self).is(':hover')) {
|
|
$(self).addClass('hover');
|
|
}
|
|
}, 200);
|
|
$(this)
|
|
.find('[data-src]')
|
|
.each(function() {
|
|
$(this).attr('src', $(this).attr('data-src'));
|
|
});
|
|
},
|
|
mouseleave: function() {
|
|
var self = this;
|
|
setTimeout(function() {
|
|
if (!$(self).is(':hover')) {
|
|
$(self).removeClass('hover');
|
|
}
|
|
}, 200);
|
|
}
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
* Footer menu toggle
|
|
*/
|
|
|
|
$('.footer').on('click', '[data-footer-opener]', function() {
|
|
$(this).toggleClass('active');
|
|
})
|
|
|
|
|
|
/**
|
|
* toggle vyhledavaciho pole v hlavicce
|
|
*/
|
|
|
|
$body.on('click', '[data-toggle="search"]', function() {
|
|
let $wrapper = $('[data-search-form]');
|
|
|
|
if ($wrapper.hasClass('active')) {
|
|
$('[data-toggle="search"]').removeClass('active');
|
|
$wrapper.removeClass('active');
|
|
} else {
|
|
$('[data-toggle="search"]').addClass('active');
|
|
$wrapper.addClass('active');
|
|
$wrapper
|
|
.find('.autocomplete-control')
|
|
.get(0)
|
|
.focus();
|
|
}
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', '[data-favorites-add]', function(e) {
|
|
e.preventDefault();
|
|
const $link = $(this);
|
|
const link_href = $link.attr('href');
|
|
const diff = parseInt($link.attr('data-favorites-add'));
|
|
const $count_el = $('.header-favorite .count');
|
|
let count = parseInt($count_el.get(0).textContent);
|
|
|
|
wpj.domUtils.reloadPartsFromUrl(link_href, $('[data-reload="favorite"]'), undefined, function(data) {
|
|
if ($(data[0]).find('[data-fav-success]').length) {
|
|
if (diff === 1) {
|
|
count = count + 1;
|
|
$link.addClass('active').attr('href', link_href + '&acn=delete').attr('data-favorites-add', -1);
|
|
} else {
|
|
count = count - 1;
|
|
$link.removeClass('active').attr('href', link_href.replace('&acn=delete','')).attr('data-favorites-add', 1);
|
|
}
|
|
|
|
$count_el.text(count);
|
|
} else {
|
|
// Log in, add product to favorites, then redirect back using next parameter
|
|
const url = $link.attr('href');
|
|
const next = window.location;
|
|
$('#login').login('setNextUrl', url ? url + '&next=' + encodeURIComponent(next) : next);
|
|
$('#login').login('show');
|
|
}
|
|
});
|
|
});
|