var instance = $('.lazyload').Lazy({
chainable: false,
multiple: function(element) {
var backgrounds = element.data('src').split('|');
element.css('background-image', 'url(' + backgrounds.join('), url(') + ')');
},
});
var instanceLazy = $('.lazyload-populars').Lazy({
chainable: false,
multiple: function(element) {
var backgrounds = element.data('src').split('|');
element.css('background-image', 'url(' + backgrounds.join('), url(') + ')');
}
});
$(window).on('load', () => {
if ($(window).width() > 992) {
$('#topsection').css('height', $(window).height() + 'px');
}
$('.popular-item__overlay').removeClass('d-none');
if (typeof AjaxForm !== 'undefined') {
AjaxForm.Message.error = function() {};
AjaxForm.Message.danger = function() {};
AjaxForm.Message.success = function() {};
}
$('header .navbar-nav ul > li .linkname').on('mousedown touch', function(event) {
let workElement = $(this).parent().parent().find('.dropdown-toggle');
let workElement1 = $(this).parent().parent().find('[data-mdb-toggle="collapse"]');
let finalElement = workElement.length > 0 ? workElement : workElement1;
if (finalElement.length > 0) {
if (finalElement.attr('href')) {
window.location.href = finalElement.attr('href');
}
}
});
$('.offscreen-menu ul li .linkname').on('mousedown touch', function(event) {
let workElement = $(this).parent().parent().find('.dropdown-toggle');
let workElement1 = $(this).parent().parent().find('[data-mdb-toggle="collapse"]');
let finalElement = workElement.length > 0 ? workElement : workElement1;
if (finalElement.length > 0) {
if (finalElement.attr('href')) {
window.location.href = finalElement.attr('href');
}
}
});
$('#topformhours').parent().parent().addClass('topform-action__item');
$('#topformminutes').parent().parent().addClass('topform-action__item');
$('#topformseconds').parent().parent().addClass('topform-action__item');
if ($(window).width() > 992) {
equalizeItems('.whatbroke-title');
equalizeItems('.whatbroke-description');
}
equalizeItems('.popular-item__second');
if (document.getElementById("topformhours") != null) {
/* Timer */
var Timer = setInterval(function() {
var countDownDate = new Date();
countDownDate.setHours(24,0,0,0);
var now = new Date().getTime();
var timeleft = countDownDate - now;
var days = Math.floor(timeleft / (1000 * 60 * 60 * 24));
var hours = Math.floor((timeleft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((timeleft % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((timeleft % (1000 * 60)) / 1000);
document.getElementById("topformhours").innerHTML = hours < 10 ? '0' + hours : hours;
document.getElementById("topformminutes").innerHTML = minutes < 10 ? '0' + minutes : minutes;
document.getElementById("topformseconds").innerHTML = seconds < 10 ? '0' + seconds : seconds;
}, 1000);
document.getElementById("topformhours").parentElement.classList.add('formform-action__header');
document.getElementById("topformminutes").parentElement.classList.add('formform-action__header');
document.getElementById("topformseconds").parentElement.classList.add('formform-action__header');
}
if (document.getElementById('happyhours') != null) {
var now = new Date();
var currentHour = now.getHours();
if (currentHour >= 0 && currentHour < 4) {
document.getElementById('happyhours').innerHTML = 'с 00:00 до 04:00';
}
if (currentHour >= 4 && currentHour < 8) {
document.getElementById('happyhours').innerHTML = 'с 04:00 до 08:00';
}
if (currentHour >= 8 && currentHour < 12) {
document.getElementById('happyhours').innerHTML = 'с 08:00 до 12:00';
}
if (currentHour >= 12 && currentHour < 16) {
document.getElementById('happyhours').innerHTML = 'с 12:00 до 16:00';
}
if (currentHour >= 16 && currentHour < 20) {
document.getElementById('happyhours').innerHTML = 'с 16:00 до 20:00';
}
if (currentHour >= 20 && currentHour < 24) {
document.getElementById('happyhours').innerHTML = 'с 20:00 до 24:00';
}
}
$('#contentblock').css('opacity', '');
$('#textblock').css('opacity', '');
$('#newsblock').css('opacity', '');
$(window).on('resize', function() {
$('#werepair .popular-item').css('height', '');
equalizeItems('#werepair .popular-item');
equalizeItems('#werepair .popular-item__title');
});
$('#ready-slider').on('init', function(event, slick){
equalizeItems('.ready-slider .v-card__title');
equalizeItems('.ready-slider .ready-item__chars');
});
$('.slidepanel-toggle').on('click', function(event) {
event.preventDefault();
if ($('.slidepanel').hasClass('active')) {
$('.slidepanel').removeClass('active');
} else {
$('.slidepanel').addClass('active');
}
});
$('.input-container__solo .input-placeholder').on('click', function() {
$(this).parent().find('input').trigger('focus');
});
$('.videoreview-image').on('click', function() {
var videocode = $(this).data('video');
$(this).append('');
});
$('#brandscarousel').slick({
slidesToShow: 1,
slidesToScroll: 1,
prevArrow: '',
nextArrow: ''
});
if (document.getElementById('brands') != null && document.getElementById('slidepanel') != null) {
$(window).on('resize', function() {
if (isElementVisible(document.getElementById('brands'))) {
document.getElementById('slidepanel').classList.add('active');
document.getElementById('slidepanel').classList.add('show');
} else {
}
if (isElementVisible(document.getElementById('footer'))) {
document.getElementById('slidepanel').classList.remove('show');
document.getElementById('slidepanel').classList.add('onfooter');
} else {
document.getElementById('slidepanel').classList.remove('onfooter');
}
});
}
assignScroll('.header-lg .v-btn');
assignScroll('.mobilesubheader a');
assignScroll('.navbar-brand .scrollelement');
$('.footer-menu a').scrollTo(1000);
$('header').css('display', 'block');
if ($('#brandscollapse > .row > div').length > 0) {
$('#brandstoggle').on('click', function() {
if ($('#brandscollapse').hasClass('active')) {
$('#brandscollapse').removeClass('active');
$('#brandscollapse').fadeOut('active');
$(this).text('Показать все слоты');
$.scrollTo($(this).closest('section'), 1000);
} else {
$('#brandscollapse').addClass('active');
$('#brandscollapse').fadeIn('active');
$(this).text('Скрыть слоты');
}
});
} else {
$('#brandstoggle').fadeOut();
}
$('input[name="name"]').on('input', keepFocused);
$('input[name="description"]').on('input', keepFocused);
$('input[name="phone"]').on('input', keepFocused);
$('input[name="phone"]').on('click', moveCursor);
$('input[name="phone"]').on('blur', function() {
if ($(this).val() != '_ (___) ___-__-__') {
$(this).addClass('focus');
} else {
$(this).removeClass('focus');
}
});
window.addEventListener('scroll', headerScroll);
this.headerScroll();
$('#slidepanel').on('transitionend', function(event) {
if (isElementVisible(document.getElementById('footer'))) {
$('#slidepanel').addClass('onfooter');
}
});
$('.scroll-arrow').on('click', function() {
$('html, body').animate({scrollTop: $('#' + ($(this).closest('section').next().attr('id'))).offset().top}, 1000);
return false;
});
$('#places .dropdown').on('mouseenter', function() {
$(this).parent().css('z-index', 1000);
});
$('#places .dropdown').on('mouseleave', function() {
$(this).parent().css('z-index', '');
});
if ($("#yandex-map").length > 0) {
YaMapsShown = false;
if (parseInt($("#yandex-map").data('full')) === 1) {
initializeYandexMap();
YaMapsShown = true;
}
$(window).scroll(function() {
if (!YaMapsShown){
if($(window).scrollTop() + $(window).height() > $(document).height() - 1500) {
initializeYandexMap();
YaMapsShown = true;
}
}
});
}
callOffscreen('.offscreen-pull-mobile');
callOffscreen('.offscreen-pull');
$('#offscreen-bigmenu').css('display', '');
$('.offscreen-block li a:not([aria-expanded])').on('click', function() {
$('.offscreen-block').removeClass('active');
$('body').css('overflow', '');
$('body').css('padding-right', '');
});
$('.offscreen-block li .scrollTo').on('click', function() {
$('body').css('overflow', '');
$('body').css('padding-right', '');
$.scrollTo($(this).attr('href'), 200);
$('.offscreen-block').removeClass('active');
});
// Вызов модалки автоматически когда пользователь уходит
var initTrack = false;
var masterModalShown = false;
if ($(window).width() > 992) {
window.addEventListener('mousemove', (event) => {
mousePos = { x: event.clientX, y: event.clientY };
if (!initTrack) {
if (mousePos.y > 100)
initTrack = true;
}
if (initTrack) {
if (mousePos.y < 25) {
if (!masterModalShown) {
if (!$('body').hasClass('modal-open')) {
masterModalShown = true;
$('#modalMaster').modal('show');
}
}
}
}
});
} else {
this.sleep(30000).then(() => {
if (!$('body').hasClass('modal-open')) {
masterModalShown = true;
$('#modalMaster').modal('show');
}
});
}
var processForm = null;
$('.reviews-form form').on('submit', function(event) {
event.preventDefault();
let name = $(this).find('input[name="name"]').val();
let description = $(this).find('input[name="description"]').val();
if (name.length > 0 && description.length > 0) {
$('#modalThanks').modal('show');
$(this).find('input[name="name"]').val('');
$(this).find('input[name="description"]').val('');
} else {
$('#modalError').modal('show');
}
});
//$($('#topsection > .container')[0]).css('left', $('section:not(#topsection) > .container').css('margin-left'));
/*
$(window).on('resize', function() {
if ($(window).width() > 992) {
$('.topsection').css('height', $(window).height());
//$($('#topsection > .container')[0]).css('left', $('section:not(#topsection) > .container').css('margin-left'));
} else {
$('.topsection').css('height', '');
}
});
*/
/*
var touchableElement = document.getElementById('types-tabs-content');
if (touchableElement) {
touchableElement.addEventListener('touchstart', function (event) {
touchstartX = event.changedTouches[0].screenX;
touchstartY = event.changedTouches[0].screenY;
}, false);
touchableElement.addEventListener('touchend', function (event) {
touchendX = event.changedTouches[0].screenX;
touchendY = event.changedTouches[0].screenY;
handleGesture();
}, false);
}
var touchableElement1 = document.getElementById('pricelist-tabs-content');
if (touchableElement1) {
touchableElement1.addEventListener('touchstart', function (event) {
touchstartX = event.changedTouches[0].screenX;
touchstartY = event.changedTouches[0].screenY;
}, false);
touchableElement1.addEventListener('touchend', function (event) {
touchendX = event.changedTouches[0].screenX;
touchendY = event.changedTouches[0].screenY;
handleGesture1();
}, false);
}
*/
$('#types-carousel-master .nav-tabs').slick({
slidesToShow: 1,
slidesToScroll: 1,
centerMode: true,
arrows: false,
infinite: false,
speed: 100,
asNavFor: '#types-carousel-slave',
variableWidth: true
});
$('#types').on('afterChange', function(event, currentSlide){
$('#types-carousel-master li a').removeClass('active');
$($('#types-carousel-master li')[currentSlide.currentSlide]).find('a').addClass('active');
$('#types-carousel-slave .tab-pane').removeClass('show').removeClass('active');
$($('#types-carousel-slave .slick-track .tab-pane')[currentSlide.currentSlide]).addClass('active').addClass('show');
});
$('#types-carousel-slave').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
infinite: false,
speed: 100,
asNavFor: '#types-carousel-master .nav-tabs',
});
$('#pricelist-carousel-master .nav-tabs').slick({
slidesToShow: 1,
slidesToScroll: 1,
centerMode: true,
arrows: false,
infinite: false,
speed: 100,
asNavFor: '#pricelist-carousel-slave',
variableWidth: true
});
$('#pricelist-carousel-slave').on('afterChange', function(event, currentSlide){
$('#pricelist-carousel-master li a').removeClass('active');
$($('#pricelist-carousel-master li')[currentSlide.currentSlide]).find('a').addClass('active');
$('#pricelist-carousel-slave .tab-pane').removeClass('show').removeClass('active');
$($('#pricelist-carousel-slave .slick-track .tab-pane')[currentSlide.currentSlide]).addClass('active').addClass('show');
});
$('#pricelist-carousel-slave').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
infinite: false,
speed: 100,
asNavFor: '#pricelist-carousel-master .nav-tabs',
});
$('#slidepanel').css('display', '');
});
function handleGesture() {
if (touchendX < touchstartX) {
// Влево, плюс
var nextElement = $('#types-tabs-content').find('.tab-pane.active').next();
if (nextElement.length !== 0) {
$('#types-tabs-content').find('.tab-pane.active').removeClass('active').removeClass('show');
$(nextElement).addClass('active').addClass('show');
var nextTab = $('#types-tabs').find('.nav-link.active').parent().next().find('.nav-link');
$('#types-tabs').find('.nav-link.active').removeClass('active').removeClass('show');
$(nextTab).addClass('active').addClass('show');
}
}
if (touchendX > touchstartX) {
// Вправо, минус
var nextElement = $('#types-tabs-content').find('.tab-pane.active').prev();
if (nextElement.length !== 0) {
$('#types-tabs-content').find('.tab-pane.active').removeClass('active').removeClass('show');
$(nextElement).addClass('active').addClass('show');
var nextTab = $('#types-tabs').find('.nav-link.active').parent().prev().find('.nav-link');
$('#types-tabs').find('.nav-link.active').removeClass('active').removeClass('show');
$(nextTab).addClass('active').addClass('show');
}
}
}
function handleGesture1() {
if (touchendX < touchstartX) {
// Влево, плюс
var nextElement = $('#pricelist-tabs-content').find('.tab-pane.active').next();
if (nextElement.length !== 0) {
$('#pricelist-tabs-content').find('.tab-pane.active').removeClass('active').removeClass('show');
$(nextElement).addClass('active').addClass('show');
var nextTab = $('#pricelist-tabs').find('.nav-link.active').parent().next().find('.nav-link');
$('#pricelist-tabs').find('.nav-link.active').removeClass('active').removeClass('show');
$(nextTab).addClass('active').addClass('show');
}
}
if (touchendX > touchstartX) {
// Вправо, минус
var nextElement = $('#pricelist-tabs-content').find('.tab-pane.active').prev();
if (nextElement.length !== 0) {
$('#pricelist-tabs-content').find('.tab-pane.active').removeClass('active').removeClass('show');
$(nextElement).addClass('active').addClass('show');
var nextTab = $('#pricelist-tabs').find('.nav-link.active').parent().prev().find('.nav-link');
$('#pricelist-tabs').find('.nav-link.active').removeClass('active').removeClass('show');
$(nextTab).addClass('active').addClass('show');
}
}
}
function callOffscreen(selector) {
$(selector).on('click touchstart tap', function(e) {
e.preventDefault();
let targetSelector = $(this).attr('href');
if ($(targetSelector).hasClass('active')) {
$(targetSelector).removeClass('active');
$('body').css('overflow', '');
$('body').css('padding-right', '');
} else {
$(targetSelector).addClass('active');
$('body').css('overflow', 'hidden');
$('body').css('padding-right', '0px');
}
$(targetSelector).find('.offmenu-close').on('click touchstart', function(event) {
event.preventDefault();
$(targetSelector).removeClass('active');
});
});
}
function initializeYandexMap() {
ymaps.ready(function () {
let coords = document.getElementById("yandex-map").getAttribute('data-coordinates').split(',');
let coordsA = parseFloat(coords[0].substring(1));
let coordsB = parseFloat(coords[1].slice(0, -1));
let map = new ymaps.Map("yandex-map", {
center: [coordsA, coordsB],
zoom: document.getElementById("yandex-map").getAttribute('data-zoom'),
controls: ['zoomControl'],
searchControlProvider: 'yandex#search'
});
let placemark = new ymaps.Placemark([coordsA, coordsB], {
balloonContentHeader: document.getElementById("yandex-map").getAttribute('data-ballon-header'),
balloonContentBody: document.getElementById("yandex-map").getAttribute('data-ballon-body'),
balloonContentFooter: document.getElementById("yandex-map").getAttribute('data-ballon-footer'),
hintContent: document.getElementById("yandex-map").getAttribute('data-ballon-hint')
});
map.geoObjects.add(placemark);
});
}
function changeValue(selector, target, value) {
$(selector).find(`input[name="${target}"]`).val(value);
}
function changeTitle(selector, value) {
$(selector).text(value);
}
function headerScroll() {
var st = window.scrollY;
if (st > 0) {
$('header.header').addClass('moving');
if (st > this.lastScrollTop && st > 550){
$('header.header').removeClass('show');
if (isElementVisible(document.getElementById('footer'))) {
$('#slidepanel').removeClass('show');
} else {
$('#slidepanel').removeClass('onfooter');
if (isElementVisible(document.getElementById('brands'))) {
$('#slidepanel').addClass('active');
}
$('#slidepanel').addClass('show');
}
} else {
$('header.header').addClass('show');
$('#slidepanel').removeClass('show');
}
this.lastScrollTop = st;
} else {
$('header.header').removeClass('moving');
}
}
function equalizeItems (selector) {
var maxHeight = 0;
$(selector).each(function(){
$(this).css('height', '');
if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
});
$(selector).height(maxHeight);
}
function isElementVisible (ele) {
if (ele) {
const { top, bottom } = ele.getBoundingClientRect();
const vHeight = (window.innerHeight || document.documentElement.clientHeight);
return (
(top > 0 || bottom > 0) &&
top < vHeight
);
} else {
return false;
}
}
function assignScroll(selector) {
$(selector).scrollTo(1000);
}
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
function keepFocused(event) {
if ($(this).attr('name') == 'phone') {
if ($(this).val() != '_ (___) ___-__-__') {
$(this).addClass('focus');
} else {
$(this).removeClass('focus');
}
} else {
if ($(this).val() != '') {
$(this).addClass('focus');
} else {
$(this).removeClass('focus');
}
}
}
function moveCursor(event) {
if ($(this).val()[0] === '_') {
$(this)[0].setSelectionRange(0, 0);
$(this).focus();
}
}