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.
208 lines
7.0 KiB
208 lines
7.0 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(value, index) {
|
|
var city = $('#id_city').val();
|
|
var deliv = $('#id_deliv_type').val();
|
|
var cart_itogo = $('#cart-itogo').html();
|
|
var order_itogo = $('#order-itogo-amount');
|
|
|
|
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)
|
|
);
|
|
});
|
|
|
|
} else {
|
|
order_itogo.html(cart_itogo);
|
|
}
|
|
}
|
|
|
|
|
|
$('#id_city').selecter({
|
|
callback: selectCity
|
|
});
|
|
|
|
$('#id_deliv_type').selecter({
|
|
callback: selectCity
|
|
});
|
|
|
|
}); |