PageSourceSearch

https://levitacia.co/local/templates/levitacia/assets/scripts/main.js

js levitacia.co collected 2026-10-08 19:05:23 UTC 17,337 bytes, 640 lines download raw bytes

1var iOS = navigator.userAgent.match(/iPhone|iPad|iPod/i)
2var event = 'click'
3
4function checkCDEK() {
5	if (
6		!$('#ID_DELIVERY_ID_42')
7			.closest('.bx-soa-pp-company')
8			.hasClass('bx-selected')
9	) {
10		setTimeout(function () {
11			//$('.bx-soa-customer [data-property-id-row="6"]').hide()
12			//$('.bx-soa-customer [data-property-id-row="7"]').hide()
13			//$('.bx-soa-customer [data-property-id-row="8"]').hide()
14		}, 1000)
15	}
16}
17
18function getParameterByName(name, url = window.location.href) {
19	name = name.replace(/[\[\]]/g, '\\$&')
20	var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
21		results = regex.exec(url)
22	if (!results) return null
23	if (!results[2]) return ''
24	return decodeURIComponent(results[2].replace(/\+/g, ' '))
25}
26
27function getCookie(name) {
28	var matches = document.cookie.match(
29		new RegExp(
30			'(?:^|; )' +
31			name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') +
32			'=([^;]*)'
33		)
34	)
35	return matches ? decodeURIComponent(matches[1]) : undefined
36}
37
38function createCookie(name, value, days) {
39	var expires
40
41	if (days) {
42		var date = new Date()
43		date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)
44		expires = '; expires=' + date.toGMTString()
45	} else {
46		expires = ''
47	}
48	document.cookie =
49		encodeURIComponent(name) +
50		'=' +
51		encodeURIComponent(value) +
52		expires +
53		'; path=/'
54}
55
56function declOfNum(number, titles) {
57	cases = [2, 0, 1, 1, 1, 2]
58	return titles[
59		number % 100 > 4 && number % 100 < 20
60			? 2
61			: cases[number % 10 < 5 ? number % 10 : 5]
62	]
63}
64
65$(document).ready(function () {
66	document.querySelector('body').classList.add('loaded')
67
68	var lazyLoadInstance = new LazyLoad({
69		elements_selector: '.lazy'
70	})
71	checkCDEK()
72
73	/*Блок поиска*/
74	$(document).on(event, '#search-btn > a', function (e) {
75		e.preventDefault()
76		$(this).siblings('.header-menu__item-search-wrap').toggle()
77	})
78	$(document).on(event, function (e) {
79		var div = $('.header-menu__item-search-wrap')
80		if (
81			!div.is(e.target) &&
82			div.has(e.target).length === 0 &&
83			!$('#search-btn a').is(e.target)
84		) {
85			div.hide()
86		}
87	})
88	/*Блок поиска Конец*/
89
90	/*Кнопка Наверх*/
91	if ($(this).scrollTop() > 50) {
92		$(document).find('.footer-toTop').fadeIn()
93	}
94	$(window).scroll(function () {
95		if ($(this).scrollTop() > 50) {
96			$(document).find('.footer-toTop').fadeIn()
97		} else {
98			$(document).find('.footer-toTop').fadeOut()
99		}
100	})
101	$(document).on(event, '.footer-toTop', function (e) {
102		$('body,html').animate({ scrollTop: 0 }, 800)
103	})
104	/*Кнопка Наверх Конец*/
105
106	/*Слайдер баннеры*/
107	$(document).find('.banners').slick({
108		arrows: false,
109		vertical: true,
110		verticalSwiping: true,
111		focusOnSelect: true,
112		slidesToShow: 1,
113		autoplay: true,
114		autoplaySpeed: 3000,
115		speed: 1000,
116		variableHeight: true
117	})
118	/*Слайдер баннеры Конец*/
119
120	/*Слайдер Карточка товара*/
121	// if (screen.width < 768) {
122	// 	$(document).find('.good-gallery__close').remove()
123	// 	$(document)
124	// 		.find('[data-entity="images-container"]:not(.slick-initialized)')
125	// 		.slick({
126	// 			infinite: false,
127	// 			arrows: true,
128	// 			slidesToShow: 1,
129	// 			dots: false,
130	// 			prevArrow: '.good-content-nav__prev',
131	// 			nextArrow: '.good-content-nav__next'
132	// 		})
133	// }
134	/*Слайдер Карточка товара Конец*/
135
136	/*Табы*/
137	$(document).on('click', '.lk-nav__item', function (e) {
138		e.preventDefault()
139		let tabContainers = $(this).closest('.tabs').find('.lk-tab')
140		tabContainers.removeClass('active')
141		tabContainers.filter(this.hash).addClass('active')
142		$(this).closest('.tabs').find('.lk-nav__item').removeClass('active')
143		$(this).addClass('active')
144	})
145	/*Табы Конец*/
146
147	/*Отмена заказа*/
148	$(document).on(
149		'click',
150		'.lk-orderListNew-item-info-down__cancel',
151		function (e) {
152			e.preventDefault()
153			$.ajax({
154				url: $(this).attr('href'),
155				dataType: 'html',
156				type: 'get',
157				success: function (data) {
158					$.fancybox.open(
159						'<div class="sizeGuide-popup" id="popup-order-cancel" style="display: none">\n' +
160						$(data).html() +
161						'</div>'
162					)
163				}
164			})
165		}
166	)
167	/*Отмена заказа конец*/
168
169	if (document.documentElement.clientWidth < 768) {
170		var slickClone = 'a.good-gallery-item.slick-slide:not(.slick-cloned)'
171		$().fancybox({
172			selector: slickClone,
173			backFocus: false,
174			animationEffect: 'fade',
175			loop: true
176		})
177	}
178
179	scrollwindow()
180	resizewindow()
181	$(window).resize(function (e) {
182		resizewindow()
183	})
184	$(window).scroll(function () {
185		scrollwindow()
186	})
187})
188
189function resizewindow() {
190	let vh = window.innerHeight * 0.01
191	document.documentElement.style.setProperty('--vh', `${vh}px`)
192}
193
194/*Фильтр*/
195if (screen.width > 767) {
196	$(document).on(event, '.main-filters__title', function (e) {
197		$(document).find('.main-filters__clear').fadeToggle()
198		$(document).find('.main-filters-categories').slideToggle()
199		$(this).toggleClass('active')
200	})
201} else {
202	$(document).on(event, '.main-filters__title', function (e) {
203		$(document).find('.main-filters-categories-wrap').slideToggle()
204		$(this).toggleClass('active')
205	})
206	$(document).on(event, '.main-filters-categories__title', function (e) {
207		$(this).next().slideToggle()
208	})
209}
210
211/*Фильтр Конец*/
212
213// function initSlick() {
214// 	$('div.good-gallery-item').remove()
215// 	$(document)
216// 		.find('[data-entity="images-container"]:not(.slick-initialized)')
217// 		.slick({
218// 			infinite: false,
219// 			arrows: true,
220// 			slidesToShow: 1,
221// 			dots: false,
222// 			prevArrow: '.good-content-nav__prev',
223// 			nextArrow: '.good-content-nav__next'
224// 		})
225// }
226
227// function removeSlick() {
228// 	$(document).find('.good-gallery__close').remove()
229// 	$(document)
230// 		.find('.slick-initialized[data-entity="images-container"]')
231// 		.slick('unslick')
232// }
233
234// function reInitSlick() {
235// 	removeSlick()
236// 	initSlick()
237// }
238
239/*Карточка товара Размеры Конец*/
240
241/*Бургер меню*/
242$(document).on(event, '.header__burger', function (e) {
243	$('.header-menu').addClass('active')
244	$('.overlay').fadeIn()
245	$('html, body').css({
246		overflow: 'hidden',
247		height: '100%'
248	})
249})
250$(document).on(event, '.header-menu__close, .overlay', function (e) {
251	$('.header-menu').removeClass('active')
252	$('.overlay').fadeOut()
253	$('html, body').css({
254		overflow: 'auto',
255		height: 'auto'
256	})
257})
258/*Бургер меню Конец*/
259
260/*Карточка товара Скролл*/
261function scrollwindow() {
262	if (screen.width > 767) {
263		let goodBlock = $(document).find('.good')[0],
264			goodInfo = $(document).find('.good-content')[0]
265		if (goodBlock && goodInfo) {
266			if (
267				goodBlock.getBoundingClientRect().bottom <=
268				goodInfo.getBoundingClientRect().bottom
269			) {
270				goodInfo.classList.add('absolute')
271			}
272			if (
273				(window.innerHeight - goodInfo.offsetHeight) / 2 <
274				goodInfo.getBoundingClientRect().top
275			) {
276				goodInfo.classList.remove('absolute')
277			}
278		}
279	}
280}
281
282/*Карточка товара Скролл Конец*/
283
284$(document).ready(function () {
285	if ($('#lk-acc2').length) {
286		console.log(window.location.hash)
287		let urlHash = window.location.hash
288		if (urlHash == '#lk-acc2') {
289			$('.lk-tab').hide()
290			$('.lk-nav__item').removeClass('active')
291			$('.lk-nav__item[href="#lk-acc2"]').addClass('active')
292			$('#lk-acc2').show().css('display', 'flex')
293		}
294	}
295
296	$('.good-content-color-view').each(function () {
297		$('.good-content-colorWrap').each(function () {
298			$(this)
299				.find('.good-content-color-view')
300				.find('span')
301				.attr(
302					'style',
303					$(this)
304						.find('.good-content-color')
305						.find('.good-content-color__item.selected')
306						.find('span')
307						.attr('style')
308				)
309			$(this)
310				.find('.good-content-color-view')
311				.find('.good-content-color-view__color')
312				.text(
313					$(this)
314						.find('.good-content-color')
315						.find('.good-content-color__item.selected')
316						.text()
317						.trim()
318				)
319		})
320	})
321
322	$(document).on('click', '.good-content-color-view', function () {
323		$(this).siblings('.good-content-color').slideToggle('fast')
324	})
325
326	$(document).on('click', '.good-content-color__item', function () {
327		$(this)
328			.closest('.good-content-color')
329			.siblings('.good-content-color-view')
330			.find('span')
331			.attr('style', $(this).find('span').attr('style'))
332		$(this)
333			.closest('.good-content-color')
334			.siblings('.good-content-color-view')
335			.find('.good-content-color-view__color')
336			.text($(this).text().trim())
337		$(this).closest('.good-content-color').slideUp('fast')
338	})
339
340	if ($('[data-entity="container-1"]').length) {
341		var updateCatalog = function (allmutations) {
342			allmutations.map(function (mr) {
343				var lazyLoadInstance = new LazyLoad({
344					elements_selector: '.lazy'
345				})
346			})
347		},
348			updateCatalogElement = document.querySelectorAll(
349				'[data-entity="container-1"]'
350			)[0],
351			updateCatalogObserver = new MutationObserver(updateCatalog),
352			updateCatalogOptions = {
353				childList: true,
354				subtree: true
355			}
356		updateCatalogObserver.observe(updateCatalogElement, updateCatalogOptions)
357	}
358	/*Пагинация*/
359	$(document).on(
360		'click',
361		'a.main-pagination__page, a.main-pagination__next, a.main-pagination__prev',
362		function (e) {
363			e.preventDefault()
364			const aHref = $(this).attr('href')
365			$.get(aHref, { AJAX_MODE: 'Y' }).done((data) => {
366				$(`[data-entity="container-1"]`).html(
367					$(data).find(`[data-entity="container-1"]`).html()
368				)
369				history.pushState(null, null, aHref)
370				window.scrollTo(0, 0)
371			})
372		}
373	)
374	/*пагинация конец*/
375	$(document).on('click', '.goodpage-footer-toTop', function (e) {
376		e.preventDefault()
377		window.history.back()
378	})
379})
380
381$(document).on('change', '.lk-tab #email', function (e) {
382	$(this).siblings('#login').val($(this).val())
383})
384
385function basketHeight() {
386	if (
387		$('.basket-content-aside').length &&
388		$('.basket-content-main').length &&
389		screen.width > 1200
390	) {
391		$('.basket-content-main').css(
392			'min-height',
393			$('.basket-content-aside').outerHeight() - 100
394		)
395	}
396}
397
398$(document).ready(function () {
399	basketHeight()
400})
401
402$(window).resize(function () {
403	basketHeight()
404})
405
406$(document).on('click', '.header-menu__parent', function () {
407	$(this).next('.header-menu__content').slideToggle().css('display', 'flex')
408})
409
410/* страница возврата */
411$(document).ready(function () {
412	addBasketValue($('#return'))
413	$(document).on('change', '.return-label_file input', function () {
414		if (this.files.length) {
415			$(this)
416				.closest('.return-label')
417				.find('.return-label_success > span')
418				.html(this.files[0].name)
419			$(this).closest('.return-label_file').fadeOut('fast')
420			setTimeout(() => {
421				$(this)
422					.closest('.return-label')
423					.find('.return-label_success')
424					.fadeIn('fast')
425					.css('display', 'flex')
426			}, 200)
427		}
428	})
429
430	$(document).on('click', '.return-label_success__delete', function () {
431		$(this).closest('.return-label').find('input')[0].value = ''
432
433		$(this).closest('.return-label_success').fadeOut('fast')
434		setTimeout(() => {
435			$(this).closest('.return-label').find('.return-label_file').fadeIn('fast')
436		}, 200)
437
438		$(this).closest('.return-label_success').find('span').html('')
439	})
440
441	$(document).on('change', '[name="FIELDS[cardIsActive]"]', function () {
442		if (
443			$(this).val() ==
444			'Моя карта утеряна/заблокирована. Прошу перечислить денежные средства по реквизитам:'
445		) {
446			$('.return-requisites').slideDown()
447			$('.return-requisites input').each(function (e) {
448				$(this).attr('required', true)
449			})
450		} else {
451			$('.return-requisites').slideUp()
452			$('.return-requisites input').each(function (e) {
453				$(this).attr('required', false)
454			})
455		}
456	})
457	$(document).on('click', '#bx-soa-delivery', function () {
458		checkCDEK()
459	})
460	$(document).on('change', '.return-goods input', function () {
461		var form = $(this).closest('form')
462		addBasketValue(form)
463	})
464
465	function addBasketValue(form) {
466		var text = ''
467		form.find('.return-goods-row').each(function (index) {
468			text += index + ')'
469			$(this)
470				.find('.return-label')
471				.each(function (index) {
472					let gInput = $(this).find('input')
473					if ($(gInput).val()) {
474						text += $(this).find('p').html() + ': ' + $(gInput).val() + ';'
475					}
476				})
477		})
478		form.find('[name="FIELDS[BASKET]"]').val(text)
479	}
480
481	function reInitReturnField() {
482		$('.return-goods .return-goods-row').each(function (index) {
483			$(this)
484				.find('input[name*="goodsArticul"]')
485				.attr('name', 'BASKET[' + index + '][goodsArticul]')
486			$(this)
487				.find('input[name*="goodsName"]')
488				.attr('name', 'BASKET[' + index + '][goodsName]')
489			$(this)
490				.find('input[name*="goodsColor"]')
491				.attr('name', 'BASKET[' + index + '][goodsColor]')
492			$(this)
493				.find('input[name*="goodsReason"]')
494				.attr('name', 'BASKET[' + index + '][goodsReason]')
495			$(this)
496				.find('input[name*="goodsPrice"]')
497				.attr('name', 'BASKET[' + index + '][goodsPrice]')
498			$(this)
499				.find('input[name*="goodsQuantity"]')
500				.attr('name', 'BASKET[' + index + '][goodsQuantity]')
501		})
502	}
503
504	function addReturnRow() {
505		$('.return-goods-addGoods').before(`
506        <div class="return-goods-row">
507          <label class="return-label">
508            <p>Артикул</p>
509            <input type="text" required name="goodsArticul">
510          </label>
511          <label class="return-label">
512            <p>Наименование</p>
513            <input type="text" required name="googsName">
514          </label>
515          <label class="return-label">
516            <p>Цвет / размер</p>
517            <input type="text" required name="goodsColor">
518          </label>
519          <label class="return-label">
520            <p>Причина возврата</p>
521            <input type="text" required name="goodsReason">
522          </label>
523          <div class="return-goods__delete"></div>
524          <input type="hidden" name="goodsPrice">
525          <input type="hidden" name="goodsQuantity">
526        </div>
527    `)
528		reInitReturnField()
529	}
530
531	$(document).on('click', '.return-goods-addGoods', function () {
532		addReturnRow()
533	})
534
535	$(document).on('click', '.return-goods__delete', function () {
536		if ($('.return-goods-row:not(.return-goods-row_title)').length == 1) {
537			return
538		}
539		$(this).closest('.return-goods-row').remove()
540		reInitReturnField()
541	})
542
543	$(document).on('click', '.lk-orderListNew-item-info', function () {
544		if ($(this).closest('.lk-orderListNew-item').hasClass('open')) {
545			$(this).next().slideToggle()
546			$(this).closest('.lk-orderListNew-item').removeClass('open')
547			return false
548		}
549		$('.lk-orderListNew-item.open')
550			.find('.lk-orderListNew-item-goods')
551			.slideToggle()
552		$('.lk-orderListNew-item.open').removeClass('open')
553
554		$(this).next().slideToggle()
555		$(this).closest('.lk-orderListNew-item').addClass('open')
556	})
557	reInitReturnField()
558})
559/* страница возврата end */
560
561/*Таблица размеров*/
562$(document).on('click', '.product-item-detail-sizeTable', function () {
563	$.fancybox.open({
564		src: '#sizeTable',
565		touch: false
566	})
567})
568/*Таблица размеров Конец*/
569
570/*Подписка*/
571$(document).on('click', '#subscribe', (e) => {
572	e.preventDefault()
573	$('.subscribe-form__wrap').addClass('active')
574})
575$(document).on(
576	'click',
577	'.subscribe-form__overlay, .subscribe-form__close',
578	(e) => {
579		$('.subscribe-form__wrap').removeClass('active')
580	}
581)
582if (document.documentElement.clientWidth < 768) {
583	$(document).on('click', '.subscribe-bot__btn', (e) => {
584		e.preventDefault()
585		$('.subscribe-form__wrap').addClass('active')
586	})
587}
588/*Подписка Конец*/
589
590/*Показать/Скрыть пароль*/
591$(document).on('click', '.lk-tab__eye', (e) => {
592	e.preventDefault()
593	if (!e.target.classList.contains('active')) {
594		e.target
595			.closest('.lk-tab__fieldset')
596			.querySelector('.lk-tab__input')
597			.setAttribute('type', 'text')
598	} else {
599		e.target
600			.closest('.lk-tab__fieldset')
601			.querySelector('.lk-tab__input')
602			.setAttribute('type', 'password')
603	}
604	e.target.classList.toggle('active')
605})
606/*Показать/Скрыть пароль Конец*/
607
608/*Копирование трэк-кода*/
609$(document).on('click', '.lk-order-track__wrap', (e) => {
610	e.preventDefault()
611})
612const clipboard = new ClipboardJS('.lk-order-track__wrap')
613clipboard.on('success', (e) => {
614	e.trigger.classList.add('active')
615	const copyTimeout = setTimeout(() => {
616		e.trigger.classList.remove('active')
617	}, 1000)
618}
618)
619/*Копирование трэк-кода Конец*/
620
621/*Выход из карточки товара назад*/
622// $(document).on('click', '.good-content__back', function (e) {
623// 	localStorage.setItem('goodTitle', $('.good-content__title').text())
624// })
625// $(document).ready(() => {
626// 	const goodTitle = localStorage.getItem('goodTitle').toLowerCase().trim()
627// 	document.querySelectorAll('.main-items-card-info__title').forEach((item) => {
628// 		if (item.innerText.toLowerCase().trim() === goodTitle) {
629// 			yCoord =
630// 				item.closest('.main-items__item').getBoundingClientRect().top +
631// 				pageYOffset
632// 			console.log(yCoord)
633// 			setTimeout(() => {
634// 				document.querySelector('html').scrollTo(0, yCoord)
635// 				localStorage.removeItem('goodTitle')
636// 			}, 500)
637// 		}
638// 	})
639// })
640/*Выход из карточки товара назад Конец*/

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.