31 lines
928 B
JavaScript
31 lines
928 B
JavaScript
export function cartboxSidebar() {
|
|
$('header')
|
|
.on('click', '[data-header-cart-link]', function() {
|
|
if ($(window).width() > 767 && $(window).height() > 520 && $(this).attr('href')) {
|
|
$('[data-cartbox]').addClass('active');
|
|
$('body').trigger('cartboxOpened');
|
|
return false;
|
|
}
|
|
})
|
|
.on('click', '[data-cartbox-hide]', function() {
|
|
$('[data-cartbox]').removeClass('active');
|
|
|
|
return false;
|
|
});
|
|
}
|
|
|
|
export function cartboxHover() {
|
|
$('header')
|
|
.on('mouseenter', '[data-cartbox-enable]', function() {
|
|
$(this).addClass('opened');
|
|
})
|
|
.on('mouseleave', '[data-cartbox-enable]', function(e) {
|
|
var $self = $(this);
|
|
setTimeout(function() {
|
|
if (!$self.is(':hover') && !$(e.target).is('input')) {
|
|
$self.removeClass('opened');
|
|
}
|
|
}, 200);
|
|
});
|
|
}
|