You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
282 lines
9.5 KiB
282 lines
9.5 KiB
$(document).on('click', '.yamm .dropdown-menu', function (e) {
|
|
e.stopPropagation();
|
|
});
|
|
$(document).ready(function () {
|
|
$("#shop-categories").on('affix.bs.affix', function () {
|
|
$('.header-middle').css('margin-bottom', $("#shop-categories").css('height'));
|
|
});
|
|
$("#shop-categories").on('affix-top.bs.affix', function () {
|
|
$('.header-middle').css('margin-bottom', '0px');
|
|
});
|
|
|
|
function reset_page_and_go(url) {
|
|
window.location = $.param.querystring(window.location.href, 'page=1&' + url);
|
|
}
|
|
|
|
$('select[name=products-sort]').on('change', function () {
|
|
reset_page_and_go('sort=' + $(this).val());
|
|
});
|
|
$('select[name=show-count]').on('change', function () {
|
|
reset_page_and_go('paginate_by=' + $(this).val());
|
|
});
|
|
|
|
var category_sort = $.deparam.querystring().sort;
|
|
if (category_sort) {
|
|
$("select[name=products-sort] option[value=" + category_sort + "]").prop("selected", "selected");
|
|
}
|
|
var paginate_by = $.deparam.querystring().paginate_by;
|
|
if (paginate_by) {
|
|
$("select[name=show-count] option[value=" + paginate_by + "]").prop("selected", "selected");
|
|
}
|
|
$('.paginate a').on('click', function () {
|
|
window.location = $.param.querystring(window.location.href, $(this).attr('href').replace('?', ''));
|
|
return false;
|
|
});
|
|
|
|
$('.attr-filter').each(function () {
|
|
var check_block = $(this);
|
|
var checkboxes = [];
|
|
|
|
$(this).find('input:checkbox').each(function () {
|
|
var current_checkbox = $(this);
|
|
checkboxes.push(current_checkbox);
|
|
current_checkbox.change(function () {
|
|
var retstring = '';
|
|
$.each(checkboxes, function () {
|
|
if ($(this).prop('name') != current_checkbox.prop('name')) {
|
|
var checkval = 'false';
|
|
if ($(this).prop('checked')) {
|
|
checkval = $(this).val();
|
|
}
|
|
retstring += '&' + $(this).prop('name') + '=' + checkval;
|
|
}
|
|
});
|
|
|
|
var current_val = 'false';
|
|
|
|
if (current_checkbox.prop('checked')) {
|
|
current_val = current_checkbox.val()
|
|
}
|
|
retstring += '&' + current_checkbox.prop('name') + '=' + current_val
|
|
reset_page_and_go(retstring);
|
|
});
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
$('.product-min-thumbnails a').each(function () {
|
|
var link = $(this);
|
|
link.on('click', function () {
|
|
$('.product-big-thumbnail img').prop('src', link.prop('href'));
|
|
$('#product-big-img').attr('data-zoom-image', link.attr("data-big-url"));
|
|
$('.zoomContainer').remove();
|
|
$('#product-big-img').removeData('elevateZoom');
|
|
$('#product-big-img').removeData('zoomImage');
|
|
$('#product-big-img').elevateZoom({
|
|
zoomType: "inner",
|
|
cursor: "crosshair",
|
|
lensFadeIn: 500,
|
|
lensFadeOut: 500,
|
|
easing: true
|
|
});
|
|
|
|
|
|
// $('.product-big-thumbnail-container').trigger('zoom.destroy');
|
|
// $('.product-big-thumbnail-container').zoom({url: link.attr("data-big-url")});
|
|
//$('a#product-big-image-url').prop('href', link.attr('data-big-url'))
|
|
return false;
|
|
})
|
|
});
|
|
$('#product-big-img').elevateZoom({
|
|
zoomType: "inner",
|
|
cursor: "crosshair",
|
|
lensFadeIn: 500,
|
|
lensFadeOut: 500,
|
|
easing: true
|
|
});
|
|
//$('.product-big-thumbnail-container').zoom({url: $('#product-big-image-url').prop("href")});
|
|
|
|
|
|
function create_cart_add_link(product_pk, count) {
|
|
return $.param.querystring('/store/cart/add/', 'pk=' + product_pk + '&count=' + count + '&next=' + window.location.pathname);
|
|
}
|
|
|
|
function selectVariation(value, index) {
|
|
var price = $('.product-variations-selecter option[value=' + value + ']').attr('data-price');
|
|
var in_stock = $('.product-variations-selecter option[value=' + value + ']').attr('data-count');
|
|
$('.product-detail-price-span').html(price);
|
|
if (in_stock > 0) {
|
|
$(".product-count-selecter").selecter('destroy');
|
|
$('.product-in-stock').show();
|
|
$('.product-not-in-stock').hide();
|
|
$('.product-count-selecter').html('');
|
|
for (i = 0; i < in_stock; i++) {
|
|
var option = $('<option/>');
|
|
option.attr({'value': i + 1}).text((i + 1) + ' шт.');
|
|
$('.product-count-selecter').append(option);
|
|
}
|
|
$(".product-count-selecter").selecter({
|
|
callback: selectCount
|
|
});
|
|
selectCount(1, index);
|
|
$('#product-add-to-cart-link').prop('href',
|
|
create_cart_add_link($('.product-variations-selecter').val(),
|
|
$('.product-count-selecter').val()));
|
|
} else {
|
|
$('.product-count-selecter').selecter('destroy');
|
|
$('.product-in-stock').hide();
|
|
$('.product-not-in-stock').show();
|
|
}
|
|
|
|
}
|
|
|
|
$(".product-variations-selecter").selecter({
|
|
callback: selectVariation
|
|
});
|
|
|
|
function selectCount(value, index) {
|
|
var price = parseInt($('.product-detail-price-span').html());
|
|
$('.itogo-span').html(price * value);
|
|
$('#product-add-to-cart-link').prop('href',
|
|
create_cart_add_link($('.product-variations-selecter').val(),
|
|
$('.product-count-selecter').val()));
|
|
}
|
|
|
|
$(".product-count-selecter").selecter({
|
|
callback: selectCount
|
|
});
|
|
|
|
|
|
if ($('.product-count-selecter option').size() < 1) {
|
|
$('.product-in-stock').hide();
|
|
$('.product-not-in-stock').show();
|
|
|
|
} else {
|
|
$(".product-count-selecter").selecter();
|
|
}
|
|
|
|
$('ul.messages li').each(function () {
|
|
var li = $(this);
|
|
var messageType = li.attr('data-type');
|
|
swal({
|
|
html: true,
|
|
type: messageType,
|
|
title: "OK!",
|
|
text: li.html()
|
|
|
|
});
|
|
});
|
|
|
|
function selectCity() {
|
|
var city = $('#id_city').val();
|
|
var deliv = $('#id_deliv_type').val();
|
|
var cart_itogo = $('#cart-itogo');
|
|
var order_itogo_delivery = $('#order-itogo-delivery');
|
|
var order_itogo = $('#order-itogo-amount');
|
|
var order_itogo_up = $('#order-itogo-amount-up');
|
|
var order_itogo_delivery_up = $('#order-itogo-delivery-up');
|
|
|
|
if (city && deliv) {
|
|
$.ajax({
|
|
method: "GET",
|
|
url: "/get_order_amount/",
|
|
data: {
|
|
city: city,
|
|
deliv: deliv,
|
|
|
|
}
|
|
})
|
|
.done(function (msg) {
|
|
order_itogo.html(
|
|
parseFloat(msg.AmountPlusFSAmount) + parseFloat(cart_itogo.html())
|
|
);
|
|
order_itogo_up.html(
|
|
parseFloat(msg.AmountPlusFSAmount) + parseFloat(cart_itogo.html())
|
|
);
|
|
order_itogo_delivery.html(
|
|
parseFloat(msg.AmountPlusFSAmount)
|
|
);
|
|
//cart_itogo.html(
|
|
// parseFloat(msg.AmountPlusFSAmount) + parseFloat(cart_itogo.html())
|
|
//);
|
|
order_itogo_delivery_up.html(
|
|
parseFloat(msg.AmountPlusFSAmount)
|
|
);
|
|
});
|
|
|
|
} else {
|
|
order_itogo.html(cart_itogo);
|
|
}
|
|
}
|
|
|
|
|
|
$('#id_city').select2({
|
|
placeholder: "Выберите город",
|
|
allowClear: false
|
|
}).on('change', function () {
|
|
selectCity();
|
|
});
|
|
|
|
$('#id_deliv_type').select2({
|
|
placeholder: "Выберите способ доставки",
|
|
allowClear: false
|
|
}).on('change', function () {
|
|
selectCity();
|
|
});
|
|
|
|
|
|
$('#order-call-link').magnificPopup({
|
|
type: 'inline',
|
|
preloader: false,
|
|
|
|
});
|
|
|
|
$('#call-form').on('submit', function(){
|
|
var f_name = $('#call-form #id_name');
|
|
var f_phone = $('#call-form #id_phone');
|
|
var f_time = $('#call-form #id_time');
|
|
var is_full = true;
|
|
|
|
if (!f_name.val()){
|
|
f_name.parent().parent('.form-group').addClass('has-error');
|
|
is_full = false;
|
|
}else{
|
|
f_name.parent().parent('.form-group').removeClass('has-error');
|
|
}
|
|
if (!f_phone.val()){
|
|
f_phone.parent().parent('.form-group').addClass('has-error');
|
|
is_full = false;
|
|
}else{
|
|
f_phone.parent().parent('.form-group').removeClass('has-error');
|
|
}
|
|
if (!f_time.val()){
|
|
f_time.parent().parent('.form-group').addClass('has-error');
|
|
is_full = false;
|
|
}else{
|
|
f_time.parent().parent('.form-group').removeClass('has-error');
|
|
}
|
|
if (is_full){
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/order_call/',
|
|
data: {
|
|
name: f_name.val(),
|
|
phone: f_phone.val(),
|
|
time: f_time.val(),
|
|
},
|
|
success: function(data){
|
|
|
|
$.magnificPopup.close();
|
|
swal("Спасибо!", "Мы приняли вашу заявку! Наш менеджер свяжется с вами в указанное время.", "success")
|
|
|
|
}
|
|
});
|
|
}
|
|
//form-group has-error
|
|
return false;
|
|
})
|
|
|
|
})
|
|
; |