PageSourceSearch

https://my.alyans-auto.ru/cabinet/assets/js/script.js?version=1782902544

js alyans-auto.ru collected 2026-09-24 10:22:02 UTC 21,584 bytes, 782 lines download raw bytes

1$('.linkcontact').click(function () {
2  if ($('.messengers').is(':visible')) {
3    $('.messengers').removeClass('act')
4    setTimeout(function () {
5      $('.messengers').hide()
6    }, 200)
7  } else {
8    $('.messengers').show()
9    setTimeout(function () {
10      $('.messengers').addClass('act')
11    }, 10)
12  }
13})
14
15function clickout(e) {
16  var div = $('.messengers, .linkcontact')
17  if (!div.is(e.target) && div.has(e.target).length === 0) {
18    $('.messengers').removeClass('act')
19    setTimeout(function () {
20      $('.messengers').hide()
21    }, 200)
22  }
23}
24
25$(document).mouseup(function (e) {
26  clickout(e)
27})
28$('.swiper').click(function (e) {
29  clickout(e)
30})
31
32function hideSubmenu() {
33  $('.submenu').removeClass('act')
34  setTimeout(function () {
35    $('.submenu').each(function () {
36      if (!$(this).hasClass('act')) $(this).hide()
37    })
38  }, 200)
39}
40
41function isHidden(el) {
42  return el.offsetParent === null
43}
44
45$('.header__menu').mousemove(function (e) {
46  if (e.target.parentNode.classList.contains('submenu')) return false
47  if (e.target.parentNode.classList.contains('sub-col')) return false
48  if (e.target.parentNode.classList.contains('header__menu-item')) {
49    var submenu = e.target.parentNode.querySelector('.submenu')
50    if (submenu) {
51      if (isHidden(submenu)) {
52        submenu.style.display = 'block'
53        setTimeout(function () {
54          submenu.classList.add('act')
55        }, 10)
56      } else submenu.classList.add('act')
57    } else hideSubmenu()
58  } else hideSubmenu()
59})
60$('.header__menu,  .submenu, .sub-col').mouseleave(function () {
61  hideSubmenu()
62})
63
64$('.header__catitem').click(function () {
65  $('.header__catitem').removeClass('act')
66  $(this).addClass('act')
67
68  var id = $(this).attr('data-id')
69  $('.header__catblock').hide()
70  $('.header__catblock[data-id=' + id + ']').show()
71})
72
73$('.header__but').click(function () {
74  $('.header__catalog').toggleClass('act')
75  $('.headerbg').removeClass('bgmodal').stop().fadeToggle(200)
76})
77
78$(document).mouseup(function (e) {
79  var div = $('.header__catalog, .header__but, .modal, .openmodal, .calc')
80  var isFocus = false
81
82  $('.form__inp').each(function () {
83    if ($(this).is(':focus')) isFocus = true
84  })
85
86  if (!isFocus && !div.is(e.target) && div.has(e.target).length === 0) {
87    $('.header__catalog').removeClass('act')
88    $('.headerbg').stop().fadeOut(200)
89    $('.modal').removeClass('showmodal')
90    setTimeout(function () {
91      $('.modal').addClass('hidemodal')
92      $('.calc').removeClass('act')
93      $('body').removeAttr('style')
94    }, 10)
95  }
96})
97
98$('.headerbg').click(function (e) {
99  var div = $('.modal')
100  var isFocus = false
101
102  $('.form__inp').each(function () {
103    if ($(this).is(':focus')) isFocus = true
104  })
105
106  if (!isFocus && !div.is(e.target) && div.has(e.target).length === 0) {
107    setTimeout(function () {
108      $('.modal').hide()
109      $(this).removeClass('bgmodal')
110    }, 200)
111  }
112})
113
114$('.close').click(function () {
115  $('.headerbg').stop().fadeOut(200)
116  $('.modal').removeClass('showmodal')
117  setTimeout(function () {
118    $('.modal').addClass('hidemodal')
119    $('.calc').removeClass('act')
120    $('body').removeAttr('style')
121  }, 10)
122  setTimeout(function () {
123    $('.modal').hide()
124    $('.headerbg').removeClass('bgmodal')
125  }, 200)
126})
127
128$('.menumobile__item').click(function () {
129  var id = $(this).attr('data-id')
130  var subblock = $('.menumobile__submenu[data-id=' + id + ']')
131  subblock.addClass('act').scrollTop(0)
132  $('.menumobile').css('overflow', 'hidden').scrollTop(0)
133
134  if (!subblock.find('.menumobile__contacts').length) {
135    var html = $('.menumobile>.menumobile__contacts').html()
136    subblock.append('<div class="menumobile__contacts">' + html + '</div>')
137  }
138})
139
140$('.menumobile__submenu-head').click(function () {
141  $(this).parent().removeClass('act')
142  $('.menumobile').scrollTop(0).removeAttr('style')
143})
144
145$('.burger').click(function () {
146  $(this).toggleClass('act')
147  $('.menumobile').toggleClass('act').scrollTop(0).removeAttr('style')
148  $('.menumobile__submenu').removeClass('act')
149})
150
151$('.switcher__btn').click(function () {
152  $('.switcher__btn').removeClass('act')
153  $(this).addClass('act')
154
155  var controller = $(this).attr('data-controller')
156  $('input[data-type=mileage]').val(controller)
157
158  if (controller === '2') {
159    $('.mainform__item[data-mileage=true]').show()
160    $('.mainform__grid').addClass('mainform__mileage')
161    $('.marksform').hide()
162    $('.marksform-mileage').addClass('act')
163    $('.secslider-auto').hide()
164  } else {
165    $('.mainform__item[data-mileage=true]').hide()
166    $('.mainform__grid').removeClass('mainform__mileage')
167    $('.marksform').show()
168    $('.marksform-mileage').removeClass('act')
169    $('.secslider-auto').show()
170  }
171})
172
173//Анимация при скроле
174function scrollAnim() {
175  var pos = $(document).scrollTop()
176  var vh = window.innerHeight
177  $('.scrollanim').each(function () {
178    const posel = $(this)[0].offsetTop
179
180    var s = 300
181    if (window.innerWidth < 500) s = 120
182
183    if (pos + vh - posel > s) {
184      $(this).removeClass('scrollanim')
185    }
186  })
187}
188
189scrollAnim()
190
191$(document).scroll(function () {
192  scrollAnim()
193})
194
195if ($('select').length) {
196  var selectize = $('select')
197    .not('.special-modal__dialer, .special-modal__brand')
198    .selectize({
199      valueField: 'value',
200      labelField: 'value',
201    })
202
203  $('select[data-type=mark]').change(function () {
204    for (var select of selectize) {
205      if (select.dataset.type === 'model') select.selectize.destroy()
206    }
207
208    $('select[data-type=model] option').each(function () {
209      if (!$(this).attr('disabled')) {
210        $('select[data-type=model]').append(
211          '<div data-mark="' +
212          $(this).attr('data-mark') +
213          '">' +
214          $(this).text() +
215          '</div>'
216        )
217        $(this).remove()
218      }
219    })
220
221    var options = []
222    $('select[data-type=model] div').each(function () {
223      if ($(this).attr('data-mark') === $('select[data-type=mark]').val())
224        options.push({ value: $(this).text() })
225    })
226
227    $('select[data-type=model]').removeAttr('disabled').val('').selectize({
228      valueField: 'value',
229      labelField: 'value',
230      searchField: 'value',
231      options: options,
232    })
233  })
234
235  $('select[data-type=model]').change(function () {
236    for (var select of selectize) {
237      if (select.dataset.type === 'generation') select.selectize.destroy()
238    }
239
240    $('select[data-type=generation] option').each(function () {
241      if (!$(this).attr('disabled')) {
242        $('select[data-type=generation]').append(
243          '<div data-model="' +
244          $(this).attr('data-model') +
245          '">' +
246          $(this).text() +
247          '</div>'
248        )
249        $(this).remove()
250      }
251    })
252
253    var options = []
254    $('select[data-type=generation] div').each(function () {
255      if ($(this).attr('data-model') === $('select[data-type=model]').val())
256        options.push({ value: $(this).text() })
257    })
258
259    $('select[data-type=generation]').removeAttr('disabled').val('').selectize({
260      valueField: 'value',
261      labelField: 'value',
262      searchField: 'value',
263      options: options,
264    })
265  })
266}
267
268$('.salon__title').click(function () {
269  const salonId = $(this).attr('data-salon')
270  var thisInner = $('.salon__inner[data-salon="' + salonId + '"]')
271  var thisTitle = $(this)
272
273  if (thisInner.hasClass('act')) {
274    thisInner.removeClass('act').slideUp(400)
275    thisTitle.removeClass('act')
276  } else {
277    thisInner.addClass('act').slideDown(400)
278    thisTitle.addClass('act')
279  }
280
281  $('.salon__inner').not(thisInner).removeClass('act').slideUp(400)
282  $('.salon__title').not(thisTitle).removeClass('act')
283})
284
285$('select').change(function () {
286  if (['Не выбрано', 'Любой', 'Любая', 'Любое'].includes($(this).val())) {
287    for (var select of selectize) {
288      if (select === $(this)[0]) select.selectize.destroy()
289    }
290    $(this).val('').selectize()
291  }
292})
293
294if ($('.price-range-slider').length) {
295  $('.price-range-slider').ionRangeSlider({
296    type: 'double',
297    step: 10000,
298    hide_min_max: true,
299    hide_from_to: true,
300    onChange: function (e) {
301      $('input[data-type=price_from]').val(e.from_pretty)
302      $('input[data-type=price_to]').val(e.to_pretty)
303    },
304  })
305}
306
307$('input[data-type=price_from]').focus(function () {
308  if ($(this).val() === '0') $(this).val('')
309})
310
311$('input[data-type=price_from]').change(function () {
312  var val = +$(this).val().replace(/\D+/g, '')
313  var price_range = $('.price-range-slider').data('ionRangeSlider')
314  if (val > price_range.options.max) val = price_range.options.max
315  if (val < price_range.options.min) val = price_range.options.min
316  if (val > price_range.old_to) val = price_range.old_to
317  $(this).val(val.toLocaleString())
318  price_range.update({
319    from: val,
320  })
321})
322
323$('input[data-type=price_from]').keyup(function () {
324  var val = +$(this).val().replace(/\D+/g, '')
325  var price_range = $('.price-range-slider').data('ionRangeSlider')
326  if (val > price_range.options.max) val = price_range.options.max
327  if (val < price_range.options.min) val = price_range.options.min
328  price_range.update({
329    from: val,
330  })
331})
332
333$('input[data-type=price_to]').focus(function () {
334  if ($(this).val() === '0') $(this).val('')
335})
336
337$('input[data-type=price_to]').change(function () {
338  var val = +$(this).val().replace(/\D+/g, '')
339  var price_range = $('.price-range-slider').data('ionRangeSlider')
340  console.log(price_range)
341  if (val > price_range.options.max) val = price_range.options.max
342  if (val < price_range.options.min) val = price_range.options.min
343  if (val < price_range.old_from) val = price_range.old_from
344  $(this).val(val.toLocaleString())
345  price_range.update({
346    to: val,
347  })
348})
349
350$('input[data-type=price_to]').keyup(function () {
351  var val = +$(this).val().replace(/\D+/g, '')
352  var price_range = $('.price-range-slider').data('ionRangeSlider')
353  if (val > price_range.options.max) val = price_range.options.max
354  if (val < price_range.options.min) val = price_range.options.min
355  price_range.update({
356    to: val,
357  })
358})
359
360if ($('.probeg-range-slider').length) {
361  $('.probeg-range-slider').ionRangeSlider({
362    type: 'double',
363    step: 5000,
364    hide_min_max: true,
365    hide_from_to: true,
366    onChange: function (e) {
367      var from = e.from_pretty
368      var to = e.to_pretty
369      if (e.to === e.max) to = '+' + to
370      if (e.to !== 0) to = to + ' км'
371
372      $('input[data-type=probeg_from]').val(from)
373      $('input[data-type=probeg_to]').val(to)
374    },
375  })
376}
377
378$('input[data-type=probeg_from]').focus(function () {
379  if ($(this).val() === '0') $(this).val('')
380})
381
382$('input[data-type=probeg_from]').change(function () {
383  var val = +$(this).val().replace(/\D+/g, '')
384  var probeg_range = $('.probeg-range-slider').data('ionRangeSlider')
385  if (val > probeg_range.options.max) val = probeg_range.options.max
386  if (val < probeg_range.options.min) val = probeg_range.options.min
387  if (val > probeg_range.old_to) val = probeg_range.old_to
388  $(this).val(val.toLocaleString())
389  probeg_range.update({
390    from: val,
391  })
392})
393
394$('input[data-type=probeg_from]').keyup(function () {
395  var val = +$(this).val().replace(/\D+/g, '')
396  var probeg_range = $('.probeg-range-slider').data('ionRangeSlider')
397  if (val > probeg_range.options.max) val = probeg_range.options.max
398  if (val < probeg_range.options.min) val = probeg_range.options.min
399  probeg_range.update({
400    from: val,
401  })
402})
403
404$('input[data-type=probeg_to]').focus(function () {
405  if ($(this).val() === '0') $(this).val('')
406})
407
408$('input[data-type=probeg_to]').change(function () {
409  var val = +$(this).val().replace(/\D+/g, '')
410  var probeg_range = $('.probeg-range-slider').data('ionRangeSlider')
411  if (val > probeg_range.options.max) val = probeg_range.options.max
412  if (val < probeg_range.options.min) val = probeg_range.options.min
413  if (val < probeg_range.old_from) val = probeg_range.old_from
414
415  var val2 = val.toLocaleString()
416  if (val > 0) val2 = val2 + ' км'
417  if (val === probeg_range.options.max) val2 = '+' + val2
418
419  $(this).val(val2)
420  probeg_range.update({
421    to: val,
422  })
423})
424
425$('input[data-type=probeg_to]').keyup(function () {
426  var val = +$(this).val().replace(/\D+/g, '')
427  var probeg_range = $('.probeg-range-slider').data('ionRangeSlider')
428  if (val >
428 probeg_range.options.max) val = probeg_range.options.max
429  if (val < probeg_range.options.min) val = probeg_range.options.min
430  probeg_range.update({
431    to: val,
432  })
433})
434
435//Слайдер автомобилей
436if ($('.sliderauto.act').length) {
437  function addSliderMark() {
438    $(
439      '.sliderauto.act .swiper-button-next, .sliderauto.act .swiper-button-prev'
440    )
441      .removeClass('in')
442      .removeClass('out')
443    new Swiper('.sliderauto.act', {
444      direction: 'horizontal',
445      spaceBetween: 10,
446      slidesPerView: 1,
447      navigation: {
448        nextEl: '.swiper-button-next',
449        prevEl: '.swiper-button-prev',
450      },
451      speed: 600,
452      breakpoints: {
453        800: {
454          slidesPerView: 4,
455          spaceBetween: 30,
456        },
457        600: {
458          slidesPerView: 3,
459        },
460        400: {
461          slidesPerView: 2,
462        },
463      },
464    })
465  }
466
467  addSliderMark()
468
469  $('.markbut').click(function () {
470    var mark = $(this).attr('data-mark')
471    $('.markbut').removeClass('act')
472    $(this).addClass('act')
473    $('.markslider').removeClass('act')
474    $('.markslider[data-mark=' + mark + ']').addClass('act')
475    addSliderMark()
476  })
477}
478
479$('.options__header').click(function () {
480  const thisUl = $(this).parent().find('.options__hide')
481  if ($(this).hasClass('act')) {
482    $(this).removeClass('act')
483    $(this).parent().find('.options__hide').slideUp(200)
484  } else {
485    $(this).addClass('act')
486    $(this).parent().find('.options__hide').slideDown(200)
487  }
488
489  $('.options__header').not($(this)).removeClass('act')
490  $('.options__header').parent().find('.options__hide').not(thisUl).slideUp(400)
491})
492
493$('.equipment__btn').click(function () {
494  $('.equipment__btn').removeClass('act')
495  $('.equipment__item').removeClass('act')
496  const thisBtnType = $(this).attr('data-type')
497  $(this).addClass('act')
498  if (!$('.equipment__item').hasClass('act')) {
499    $('.equipment__item').removeClass('act').hide()
500  }
501  if (thisBtnType === 'all') {
502    $('.equipment__item').addClass('act').show()
503  }
504  $('.equipment__item[data-type=' + thisBtnType + ']')
505    .addClass('act')
506    .show()
507})
508
509//Слайдер в карточке товара
510if (
511  $('.goods__slider').length &&
512  $('.goods__top').length &&
513  $('.goods__bottom').length
514) {
515  $('.goods__slider-mobile').html($('.goods__slider').html())
516
517  new Swiper('.goods__top', {
518    direction: 'horizontal',
519    speed: 250,
520    on: {
521      realIndexChange: function (swiper) {
522        $('.goods__bottom .goods__slideritem').removeClass('act')
523        $('.goods__bottom').each(function () {
524          if ($(this).find('.goods__slideritem')[swiper.realIndex]) {
525            $(this)
526              .find('.goods__slideritem')
527            [swiper.realIndex].classList.add('act')
528          }
529        })
530      },
531    },
532  })
533
534  new Swiper('.goods__bottom', {
535    direction: 'horizontal',
536    spaceBetween: 10,
537    slidesPerView: 4,
538    navigation: {
539      nextEl: '.swiper-button-next',
540      prevEl: '.swiper-button-prev',
541    },
542    speed: 250,
543  })
544
545  $('body').on('click', '.goods__slideritem', function () {
546    $('.goods__slideritem').removeClass('act')
547    $(this).addClass('act')
548    document.querySelectorAll('.goods__top').forEach(function (el) {
549      const swiper = el.swiper
550      const itemIndex = $('.goods__slideritem.act').index()
551      swiper.slideTo(itemIndex, 200)
552    })
553  })
554}
555
556//Слайдер акций
557if ($('.slideraction').length) {
558  $('.slideraction .swiper-button-next, .slideraction .swiper-button-prev')
559    .removeClass('in')
560    .removeClass('out')
561  new Swiper('.slideraction', {
562    direction: 'horizontal',
563    spaceBetween: 8,
564    slidesPerView: 2,
565    navigation: {
566      nextEl: '.swiper-button-next',
567      prevEl: '.swiper-button-prev',
568    },
569    speed: 600,
570    breakpoints: {
571      860: {
572        spaceBetween: 15,
573        slidesPerView: 4,
574      },
575      600: {
576        slidesPerView: 4,
577      },
578      525: {
579        slidesPerView: 3,
580      },
581    },
582  })
583}
584
585//Слайдер новостей
586if ($('.slidernews').length) {
587  $('.slidernews .swiper-button-next, .slidernews .swiper-button-prev')
588    .removeClass('in')
589    .removeClass('out')
590  new Swiper('.slidernews', {
591    direction: 'horizontal',
592    spaceBetween: 15,
593    slidesPerView: 1,
594    navigation: {
595      nextEl: '.swiper-button-next',
596      prevEl: '.swiper-button-prev',
597    },
598    speed: 600,
599    breakpoints: {
600      800: {
601        slidesPerView: 4,
602        spaceBetween: 30,
603      },
604      600: {
605        slidesPerView: 3,
606      },
607      400: {
608        slidesPerView: 2,
609      },
610    },
611  })
612}
613
614//Расчет цены в карточке товара
615$('.formcalcprice__item input[type=checkbox]').change(function () {
616  var sumStart = $('.product-price')[0]
617    ? parseInt($('.product-price')[0].getAttribute('data-price'))
618    : 0
619
620  $('.formcalcprice__item input[type=checkbox]').each(function () {
621    if (!$(this).prop('checked')) {
622      sumStart += parseInt($(this).parent().find('.sumchange').attr('data-sum'))
623    }
624  })
625
626  $('.product-price').text(sumStart.toLocaleString())
627})
628
629//Модалки
630$('.openmodal').click(function () {
631  var type = $(this).attr('data-modal')
632  $('.headerbg').addClass('bgmodal').stop().fadeIn(200)
633
634  if (type !== 'calc') {
635    $('.modal[data-modal=' + type + ']')
636      .show()
637      .css('display', 'flex')
638      .removeClass('hidemodal')
639      .addClass('showmodal')
640  } else {
641    $('.calc').addClass('act')
642    $('body').css('overflow', 'hidden')
643    $('.calc__img').html(
644      '<img src="' + $('.goods__slider img').first().attr('src') + '" alt=""/>'
645    )
646  }
647})
648
649$('.form__inp').change(function () {
650  if (!$(this).val()) $(this).parent().find('.form__label').removeClass('act')
651  else $(this).parent().find('.form__label').addClass('act')
652})
653
654$('.form__inp').focus(function () {
655  $(this).removeClass('error')
656  $(this).closest('.form').find('.form__error').text('').hide()
657})
658
659$('input[name=phone]').inputmask('mask', {
660  mask: '+7(*99) 999-99-99',
661  clearIncomplete: true,
662  showMaskOnHover: false,
663  showMaskOnFocus: false,
664  definitions: { '*': { validator: '[0-69]' } },
665})
666
667function serialize(obj) {
668  var str = []
669  for (var p in obj)
670    if (obj.hasOwnProperty(p)) {
671      str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]))
672    }
673  return str.join('&')
674}
675
676function opensuccess(title, desc, desc2) {
677  title ? $('.modal__title').html(title) : $('.modal__title').html('Успешно!')
678  desc
679    ? $('.modal__desc').html(desc)
680    : $('.modal__desc').html('Ваша заявка отправлена!')
681  desc2
682    ? $('.modal__desc2').html(desc2)
683    : $('.modal__desc2').html(
684      'Наши менеджеры в ближайшее время свяжутся с вами'
685    )
686  $('.headerbg').addClass('bgmodal').stop().fadeIn(200)
687  $('.modal').removeClass('showmodal')
688  setTimeout(function () {
689    $('.modal').addClass('hidemodal')
690    $('.calc').removeClass('act')
691  }, 10)
692  setTimeout(function () {
693    $('.modal').hide()
694    $('.modal[data-modal=success]')
695      .show()
696      .removeClass('hidemodal')
697      .addClass('showmodal')
698  }, 200)
699}
700
701function openerror(title, desc) {
702  title ? $('.modal[data-modal=error] .modal__title').html(title) : $('.modal[data-modal=error] .modal__title').html('Ошибка!')
703  desc
704    ? $('.modal[data-modal=error] .modal__desc').html(desc)
705    : $('.modal[data-modal=error] .modal__desc').html('Произошла ошибка')
706  $('.headerbg').addClass('bgmodal').stop().fadeIn(200)
707  $('.modal').removeClass('showmodal')
708  setTimeout(function () {
709    $('.modal').addClass('hidemodal')
710    $('.calc').removeClass('act')
711  }, 10)
712  setTimeout(function () {
713    $('.modal').hide()
714    $('.modal[data-modal=error]')
715      .show()
716      .removeClass('hidemodal')
717      .addClass('showmodal')
718  }, 200)
719}
720
721//Отправка форм
722$('.form').submit(function (e) {
723  e.preventDefault()
724
725  var form = $(this)
726
727  if (
728    form.find('input[data-mask=phone]').length &&
729    form.find('input[data-mask=phone]').val().replace(/\D+/g, '').length !== 11
730  ) {
731    form.find('.form__error').text('Некорректный номер').show()
732    form.find('input[data-mask=phone]').addClass('error')
733    return false
734  }
735
736  var action = form.attr('action')
737
738  var btn = $(this).find('.form__but')
739  if (!btn.hasClass('disable')) {
740    btn.removeAttr('style')
741    var btn_old = btn.html()
742    btn
743      .addClass('disable')
744      .css('width', btn.outerWidth() + 'px')
745      .css('height', btn.outerHeight() + 'px')
746      .html(
747        '<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>'
748      )
749
750    var objUtm = {
751      t_typ,
752      t_src,
753      t_mdm,
754      t_cmp,
755      t_cnt,
756      t_trm,
757      t_aep,
758      t_vst,
759      t_pgs,
760      t_afd,
761      t_cpg,
762      t_uag,
763    }
764
765    $.ajax({
766      url: action,
767      type: 'post',
768      data: form.serialize() + '&' + serialize(objUtm),
769      success: function () {
770        opensuccess()
771        form.trigger('reset')
772        form.find('.form__label').removeClass('act')
773        btn.removeClass('disable').html(btn_old)
774      },
775      error: function () {
776        form.find('.form__error').text('Неизвестная ошибка').show()
777        btn.removeClass('disable').html(btn_old)
778      },
779    })
780  }
781})
782

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.