93 lines
3.5 KiB
JavaScript
Executable File
93 lines
3.5 KiB
JavaScript
Executable File
(function () { // popup basket context
|
|
$(function(){
|
|
BX.ready(function(){
|
|
if ($('.viasite-popup.basket').length > 0) return;
|
|
$('<div class="viasite-popup basket"></div>').appendTo('body');
|
|
$('<div class="popup-content-cell"></div>').appendTo('.viasite-popup');
|
|
$('<div class="popup-content"></div>').appendTo('.popup-content-cell');
|
|
$('<div class="lazy"></div>').appendTo('.popup-content-cell');
|
|
$('<h2>Товар добавлен в корзину</h2>').appendTo('.popup-content');
|
|
$('<div class="popup-details"></div>').appendTo('.popup-content');
|
|
$('<a href="#towebsite" class="btn">Продолжить покупки</a><span> </span>').appendTo('.popup-content').on('click', function(){
|
|
$('.viasite-popup').removeClass('active');
|
|
$('.viasite-popup').removeClass('success');
|
|
$('.popup-details').html('');
|
|
return false;
|
|
});
|
|
$('<a href="#tobasket" class="btn">Оформить заказ</a>').appendTo('.popup-content').on('click', function(){
|
|
document.location.href = '/personal/cart/';
|
|
return false;
|
|
});
|
|
$('a[rel*=ADD2BASKET]').on('click.popup', function(){
|
|
var p = $(this).parents('.product-layout');
|
|
if(p.length == 0) {
|
|
p = $(this).parents('.owl-item');
|
|
}
|
|
var productName = $('.name a', p[0]).html();
|
|
var productPrice = $('.price-new', p[0]).html();
|
|
var productPicture = $('.img-responsive', p[0]).attr('src');
|
|
if(productPrice === undefined) productPrice = $('.price', p[0]).html();
|
|
$('.popup-details').html('');
|
|
if(productPicture !== undefined) $('<img src="'+productPicture+'" width="64" height="64">').appendTo('.popup-details');
|
|
$('<h3>'+productName+'</h3>').appendTo('.popup-details');
|
|
$('<p> Стоимость товара: <b>'+productPrice+'</b></p>').appendTo('.popup-details');
|
|
$('.viasite-popup.basket').addClass('active');
|
|
});
|
|
});
|
|
});
|
|
|
|
$(function(){
|
|
BX.ready(function(){
|
|
if($('.y_map').length > 0) $('body').addClass('contacts-page');
|
|
if($(window).width() > 580) return false;
|
|
var gallery = $('#productFullGallery')[0];
|
|
if(gallery) {
|
|
pTop = $('#productFullGallery').offset().top;
|
|
console.log(pTop);
|
|
$("html,body").animate({
|
|
scrollTop: pTop
|
|
}, 300);
|
|
}
|
|
});
|
|
});
|
|
|
|
// Цели метрики
|
|
var counter_code = "47475820";
|
|
$(function () {
|
|
var counter_attempts = 0;
|
|
var initCounter = setInterval(function () {
|
|
counter_attempts++;
|
|
if (window['yaCounter' + counter_code] !== undefined) {
|
|
phone_click();
|
|
add_to_cart_click();
|
|
clearInterval(initCounter);
|
|
}
|
|
if (counter_attempts > 24) {
|
|
clearInterval(initCounter);
|
|
console.warn('Счетчик не найден!');
|
|
}
|
|
}, 2500);
|
|
});
|
|
function phone_click() {
|
|
$('body').on('click', 'a[href^="tel:"]', function () {
|
|
var number = $(this).attr('href').replace('tel:', '');
|
|
window['yaCounter' + counter_code].reachGoal('phone_click', {});
|
|
});
|
|
}
|
|
function add_to_cart_click() {
|
|
$('a[rel*=ADD2BASKET]').on('click.popup', function(){
|
|
window['yaCounter' + counter_code].reachGoal('add_to_cart_click', {});
|
|
});
|
|
}
|
|
|
|
$(function() {
|
|
$('.burger').click(function(evt) {
|
|
evt.stopPropagation(); //stops the document click action
|
|
$('body').toggleClass('menu--open');
|
|
});
|
|
$(document).click(function() {
|
|
$('body').removeClass('menu--open'); //make all inactive
|
|
});
|
|
});
|
|
|
|
})(); |