Date.prototype.getMonthFormatted = function () {
var month = this.getMonth() + 1;
return month < 10 ? '0' + month : month;
}
Date.prototype.getDateFormatted = function () {
var date = this.getDate();
return date < 10 ? '0' + date : date;
}
jQuery.fn.extend({
toggleText: function (a, b) {
var that = this;
if (that.text() != a && that.text() != b) {
that.text(a);
} else if (that.text() == a) {
that.text(b);
} else if (that.text() == b) {
that.text(a);
}
return this;
}
});
$(document).ready(function () {
$(".js-search-swap").click(function () {
$(this).parent(".search-item").toggleClass("active");
$(".full-width-search").toggleClass("active");
return false;
});
$(".js-close-minicart").click(function () {
$(".sidebar-cart").removeClass("open");
});
$(".sidebar-mm").hover(function () {
$(this).addClass("open");
$(".sidebar-shadow").addClass("open");
$(".hamburger").addClass("is-active");
}, function () {
$(this).removeClass("open");
$(".sidebar-shadow").removeClass("open");
$(".hamburger").removeClass("is-active");
});
$('.inputmode').attr('inputmode', 'numeric');
imageGallery();
$(".split-catalog-slide .fa").click(function () {
$(this).closest(".tree").find("ul:first").slideToggle();
return false;
});
$(".split-catalog-slide li.selected").find("ul:first").css("display", "block");
$(".split-catalog-slide li.selected").parents("ul").css("display", "block");
$(".split-catalog-slide .header").click(function () {
$(".split-catalog-slide").toggleClass("hide");
});
$(".js-topmenu-open").click(function () {
$(this).closest(".cat-nav").toggleClass("open");
$(".cat-nav__categories-list").toggleClass("open");
var sidebar_width = $(".mega-sidebar.cat-nav__topmenu").width();
var container_width = $("nav .container").width();
var ul_width = container_width - sidebar_width - 10;
$(".mega-sidebar.cat-nav__topmenu ul").attr("style", "width:" + ul_width + "px");
});
$(".js-show-order").click(function () {
$(this).parent("div").prev().toggleClass("show");
$(this).toggleText($(this).data("open"), $(this).data("close"));
});
$(".js-footer-more").click(function () {
$(this).closest(".col-12").find(".hide-mobile").removeClass("hide-mobile");
$(this).remove();
$(".menu-h-footer li").addClass("show-all");
});
$(".js-m-nav__open").click(function () {
$(".nav-block").toggleClass("nav-full-screen");
$(".catalog-menu").toggleClass("compact");
});
$(".js-show-all").click(function () {
$(this).addClass("hide");
$(this).parent("ul").find("li").addClass("show");
});
$(".js-open-search").click(function () {
$('html, body').animate({scrollTop: 0}, 300, 'linear');
$(".m-search").toggleClass("open");
});
$(".js-show-filter-mobile, .js-closefilter").click(function () {
$(".filter").toggleClass("open");
});
$(".js-show-xs-menu").click(function () {
$(".m-menu").toggleClass("open");
});
$(".js-close-m-menu").click(function () {
$(".m-menu").toggleClass("open");
});
$(".js-expand").click(function () {
if ($(this).hasClass("open")) {
$(this).removeClass("open");
$(this).parent("li").removeClass("open");
} else {
$(this).parent("li").addClass("open");
$(this).addClass("open")
}
$(this).parent("li").find("ul:first").slideToggle();
return false;
});
/** Catalog type **/
$(document).on("click", ".js-showtype span", function () {
$(".showtype span").removeClass("active");
$(this).addClass("active");
if ($(this).data("list") == 'list') {
$.cookie('show', 'list', {
expires: 7,
path: '/'
});
} else if ($(this).data("list") == 'text') {
$.cookie('show', 'text', {
expires: 7,
path: '/'
});
} else {
$.cookie('show', 'thumbs', {
expires: 7,
path: '/'
});
}
$('.filterform').submit();
return false;
});
/** Custom tooltips **/
$('[data-toggle="tooltip-custom"]').hover(function () {
var text = $(this).data("title");
$(this).append("
«);
}, function () {
$(«.custom-tooltips»).remove();
});
/** Home mailer form **/
$(«.form-control.email-check»).focus(function () {
$(this).closest(«#mailer-subscribe-form»).find(«.rules»).show();
});
$(‘#mailer-subscribe-form input.charset’).val(document.charset || document.characterSet);
$(‘#mailer-subscribe-form’).submit(function () {
var form = $(this);
var email_input = form.find(‘.email-check’);
var rules = form.find(‘input[name=»rules»]’);
if (!rules.prop(«checked»)) {
alert(«Необходимо принять условия: » + rules.data(«text»));
return false;
}
if (!email_input.val()) {
email_input.addClass(‘error’);
alert(email_input.attr(«placeholder»));
return false;
} else {
email_input.removeClass(‘error’);
}
$(‘#mailer-subscribe-iframe’).load(function () {
$(‘.mailer-subscribe .table-cell’).hide();
$(‘#mailer-subscribe-iframe’).hide();
$(‘#mailer-subscribe-thankyou’).show();
});
});
/** Home tabs switch **/
$(«.js-tabs-home a»).click(function () {
var ind = $(this).index();
$(this).closest(«.h1-header-tabs»).find(«.tab»).removeClass(«active»);
$(this).addClass(«active»);
$(«.p-block .p-thumbs»).removeClass(«show»);
$(«.p-block .p-thumbs-switch .p-thumbs»).eq(ind).addClass(«show»);
$(‘.lazy’).Lazy({
effect: «fadeIn»,
effectTime: 800,
threshold: 1
});
});
/** Home slider **/
var home_slider_time = $(«.home-slider__slick»).data(«slide-time»);
if (!home_slider_time) {
var home_slider_time = 3000;
}
$(«.js-main-slider»).on(‘afterChange’, function(event, slick, currentSlide, nextSlide){
$(‘.lazy’).Lazy({
effect: «fadeIn»,
effectTime: 800,
threshold: 1
});
});
$(«.js-main-slider»).slick({
autoplay: true,
infinite: false,
autoplaySpeed: home_slider_time,
rows: 0,
lazyLoad: ‘ondemand’,
dots: false,
nav: false,
height: true,
nextArrow: ‘
‘,
prevArrow: ‘
‘,
}).css(«visibility», «visible»);
/** Product slider **/
$(«.js-product-image-slider»).slick({
autoplay: false,
infinite: false,
rows: 0,
adaptiveHeight: true,
dots: true,
arrows: true,
draggable: false,
nextArrow: ‘
‘,
prevArrow: ‘
‘,
}).css(«visibility», «visible»);
/** 4-col home slider **/
var sliderFourProduct = $(«.js-sproduct-four»);
sliderFourProduct.on(‘afterChange’, function(event, slick, currentSlide, nextSlide){
$(‘.lazy’).Lazy({
effect: «fadeIn»,
effectTime: 800,
threshold: 1
});
});
var buttonFourPrev = $(‘.js-sproduct-four-prev’);
var buttonFourNext = $(‘.js-sproduct-four-next’);
sliderFourProduct.slick({
infinite: false,
autoplay: true,
autoplaySpeed: 8000,
slidesToShow: 4,
slidesToScroll: 4,
rows: 0,
dots: false,
arrows: true,
nextArrow: ‘
‘,
prevArrow: ‘
‘,
responsive: [
{
breakpoint: 2024,
settings: {
slidesToShow: 4,
slidesToScroll: 4,
}
},
{
breakpoint: 1500,
settings: {
slidesToShow: 4,
slidesToScroll: 4
}
},
{
breakpoint: 1140,
settings: {
slidesToShow: 3,
slidesToScroll: 3
}
},
{
breakpoint: 800,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
},
{
breakpoint: 380,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
buttonFourPrev.click(function () {
sliderFourProduct.slick(‘slickPrev’);
});
buttonFourNext.click(function () {
sliderFourProduct.slick(‘slickNext’);
});
/** 5-col home slider **/
var sliderFiveProduct = $(«.js-sproduct-five»);
sliderFiveProduct.on(‘afterChange’, function(event, slick, currentSlide, nextSlide){
$(‘.lazy’).Lazy({
effect: «fadeIn»,
effectTime: 800,
threshold: 1
});
});
var mobilerow = sliderFiveProduct.data(«mobile-row»);
sliderFiveProduct.slick({
infinite: false,
autoplay: true,
autoplaySpeed: 8000,
slidesToShow: 5,
slidesToScroll: 5,
rows: 0,
dots: false,
arrows: true,
nextArrow: ‘
‘,
prevArrow: ‘
‘,
responsive: [
{
breakpoint: 2024,
settings: {
slidesToShow: 5,
slidesToScroll: 5,
}
},
{
breakpoint: 1500,
settings: {
slidesToShow: 4,
slidesToScroll: 4
}
},
{
breakpoint: 1140,
settings: {
slidesToShow: 3,
slidesToScroll: 3
}
},
{
breakpoint: 800,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: mobilerow,
slidesToScroll: mobilerow
}
},
{
breakpoint: 380,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
/** 5-col home second slider **/
var sliderDFiveProduct = $(«.js-dproduct-five»);
var buttonDFivePrev = $(‘.js-dproduct-five-prev’);
var buttonDFiveNext = $(‘.js-dproduct-five-next’);
sliderDFiveProduct.slick({
infinite: false,
autoplay: true,
autoplaySpeed: 8000,
slidesToShow: 5,
slidesToScroll: 5,
rows: 0,
dots: false,
arrows: false,
prevArrow: buttonDFivePrev,
nextArrow: buttonDFiveNext,
responsive: [
{
breakpoint: 2024,
settings: {
slidesToShow: 5,
slidesToScroll: 5,
}
},
{
breakpoint: 1500,
settings: {
slidesToShow: 4,
slidesToScroll: 4
}
},
{
breakpoint: 1140,
settings: {
slidesToShow: 3,
slidesToScroll: 3
}
},
{
breakpoint: 800,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
},
{
breakpoint: 380,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
buttonDFivePrev.click(function () {
sliderDFiveProduct.slick(‘slickPrev’);
});
buttonDFiveNext.click(function () {
sliderDFiveProduct.slick(‘slickNext’);
});
/** 4-col home second slider **/
var sliderDFourProduct = $(«.js-dproduct-four»);
var buttonDFourPrev = $(‘.js-dproduct-four-prev’);
var buttonDFourNext = $(‘.js-dproduct-four-next’);
sliderDFourProduct.slick({
infinite: false,
autoplay: true,
autoplaySpeed: 8000,
slidesToShow: 5,
slidesToScroll: 5,
rows: 0,
dots: false,
arrows: false,
prevArrow: buttonDFourPrev,
nextArrow: buttonDFourNext,
responsive: [
{
breakpoint: 2024,
settings: {
slidesToShow: 4,
slidesToScroll: 4,
}
},
{
breakpoint: 1000,
settings: {
slidesToShow: 4,
slidesToScroll: 4
}
},
{
breakpoint: 800,
settings: {
slidesToShow: 3,
slidesToScroll: 3
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 380,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
buttonDFourPrev.click(function () {
sliderDFourProduct.slick(‘slickPrev’);
});
buttonDFourNext.click(function () {
sliderDFourProduct.slick(‘slickNext’);
});
/** 4-col home second slider **/
var splitSliderProduct = $(«.js-gallery-split»);
splitSliderProduct.slick({
prevArrow: ««,
nextArrow: ««,
infinite: false,
autoplay: false,
slidesToShow: 4,
slidesToScroll: 1,
autoplaySpeed: 8000,
dots: false,
arrows: true,
responsive: [
{
breakpoint: 2024,
settings: {
slidesToShow: 4,
slidesToScroll: 1,
}
},
{
breakpoint: 1000,
settings: {
slidesToShow: 4,
slidesToScroll: 1
}
},
{
breakpoint: 800,
settings: {
slidesToShow: 5,
slidesToScroll: 5
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 3,
slidesToScroll: 3
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 5,
slidesToScroll: 5
}
},
{
breakpoint: 380,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
/** Brands **/
/** 5-col home slider **/
var sliderFiveProduct = $(«.js-brands-home»);
sliderFiveProduct.slick({
infinite: false,
autoplay: true,
autoplaySpeed: 8000,
slidesToShow: 5,
slidesToScroll: 5,
rows: 0,
dots: false,
arrows: true,
nextArrow: ‘
‘,
prevArrow: ‘
‘,
responsive: [
{
breakpoint: 2024,
settings: {
slidesToShow: 5,
slidesToScroll: 5,
}
},
{
breakpoint: 1500,
settings: {
slidesToShow: 4,
slidesToScroll: 4
}
},
{
breakpoint: 1140,
settings: {
slidesToShow: 3,
slidesToScroll: 3
}
},
{
breakpoint: 800,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
},
{
breakpoint: 380,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
/** review **/
var sliderReview = $(«.js-review»);
var buttonReviewPrev = $(‘.js-review-prev’);
var buttonReviewNext = $(‘.js-review-next’);
sliderReview.slick({
infinite: false,
autoplay: true,
autoplaySpeed: 5000,
slidesToShow: 1,
slidesToScroll: 1,
rows: 0,
dots: false,
arrows: false,
adaptiveHeight: true,
prevArrow: buttonReviewPrev,
nextArrow: buttonReviewNext,
});
buttonReviewPrev.click(function () {
sliderReview.slick(‘slickPrev’);
});
buttonReviewNext.click(function () {
sliderReview.slick(‘slickNext’);
});
$(«.hidden1»).parent(«li»).remove();
$(«.btn.disabled»).click(function () {
return false;
});
// Clear favorite
$(«.clearfavorite»).click(function () {
$.cookie(‘shop_favorite’, », {
expires: 30,
path: ‘/’
});
location.reload();
return false;
});
// Clear view
$(«.clearview»).click(function () {
$.cookie(‘shop_view’, », {
expires: 30,
path: ‘/’
});
location.reload();
return false;
});
/** Preview button & window **/
$(‘body’).on(‘click’, ‘.js-preview’, function () {
var f = $(this).closest(«.p-card-clone»).find(«.p-catalog-submit»);
if (f.data(‘preview’)) {
var d = $(‘#dialog’);
var c = d.find(‘.dialog-cart’);
d.show();
d.append(«
«);
c.hide();
c.load(f.data(‘preview’), function () {
d.find(«.loading»).remove();
c.prepend(‘
‘);
c.css(‘top’, $(window).scrollTop() + 100);
if ($(«body»).width() < 600) {
c.css('top', '0');
c.css('max-height', '100%');
}
c.fadeIn();
});
return false;
}
});
/** LiveSearch **/
$(".livesearch").on("keyup", function () {
var input = $(this);
input.focus();
var url_search = input.closest("form").data("search");
var cart = $(".search-popup");
var value = $(this).val();
if (value.length > 3) {
var url = encodeURI(value);
input.after(«
«);
cart.load(url_search + ‘?view=ajax_search&query=’ + url + ‘ .ajax_block’, function () {
cart.show();
cart.find(«.ajax_search_link a»).attr(«href», url_search + ‘?query=’ + value);
$(«.loading_ajax»).remove();
$(«.header»).addClass(«z-ind50»);
$(«.hide_search»).click(function () {
$(«.header»).removeClass(«z-ind50»);
$(«.search-popup»).html(«»);
$(«.loading_ajax»).remove();
return false;
});
});
} else {
cart.hide();
$(«.search-popup»).html(«»);
$(«.loading_ajax»).remove();
$(«.header»).removeClass(«z-ind50»);
}
});
// Remove search popup
$(«.remove-search a»).click(function () {
$(«input[name=’query’]»).val(«»);
$(this).fadeOut();
return false;
});
setTimeout(function () {
updateTopMenu();
}, 30);
$(window).resize(function () {
$(‘.t-line .menu-h .drop-link’).remove();
var cnt = $(«.t-line .more-menu»).contents();
$(«.t-line .more-menu»).replaceWith(cnt);
$(«.t-line .more»).after(cnt);
$(«.t-line .more»).remove();
updateTopMenu();
});
$(document).on(‘scroll’, function () {
if ($(window).scrollTop() > 100) {
$(‘.scroll-top-wrapper’).addClass(‘show’);
$(‘.sidebar-button’).addClass(‘show’);
} else {
$(‘.scroll-top-wrapper’).removeClass(‘show’);
$(‘.sidebar-button’).removeClass(‘show’);
}
if ($(window).scrollTop() > $(‘.footer’).offset().top — $(window).height()) {
$(‘.js-product-seen’).animate({‘right’: ‘0px’}, 300);
$(‘.lazy’).Lazy({
effect: «fadeIn»,
effectTime: 800,
threshold: 1
});
} else {
$(‘.js-product-seen’).stop(true).animate({‘right’: ‘-101%’}, 100);
}
});
$(‘.js-close-seen’).click(function(){
$(this).closest(«.product__seen»).hide();
});
// Scroll Top
$(‘.scroll-top-wrapper’).on(‘click’, scrollToTop);
favoriteProduct();
compareProduct();
// countdown
if ($.fn.countdowntimer) {
$(‘.js-promo-countdown’).each(function () {
var $this = $(this).html(»);
var id = ($this.attr(‘id’) || ‘js-promo-countdown’ + (» + Math.random()).slice(2));
$this.attr(‘id’, id);
var start = $this.data(‘start’).replace(/-/g, ‘/’);
var end = $this.data(‘end’).replace(/-/g, ‘/’);
$this.countdowntimer({
startDate: start,
dateAndTime: end,
size: ‘lg’,
regexpMatchFormat: «([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})»,
regexpReplaceWith: «$1 дн. $2:$3:$4»
});
});
}
// Compare
$(‘.js-clear-compare’).on(‘click’, function () {
$.cookie(‘shop_compare’, null, {path: ‘/’});
location.href = location.href.replace(/compare\/.*/, ‘compare/’);
return false;
});
$(«#compare-all»).click(function () {
$(«#compare-table tr.same»).show();
$(this).closest(‘ul’).find(‘li.selected’).removeClass(‘selected’);
$(this).parent().addClass(‘selected’);
return false;
});
$(«#compare-diff»).click(function () {
$(«#compare-table tr.same»).hide();
$(this).closest(‘ul’).find(‘li.selected’).removeClass(‘selected’);
$(this).parent().addClass(‘selected’);
return false;
});
$(«#compare-table .compare-remove»).on(‘click’, function () {
var compare = $.cookie(‘shop_compare’);
if (compare) {
compare = compare.split(‘,’);
} else {
compare = [];
}
var i = $.inArray($(this).data(‘product’) + », compare);
if (i != -1) {
compare.splice(i, 1)
}
if (compare) {
$.cookie(‘shop_compare’, compare.join(‘,’), {expires: 30, path: ‘/’});
} else {
$.cookie(‘shop_compare’, null);
}
});
$(document).on(«click», «.js-inc_cart», function () {
var current = $(this).parent(«div»).find(«.select_input_cart»).val();
if (current >= 999) {
var current = 999;
}
$(this).parent(«div»).find(«.select_input_cart»).val(parseInt(current) + 1).trigger(‘change’);
blink($(this).parent(«div»).find(«.select_input_cart»));
return false;
});
$(document).on(«click», «.js-dec_cart», function () {
var current = $(this).parent(«div»).find(«.select_input_cart»).val();
if (current == 1) {
var current = 2;
}
$(this).parent(«div»).find(«.select_input_cart»).val(parseInt(current) — 1).trigger(‘change’);
blink($(this).parent(«div»).find(«.select_input_cart»));
return false;
});
$(«.filtergroup .panel-body»).click(function () {
if ($(this).closest(«.filtergroup»).hasClass(«open»)) {
$(this).find(«.hint»).html($(this).find(«.hint»).data(«open»));
} else {
$(this).find(«.hint»).html($(this).find(«.hint»).data(«close»));
}
$(this).closest(«.filtergroup»).toggleClass(«open»);
return false;
});
$(«.sorting-mobile .toggle-dropdown»).click(function () {
$(this).parent(«li»).find(«ul»).toggleClass(«open»);
return false;
});
$(‘.m-filter-select’).on(‘change’, function () {
var url = $(this).val(); // get selected value
if (url == ‘default’) {
return false;
}
if (url) { // require a URL
window.location = url; // redirect
}
return false;
});
var f = function () {
//product filtering
var ajax_form_callback = function (f) {
var fields = f.serializeArray();
var params = [];
var filter_count = 0;
for (var i = 0; i < fields.length; i++) {
if (fields[i].value !== '') {
params.push(fields[i].name + '=' + fields[i].value);
if (fields[i].name != 'sort' && fields[i].name != 'order') {
filter_count = filter_count + 1;
}
}
}
$(".mobile-filter__count").text(filter_count);
if ($(window).width() < 580) {
scrollToTop();
}
var url = '?' + params.join('&');
$(window).lazyLoad && $(window).lazyLoad('sleep');
$('#product-list').html('‘);
$.get(url + ‘&_=_’, function (html) {
var tmp = $(‘
‘).html(html);
$(‘#product-list’).html(tmp.find(‘#product-list’).html());
if (!!(history.pushState && history.state !== undefined)) {
window.history.pushState({}, », url);
}
$(window).lazyLoad && $(window).lazyLoad(‘reload’);
$(«.subcategory-images»).slideUp();
imageGallery();
compareProduct();
favoriteProduct();
$(‘.lazy’).Lazy({
effect: «fadeIn»,
effectTime: 800,
threshold: 1
});
});
};
$(‘.filters.ajax form input’).change(function () {
ajax_form_callback($(this).closest(‘form’));
});
$(‘.filters.ajax form’).submit(function () {
ajax_form_callback($(this));
return false;
});
$(‘.filters .sliderunit’).each(function () {
if (!$(this).find(‘.filter-slider’).length) {
$(this).append(‘
‘);
} else {
return;
}
var min = $(this).find(‘.min’);
var max = $(this).find(‘.max’);
var min_value = parseFloat(min.attr(‘placeholder’));
var max_value = parseFloat(max.attr(‘placeholder’));
var step = 1;
var slider = $(this).find(‘.filter-slider’);
if (slider.data(‘step’)) {
step = parseFloat(slider.data(‘step’));
} else {
var diff = max_value — min_value;
if (Math.round(min_value) != min_value || Math.round(max_value) != max_value) {
step = diff / 10;
var tmp = 0;
while (step < 1) {
step *= 10;
tmp += 1;
}
step = Math.pow(10, -tmp);
tmp = Math.round(100000 * Math.abs(Math.round(min_value) - min_value)) / 100000;
if (tmp && tmp < step) {
step = tmp;
}
tmp = Math.round(100000 * Math.abs(Math.round(max_value) - max_value)) / 100000;
if (tmp && tmp < step) {
step = tmp;
}
}
}
slider.slider({
range: true,
min: parseFloat(min.attr('placeholder')),
max: parseFloat(max.attr('placeholder')),
step: step,
values: [parseFloat(min.val().length ? min.val() : min.attr('placeholder')),
parseFloat(max.val().length ? max.val() : max.attr('placeholder'))],
slide: function (event, ui) {
var v = ui.values[0] == $(this).slider('option', 'min') ? '' : ui.values[0];
min.val(v);
v = ui.values[1] == $(this).slider('option', 'max') ? '' : ui.values[1];
max.val(v);
},
stop: function (event, ui) {
min.change();
}
});
min.add(max).change(function () {
var v_min = min.val() === '' ? slider.slider('option', 'min') : parseFloat(min.val());
var v_max = max.val() === '' ? slider.slider('option', 'max') : parseFloat(max.val());
if (v_max >= v_min) {
slider.slider(‘option’, ‘values’, [v_min, v_max]);
}
});
});
$(‘.filters .sliderdate’).each(function () {
if (!$(this).find(‘.filter-slider’).length) {
$(this).append(‘
‘);
} else {
return;
}
var th = $(this);
var min_input = th.find(‘.min’).attr(‘placeholder’);
var max_input = th.find(‘.max’).attr(‘placeholder’)
var min = new Date(min_input).getTime() / 1000;
var max = new Date(max_input).getTime() / 1000;
var step = 86400;
var slider = $(this).find(‘.filter-slider’);
slider.slider({
range: true,
min: min,
max: max,
step: step,
values: [min, max],
slide: function (event, ui) {
th.val(ui.values[0], ui.values[1]);
var date_min = new Date(ui.values[0] * 1000);
var date_max = new Date(ui.values[1] * 1000);
var date_min = date_min.getFullYear() + «-» + date_min.getMonthFormatted() + «-» + date_min.getUTCDate();
var date_max = date_max.getFullYear() + «-» + date_max.getMonthFormatted() + «-» + date_max.getUTCDate();
th.find(‘.min’).attr(‘placeholder’, date_min);
th.find(‘.min’).val(date_min);
th.find(‘.max’).attr(‘placeholder’, date_max);
th.find(‘.max’).val(date_max);
},
stop: function (event, ui) {
ajax_form_callback($(«.filterform»));
}
});
});
};
f();
$.fn.toggleChecked = function () {
return this.each(function () {
this.checked = this.unchecked;
});
};
$(document).on(‘click’, ‘.js-clearfilter’, function () {
$(‘.checkbox’).find(‘input’).toggleChecked();
$(‘.radio’).find(«.any»).attr(«checked», true);
$(«.rangefilter»).each(function () {
var min = parseFloat($(this).find(«.min»).attr(‘placeholder’));
var max = parseFloat($(this).find(«.max»).attr(‘placeholder’));
$(this).closest(‘.filtergroup’).find(‘.filter-slider’).slider({
min: min,
max: max,
values: [min, max]
});
});
$(‘.rangefilter input’).val(»);
$(‘.filterform’).submit();
return false;
});
$(document).on(‘click’, ‘.js-addtocart’, function () {
var th = $(this);
var f = $(this).closest(«form»);
var count = $(this).closest(«.p-thumbs__button»).find(«.select_input_cart»).val();
if (f.data(‘url’)) {
var d = $(‘#dialog’);
var c = d.find(‘.dialog-cart’);
d.show();
d.append(«
«);
c.hide();
c.load(f.data(‘url’), function () {
d.find(«.loading»).remove();
c.prepend(‘
‘);
c.fadeIn();
c.css(‘bottom’, ‘auto’);
c.css(‘top’, $(window).scrollTop() + 100);
if ($(«body»).width() < 600) { c.css('top', '0'); c.css('max-height', '100%'); } }); return false; } th.addClass("loading-cart-icon"); $.post(f.attr('action') + '?html=1', f.serialize(), function (response) { if (response.status == "ok") { miniCartLoad(".js-load-cart"); if ($(window).width() < 580) { var cart = $('.xs-menu__icons__cart'); } else { if (isOnScreen($(".header-button .icon-cart"))) { var cart = $('.header-button .icon-cart'); } else if (isOnScreen($(".sidebar-button"))) { var cart = $('.sidebar-button .icon-cart'); } else { var cart = $('.header-button .icon-cart'); } } var origin = th.closest(".p-card-clone"); var block = $('
‘).append(origin.html());
block.css({
‘z-index’: 100500,
top: origin.offset().top,
left: origin.offset().left,
width: origin.width() + ‘px’,
height: origin.height() + ‘px’,
position: ‘absolute’,
overflow: ‘hidden’
}).appendTo(‘body’).css({
‘border’: ‘1px solid #eee’,
‘padding’: ’10px’
}).animate({
top: cart.offset().top,
left: cart.offset().left,
width: ’10px’,
height: ’10px’,
opacity: 0.7
}, 700, function () {
$(‘.dialog’).find(‘.dialog-cart’).empty();
$(this).remove();
});
setTimeout(function () {
th.removeClass(«loading-cart-icon»);
}, 800);
cartAlert(3000, count, » добавлен в корзину», true);
$(«.cart-count»).html(response.data.count);
$(«.cart-total»).html(response.data.total);
blink($(«.sidebar-button .icon-cart»));
blink($(«.xs-menu__icons__cart»));
} else if (response.status == ‘fail’) {
th.removeClass(«loading-cart-icon»);
alert(response.errors);
$.post(f.attr(«action»).replace(«add», «save»), function (response) {
$(«.cart-count»).html(response.data.count);
$(«.cart-total»).html(response.data.total);
});
}
}, «json»);
return false;
});
$(‘.dialog’).on(‘click’, ‘.close-block’, function () {
$(this).closest(‘.dialog’).hide().find(‘.dialog-cart’).empty();
return false;
});
$(‘.dialog-callback’).on(‘click’, ‘.close-block’, function () {
$(this).closest(‘.dialog-callback’).hide();
return false;
});
$(document).keyup(function (e) {
if (e.keyCode == 27) {
$(«.dialog:visible»).hide().find(‘.dialog-cart’).empty();
$(«#product-review-form»).removeClass(«review-fixed»).css(«display», «none»);
$(«.review-fixed-background»).removeClass(«show»);
}
});
$(«.favorite-link»).click(function () {
var id = $(this).data(«product»);
var compare = $.cookie(‘shop_compare’);
$.cookie(‘shop_compare’, compare, {expires: 30, path: ‘/’});
if (compare) {
compare = compare.split(‘,’);
} else {
compare = [];
}
var i = $.inArray($(this).data(‘product’) + », compare);
if (i != -1) {
compare.splice(i, 1)
}
if (compare.length > 0) {
$.cookie(‘shop_compare’, compare.join(‘,’), {expires: 30, path: ‘/’});
} else {
$.cookie(‘shop_compare’, null, {path: ‘/’});
}
});
});
function blink(selector) {
$(selector).fadeOut(‘fast’, function () {
$(this).fadeIn(‘fast’, function () {
});
});
}
function scrollToTop() {
verticalOffset = typeof (verticalOffset) != ‘undefined’ ? verticalOffset : 0;
element = $(‘body’);
offset = element.offset();
offsetTop = offset.top;
$(‘html, body’).animate({scrollTop: offsetTop}, 500, ‘linear’);
}
function updateTopMenu() {
if ($(«.t-line .menu-h»).length) {
var menu = $(«.t-line .menu-h > li»);
}
var container = $(‘.t-line .menu-h’).width();
var full_with = 0;
var current = 0;
menu.each(function (count) {
full_width_count = count;
});
menu.each(function (count) {
full_with += $(this).width();
if ((container — 50) < full_with) {
current = count;
return false;
}
});
if (current > 1) {
current = current — 1;
menu.filter(‘:gt(‘ + current + ‘)’).wrapAll(‘