');
$li.data('i', i);
$li.click(function() {
var $tt, d;
$tt = $(this);
//$t.val($tt.text())
d = $tt.data('i');
$t.val(d.name);
return $res.hide();
});
results.push($res.append($li));
} else {
results.push(void 0);
}
}
return results;
});
},
yandexSearchCity: function() {
var $par, $res, $t, val;
$t = $(this);
val = $t.val();
$par = $t.closest(".dadata_wrap");
$res = $(".dadata_res", $par);
console.log($res, $par);
return API('geocode/searchCity', {
q: val,
dataType: 'JSON'
}, function(data) {
var $li, i, k, len, results;
console.log(data);
$res.html('').show();
results = [];
for (k = 0, len = data.length; k < len; k++) {
i = data[k];
if (i.title !== '') {
$li = $('
' + i.name + '
' + i.city + '
');
$li.data('i', i);
$li.click(function() {
var $tt, d;
$tt = $(this);
//$t.val($tt.text())
d = $tt.data('i');
$t.val(d.name);
$("#delivery_city").attr('data-bbox', d.bbox);
console.log('ddd', d);
return $res.hide();
});
results.push($res.append($li));
} else {
results.push(void 0);
}
}
return results;
});
},
checkPhone: function(e) {
var val;
val = $(this).val().replace(/[^\d]/gi, '');
return A.P.formatPhone(val, e, $(this));
},
checkPhoneFromPaste: function(e) {
return A.P.formatPhone(e.originalEvent.clipboardData.getData('Text'), e, $(this));
},
formatPhone: function(val, e, $t) {
var ref;
if (val.length === 11) {
if ((ref = parseInt(val.substr(0, 1))) === 7 || ref === 8) {
val = val.substr(1);
}
if (e.originalEvent !== void 0) {
e.originalEvent.preventDefault();
e.originalEvent.stopPropagation();
}
//console.log(val.substr(0,1) ,[7,8],val.substr(0,1) in [7,8],val)
return $t.val(val).mask(A.phone_mask);
}
},
removeVacancyFiles: function() {
var $t;
($t = $('[type="file"]')).val(null);
$t.next().removeClass('dn');
$t.next().next().addClass('dn');
return $t.next().next().next().addClass('dn');
},
initOptions: function($t) {
var $options;
$options = $(".options", $t);
return $options.click(function(e) {
var $c, $option, $target, title;
$target = $(e.target);
//console.log('click',$target)
$option = null;
if ($target.hasClass('option')) {
$option = $target;
} else if (($c = $target.closest('.option')).length > 0) {
$option = $($c[0]);
}
console.log('click', $option);
if ($option.attr('data-value')) {
title = $option.attr('data-title');
if ((title != null) && title !== '') {
$(".value .txt", $t).text(title);
} else {
$(".value .txt", $t).text($option.text());
}
$t.data('value', $option.attr('data-value'));
$t.trigger('select.change');
$(".option", $options).removeClass('selected');
return $option.addClass('selected');
}
});
},
initSelect: function($t) {
var $options_list, url;
//$t = $(@)
$(".value", $t).click(function() {
return $t.toggleClass('open');
});
$t.data('value', '');
if ($t.attr('data-value')) {
$t.data('value', $t.attr('data-value'));
}
if ($t.hasClass('_ajax')) {
$options_list = $(".options_list", $t);
url = $t.attr('data-url');
return $("input", $t).keyup(function() {
var val;
val = $(this).val().toLowerCase();
$options_list.html('
Загрузка...
');
return $.ajax({
url: url,
type: "POST",
data: {
q: val
},
success: function(data) {
$options_list.html(data);
return A.P.initOptions($t);
}
});
});
} else {
$("input", $t).keyup(function() {
var val;
val = $(this).val().toLowerCase();
return $(".option", $t).each(function() {
var text;
text = $(this).text();
return $(this).toggle(text.toLowerCase().indexOf(val) > -1);
});
});
return A.P.initOptions($t);
}
},
//$options.hide()
//setTimeout ->
// $options.css('display','')
//,500
initItem: function($html) {
return null;
if (!A.isMobile()) {
//console.log("$(\".item:not(.inited)\",$html)",$(".item:not(.inited)",$html))
return $(".item:not(.inited)", $html).each(function() {
var $slider, $t, $wrap, slider_height;
$t = $(this);
$t.addClass('inited');
// console.log('$t.data(\'init_slider\')',$t.data('init_slider'))
if ($t.data('init_slider') === null || $t.data('init_slider') === void 0) {
$t.data('init_slider', true);
$wrap = $t.closest(".item_slide");
$slider = $t.closest('.item_slider');
slider_height = $slider.height();
return $t.hover(function() {
var $add, $bg, $ya, addh, addm, h;
console.log("hover");
$bg = $(".bg", $t);
$add = $(".text_add", $t);
$ya = $(".cont .ya_split", $t);
if ($ya.length > 0) {
$add.parent().css('margin-top', '-' + ($ya.height() + 10) + 'px');
}
//$add.show()
// h = 'calc(100% + var(--height-counter) + var(--height-buttons) + var(--m) * 2 + '+$add.height()+'px)'
//console.log('$add.height()',$add.height())
addh = $add.height();
if (addh === void 0) {
addh = 0;
} else {
addh += parseInt($add.parent().css('margin-top'));
}
addm = $(".flower_txt", $t).length > 0;
h = 'calc(100% + var(--height-counter) + var(--height-buttons) + var(--m) ' + (addm ? ' * 2' : '') + ' + ' + addh + 'px)';
//if($t.closest('.item_slider').length > 0)
// #h = 'calc(100% + var(--m) * 2 + '+$add.height()+'px)'
// h = 'calc(100% + var(--m) + '+$add.height()+'px)'
// h = 'calc(100% + var(--m) * 2)'
//console.log(h)
$bg.css('height', h);
return setTimeout(function() {
var mb;
mb = $wrap.outerHeight() - $bg.outerHeight();
return $(".owl-stage-outer", $slider).css({
'height': $bg.outerHeight(),
'margin-bottom': mb
});
}, 1);
}).mouseleave(function() {
return setTimeout(function() {
return $(".owl-stage-outer", $slider).css({
'height': $wrap.outerHeight(),
'margin-bottom': 0
});
}, 1);
});
}
});
}
},
//console.log('leave')
//$t = $(@)
//$add = $(".text_add",$t)
//$add.hide()
initItemSlider: function($html) {
return $('.item_slider', $html).each(function() {
var $t, count, only2;
$t = $(this);
count = $(".item_slide", $t).length;
only2 = $t.hasClass('only2');
if ($t.hasClass('inited')) {
return null;
}
$t.addClass('inited');
$t.owlCarousel({
loop: count >= 3,
nav: true,
dots: false,
autoplay: false,
smartSpeed: 1000,
//margin : 48
//margin: 48
autoHeight: true,
lazyLoad: true,
animateOut: 'fadeOut',
//navText: ['
','
']
navText: ['', ''],
responsive: {
0: {
items: 2,
//margin : 24
margin: 0
},
768: {
items: 2
},
//margin : 48
//margin : 12
1025: {
items: only2 ? 2 : 4
}
}
});
//margin: 48
//margin: 12
$t.on('load.owl.lazy', function(x) {
return console.log('load.owl.lazy', $t, x);
});
$t.on('changed.owl.carousel', function() {
return console.log('changed.owl.carousel', $t);
});
$t.mousemove(function(e) {
var a;
a = e.originalEvent.target.closest('.item');
return $(this).toggleClass('hover', a !== null);
});
$t.mouseleave(function(e) {
return $(this).removeClass('hover');
});
return A.P.initItem($html);
});
},
initNewsCarousel: function($html = A.P.body) {
var $x, now;
$x = $(".news_carousel ", $html);
if ($x.length === 0) {
return null;
}
now = $(".news_carousel .center .slide", $html).attr('data-index');
if (!now) {
now = 0;
}
console.log('now ', now);
$(".news_carousel", $html).trigger('destroy.owl.carousel');
$(".news_carousel", $html).owlCarousel({
loop: true,
nav: true,
startPosition: now,
dots: false,
autoplay: false,
// autoHeight: true
navText: ["", ''],
autoWidth: true,
animateOut: 'fadeOut',
lazyLoad: true,
center: true,
mouseDrag: false,
margin: 12,
items: 7,
navSpeed: 350
});
$(".news_carousel", $html).on('changed.owl.carousel', function() {
return $(".news_carousel .center .news").removeClass('first');
});
$(".news_carousel", $html).on('translate.owl.carousel', function(e) {
var h1;
$(".news_carousel .prev", $html).removeClass('prev');
$(".news_carousel .next", $html).removeClass('next');
h1 = $(".news_carousel .center .img").height() + 32;
return setTimeout(function() {
var $c, h2;
$c = $(".news_carousel .center");
h2 = $(".cont", $c).height();
if ($c != null) {
$c.prev().addClass('prev');
$c.next().addClass('next');
//$(".news_carousel",$html).height($c.height())
return $(".news_carousel", $html).animate({
height: h1 + h2
}, 350);
}
}, 1);
});
$(".news_carousel", $html).on('translated.owl.carousel', function(e) {
var $c;
$(".news_carousel .prev", $html).removeClass('prev');
$(".news_carousel .next", $html).removeClass('next');
$c = $(".news_carousel .center");
$c.prev().addClass('prev');
$c.next().addClass('next');
//$(".news_carousel",$html).height($c.height())
return $(".news_carousel", $html).animate({
height: $c.height()
}, 350);
});
return setTimeout(function() {
return $(".news_carousel", $html).trigger('translated.owl.carousel');
}, 350);
},
/*
$('.news_carousel',$html).on 'click', '.slide', (e)->
console.log('????')
e.preventDefault()
e.stopPropagation()
*/
initMini: function($html = A.P.body) {
var $c, $order_map, $owlDates, $owlSubcategories;
console.log('initMini', $html);
$.fn.LOG('add', 'start');
if (($c = $('#applink', $html)).length > 0) {
window.location.href = $c.attr('data-link');
}
$.fn.TOP('init', A.P.html);
A.P.initPreventLink($html);
$.fn.LOG('add', 'preventLink');
$.fn.ROISTAT('init', $html);
$.fn.LOG('add', 'SIDEBAR');
$.fn.SIDEBAR('init', $html);
$.fn.LOG('add', 'SIDEBAR');
$.fn.SHOP('init', $html);
$.fn.LOG('add', 'SHOP');
//$.fn.SCHOOL('init',$html)
$.fn.YAPAY('init', $html);
$.fn.LOG('add', 'YAPAY');
$.fn.MENU('init', $html);
$.fn.LOG('add', 'MENU');
$.fn.SEARCH('init', $html);
$.fn.LOG('add', 'SEARCH');
$.fn.DELIVERY_ADDRESS('init', $html);
$.fn.LOG('add', 'DELIVERY_ADDRESS');
//$.fn.YANDEX('init',$html)
$.fn.CART('init', $html);
$.fn.LOG('add', 'CART');
$.fn.CONFIRM('init', $html);
$.fn.CONFIRM2('init', $html);
$.fn.LOG('add', 'CONFIRM');
$.fn.FILTER('init', $html);
$.fn.LOG('add', 'FILTER');
$.fn.FILTER2('init', $html);
$.fn.LOG('add', 'FILTER');
$.fn.STORIES('init', $html);
$.fn.LOG('add', 'STORIES');
$.fn.ECOMMERCE('init', $html);
$.fn.LOG('add', 'ECOMMERCE');
$.fn.TINKOFF('initDolyami', $html);
$.fn.LOG('add', 'TINKOFF');
$.fn.COM('init', $html);
$.fn.LOG('add', 'COM');
$.fn.ITEM('init', $html);
$.fn.LOG('add', 'ITEM');
$.fn.MINDBOX('init', $html);
$.fn.PROFILE('init', $html);
$.fn.SALE_NINJA('init', $html);
// $.fn.MAP('init',$html)
$("[data-fancybox]", $html).fancybox({
hash: false,
autoFocus: false,
backFocus: false
});
$(".choose_time", $html).each(function() {
var $hour, $p, set;
$p = $(this);
$p.data('hours', null);
$p.data('minutes', '00');
$hour = $(".hour", $p);
set = function(b, e, except = []) {
var h, i, k, ref, ref1, ref2;
$hour.html('');
if ((b != null) && (e != null)) {
if (e === 0) {
e = 24;
}
e--;
if (e >= b) {
for (i = k = ref = b, ref1 = e; (ref <= ref1 ? k <= ref1 : k >= ref1); i = ref <= ref1 ? ++k : --k) {
console.log('i', i, except, indexOf.call(except, i) >= 0);
if (indexOf.call(except, i) >= 0 || (ref2 = i + '', indexOf.call(except, ref2) >= 0)) {
continue;
}
h = i < 10 ? '0' + i : i;
$hour.append('
' + h + '
');
}
$p.data('hours', b < 10 ? '0' + b : b).trigger('change');
} else {
$p.data('hours', null).trigger('change');
}
} else {
$p.data('hours', null).trigger('change');
}
return setTimeout(function() {
return $hour.scrollTop(0);
}, 10);
};
$p.on('set', function(e, x, y, except) {
return set(x, y, except);
});
$p.on('change', function() {
var hours, id, minutes, value;
value = null;
hours = $p.data('hours');
minutes = $p.data('minutes');
if (hours != null) {
value = hours + ':' + minutes;
}
console.log('updateValue', value, hours, minutes);
id = $p.attr('data-id');
if (id != null) {
return $(`#${id}`).val(value).blur();
}
});
return $(".chooser_time", $p).each(function() {
var $t, diffScroll, initScrollTop, isFirstScroll, offsetScroll, setHours, setMinutes, sy;
$t = $(this);
sy = 0;
initScrollTop = 0;
diffScroll = 0;
isFirstScroll = false;
offsetScroll = 0;
setHours = function(h) {
console.log('setHours', h);
return $p.data('hours', h).trigger('change');
};
setMinutes = function(m) {
console.log('setMinutes', m);
return $p.data('minutes', m).trigger('change');
};
$t.on('touchstart', function(e) {
sy = e.originalEvent.targetTouches[0].pageY;
initScrollTop = $t.scrollTop();
isFirstScroll = false;
return offsetScroll = 0;
});
$t.on('touchmove', function(e) {
diffScroll = sy - e.originalEvent.targetTouches[0].pageY;
if (!isFirstScroll) {
isFirstScroll = true;
offsetScroll = diffScroll;
}
diffScroll -= offsetScroll;
return $t.scrollTop(initScrollTop + diffScroll);
});
return $t.on('touchend', function(e) {
var $value, diff, min, selectedTop, st;
e.preventDefault();
e.originalEvent.stopPropagation();
selectedTop = 72;
st = $t.scrollTop();
min = 10000;
$value = null;
diff = 0;
$(".el", $t).each(function() {
var $el;
$el = $(this);
diff = Math.abs(selectedTop - $el.position().top);
if (diff < min) {
$value = $el;
return min = diff;
}
});
if ($value != null) {
$t.scrollTop($value.position().top + st - selectedTop);
if ($t.hasClass('hour')) {
return setHours($value.data('value'));
} else {
return setMinutes($value.data('value'));
}
}
});
});
});
$(".checkbox_group", $html).each(function() {
var $area, $cont, $t;
$t = $(this);
$cont = $(".checkbox_content", $t);
$area = $(".checkbox_area", $t);
return $("[type=radio]", $t).click(function() {
var area;
area = $(this).attr('data-area');
$cont.slideUp(150);
$area.removeClass('selected');
$(`.checkbox_area[data-area='${area}']`, $t).addClass('selected');
return $(`.checkbox_content[data-area='${area}']`, $t).slideDown(150);
});
});
if ($(window).width() < 340) {
$("yandex-pay-badge", $html).attr('size', 'm');
}
$.fn.LOG('add', 'yandex-pay-badge');
$(".number_placeholder", $html).each(function() {
var $t;
$t = $(this);
$t.attr('data-placeholder', $t.attr('placeholder'));
$t.focus(function() {
return $t.attr('placeholder', '10');
});
return $t.blur(function() {
return $t.attr('placeholder', $t.attr('data-placeholder'));
});
});
$.fn.LOG('add', 'number_placeholder');
A.P.initItem($html);
$.fn.LOG('add', 'initItem');
A.W.initSBP($html);
$.fn.LOG('add', 'initSBP');
// uLogin?.init();
if (A.isMobile()) {
$('.owl-lazy[data-src-mobile]', $html).each(function() {
console.log('??asdasd a');
return $(this).attr('data-src', $(this).attr('data-src-mobile'));
});
}
$order_map = $("#order_map", $html);
if ($order_map.length > 0) {
$.fn.MAP('init', 'order_map', function() {
var coord;
coord = JSON.parse($order_map.attr('data-address-coord'));
return $.fn.MAP('makePoint', 'order_map', coord);
});
}
$(".tab_titles", $html).each(function() {
var $content, $title;
$title = $(".tab_title");
$content = $(".tab_content");
$title.click(function() {
var $t, index;
$t = $(this);
index = $t.index();
$title.removeClass('selected');
$t.addClass('selected');
$content.hide();
return $($content[index]).show();
});
return $($title[0]).click();
});
if (!A.isPad()) {
$("#popular_toggler", $html).each(function() {
var $buttons, $catalog, $el, $t;
$t = $(this);
$el = $(".el", $t);
$catalog = $(".popular_catalog", $html);
$buttons = $("#popular_buttons .h_button", $html);
$el.click(function() {
var index;
$el.removeClass('selected');
$(this).addClass('selected');
index = $(this).index();
$catalog.hide();
$buttons.hide();
$($catalog[index]).show();
return $($buttons[index]).show();
});
return $(".el.selected", $t).click();
});
}
$.fn.CATALOG('summer_week');
$("#column_toggler", $html).each(function() {
var $el, $t, index;
$t = $(this);
$el = $(".el", $t);
$el.click(function() {
var $e;
$e = $(this);
$el.removeClass('selected');
$e.addClass('selected');
$(".catalog").removeClass('type0 type1');
$(".catalog").addClass('type' + $e.index());
A.setCookie('catalog', $e.index());
return $.fn.CATALOG('summer_week');
});
index = A.getCookie('catalog');
if (index === void 0) {
index = 0;
}
return $($el[index]).click();
});
$(".choose_city", $html).click(function() {
return $(this).toggleClass('open');
});
$(".custom_auth .el.ya:visible", $html).each(function() {
return $.fn.YANDEX('oauth');
});
$(".toggler_content .toggle_title", $html).click(function() {
$(this).parent().toggleClass('open');
return $(this).next().slideToggle(300);
});
$(".vacancy_title", $html).click(function(e) {
e.preventDefault();
e.stopPropagation();
$(this).parent().toggleClass('open');
return $(this).next().slideToggle(300);
});
$(".owl-carousel img", $html).addClass('owl-lazy');
$(".item", $html).each(function() {
var $buy, $fast, $t, $vars;
$t = $(this);
$vars = $(".variant", $t);
$buy = $(".button_buy", $t);
$fast = $(".button_fast", $t);
$vars.click(function() {
var $v, data, id;
$vars.removeClass('selected');
$v = $(this);
$v.addClass('selected');
id = $v.attr('data-id');
$buy.attr('onclick', "$.fn.SHOP('buy'," + id + ")");
$fast.attr('onclick', "$.fn.SHOP('fast'," + id + ")");
data = JSON.parse($v.attr('data-variant'));
console.log('data', data);
$(".variant_price", $t).html(data.f_price);
$(".price_old", $t).html(data.f_old);
return $(".variant_link", $t).attr('href', data.link);
});
return $($vars[0]).click();
});
$(".stars", $html).each(function() {
var $stars, $t;
$t = $(this);
$stars = $(".star", $t);
return $stars.on('mouseover', function() {
var index;
$stars.removeClass('selected');
index = $(this).index();
return $stars.each(function() {
if ($(this).index() <= index) {
return $(this).addClass('selected');
}
});
}).on('mouseout', function() {
var index;
$stars.removeClass('selected');
index = $t.attr('data-value');
return $stars.each(function() {
if ($(this).index() <= (index - 1)) {
return $(this).addClass('selected');
}
});
}).on('click', function() {
return $t.attr('data-value', $(this).index() + 1);
});
});
if ($("#addresses", $html).length > 0) {
$.fn.ADDRESS('reload');
}
if ($("#dates", $html).length > 0) {
$.fn.DATES('reload');
}
if (($c = $("#init_confirm", $html)).length > 0) {
console.log('init_confirm', parseInt($c.attr('data-auth')), $c);
$.fn.SHOP('initConfirm', parseInt($c.attr('data-auth')) === 1);
}
// $.fn.SHOP(\'initConfirm\','.(boolval(IF_AUTH)?'true':'false').')
$(".i", $html).keyup(function() {
return $(".res_submit").hide();
});
$(".light_blue_wrap p", $html).each(function() {
var $p;
$p = $(this);
return $p.html('
' + $p.html() + '');
});
$(".favorite_toggler .el", $html).click(function() {
var $t;
$(".favorite_toggler .el", $html).removeClass('selected');
$t = $(this);
$t.addClass('selected');
$(".favorite_wrap", $html).addClass('dn-mob');
return $(`.favorite_wrap:eq(${$t.index()})`, $html).removeClass('dn-mob');
});
if (!A.isMobile()) {
$("#item .tooltip", $html).on('mouseenter', function() {
var $cont, $p, $t, b1, b2, diff, id, style;
$t = $(this);
$p = $t.parent();
$cont = $(".tooltip_content", $t);
b1 = $cont[0].getBoundingClientRect();
b2 = $p[0].getBoundingClientRect();
if (b1.x < b2.x) {
diff = b2.x - b1.x;
$cont.css('transform', 'translateX(' + diff + 'px)');
id = "tooltip" + Date.now();
$cont.attr('id', id);
style = $('');
console.log(style);
return $cont.append(style);
}
});
}
$(".tooltip", $html).mouseover(function(e) {
var $cont, $t, b1, b2, x, y;
if (A.isMobile()) {
return $cont.css('transform', 'translate(0px,0px)');
} else {
//$(@).closest('.b').addClass('z_max2')
console.log('e', e);
$t = $(this);
$cont = $(".tooltip_content", $t);
b1 = this.getBoundingClientRect();
b2 = $cont[0].getBoundingClientRect();
x = b1.x - b2.width / 2;
y = b1.y - b2.height;
if ($t.attr('data-horizontal') === 'right') {
x = b1.right - b2.width;
}
if ($t.attr('data-vertical') === 'bottom') {
y = b1.bottom;
}
console.log(b1, b2, x, y);
return $cont.css('transform', 'translate(' + x + 'px,' + y + 'px)');
}
}).mouseout(function() {});
//$(@).closest('.b').removeClass('z_max2')
$(".toggler_footer", $html).click(function() {
$(this).toggleClass('open');
$(".toggle_footer").toggleClass('hide');
$(".link_return").toggle();
$(".link_instruktsiya_svezhesti").toggle();
$(".link_vacancies").toggle();
$(".link_legal_information").toggle();
$(".link_plantscare").toggle();
return $("#d_footer").toggleClass("open");
});
$.fn.LOG('add', 'half');
$(".text,.h1,.h2,.h3,.h4,.h5,.h4_2", $html).each(function() {
var $t, a, reg;
$t = $(this);
a = ['в', 'без', 'до', 'из', 'к', 'на', 'по', 'о', 'от', 'перед', 'при', 'через', 'с', 'у', 'за', 'над', 'об', 'под', 'про', 'для', 'но', 'и', 'или'];
reg = new RegExp(" (" + a.join("|") + ") ", 'gi');
return $t.html($t.html().replace(reg, " $1 "));
});
$.fn.LOG('add', 'NBSP');
// $(".dadata_wrap:not(.yandex_search) input",$html).keyup(A.P.dadataSearch).on('paste',A.P.dadataSearch)
$(".dadata_wrap.yandex_search input", $html).keyup(A.P.yandexSearch).on('paste', A.P.yandexSearch);
$(".dadata_wrap.dadata_inn input", $html).keyup(A.P.dadataInn).on('paste', A.P.dadataInn);
$(".dadata_wrap.dadata_bank input", $html).keyup(A.P.dadataBank).on('paste', A.P.dadataBank);
$('[type="file"]', $html).change(function() {
var $t;
$t = $(this);
console.log(this.files[0]);
if (this.files.length > 0) {
$t.next().addClass('dn');
$t.next().next().removeClass('dn').text("Открепить файл: " + this.files[0].name);
return $t.next().next().next().removeClass('dn');
}
});
if (A.isPad()) {
$(".main_categories .category:eq(3)").insertBefore($(".main_categories .category:eq(2)"));
}
setTimeout(function() {
var $el, offset;
$el = $("#profile_menu .el.selected:eq(0)", $html);
if ($el.length > 0) {
offset = $("#profile_menu .el.selected:eq(0)", $html).offset().left - 25;
return $("#profile_menu", $html).scrollLeft(offset);
}
}, 1);
$.fn.LOG('add', 'half2');
$(".close_search", $html).click(function() {
return $("#b_search_wrap").removeClass('open');
});
$(".open_search", $html).click(function() {
$("#b_search_wrap").addClass('open');
return $("#search").focus();
});
$('#search', $html).keyup(function() {
var $res, v;
v = $.trim($(this).val());
$res = $("#search_res", $html);
$res.html('
Загрузка...
');
if (v !== '') {
return API('item/search', {
s: v
}, function(data) {
var $data;
$data = $(data);
A.P.initMini($data);
$res.html($data);
return A.tiktok('Search');
});
} else {
return $res.html('');
}
});
$(".subcategories .toggle", $html).click(function(e) {
e.stopPropagation();
e.preventDefault();
return $(this).parent().parent().toggleClass('opened');
});
$(".toggle_filter", $html).click(function() {
return $(".filter_wrap").toggleClass('open');
});
$(".toggle .title", $html).click(function() {
return $(this).parent().toggleClass('open');
});
$(".prop_title", $html).click(function() {
return $(this).parent().toggleClass('open');
});
$(".to_top", $html).click(function() {
return A.P.scrollToAnimate(0);
});
$(".tab_wrap", $html).each(function() {
var $contents, $t, $tab;
$t = $(this);
$contents = $(".tab_content", $t);
$contents.hide();
$tab = $(".tab", $t);
$tab.click(function() {
var $tt, index;
//console.log 'click'
$tab.removeClass('selected');
($tt = $(this)).addClass('selected');
index = $tt.index();
$contents.hide();
return $($contents[index]).show();
});
return $(".tab:eq(0)", $t).click();
});
$("._ps", $html).perfectScrollbar({
suppressScrollY: false
});
$(".f-price-box", $html).each(function() {
var $bar, $max, $min, $p, $p1, $p2, blur, diff, getMax, getMaxPercent, getMin, getMinPercent, getMousePercent, getRect, getValueByPercent, max, min, moveMax, moveMin, setMax, setMin, startMoveMax, startMoveMin, stopMax, stopMin, timeout, touchMoveMax, touchMoveMin;
$p = $(this);
min = parseFloat($p.attr('data-min'));
max = parseFloat($p.attr('data-max'));
$bar = $(".bar", $p);
diff = max - min;
$p1 = $(".fpc1", $p);
$p2 = $(".fpc2", $p);
getRect = function() {
return $(".filter-price", $p)[0].getBoundingClientRect();
};
getMousePercent = function(x) {
var rect;
rect = getRect();
return Math.max(0, Math.min(100, (x - rect.x) / rect.width * 100));
};
setMax = function() {
var p, page, url;
url = new URL(window.location.href);
url.searchParams.delete('max');
url.searchParams.set('max', getMax());
p = H.parse(url.pathname);
page = parseInt(p[p.length - 1]);
if (!isNaN(page)) {
delete p[p.length - 1];
}
return url.pathname = '/' + p.join("/");
};
// H.go( url.pathname + url.search )
setMin = function() {
var p, page, url;
url = new URL(window.location.href);
url.searchParams.delete('min');
url.searchParams.set('min', getMin());
p = H.parse(url.pathname);
page = parseInt(p[p.length - 1]);
if (!isNaN(page)) {
delete p[p.length - 1];
}
return url.pathname = '/' + p.join("/");
};
// H.go( url.pathname + url.search )
getValueByPercent = function(x) {
return ((diff * x / 100) + min).toFixed(0);
};
moveMax = function(e) {
var minp, p;
p = getMousePercent(e.clientX);
p = Math.max(p, minp = getMinPercent());
$max.val(getValueByPercent(p));
return $bar.css({
width: (p - minp) + '%'
});
};
touchMoveMax = function(e) {
var minp, p;
p = getMousePercent(e.touches[0].clientX);
p = Math.max(p, minp = getMinPercent());
$max.val(getValueByPercent(p));
return $bar.css({
width: (p - minp) + '%'
});
};
stopMax = function() {
$(document).off('mousemove', moveMax);
$(document).off('mouseup', stopMax);
$(document).off('touchmove', touchMoveMax);
$(document).off('touchend', stopMax);
return setMax();
};
startMoveMax = function() {
var rect;
rect = $(".filter-price", $p)[0].getBoundingClientRect();
$(document).on('mousemove', moveMax);
$(document).on('mouseup', stopMax);
$(document).on('touchmove', touchMoveMax);
return $(document).on('touchend', stopMax);
};
moveMin = function(e) {
var maxp, p;
p = getMousePercent(e.clientX);
p = Math.min(p, maxp = getMaxPercent());
$min.val(getValueByPercent(p));
return $bar.css({
left: p + '%',
width: (maxp - p) + '%'
});
};
touchMoveMin = function(e) {
var maxp, p;
p = getMousePercent(e.touches[0].clientX);
p = Math.min(p, maxp = getMaxPercent());
$min.val(getValueByPercent(p));
return $bar.css({
left: p + '%',
width: (maxp - p) + '%'
});
};
stopMin = function() {
$(document).off('mousemove', moveMin);
$(document).off('mouseup', stopMin);
$(document).off('touchmove', touchMoveMin);
$(document).off('touchend', stopMin);
return setMin();
};
startMoveMin = function() {
var rect;
rect = $(".filter-price", $p)[0].getBoundingClientRect();
$(document).on('mousemove', moveMin);
$(document).on('mouseup', stopMin);
$(document).on('touchmove', touchMoveMin);
return $(document).on('touchend', stopMin);
};
$p1.on('mousedown', startMoveMin);
$p2.on('mousedown', startMoveMax);
$p1.on('touchstart', startMoveMin);
$p2.on('touchstart', startMoveMax);
blur = function() {
var _max, _min, left, width;
_min = getMin();
_max = getMax();
if (_min > _max || _max < _min) {
$max.val(_min);
}
left = getMinPercent();
width = getMaxPercent() - left;
return $bar.css({
left: left + '%',
width: width + '%'
});
};
timeout = null;
$min = $("input:eq(0)", $p).blur(function() {
blur();
setMin().keyup(function() {});
clearTimeout(timeout);
return setTimeout(setMin, 750);
});
$max = $("input:eq(1)", $p).blur(function() {
blur();
setMax().keyup(function() {});
clearTimeout(timeout);
return setTimeout(setMax, 750);
});
getMax = function() {
var v;
v = parseFloat($max.val());
if (isNaN(v) || v > max) {
v = max;
}
$max.val(v);
return v;
};
getMin = function() {
var v;
v = parseFloat($min.val());
if (isNaN(v) || v <= min) {
v = min;
}
$min.val(v);
return v;
};
getMinPercent = function() {
var v;
v = getMin();
return (v - min) / diff * 100;
};
getMaxPercent = function() {
var v;
v = getMax();
return (v - min) / diff * 100;
};
blur();
return $p.on('destroyed', function() {
return getMin = getMinPercent = getMaxPercent = $max = $min = $bar = null;
});
});
$(".counter", $html).each(function() {
var $i, $minus, $plus, $t, getVal, max, min, setVal, step;
$t = $(this);
$plus = $(".plus,.up", $t);
$minus = $(".minus,.down", $t);
step = parseInt($t.attr('data-step'));
min = parseInt($t.attr('data-min'));
max = parseInt($t.attr('data-max'));
if (isNaN(step)) {
step = 1;
}
if (isNaN(min)) {
min = 1;
}
$i = $("input", $t);
getVal = function() {
return parseInt($i.val());
};
$plus.click(function() {
return setVal(getVal() + step);
});
$minus.click(function() {
return setVal(getVal() - step);
});
$i.blur(function() {
return setVal(getVal());
});
return setVal = function(x) {
x = parseInt(x);
if (isNaN(x)) {
x = 1;
}
if (x < min || x <= 0) {
$t.trigger('counter.min');
}
if (x <= 0) {
x = 1;
}
if (x <= min) {
x = min;
}
if (!isNaN(max)) {
if (x >= max) {
x = max;
}
}
return $i.val(x).change();
};
});
/*
$(".main_images_scroller_wrap",$html).on 'wheel',(e)->
$e = $(".item_wrap .main_images .img:eq(0)",$html)
h = $e.height()
o = e.originalEvent
console.log('wheel',e)
isLast = false
mt = parseInt($(".main_images").css("margin-top"))
console.log('mt',mt,o.deltaY)
mt+=-o.deltaY
$c = $(".main_images")
hh = $c.height()
max = -(hh-h)
if mt>0
mt = 0
isLast = true
if mt<=max
mt = max
isLast = true
$(".main_images").css({marginTop:mt})
if !isLast
e.preventDefault()
*/
$(".item_wrap .imgs .img", $html).click(function() {
/*
$e = $(".item_wrap .main_images .img:eq(#{index})",$html)
h = $e.height()
mb = parseFloat($e.css('margin-bottom'))
h = mb+h
$(".main_images").css({marginTop:-h*index})
*/
var $e, $t, index;
$t = $(this);
$(".item_wrap .imgs .img", $html).removeClass('selected');
$t.addClass('selected');
index = $t.index();
$e = $(`.item_wrap .main_images .img_wrap:eq(${index})`, $html);
return A.P.scrollToAnimate($e.offset().top);
});
$("#country", $html).on('select.change', function() {
var val;
val = parseInt($(this).data('value'));
return $("#city").parent().toggle(val === 1);
});
$(".select", $html).each(function() {
return A.P.initSelect($(this));
});
$(".select", $html).on('select.change', function() {
var $p, $t;
console.log('select.change', this);
$t = $(this);
$t.removeClass('error');
//$t.closest('.i_wrap').removeClass('error')
$p = $(this).closest('.i_wrap');
$p.removeClass('error');
return $(".error_text", $p).remove();
});
$(".i", $html).keyup(function() {
var $p;
$p = $(this).closest('.i_wrap');
$p.removeClass('error');
return $(".error_text", $p).remove();
});
if ($('#main_items:visible', $html).length > 0) {
setTimeout(function() {
return API('item/get/main', {}, function(data) {
var $data;
$data = $(data);
$('#main_items:visible', $html).replaceWith($data);
if (A.isMobile()) {
$("[data-src]", $data).each(function() {
return $(this).attr('data-src', $(this).attr('data-src-mobile'));
});
}
//A.initMini($data)
return A.P.initItemSlider($data);
});
}, 5000);
}
if ($('#main_faq:visible', $html).length > 0) {
setTimeout(function() {
return API('faq/get/main', {}, function(data) {
var $data;
$data = $(data);
$('#main_faq:visible', $html).replaceWith($data);
return A.P.initMini($data);
});
}, 10000);
}
A.P.initNewsCarousel($html);
$owlDates = $('.delivery_dates', $html);
$owlDates.owlCarousel({
loop: false,
nav: true,
mouseDrag: false,
dots: false,
autoplay: false,
lazyLoad: true,
autoWidth: true,
margin: 4,
slideBy: 4,
navText: ['', '']
});
$owlDates.on('mousewheel', '.owl-stage', function(e) {
return e.preventDefault();
});
$owlSubcategories = $('#subcategories.owl-carousel', $html);
$owlSubcategories.owlCarousel({
loop: false,
nav: false,
mouseDrag: true,
dots: false,
autoplay: false,
autoWidth: true,
margin: 4,
slideBy: 1,
navText: ['', '']
});
$(".choose_city_mobile", $html).each(function() {
var $t, $value;
$t = $(this);
$value = $(".value", $t);
return $value.click(function() {
return $t.toggleClass('open');
});
});
if ($('#mobile_slider:visible', $html).length > 0) {
$('.main_slider_mob', $html).owlCarousel({
loop: true,
nav: false,
dots: true,
autoplay: true,
smartSpeed: 1000,
autoplayTimeout: 10000,
autoHeight: true,
animateOut: 'fadeOut',
lazyLoad: true,
//navText: ["
","
"]
responsive: {
0: {
items: 1
},
521: {
items: 1
},
1000: {
items: 1
}
}
});
}
if ($('#b_slider .d:visible', $html).length > 0) {
if (A.isMobile()) {
$("#b_slider .dn-mob").remove();
}
$('.main_slider', $html).owlCarousel({
loop: true,
nav: true,
dots: true,
autoplay: true,
smartSpeed: 1000,
autoplayTimeout: 10000,
autoHeight: true,
animateOut: 'fadeOut',
lazyLoad: true,
navText: ["", ""],
responsive: {
0: {
items: 1
},
521: {
items: 1
},
1000: {
items: 1
}
}
});
}
/*
$('.item_images_mobile',$html).owlCarousel
loop: true
nav: false
dots: true
items : 1
autoplay: true
smartSpeed: 1000
autoplayTimeout: 10000
autoHeight: true
animateOut: 'fadeOut'
lazyLoad:true
#navText: ["
","
"]
*/
$('.news_gallery', $html).each(function() {
var $t, by2;
$t = $(this);
console.log('???asdasd', $t.hasClass('by2') ? 2 : 1);
by2 = $t.hasClass('by2');
return $t.owlCarousel({
loop: true,
lazyLoad: true,
nav: true,
dots: true,
items: by2 ? 2 : 1,
margin: by2 ? 20 : 0,
slideBy: by2 ? 2 : 1,
autoplay: false,
smartSpeed: 1000,
autoplayTimeout: 10000,
autoHeight: true,
animateOut: 'fadeOut',
//navText: ["
","
"]
//navText: ['
','
']
navText: ['', '']
});
});
//A.P.initItemSlider($html)
$('.school_soon', $html).owlCarousel({
loop: true,
nav: true,
dots: false,
autoplay: false,
smartSpeed: 1000,
autoHeight: true,
animateOut: 'fadeOut',
//navText: ['
','
']
navText: ['', ''],
responsive: {
0: {
items: 1,
margin: 0
},
768: {
items: 2,
margin: 48
},
1025: {
items: 3,
margin: 48
}
}
});
$('.school_materials', $html).owlCarousel({
loop: false,
nav: true,
dots: false,
autoplay: false,
smartSpeed: 1000,
autoHeight: true,
animateOut: 'fadeOut',
//navText: ['
','
']
navText: ['', ''],
responsive: {
0: {
items: 1,
margin: 0
},
768: {
items: 2,
margin: 0
},
1025: {
items: 2,
margin: 0
}
}
});
$('.faq_list', $html).owlCarousel({
loop: true,
nav: true,
dots: false,
autoplay: false,
smartSpeed: 1000,
autoHeight: true,
animateOut: 'fadeOut',
//navText: ['
','
']
navText: ['', ''],
responsive: {
0: {
items: 1,
margin: 0
},
768: {
items: 2,
margin: 8
},
1025: {
items: 4,
margin: 8
}
}
});
$('.items_slider', $html).owlCarousel({
loop: true,
nav: true,
dots: false,
autoplay: false,
smartSpeed: 1000,
autoHeight: true,
animateOut: 'fadeOut',
//navText: ['
','
']
lazyLoad: true,
navText: ['', ''],
responsive: {
0: {
items: 2,
margin: 0
},
768: {
items: 2,
margin: 8
},
1025: {
items: 4,
margin: 8
}
}
});
$('.owl-carousel.events', $html).owlCarousel({
loop: false,
nav: true,
dots: false,
autoplay: false,
smartSpeed: 1000,
//margin : 48
autoHeight: true,
autoWidth: true,
animateOut: 'fadeOut',
//navText: ['
','
']
navText: ['', '']
});
//items: 1
$('.owl-carousel.variants', $html).owlCarousel({
loop: true,
nav: true,
dots: false,
autoplay: false,
smartSpeed: 1000,
//navText: ['
','
']
navText: ['', ''],
autoHeight: true,
animateOut: 'fadeOut',
items: 1
});
$('.owl-carousel.personal_slider', $html).owlCarousel({
loop: false,
nav: false,
dots: true,
items: 1,
autoplay: false,
animateOut: 'fadeOut',
lazyLoad: true,
navSpeed: 150
});
$('.contacts_slider', $html).owlCarousel({
loop: true,
nav: true,
dots: false,
autoplay: false,
smartSpeed: 1000,
//margin : 48
autoHeight: true,
animateOut: 'fadeOut',
//navText: ['
','
']
navText: ['', ''],
items: 1
});
$('.loyalty_list', $html).owlCarousel({
loop: true,
nav: false,
dots: false,
autoplay: false,
smartSpeed: 1000,
margin: 8,
autoHeight: true,
animateOut: 'fadeOut',
//navText: ['
','
']
navText: ['', ''],
responsive: {
0: {
items: 1
},
768: {
items: 2
},
1024: {
items: 2
},
1328: {
items: 3
}
}
});
$(".owl-carousel img", $html).each(function() {
return this.addEventListener('load', A.P.onLoadCarouselImage);
});
//$(@).on 'load',A.P.onLoadCarouselImage
/*
$(".owl-carousel").on 'changed.owl.carousel', ->
console.log('changed')
A.P.checkLazy()
$(".owl-carousel").on 'change.owl.carousel', ->
console.log('change')
A.P.checkLazy()
*/
$(".item_info_content", $html).on('touchmove', function(e) {
var $wrap, bp, delta, next, start, wh, wrap;
wh = window.innerHeight;
$wrap = $(".item_wrap");
wrap = $wrap[0];
bp = wrap.getBoundingClientRect();
//console.log('touchmove',bp.top > 0 , bp.bottom - wh < 0)
if (bp.top > 0 || bp.bottom - wh < 0 && false) {
} else {
//start = $(@).data('pos')
start = A.P.startScroll;
delta = start - e.touches[0].screenY;
next = this.scrollTop + delta;
A.P.startScroll = e.touches[0].screenY;
//console.log('next',next,delta)
//@.scrollTo(0,@.scrollTop+delta)
$(this).scrollTop(next);
if (next <= 0 || next + this.clientHeight > this.scrollHeight) {
} else {
//console.log('STOP!!!!')
e.stopPropagation();
e.preventDefault();
e.originalEvent.stopPropagation();
return e.originalEvent.preventDefault();
}
}
});
//A.initGoogleCaptcha()
return $.fn.LOG('add', 'end');
},
onLoadCarouselImage: function(e) {
var $owl, $t;
//console.log('onLoadCarouselImage')
e.target.removeEventListener('load', A.P.onLoadCarouselImage);
$t = $(e.target);
if ($t.closest('.item_slide').length === 0) {
$owl = $t.closest('.owl-carousel');
return $owl.trigger('refresh.owl.carousel');
} else {
//console.log('loaded',$owl)
return A.P.initItem(A.P.body);
}
},
googleCaptcha: function(token) {
return $(".reg_button").prop('disabled', false);
},
//A.C._google_captcha = token ;
initForm: function($html) {
return $("form [type=submit]", $html).click(function() {
var $f, $t;
$f = ($t = $(this)).closest('form');
return $f.data('submit_clicked', $t);
});
},
initPreventLink: function(x) {
return $("a:not(.prevented)", $(x)).addClass('prevented').click(A.P.preventALink);
},
preventALink: function(e) {
var $t, href;
href = ($t = $(this)).attr('href');
if ($t.hasClass('propagation')) {
e.preventDefault();
return e.stopPropagation();
} else if (href === "" || href === "#") {
return e.preventDefault();
//e.stopPropagation()
} else if (href !== void 0) {
if ($t.hasClass('_to_card')) {
e.preventDefault();
e.stopPropagation();
return $.fn.CARD('openNew', {
api: $t.attr('data-module'),
id: $t.attr('data-id')
});
} else if (href.substr(0, 1) === '/') {
e.preventDefault();
e.stopPropagation();
return H.go($(this).attr('href'));
}
}
}
};
//-----------------------------------------------
// A.W - Работа со всплывающими окнами
//-----------------------------------------------
A.W = {
back: null,
w: null,
i: null,
init: function() {
A.W.back = $("#wback");
if (A.W.back.length > 0) {
A.W.w = $("#window");
return A.W.i = $("#w_inner");
} else {
return delete A.W;
}
},
startLoad: function() {
return A.W.i.addClass("load").html("Загрузка данных");
},
finishLoad: function(data) {
var $data;
$data = $(data);
A.W.i.removeClass("load").html($data);
return A.P.initMini($data);
},
//$(".window_inner input[name=phone]").mask("+7 (999) 999-99-99");
beige: function() {
return $("#window").addClass('beige');
},
setHtml: function(data) {
return A.W.finishLoad(data);
},
scrollPosition: 0,
unblockScroll: function() {
var body;
body = document.body;
body.style.removeProperty('overflow');
body.style.removeProperty('position');
body.style.removeProperty('top');
body.style.removeProperty('width');
return window.scrollTo(0, A.W.scrollPosition);
},
blockScroll: function() {
var body;
body = document.body;
A.W.scrollPosition = window.pageYOffset;
body.style.overflow = 'hidden';
body.style.position = 'fixed';
body.style.top = '-' + A.W.scrollPosition + 'px';
return body.style.width = '100%';
},
open: function(w) {
A.P.body.css('overflow', 'hidden');
A.W.back.addClass('open');
A.W.w.css({
maxWidth: (w !== void 0 ? w : 800) + "px"
});
return A.W.blockScroll();
},
close: function() {
var base;
A.W.back.removeClass('open');
$("#window").removeClass('beige');
A.P.body.css('overflow', 'auto');
A.W.i.html("");
if (typeof (base = A.W).onClose === "function") {
base.onClose();
}
A.W.unblockScroll();
return $("#window .back").show();
},
openShareItem: function(id) {
A.W.open(400);
A.W.startLoad();
return API('item/get/share', {
id: id,
fid: A.city
}, A.W.setHtml);
},
initSBP: function($data) {
return $("#search_sbp", $data).keyup(function() {
var val;
val = $(this).val().toLowerCase();
if (val !== "") {
$(".sbp").hide();
return $(".sbp").each(function() {
var $t, txt;
$t = $(this);
txt = $t.text();
if (txt.toLowerCase().indexOf(val) >= 0) {
return $t.show();
}
});
} else {
return $(".sbp").show();
}
});
},
openSbp: function(url) {
A.W.open(400);
A.W.hideBack();
A.W.startLoad();
return API('cart/get/sbp', {
url,
ios: A.isIOS() ? 1 : 0
}, function(data) {
var $data;
$data = $(data);
A.W.setHtml($data);
return A.W.initSBP($data);
});
},
openMasterClassBuy: function(id) {
A.W.open(400);
A.W.startLoad();
return API('cart/get/master_class', {
id: id,
fid: A.city,
count: $(`#item_count_${id}`).val()
}, function(data) {
var $data;
$data = $(data);
//A.P.initMini($data)
$("#count_master_class", $data).on('select.change', function() {
var $t, count, i;
$t = $(this);
$(".master_class_name").addClass('dn');
count = parseInt($t.data('value'));
i = 1;
return $(".master_class_name", $data).each(function() {
var $i;
$i = $(this);
$i.toggleClass('dn', i > count);
return i++;
});
}).trigger('select.change');
return A.W.setHtml($data);
});
},
openFastBuy: function(id, category) {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('cart/get/fastbuy2', {
id: id,
category,
fid: A.city
}, function(data) {
var $data;
$data = $(data);
A.P.initMini($data);
A.W.setHtml($data);
//if A.isMobile()
$(".reg_button").prop('disabled', false);
$("#google_captcha").remove();
//else
// A.initGoogleCaptcha()
return A.reach('b_pok_click');
});
},
openCertBuy: function(id) {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('cart/get/certbuy', {
id: id,
price: $(`#item_count_${id}`).val(),
fid: A.city,
is_paper: $("#is_paper").is(":checked") ? 1 : 0
}, function(data) {
var $data;
$data = $(data);
A.P.initMini($data);
return A.W.setHtml($data);
});
},
openAbuy: function(id) {
return $.fn.CART('openCartModal');
},
//A.W.open(600);
//A.W.startLoad()
//API API_THEME+'abuy',{id:id},A.W.setHtml
hideBack: function() {
return $("#window .back").hide();
},
openWantChangeAddress: function(id) {
A.W.open(400);
A.W.startLoad();
A.W.hideBack();
return API('cart/get/change_address', {}, A.W.setHtml);
},
openAuth: function(options = {}) {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('account/get/auth', options, A.W.setHtml);
},
openAuthEmail: function() {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('account/get/authEmail', {}, A.W.setHtml);
},
openRegEmail: function() {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('account/get/regEmail', {}, function(data) {
var $data;
$data = $(data);
A.W.setHtml($data);
return $.fn.REG_EMAIL('init', $data);
});
},
openRemind: function() {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('account/get/remind', {}, A.W.setHtml);
},
openCheckbot: function(data) {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('bot/windowCheckBot', {}, function(data) {
var $data;
$data = $(data);
A.W.setHtml($data);
$(".reg_button", $data).click(function() {
return API('bot/notBot', {}, A.W.close);
});
return typeof grecaptcha !== "undefined" && grecaptcha !== null ? typeof grecaptcha.render === "function" ? grecaptcha.render('google_captcha', {
sitekey: '6LcOV9sUAAAAAGSp6qV1zXUv7CVUBynuZ_tx3nPE',
callback: A.P.googleCaptcha
}) : void 0 : void 0;
});
},
openAddressAuth: function() {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('cart/get/openAddressAuth', {}, A.W.setHtml);
},
openChangedAddress: function() {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
A.W.beige();
return API('cart/get/openChangedAddress', {}, A.W.setHtml);
},
openChooseCity: function() {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('account/get/openChooseCity', {}, A.W.setHtml);
},
openDate: function(id = 0) {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('account/get/date', {id}, A.W.setHtml);
},
openNeedPhone: function() {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('account/get/need_phone', {}, A.W.setHtml);
},
openAddress: function(id = 0) {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('account/get/address', {id}, A.W.setHtml);
},
openChooseOrderPayment: function(id = 0) {
A.W.open(500);
A.W.startLoad();
A.W.hideBack();
return API('order/get/chooseGetPayment', {id}, A.W.setHtml);
}
};
(function($) {
var F;
$.fn.ADDRESS = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.ADDRESS');
}
};
return F = {
init: function() {},
addAddress: function(f) {
var $f, s;
$f = $(f);
s = $f.serializeArray();
API.GET.r('/api/app/addAddress/', s, function(data) {
F.reload();
return A.W.close();
});
return false;
},
editAddress: function(f) {
var $f, s;
$f = $(f);
s = $f.serializeArray();
API.GET.r('/api/app/updateAddress/', s, function(data) {
F.reload();
return A.W.close();
});
return false;
},
save: function() {
var $f, $res, f, s;
f = ($f = $(event.target)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
console.log(s);
if (parseInt(s.id) !== 0) {
API('app/updateAddress', s, function(data) {
return F.reload();
});
} else {
API('app/addAddress', s, function(data) {
return F.reload();
});
}
A.W.close();
return false;
},
open: function(id = 0) {
return A.W.openAddress(id);
},
//$.fn.SIDEBAR('openAddress',id)
confirmDelete: function(id) {
if (confirm("Вы действительно хотите удалить адрес?")) {
return API('app/removeAddress', {
id: id
}, function(data) {
F.reload();
return A.W.close();
});
}
},
initAddress: function(i) {
var $t;
// $.fn.ADDRESS(\'confirmDelete\','+i.id+')
$t = $('
' + i.name + '
' + i.address + '
');
$t.data('info', i);
return $t;
},
reload: function() {
var $t;
($t = $("#addresses")).css({
opacity: 0.5,
'pointer-events': 'none'
});
return API('app/getAddresses', {
dataType: "JSON"
}, function(data) {
var $res, i, j, len;
$res = [];
if (data.length === 0) {
$t.html('У вас пока нет запомненных адресов');
} else {
for (j = 0, len = data.length; j < len; j++) {
i = data[j];
$res.push(F.initAddress(i));
}
}
$t.html($res);
// $t.append('
')
return ($t = $("#addresses")).css({
opacity: 1,
'pointer-events': 'all'
});
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.AI = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.AI');
}
};
return F = {
ws: null,
init: function() {
var ws;
F.$input = $("#ai_ibnput");
F.$list = $("#ai_messages");
F.ws = ws = new WebSocket("ws://127.0.0.1:3011/");
ws.onopen = function() {
console.log("Соединение установлено.");
return F.getSession();
};
return ws.onmessage = function(event) {
var data, e;
try {
data = JSON.parse(event.data);
switch (data['action']) {
case 'message':
F.newMessage(data);
}
} catch (error) {
e = error;
}
console.log("Получены данные " + event.data);
return setInterval(function() {
return F.ws.send(JSON.stringify({
action: "ping"
}));
}, 5000);
};
},
send: function(f) {
var mess;
mess = F.$input.val();
console.log(mess);
F.$input.val('');
F.sendMessage(mess);
return false;
},
newMessage: function(data) {
var $html, $x;
console.log(data);
$html = $(data['html']);
$x = $(".ai_message[data-id='" + data['id'] + "']");
if ($x.length > 0) {
return $x.replaceWith($html);
} else {
return F.$list.append($html);
}
},
getSession: function(x) {
return API('ai/getSession', {
dataType: "JSON"
}, function(data) {
if (data['session']) {
data['action'] = 'setSession';
return F.ws.send(JSON.stringify(data));
}
});
},
sendMessage: function(x) {
var s;
s = {
'message': x,
dataType: 'json'
};
console.log(s);
return API('ai/userMessage', s, function(data) {});
}
};
//if data['session']
// data['action'] = 'setSession'
// F.ws.send(JSON.stringify(data))
})(jQuery);
(function($) {
var F;
$.fn.CALENDAR = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.CALENDAR');
}
};
return F = {
months: ['Январь', 'Февраль', 'Март', 'Аперль', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
daysInMonths: function(d) {
return 33 - new Date(d.getFullYear(), d.getMonth(), 33).getDate();
},
create: function(t, options = {}) {
var $body, $month, $next, $prev, $t, callback, d, deliveryHours, endHour, endTime, maxDeliveryHour, month, now, ref, selected, setMonth, setSelected, today, year;
callback = (ref = options.callback) != null ? ref : null;
$t = $(t);
$prev = $("._prev", $t);
$next = $("._next", $t);
$month = $("._month", $t);
$body = $(".oc-body", $t);
d = new Date();
month = d.getMonth();
year = d.getFullYear();
now = d;
today = new Date(d.getFullYear(), d.getMonth(), d.getDate());
deliveryHours = 2;
endHour = 20;
maxDeliveryHour = endHour - deliveryHours;
endTime = today.getTime() + 60 * 60 * maxDeliveryHour * 1000;
selected = today;
if (now.getTime() > endTime) {
selected = new Date(selected.getTime() + 60 * 60 * 24 * 1000);
}
$prev.click(function() {
var prev;
d = new Date(year, month, 1);
prev = new Date(d.getTime() - 60 * 60 * 24 * 2 * 1000);
return setMonth(prev.getMonth(), prev.getFullYear());
});
$next.click(function() {
var monthDays, next;
d = new Date(year, month, 1);
monthDays = F.daysInMonths(d);
next = new Date(d.getTime() + 60 * 60 * 24 * (monthDays + 10) * 1000);
return setMonth(next.getMonth(), next.getFullYear());
});
setSelected = function() {
var date;
$t = $(this);
date = $t.data('date');
selected = date;
$(".oc-item").removeClass('selected');
$t.addClass('selected');
return typeof callback === "function" ? callback(date) : void 0;
};
setMonth = function(m, y) {
var $d, $week, classes, day, days, endDate, endDay, i, isAvailable, j, k, l, len, len1, monthDays, n, next, nextMonth, nextYear, o, prev, prevDays, prevMonth, prevYear, ref1, ref2, ref3, results, startDay, week, weeks;
month = m;
year = y;
$month.html(F.months[m] + ', ' + y);
d = new Date(y, m, 1);
monthDays = F.daysInMonths(d);
prev = new Date(d.getTime() - 60 * 60 * 24 * 2 * 1000);
next = new Date(d.getTime() + 60 * 60 * 24 * (monthDays + 10) * 1000);
prevDays = F.daysInMonths(prev);
prevMonth = prev.getMonth();
prevYear = prev.getFullYear();
nextMonth = next.getMonth();
nextYear = next.getFullYear();
startDay = d.getDay();
endDate = new Date(y, m, monthDays);
endDay = endDate.getDay();
if (startDay === 0) {
startDay = 7;
}
startDay--;
if (endDay === 0) {
endDay = 7;
}
endDay--;
days = [];
if (startDay > 0) {
for (i = j = 0, ref1 = startDay - 1; (0 <= ref1 ? j <= ref1 : j >= ref1); i = 0 <= ref1 ? ++j : --j) {
days.push(new Date(prevYear, prevMonth, prevDays - (startDay - 1 - i)));
}
}
for (i = k = 1, ref2 = monthDays; (1 <= ref2 ? k <= ref2 : k >= ref2); i = 1 <= ref2 ? ++k : --k) {
days.push(new Date(y, m, i));
}
if (endDay < 6) {
for (i = l = 1, ref3 = 6 - endDay; (1 <= ref3 ? l <= ref3 : l >= ref3); i = 1 <= ref3 ? ++l : --l) {
days.push(new Date(nextYear, nextMonth, i));
}
}
weeks = days.reduce(function(p, c, i, a) {
if (i % 7 === 0) {
p.push([]);
}
p[p.length - 1].push(c);
return p;
}, []);
$body.html('');
results = [];
for (n = 0, len = weeks.length; n < len; n++) {
week = weeks[n];
$week = $('
');
for (o = 0, len1 = week.length; o < len1; o++) {
d = week[o];
isAvailable = d.getMonth() === m && d.getTime() >= today.getTime();
if (d.getTime() === today.getTime()) {
isAvailable = now.getTime() < endTime;
}
day = d.getDay();
classes = ['oc-item'];
if (isAvailable) {
if (day === 0 || day === 6) {
classes.push('oc-weekend');
}
} else {
classes.push('na');
}
if (d.getTime() === selected.getTime()) {
classes.push('selected');
}
$d = $('
' + d.getDate() + '
');
$d.data('date', d);
if (isAvailable) {
$d.click(setSelected);
}
$week.append($d);
}
results.push($body.append($week));
}
return results;
};
setMonth(month, year);
return typeof callback === "function" ? callback(selected) : void 0;
},
init: function(x, options = {}) {
return $(x).each(function() {
return F.create($(this), options);
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.CART = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.CART');
}
};
return F = {
submitAcceptMobile: function() {
return A.W.openNeedPhone();
},
submit: function() {
var $aqua, $pack;
if (A.isAuth()) {
$pack = $('[data-name="pack"] input');
$aqua = $('[data-name="aqua"] input');
A.setCookie('pack', $pack.length && $pack.prop('checked') ? '1' : '0');
A.setCookie('aqua', $aqua.length && $aqua.prop('checked') ? '1' : '0');
return H.go('/confirm/');
} else {
return A.W.openAuth();
}
},
mathTotal: function() {
var total;
total = parseFloat(F.totals.sum);
return $("#total").text(total);
},
updateCartTotal: function() {
return $.fn.SHOP('updateTotals', function(data) {
F.totals = data;
//console.log(data)
$("#button_cart_total").html(data.fsum);
$("#total_text").html(data.text);
return F.mathTotal();
});
},
//$.fn.YAPAY('initCart')
init: function($html) {
var $cart;
$cart = $("#cart_wrap", $html);
if ($cart.length === 0) {
return null;
}
$(".counter", $cart).on('counter.min', function() {
var $citem, id;
$citem = $(this).closest('.cart_item');
id = $citem.attr('data-id');
$(`.cart_item[data-id=${id}]`).remove();
return API('citem/remove', {
id: id
}, function() {
F.updateCartTotal();
if ($(".cart_item", $cart).length === 0) {
return H.reload();
}
});
});
$(".counter input", $cart).change(function() {
var count, id;
count = parseInt($(this).val());
if (isNaN(count)) {
count = 0;
}
if (count > 0) {
id = $(this).attr('data-id');
return API('citem/set', {
id: id,
count: count
}, function() {
return F.updateCartTotal();
});
}
});
return $(".remove", $cart).click(function() {
var id;
id = $(this).attr('data-id');
$(`.cart_item[data-id=${id}]`).remove();
return API('citem/remove', {
id: id
}, function() {
F.updateCartTotal();
if ($(".cart_item", $cart).length === 0) {
return H.reload();
}
});
});
},
toggleCartModalItems: function() {
return $("#cart_modal").toggleClass('open');
},
closeModal: function() {
return $("#cart_modal").removeClass('show');
},
openCartModal: function(cid) {
var $list;
$("#cart_modal").addClass('show');
$list = $(".cart_modal_list");
$list.html('
Загрузка...
');
API('cart/cartModalItems', {
dataType: "JSON",
cid
}, function(data, cd) {
var $data;
console.log(data);
$data = $(data['html']);
A.P.initMini($data);
return $list.replaceWith($data);
});
if (window.location.pathname.indexOf('/cart/') === 0) {
return H.reload();
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.CATALOG = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.CATALOG');
}
};
return F = {
$catalog: null,
eachRow: 4,
summer_week: function() {
var $items, $silk, $summer, $ten, $week, cols, row, silk_index, summer_index, ten_index, week_index;
F.$catalog = $("#main_catalog");
if (F.$catalog.length === 0) {
return null;
}
cols = F.$catalog.css('grid-template-columns').split(" ").length;
$items = $(".item", F.$catalog);
$silk = $("#silk_wrap");
$summer = $("#summer_wrap");
$week = $("#week_wrap");
$ten = $("#ten_wrap");
row = 1;
silk_index = null;
if ($silk.length > 0) {
silk_index = cols * F.eachRow * row - 1;
row++;
}
if ($ten.length > 0) {
ten_index = cols * F.eachRow * row - 1;
row++;
}
summer_index = cols * F.eachRow * row - 1;
row++;
week_index = cols * F.eachRow * row - 1;
row++;
if ($silk.length > 0) {
if ($items[silk_index]) {
$silk.show().insertAfter($($items[silk_index]));
} else {
$silk.hide();
}
}
if ($ten.length > 0) {
if ($items[ten_index]) {
$ten.show().insertAfter($($items[ten_index]));
} else {
$ten.hide();
}
}
if ($items[summer_index]) {
$summer.show().insertAfter($($items[summer_index]));
} else {
$summer.hide();
}
if ($items[week_index]) {
return $week.show().insertAfter($($items[week_index]));
} else {
return $week.hide();
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.COM = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.COM');
}
};
return F = {
isCom: false,
initialize: function() {
return F.isCom = $("body").hasClass('is_com');
},
validatePhone: function() {
var $t, isValidNumber, phone;
$t = $(this);
phone = $t.val();
isValidNumber = numberValidation(phone);
return $t.toggleClass('error', !isValidNumber.valid);
},
init: function($html) {
if (F.isCom) {
$("input.phone", $html).each(function() {
return $(this).attr('data-value', $(this).val());
});
$("input.phone", $html).keyup(F.validatePhone);
$("input.phone", $html).blur(F.validatePhone).change(F.validatePhone).on('paste', F.validatePhone).change();
intlTelInputInit($html[0].querySelectorAll('input.phone'));
return $("input.phone", $html).each(function() {
return $(this).val($(this).attr('data-value'));
});
} else {
$("input.phone", $html).change(A.P.checkPhone).on('paste', A.P.checkPhoneFromPaste);
return $("input.phone:not(.foreign)", $html).mask(A.phone_mask);
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.CONFIRM = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.CONFIRM');
}
};
return F = {
$wrap: null,
$window: null,
$dates: null,
$delivery: null,
date: null,
beautyDate: null,
delivtype_id: 0,
delivery_time: 0,
time: null,
times: null,
except: null,
deliveryPrice: 0,
km: 0,
kmPrice: 0,
delivery_id: 0,
getData: function() {
var data;
return data = {
deliveryTypeId: parseInt(F.delivtype_id),
deliveryId: parseInt(F.delivery_id),
date: F.date,
time: F.time,
kmPrice: F.kmPrice,
km: F.km,
deliveryPrice: F.deliveryPrice,
delivery_time: F.delivery_time,
beautyDate: F.beautyDate
};
},
resetDateTime: function() {
F.date = null;
F.beautyDate = null;
F.delivtype_id = 0;
F.delivery_id = 0;
F.delivery_time = 0;
F.deliveryPrice = 0;
F.time = null;
F.times = null;
F.except = null;
return $("#datetime").addClass('empty').text("Не выбрано");
},
getTime: function() {
var res;
res = null;
switch (parseInt(F.delivery_time)) {
case 1:
case 2: // Самовывоз, # Точное время
res = $("#delivery_time", F.$window).val();
if (res === '') {
res = null;
}
}
return res;
},
saveDateTime: function() {
switch (parseInt(F.delivery_time)) {
case 1:
case 2: // Самовывоз, # Точное время
F.time = $("#delivery_time", F.$window).val();
if (F.time === '') {
F.time = null;
}
}
if (F.time === null) {
} else {
A.W.close();
return $("#datetime").removeClass('empty').text(F.beautyDate + " " + F.time);
}
},
getTimes: function() {
var s;
if (F.date === null) {
return null;
}
s = {
date: F.date,
delivtype: F.delivtype_id,
delivery: F.$delivery.data('value'),
filial: A.city,
dataType: "JSON",
extend: true,
address: A.getCookie('address')
};
return API('app/getTimes', s, function(data, cd) {
var $option, $options, i, intervalInfo, isEmpty, j, len, ref;
console.log('%cTIMES', 'color:red', data);
F.time = null;
F.times = data.times;
F.except = data.except;
isEmpty = false;
intervalInfo = '';
$("#delivery_time", F.$window).val('');
$("#interval,#time", F.$window).hide();
switch (parseInt(F.delivery_time)) {
case 1:
case 2: // Самовывоз, # Точное время
if (F.times.length === 0) {
isEmpty = true;
} else {
if (F.times[1] === 24) {
F.times[1] = 0;
}
intervalInfo = "Доступный интервал: " + F.times[0] + ":" + data.minutes + " - " + (F.times[1] < 10 ? "0" : "") + F.times[1] + ":" + data.minutes;
$("#delivery_time", F.$window).val(F.times[0] + ":" + data.minutes);
}
$("#time", F.$window).toggle(!isEmpty);
break;
case 3:
case 4: // Часовой, # 4-хчасовой
$("#interval .select", F.$window).data('value', '');
if (F.times.length === 0) {
isEmpty = true;
} else {
$options = $("#interval .options", F.$window);
$("#interval .value .txt", F.$window).text("Интервал доставки");
$options.html('');
ref = F.times;
for (j = 0, len = ref.length; j < len; j++) {
i = ref[j];
$option = $('
' + i + '
');
$option.data('info', i);
$options.append($option);
$option.click(function() {
return F.time = $(this).data('info');
});
}
// F.checkDelivery()
$(".option:eq(0)", $options).click();
}
$("#interval", F.$window).toggle(!isEmpty);
}
if (isEmpty) {
intervalInfo = "Доступные интервалы отсутствуют";
}
$("#interval_info", F.$window).toggle(intervalInfo !== '').text(intervalInfo);
$("#warnings", F.$window).html('');
if (data.warning) {
$("#warnings", F.$window).html(data.warning.join('
'));
}
$.fn.SHOP('remathConfirm');
return $("#is_photo_wrap").each(function() {
var $t, e, excludePhoto, isBadDate;
$t = $(this);
try {
excludePhoto = JSON.parse($t.attr('data-exclude'));
isBadDate = excludePhoto.indexOf(F.date) >= 0;
$t.toggle(!isBadDate);
if (isBadDate) {
return $("#is_photo_wrap input[type=checkbox]").prop('checked', false);
}
} catch (error) {
e = error;
}
});
});
},
onAddressChanged: function() {
F.resetDateTime();
F.check();
return A.W.openChangedAddress();
},
check: function() {
var data;
data = $.fn.CONFIRM('getData');
$("#b_confirm").attr('data-delivtype', 0);
$("#b_confirm").attr('data-delivery', 0);
$("#b_confirm").attr('data-km', 0);
$("#b_confirm").attr('data-is_self', A.getCookie('self'));
$("#b_confirm").attr('data-is_ask', A.getCookie('ask'));
return $.fn.SHOP('check');
},
chooseDateTime: function() {
A.W.open(460);
A.W.startLoad();
A.W.hideBack();
return API('cart/get/chooseDateTime', {}, function(data) {
var $data, $date0, $dates;
$data = $(data);
A.W.setHtml($data);
F.$window = $data;
$dates = $(".deliver_date", $data);
$(document).on('click', ".deliver_date", function(e) {
e.preventDefault();
e.stopPropagation();
$dates.removeClass('selected');
$(this).addClass('selected');
F.date = $(this).attr('data-date');
F.beautyDate = $(this).attr('data-beauty');
return F.getTimes();
});
F.$delivery = $("#delivery_id");
F.delivtype_id = F.$delivery.attr('data-type');
F.km = F.$delivery.attr('data-km');
F.kmPrice = F.$delivery.attr('data-km_price');
F.isSelf = parseInt(F.$delivery.attr('data-is_self')) === 1;
F.isAsk = parseInt(F.$delivery.attr('data-is_ask')) === 1;
$("#b_confirm").attr('data-is_self', F.isSelf ? 1 : 0);
$("#b_confirm").attr('data-is_ask', F.isAsk ? 1 : 0);
F.$delivery.on('select.change', function() {
var val;
val = F.$delivery.data('value');
F.delivery_time = $(`.option[data-value=${val}]`, F.$delivery).attr('data-time');
F.deliveryPrice = $(`.option[data-value=${val}]`, F.$delivery).attr('data-price');
$("#b_confirm").attr('data-delivery', F.deliveryPrice);
$("#b_confirm").attr('data-km', F.kmPrice);
F.delivery_id = val;
return F.getTimes();
});
$("#delivery_id .option:eq(0)").click();
$date0 = $($dates[0]);
$date0.addClass('selected');
F.date = $date0.attr('data-date');
F.beautyDate = $date0.attr('data-beauty');
F.getTimes();
$("#delivery_time", F.$window).blur(F.checkTime);
$("#km").val(F.$delivery.attr('data-km'));
return $("[data-name=km]").toggle(parseInt(F.kmPrice) > 0);
});
},
checkTime: function() {
var h, v;
v = $("#delivery_time", F.$window).val().split(":");
h = parseInt(v[0]);
if (F.except !== null && F.except.length > 0) {
if (F.except.indexOf(v[0]) >= 0) {
$("#delivery_time", F.$window).val("");
}
}
if (h < F.times[0]) {
h = (F.times[0] < 10 ? "0" : "") + F.times[0];
return $("#delivery_time", F.$window).val(h + ":00");
} else if (h > F.times[1] && F.times[1] !== 0) {
h = (F.times[1] < 10 ? "0" : "") + F.times[1];
return $("#delivery_time", F.$window).val(h + ":00");
}
},
init: function($html) {
var $x, address;
$x = $("#b_confirm", $html);
if ($x.length === 0) {
return null;
}
F.$wrap = $x;
$("body").on('address.changed', F.onAddressChanged);
$.fn.MAP('init', 'confirm_map_delivery');
F.check();
address = A.getCookie('address');
if (address !== void 0 && address !== '') {
return A.captcha('parseAddress', function(token) {
var s;
s = {
address,
dataType: "JSON"
};
s._g_token = token;
s.searchSource = 'confirm';
return API('geocode/parse', s, function(data) {
return $.fn.MAP('makePoint', 'confirm_map_delivery', data.coordinates);
});
});
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.CONFIRM2 = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.CONFIRM2');
}
};
return F = {
$wrap: null,
$wrapPayment: null,
$paymentList: null,
$isOrg: null,
$stepDelivery: null,
$stepReceiver: null,
$stepDate: null,
$stepPayment: null,
$valueDelivery: null,
$valueReceiver: null,
$valueDate: null,
$valuePayment: null,
isAsk: function() {
return parseInt(F.$wrap.data('is_ask')) === 1;
},
isSelf: function() {
return parseInt(F.$wrap.data('is_self')) === 1;
},
isKm: function() {
return parseInt(F.$wrap.data('km_price')) > 0;
},
getDeliveryType: function() {
return F.$wrap.data('delivtype');
},
getDeliveryId: function() {
return F.$wrap.data('delivery');
},
getDate: function() {
return F.$wrap.data('date');
},
getTime: function() {
return F.$wrap.data('time');
},
getKmPrice: function() {
return F.$wrap.data('km_price');
},
getKm: function() {
return F.$wrap.data('km');
},
getDeliveryTime: function() {
return F.$wrap.data('delivery_time');
},
getDeliveryPrice: function() {
return F.$wrap.data('delivery_price');
},
getBeautyDate: function() {
return F.$wrap.data('beautyDate');
},
getAddress: function() {
return A.getCookie('address');
},
getMyPhone: function() {
return $("#my_phone").attr('data-phone');
},
getMyPhoneBeauty: function() {
return $("#my_phone").text();
},
getPaymentId: function() {
var id;
id = parseInt(F.$wrap.data('payment'));
if (isNaN(id)) {
id = null;
}
return id;
},
getMyName: function() {
return F.getMyProp('my_name', 'my_name_input', 'my_name_receiver_input');
},
getMyEmail: function() {
return F.getMyProp('my_email', 'my_email_input', 'my_email_receiver_input');
},
getMyProp: function(x, y, z) {
var $name, res;
res = null;
$name = $(`#${x}`);
if ($name.length === 1) {
res = $name.text();
} else {
if (F.isMeReceiver()) {
res = $(`#${y}`).val();
} else if (F.isOtherReceiver()) {
res = $(`#${z}`).val();
}
}
return res;
},
getReceiverName: function() {
return $('[name="receiver_name"]').val();
},
getReceiverPhone: function() {
return $('[name="receiver_phone"]').val();
},
isOrg: function() {
return F.$isOrg.is(":checked");
},
isMeReceiver: function() {
return parseInt($("[name='receiver_type']:checked").val()) === 0;
},
isOtherReceiver: function() {
return parseInt($("[name='receiver_type']:checked").val()) === 1;
},
isSetAddress: function() {
return F.getAddress() !== '';
},
isSetDelivery: function() {
var res;
res = false;
res = F.isAsk() || F.isSelf() || F.isSetAddress();
return res;
},
isSetDate: function() {
var date;
date = F.getDate();
return (date != null) && date !== '';
},
isSetTime: function() {
var date;
date = F.getTime();
return (date != null) && date !== '';
},
isSetDateTime: function() {
return F.isSetDate() && F.isSetTime();
},
isSetPayment: function() {
var id, res;
res = false;
id = parseInt(F.$wrap.data('payment'));
if (!isNaN(id) && id > 0) {
res = true;
}
return res;
},
isSetOrg: function() {
var data, res;
res = false;
if (F.isOrg()) {
data = F.getConfirmData();
if (data['inn'] && data['bank_title'] && data['bank_rs']) {
res = true;
}
} else {
res = true;
}
return res;
},
isSetReceiver: function() {
var isMyEmail, myEmail, myName, name, phone, res;
res = false;
myName = F.getMyName();
myEmail = F.getMyEmail();
isMyEmail = false;
if ($("#my_email").length === 1) {
isMyEmail = true;
} else {
isMyEmail = A.mail.test(myEmail);
}
if (myName !== '' && isMyEmail) {
if (F.isMeReceiver()) {
res = true;
}
if (F.isOtherReceiver()) {
name = F.getReceiverName();
phone = F.getReceiverPhone();
if (name !== '' && phone !== '' && phone.indexOf('_') < 0) {
res = true;
}
}
}
return res;
},
checkIsAsk: function() {
var isAsk;
isAsk = F.isAsk();
$("#me_receiver_wrap").toggle(!isAsk);
if (isAsk) {
$("[name='receiver_type'][value='1']").click();
} else {
$("[name='receiver_type']").prop("checked", false);
$("#confirm_receiver .checkbox_content").hide();
$("#confirm_receiver .checkbox_area").removeClass('selected');
}
return F.check();
},
check: function() {
var isSetDateTime, isSetDelivery, isSetOrg, isSetPayment, isSetReceiver;
isSetDelivery = F.isSetDelivery();
isSetReceiver = F.isSetReceiver();
isSetDateTime = F.isSetDateTime();
isSetPayment = F.isSetPayment();
isSetOrg = F.isSetOrg();
F.$stepReceiver.toggleClass('selected', isSetDelivery);
F.$stepDate.toggleClass('selected', isSetReceiver);
F.$stepPayment.toggleClass('selected', isSetDateTime && isSetReceiver);
if (isSetDelivery) {
F.$deliveryTitle.removeClass('error');
}
if (isSetReceiver) {
F.$receiverTitle.removeClass('error');
}
if (isSetDateTime) {
F.$dateTitle.removeClass('error');
}
if (isSetPayment && isSetOrg) {
F.$paymentTitle.removeClass('error');
}
//F.$confirmButton.prop('disabled',!(isSetPayment & isSetOrg))
F.checkValues();
F.checkButtons();
return F.reloadTotal();
},
//F.checkSubmits(true)
checkReceiverButton: function() {
var isSetReceiver;
isSetReceiver = F.isSetReceiver();
return F.$receiverButton.prop('disabled', !isSetReceiver);
},
checkDateButton: function() {
var isSetDateTime;
isSetDateTime = F.isSetDateTime();
return F.$dateButton.prop('disabled', !isSetDateTime);
},
checkValues: function() {
F.checkReceiverValue();
F.checkDateValue();
return F.checkPaymentValue();
},
checkButtons: function() {
F.checkReceiverButton();
return F.checkDateButton();
},
checkReceiverValue: function() {
var isSetReceiver, name, phone, value;
isSetReceiver = F.isSetReceiver();
value = '';
if (isSetReceiver) {
if (F.isMeReceiver()) {
name = F.getMyName();
phone = F.getMyPhoneBeauty();
} else {
name = F.getReceiverName();
phone = F.getReceiverPhone();
}
value = name !== '' ? `${name}
${phone}` : `${phone}`;
}
F.$valueReceiver.html(value);
return F.$valueReceiver.closest('.step_content').toggleClass('empty', value === '');
},
checkDateValue: function() {
var d, date, exclude, isExclude, time, value;
value = '';
date = F.getBeautyDate();
time = F.getTime();
if (date && time) {
value = `${date} в ${time}`;
}
F.$valueDate.html(value);
F.$valueDate.closest('.step_content').toggleClass('empty', value === '');
try {
exclude = JSON.parse($("#whatsapp_wrap").attr('data-exclude'));
d = F.getDate();
isExclude = exclude.indexOf(d) >= 0;
$("#whatsapp_wrap").toggle(!isExclude);
if (isExclude) {
return $("#input_whatsapp").prop('checked', false);
}
} catch (error) {}
},
checkPaymentValue: function() {
var isSetPayment, value;
value = '';
isSetPayment = F.isSetPayment();
if (isSetPayment) {
value = $("[name='payment']:checked").attr('data-name');
}
return F.$valuePayment.html(value);
},
checkEmail: function() {
var $t, val;
$t = $(this);
val = $t.val();
return $t.parent().toggleClass('error', !A.mail.test(val));
},
init: function($html) {
var $c, $dates;
$c = $("#b_confirm2", $html);
if ($c.length === 0) {
return;
}
if ($c.data('init')) {
return;
}
$c.data('init', true);
F.$wrap = $c;
F.$wrapPayment = $("#confirm_payment");
F.$paymentList = $("#confirm_payment_list");
F.$isOrg = $("#is_org", F.$wrap);
F.$confirmButton = $("#confirm_button", F.$wrap);
F.$receiverButton = $("#receiver_button");
F.$dateButton = $("#date_button");
F.$stepDelivery = $(".step_el[data-step='delivery']", F.$wrap);
F.$stepReceiver = $(".step_el[data-step='receiver']", F.$wrap);
F.$stepDate = $(".step_el[data-step='date']", F.$wrap);
F.$stepPayment = $(".step_el[data-step='payment']", F.$wrap);
F.$valueDelivery = $(".step_value", F.$stepDelivery);
F.$valueReceiver = $(".step_value", F.$stepReceiver);
F.$valueDate = $(".step_value", F.$stepDate);
F.$valuePayment = $(".step_value", F.$stepPayment);
F.$delivery = $("#confirm_delivery_id");
F.$deliveryTime = $("#confirm_delivery_time");
F.$interval = $("#confirm_interval");
F.$intervalSelect = $(".select", F.$intervalSelect);
F.$time = $("#confirm_time");
F.$timeIntervalInfo = $("#confirm_interval_info");
F.$timeWarning = $("#confirm_warnings");
F.$promocodeWrap = $("#promocode_wrap", F.$wrap);
F.$promocode = $("#promocode", F.$wrap);
F.$confirmRes = $("#confirm_res");
F.$deliveryTitle = $("#confirm_delivery_title");
F.$receiverTitle = $("#confirm_receiver_title");
F.$dateTitle = $("#confirm_date_title");
F.$paymentTitle = $("#confirm_payment_title");
F.$interval.hide();
F.$time.hide();
$("body").on("address.changed", F.onAddressChanged);
F.$deliveryTime.blur(F.checkTime);
F.$isOrg.click(function() {
var isOrg;
isOrg = F.isOrg();
$(".not_is_org").slideToggle(!isOrg);
$(".is_org").slideToggle(isOrg);
F.$wrap.data('is_org', F.$isOrg.is(":checked"));
F.check();
return F.loadPayments();
});
$(".confirm_modal input,.confirm_modal textarea").on('keyup click change paste', F.checkButtons);
$("#b_confirm2 input").on('keyup click change paste', F.check);
$("#confirm_receiver [type='email']").on('keyup click change paste', F.checkEmail);
$.fn.CONFIRM_ADDRESS('init', $html);
$(".confirm_modal .close", $html).click(F.closeModal);
F.$delivery.on('select.change', function() {
var $options, data, val;
val = F.$delivery.data('value');
$options = $(`.option[data-value=${val}]`, F.$delivery);
data = $options.data('data');
F.$wrap.data('delivery_price', data.price);
F.$wrap.data('delivery_time', data.time);
F.$wrap.data('delivery', data.id);
//F.delivery_time = $(".option[data-value=#{val}]",F.$delivery).attr('data-time')
//F.deliveryPrice = $(".option[data-value=#{val}]",F.$delivery).attr('data-price')
//$("#b_confirm").attr('data-delivery',F.deliveryPrice)
//$("#b_confirm").attr('data-km',F.kmPrice)
return F.getTimes();
});
$("#delivery_id .option:eq(0)").click();
$dates = $(".confirm_dates .date", $html);
$dates.click(function() {
$dates.removeClass('selected');
F.$wrap.data('date', $(this).data('value'));
F.$wrap.data('beautyDate', $(this).text());
$(this).addClass('selected');
F.getTimes();
return F.loadPayments();
});
if (!A.isMobile()) {
$(".confirm_dates", $html).owlCarousel({
autoWidth: true,
nav: true,
margin: 8,
navText: ['', '']
});
}
F.check();
F.getDeliveries();
F.reloadTotal();
return setTimeout(F.checkIsAsk, 100);
},
onAddressChanged: function() {
var isSetDate;
console.log('onAddressChanged', F.isSetDate());
isSetDate = F.isSetDate();
F.$wrap.data('date', null);
$(".confirm_dates .date").removeClass('selected');
F.$timeIntervalInfo.text('');
F.$timeWarning.text('');
F.getDeliveries();
if (isSetDate) {
return setTimeout(function() {
return F.openTimeChanges();
}, 100);
}
},
getData: function() {
var data;
data = {
deliveryTypeId: F.getDeliveryType(),
deliveryId: F.getDeliveryId(),
date: F.getDate(),
time: F.getTime(),
kmPrice: F.getKmPrice(),
km: F.getKm(),
deliveryPrice: F.getDeliveryPrice(),
delivery_time: F.getDeliveryTime(),
beautyDate: F.getBeautyDate()
};
return data;
},
getCartData: function() {
var confirm, data, isAsk, isNeedAddress, isOther, isSelf;
confirm = F.getData();
isSelf = F.isSelf();
isAsk = F.isAsk();
isOther = F.isOtherReceiver();
isNeedAddress = !(isAsk || isSelf);
data = {
'deltype': confirm.deliveryTypeId,
'delivery': confirm.deliveryId,
'date': confirm.date,
'time': confirm.time,
'is_org': F.isOrg() ? 1 : 0,
'ask_receiver': isOther && isAsk ? 1 : 0, // confirm.isOtherReceiver && confirm.isReceiverAsk ? 1 : 0,
'receiver_name': F.getReceiverName(), // confirm.isSelfDelivery ? '' : ( confirm.isOtherReceiver ? confirm.controllerReceiverName.text : ''),
'receiver_phone': F.getReceiverPhone(), // confirm.isSelfDelivery ? '' : ( confirm.isOtherReceiver ? confirm.controllerReceiverPhone.text : ''),
'address': isNeedAddress ? A.getCookie('address') : '',
'flat': isNeedAddress ? A.getCookie('flat') : '', // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerFlat.text,
'entrance': isNeedAddress ? A.getCookie('entrance') : '', // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerEntrance.text,
'floor': isNeedAddress ? A.getCookie('floor') : '', // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerFloor.text,
'intercom': isNeedAddress ? A.getCookie('intercom') : '', // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerIntercom.text,
'comment': isNeedAddress ? A.getCookie('comment') : '' // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerComment.text,
};
return data;
},
openModal: function(x) {
$(`#${x}`).addClass('open');
$("body").addClass('open_confirm_address');
A.P.body.css('overflow', 'hidden');
return A.W.blockScroll();
},
closeModal: function() {
$(".confirm_modal").removeClass('open');
$("body").removeClass('open_confirm_address');
A.W.unblockScroll();
return F.check();
},
openAddress: function() {
F.openModal('confirm_address_wrap');
return $.fn.CONFIRM_ADDRESS('open');
},
openReceiver: function() {
return F.openModal('confirm_receiver');
},
openCard: function() {
return F.openModal('confirm_card');
},
openComment: function() {
return F.openModal('confirm_comment');
},
openTimeChanges: function() {
F.openModal('confirm_date_changes');
return F.loadPayments();
},
openPayment: function() {
F.openModal('confirm_payment');
return F.loadPayments();
},
loadPayments: function() {
var payment, s;
payment = F.$wrap.data('payment');
F.$wrap.data('payment', null);
F.check();
F.$paymentList.html('Загрузка...');
s = F.getCartData();
s.dataType = 'JSON';
return API('cart/get_payments2', s, function(data, cd) {
var $html, $inp;
$html = $(data.html);
A.P.initMini($html);
F.$paymentList.html($html);
$inp = $("input", F.$paymentList);
$inp.click(function() {
var $t;
$t = $(this);
F.$wrap.data('payment', $t.val());
$("#payment_value").text($t.attr('data-name'));
return F.check();
});
if ($inp.length === 1) {
return $inp.click();
} else {
return $inp.filter('[value="' + payment + '"]').click();
}
});
},
checkPromoCode: function() {
var $res, s;
F.$promocodeWrap.addClass('loading');
s = {
coupon: F.$promocode.val(),
dataType: "JSON"
};
$res = $("#promo_code_info").slideUp(300);
API('cart/add_coupon', s, function(data) {
F.$promocodeWrap.removeClass('loading');
if (data.e === 0) {
F.$promocodeWrap.addClass('has_promocode');
return F.reloadTotal();
} else {
return $res = $("#promo_code_info").text(data['m']).slideDown(300);
}
});
return false;
},
removePromoCode: function() {
var $res, coupon;
F.$promocodeWrap.addClass('loading');
coupon = F.$promocode.val();
F.$promocode.val('');
$res = $("#promo_code_info").slideUp(300);
API('cart/remove_coupon', {coupon}, function() {
F.$promocodeWrap.removeClass('loading has_promocode');
return F.reloadTotal();
});
return false;
},
reloadTotal: function() {
return $.fn.SHOP('updateTotals', F.remathConfirm);
},
saveCard: function() {
var val;
F.closeModal();
val = $("#card_text_input").val();
$("#card_text").text(val);
return $("#add_card").toggleClass('has_value', val !== '');
},
saveComment: function() {
var val;
F.closeModal();
val = $("#comment_text_input").val();
$("#comment_text").text(val);
return $("#add_comment").toggleClass('has_value', val !== '');
},
savePayment: function() {
return F.closeModal();
},
saveDate: function() {
return F.closeModal();
},
saveReceiver: function() {
return F.closeModal();
},
openDateTime: function() {
return F.openModal('confirm_date');
},
getDeliveries: function() {
var s;
F.$wrap.data('km', 0);
F.$wrap.data('km_price', 0);
F.$wrap.data('delivery', 0);
F.$wrap.data('delivtype', 0);
//F.$wrap.data('date',null)
F.$wrap.data('time', null);
F.check();
s = {
dataType: "JSON"
};
return API('cart/getDeliveries', s, function(data, cd) {
var $options;
F.$wrap.data('km', data['km']);
F.$wrap.data('km_price', data['km_price']);
F.$wrap.data('delivtype', data['delivtype']);
F.$wrap.data('delivery_id', data['delivery_id']);
$options = $(".options", F.$delivery);
$options.html('');
data['deliveries'].forEach(function(item) {
var $option;
$option = $('
' + item['title'] + '
' + item['fprice'] + '
');
$option.data('data', item);
$option.data('value', item['id']);
return $options.append($option);
});
//A.P.initOptions(F.$delivery)
return $(".option:eq(0)", F.$delivery).click();
});
},
getTimes: function() {
var date, isDate, s;
date = F.getDate();
isDate = date !== null && date !== '' && date !== void 0;
$("#deliveries_selects").toggle(isDate);
if (!isDate) {
return null;
}
F.$wrap.data('time', null);
s = {
date: F.getDate(),
delivtype: F.getDeliveryType(),
delivery: F.getDeliveryId(),
filial: A.city,
dataType: "JSON",
extend: true,
//address : A.getCookie('address')
address: F.isSelf() ? null : A.getCookie('address')
};
if (s['delivtype'] === null) {
return;
}
if (parseInt(s['delivtype']) === 0) {
return;
}
F.check();
return API('app/getTimes', s, function(data, cd) {
var $option, $options, deliveryType, h, i, intervalInfo, isEmpty, j, len, ref, time;
console.log('%cTIMES', 'color:red', data, s);
F.time = null;
F.times = data.times;
F.except = data.except;
isEmpty = false;
intervalInfo = '';
F.$deliveryTime.val('');
F.$interval.hide();
F.$time.hide();
deliveryType = parseInt(F.getDeliveryTime());
switch (deliveryType) {
case 1:
case 2: // Самовывоз, # Точное время
if (F.times.length === 0) {
isEmpty = true;
} else {
if (F.times[1] === 24) {
F.times[1] = 0;
}
intervalInfo = "Доступный интервал: " + F.times[0] + ":" + data.minutes + " - " + (F.times[1] < 10 ? "0" : "") + F.times[1] + ":" + data.minutes;
h = (F.times[0] < 10 ? "0" : "") + F.times[0];
time = F.times[0] + ":" + data.minutes;
F.$wrap.data('time', time);
F.$deliveryTime.val(h + ":" + data.minutes);
}
$("#choose_time").trigger('set', [F.times[0], F.times[1], data['except']]);
F.$time.toggle(!isEmpty);
break;
case 3:
case 4: // Часовой, # 4-хчасовой
F.$intervalSelect.data('value', '');
if (F.times.length === 0) {
isEmpty = true;
} else {
$options = $(".options", F.$interval);
$(".value .txt", F.$interval).text("Интервал доставки");
$options.html('');
ref = F.times;
for (j = 0, len = ref.length; j < len; j++) {
i = ref[j];
$option = $('
' + i + '
');
$option.data('info', i);
$options.append($option);
$option.click(function() {
F.$wrap.data('time', $(this).data('info'));
//F.time = $(@).data('info')
return F.check();
});
}
// F.checkDelivery()
$(".option:eq(0)", $options).click();
}
F.$interval.toggle(!isEmpty);
}
if (isEmpty) {
intervalInfo = "Доступные интервалы отсутствуют";
}
F.check();
F.$timeIntervalInfo.toggle(intervalInfo !== '').text(intervalInfo);
F.$timeWarning.html('');
if (data.warning) {
F.$timeWarning.html(data.warning.join('
'));
}
setTimeout(function() {
var oY;
if (A.isMobile()) {
switch (deliveryType) {
case 1:
case 2:
h = 0;
break;
case 3:
case 4:
h = F.$interval.is(":visible") ? F.$interval.outerHeight() : 0;
}
$option = $("#confirm_delivery_id .option").css('margin-bottom', '0px');
$option = $("#confirm_delivery_id .selected");
$option.css('margin-bottom', h + 'px');
oY = $option.position().top + $option.outerHeight();
F.$interval.css('top', oY + 'px');
return F.$deliveryTime.hide();
}
}, 10);
return $("#is_photo_wrap").each(function() {
var $t, e, excludePhoto, isBadDate;
$t = $(this);
try {
excludePhoto = JSON.parse($t.attr('data-exclude'));
isBadDate = excludePhoto.indexOf(F.date) >= 0;
$t.toggle(!isBadDate);
if (isBadDate) {
return $("#is_photo_wrap input[type=checkbox]").prop('checked', false);
}
} catch (error) {
e = error;
}
});
});
},
checkTime: function() {
var h, v;
v = F.$deliveryTime.val().split(":");
h = parseInt(v[0]);
if (F.except !== null && F.except.length > 0) {
if (F.except.indexOf(v[0]) >= 0) {
F.$deliveryTime.val("");
}
}
if (h < F.times[0]) {
h = (F.times[0] < 10 ? "0" : "") + F.times[0];
F.$deliveryTime.val(h + ":00");
} else if (h > F.times[1] && F.times[1] !== 0) {
h = (F.times[1] < 10 ? "0" : "") + F.times[1];
F.$deliveryTime.val(h + ":00");
}
F.$wrap.data('time', F.$deliveryTime.val());
return F.check();
},
remathConfirm: function() {
var cert_free, cert_left, cert_minus, cert_minus_total, currency, delivery, delivery_total, isSale, km, km_price, km_print, km_total, o, percent, total, total_items, total_old;
total = parseFloat(F.$wrap.data('total'));
total_old = parseFloat(F.$wrap.data('old'));
delivery = parseFloat(F.getDeliveryPrice());
km_price = parseFloat(F.getKmPrice());
cert_minus = parseFloat(F.$wrap.data('cert_minus'));
cert_free = parseFloat(F.$wrap.data('cert_free'));
cert_left = parseFloat(F.$wrap.data('cert_left'));
currency = parseFloat(F.$wrap.data('currency'));
o = currency === 1 ? 0 : 2;
total = parseFloat((total / currency).toFixed(o));
total_old = parseFloat((total_old / currency).toFixed(o));
delivery = parseFloat((delivery / currency).toFixed(o));
cert_minus = parseFloat((cert_minus / currency).toFixed(o));
cert_free = parseFloat((cert_free / currency).toFixed(o));
cert_left = parseFloat((cert_left / currency).toFixed(o));
km_price = parseFloat((km_price / currency).toFixed(o));
total_items = total;
km = 0;
km_total = 0;
km_print = 0;
delivery_total = delivery;
cert_minus_total = cert_minus;
km = F.getKm();
if (isNaN(km)) {
km = 0;
}
km_total += km_price * km;
km_print = km_total;
cert_left -= delivery_total;
if (cert_left < 0) {
cert_minus_total += delivery_total + cert_left;
delivery_total = -cert_left;
} else {
cert_minus_total += delivery_total;
delivery_total = 0;
cert_left -= km_total;
if (cert_left < 0) {
cert_minus_total += km_total + cert_left;
km_total = -cert_left;
} else {
cert_minus_total += km_total;
km_total = 0;
}
}
$(".cert_wrap").toggle(cert_free > 0);
total += delivery_total + km_total - cert_minus;
total_old += delivery_total + km_total - cert_minus;
percent = ((1 - (total / total_old)) * 100).toFixed(0);
$(".confirm_total_items").text(total_items.toFixed(o));
$(".confirm_total").text(total.toFixed(o));
$(".confirm_old").text(total_old.toFixed(o));
$(".confirm_total_wihtout_delivery").text((total - delivery_total).toFixed(o));
//$(".delivery_total").text(delivery_total)
$(".delivery_total").text(isNaN(delivery) ? 0 : delivery.toFixed(o));
//$(".km_total").text(km_total)
$(".km_total_wrap").toggle(km_print > 0);
$(".km_total").text(km_print.toFixed(o));
$(".cert_minus").text(cert_minus_total.toFixed(o));
$(".cert_left").text(Math.max(0, cert_left).toFixed(o));
isSale = total_old > total;
$(".old_price").toggle(isSale);
return $(".old_percent").text(percent + '%');
},
getConfirmData: function() {
var c, data, isOther;
isOther = F.isOtherReceiver();
return data = {
'delivtype': F.getDeliveryType(), // confirm.deliveryType?.id ?? 0,
'delivery': F.getDeliveryId(), // confirm.delivery?.id ?? 0,
'date': F.getDate(), // Global.formatDateToApi(confirm.date),
'time': F.getTime(), // confirm.timeToSend,
'pay': '', // confirm.payment?.id ?? 0,
//'comment' : $('#input_comment').val() # confirm.controllerComment.text,
'comment': $('#comment_text_input').val(), // confirm.controllerComment.text,
'pack': (c = A.getCookie('pack')) === false ? 1 : c,
'aqua': (c = A.getCookie('aqua')) === false ? 1 : c,
'is_photo': $('#input_whatsapp').is(":checked") ? 1 : 0,
'anon': isOther && $('#input_anon').is(":checked") ? 1 : 0, // confirm.isOtherReceiver && confirm.isAnon ? 1 : 0,
'ask_receiver': F.isAsk() ? 1 : 0, // confirm.isOtherReceiver && confirm.isReceiverAsk ? 1 : 0,
'me_receiver': F.isMeReceiver() ? 1 : 0, // confirm.isMeReceiver ? 1 : 0,
'is_save_address': 0, // 0,
'is_save_date': 0,
'km': F.isKm() ? F.getKm() : 0, // confirm.isKM ? confirm.km : '',
'props': {
'1': isOther ? F.getReceiverPhone() : '', // '' # confirm.isOtherReceiver ? confirm.controllerReceiverPhone.text : '',// receiverPhoneController.text,
'2': isOther ? F.getReceiverName() : '', // confirm.isOtherReceiver ? confirm.controllerReceiverName.text : '',// receiverNameController.text,
'3': F.getMyName(), // confirm.controllerName.text,// nameController.text,
'4': F.getMyEmail(), // confirm.controllerEmail.text,// emailController.text,
'5': F.getMyPhone(), // confirm.controllerPhone.text,// phoneController.text,
'8': $('#card_text_input').val() // confirm.controllerCard.text, // cardController.text,
},
'is_org': F.isOrg() ? 1 : 0,
'inn': $('[data-name="inn"] input').val(),
'kpp': $('[data-name="kpp"] input').val(),
'org_title': $('[data-name="org_title"] input').val(),
'org_address': $('[data-name="org_address"] input').val(),
'bank_title': $('[data-name="bank_title"] input').val(),
'bank_bik': $('[data-name="bank_bik"] input').val(),
'bank_ks': $('[data-name="bank_ks"] input').val(),
'bank_rs': $('[data-name="bank_rs"] input').val(),
'pay': F.getPaymentId()
};
},
checkSubmits: function(isSilent = false) {
var isSetDateTime, isSetDelivery, isSetOrg, isSetPayment, isSetReceiver, warnings;
if (!isSilent) {
F.$confirmRes.slideUp(300);
}
isSetDelivery = F.isSetDelivery();
isSetReceiver = F.isSetReceiver();
isSetDateTime = F.isSetDateTime();
isSetPayment = F.isSetPayment();
isSetOrg = F.isSetOrg();
F.$deliveryTitle.removeClass('error');
F.$receiverTitle.removeClass('error');
F.$dateTitle.removeClass('error');
F.$paymentTitle.removeClass('error');
warnings = [];
if (!isSetDelivery) {
if (!isSilent) {
F.$deliveryTitle.addClass('error');
}
warnings.push('Выберите способ получения');
}
if (!isSetReceiver) {
if (!isSilent) {
F.$receiverTitle.addClass('error');
}
warnings.push('Выберите получателя');
}
if (!isSetDateTime) {
if (!isSilent) {
F.$dateTitle.addClass('error');
}
warnings.push('Выберите дату и время');
}
if (!isSetPayment) {
if (!isSilent) {
F.$paymentTitle.addClass('error');
}
warnings.push('Выберите способ оплаты');
}
if (!isSetOrg) {
warnings.push('Заполните реквизиты организации');
}
if (isSilent) {
F.$confirmRes.html(warnings.join('
'));
} else {
F.$confirmRes.html(warnings.join('
')).slideDown(300);
}
return warnings.length === 0;
},
submit: function() {
var cart, isCanSend;
isCanSend = F.checkSubmits();
if (isCanSend) {
A.I.waitButton(F.$confirmButton);
cart = F.getCartData();
API('cart/addData', cart, function(data) {
var s;
console.log('data', data);
//A.I.unwaitButton(F.$confirmButton)
s = F.getConfirmData();
s.dataType = "JSON";
s.subscribe = $("#subscribe_unput").is(":checked") ? 1 : 0;
//A.I.waitButton $b = $(".confirm_button")
return A.captcha('cart', function(token) {
s._g_token = token;
A.reach('order');
return API('cart/confirm', s, F.aConfirm);
});
});
}
return false;
},
aConfirm: function(data, cd) {
//A.I.unwaitButton cd.$b
A.ga('lead', 'sale');
A.tiktok('Checkout');
//if cd.s.payID==A.C.payOnlineID
// A.ga('lead','online_paid')
if (data.link != null) {
H.go(data.link);
return A.reach('order');
}
}
};
//window.location.href = data.link
//window.location.href = data.id
})(jQuery);
(function($) {
var F;
$.fn.CONFIRM_ADDRESS = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.CONFIRM_ADDRESS');
}
};
return F = {
$wrap: null,
mapID: "confirm_map_yandex",
address: null,
search: function() {
var $i, val;
F.$error.hide();
F.address = null;
F.$address.data('changed', true);
$i = $(this);
val = $i.val();
return API('dadata/searchAddressForShop', {
q: val,
dataType: 'JSON',
'fid': A.city
}, function(data) {
var i, j, len, results;
F.$results.html('').show();
results = [];
for (j = 0, len = data.length; j < len; j++) {
i = data[j];
if (i.title !== '') {
results.push(F.$results.each(function() {
var $li;
$li = $('
' + i.title + '
' + i.value_app + '
');
$li.data('address', i);
$li.click(function() {
var address;
address = $(this).data('address');
F.$results.hide();
if (address['is_house']) {
return F.chooseAddress(address);
} else {
F.$input.val(address.value + " ");
return F.$input.focus();
}
});
return $(this).append($li);
}));
} else {
results.push(void 0);
}
}
return results;
});
},
chooseAddress: function(x) {
F.address = x;
F.$address.val(x.value);
F.$address.data('changed', false);
F.prevAddress = x.value;
return F.parseAddress();
},
parseAddress: function(cb) {
//A.I.waitButton(F.$saveAddress,'Проверка...')
A.I.waitButton(F.$saveAddress);
return A.captcha('parseAddress', function(token) {
var address, s;
address = F.prevAddress;
s = {
address,
dataType: "JSON"
};
s._g_token = token;
s.searchSource = 'confirmAddress parseAddress';
return API('geocode/parse', s, function(data) {
A.I.unwaitButton(F.$saveAddress);
$.fn.MAP('makePoint', F.mapID, data.coordinates);
if (data.out) {
if (data.warning) {
return F.warning(data.warning.join('
'));
}
} else {
return typeof cb === "function" ? cb() : void 0;
}
});
});
},
warning: function(x) {
F.$error.text(x).show();
return F.isWarning = x !== '';
},
saveAddress: function() {
F.warning('');
if (F.isWarning) {
return null;
}
if (F.address !== null) {
if (F.address.is_house) {
return F.saveInputs();
} else {
return F.warning('Выберите адрес с указанным домом');
}
} else {
if (F.$address.data('changed')) {
if (F.prevAddress === F.$address.val()) {
return F.saveInputs();
} else {
return F.warning('Выберите адрес с указанным домом');
}
} else {
if (F.$address.val().trim() === '') {
return F.warning('Укажите адрес доставки');
} else {
return F.saveInputs();
}
}
}
},
clearData: function() {
A.setCookie('address_id', '');
A.setCookie('address', '');
A.setCookie('entrance', '');
A.setCookie('floor', '');
A.setCookie('flat', '');
A.setCookie('intercom', '');
A.setCookie('comment', '');
A.setCookie('ask', '');
A.setCookie('self', '');
F.$confirm.data('self', 0);
F.$confirm.data('ask', 0);
F.isAsk = false;
return F.isSelf = false;
},
saveInputs: function() {
return F.parseAddress(function() {
F.clearData();
A.setCookie('address', F.$address.val());
A.setCookie('entrance', F.$entrance.val());
A.setCookie('floor', F.$floor.val());
A.setCookie('flat', F.$flat.val());
A.setCookie('intercom', F.$intercom.val());
A.setCookie('comment', F.$comment.val());
F.setValue(F.$address.val());
return F.close();
});
},
setTag: function(x) {
return $(".step_tag").text(x);
},
setIsSelf: function() {
F.setTag('Самовывоз');
F.$confirm.data('is_ask', 0);
F.$confirm.data('is_self', 1);
A.setCookie('ask', 0);
A.setCookie('self', 1);
$(".address_value").text(F.$confirm.data('self_address'));
F.close();
return F.addressChanged();
},
setIsAsk: function() {
F.setTag('Доставка курьером');
F.$confirm.data('is_ask', 1);
F.$confirm.data('is_self', 0);
A.setCookie('ask', 1);
A.setCookie('self', 0);
$(".address_value").text('Уточним адрес у получателя');
F.close();
return F.addressChanged();
},
setValue: function(x) {
//F.$value.text(x)
//F.$value.removeClass('empty')
$(".address_value").text(x);
F.addressChanged();
F.$confirm.data('is_ask', 0);
F.$confirm.data('is_self', 0);
A.setCookie('ask', 0);
A.setCookie('self', 0);
F.setTag('Доставка курьером');
return F.close();
},
addressChanged: function() {
return $("body").trigger("address.changed");
},
init: function($html) {
var $c;
$c = $("#confirm_address_wrap", $html);
if ($c.length === 0) {
return;
}
$.fn.MAP('init', F.mapID);
F.$wrap = $c;
F.$confirm = $("#b_confirm2");
F.$address = $('[name="address"]', F.$wrap);
F.$entrance = $('[name="entrance"]', F.$wrap);
F.$floor = $('[name="floor"]', F.$wrap);
F.$flat = $('[name="flat"]', F.$wrap);
F.$intercom = $('[name="intercom"]', F.$wrap);
F.$comment = $('[name="comment"]', F.$wrap);
F.$input = $(".search_address_input", F.$wrap);
F.$results = $(".delivery_search_result", F.$wrap);
F.$error = $(".error", F.$wrap);
F.$saveAddress = $("#save_confirm_address", F.$wrap);
F.$choose_address = $("#choose_address", F.$wrap);
F.$input.keyup(F.search);
//F.$clear.click ->
// F.$input.val('').keyup()
//$(".close",F.$wrap).click F.close
$(".back", F.$wrap).click(function() {
var page;
page = $(this).attr('data-page');
return F.setPage(page);
});
$("#delivery_type_toggler .el", F.$wrap).click(function() {
var $t, page, type;
$t = $(this);
type = $t.attr('data-type');
page = $t.attr('data-page');
F.setPage(page);
return F.setType(type);
});
return $("[type=radio][name='confirm_address']", F.$wrap).click(function() {
var $t, address, s, val, x;
F.$choose_address.prop('disabled', true);
$t = $(this);
val = $t.val();
if (val === 'ask') {
return F.$choose_address.prop('disabled', false);
} else {
x = JSON.parse($t.attr('data-data'));
address = x['address'];
s = {
address,
dataType: "JSON"
};
//s._g_token = token
s.searchSource = 'confirmAddress typeRadio';
return API('geocode/parse', s, function(data) {
console.log(data);
if (data.coordinates && data.coordinates.length > 0 && parseInt(data.coordinates[0]) !== 0) {
//A.I.unwaitButton(F.$saveAddress)
$.fn.MAP('makePoint', F.mapID, data.coordinates);
return F.$choose_address.prop('disabled', false);
} else {
return F.$choose_address.prop('disabled', true);
}
});
}
});
},
setType: function(type) {
$("#delivery_type_toggler .el", F.$wrap).removeClass('selected');
$(`#delivery_type_toggler .el[data-type=${type}]`, F.$wrap).addClass('selected');
$(".toggle_content", F.$wrap).hide();
$(`.toggle_content[data-type=${type}]`, F.$wrap).show();
$("#confirm_address_content").removeClass('no_choose');
return setTimeout(function() {
return $.fn.MAP('resize', F.mapID);
}, 150);
},
openEditAddress: function(e) {
var d;
F.setPage('search_address');
try {
d = JSON.parse($(e).attr('data-data'));
} catch (error) {
e = error;
d = {};
}
F.$address.val(d['address']);
F.$entrance.val(d['entrance']);
F.$floor.val(d['floor']);
F.$flat.val(d['flat']);
F.$intercom.val(d['intercom']);
return F.$comment.val(d['comment']);
},
openAddAddress: function() {
F.setPage('search_address');
F.$address.val('');
F.$entrance.val('');
F.$floor.val('');
F.$flat.val('');
F.$intercom.val('');
return F.$comment.val('');
},
setPage: function(page) {
$(".page", F.$wrap).hide();
return $(`.page[data-page=${page}]`, F.$wrap).show();
},
open: function() {
$("#confirm_address_wrap").addClass('open');
//$("body").addClass('open_confirm_address')
//A.P.body.css('overflow','hidden');
//A.W.blockScroll()
return A.captcha('parseAddress', function(token) {
var address, s;
address = F.$confirm.data('self_address');
s = {
address,
dataType: "JSON"
};
s._g_token = token;
s.searchSource = 'confirmAddress open';
return API('geocode/parse', s, function(data) {
return $.fn.MAP('makePoint', F.mapID, data.coordinates);
});
});
},
close: function() {
$.fn.CONFIRM2('checkIsAsk');
return $.fn.CONFIRM2('closeModal');
},
//$("#confirm_address_wrap").removeClass('open')
//$("body").removeClass('open_confirm_address')
//A.W.unblockScroll()
chooseSelectedAddress: function() {
var $i, val, x;
$i = $("[name=confirm_address]:checked", F.$wrap);
val = $i.val();
if (val === 'ask') {
return F.setIsAsk();
} else {
x = JSON.parse($i.attr('data-data'));
F.clearData();
F.$address.val(x['address']);
F.$entrance.val(x['entrance']);
F.$floor.val(x['floor']);
F.$flat.val(x['flat']);
F.$intercom.val(x['intercom']);
F.$comment.val(x['comment']);
F.prevAddress = x['address'];
F.warning('');
F.parseAddress(function() {
return A.setCookie('address_id', x['id']);
});
return F.saveInputs();
}
},
chooseSelf: function() {
return F.setIsSelf();
}
};
})(jQuery);
(function($) {
var F;
$.fn.DATES = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.ADDRESS');
}
};
return F = {
init: function() {},
addAddress: function(f) {
var $f, s;
$f = $(f);
s = $f.serializeArray();
API.GET.r('/api/app/addAddress/', s, function(data) {
F.reload();
return A.W.close();
});
return false;
},
editAddress: function(f) {
var $f, s;
$f = $(f);
s = $f.serializeArray();
API.GET.r('/api/app/updateAddress/', s, function(data) {
F.reload();
return A.W.close();
});
return false;
},
save: function() {
var $f, $res, f, s;
f = ($f = $(event.target)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
console.log(s);
if (parseInt(s.id) !== 0) {
API('app/updateDate', s, function(data) {
return F.reload();
});
} else {
API('app/addDate', s, function(data) {
return F.reload();
});
}
//$.fn.SIDEBAR('close')
A.W.close();
return false;
},
open: function(id = 0) {
return A.W.openDate(id);
},
confirmDelete: function(id) {
if (confirm("Вы действительно хотите удалить адрес?")) {
return API('app/removeDate', {
id: id
}, function(data) {
F.reload();
return A.W.close();
});
}
},
initDate: function(i) {
var $t;
// $.fn.DATES(\'confirmDelete\','+i.id+')
$t = $('
' + i.name + '
' + i.fdate + '
');
$t.data('info', i);
return $t;
},
reload: function() {
var $t;
($t = $("#dates")).css({
opacity: 0.5,
'pointer-events': 'none'
});
return API('app/getDates', {
dataType: "JSON"
}, function(data) {
var $res, i, j, len;
$res = [];
if (data.length === 0) {
$t.html('У вас пока нет запомненных дат');
} else {
for (j = 0, len = data.length; j < len; j++) {
i = data[j];
$res.push(F.initDate(i));
}
}
$t.html($res);
// $t.append('
')
return ($t = $("#dates")).css({
opacity: 1,
'pointer-events': 'all'
});
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.DELIVERY_ADDRESS = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.DELIVERY_ADDRESS');
}
};
return F = {
$wrap: null,
$value: null,
$options: null,
$info: null,
$clear: null,
address: null,
mapID: 'yandex_map_delivery',
confirmMapID: 'confirm_map_delivery',
$i_address: null,
$i_entrance: null,
$i_floor: null,
$i_flat: null,
$i_intercom: null,
$i_comment: null,
$saveAddress: null,
$back: null,
$empty: null,
prevAddress: '',
isSelf: false,
isAsk: false,
isWarning: false,
state: 0, // 0 - закрыто; 1 - выбор пунктов меню; 2 - ввод дополнительных данных
chooseAddress: function(x) {
F.address = x;
F.setState(2);
F.$i_address.val(x.value);
F.$i_address.data('changed', false);
F.prevAddress = x.value;
return F.parseAddress();
},
parseAddress: function(cb) {
//A.I.waitButton(F.$saveAddress,'Проверка...')
A.I.waitButton(F.$saveAddress);
return A.captcha('parseAddress', function(token) {
var address, s;
address = F.prevAddress;
s = {
address,
dataType: "JSON"
};
s._g_token = token;
s.searchSource = 'deliveryAddress';
return API('geocode/parse', s, function(data) {
A.I.unwaitButton(F.$saveAddress);
$.fn.MAP('makePoint', F.mapID, data.coordinates);
$.fn.MAP('makePoint', F.confirmMapID, data.coordinates);
if (data.out) {
if (data.warning) {
return F.warning(data.warning.join('
'));
}
} else {
return typeof cb === "function" ? cb() : void 0;
}
});
});
},
warning: function(x) {
F.$error.text(x).show();
return F.isWarning = x !== '';
},
saveAddress: function() {
F.warning('');
if (F.isWarning) {
return null;
}
if (F.address !== null) {
if (F.address.is_house) {
return F.saveInputs();
} else {
return F.warning('Выберите адрес с указанным домом');
}
} else {
if (F.$i_address.data('changed')) {
if (F.prevAddress === F.$i_address.val()) {
return F.saveInputs();
} else {
return F.warning('Выберите адрес с указанным домом');
}
} else {
return F.saveInputs();
}
}
},
clearData: function() {
A.setCookie('address_id', '');
A.setCookie('address', '');
A.setCookie('entrance', '');
A.setCookie('floor', '');
A.setCookie('flat', '');
A.setCookie('intercom', '');
A.setCookie('comment', '');
A.setCookie('ask', '');
A.setCookie('self', '');
F.$wrap.attr('data-self', 0);
F.$wrap.attr('data-ask', 0);
F.isAsk = false;
return F.isSelf = false;
},
saveInputs: function() {
return F.parseAddress(function() {
F.clearData();
A.setCookie('address', F.$i_address.val());
A.setCookie('entrance', F.$i_entrance.val());
A.setCookie('floor', F.$i_floor.val());
A.setCookie('flat', F.$i_flat.val());
A.setCookie('intercom', F.$i_intercom.val());
A.setCookie('comment', F.$i_comment.val());
F.setValue(F.$i_address.val());
return F.close();
});
},
chooseAskReceiver: function() {
F.clearData();
F.isAsk = true;
A.setCookie('ask', 1);
F.$wrap.attr('data-ask', 1);
F.checkCheckboxes();
F.setValue('Уточнить у получателя');
return F.close();
},
chooseSelfDelivery: function() {
F.clearData();
F.isSelf = true;
A.setCookie('self', 1);
F.$wrap.attr('data-self', 1);
F.checkCheckboxes();
F.setValue('Самовывоз');
return F.close();
},
setValue: function(x) {
F.$value.text(x);
F.$value.removeClass('empty');
$(".address_value").text(x);
return $("body").trigger("address.changed");
},
checkCheckboxes: function() {
var address_id;
F.$ask.prop('checked', F.isAsk);
F.$self.prop('checked', F.isSelf);
address_id = A.getCookie('address_id');
$("[data-name=my_address]").prop("checked", false);
if ((address_id != null) && address_id !== '') {
return $(`[data-name=my_address][data-id=${address_id}]`).prop("checked", true);
}
},
isAuth: function() {
return parseInt(F.$wrap.attr('data-auth')) === 1;
},
isAddress: function() {
return F.$i_address.val() !== '';
},
isSearching: function() {
return F.$input[0].value !== '' || F.$input[1].value !== '';
},
toOptions: function() {
F.$input.val('');
return F.setState(1);
},
search: function() {
var $i, val;
F.$error.hide();
F.address = null;
F.$i_address.data('changed', true);
F.setState(F.state);
$i = $(this);
val = $i.val();
return API('dadata/searchAddressForShop', {
q: val,
dataType: 'JSON',
'fid': A.city
}, function(data) {
var i, j, len, results;
F.$results.html('').show();
results = [];
for (j = 0, len = data.length; j < len; j++) {
i = data[j];
if (i.title !== '') {
results.push(F.$results.each(function() {
var $li;
$li = $('
' + i.title + '
' + i.value_app + '
');
$li.data('address', i);
$li.click(function() {
var address;
address = $(this).data('address');
if (address.is_house) {
return F.chooseAddress(address);
} else {
F.$input.val(address.value + " ");
return F.$input.focus();
}
});
return $(this).append($li);
}));
} else {
results.push(void 0);
}
}
return results;
});
},
setState: function(x) {
var isClose, isInfo, isOpen, isOptions;
F.state = x;
isClose = x === 0;
isOpen = !isClose;
isOptions = x === 1;
isInfo = x === 2;
F.$wrap.toggleClass('open', !isClose);
F.$options.toggle(isOptions);
F.$info.toggle(isInfo);
F.$results.toggle(isOptions && F.isSearching());
F.$back.toggle(isInfo);
F.$empty.toggle(!isInfo);
if (x === 2) {
return F.parseAddress();
}
},
chooseMyAddress: function(x) {
F.clearData();
F.$i_address.val(x['address']);
F.$i_entrance.val(x['entrance']);
F.$i_floor.val(x['floor']);
F.$i_flat.val(x['flat']);
F.$i_intercom.val(x['intercom']);
F.$i_comment.val(x['comment']);
F.setState(2);
F.prevAddress = x['address'];
F.checkCheckboxes();
F.warning('');
return F.parseAddress(function() {
A.setCookie('address_id', x['id']);
return F.checkCheckboxes();
});
},
close: function() {
A.W.unblockScroll();
return F.setState(0);
},
open: function() {
$.fn.MAP('init', F.mapID);
A.W.blockScroll();
if (F.isAuth()) {
if (F.state === 0) {
if (F.isAddress()) {
return F.setState(2);
} else {
return F.setState(1);
}
} else {
return F.close();
}
} else {
if (F.state === 0) {
return A.W.openAddressAuth();
} else {
return F.close();
}
}
},
openNoAuth: function() {
A.W.blockScroll();
if (F.isAddress()) {
return F.setState(2);
} else {
return F.setState(1);
}
},
init: function($html) {
if ($(".choose_delivery_modal", $html).length === 0) {
return null;
}
F.$wrap = $(".choose_delivery_modal", $html);
if (F.$wrap.data('inited')) {
return null;
}
F.$wrap.data('inited', true);
F.$value = $(".choose_delivery_wrap .value", $html);
F.$options = $(".choose_delivery_options", $html);
F.$input = $(".search_address_input", $html);
F.$results = $(".delivery_search_result", F.$wrap);
F.$info = $(".input_delivery_info", $html);
F.$i_address = $("[name=address]", F.$wrap);
F.$i_entrance = $("[name=entrance]", F.$wrap);
F.$i_floor = $("[name=floor]", F.$wrap);
F.$i_flat = $("[name=flat]", F.$wrap);
F.$i_intercom = $("[name=intercom]", F.$wrap);
F.$i_comment = $("[name=comment]", F.$wrap);
F.$error = $(".error", F.$wrap);
F.prevAddress = F.$i_address.val();
F.$ask = $("#ask_receiver", F.$wrap);
F.$self = $("#self_delivery", F.$wrap);
F.$saveAddress = $("#save_address", F.$wrap);
F.$back = $(".back", F.$wrap);
F.$empty = $(".empty", F.$wrap);
F.$clear = $(".clear", F.$wrap);
F.isSelf = parseInt(F.$wrap.attr('data-self')) === 1;
F.isAsk = parseInt(F.$wrap.attr('data-ask')) === 1;
F.checkCheckboxes();
F.$value.click(F.open);
F.$input.keyup(F.search);
return F.$clear.click(function() {
return F.$input.val('').keyup();
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.ECOMMERCE = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.ECOMMERCE');
}
};
return F = {
init: function($html) {
var $c, d;
$c = $("#make_order", $html);
if ($c.length > 0) {
d = JSON.parse($c.attr('data-ecom'));
console.log('ecom', d);
F.ecommerce(d);
return A.reach('make_order');
}
},
ecommerce: function(data) {
var s;
window.dataLayer = window.dataLayer || [];
s = {
ecommerce: {
currencyCode: "RUB",
purchase: {
actionField: {
id: data.id
},
products: data.products
}
}
};
return window.dataLayer.push(s);
},
ecommerceAddToCart: function(data) {
var s;
window.dataLayer = window.dataLayer || [];
s = {
ecommerce: {
currencyCode: "RUB",
add: {
products: [data]
}
}
};
console.log('ecommerceAddToCart', s);
return window.dataLayer.push(s);
},
getEcommerceCart: function(data, sum) {
return A.F.ecommerce(data);
}
};
})(jQuery);
(function($) {
var F;
$.fn.FILTER = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.FILTER');
}
};
return F = {
$wrap: null,
$value: null,
$title: null,
$props: null,
$buttons: null,
$value: null,
$submit: null,
$reset: null,
openProp: function() {
var $content, $prop, $t, $title;
$t = $(this);
F.hideAll();
$prop = $t.closest(".prop");
$content = $(".prop_content", $prop);
$title = $(".prop_wrap", $prop);
$prop.show();
$title.hide();
return $content.show();
},
back: function() {
F.$props.show();
F.$title.hide();
F.$content.hide();
F.$title.show();
F.$titles.show();
F.$buttons.show();
return F.$price.show();
},
hideAll: function() {
F.$title.hide();
F.$props.hide();
return F.$buttons.hide();
},
checkValues: function() {
return F.$props.each(function() {
var $t, $value, count, isEmpty;
$t = $(this);
count = $("input:checked", $t).length;
$value = $(".prop_value", $t);
isEmpty = count === 0;
$value.toggleClass('empty', isEmpty);
return $value.text(isEmpty ? 'Выбрать' : 'Выбрано');
});
},
open: function() {
F.$wrap.addClass('open');
F.checkValues();
$("#content1").addClass('z_max');
if (A.isMobile()) {
return A.W.blockScroll();
}
},
close: function() {
F.back();
F.$wrap.removeClass('open');
$("#content1").removeClass('z_max');
if (A.isMobile()) {
return A.W.unblockScroll();
}
},
init: function($html) {
var $wrap;
$wrap = $("#filter_window_wrap_bg", $html);
if ($wrap.length === 0) {
return null;
}
F.$wrap = $wrap;
F.$value = $(".prop_value", F.$wrap);
F.$title = $("#prop_top_title", F.$wrap);
F.$titles = $(".prop_wrap", F.$wrap);
F.$props = $(".prop", F.$wrap);
F.$buttons = $("#filter_buttons", F.$wrap);
F.$back = $(".back", F.$wrap);
F.$content = $(".prop_content", F.$wrap);
F.$price = $("#filter_price_content", F.$wrap);
F.$checkbox = $("input[type=checkbox]", F.$wrap);
F.$close = $(".close", F.$wrap);
F.$submit = $("#submit_filter", F.$wrap);
F.$reset = $("#reset_filter", F.$wrap);
F.$value.click(F.openProp);
F.$back.click(F.back);
F.$checkbox.click(F.checkValues);
F.$close.click(F.close);
F.$submit.click(F.close);
return F.$reset.click(F.close);
}
};
})(jQuery);
(function($) {
var F;
$.fn.FILTER2 = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.FILTER2');
}
};
return F = {
init: function($html) {
return $("#listing_categories .parent", $html).click(function() {
var $t;
$t = $(this);
$t.toggleClass("open");
return $(".subcategories", $t).slideToggle(300);
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.ITEM = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.Item');
}
};
return F = {
clickHover: function(x, id) {
var isParent, link;
isParent = event && (event.target === x || (event.target && event.target.classList && (event.target.classList.contains('description') || event.target.classList.contains('text') || event.target.classList.contains('descr'))));
//console.log('e',isParent,event.target.classList,link)
if (isParent) {
link = $(`.item[data-id=${id}] .variant_link`).attr('href');
return H.go(link);
}
},
init: function($html) {
var $c;
if ($c = $("#b_item", $html).length === 0) {
return false;
}
return $(".chooser_pots", $html).each(function() {
var $opts, $p;
$p = $(this);
$opts = $(".pot_el", $p);
return $opts.click(function() {
var $t, selected;
$t = $(this);
selected = $t.hasClass('selected');
$opts.removeClass("selected");
return $t.toggleClass('selected', !selected);
});
});
}
};
})(jQuery);
var jivo_onLoadCallback;
(function($) {
var F;
$.fn.JIVO = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.JIVO');
}
};
return F = {
init: function() {
console.log('init jivo???');
API("jivo/getData", {
dataType: "JSON"
}, function(data, cd) {
//console.log('jivo/getData',data)
if (data.token) {
//console.log 'setToken',jivo_api.setUserToken(data.token);
jivo_api.setUserToken(data.token);
}
if (data.contact) {
//console.log 'setContactInfo',jivo_api.setContactInfo(data.contact);
return jivo_api.setContactInfo(data.contact);
}
});
return setTimeout(function() {
console.log("jdiv a", $("jdiv a"));
$.fn.ROISTAT('init', $("jdiv"));
return null;
return $("jdiv a").each(function() {
var $t, href, url;
$t = $(this);
href = $t.attr('href');
url = new URL(href);
if (url.hostname === 't.me') {
if (window.roistat) {
url.searchParams.set('start', window.roistat.getVisit());
}
}
return $t.attr('href', url.toString());
});
}, 1000);
}
};
})(jQuery);
jivo_onLoadCallback = function() {
return $.fn.JIVO('init');
};
(function($) {
var F;
$.fn.LOG = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.LOG');
}
};
return F = {
time: Date.now(),
logs: [],
echo: function() {
return console.log(F.logs);
},
start: function() {
F.logs = [];
return F.time = Date.now();
},
add: function(log) {
var diff, t;
t = Date.now();
diff = t - F.time;
F.time = t;
return F.logs.push({
tag: log,
time: diff
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.MAP = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.MAP');
}
};
return F = {
loaded: false,
loading: false,
initMap: function(cb) {
var int, s;
console.log('Map.initMap');
if ($("#map_script").length === 0) {
if (!F.loading) {
F.loading = true;
s = document.createElement('script');
s.setAttribute('id', 'map_script');
document.head.append(s);
s.onload = function() {
console.log('mapLoadededed');
F.loaded = true;
setTimeout(function() {
return cb();
}, 300);
return $("body").trigger('map.loaded');
};
return s.src = 'https://api-maps.yandex.ru/2.1/?lang=ru_RU&apikey=f29f7dee-f218-4f60-afa0-974ada287d37';
}
} else if (F.loaded) {
return int = setInterval(function() {
if (ymaps.Placemark != null) {
clearInterval(int);
return cb();
}
}, 500);
} else {
return $("body").on('map.loaded', function() {
return cb();
});
}
},
resize: function(id) {
return F.init(id, function() {
var $t, map;
$t = $('#' + id);
map = $t.data('map');
if (!$t.data('map')) {
return null;
}
return map.container.fitToViewport();
});
},
makePoint: function(id, coord) {
// console.log('makePoint',id,coord)
if (coord === void 0) {
return null;
}
return F.init(id, function() {
var $t, c, map, mark;
$t = $('#' + id);
map = $t.data('map');
if (!$t.data('map')) {
return null;
}
c = $t.data('coord');
// console.log('Map.makePoint',c,coord)
//if !c || (c[0]!=coord[0] || c[1]!=coord[1])
if (coord[0] === 0 || coord[1] === 0) {
return null;
}
$t.data('coord', coord);
mark = new ymaps.Placemark(coord, {
hintContent: '',
balloonContent: ''
}, {
iconLayout: 'default#image',
iconImageHref: 'https://roots-store.ru/themes/v3/pics/icons/map.point.png',
iconImageSize: [54, 54],
iconImageOffset: [-27, -54]
});
if ($t.data('mark') != null) {
map.geoObjects.remove($t.data('mark'));
}
$t.data('mark', mark);
map.geoObjects.add($t.data('mark'));
return map.setCenter(coord, 16);
});
},
destroy: function(id, cb) {
var $t;
$t = $("#" + id);
if ($t.data('map') !== void 0) {
$t.data('map').destroy();
$t.data('map', void 0);
if (cb != null) {
return cb();
}
}
},
init: function(id, cb) {
var $t;
$t = $("#" + id);
if ($t.length > 0) {
return F.initMap(function() {
var int, map;
if (!$t.data('map')) {
map = new ymaps.Map(id, {
center: [55.753994, 37.622093],
zoom: 11,
controls: []
});
$t.data('map', map);
if (cb != null) {
setTimeout(function() {
return cb();
}, 300);
}
return int = setInterval(function() {
var a;
a = document.getElementById(id);
if (a.offsetParent === null) {
//console.log(a)
map.destroy();
$t.data('map', null);
clearInterval(int);
return $t.html('');
}
// console.log('destroy map')
}, 10000);
} else {
if (cb != null) {
return cb();
}
}
});
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.MENU = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.MENU');
}
};
return F = {
state: 0, // 0 -закрыт, 1 - открыт, 2 - подменю
$toggler: null,
$back: null,
$close: null,
$top: null,
setState: function(x) {
var isClose, isOpen, isSubmenu;
F.state = x;
isClose = x === 0;
isOpen = x === 1;
isSubmenu = x === 2;
F.$top.toggleClass('open', isOpen || isSubmenu);
F.$toggler.toggle(isClose);
F.$close.toggle(isOpen);
F.$back.toggle(isSubmenu);
F.$mainMenu.toggle(isOpen);
return F.subcategories.hide();
},
close: function() {
if (F.state !== 0) {
F.setState(0);
return A.W.unblockScroll();
}
},
open: function() {
F.setState(1);
return A.W.blockScroll();
},
submenu: function(x) {
F.setState(2);
return $(`.subcategories[data-id=${x}]`).show();
},
init: function($html) {
if ($("#b_top2", $html).length === 0) {
return null;
}
F.$top = $("#b_top2", $html);
F.$toggler = $(".toggle_menu_wrap .toggle_menu", F.$top);
F.$close = $(".toggle_menu_wrap .close, #b_menu .close", F.$top);
F.$back = $(".toggle_menu_wrap .back, #b_menu .back", F.$top);
F.$mainMenu = $(".main_menu", F.$top);
F.subcategories = $(".subcategories", F.$top);
$("#b_menu .parent", $html).click(function(e) {
e.originalEvent.preventDefault();
e.originalEvent.stopPropagation();
return F.submenu($(this).attr('data-id'));
});
$("#b_menu a", F.$top).click(function() {
var $p, $t;
$t = $(this);
$p = $t.parent();
if (!$p.hasClass('parent')) {
return F.close();
}
});
F.$toggler.click(function() {
if (F.state === 0) {
return F.open();
} else {
return F.close();
}
});
F.$close.click(function() {
return F.close();
});
return F.$back.click(function() {
var id;
id = $(".subcategories:visible").attr('data-id');
if (id === "houseplant3") {
return F.submenu('houseplant');
} else {
return F.open();
}
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.MINDBOX = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.MINDBOX');
}
};
return F = {
init: function($html) {
console.log('initMindbox');
F.viewProduct($html);
return F.initItems($html);
},
viewProduct: function($html) {
var $c, d, e;
return null;
$c = $("#b_item", $html);
//console.log 'viewProduct',$c
if ($c.length === 0) {
return;
}
try {
d = JSON.parse($c.attr('data-mindbox'));
} catch (error) {
e = error;
}
console.log('viewProduct', d);
d['onSuccess'] = function() {
return console.log('onSuccess');
};
d['onError'] = function(e) {
return console.log('onError', e);
};
return typeof mindbox === "function" ? mindbox("async", d) : void 0;
},
initItems: function($html) {
var $mb, interval;
$mb = $("#mindbox_items", $html);
console.log('initItems', $mb);
if ($mb.length === 0) {
return;
}
return interval = setInterval(function() {
var $c;
$c = $(".popmechanic-js-container");
if ($c.length > 0) {
clearInterval(interval);
return $c.each(function() {
var $p, counter, ids, int;
$p = $(this);
ids = [];
counter = 1;
return int = setInterval(function() {
var $items;
$items = $(".item_async_load", $p);
if ($items.length > 0) {
clearInterval(int);
$(".item_async_load").each(function() {
return ids.push($(this).attr('data-roots-id'));
});
API('item/asyncLoadItems', {ids}, function(data) {
var $data;
$("#item_recommends").remove();
$data = $(data);
$p.replaceWith($data);
return setTimeout(function() {
A.P.initMini($(".popmechanic-loaded"));
return $("[data-popmechanic-embed] a").click(function(e) {
var $id, $t, id;
$t = $(this).closest(".item_slide");
$id = $('[itemprop="productID"]', $t);
id = $id.attr('content').substr(4);
return typeof mindbox === "function" ? mindbox("async", {
operation: "popmechanic-widget-click-96535",
data: {
"clicked": {
"product": {
"ids": {
"Roots": id
}
}
}
},
onSuccess: function() {
return {
onError: function(err) {}
};
}
}) : void 0;
});
}, 10);
});
}
if (counter++ >= 25) {
return clearInterval(int);
}
}, 100);
});
}
}, 25);
}
};
})(jQuery);
(function($) {
var F;
$.fn.ORDER = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.ORDER');
}
};
return F = {
setOrderPayment: function(order, pay) {
console.log('order', order, pay);
return API('application/setPayment', {
order,
pay,
dataType: "JSON"
}, function(data) {
console.log('data', data);
A.W.close();
return window.location.reload();
});
}
};
})(jQuery);
$.extend($, {
Ping: function(url, timeout) {
var timer;
timeout = timeout || 1500;
timer = null;
return $.Deferred(function(defer) {
var cleanup, fail, img, start, success;
img = new Image();
cleanup = function() {
window.clearTimeout(timer);
timer = img = null;
};
success = function(x) {
cleanup();
defer.resolve(x);
};
fail = function() {
cleanup();
defer.reject(false, url, new Date() - start, 'timeout');
};
img.onload = function() {
success(true);
};
img.onerror = function() {
success(false);
};
// onerror is also success, because this means the domain/ip is found, only the image not;
start = new Date();
img.src = url += '?cache=' + +start;
timer = window.setTimeout((function() {
fail();
}), timeout);
}).promise();
}
});
// ---
// generated by js2coffee 2.2.0
(function($) {
var F;
$.fn.PROFILE = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.PROFILE');
}
};
return F = {
time_wait: 180,
timeout: null,
sms_id: 0,
email_id: 0,
init: function($html) {
var $foreign;
$foreign = $("#foreign_phone", $html);
if ($foreign.length > 0) {
$foreign.on('change', F.checkPhoneForeign);
return F.checkPhoneForeign();
}
},
checkPhoneForeign: function() {
var isForeign;
isForeign = !$("#foreign_phone").is(':checked');
if (isForeign) {
return $("input.phone").mask(A.phone_mask);
} else {
return $("input.phone").unmask();
}
},
accept_email: function(btn) {
var $btn;
$btn = $(btn);
A.I.waitButton($btn);
console.log('accept_email');
return API('account/send_accept_email', {}, function(data, cd) {
return $btn.replaceWith('
На вашу почту отправлено письмо с подтверждением.
');
});
},
// НАЧАЛО ВОССТАНОВЛЕНИЕ ПАРОЛЯ
send_email_code: function() {
var $res, s;
s = {
dataType: "JSON",
email: $("[data-name=email] input").val()
};
$res = $("#code_res").hide();
return API('email_code/check_email', s, F.getEmailCode, {});
},
getEmailCode: function(data, cd) {
var $res;
console.log(data);
$res = $("#code_res");
A.notify($res, data.m);
$res.toggleClass('error', data.e === 1);
$res.toggleClass('gray', data.e !== 1);
if (data.e === 0) {
F.email_id = data.email_id;
clearTimeout(F.timeout);
F.time = F.time_wait;
F.timeout = setInterval(F.timer, 1000);
F.timer();
$("[data-name=email] input").prop("disabled", true);
$("#check_email").hide();
$("#code_email").show();
$("#send_again").show();
$("#code_email").removeClass('dn');
return $("#check_code").removeClass('dn');
}
},
check_email_code: function() {
var $res, s;
s = {
dataType: "JSON",
code: $("[data-name=code] input").val(),
email_id: F.email_id
};
$res = $("#code_res").hide();
return API('email_code/check_code', s, function(data, cd) {
console.log('check_email_code', data);
$res = $("#code_res");
A.notify($res, data.m);
$res.toggleClass('error', data.e === 1);
$res.toggleClass('gray', data.e !== 1);
if (data.e === 0) {
$("#email_info").html(data.info);
$("#new_pass").removeClass("dn");
clearTimeout(F.timeout);
$("#email_wrap").remove();
$("#b_guest [data-name=id]").val(data.id);
$("#b_guest [data-name=key]").val(data.key);
return $("#b_guest [data-name=hash]").val(data.hash);
}
}, {});
},
// НАЧАЛО СМС
time: 0,
timer: function() {
var isEnd, m, s, t;
F.time--;
isEnd = F.time <= 0;
$("#send_again").toggleClass('white', isEnd);
$("#send_again").toggleClass('dark_gray', !isEnd);
$("#send_again").prop('disabled', !isEnd);
if (isEnd) {
return $("#time_sms").text('');
} else {
m = Math.floor(F.time / 60);
s = F.time % 60;
t = "" + m + ':' + (s < 10 ? 0 : '') + s;
return $("#time_sms").text(t);
}
},
accept_phone: function() {
var $c, $res, s;
s = {
dataType: "JSON",
code: $('[data-name=code] input').val(),
sms_id: F.sms_id
};
if (($c = $("#foreign_phone")).length > 0) {
s['foreign'] = $c.is(':checked') ? 1 : 0;
}
$res = $("#res_phone_accept").hide();
return A.captcha('accept_phone', function(token) {
s._g_token = token;
return API('sms_code/accept_phone', s, function(data, cd) {
if (data.m) {
A.notify($res, data.m);
$res.toggleClass('error', data.e === 1);
$res.toggleClass('gray', data.e !== 1);
}
if (data.e === 0) {
$("#send_code").hide();
// $("#time_sms").hide()
$("#send_again").hide();
$("#btn_phone_accept").hide();
$("#phone_wrap").removeClass('c-2-3');
return clearTimeout(F.timeout);
}
});
});
},
get_code_for_phone: function() {
var $res, s;
s = {
dataType: "JSON",
phone: $('[data-name=phone] input').val()
};
$res = $("#res_phone_accept").hide();
if (!s.phone) {
return A.notify($res, "Укажите номер телефона");
} else {
return A.captcha('get_code_for_phone', function(token) {
s._g_token = token;
return API('sms_code/code_for_phone', s, F.aSendSmsInProfile, {
r: $res
});
});
}
},
init_auth_by_sms: function() {},
send_sms_again: function() {
var $res;
clearTimeout(F.timeout);
$res = $("#sms_res").hide();
return A.captcha('send_sms_again', function(token) {
var s;
s = {};
s._g_token = token;
s.phone = $("#sms_phone").val();
s.dataType = "JSON";
return API('sms_code/check_phone', s, F.aSendSms, {
r: $res
});
});
},
send_sms_again_in_profile: function() {
var $res;
clearTimeout(F.timeout);
$res = $("#sms_res").hide();
return A.captcha('send_sms_again_in_profile', function(token) {
var s;
s = {};
s._g_token = token;
s.phone = $('[data-name=phone] input').val();
s.dataType = "JSON";
return API('sms_code/code_for_phone', s, F.aSendSmsInProfile, {
r: $res
});
});
},
aSendSmsInProfile: function(data, cd) {
console.log('aSendSmsInProfile', data);
if (data.sms_id) {
F.sms_id = data.sms_id;
$("#send_code").show();
$("#btn_phone_accept").hide();
$("#send_again").show();
clearTimeout(F.timeout);
F.time = F.time_wait;
F.timeout = setInterval(F.timer, 1000);
F.timer();
}
if (data.m) {
A.notify(cd.r, data.m);
cd.r.toggleClass('error', data.e === 1);
return cd.r.toggleClass('gray', data.e !== 1);
}
},
aSendSms: function(data, cd) {
console.log('aSendSms', data);
if (data.sms_id) {
F.sms_id = data.sms_id;
$("#send_again").show();
$("#sms_phone").prop('disabled', true);
$("#send_sms_code").hide();
$("#auth_by_sms").show();
$("#sms_code").show();
clearTimeout(F.timeout);
F.time = F.time_wait;
F.timeout = setInterval(F.timer, 1000);
F.timer();
}
if (data.m) {
A.notify(cd.r, data.m);
cd.r.toggleClass('error', data.e === 1);
return cd.r.toggleClass('gray', data.e !== 1);
}
},
send_sms_code: function() {
var $f, $res, f, s;
f = ($f = $("#form_auth_by_sms")).FORM();
s = f.json();
s.sms_id = F.sms_id;
s.dataType = "JSON";
$res = $("#sms_res", $f).hide();
clearTimeout(F.timeout);
$("#send_again").hide();
return f.validate({
success: function() {
return A.captcha('check_sms', function(token) {
s._g_token = token;
console.log('s', s);
return API('sms_code/check_phone', s, F.aSendSms, {
f: $f,
r: $res
});
});
}
});
},
auth_by_sms: function(f) {
var $f, $res, s;
f = ($f = $(f)).FORM();
s = f.json();
s.dataType = "JSON";
s.sms_id = F.sms_id;
$res = $("#sms_res", $f).hide(300);
f.validate({
success: function() {
return API('sms_code/login', s, F.aAuth, {
f: $f,
r: $res
});
}
});
return false;
},
// КОНЕЦ СМС
login: function(f) {
var $f, $res, s;
f = ($f = $(f)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
f.validate({
success: function() {
return API('account/login', s, F.aAuth, {
f: $f,
r: $res
});
}
});
return false;
},
exit: function() {
A.setCookie('uid', '---');
A.setCookie('uim', '---');
return window.location.href = "/";
},
update_student: function(f) {
var $f, $res, s;
f = ($f = $(f)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
s.country = $("#country").data('value');
s.city = $("#city").data('value');
s.course_target = $("#course_target").data('value');
s.course_who = $("#course_who").data('value');
f.validate({
success: function() {
return API("account/updateStudent", s, function(data, cd) {
console.log(data);
A.I.unwaitButton($("button", cd.f));
A.I.unwaitInput($("input[type=submit]", cd.f));
if (data.e === 1) {
return A.notify(cd.r, data.m);
} else {
return A.reload();
}
}, {
f: $f,
r: $res
});
}
});
return false;
},
reg: function(f) {
var $f, $res, s;
f = ($f = $(f)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
if (($("#country").length)) {
s.country = $("#country").data('value');
s.city = $("#city").data('value');
s.course_target = $("#course_target").data('value');
s.course_who = $("#course_who").data('value');
A.reach('school_reg');
}
f.validate({
success: function() {
if (A.isLocal()) {
return API("account/uadd", s, F.aAuth, {
f: $f,
r: $res
});
} else {
//grecaptcha.ready ->
// grecaptcha.execute('6LdWc9oUAAAAABOi5jw_oZV43S2KLBUa3Z6KJnBj', {action: 'login'}).then (token) ->
// s._g_token = token;
return API("account/uadd", s, function(data, cd) {
//console.log data
return F.aAuth(data, cd);
}, {
f: $f,
r: $res
});
}
}
});
//window.location.reload()
return false;
},
aAuth: function(data, cd) {
var url;
A.I.unwaitButton($("button", cd.f));
A.I.unwaitInput($("input[type=submit]", cd.f));
A.notify(cd.r, data.m);
if (data.e === 1) {
A.notify(cd.r, data.m);
cd.r.toggleClass('error', data.e === 1);
return cd.r.toggleClass('gray', data.e !== 1);
} else {
A.tiktok('Registration');
if (data.p !== void 0) {
A.setCookie('uid', data.p.uid);
A.setCookie('uim', data.p.uim);
}
url = new URL(window.location.href);
if (url.searchParams.get('favorite')) {
return API('favorite/toggle', {
id: url.searchParams.get('favorite'),
dataType: "JSON"
}, function(data, cd) {
//console.log(data)
return window.location.href = "/personal/favorite/";
});
} else {
return A.reload();
}
}
},
remind: function(f) {
var $f, $res, s;
f = ($f = $(f)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
f.validate({
success: function() {
return API('account/remind', s, function(data) {
return $res.html(data.m).show(300);
});
}
});
return false;
},
new_pass: function(f) {
var $f, $res, s;
f = ($f = $(f)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".result", $f).hide().html('');
if (s.pass1 !== s.pass2) {
A.notify($res, "Пароли не совпадают");
} else {
f.validate({
success: function() {
return API('account/newpass', s, function(data) {
console.log(data);
$res.html(data.m).show();
$res.toggleClass('error', data.e === 1);
return $res.toggleClass('gray', data.e !== 1);
});
}
});
}
//if data.e==0
// setTimeout(->
// window.location.reload()
// ,3000)
return false;
},
update: function() {
var $f, $res, f, s;
f = ($f = $(event.target)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
s.is_push = $("#is_push").is(":checked") ? 1 : 0;
f.validate({
success: function() {
return API('account/uupdate', s, function(data) {
if (data.e === 1) {
return $res.html(data.m).show(300);
} else {
$res.html("Успешно сохранено").show(300);
return setTimeout(H.reload, 2000);
}
});
}
});
return false;
},
resetPass: function() {
var $f, $res, f, s;
f = ($f = $(event.target)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
f.validate({
success: function() {
if (s.pass1 !== s.pass2) {
return $res.html("Новые пароли не совпадают").show(300);
} else {
return API('account/resetpass', s, F.aResetPass, {
f: $f,
r: $res
});
}
}
});
return false;
},
aResetPass: function(data, cd) {
A.I.unwaitButton($("button", cd.f));
A.I.unwaitInput($("input[type=submit]", cd.f));
A.notify(cd.r, data.m);
if (data.uim !== void 0) {
return A.setCookie('uim', data.uim);
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.PROMO = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.PROMO');
}
};
return F = {
init: function() {},
close: function(x) {
$(`#promo_${x}`).removeClass('show');
$("#content1").css('z-index', 0);
setTimeout(function() {
return $(`#promo_${x}`).remove();
}, 1000);
return null;
switch (x) {
case "app":
$("#promo_app").removeClass('show');
return setTimeout(function() {
return $("#promo_app").remove();
}, 1000);
}
},
show: function() {
var $a, $c, $cc, x;
if (window.location.pathname.indexOf('cart') > -1 || window.location.pathname.indexOf('confirm') > -1) {
return null;
}
x = '';
$cc = $(".promo_wrap");
if ($cc.length > 0) {
x = $cc.attr('data-promo');
console.log('show', x);
$("#content1").css('z-index', 100);
} else {
return null;
}
if (($c = $(`#promo_${x}`)).length > 0) {
A.setCookie('show_promo_' + x, 1, new Date().getTime() + 24 * 60 * 60 * 1000);
$c.addClass('show');
A.reach(`show_promo_${x}`);
}
return null;
switch (x) {
case "app":
if (($c = $("#promo_app")).length > 0) {
A.setCookie('show_promo_' + x, 1, new Date().getTime() + 24 * 60 * 60 * 1000);
$c.addClass('show');
A.reach('show_promo_app');
return $a = $("a", $c);
}
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.ROISTAT = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.ROISTAT');
}
};
return F = {
visit: null,
init: function($html) {
return F.replace($html);
},
replace: function($html) {
console.log('replace roistat_visit', $('a.roistat', $html), F.visit);
if (F.visit !== null) {
$('a.roistat', $html).each(function() {
var $t;
$t = $(this);
return $t.attr('href', $t.attr('href').replace('roistat_visit', F.visit));
});
$("a[href*='https://api.whatsapp.com/']").each(function() {
var $t, a;
$t = $(this);
a = new URL($t.attr('href'));
a.searchParams.set('text', 'Обязательно отправьте это сообщение и дождитесь ответа. Ваш номер: ' + F.visit);
return $(this).attr('href', a.toString());
});
return $("a[href*='https://t.me/']").each(function() {
var $t, a;
$t = $(this);
a = new URL($t.attr('href'));
a.searchParams.set('start', F.visit);
return $(this).attr('href', a.toString());
});
}
},
// Обязательно отправьте это сообщение и дождитесь ответа. Ваш номер: 1817695
loaded: function(x) {
F.visit = window.roistat.getVisit();
return $.fn.ROISTAT('init', A.P.$body);
},
finger: function() {
var ref;
return (ref = window.roistat) != null ? ref.sendDeviceFingerprint() : void 0;
}
};
})(jQuery);
window.onRoistatAllModulesLoaded = function() {
console.log('onRoistatAllModulesLoaded??');
return window.roistat.registerOnVisitProcessedCallback(function() {
console.log("Установлен номер визита: " + window.roistat.getVisit());
return $.fn.ROISTAT('loaded');
});
};
(function($) {
var F;
$.fn.SALE_NINJA = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.SALE_NINJA');
}
};
return F = {
getItems: async function(placeId, callback) {
var ids, mapIds, unsubscribe;
ids = [];
mapIds = {};
return unsubscribe = (await ninja('onProductRecommendations', {
placementId: placeId,
handler: function({status, items, trackClick}) {
var i, itemId, j, len;
console.log(status, items);
for (j = 0, len = items.length; j < len; j++) {
i = items[j];
itemId = i.externalItemId.substr(4);
mapIds[itemId] = i.projectProductId;
ids.push(i.externalItemId.substr(4));
}
console.log(ids);
ids = ids.splice(0, 4);
return API('item/getListItemByIds', {
ids,
dataType: 'json'
}, function(data) {
var $data;
$data = $(data['html']);
A.P.initMini($data);
$data.click(function() {
return trackClick({
externalItemId: 'item' + $(this).attr('data-id')
});
});
return callback($data);
});
}
}));
},
// trackClick({ projectProductId: item.projectProductId })
init: function($html) {
F.init_1($html); // лучшее по всему каталогу - главная страница вместо популярного
F.init_2($html); // дополнение к товару - в карточке товара внизу. Там сейчас "новинки" и "вам подойдет". Вместо новинок
F.init_3($html); // альтернатива товару - в карточке товара внизу. Там сейчас "новинки" и "вам подойдет". Вместо "вам подойдет"
F.init_4($html); // дополнение к корзине - в корзине
F.init_5($html); // личная подборка посетителя - в карточке товара. Третьей строкой добавляем "вы смотрели"
return F.init_8($html); // популярное без истории - в карточку товара вместо личной подборки
},
init_1: function($html) {
if ($("#popular_catalogs", $html).length === 0) {
return;
}
return F.getItems('64cb30e3-3abe-4804-8833-c6950b60df3e', function($items) {
return $(".popular_catalog[data-counter=1]").html($items);
});
},
init_2: function($html) {
if ($("#item_recommends", $html).length === 0) {
return;
}
return F.getItems('80f6e5d0-9f7d-4bb4-96a9-902863739d28', function($items) {
return $("#item_recommends.popular_catalog", $html).html($items);
});
},
init_3: function($html) {
if ($("#b_main_new", $html).length === 0) {
return;
}
return F.getItems('ff429b98-a6a8-4108-8ca1-f290c3dbd89b', function($items) {
return $("#b_main_new .popular_catalog").html($items);
});
},
init_4: function($html) {
if ($("#cart_reccomend", $html).length === 0) {
return;
}
return F.getItems('318fee68-5191-4045-a642-3824c7056153', function($items) {
return $("#cart_reccomend").html($items);
});
},
init_5: function($html) {
if ($("#item_views_wrap", $html).length === 0) {
return;
}
return F.getItems('aa2fc3cd-3975-4a5a-a99c-93da93a7417a', function($items) {
if ($items) {
$("#item_views_wrap").removeClass('dn');
return $("#item_views_wrap .catalog").html($items);
}
});
},
init_8: function($html) {
return false;
return F.getItems('177936e5-14c7-4187-820a-78640ca4fa2b', function($items) {
return $(".popular_catalog").html($items);
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.SBER = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.SBER');
}
};
return F = {
init: function() {},
sberpay: function(urls) {
var e, i, len, url;
e = 0;
for (i = 0, len = urls.length; i < len; i++) {
url = urls[i];
window.location.href = url;
e++;
}
if (e === urls.length) {
return window.location.href = "https://www.sberbank.ru/ru/person/payments/online_sberpay";
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.SCHOOL = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.SCHOOL');
}
};
return F = {
video: null,
script: null,
loadedScript: false,
loadPlayer: function(cb) {
if (F.loadedScript) {
return cb();
} else {
F.script = document.createElement('script');
F.script.async = true;
F.script.onload = function() {
return cb();
};
document.head.appendChild(F.script);
return F.script.src = '/lib/js/playerjs.js';
}
},
//
clearVideo: function() {
if (F.video !== null) {
F.video.api("destroy");
return console.log("destroy video");
}
},
init: function($html) {
var $players;
console.log("initVideo");
if (A.isVideoPlayer) {
if (!$html) {
$html = $("body");
}
$players = $(".video_player", $html);
if ($players.length > 0) {
return F.loadPlayer(function() {
return $players.each(function() {
var $t, id, o;
$t = $(this);
if (!$t.data('video')) {
$t.data('video', true);
id = $t.attr("id");
o = {
'id': id,
'poster': $t.attr('data-poster'),
'file': $t.attr('data-file'),
'qualities': $t.attr('data-qualities'),
'default_quality': '1080p'
};
console.log(o);
return F.video = new Playerjs(o);
}
});
});
}
}
},
lessonView: function(lesson_id, student_id) {
console.log('lessonView', lesson_id, student_id);
return API('student/lessonView', {
lesson: lesson_id,
student: student_id
}, function(data) {
return console.log(data);
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.SEARCH = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.SEARCH');
}
};
return F = {
$block: null,
$toggle: null,
$results: null,
$close: null,
$input: null,
state: 0,
open: function() {
return F.setState(1);
},
close: function() {
return F.setState(0);
},
search: function() {
var v;
F.open();
v = F.$input.val();
F.$results.html('
');
if (v !== '') {
return API('item/search', {
s: v
}, function(data, cd) {
var $data;
if (cd['value'] === F.$input.val()) {
$data = $(data);
A.P.initMini($data);
return F.$results.html($data);
}
}, {
value: v
});
} else {
return F.$results.html('');
}
},
isSearching: function() {
return F.$input.val() !== '';
},
setState: function(x) {
var isOpen;
F.state = x;
isOpen = x === 1;
F.$block.toggleClass('open', isOpen);
return F.$results.toggleClass('open', isOpen && F.isSearching());
},
init: function($html) {
if ($("#b_search", $html).length === 0) {
return null;
}
F.$block = $("#b_search", $html);
F.$toggle = $("#b_top2 .search", $html);
F.$close = $("#b_search .close", $html);
F.$results = $("#search_results", $html);
F.$input = $("#search_inpu", $html);
F.$toggle.click(F.open);
F.$close.click(F.close);
return F.$input.keyup(F.search);
}
};
})(jQuery);
(function($) {
var F;
$.fn.SHOP = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.SHOP');
}
};
return F = {
confirmData: null,
sbol_script: null,
isAsk: function() {
return parseInt($("#b_confirm").attr('data-is_ask')) === 1;
},
isSelf: function() {
return parseInt($("#b_confirm").attr('data-is_self')) === 1;
},
isKm: function() {
return parseInt($("#b_confirm").attr('data-km')) > 0;
},
isMeReceiver: function() {
return $("#send_to_me input").is(':checked') && !F.isSelf();
},
isOtherReceiver: function() {
var isMe;
isMe = $("#send_to_me input").is(':checked');
if (F.isSelf()) {
isMe = true;
}
if (F.isAsk()) {
isMe = false;
}
return !isMe;
},
kmPrice: function() {
return parseInt($("#b_confirm").attr('data-km'));
},
check: function() {
var $comment, isAsk, isSelf, kmPrice;
isAsk = F.isAsk();
isSelf = F.isSelf();
kmPrice = F.kmPrice();
$("[data-name=km]").toggle(parseInt(kmPrice) > 0);
$("#send_to_me").toggle(!isAsk);
if (isAsk) {
$("[data-name=send_to_me] input").prop("checked", true).click();
}
$("#anonymous_wrap").toggle(!isSelf);
$(".no_self").toggle(!isSelf);
$("#confirm_map_delivery").toggle(!isSelf && !isAsk);
$comment = $("#b_confirm [data-name=comment]");
if (isSelf) {
return $("#comment_self").append($comment);
} else {
return $("#comment_no_self").append($comment);
}
},
init: function($html) {
var $askReceiver, checked;
if ($("#b_confirm").length > 0) {
if ($("#b_confirm", $html).data('init')) {
return null;
}
$("#b_confirm", $html).data('init', true);
if (!F.sbol_script) {
//console.log('F.sbol_script')
F.sbol_script = document.createElement('script');
F.sbol_script.onerror = function() {
return $(".payment_wrap[data-type=7]").hide();
};
F.sbol_script.onload = function() {};
//F.sbol_script.src = 'https://securepayments.sberbank.ru/payment/modules/sbol-pay/sbol-pay.js'
F.sbol_script.src = 'https://securecardpayment.ru/payment/modules/sbol-pay/sbol-pay.js';
document.head.append(F.sbol_script);
}
}
if (!A.isMobile()) {
$(".item_info_content .accordion_wrap ", $html).click(function() {
var $info, $t, cont;
$t = $(this);
//console.log 'click'
$info = $(".item_info_content");
cont = $info[0];
return cont.scrollTo({
top: $t.offset().top,
behavior: 'smooth'
});
});
}
$("[data-name=send_to_me] input", $html).click(function() {
var checked;
checked = $(this).is(":checked");
$(".anonymous_wrap").toggle(!checked);
$("[data-name='receiver_name']").toggle(!checked);
$("[data-name='receiver_phone']").toggle(!checked);
$("#confirm_addresses").toggle(!checked);
if ($("[data-name='ask_receiver'] input").is(":checked")) {
$("[data-name='ask_receiver'] input").click();
}
//$("[data-name='ask_receiver']").parent().parent().toggle(!checked)
return console.log('send_to_me_click???');
});
//$("[data-name='receiver_name'] input").val("")
//$("[data-name='receiver_phone'] input").val("")
$askReceiver = $("[data-name=ask_receiver] input", $html);
if ($askReceiver.length > 0) {
$askReceiver.click(function() {
var checked;
checked = $(this).is(":checked");
return $(".ask_receiver").toggle(!checked);
});
checked = $askReceiver.is(":checked");
$(".ask_receiver").toggle(!checked);
}
$("#km", $html).change(function() {
var max, val;
val = parseInt($(this).val());
if (isNaN(val)) {
val = 0;
}
max = parseInt($(this).attr('max'));
//console.log('km',val,max)
if (max > 0 && val > max) {
return $(this).val(max).change();
}
});
$("[data-name=is_org] input", $html).click(function() {
return $(".is_org").toggleClass('dn', !F.isOrg());
});
F.remathConfirm();
return F.check();
},
isOrg: function() {
return parseInt($("[data-name=is_org] input:checked").val()) === 1;
},
favoritePlant: function() {
var $t, id;
$t = $(this);
id = $t.attr('data-id');
//console.log(id)
$t.prop('disabled', true);
return API('favorite/toggle', {
id,
dataType: "JSON"
}, function(data, cd) {
var $btn, favorites, i, j, len, x;
$t.prop('disabled', false);
if (data.link) {
A.W.openAuth();
} else {
//H.go(data.link)
$t.toggleClass('selected', data.favorited);
}
$btn = $t.data('parent');
$btn.toggleClass('favorited', $("#favorites .el.selected").length > 0);
favorites = JSON.parse($btn.attr('data-favorites'));
for (j = 0, len = favorites.length; j < len; j++) {
i = favorites[j];
x = $(`#favorites .el[data-id=${i.id}]`);
i.favorite = x.hasClass('selected');
}
return $btn.attr('data-favorites', JSON.stringify(favorites));
});
},
favorite: function(id, btn) {
var $btn, $el, $f, e, favorites, i, j, len, results;
event.stopPropagation();
event.preventDefault();
$btn = $(btn);
try {
favorites = JSON.parse($btn.attr('data-favorites'));
if (favorites) {
$("#favorites_wrap").addClass('open');
$("#favorite_title").text($btn.attr('data-title'));
$f = $("#favorites");
$f.html('');
results = [];
for (j = 0, len = favorites.length; j < len; j++) {
i = favorites[j];
$el = $('
' + i.size + '
');
$el.click(F.favoritePlant);
$el.data('parent', $btn);
results.push($f.append($el));
}
return results;
} else {
$btn.prop('disabled', true);
return API('favorite/toggle', {
id,
dataType: "JSON"
}, function(data, cd) {
$btn.prop('disabled', false);
if (data.link) {
return A.W.openAuth();
} else {
//H.go(data.link)
return $btn.toggleClass('favorited', data.favorited);
}
});
}
} catch (error1) {
e = error1;
return console.warn(e);
}
},
promo: function(f) {
var $f, $res, s;
f = ($f = $(f)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
f.validate({
success: function() {
return API('cart/addPromo', s, function(data) {
//console.log('data',data)
if (data.e === 0) {
$f.replaceWith('
Промокод успешно применён
');
return $.fn.SIDEBAR('cart');
} else {
return A.notify($res, data.m);
}
});
}
});
return false;
},
updateTotals: function(cb = null) {
return API('cart/my_cart_total', {
dataType: "JSON"
}, function(data) {
var i, isEmptyCart;
//console.log data
isEmptyCart = data.citems_count === 0;
for (i in data.totals) {
$(`#item_total_${i}`).html(data.totals[i]);
}
$("#cart_total").html(data.total);
$(".top_total_count").html(data.citems_count).toggleClass('hide', isEmptyCart);
$(".empty_cart").toggle(isEmptyCart);
$(".no_empty_cart").toggle(!isEmptyCart);
$("#b_confirm").attr('data-total', data.sum);
$("#b_confirm").attr('data-cert_minus', data.cert_minus);
$("#b_confirm").attr('data-cert_free', data.cert_free);
$("#b_confirm").attr('data-cert_left', data.cert_left);
$("#b_confirm2").data('total', data.sum);
$("#b_confirm2").data('cert_minus', data.cert_minus);
$("#b_confirm2").data('cert_free', data.cert_free);
$("#b_confirm2").data('cert_left', data.cert_left);
$(".cert_free").text(data.cert_free);
$(".cart_top").toggleClass('fill', !isEmptyCart);
F.remathConfirm();
if (cb) {
return cb(data);
}
});
},
chooseCard: function(type) {
var card;
card = $(`.variant_wrap[data-card-type=${type}] .owl-item.active`).text();
$("[data-name='card'] textarea").val(card.substr(1, card.length - 2));
return $(".card_content_wrap").removeClass('open');
},
remathConfirm: function() {
var $km, cert_free, cert_left, cert_minus, cert_minus_total, currency, delivery, delivery_total, isSale, km, km_price, km_print, km_total, o, percent, total, total_old;
if ($("#b_confirm").length === 0) {
return null;
}
total = parseFloat($("#b_confirm").attr('data-total'));
total_old = parseFloat($("#b_confirm").attr('data-old'));
delivery = parseFloat($("#b_confirm").attr('data-delivery'));
cert_minus = parseFloat($("#b_confirm").attr('data-cert_minus'));
cert_free = parseFloat($("#b_confirm").attr('data-cert_free'));
cert_left = parseFloat($("#b_confirm").attr('data-cert_left'));
km_price = parseFloat($("#b_confirm").attr('data-km'));
currency = parseFloat($("#b_confirm").attr('data-currency'));
o = currency === 1 ? 0 : 2;
total = parseFloat((total / currency).toFixed(o));
total_old = parseFloat((total_old / currency).toFixed(o));
delivery = parseFloat((delivery / currency).toFixed(o));
cert_minus = parseFloat((cert_minus / currency).toFixed(o));
cert_free = parseFloat((cert_free / currency).toFixed(o));
cert_left = parseFloat((cert_left / currency).toFixed(o));
km_price = parseFloat((km_price / currency).toFixed(o));
km = 0;
km_total = 0;
km_print = 0;
delivery_total = delivery;
cert_minus_total = cert_minus;
if (($km = $("#km")).length > 0) {
km = parseFloat($km.val());
if (isNaN(km)) {
km = 0;
}
km_total += km_price * km;
}
km_print = km_total;
cert_left -= delivery_total;
if (cert_left < 0) {
cert_minus_total += delivery_total + cert_left;
delivery_total = -cert_left;
} else {
cert_minus_total += delivery_total;
delivery_total = 0;
cert_left -= km_total;
if (cert_left < 0) {
cert_minus_total += km_total + cert_left;
km_total = -cert_left;
} else {
cert_minus_total += km_total;
km_total = 0;
}
}
$(".cert_wrap").toggle(cert_free > 0);
total += delivery_total + km_total - cert_minus;
total_old += delivery_total + km_total - cert_minus;
percent = ((1 - (total / total_old)) * 100).toFixed(0);
$(".confirm_total").text(total.toFixed(o));
$(".confirm_old").text(total_old.toFixed(o));
$(".confirm_total_wihtout_delivery").text((total - delivery_total).toFixed(o));
//$(".delivery_total").text(delivery_total)
$(".delivery_total").text(delivery.toFixed(o));
//$(".km_total").text(km_total)
$(".km_total").text(km_print.toFixed(o));
$(".cert_minus").text(cert_minus_total.toFixed(o));
$(".cert_left").text(Math.max(0, cert_left).toFixed(o));
isSale = total_old > total;
$(".old_price").toggle(isSale);
return $(".old_percent").text(percent + '%');
},
setConfirmAddress: function(x) {
console.log('setConfirmAddress', x);
$(".card_content_wrap").removeClass('open');
if ($("[data-name='receiver_name'] input").is(":visible")) {
$("[data-name='receiver_name'] input").val(x.name);
}
if ($("[data-name='receiver_phone'] input").is(":visible")) {
$("[data-name='receiver_phone'] input").val(x.phone);
}
$("[data-name='flat'] input").val(x['flat']);
$("[data-name='entrance'] input").val(x['entrance']);
$("[data-name='floor'] input").val(x['floor']);
$("[data-name='intercom'] input").val(x['intercom']);
$("[data-name='comment'] textarea").val(x['comment']);
$("[data-name='address'] input").val(x.address);
$.fn.SIDEBAR('setAddress', x);
$.fn.SIDEBAR('setAddressChoosed', true);
return $.fn.SIDEBAR('checkDelivery');
},
getMyCartConfirmList: function() {
return API('cart/getMyCartConfirmList', {
dataType: "JSON"
}, function(data) {
var $data;
$data = $(data.items);
A.P.initMini($data);
return $(".cart_items").html($data);
});
},
setStep: function(x) {
var s;
if (x === 'payment') {
//initGoogleCaptcha()
$(".step_dot").removeClass('now').addClass('selected');
$(".step_dot:eq(2)").addClass('now');
$(".step_dot").last().removeClass('selected');
$(".steps_line").addClass('step3_4').removeClass('step2_4');
A.reach('payment_step');
s = F.getCartData();
s.dataType = "JSON";
API('cart/get_payments', s, function(data, cd) {
var $html, $inp;
console.log('hello', data);
$html = $(data.html);
A.P.initMini($html);
$("#payment_types").html($html);
$inp = $("#payment_types input");
if ($inp.length === 1) {
return $inp.click();
}
});
}
$(".step").hide();
$(`.step[data-step='${x}']`).show();
A.P.scrollToAnimate(0);
if (x === 'delivery') {
if (A.isPad()) {
$("#mob_to_payment").show();
}
}
if (x === 'payment') {
if (A.isPad()) {
$("#mob_confirm").show();
return $("#mob_to_payment").hide();
}
}
},
feedback: function(f) {
var $f, $res, s;
f = ($f = $(f)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
s.management = $("#feedback_management").attr('data-value');
s.floristics = $("#feedback_floristics").attr('data-value');
s.delivery = $("#feedback_delivery").attr('data-value');
f.validate({
success: function() {
return API('order/feedback', s, function(data) {
return $f.replaceWith('
Спасибо
');
});
}
});
return false;
},
coupon: function() {
var $b, $res, coupon;
coupon = $("#coupon").val();
A.I.waitButton($b = $(event.target));
$res = $("#res_coupon").hide(300);
return API('cart/add_coupon', {
dataType: "JSON",
coupon
}, F.aAddCoupon, {
b: $b,
res: $res,
coupon
});
},
remove_coupon: function() {
var $b, $res, coupon;
coupon = $("#coupon").val();
A.I.waitButton($b = $(event.target));
$res = $("#res_coupon").hide(300);
return API('cart/remove_coupon', {coupon}, F.aRemoveCoupon, {
b: $b,
res: $res,
coupon
});
},
aRemoveCoupon: function(data, cd) {
$("#coupon_wrap").replaceWith('
');
return F.updateTotals();
},
aAddCoupon: function(data, cd) {
if (typeof data === 'string') {
data = JSON.parse(data);
}
A.I.unwaitButton(cd.b);
if (data.e !== 0) {
return A.notify(cd.res, data.m);
} else {
$("#coupon_wrap").replaceWith('
Промокод: ' + cd.coupon + '
');
return F.updateTotals();
}
},
echoConfirmData: function() {
return F.confirmData;
},
payment: function() {
var $b, $res, s, val;
$res = $(".payment_res").hide(300).html("");
val = $("[name=payment]:checked").val();
if (val !== void 0) {
s = F.getConfirmData();
s.pay = val;
s.dataType = "JSON";
s.subscribe = $("[data-name=subscribe]:visible input").is(":checked") ? 1 : 0;
A.I.waitButton($b = $(".confirm_button"));
return A.captcha('cart', function(token) {
s._g_token = token;
A.reach('order');
return API('cart/confirm', s, F.aConfirm, {
$b: $b
});
});
} else {
return A.notify($res, 'Выберите способ оплаты');
}
},
aConfirm: function(data, cd) {
A.I.unwaitButton(cd.$b);
A.ga('lead', 'sale');
A.tiktok('Checkout');
//if cd.s.payID==A.C.payOnlineID
// A.ga('lead','online_paid')
if (data.link != null) {
return H.go(data.link);
}
},
//window.location.href = data.link
//window.location.href = data.id
getCartData: function() {
var confirm, data, isAsk, isNeedAddress, isOther, isSelf;
confirm = $.fn.CONFIRM('getData');
isSelf = F.isSelf();
isAsk = F.isAsk();
isOther = F.isOtherReceiver();
isNeedAddress = !(isAsk || isSelf);
return data = {
'deltype': confirm.deliveryTypeId,
'delivery': confirm.deliveryId,
'date': confirm.date,
'time': confirm.time,
'is_org': F.isOrg() ? 1 : 0,
'ask_receiver': isOther && isAsk ? 1 : 0, // confirm.isOtherReceiver && confirm.isReceiverAsk ? 1 : 0,
//'receiver_name' : if isOther then $('[data-name="receiver_name"] input').val() else '' # confirm.isSelfDelivery ? '' : ( confirm.isOtherReceiver ? confirm.controllerReceiverName.text : ''),
//'receiver_phone' : if isOther then $('[data-name="receiver_phone"] input').val() else '' # confirm.isSelfDelivery ? '' : ( confirm.isOtherReceiver ? confirm.controllerReceiverPhone.text : ''),
'receiver_name': $('[data-name="receiver_name"] input').val(), // confirm.isSelfDelivery ? '' : ( confirm.isOtherReceiver ? confirm.controllerReceiverName.text : ''),
'receiver_phone': $('[data-name="receiver_phone"] input').val(), // confirm.isSelfDelivery ? '' : ( confirm.isOtherReceiver ? confirm.controllerReceiverPhone.text : ''),
'address': isNeedAddress ? A.getCookie('address') : '',
'flat': isNeedAddress ? A.getCookie('flat') : '', // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerFlat.text,
'entrance': isNeedAddress ? A.getCookie('entrance') : '', // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerEntrance.text,
'floor': isNeedAddress ? A.getCookie('floor') : '', // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerFloor.text,
'intercom': isNeedAddress ? A.getCookie('intercom') : '', // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerIntercom.text,
'comment': isNeedAddress ? A.getCookie('comment') : '' // confirm.isSelfDelivery || confirm.isReceiverAsk ? '' : confirm.controllerComment.text,
};
},
getConfirmData: function() {
var confirm, data, isOther;
confirm = $.fn.CONFIRM('getData');
isOther = F.isOtherReceiver();
//isReceiverPhone = $('[data-name="receiver_phone"] input').is(":visible")
//isReceiverName = $('[data-name="receiver_name"] input').is(":visible")
return data = {
'delivtype': confirm.deliveryTypeId, // confirm.deliveryType?.id ?? 0,
'delivery': confirm.deliveryId, // confirm.delivery?.id ?? 0,
'date': confirm.date, // Global.formatDateToApi(confirm.date),
'time': confirm.time, // confirm.timeToSend,
'pay': '', // confirm.payment?.id ?? 0,
'comment': $('#b_confirm [data-name="comment"] textarea').val(), // confirm.controllerComment.text,
'pack': $('[data-name="pack"] input').is(":checked") ? 1 : 0, // confirm.isPack ? 1 : 0,
'aqua': $('[data-name="aqua"] input').is(":checked") ? 1 : 0, // confirm.isAqua ? 1 : 0,
'is_photo': $('[data-name="is_photo"] input').is(":checked") ? 1 : 0,
'anon': isOther && $('[data-name="anonymous"] input').is(":checked") ? 1 : 0, // confirm.isOtherReceiver && confirm.isAnon ? 1 : 0,
'ask_receiver': F.isAsk() ? 1 : 0, // confirm.isOtherReceiver && confirm.isReceiverAsk ? 1 : 0,
'me_receiver': F.isMeReceiver() ? 1 : 0, // confirm.isMeReceiver ? 1 : 0,
'is_save_address': 0, // 0,
'is_save_date': $('[data-name="is_save_date"] input').is(":checked") ? 1 : 0, // confirm.isSaveDate,
'km': F.isKm() ? $("#km").val() : 0, // confirm.isKM ? confirm.km : '',
'props': {
'1': isOther ? $('[data-name="receiver_phone"] input').val() : '', // '' # confirm.isOtherReceiver ? confirm.controllerReceiverPhone.text : '',// receiverPhoneController.text,
'2': isOther ? $('[data-name="receiver_name"] input').val() : '', // confirm.isOtherReceiver ? confirm.controllerReceiverName.text : '',// receiverNameController.text,
//'1' : $('[data-name="receiver_phone"] input').val() # '' # confirm.isOtherReceiver ? confirm.controllerReceiverPhone.text : '',// receiverPhoneController.text,
//'2' : $('[data-name="receiver_name"] input').val() # confirm.isOtherReceiver ? confirm.controllerReceiverName.text : '',// receiverNameController.text,
'3': $('[data-name="name"] input').val(), // confirm.controllerName.text,// nameController.text,
'4': $('[data-name="email"] input').val(), // confirm.controllerEmail.text,// emailController.text,
'5': $('[data-name="phone"] input').val(), // confirm.controllerPhone.text,// phoneController.text,
'8': $('[data-name="card"] textarea').val() // confirm.controllerCard.text, // cardController.text,
},
'is_org': F.isOrg() ? 1 : 0,
'inn': $('[data-name="inn"] input').val(),
'kpp': $('[data-name="kpp"] input').val(),
'org_title': $('[data-name="org_title"] input').val(),
'org_address': $('[data-name="org_address"] input').val(),
'bank_title': $('[data-name="bank_title"] input').val(),
'bank_bik': $('[data-name="bank_bik"] input').val(),
'bank_ks': $('[data-name="bank_ks"] input').val(),
'bank_rs': $('[data-name="bank_rs"] input').val()
};
},
submit: function() {
var $i_email, $i_km, $i_name, $i_phone, $i_rphone, $phone, $phone2, $res, cart, confirm, e, errors, inputs, isAsk, isNeedAddress, isOther, isSelf, km;
try {
// $res = $(".res_submit").hide(300).html("")
//$f = $("#form_delivery")
//ask_receiver = $("[data-name=ask_receiver] input").is(":checked")
//$f.data('form_inited',false)
//$("[data-input]",$f).removeData('_data_input' )
//address_check = if ask_receiver then {} else {'validation':{'notEmpty':true}}
//receiver_check = if ask_receiver then {'validation':{'notEmpty':true}} else {}
//f = $f.FORM()
//s = f.json()
//s.dataType="JSON"
//s = F.getCartData()
//console.log('submit',s)
/*
Тут самое сложное, проверка заполненности корзины
Есть несколько вариантов развития
0. Во всех случаях нужно проверить:
0.1 заполнен номер телефона получателя, если получает другой человек.
0.2 Время/интервал доставки/самовывоза
0.3 Способ оплаты
0.4 Телефон
0.5 Имя
0.6 Email
1. Самовывоз
Тут дополнительно ничего проверять не надо
2. Доставка
2.1 Тут надо проверять, есть ли уточнение адреса у получателя
-- Если нет, то надо проверить, чтобы бы был введён адрес.
2.2 Если за МКАД, то обязательно должны быть введены кол-во км за мкад
2.3. Обязательно выбрать тип доставки
*/
$res = $(".res_submit").hide().html("");
errors = [];
cart = F.getCartData();
confirm = F.getConfirmData();
isSelf = F.isSelf();
isAsk = F.isAsk();
isOther = F.isOtherReceiver();
isNeedAddress = !(isAsk || isSelf);
$i_name = $('[data-name="name"] input');
$i_email = $('[data-input="email"] input');
$i_phone = $('[data-name="phone"] input');
$i_rphone = $('[data-name="receiver_phone"] input');
$i_km = $('#km');
$i_name.removeClass('error');
$i_email.removeClass('error');
$i_phone.removeClass('error');
$i_rphone.removeClass('error');
$i_km.removeClass('error');
console.log('cart', cart, confirm);
inputs = [];
$phone = $('[data-name="phone"] input').change();
$phone2 = $('[data-name="receiver_phone"] input').change();
if ($phone.hasClass('error') && $phone.is(":visible")) {
errors.push('Введите корректный номер телефона заказчика');
}
if ($phone2.hasClass('error') && $phone2.is(":visible")) {
errors.push('Введите корректный номер телефона получателя');
}
console.log('phones', $phone2, $phone, $phone.hasClass('error'), $phone.is(":visible"));
if (confirm.is_org) {
if (confirm.org_title === '') {
errors.push('Укажите ИНН и выберите компанию из выпадающего списка');
}
if (confirm.bank_title === '') {
errors.push('Укажите название банк и выберите из выпадающего списка');
}
if (confirm.bank_rs === '') {
errors.push('Укажите расчетный счет');
}
}
if (!isSelf && !isAsk && !cart.address) {
errors.push('Укажите адрес доставки');
$.fn.DELIVERY_ADDRESS('open');
} else if (cart.delivery === 0 || cart.time === null || cart.time.trim() === '') {
errors.push('Укажите время доставки');
$.fn.CONFIRM('chooseDateTime');
} else {
console.log('??', confirm.props['3'], isOther, confirm.props['1']);
if (confirm.props['3'].trim() === '') {
inputs.push('имя отправителя');
$i_name.addClass('error');
}
if (confirm.props['4'].trim() === '') {
inputs.push('email отправителя');
$i_email.addClass('error');
} else if (!A.mail.test(confirm.props['4'])) {
inputs.push('корректный email отправителя');
$i_email.addClass('error');
}
if (confirm.props['5'].trim() === '') {
$i_phone.addClass('error');
inputs.push('телефон отправителя');
}
if (isOther) {
if (confirm.props['1'].trim() === '') {
inputs.push('телефон получателя');
$i_rphone.addClass('error');
}
}
console.log('ISKM', F.isKm(), parseInt(confirm.km), km <= 0, isNaN(km));
km = parseInt(confirm.km);
if (F.isKm()) {
if (km <= 0 || isNaN(km)) {
inputs.push($("#km").attr('placeholder').toLowerCase());
$i_km.addClass('error');
}
}
if (inputs.length) {
errors.push("Укажите " + inputs.join(", "));
}
}
A.notify($res, errors.join(", "));
if (errors.length === 0) {
F.setStep('payment');
API('cart/addData', cart);
}
} catch (error1) {
e = error1;
console.log('ERRORR', e);
}
return false;
f.validate({
fail: function(e) {
var i, inp;
errors = [];
for (i in e.bad) {
inp = e.bad[i].input.$input;
errors.push(inp.attr('placeholder').toLowerCase());
}
return A.notify($res, "Заполните: " + errors.join(", "));
},
success: function() {
F.confirmData = s;
return F.setStep('payment');
}
});
// API 'account/login',s, F.aAuth,{f:$f,r:$res}
return false;
},
checkSberPay: function() {
return console.log('checkSberPay');
},
checkPayments: function() {
var s;
s = document.getElementById('sberpay_script');
if (s) {
return F.checkSberPay();
} else {
s = document.createElement('script');
s.id = 'sberpay_script';
document.head.append(s);
s.onload = F.checkSberPay();
//s.src = 'https://securepayments.sberbank.ru/payment/modules/sbol-pay/sbol-pay.js'
return s.src = 'https://securecardpayment.ru/payment/modules/sbol-pay/sbol-pay.js';
}
},
initConfirm: function(if_auth) {
console.log('initConfirm??');
$.fn.SHOP('getMyCartConfirmList');
$("#km").change(F.remathConfirm).keyup(F.remathConfirm);
$(".variant_wrap").hide();
$(".events .event").click(function() {
var $t, card_type;
$(".variant_wrap").hide();
card_type = ($t = $(this)).attr('data-card-type');
return $(`.variant_wrap[data-card-type=${card_type}]`).show();
});
$(".step").hide();
if (if_auth) {
F.setStep('delivery');
} else {
F.setStep('account');
}
F.checkPayments();
return $(".payment").click(function() {
var $t, txt, type;
$t = $(this).prev();
type = parseInt($t.attr('data-type'));
if (type === 0) {
txt = 'ОФОРМИТЬ';
} else {
txt = 'ОПЛАТИТЬ';
}
return $(".pay_type_txt").text(txt);
});
},
aBuy: function(data, cd) {
var p;
console.log('abuy', data);
if (cd.b) {
A.I.unwaitButton(cd.b);
}
F.updateTotals();
//if $("#cart_sidebar").hasClass('open')
// $.fn.SIDEBAR('loadCartList')
p = H.parse();
if (p[0] !== "confirm") {
//$.fn.SIDEBAR('cart')
$.fn.CART('openCartModal', data.cid);
} else {
F.getMyCartConfirmList();
}
A.reach('added_to_cart');
A.ecommerceAddToCart({
id: data.id,
name: data.name,
price: data.price,
quantity: data.citems_count,
brand: A.city === 1 ? 'Москва' : 'Санкт-Петербург'
});
A.ga('lead', 'added_to_cart');
return A.tiktok('AddToCart', {
content_type: 'product',
content_name: data.name,
content_id: data.id,
quantity: data.citems_count,
price: data.price,
currency: 'RUB',
value: data.total
});
},
makeMasterClass: function() {
var $btn, $f, $res, f, next, s;
f = ($f = $(event.target)).FORM();
s = f.json();
s.dataType = "JSON";
s.masterclass = 1;
$res = $(".result", $f).hide(300);
$btn = $("#master_class_confirm");
next = function() {
var pay_id;
s.count = $("#count_master_class").data('value');
pay_id = parseInt(s.payment);
if (isNaN(pay_id)) {
return $res.text("Выберите способ оплаты");
} else {
//console.log('send',s)
A.I.waitButton($btn);
//API 'cart/fastbuy', s, F.aFastBuy,{f:$f,r:$res}
return A.captcha('master_class', function(token) {
s._g_token = token;
return API('cart/fastbuy', s, function(data, cd) {
A.I.unwaitButton($btn);
return F.aFastBuy(data, cd);
}, {
f: $f,
r: $res
});
});
}
};
f.validate({
success: function() {
return next();
},
// API 'cart/masterclass', s, F.aFastBuy,{f:$f,r:$res}
fail: function(data) {
var i, isAnyVisible, visible, x;
isAnyVisible = false;
for (i in data.bad) {
x = data.bad[i];
visible = x.input.$input.is(":visible");
isAnyVisible = isAnyVisible || visible;
}
if (!isAnyVisible) {
return next();
}
}
});
return false;
},
makeFast: function() {
var $c, $f, $res, error, f, s;
f = ($f = $(event.target)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide();
error = [];
$c = $('[name="confidential"]');
if ($c.length > 0) {
if (!$c.is(":checked")) {
error.push('Для продолжения примите согласие с политикой конфиденциальности');
}
}
if ($('[name="payment"]', $f).length > 0) {
if ($('[name="payment"]:checked', $f).length === 0) {
error.push('Выберите способ оплаты');
} else {
s['payment'] = $('[name="payment"]:checked', $f).val();
}
}
if (error.length !== 0) {
$res.show().html(error.join('
'));
} else {
f.validate({
success: function() {
A.I.waitButton($(".btn", $f));
return A.captcha('fast_buy', function(token) {
s._g_token = token;
return API('cart/fastbuy', s, F.aFastBuy, {
f: $f,
r: $res
});
});
}
});
}
//API 'cart/fastbuy', s, F.aFastBuy,{f:$f,r:$res}
return false;
},
aFastBuy: function(data, cd) {
A.I.unwaitInput($("button", cd.f));
if (data.e === 1) {
return cd.r.html(data.m).show(300);
} else {
A.reach('b_pok_ok');
A.W.close();
if (data.link != null) {
H.go(data.link);
}
//window.location.href = data.link
return A.ga('lead', 'b_pok_ok');
}
},
master_class: function(id) {
return A.W.openMasterClassBuy(id);
},
fast: function(id, category) {
return A.W.openFastBuy(id, category);
},
additional: function(id, parent_id) {
var $b;
A.I.waitButton($b = $(event.target), {
title: 'Добавляем'
});
return API('cart/additional', {
id,
parent_id,
dataType: 'JSON'
}, F.aBuy, {
b: $b,
id
});
},
buySubscription: function(form) {
var $f, $res, f, s;
f = ($f = $(form)).FORM();
s = f.json();
//s.dataType="JSON"
$res = $(".res", $f).hide(300);
console.log(s);
f.validate({
success: function() {
var $count, comment, count, id;
id = s.id;
comment = "Количество доставок в неделю: " + s.week + "\nКоличество недель: " + s.week_count + "\nКомментарии и пожелания: " + s.text;
$count = $(`#item_count_${id}`);
count = $count.val();
$.fn.SHOP('aBuyPersonal');
return API('cart/append', {
id,
count: count,
comment: comment,
dataType: 'JSON'
}, F.aBuy, {id, count});
}
});
return false;
},
buyByPlus: function(id, cat) {
console.log('buyByPlus', id, event);
if (event) {
event.preventDefault();
event.stopPropagation();
}
F.buy(id, 1, cat);
return false;
},
buy: function(id, count, category) {
var $b, $count, $targ, additional, comment;
if (event) {
$targ = $(event.target);
if (!$targ.hasClass('variant_price')) {
A.I.waitButton($b = $(event.target), {
title: 'Добавляем'
});
}
}
if (count === void 0 || count === null) {
$count = $(`#item_count_${id}`);
count = $count.val();
console.log('buy:(id,count,category)', id, count, category);
}
comment = $(`#item_comment_${id}`).val();
additional = [];
$(`#item[data-id=${id}] .additional_item:checked`).each(function() {
return additional.push($(this).val());
});
console.log(id, count, category, {
id,
count,
comment,
dataType: 'JSON',
additional,
category
});
API('cart/append', {
id,
count,
comment,
dataType: 'JSON',
additional,
category
}, F.aBuy, {
b: $b,
id,
count
});
return $(".chooser_pots .pot_el.selected").each(function() {
var $t, potId;
$t = $(this);
potId = $t.attr('data-id');
return API('cart/append', {
id: potId,
count,
comment,
category,
dataType: 'JSON'
});
});
},
resetFilter: function() {
$(".prop_content input:checked").prop("checked", false);
return F.filter();
},
filter: function(parent = "#filter_toggler_wrap") {
var $max, $min, $price, $wrap, i, j, len, max, min, not_sort, priceMax, priceMin, s, sort, ss, url;
s = {};
ss = {};
sort = ['flower', 'pack', 'color', 'ground', 'wet', 'light', 'pet', 'transfer', 'height', 'diametr', 'width', 'length'];
not_sort = [];
$wrap = $(`${parent}`);
$(".prop_content input:checked", $wrap).each(function() {
var $t, text_id;
$t = $(this);
text_id = $t.attr('data-text-id');
if (!s[text_id]) {
s[text_id] = [];
}
return s[text_id].push($t.val());
});
url = new URL(window.location.href);
url.pathname = CATALOG_URL;
for (j = 0, len = sort.length; j < len; j++) {
i = sort[j];
if (s[i]) {
ss[i] = s[i];
}
}
for (i in s) {
if (sort.indexOf(i) < 0) {
ss[i] = s[i];
}
}
for (i in ss) {
url.pathname += i + "-" + s[i].join("-") + "/";
}
$price = $(".f-price-box", $wrap);
url.searchParams.delete('max');
url.searchParams.delete('min');
$min = $(".price_inputs input:eq(0)", $wrap);
$max = $(".price_inputs input:eq(1)", $wrap);
min = parseFloat($min.val());
max = parseFloat($max.val());
priceMin = parseFloat($price.attr('data-min'));
priceMax = parseFloat($price.attr('data-max'));
if (min > priceMin) {
url.searchParams.set('min', min);
}
if (max < priceMax) {
url.searchParams.set('max', max);
}
//url.searchParams.set('max',getMax())
//url.searchParams.set('min',getMax())
console.log(url.pathname + url.search);
return H.go(url.pathname + url.search);
},
sort: function(x) {
var url;
url = new URL(window.location.href);
url.searchParams.set("sort", x);
return H.go(url.pathname + url.search);
},
copyOrder: function(id) {
var $b;
A.I.waitButton($b = $(event.target));
return API('cart/user_clone', {
id: id
}, function(data) {
A.I.unwaitButton($b);
return F.updateTotals(function() {
return $.fn.SIDEBAR('cart');
});
});
},
want_change_address: function() {
return A.W.openWantChangeAddress();
},
aBuyPersonal: function() {
$(".personal_inputs").hide();
return $("#personal_success").removeClass('dn');
}
};
})(jQuery);
(function($) {
var F;
$.fn.SIDEBAR = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.SIDEBAR');
}
};
return F = {
interval: null,
time: null,
times: [],
except: [],
delivery: null,
deliveryType: null,
deliveryDate: null,
dateInited: false,
lastAddress: "",
choosedDate: null,
askReceiver: false,
isSelf: false,
addressChoosed: false,
address: null,
parseAddress: function() {
var address;
address = F.askReceiver ? "" : F.lastAddress;
return A.captcha('parseAddress', function(token) {
var s;
s = {
address,
dataType: "JSON"
};
s._g_token = token;
s.searchSource = 'sidebar';
return API('geocode/parse', s, function(data) {
$(`#delivery_types .option[data-value=${data.delivtypeId}]`).click();
$("#delivery_add").toggle(!data.out);
$("#deliveries").toggle(!data.out);
if (data.out) {
if (data.warning) {
return $("#warnings").html(data.warning.join('
'));
}
} else {
return F.checkDelivery();
}
});
});
},
setAddress: function(x) {
F.address = x;
F.lastAddress = x['address'];
F.addressChoosed = true;
return F.parseAddress();
},
//console.log('setAddress',x)
init: function($html) {
/*
if A.isMobile()
$(".xdsoft_datetimepicker").css({
position: 'fixed'
top: '50%'
'margin-top': '-190px'
})
console.log('inited date!!!!O!IPOKI')
*/
var date;
$(".sidebar", $html).each(function() {
var $t;
$t = $(this);
return $(".back,> .hover", $t).click(function() {
return F.close();
});
});
$("#delivery_time", $html).blur(F.checkTime);
$("#delivery_date", $html).change(F.checkDate);
$(".yandex_search input", $html).on('yandex.search', function() {
F.addressChoosed = false;
F.lastAddress = "";
F.address = null;
F.deliveryType = null;
F.delivery = null;
return F.checkDelivery();
});
// console.log('search')
$(".yandex_search input", $html).on('yandex.choose', function() {
F.addressChoosed = true;
F.lastAddress = $("#delivery_address input").val();
F.parseAddress();
return F.checkDelivery();
});
$("#delivery_date", $html).click(function() {
$(".xdsoft_datetimepicker").width($("#delivery_date").parent().width() - 2);
return $(this).blur();
});
return date = new Date();
},
//m = date.getMonth()
//day = date.getDate()
//console.log(date.getFullYear()+'-'+(if m < 10 then "0"else"")+m+'-'+(if day<10 then "0"else "")+day)
initDate: function() {
var d;
d = {
minDate: new Date(),
yearOffset: 0,
scrollMonth: false,
lang: 'ru',
timepicker: false,
format: 'd.m.Y',
formatDate: 'd.m.Y',
scrollInput: false,
closeOnDateSelect: true
};
//value : date.getFullYear()+'-'+(if m < 10 then "0"else"")+m+'-'+(if day<10 then "0"else "")+day
//if !A.isMobile()
return $("#delivery_date").each(function() {
var $t;
$t = $(this);
if ($t.data('inited') !== 1) {
$t.datetimepicker(d);
$("#delivery_date").data('inited', 1);
return $t.on('change', function() {
return F.choosedDate = $t.val();
});
}
});
},
stopScroll: function(e) {
var $t;
//e.preventDefault();
//e.stopPropagation();
$t = $(e.target);
if ($t.hasClass('sidebar') || $t.closest('.sidebar').length > 0) {
return e.stopPropagation();
} else {
return e.preventDefault();
}
},
scrollPosition: 0,
open: function() {
var body, w;
A.P.body.css('overflow', 'hidden');
w = A.scrollbarWidth();
A.P.body.css('padding-right', w + 'px');
A.P.body.addClass('opened_sidebar');
body = document.body;
F.scrollPosition = window.pageYOffset;
body.style.overflow = 'hidden';
body.style.position = 'fixed';
body.style.top = '-' + F.scrollPosition + 'px';
body.style.width = '100%';
return F.initDate();
},
close: function() {
var body;
$(".sidebar").removeClass('open');
A.P.body.css('overflow', 'auto');
A.P.body.css('padding-right', '0px');
A.P.body.removeClass('opened_sidebar');
body = document.body;
body.style.removeProperty('overflow');
body.style.removeProperty('position');
body.style.removeProperty('top');
body.style.removeProperty('width');
window.scrollTo(0, F.scrollPosition);
$("#delivery_date").data('inited', 0);
return $("#delivery_date").datetimepicker('destroy');
},
date: function(id) {
var date, name, turn_on, x;
F.open();
$("#date_id").val(id);
$("#dates_sidebar").addClass('open');
name = '';
date = '';
turn_on = true;
if (id !== 0) {
x = $(`.date[data-id=${id}]`).data('info');
console.log(x);
name = x.name;
date = x.date;
turn_on = x.turn_on === 1;
}
$("#date_name").val(name);
$("#date_date").val(date);
return $("#date_turn_on").prop("checked", turn_on);
},
openAddress: function(id) {
var address, comment, entrance, flat, floor, intercom, name, phone, x;
F.open();
$("#addres_id").val(id);
$("#address_sidebar").addClass('open');
name = '';
address = '';
phone = '';
flat = '';
entrance = '';
floor = '';
intercom = '';
comment = '';
if (id !== 0) {
x = $(`.address[data-id=${id}]`).data('info');
name = x['name'];
address = x['address'];
phone = x['phone'];
flat = x['flat'];
entrance = x['entrance'];
floor = x['floor'];
intercom = x['intercom'];
comment = x['comment'];
}
$("#address_name").val(name);
$("#address_phone").val(phone);
$("[data-name=address] input").val(address);
$("[data-name=flat] input").val(flat);
$("[data-name=entrance] input").val(entrance);
$("[data-name=floor] input").val(floor);
$("[data-name=intercom] input").val(intercom);
return $("[data-name=comment] textarea").val(comment);
},
sendVacancy: function(f) {
var $f, $res, s;
f = ($f = $(f)).FORM();
s = f.json();
s.dataType = "JSON";
$res = $(".res", $f).hide(300);
console.log(s);
//f.validate
// success:->
// API 'vacancy/send',s, (data)->
// $f.replaceWith('
Данные успешно отправлены
')
f.validate({
success: function() {
return A.captcha('vacancy', function(token) {
s._g_token = token;
$(".btn", $f).text("Пожалуйста, подождите, отправляются файлы");
$(".btn", $f).prop('disabled', true);
console.log(s);
$f.ajaxForm();
return $f.ajaxSubmit({
url: '/api/vacancy/send/',
data: s,
type: "POST",
method: "POST",
success: function(data) {
console.log(data);
return $f.replaceWith('
Данные успешно отправлены
');
}
});
});
}
});
return false;
},
vacancy: function(id) {
F.open();
$("#vacancy_sidebar").addClass('open');
return API('vacancy/getData', {
id,
dataType: "JSON"
}, function(data) {
$("#vacancy_id").val(data.id);
$("#vacancy_name").text(data.name);
return $("#vacancy_text").html(data.text);
});
},
confirmCart: function() {
var $address, $askReceiver, $b, $err, $f, $res, d, date, err, isEmptyAddress, s, t, time;
$f = $(event.currentTarget);
$res = $(".result", $f).hide(300);
err = "";
time = "";
date = $("#delivery_date").val();
$err = null;
$address = $("#delivery_address input");
isEmptyAddress = false;
if ($address.is(":visible")) {
//isEmptyAddress = $address.val().trim()==""
isEmptyAddress = !F.addressChoosed;
}
//if !F.deliveryType
// err = "Выберите вид доставки"
// $err = "delivery_types"
//else
if (isEmptyAddress) {
err = "Выберите адрес доставки ";
$err = "delivery_address";
} else if (!F.delivery) {
err = "Выберите способ доставки";
$err = "deliveries";
} else if (date === "") {
err = "Выберите дату";
$err = "delivery_date";
} else if (F.times.length === 0) {
err = "Доступные интервалы отсутствуют";
$err = "delivery_date";
} else if (F.delivery) {
switch (parseInt(F.delivery.delivery_time)) {
case 1:
case 2: // Самовывоз, # Точное время
time = $("#delivery_time").val();
if (!time) {
err = "Введите время";
$err = "delivery_time";
} else {
t = time.split(":");
console.log(t, F.except, F.except.indexOf(t[0]));
if (F.except && Array.isArray(F.except) && F.except.indexOf(t[0]) >= 0) {
err = "Данный интервал не доступен";
$err = "delivery_time";
}
}
break;
case 3:
case 4: // Часовой, # 4-хчасовой
time = $("#interval .select").data('value');
if (!time) {
err = "Выберите интервал доставки";
$err = "interval";
}
}
}
$("#cart_sidebar .i_wrap, #cart_sidebar .i").removeClass('error');
console.log(`err ${$err}`);
if (err) {
A.notify($res, err);
$(`#${$err}`).addClass('error');
} else {
d = date.split(".");
date = d[2] + "-" + d[1] + "-" + d[0];
s = {
deltype: F.deliveryType.delivtype_id,
delivery: F.delivery.delivery_id,
date: date,
time: time
};
$address = $('#delivery_address input');
$askReceiver = $('#ask_receiver_wrap');
if ($address.is(":visible")) {
s.address = $address.val();
if (F.address) {
s.receiver_name = F.address.name;
s.receiver_phone = F.address.phone;
}
s.flat = $("[data-name=flat] input").val();
s.entrance = $("[data-name=entrance] input").val();
s.floor = $("[data-name=floor] input").val();
s.intercom = $("[data-name=intercom] input").val();
s.comment = $("[data-name=comment] textarea").val();
}
if ($askReceiver.is(":visible")) {
s.ask_receiver = $("input", $askReceiver).is(":checked") ? 1 : 0;
}
A.I.waitButton($b = $("button", $f));
API('cart/addData', s, function(data) {
//console.log('addData',s,data)
A.reach('order');
H.go('/confirm/');
A.I.unwaitButton($b);
return F.close();
});
}
return false;
},
updateCartTotal: function() {
return $.fn.SHOP('updateTotals', function(data) {
F.totals = data;
F.mathTotal();
return $.fn.YAPAY('initCart');
});
},
mathTotal: function() {
var total;
total = parseFloat(F.totals.sum);
if (F.delivery) {
//console.log(F.delivery)
total += parseFloat(F.delivery.delivery_price);
}
//console.log('F.totals',F.totals,total)
return $("#total").text(total);
},
checkDate: function() {
var address, s;
F.deliveryDate = $("#delivery_date").val();
address = "";
if ($("#delivery_address input").is(":visible")) {
address = $("#delivery_address input").val();
}
if (!F.delivery) {
return;
}
s = {
date: F.deliveryDate,
delivtype: F.deliveryType.delivtype_id,
delivery: F.delivery.delivery_id,
filial: A.city,
dataType: "JSON",
extend: true,
address: address
};
return API('app/getTimes', s, function(data, cd) {
var $option, $options, i, intervalInfo, isEmpty, j, len, ref;
console.log('%cTIMES', 'color:red', data);
F.times = data.times;
F.except = data.except;
isEmpty = false;
intervalInfo = '';
$("#delivery_time").val('');
switch (parseInt(F.delivery.delivery_time)) {
case 1:
case 2: // Самовывоз, # Точное время
if (F.times.length === 0) {
isEmpty = true;
} else {
if (F.times[1] === 24) {
F.times[1] = 0;
}
intervalInfo = "Доступный интервал: " + F.times[0] + ":" + data.minutes + " - " + (F.times[1] < 10 ? "0" : "") + F.times[1] + ":" + data.minutes;
$("#delivery_time").val(F.times[0] + ":" + data.minutes);
}
$("#time").toggle(!isEmpty);
break;
case 3:
case 4: // Часовой, # 4-хчасовой
$("#interval .select").data('value', '');
if (F.times.length === 0) {
isEmpty = true;
} else {
$options = $("#interval .options");
$("#interval .value .txt").text("Интервал доставки");
$options.html('');
ref = F.times;
for (j = 0, len = ref.length; j < len; j++) {
i = ref[j];
$option = $('
' + i + '
');
$option.data('info', i);
$options.append($option);
$option.click(function() {
return F.time = $(this).data('info');
});
}
}
// F.checkDelivery()
$("#interval").toggle(!isEmpty);
}
if (isEmpty) {
intervalInfo = "Доступные интервалы отсутствуют";
}
$("#interval_info").toggle(intervalInfo !== '').text(intervalInfo);
$("#warnings").html('');
if (data.warning) {
return $("#warnings").html(data.warning.join('
'));
}
});
},
checkTime: function() {
var h, v;
v = $("#delivery_time").val().split(":");
h = parseInt(v[0]);
if (h < F.times[0]) {
h = (F.times[0] < 10 ? "0" : "") + F.times[0];
return $("#delivery_time").val(h + ":00");
} else if (h > F.times[1] && F.times[1] !== 0) {
h = (F.times[1] < 10 ? "0" : "") + F.times[1];
return $("#delivery_time").val(h + ":00");
}
},
setAddressChoosed: function(x) {
return F.addressChoosed = x;
},
checkDelivery: function() {
var ask_receiver, isAddressChoosed, isSelf, showDeliveries, showInterval, showTime, time;
$("#interval").hide();
//$("#cart_address_wrap").hide()
$("#time").hide().val('');
$("#ask_receiver_wrap").hide();
$("#is_self_wrap").hide();
$("#delivery_add").hide();
ask_receiver = $("#ask_receiver").is(":checked");
showInterval = false;
showTime = false;
if (!F.delivery) {
} else {
$("#delivery_date").show();
time = parseInt(F.delivery.delivery_time);
//console.log("time",time)
switch (time) {
case 1: // Самовывоз
showTime = true;
break;
case 2: // Точное время
showTime = true;
break;
case 3: // Часовой
showInterval = true;
break;
case 4: // 4-хчасовой
showInterval = true;
}
}
isSelf = time === 1;
isAddressChoosed = time === 1 || (F.addressChoosed && time !== 1) || ask_receiver;
//console.log('isAddressChoosed',isAddressChoosed,time==1 , (F.addressChoosed && time!=1) , ask_receiver)
showInterval = showInterval && isAddressChoosed;
showTime = showTime && isAddressChoosed;
$("#cart_address_wrap").toggle(!isSelf && !ask_receiver);
$("#ask_receiver_wrap").toggle(!isSelf);
if (showInterval || showTime) {
F.checkDate();
F.mathTotal();
}
$("#warnings").html('');
$("#interval").toggle(showInterval);
$("#time").toggle(showTime);
showDeliveries = F.addressChoosed || ask_receiver;
$("#deliveries").toggle(showDeliveries);
$("#is_self_wrap").toggle(!ask_receiver);
$("#delivery_add").toggle(F.addressChoosed);
return $("#delivery_date_header").toggle(F.addressChoosed || isSelf || ask_receiver);
},
setDeliveryType: function(type) {
F.deliveryType = type;
F.delivery = null;
F.interval = null;
F.time = null;
return F.checkDeliveryType();
},
checkDeliveryType: function() {
var $option, $options, i, isSelf, j, len, ref, showDeliveries, type;
type = F.deliveryType;
showDeliveries = false;
if (!type) {
} else {
$("#interval").hide();
$("#time").hide();
$options = $("#deliveries .options");
$("#deliveries .select").data('value', '');
$("#deliveries .value .txt").text("Способ доставки");
$options.html('');
ref = type.delivery_array;
for (j = 0, len = ref.length; j < len; j++) {
i = ref[j];
$option = $('
' + i.name + ' - ' + i.price + '
');
$option.data('info', i);
$options.append($option);
$option.click(function() {
F.delivery = $(this).data('info');
return F.checkDelivery();
});
if (F.delivery && F.delivery.delivery_id === i.delivery_id) {
$option.click();
}
}
//F.checkDelivery()
A.P.initOptions($("#deliveries"));
isSelf = parseInt(type.delivtype_self) === 1;
if (isSelf) {
showDeliveries = false;
$(".option:eq(0)", $options).click();
}
}
return F.mathTotal();
},
loadCartList: function() {
$("#cart_sidebar_result").hide();
return API('cart/getMyCartList', {
dataType: "JSON"
}, function(data, cd) {
var $data;
$data = $(data.items);
A.P.initMini($data);
$(".counter input", $data).change(function() {
var count, id;
count = parseInt($(this).val());
if (isNaN(count)) {
count = 0;
}
if (count > 0) {
id = $(this).attr('data-id');
return API('citem/set', {
id: id,
count: count
}, function() {
F.checkDate();
return F.updateCartTotal();
});
}
});
$(".remove", $data).click(function() {
var id;
id = $(this).attr('data-id');
$(`.cart_item[data-id=${id}]`).remove();
return API('citem/remove', {
id: id
}, F.updateCartTotal);
});
return $("#cart").html($data);
});
},
cart_old: function() {
var $del_types;
F.deliveryType = null;
F.deliveryDate = null;
F.delivery = null;
F.open();
$("#cart_sidebar").addClass('open');
$del_types = $("#delivery_types .options");
$("#deliveries").hide();
$("#interval").hide();
$("#time").hide();
$("#delivery_date").hide();
$("#cart_sidebar .i_wrap input:not(.inited)").addClass('inited').change(function() {
return $("#cart_sidebar_result").hide();
});
$("#cart_sidebar .select:not(.inited)").addClass('inited').on('select.change', function() {
return $("#cart_sidebar_result").hide();
});
$("#cart").html('
Загрузка
');
F.updateCartTotal();
F.loadCartList();
API('cart/getMyCartItems', {
dataType: "JSON"
}, function(data, cd) {
$(".additional_wrap .items").replaceWith(data.html);
$(".additional_wrap").prev().toggle(data.count > 0);
return $(".additional_wrap").toggle(data.count > 0);
});
API('cart/cartListing', {}, function(data, cd) {
var $data;
$data = $(data);
A.P.initMini($data);
$("#cart_listings").html('');
$("#cart_listings").append($data);
$("img", $data).each(function() {
var $t;
$t = $(this);
return $t.attr('src', $t.attr('data-src-mobile'));
});
return $("a", $data).click(function() {
return F.close();
});
});
API('app/getConfirmRules', {
dataType: "JSON"
}, function(data, cd) {
var $option, i, j, len, ref, results;
$del_types.html('');
ref = data.delivtypes_array;
results = [];
for (j = 0, len = ref.length; j < len; j++) {
i = ref[j];
$option = $('
' + i.name + '
');
$option.data('info', i);
$option.click(function() {
F.deliveryType = $(this).data('info');
return F.checkDeliveryType();
});
results.push($del_types.append($option));
}
return results;
});
return $.fn.YAPAY('initCart');
},
is_self: function() {
F.isSelf = $("#is_self_wrap input").prop("checked");
if (F.isSelf) {
$("#delivery_types .option").each(function() {
var $t, info;
$t = $(this);
info = $t.data('info');
if (parseInt(info.delivtype_self) === 1) {
return $t.click();
}
});
} else {
F.deliveryType = null;
F.delivery = null;
}
return F.checkDelivery();
},
ask_receiver: function() {
F.askReceiver = $("#ask_receiver_wrap input").prop("checked");
F.parseAddress();
return F.checkDelivery();
},
preload: function() {
F.preload_scroll = $("#cart_sidebar .content").scrollTop();
$("#cart_sidebar .content").scrollTop(0);
return $("#cart_sidebar").addClass('loading');
},
loaded: function() {
$("#cart_sidebar").removeClass('loading');
return $("#cart_sidebar .content").scrollTop(F.preload_scroll);
},
cart: function() {
var $del_types;
//F.deliveryType = null
//F.deliveryDate = null
//F.delivery = null
if ($("#yamaps_script").length === 0) {
$("body").append('');
}
F.open();
F.preload();
$("#cart_sidebar").addClass('open');
$del_types = $("#delivery_types .options");
if (F.lastAddress) {
$("#delivery_address input").val(F.lastAddress);
}
if (F.choosedDate) {
$("#delivery_date").val(F.choosedDate);
}
$("#deliveries").hide();
$("#interval").hide();
$("#delivery_types").hide();
//$("#cart_address_wrap").hide()
//$("#ask_receiver_wrap").hide()
$("#time").hide();
$("#delivery_date_header").hide();
$("#delivery_date").hide();
$("#delivery_add").hide();
if (F.askReceiver) {
$("#ask_receiver_wrap input").prop("checked", F.askReceiver);
}
$("#cart_sidebar .i_wrap input:not(.inited)").addClass('inited').change(function() {
return $("#cart_sidebar_result").hide();
});
$("#cart_sidebar .select:not(.inited)").addClass('inited').on('select.change', function() {
return $("#cart_sidebar_result").hide();
});
$("#cart").html('
Загрузка
');
F.updateCartTotal();
F.loadCartList();
API('cart/getMyCartItems', {
dataType: "JSON"
}, function(data, cd) {
$(".additional_wrap .items").replaceWith(data.html);
$(".additional_wrap").prev().toggle(data.count > 0);
return $(".additional_wrap").toggle(data.count > 0);
});
API('cart/cartListing', {}, function(data, cd) {
var $data;
$data = $(data);
A.P.initMini($data);
$("#cart_listings").html('');
$("#cart_listings").append($data);
$("img", $data).each(function() {
var $t;
$t = $(this);
return $t.attr('src', $t.attr('data-src-mobile'));
});
return $("a", $data).click(function() {
return F.close();
});
});
API('app/getConfirmRules', {
dataType: "JSON"
}, function(data, cd) {
var $option, i, j, len, ref, selected;
$del_types.html('');
ref = data.delivtypes_array;
for (j = 0, len = ref.length; j < len; j++) {
i = ref[j];
$option = $('
' + i.name + '
');
$option.data('info', i);
selected = F.deliveryType && F.deliveryType.delivtype_id === i.delivtype_id;
$option.data('selected', selected);
if (i.delivtype_self === "1") {
$("#self_address").text(i.info);
}
$option.click(function() {
//F.deliveryType = $(@).data('info')
if ($(this).data('selected')) {
$(this).data('selected', false);
return F.checkDeliveryType();
} else {
return F.setDeliveryType($(this).data('info'));
}
});
$del_types.append($option);
if (selected) {
$option.click();
}
}
return F.loaded();
});
return $.fn.YAPAY('initCart');
}
};
})(jQuery);
(function($) {
var F;
$.fn.STORIES = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.STORIES');
}
};
return F = {
init: function($html) {
var $div, currentSkin;
currentSkin = {
name: 'snapgram',
params: {
autoFullScreen: true,
avatars: true,
paginationArrows: true,
cubeEffect: false,
list: false
}
};
$div = $('#stories', $html);
if ($div.length > 0) {
console.log($div.data('inited'));
if ($div.data('inited') === true) {
return;
}
$div.data('inited', true);
return setTimeout(function() {
var data, stories;
console.log('STORIES!!', $html);
data = JSON.parse($div.attr('data-data'));
console.log("DATA", data);
return stories = window.Zuck($div[0], {
backNative: false,
previousTap: true,
skin: currentSkin['name'],
autoFullScreen: currentSkin['params']['autoFullScreen'],
avatars: currentSkin['params']['avatars'],
paginationArrows: currentSkin['params']['paginationArrows'],
list: currentSkin['params']['list'],
cubeEffect: currentSkin['params']['cubeEffect'],
localStorage: true,
callbacks: {
onOpen: function(id, cb) {
console.log('onOPen', id, cb);
A.W.blockScroll();
return cb();
},
// A.W.blockScroll()
onView: function(id, cb) {
if (cb != null) {
return cb();
}
},
onEnd: function(id, cb) {
return cb();
},
onClose: function(id, cb) {
A.W.unblockScroll();
return cb();
},
onNextItem: function(id, next, cb) {
return cb();
},
onNavigateItem: function(id, next, cb) {
return cb();
},
onDataUpdate: function(id, cb) {
return cb();
}
},
stories: data,
stories1: [
{
id: 'r',
photo: 'http://roots2.in/themes/v3/pics/logo/top2.svg',
name: 'Новинки',
time: Math.floor((new Date()).getTime() / 1000),
items: [
{
id: 'sasdasdasd',
type: 'photo',
src: 'https://roots-store.ru/upload/images/products/o/d6f81dbe9b424c0a37868dda46845981_webp.webp',
preview: 'https://roots-store.ru/upload/images/products/o/d6f81dbe9b424c0a37868dda46845981_webp.webp',
time: Math.floor((new Date()).getTime() / 1000)
}
]
}
]
});
}, 3000);
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.TINKOFF = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.TINKOFF');
}
};
return F = {
s: null,
loaded: false,
loading: false,
load: function() {},
dolyami: function($html) {},
initDolyami: function($html) {
var time;
return null;
if (F.loaded) {
return F.dolyami($html);
} else {
if (!F.s) {
F.s = document.createElement('script');
}
if (!F.loading) {
F.loading = true;
if ($(".dolyami").length > 0) {
time = 1;
} else {
time = 10000;
}
console.log('initDolyamy', time);
return F.initTimeout = setTimeout(function() {
F.s.onload = function() {
F.loaded = true;
return F.dolyami($html);
};
F.s.src = '//aq.dolyame.ru/6712/client.js?ts=' + Date.now();
return document.body.appendChild(F.s);
}, time);
}
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.TOP = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.TOP');
}
};
return F = {
$wrap: null,
$menu: null,
openBigMenu: function(x) {
if (A.isMobile()) {
F.$menu.attr('data-menu-back', F.$menu.attr('data-menu'));
return F.openMobileMenu(x);
} else {
F.$menu.addClass('big_menu');
//$(".left",F.$menu).hide()
$(".center .menu", F.$menu).hide();
return $(`.center .menu[data-menu=${x}]`, F.$menu).show();
}
},
hideBigMenu: function() {
F.$menu.removeClass('big_menu');
//$(".left",F.$menu).show()
$(".center .menu", F.$menu).show();
return $(".center .menu[data-big=1]", F.$menu).hide();
},
openMobileMenu: function(x) {
F.$menu.attr('data-menu', x);
$("#d_menu3").addClass('open');
$(".menu[data-menu]", F.$wrap).hide();
return $(`.menu[data-menu=${x}]`, F.$wrap).show();
},
back: function() {
var menu;
if (F.$menu.attr('data-menu-back') != null) {
menu = F.$menu.attr('data-menu-back');
F.$menu.attr('data-menu-back', null);
return F.openMobileMenu(menu);
} else {
return $('#d_menu3').removeClass('open');
}
},
init: function($html) {
var $c;
$c = $("#b_top3", $html);
if ($c.length === 0) {
return;
}
if ($c.data('init')) {
return;
}
$c.data('init', true);
F.$wrap = $c;
F.$menu = $("#b_menu3", $html);
$(".back_big", F.$wrap).click(function() {
return F.hideBigMenu();
});
$(".center .parent", F.$menu).click(function() {
var $t, menu;
$t = $(this);
menu = $t.attr('data-menu');
return F.openBigMenu(menu);
});
$(".search", F.$wrap).click(function() {
return $("#b_search").addClass('open');
});
$("._toggle_menu", F.$wrap).click(function() {
$("#b_top3").toggleClass('open');
if ($("#b_top3").hasClass('open')) {
return A.W.blockScroll();
} else {
return A.W.unblockScroll();
}
});
$(".parents .el", F.$wrap).click(function() {
var $t, type;
$t = $(this);
type = $t.attr('data-menu');
return F.openMobileMenu(type);
});
return $("a", F.$wrap).click(function() {
$("#b_top3").removeClass('open');
return $('#d_menu3').removeClass('open');
});
}
};
})(jQuery);
(function($) {
var F;
$.fn.VACANCY = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.VACANCY');
}
};
return F = {
to: function(id) {
A.P.scrollToAnimate($("#vacancy_form").offset().top - 100);
return $("#vacancy_id").val(id);
}
};
})(jQuery);
(function($) {
var F;
$.fn.YANDEX = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.YANDEX');
}
};
return F = {
inited: null,
initializing: function($html) {},
//F.oauth($html)
init: function($html) {
var s;
if (F.inited) {
return F.initializing($html);
} else {
if (F.inited === null) {
F.inited = false;
s = document.createElement('script');
s.src = 'https://yastatic.net/s3/passport-sdk/autofill/v1/sdk-suggest-with-polyfills-latest.js';
s.onload = function() {
F.inited = true;
return F.initializing($html);
};
return document.body.append(s);
}
}
},
timeout: function() {
return setTimeout(F.oauth, 100);
},
oauth: function(checker) {
console.log('yandex.oauth');
if (!F.inited) {
F.timeout();
return null;
}
return YaAuthSuggest.init({
client_id: '2e99af96432a4d9997567d7d938b6333',
response_type: 'token',
redirect_uri: window.location.origin + '/api/account/yandexOAuth/'
}, window.location.origin).then(function({handler}) {
return handler();
}).then(function(data) {
var token;
console.log('Сообщение с токеном', data);
token = data.access_token;
return API('account/yandexOAuthMe', {token}, function() {
return H.reload();
});
}).catch(function(error) {
return console.log('Обработка ошибки', error);
});
}
};
})(jQuery);
/*
var ecommerce = function(data) {
var s;
window.dataLayer = window.dataLayer || [];
s = {
ecommerce: {
currencyCode: "RUB",
purchase: {
actionField: {
id: data.id
},
products: data.products
}
}
};
console.log('ecommerce', s, data);
return window.dataLayer.push(s);
}
var ecommerceAddToCart = function(data) {
var s;
window.dataLayer = window.dataLayer || [];
s = {
ecommerce: {
currencyCode: "RUB",
add: {
products: [data]
}
}
};
console.log('ecommerceAddToCart', s);
return window.dataLayer.push(s);
}
var getEcommerceCart = function(data, sum) {
console.log('getEcommerceCart ', data)
var i, ids, j, len;
sum = 0;
ids = [];
ecommerce(data);
for (j = 0,
len = data.length; j < len; j++) {
i = data[j];
ids.push("item" + o.id);
}
}
*/
(function($) {
var F;
$.fn.YAPAY = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.YAPAY');
}
};
return F = {
s: null,
loaded: false,
loading: false,
clickMetrik: function() {
console.log('YaPay.clickMetrik');
return ym(32763095, 'reachGoal', 'yapay_click');
},
initCart: function() {
if (!A.isYaCheckout) {
return null;
}
$("#button_container3").each(function() {
return F.getCheckoutCartData();
});
return $("#button_container3").click(F.clickMetrik);
},
onPayButtonClick: function() {
return '';
},
initPay: function($html) {
// console.log('initPay')
$("#button_container", $html).click(F.clickMetrik);
return $("#button_container", $html).each(function() {
/*
YaPay.createPayment(data).then (payment)->
container = document.querySelector('#button_container');
button = payment.mountButton(container, {
type: YaPay.ButtonType.Pay,
theme: YaPay.ButtonTheme.Black,
width: YaPay.ButtonWidth.Auto,
});
payment.on YaPay.CheckoutEventType.Success, (event) ->
try
if event.metadata
d = JSON.parse(event.metadata)
if d.link
window.location.href = d.link
else
H.reload()
else
H.reload()
payment.on YaPay.PaymentEventType.Error, (event)->
payment.complete(YaPay.CompleteReason.Error)
payment.on YaPay.PaymentEventType.Abort, (event)->
payment.on YaPay.PaymentEventType.Process,(event)->
payment.complete(YaPay.CompleteReason.Success);
button.on YaPay.ButtonEventType.Click, ->
payment.checkout();
.catch (err)->
console.log('яндекс пей не создан. ' +err)
*/
var $t, data, e;
$t = $(this);
try {
data = JSON.parse($t.attr('data-data'));
console.log('paymentData', data);
return YaPay.createSession(data, {
onPayButtonClick: F.onPayButtonClick,
onAbort: function() {
return console.log("onAbort");
},
onError: function() {
return console.log("onError");
},
onSuccess: function(event) {
var d;
console.log("onSuccess");
ym(32763095, 'reachGoal', 'yapay_success');
try {
if (event.metadata) {
A.reach('order');
d = JSON.parse(event.metadata);
if (d.link) {
return H.go(d.link);
} else {
// window.location.href = d.link
return H.reload();
}
} else {
return H.reload();
}
} catch (error) {}
}
}).then(function(paymentSession) {
var container, x;
container = document.querySelector('#button_container');
container.innerHTML = '';
paymentSession.mountWidget(container, x = {
//widgetType : YaPay.WidgetType.Mini
//widgetType : YaPay.WidgetType.Compact
//widgetType : YaPay.WidgetType.BnplRequired
//widgetType : YaPay.WidgetType.BnplPreview
widgetType: YaPay.WidgetType.BnplOffer,
widgetTheme: YaPay.WidgetTheme.Light,
buttonTheme: YaPay.ButtonTheme.WhiteOutlined,
borderRadius: 100,
//type: YaPay.ButtonType.Pay,
//theme: YaPay.ButtonTheme.Black,
//width: YaPay.ButtonWidth.Max,
//theme: YaPay.ButtonTheme.WhiteOutlined,
borderRadius: 100
});
return console.log('xxx', x);
}).catch(function(err) {
return console.log('Чекаут не создан. ' + err);
});
} catch (error) {
e = error;
return console.log('yapay error', e);
}
});
},
initCheckout: function($html) {
if (!A.isYaCheckout) {
return null;
}
$("#button_container2", $html).click(F.clickMetrik);
return $("#button_container2", $html).each(function() {
var $t, id;
$t = $(this);
id = $t.attr('data-id');
F.getCheckoutData(id);
return $(`#item_count_${id}`).change(function() {
return F.getCheckoutData(id);
});
});
},
getCheckoutCartData: function() {
return API(API_THEME + 'yandex/getCheckoutCartData', {
dataType: "JSON"
}, function(data, cd) {
//console.log('getCheckoutCartData',data)
return YaPay.createSession(data, {
onAbort: function() {
return F.getCheckoutData(id);
},
onError: function() {
return F.getCheckoutData(id);
},
onSuccess: function(event) {
var d;
ym(32763095, 'reachGoal', 'yapay_success');
try {
if (event.metadata) {
A.reach('order');
d = JSON.parse(event.metadata);
if (d.link) {
return H.go(d.link);
} else {
// window.location.href = d.link
return H.reload();
}
} else {
return H.reload();
}
} catch (error) {}
}
}).then(function(checkout) {
var container;
container = document.querySelector('#button_container3');
container.innerHTML = '';
return checkout.mountWidget(container, {
widgetType: YaPay.WidgetType.Mini,
widgetTheme: YaPay.WidgetTheme.Light,
buttonTheme: YaPay.ButtonTheme.WhiteOutlined,
borderRadius: 100,
//bnplSelected : true # Сплит по умолчанию
borderRadius: 0,
type: YaPay.ButtonType.Checkout,
// theme: YaPay.ButtonTheme.Black,
width: YaPay.ButtonWidth.Max,
theme: YaPay.ButtonTheme.WhiteOutlined
});
});
});
},
getCheckoutData: function(id) {
var count;
count = $(`#item_count_${id}`).val();
return API(API_THEME + 'yandex/getCheckoutData', {
id,
count,
dataType: "JSON"
}, function(data, cd) {
console.log('data', data, JSON.stringify(data));
return YaPay.createSession(data, {
onAbort: function() {
return F.getCheckoutData(id);
},
onError: function() {
return F.getCheckoutData(id);
},
onSuccess: function(event) {
var d;
ym(32763095, 'reachGoal', 'yapay_success');
try {
if (event.metadata) {
A.reach('order');
d = JSON.parse(event.metadata);
if (d.link) {
H.go(d.link);
return window.location.href = d.link;
} else {
return H.reload();
}
} else {
return H.reload();
}
} catch (error) {}
}
}).then(function(checkout) {
var container, type;
container = document.querySelector('#button_container2');
container.innerHTML = '';
type = YaPay.WidgetType.Mini;
console.log('container.classList', container.classList, container.classList.contains('plant_pot'));
if (container.classList.contains('plant_pot')) {
type = YaPay.WidgetType.Mini;
type = YaPay.WidgetType.BnplOffer;
}
//widgetType : YaPay.WidgetType.Mini
//widgetType : YaPay.WidgetType.Compact
//widgetType : YaPay.WidgetType.BnplOffer
//widgetType : YaPay.WidgetType.BnplRequired
//widgetType : YaPay.WidgetType.BnplPreview
//console.log('type',type)
return checkout.mountWidget(container, {
//widgetType : YaPay.WidgetType.Mini
widgetType: type,
widgetTheme: YaPay.WidgetTheme.Light,
buttonTheme: YaPay.ButtonTheme.WhiteOutlined,
borderRadius: 100,
//bnplSelected : true # Сплит по умолчанию
//borderRadius : 0
//type: YaPay.ButtonType.Checkout,
//type: YaPay.ButtonType.Mini,
//theme: YaPay.ButtonTheme.WhiteOutlined,
//width: YaPay.ButtonWidth.Auto,
borderRadius: 100
});
}).catch(function(err) {
return console.log('Чекаут не создан. ' + err);
});
});
},
initTimeout: null,
init: function($html) {
var s, time;
if (F.loaded) {
F.initPay($html);
return F.initCheckout($html);
} else {
if (!F.s) {
F.s = s = document.createElement('script');
}
if (!F.loaded) {
if (!F.loading) {
F.loading = true;
clearTimeout(F.initTimeout);
if ($("#button_container2,#button_container,yandex-pay-badge").length > 0) {
time = 1;
} else {
time = 10000;
}
console.log('initYandexPayTime', time);
return F.initTimeout = setTimeout(function() {
F.s.onload = function() {
F.loaded = true;
F.initPay($html);
return F.initCheckout($html);
};
F.s.src = 'https://pay.yandex.ru/sdk/v1/pay.js';
return document.body.appendChild(F.s);
}, time);
}
}
}
}
};
})(jQuery);
(function($) {
var F;
$.fn.REG_EMAIL = function(method) {
if (F[method]) {
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
return F.init.apply(this, arguments);
} else {
return $.error('Метод с именем ' + method + ' не существует для jQuery.REG_EMAIL');
}
};
return F = {
$sendMailButton: null,
$inputEmailCodeWrap: null,
$authByEmailButton: null,
$sendAgainButton: null,
time: 0,
time_wait: 60,
timeout: null,
email_id: 0,
getForm: function() {
return $("#form_reg_by_email");
},
getEmail: function() {
return $("#form_reg_by_email [data-name='email'] input").val().trim();
},
check_code: function($html) {},
init: function($html) {
if ($("#form_reg_by_email").length === 0) {
return;
}
F.$sendMailButton = $("#send_email_code");
F.$inputEmailCodeWrap = $("#email_code").hide();
F.$authByEmailButton = $("#auth_by_email").hide();
F.$sendAgainButton = $("#send_again").hide();
F.time = 0;
return F.stopEmailTimer();
},
startEmailTimer: function() {
F.$sendAgainButton.show();
clearTimeout(F.timeout);
F.time = F.time_wait;
F.timeout = setInterval(F.timer, 1000);
return F.timer();
},
stopEmailTimer: function() {
return clearTimeout(F.timeout);
},
timer: function() {
var isEnd, m, s, t;
F.time--;
isEnd = F.time <= 0;
F.$sendAgainButton.toggleClass('white', isEnd);
F.$sendAgainButton.toggleClass('dark_gray', !isEnd);
F.$sendAgainButton.prop('disabled', !isEnd);
if (isEnd) {
return $("#time_email").text('');
} else {
m = Math.floor(F.time / 60);
s = F.time % 60;
t = "" + m + ':' + (s < 10 ? 0 : '') + s;
return $("#time_email").text(t);
}
},
send_again: function() {
F.startEmailTimer();
return F.send_code();
},
send_code: function() {
var $f, $res, f, s;
$f = F.getForm();
f = $f.FORM();
s = f.json();
$res = $(".res", $f).hide();
f.validate({
success: function() {
A.I.waitButton(F.$sendMailButton);
return A.captcha('check_email', function(token) {
s._g_token = token;
s.dataType = "JSON";
return API('email_code/get_reg_code', s, F.aSendEmail, {
r: $res
});
});
}
});
return false;
},
aSendEmail: function(data, cd) {
A.I.unwaitButton(F.$sendMailButton);
if (data['m']) {
cd['r'].show().html(data['m']);
}
if (data['e'] === 0) {
F.email_id = data['email_id'];
F.$sendMailButton.hide();
F.$authByEmailButton.show();
F.$inputEmailCodeWrap.show();
return F.startEmailTimer();
}
},
regEmail: function(f) {
var $f, $res, s;
$f = F.getForm();
f = $f.FORM();
s = f.json();
s['email_id'] = F.email_id;
console.log(s, F.email_id);
$res = $(".res", $f).hide();
f.validate({
success: function() {
A.I.waitButton(F.$authByEmailButton);
return A.captcha('check_reg_code', function(token) {
s._g_token = token;
s.dataType = "JSON";
return API('email_code/check_reg_code', s, F.aRegEmail, {
r: $res
});
});
}
});
return false;
},
aRegEmail: function(data, cd) {
if (data['e'] === 1) {
A.I.unwaitButton(F.$authByEmailButton);
return cd['r'].show().html(data['m']);
} else {
A.setCookie('uid', data['uid']);
A.setCookie('uim', data['uim']);
return window.location.reload();
}
}
};
})(jQuery);