PageSourceSearch

https://bitmall.ru/catalog/view/theme/unishop2/js/common.js

js bitmall.ru collected 2026-10-09 01:31:17 UTC 46,100 bytes, 1,597 lines download raw bytes

1//'use strict';
2
3window.dataLayer = window.dataLayer || [];
4
5var uni_touch_support;
6	
7if ('ontouchstart' in document.documentElement) uni_touch_support = true;
8
9$(() => {
10	if(uni_touch_support) $('body').addClass('touch-support');
11	
12	uniMenuAim();
13	//uniMenuDropdownHeight();
14	uniMenuMobile();
15	uniSearch.init();
16	uniChangeBtn.init();
17	
18	$('#language li a').on('click', function(e) {
19		e.preventDefault();
20		$('#language input[name="code"]').val($(this).data('code'));
21		$('#language').submit();
22	});
23	
24	$('#currency li a').on('click', function(e) {
25		e.preventDefault();
26		$('#currency input[name="code"]').val($(this).data('code'));
27		$('#currency').submit();
28	});
29	
30	$('.header-phones__additional').on('click', function() {
31		$('.header-phones__additional').addClass('selected').not($(this)).removeClass('selected');
32		
33		if($('.header-phones__main').text() == $(this).data('phone') && $(this).data('href')) {
34			location = $(this).data('href');
35		} else {
36			$('.header-phones__main').text($(this).data('phone')).attr('href', $(this).data('href'));
37		}
38	});
39	
40	$('[data-toggle=\'tooltip\']').tooltip({container:'body', trigger:'hover'});
41	
42	$('body').on('show.bs.modal', '.modal.animated', () => {
43		const padding = (window.innerWidth - document.documentElement.clientWidth);
44		
45		if(padding) {
46			$('header.fixed').css({'margin-right': -padding, 'padding-right': padding});
47			$('.fly-menu, .fly-block').css('padding-right', padding);
48		}
49	});
50	
51	$('body').on('hide.bs.modal', '.modal.animated', function() {
52		$(this).removeClass(uniJsVars.popup_effect_in).addClass(uniJsVars.popup_effect_out);
53	});
54		
55	$('body').on('hidden.bs.modal', '.modal.animated', (e) => {
56		setTimeout(() => {
57			e.target.remove();
58		}, 200);
59		
60		$('body').removeClass('scroll-disabled');
61		
62		if($('body > .modal.fade.in').length) {
63			$('body').addClass('modal-open');
64		} else {
65			$('header.fixed').css({'margin-right': '', 'padding-right': ''});
66			$('.fly-menu, .fly-block').css('padding-right', '');
67		}
68	});
69	
70	$('.add_to_cart.disabled:not(.fly-menu__product-btn)').each(function() {
71		$(this).attr('disabled', true);
72	});
73	
74	$(document).ajaxStop(() => {	
75		$('[data-toggle=\'tooltip\']').tooltip({container:'body', trigger:'hover'});
76		
77		$('.add_to_cart.disabled:not(.fly-menu__product-btn)').each(function(){
78			$(this).attr('disabled', true);
79		});
80	});
81	
82	$('body').on('click keyup', '.qty-switch__input, .qty-switch__btn', function(e) {
83		let $elem = $(this), delay = 0, timer;
84		
85		if($(this).hasClass('qty-switch__btn')) {
86			$elem = $(this).closest('.qty-switch').find('input');
87			
88			e.preventDefault();
89		}
90		
91		if($(this).hasClass('qty-switch__input')) {
92			if(e.type == 'click' || e.keyCode == 8) {
93				return;
94			}
95			
96			clearTimeout(timer);
97			
98			delay = 250;
99		}
100			
101		const changeQty = () => {
102			let qty = parseFloat($elem.val()),
103				min = $elem.data('minimum') ? parseFloat($elem.data('minimum')) : 1,
104				max = $elem.data('maximum') ? parseFloat($elem.data('maximum')) : 100000,
105				step = uniJsVars.qty_switch.step ? min : 1,
106				decimal = 0,
107				show_alert,
108				new_qty;
109		
110			if(max != 100000) {
111				let main_block = $elem.closest('.product-thumb');
112		
113				if(!main_block.length) main_block = $elem.closest('.product-block');
114		
115				if(main_block.find('.option').length) {
116					main_block.find('input:checked, option:selected').each(function() {
117						const this_max = $(this).data('maximum');
118				
119						if(this_max < max) {
120							max = this_max;
121						}
122					});
123				}
124			}
125		
126			if(qty >= max) show_alert = true;
127		
128			if($(this).hasClass('qty-switch__input')) {
129				if(step > 1) qty = Math.round(qty/min)*min;
130			
131				new_qty = (qty > min) && (qty < max) ? qty : ((qty >= max) ? max : min);
132			} else {
133				new_qty = $(this).hasClass('fa-plus') ? ((qty < max) ? qty+step : qty) : ((qty > min) ? qty-step : qty);
134			}
135		
136			new_qty = new_qty.toFixed(decimal);
137		
138			$elem.val(new_qty).change();
139		
140			if(new_qty < max) show_alert = false;
141		
142			if(show_alert) uniFlyAlert('warning', uniJsVars.qty_switch.stock_warning)
143		
144			if($(this).closest('.checkout-cart__quantity, .header-cart__quantity').length) {
145				cart.update($elem.data('cid'), new_qty);
146			}
147		};
148		
149		timer = setTimeout(() => { 
150			changeQty();
151		}, delay);
152	});
153	
154	$('body').on('change', '.option input[type="checkbox"], .option input[type="radio"], .option select', function() {
155		let $elem = $(this), main_block = $elem.closest('.product-thumb'), max = $elem.data('maximum');
156		
157		if(!main_block.length) main_block = $elem.closest('.product-block');
158		
159		const qty_input = main_block.find('.qty-switch__input');
160		
161		qty_input.val(qty_input.data('minimum'));
162	});
163	
164	$('body').on('touchstart mouseenter', '.option__item', function(e) {
165		let elem = $(this).find('img');
166		
167		if(!elem.length) return;
168		
169		let ended = $(this).hasClass('ended') ?? '',
170			block = $('<div class="option__popup '+elem.data('type')+' '+(ended ? 'ended' : '')+'"><img src="'+elem.data('thumb')+'" class="option__popup-img img-responsive" />'+(ended ? '---' : elem.attr('alt'))+'</div>'),
171			imgSrc = elem.data('thumb'),
172			elemTop = elem.offset().top,
173			elemLeft = elem.offset().left+(elem.outerWidth()/2);
174			
175		$('.option__popup').remove()
176		
177		$('body').append(block);
178		
179		if(elemLeft < block.outerWidth()/2) {
180			elemLeft = elem.offset().left;
181		} else if(elemLeft + (block.outerWidth()/2) > $(window).width()) {
182			elemLeft = elem.offset().left + elem.outerWidth() - block.outerWidth();
183		} else {
184			elemLeft = elemLeft - (block.outerWidth()/2);
185		}
186
187		setTimeout(() => {
188			block.css({top: elemTop-block.outerHeight()-10, left: elemLeft}).addClass('show');
189		}, 170);
190		
191		$(this).on('mouseleave', () => {
192			block.remove();
193		});
194		
195		$('body').on('touchstart', () => { 
196			block.remove();     
197		});
198	});
199	
200	$('body').on('click', '.uni-href', function(e) {
201		e.preventDefault();
202		
203		if(typeof($(this).data('href')) != 'undefined' && $(this).data('href') != '') {
204			if(($(this).attr('target') || $(this).data('target')) == '_blank') {
205				window.open($(this).data('href'), '_blank');
206			} else {
207				location = $(this).data('href');
208			}
209		}
210	});
211	
212	const input = 'input[type="password"]', wrapper = 'pass-wrap', eye_1 = 'fa-eye-slash', eye_2 = 'fa-eye';
213
214	$('body').on('mouseenter', input, function() {
215		$this = $(this);
216	
217		if(!$this.parent().hasClass(wrapper)) {
218			$this.wrap('<div class="'+wrapper+'">').after('<i class="far '+eye_1+'"></i>');
219		
220			$this.next().on('click', function() {
221				if($(this).hasClass(eye_1)) {
222					$this.attr('type', 'text');
223					$(this).removeClass(eye_1).addClass(eye_2);
224				} else {
225					$this.attr('type', 'password');
226					$(this).removeClass(eye_2).addClass(eye_1);
227				}
228			});
229		}
230	});
231	
232	$('.breadcrumb').scrollLeft(1000);
233	
234	if(uniJsVars.unregisterSW && ('serviceWorker' in navigator)) {
235		navigator.serviceWorker.getRegistrations().then(function(registrations) {
236			for(let registration of registrations) {
237				registration.unregister();
238			}
239		});
240		
241		typeof(uniDelPageCache) === 'function' && uniDelPageCache();
242	}
243});
244
245function uniMenuAim() {
246	if(window.innerWidth > 991) {
247		let blur_blocks = $('main, footer'), items = '.menu__level-2', timer = '', delay = 50, delay2 = 0;
248		
249		$('.menu.menu2 li.has-children').on('mouseenter', function() {
250			timer = setTimeout(() => { 
251				changeState($(this), 1);
252			}, delay);
253		}).on('mouseleave', function() {
254			clearTimeout(timer);
255			changeState($(this), 0);
256		});
257		
258		$('.menu.menu1 .menu__collapse').menuAim({
259			rowSelector:'.menu__level-1-li',
260			submenuSelector:'*',
261			activate:function(data) {
262				changeState($(data), 1);
263			},
264			deactivate:function(data) {
265				changeState($(data), 0);
266			},
267			exitMenu:function(data) {
268				if(!$(data).parent().hasClass('new')) {
269					return true;
270				}
271			}
272		});
273
274		const changeState = (elem, state) => {
275			const child = elem.children(items);
276			
277			if(child.css('display') == 'none') child.css('opacity', 0);
278			
279			$('.menu__level-1-li:first, .menu__level-1-li:first .menu__level-2').removeClass('open');
280			
281			if(state) {
282				elem.addClass('open');
283				child.addClass('open').animate({opacity: 1}, delay2);
284			} else {
285				elem.removeClass('open');
286				child.removeClass('open');
287			}
288		};
289		
290		const menuBlur = () => {
291			if(typeof(uniJsVars) == 'undefined' || !uniJsVars.menu_blur) return;
292			
293			let blur_delay = 110, blur_timer = '';
294		
295			$('.menu1:not(.new), .menu2').on('mouseenter', () => {
296				blur_timer = setTimeout(() => { 
297					blur_blocks.addClass('blur');
298				}, blur_delay);
299			}).on('mouseleave', () => {
300				clearTimeout(blur_timer);
301				blur_blocks.removeClass('blur');
302			});
303			
304			if($('.menu-wrapper.new').hasClass('show')) {
305				blur_blocks.addClass('blur');
306			} else {
307				blur_blocks.removeClass('blur');
308			}
309		};
310		
311		menuBlur();
312		
313		$('.header-menu__btn').off('click').on('click', function() {
314			const elem = $(this).hasClass('fly-menu__menu-btn') ? '.fly-menu' : 'header', wrapper = elem+' .menu-wrapper.new', li = elem+' .menu1.new .menu__level-1-li';
315				
316			$(this).toggleClass('show');
317			
318			changeState($(li).not(':first-child'), 0);
319			changeState($(li).first(), 1);
320			
321			$(wrapper).toggleClass('show');
322		
323			menuBlur();
324		});
325		
326		$('main, footer').off('click').on('click touchstart', () => {
327			$(items).removeClass('open');
328			$('.menu__chevron').removeClass('open');
329			$('.menu .collapse').collapse('hide');
330			
331			$('body').removeClass('scroll-disabled');
332			$('.menu-wrapper, .header-menu__btn').removeClass('show');
333			
334			blur_blocks.removeClass('blur');
335		});
336		
337		//setTimeout(() => {
338			uniMenuDropdownPos();
339		//}, 100);
340	}
341	
342	const menu = 0;
343	
344	if($('#menu').hasClass('slide-down')) {
345		$('.menu__chevron').off('click').on('click', function() {
346			$(this).toggleClass('open');
347			$(this).parent().toggleClass('active');
348			$(this).next().collapse('toggle');
349		});
350	} else {
351		$('.menu__chevron').off('click').on('click', function() {
352			$(this).next().toggleClass('active');
353		});
354		
355		$('.menu__back').off('click').on('click', function() {
356			$(this).parent().toggleClass('active');
357			$(this).parent().parent().toggleClass('active');
358		});
359	}
360	
361	$('.menu-open, .menu-close').off('click').on('click', () => {
362		$('body').toggleClass('scroll-disabled');
363		$('.menu-wrapper').toggleClass('show');
364		$('.fly-menu__block').removeClass('show');
365	});
366};
367
368function uniMenuUpd(block) {
369	
370	if(!$(block).length) return;
371	
372	const init = () => {
373		let menu_block = $(block), menu_items = menu_block.children('.menu__level-1-li:not
373(.menu__additional)');
374			
375		menu_items.css('display', '');
376			
377		if(window.innerWidth > 991) {
378			
379			menu_block.find('.menu__additional').remove();
380		
381			let coord = menu_block.offset().left + menu_block.width(), flag = false, new_items = '';
382			
383			if(!menu_items.length || Math.floor(menu_items.last().offset().left + menu_items.last().width()) <= coord) return;
384		
385			menu_items.each(function() {
386				if($(this).offset().left + $(this).width() > coord - 60) {
387					let item = $(this).find('> a'), item_child = $(this).find('.menu__level-2-a'), new_child_items = '';
388				
389					if(item_child.length) {
390						new_child_items = '<div class="menu__level-3"><ul class="menu__level-3-ul">';
391				
392						item_child.each(function() {
393							new_child_items += '<li class="menu__level-3-li"><a class="menu__level-3-a';
394	
395							if(!$(this).attr('href').length) new_child_items += 'disabled';
396						
397							new_child_items += '" href="'+$(this).attr('href')+'">'+$(this).text()+'</a></li>';
398						});
399					
400						new_child_items += '</ul></div>';
401					}
402				
403					new_items += '<div class="menu__level-2-ul col-md-12"><a class="menu__level-2-a';
404				
405					if(new_child_items) new_items += ' has-children';
406				
407					if(!item.attr('href').length) new_items += ' disabled';
408
409					new_items += '" href="'+item.attr('href')+'">'+item.text()+'</a>'+new_child_items+'</div>';
410
411					$(this).hide();
412				
413					flag = true;
414				} else {
415					$(this).show();
416				}
417			});
418		
419			if (flag) {
420				if (!menu_block.find('.menu__additional').length) {
421					let html = '<li class="menu__level-1-li menu__additional has-children">';
422						html += '<a class="menu__level-1-a additional" href="#" onclick="return false"><i class="fa fa-ellipsis-h"></i></a>';
423						html += '<div class="menu__level-2 column-1"></div>';
424						html += '</li>';
425					
426					menu_block.append(html);
427				
428					uniMenuAim();
429				}
430				
431				menu_block.find('.menu__additional .menu__level-2').html(new_items);
432			}
433		}
434	}
435	
436	init();
437	
438	setTimeout(() => {
439		init();
440	}, 200);
441	
442	$(window).resize(init);
443};
444
445function uniMenuDropdownHeight() {
446	const menu_block = $('header .menu1:not(.new) .menu__level-2, header .menu2 .menu__level-2');
447	
448	if(menu_block.length) {
449		const init = () => {
450			if(window.innerWidth > 991) {
451				menu_block.css('max-height', ($(window).height() - $('header .menu').offset().top - 100));
452			} else {
453				menu_block.css('max-height', '');
454			}
455		}
456	
457		init();
458	
459		$(window).resize(init);
460	}
461};
462
463function uniMenuDropdownPos() {
464	const menu_block = $('header .menu2');
465	
466	if(menu_block.length) {
467		const init = () => {
468			if(window.innerWidth > 991) {
469				menu_block.find('.menu__level-2').each(function() {
470					const child_pos = ($(this).parent().offset().left + $(this).outerWidth()) - (menu_block.offset().left + menu_block.outerWidth());
471			
472					$(this).css('margin-left', '-'+(child_pos > 0 ? child_pos : 0)+'px');
473				});
474			}
475		}
476		
477		init();
478	
479		$(window).resize(init);
480	}
481};
482
483function uniMenuMobile() {
484	const menu1 = $('.menu1 .menu__collapse'), menu2 = $('.menu-right .menu__collapse');
485		
486	if(menu1.length && menu2.length) {
487		const init = () => {
488			if(window.innerWidth < 991) {
489				let item = menu1.find('.menu__level-1-a'), arr = [];
490				
491				item.each(function() {
492					arr.push($(this).text().trim());
493				});
494				
495				menu2.find('.menu__level-1-a').each(function() {
496					if(arr.indexOf($(this).text().trim()) === -1) {
497						$(this).parent().addClass('new-items').appendTo(menu1);
498					}
499				});
500			} else {
501				menu1.find('.new-items').removeClass('new-items').appendTo(menu2);
502			}
503		}
504	
505		init();
506	
507		$(window).resize(init);
508	}
509}
510
511function uniBannerLink(url) {
512	$.ajax({
513		url: url,
514		type: 'get',
515		dataType: 'html',
516		success: function(data) {
517			var data = $(data), title, text;
518			
519			title = data.find('h1').text(), 
520			data.find('h1').remove();
521			text = data.find('#content').html();
522			
523			uniModalWindow('modal-banner', 'lg', title, text);
524		}
525	});
526}
527
528function form_error(form, input, text) {
529	let element = $(form+' input[name="'+input+'"], '+form+' textarea[name="'+input+'"], '+form+' select[name="'+input+'"]').addClass('input-warning'), time = 15;
530	
531	if(typeof(uniJsVars) != 'undefined') time = uniJsVars.alert_time;
532	
533	setTimeout(() => { 
534		$(form+' .input-warning').removeClass('input-warning');
535	}, time*1000);
536	
537	$(form+' .input-warning').click(function() {
538		$(this).removeClass('input-warning');
539	});
540}
541
542function uniScrollTo(target, time = 200) {
543	let top = 20;
544	
545	if(window.innerWidth > 991) {
546		if(uniJsVars.fly_menu.fixed_header) top += $('header').height();
547		if(uniJsVars.fly_menu.topmenu_hide) top -= $('.top-menu').height();
548		if($('.fly-menu').length) top += $('.fly-menu').height();
549	}
550	
551	$('html, body').animate({scrollTop: $(target).offset().top - top}, time);
552}
553
554function uniModalWindow(id, type, title, data) {
555	
556	/* 	id = id modal form;	type = sm, lg, or empty; title = title modal form; data = text or other data modal form; */
557	
558	$('#'+id).remove();
559				
560	let html  = '<div id="'+id+'" class="modal '+uniJsVars.popup_effect_in+'">';
561		html += '<div class="modal-dialog modal-'+type+'">';
562		html += '<div class="modal-content">';
563		html += '<div class="modal-header">';
564		html += '<button type="button" class="close" data-dismiss="modal">&times;</button>';
565		html += '<h4 class="modal-title">'+title+'</h4>';
566		html += '</div>';
567		html += '<div class="modal-body">'+data+'</div>';
568		html += '</div>';
569		html += '</div>';
570		html += '</div>';
571	
572	$('html body').append(html);
573	$('#'+id).modal('show');
574}
575
576function uniFlyAlert(type, data) {
577	let time = 15, effectIn = 'animated bounceInRight', effectOut = 'animated bounceOutRight';
578	
579	if(typeof(uniJsVars) != 'undefined') {
580		time = uniJsVars.alert_time;
581		effectIn = uniJsVars.alert_effect_in;
582		effectOut = uniJsVars.alert_effect_out;
583	}
584	
585	let time1 = time*1000,
586		time2 = time1+1000,
587		time3 = 100,
588		top_offset = 50,
589		top_margin = 15,
590		icon;
591	
592	if(type == 'success') icon = 'far fa-circle-check';
593	if(type == 'danger') icon = 'fas fa-exclamation-circle';
594	if(type == 'warning') icon = 'fas fa-exclamation-circle';
595	
596	$('.uni-alert').remove();
597	
598	let createAlert = (data) => {
599		if($('.uni-alert').length) {
600			top_offset = $('.uni-alert:last').position().top + $('.uni-alert:last').outerHeight() + top_margin;
601		}
602	
603		const block = $('<div class="uni-alert alert-'+type+' '+effectIn+'" style="top:'+top_offset+'px"><i class="uni-alert__icon '+icon+'"></i><div>'+data+'</div><i class="uni-alert__icon fas fa-times" onclick="$(this).parent().remove()"></i></div>');
604	
605		$('html body').append(block);
606	
607		setTimeout(() => {
608			block.removeClass(effectIn).addClass(effectOut);
609		}, time1);
610	
611		setTimeout(() => {
612			block.remove();
613		}, time2);
614	}
615	
616	if(typeof(data) == 'object') {
617		let arr = [];
618	
619		for (i in data) {
620			arr.push(data[i]);
621		}
622	
623		let index = -1,
624			timer = setInterval(() => {
625			if (++index == arr.length) {
626				clearInterval(timer);
627			} else {
628				createAlert(arr[index]);
629			}
630		}, time3);
631	} else {
632		createAlert(data);
633	}
634}
635
636const uniDescCollapse = (parent_block, collapse_block) => {
637	const config = {
638		height_1: Math.round($(parent_block).outerHeight(true)),
639		height_2: Math.round($(collapse_block).outerHeight(true)),
640		div: {'class': 'desc-collapse'},
641		btn: {'class': 'btn btn-default', 'text': uniJsVars.cat_descr_collapse.text_expand}
642	};
643			
644	if(config.height_2 > config.height_1) {
645		$(parent_block).append('<div class="'+config.div.class+'"><button type="button" class="'+config.btn.class+'">'+config.btn.text+'</button></div>');
646			
647		$('html body').on('click', parent_block+' .'+config.div.class+' button', function() {
648			$(this).parent().parent().css('max-height', '100%');
649			$(this).parent().remove();
650		});
651	}
652}
653
654//add css and js from script
655var cssUrls = [], jsUrls = [];
656
657function uniAddCss(url) {
658	if(cssUrls.indexOf(url) == -1) {
659		cssUrls.push(url);
660		$('html head').append('<link href="'+url+'" type="text/css" rel="stylesheet" media="screen">')
661	}
662}
663
664function uniAddJs(url) {
665	if(jsUrls.indexOf(url) == -1) {
666		jsUrls.push(url);
667		$.getScript(url);
668	}
669}
670
671(function($){
672	var Modules = {
673		init:function(options, el) {
674            var base = this;
675			
676			base.$elem = $(el);
677			base.$elem2 = $(el).children();
678			base.options = $.extend({}, $.fn.uniModules.options, options);
679			
680			base.load();
681        },
682		load:function() {
683			var base = this;
684			
685			base.wrapper = (base.$elem2.closest('.tab-content').length) ? base.$elem2.closest('.tab-content') : base.$elem;
686			
687			if((base.options.type == 'grid' && module_on_mobile == 'carousel' && base.wrapper.width()+20 < 768) || base.wrapper.closest('#column-left, #column-right').length) {
688				base.options.type = 'carousel';
689			}
690			
691			if(base.wrapper.closest('#column-left, #column-right').length) {
692				base.options.items = {0: {items: 1}};
693			}
694			
695			if (base.options.type == 'grid') {
696				base.$elem2.children().wrap('<div class="uni-module__item" style="width:'+base.items()+'"></div>');
697			} else {
698				base.$elem2.addClass('owl-carousel').owlCarousel({
699					responsive: base.options.items,
700					responsiveBaseElement: base.wrapper,
701					dots: base.options.dots,
702					mouseDrag: false,
703					rewind: base.options.loop,
704					autoplay: base.options.autoplay,
705					autoplayTimeout: base.options.autoplayTimeout,
706					autoplayHoverPause: base.options.autoplayHoverPause,
707					nav: true
708				});
709				
710				if(base.$elem2.width() == 0) {
711					const item = base.$elem2.find('.owl-item'), item_width = base.items();
712					
713					item.css({width: item_width});
714					base.$elem2.find('.owl-stage').css({width:item.length * item_width});
715				}
716			}
717			
718			base.$elem2.addClass('load-complete');
719			base.responsive();
720		},
721		items:function() {
722			var base = this, match = -1, width = base.wrapper.width();
723			
724			width += (base.wrapper.attr('class') == 'tab-content' && width < 520) ? 10 : 20;
725			
726			$.each(base.options.items, (breakpoint) => {
727				if (breakpoint <= width && breakpoint > match) {
728					match = Number(breakpoint);
729				}
730			});
731			
732			const items = base.options.items[match]['items']
733			
734			return (base.options.type == 'carousel') ? width/items : 100/items+'%';
735		},
736		responsive:function() {
737            var base = this, lastWindowWidth = window.innerWidth;
738			
739			base.resizer = () => {
740                if (window.innerWidth != lastWindowWidth || uni_touch_support) {
741					if (base.options.type == 'grid') {	
742						base.$elem2.children().css('width', base.items());
743					}
744                }
745            };
746			
747			const time = base.options.type == 'grid' ? 100 : 0;
748			
749			$(window).resize(() => {
750				setTimeout(() => {
751					base.resizer();
752				}, time);
753			});
754        }
755	};
756	
757	$.fn.uniModules = function(options) {		
758		return this.each(function() {
759            if ($(this).data('uni-modules-init') === true) {
760                return false;
761            }
762			
763            $(this).data('uni-modules-init', true);
764			
765            var module = Object.create(Modules);
766            module.init(options, this);
767        });
768	};
769	
770	if(typeof(items_on_mobile) == 'undefined') items_on_mobile = 2;
771	
772	$.fn.uniModules.options = {
773		type 	   :'carousel',
774		items	   :{0:{items:items_on_mobile},700:{items:3},992:{items:4},1400:{items:5}},
775		dots	   :true,
776		loop	   :false,
777		autoplay   :false,
778		autoplayTimeout: 2000,
779		autoplayHoverPause: false
780	};
781})(jQuery);
782
783const uniSearch = {
784	init: function() {
785		let base = this, phrase_arr = uniJsVars.search.phrase_arr, cleaning = uniJsVars.search.cleaning_status, w_width = window.innerWidth, breakpoint = 575;
786		
787		$('body').on('click', '.header-search__category-li', function() {
788			const elem = $(this), parent = elem.closest('.header-search'), btn = parent.find('.header-search__category-btn'), span = btn.find('.header-search__category-span');
789			
790			btn.attr('title', elem.data('title'));
791			
792			if(elem.is(':first-child')) {
793				span.text('').removeClass('v');
794			} else {
795				span.text(elem.text()).addClass('v');
796			}
797			
798			parent.find('input[name="filter_category_id"]').val(elem.data('id'));
799		});
800
801		$('body').on('click', '.header-search__btn', function() {
802			let url = uniJsVars.search.url,
803				seo_url = uniJsVars.search.seo_url,
804				elem = $(this).closest('.header-search'),
805				elem_input = elem.find('input[name="search"]'),
806				search = elem.find('input[name="search"]').val(), 
807				filter_category_id = elem.find('input[name="filter_category_id"]').val();
808				
809			if (!search && phrase_arr.length && w_width > breakpoint) search = elem_input.attr('placeholder');
810			
811			if (search) {
812				url += (seo_url ? '/?' : '&') + 'search=' + encodeURIComponent(search);			
813				
814				if (filter_category_id > 0) url += '&category_id='+encodeURIComponent(filter_category_id)+'&sub_category=true';
815				
816				window.location = url;
817			}
818		});
819
820		$('body').on('keydown', '.header-search__input', function(e) {
821			if (e.keyCode == 13) $(this).parent().find('.header-search__btn').click();
822		});
823	
824		if (w_width > breakpoint && phrase_arr.length > 1) {
825			new Typed('.header-search__input', {
826				strings: phrase_arr,
827				startDelay: 3000,
828				typeSpeed: 80,
829				backDelay: 1500,
830				backSpeed: 45,
831				attr: 'placeholder',
832				bindInputFocusEvents: true,
833				loop: true
834			});
835		}
836		
837		base.clearBtn();
838	},
839	clearBtn: function() {
840		const input = 'input[name="search"]', btn = '.search-btn-clear';
841	
842		$(input).each(function() {
843			$(this).on('input', () => {
844				$(input).not($(this)).val($(this).val());
845			
846				if($(this).val() != '') {
847					$(btn).addClass('show');
848				} else {
849					$(btn).removeClass('show');
850				}
851			});
852		});
853	
854		$('body').on('click', btn, () => {
855			$(input).val('');
856			$(btn).removeClass('show');
857			if (typeof(uniLiveSearch.hide) === 'function') uniLiveSearch.hide();
858		});
859	}
860};
861
862const uniSelectView = {
863	init:function(viewtype){
864		var base = this;
865		
866		base.display = default_view;
867		base.displayMobile = default_mobile_view;
868		
869		if(typeof(viewtype) != 'undefined') {
870			base.display = viewtype;
871		} else if(typeof(MegaFilter) === 'function' && localStorage.getItem('displayMFP')) {
872			base.display = localStorage.getItem('displayMFP');
873		} else if(localStorage.getItem('display')) {
874			base.display = localStorage.getItem('display');
875		}
876		
877		base.bind();
878		base.switcher();
879	},
880	switcher:function() {
881		var base = this, lastWindowWidth = window.innerWidth, breakpoint = 991;
882		
883		base.switcher2 = (new_width) => {
884			if(localStorage.getItem('displayMobile')) base.displayMobile = localStorage.getItem('displayMobile');
885			
886			if(!$('.products-block').length) return;
887			
888			let disp = (new_width <= breakpoint) ? base.displayMobile : base.display;
889			
890			if (disp == 'list') {
891				base.list();
892			} else if (disp == 'grid') {
893				base.grid();
894			} else {
895				base.compact();
896			}
897		}
898			
899		base.switcher2(lastWindowWidth);
900			
901		$(window).resize(function(){
902			if($(this).width() != lastWindowWidth) {
903				base.switcher2($(this).width());
904			}
905		});
906	},
907	list:function() {
908		var base = this, breakpoint = 992, product_layout = $('.product-layout'), new_class = 'product-layout product-list list-view col-sm-12';
909		
910		if(!product_layout.first().attr('class').includes('list-view')) {
911			$('.list-view, .grid-view, .compact-view, .product-grid, .product-list, .product-compact').attr('class', new_class);
912			
913			$.post('index.php?route=extension/module/uni_new_data/setDefaultView', {view: 'list'});
914		}
915		
916		$('.sorts-block__btn').addClass('selected').not('#list-view').removeClass('selected');
917		
918		base.setItem('list');
919	},
920	grid:function() {
921		var base = this, breakpoint = 992, col_left = $('#column-left').length, col_right =  $('#column-right').length, product_layout = $('.product-layout'), new_class = 'product-layout product-grid grid-view col-sm-6 col-md-3 col-lg-3 col-xxl-4';
922
923		if (col_left && col_right) {
924			new_class = 'product-layout product-grid grid-view col-sm-12 col-md-6 col-lg-6 col-xxl-6-1';
925		} else if (col_left || col_right) {
926			new_class = 'product-layout product-grid grid-view col-sm-6 col-md-4 col-lg-4 col-xxl-5';
927		}
928		
929		if(!product_layout.first().attr('class').includes('grid-view')) {
930			$.post('index.php?route=extension/module/uni_new_data/setDefaultView', {view: 'grid'});
931		}
932		
933		$('.list-view, .grid-view, .compact-view, .product-grid, .product-list, .product-compact').attr('class', new_class);
934		
935		$('.sorts-block__btn').addClass('selected').not('#grid-view').removeClass('selected');
936		
937		base.setItem('grid');
938	},
939	compact:function() {
940		var base = this, breakpoint = 992, product_layout = $('.product-layout'), new_class = 'product-layout product-price compact-view col-sm-12';
941		
942		if(!product_layout.first().attr('class').includes('compact-view')) {
943			$('.list-view, .grid-view, .compact-view, .product-grid, .product-list, .product-compact').attr('class', new_class);
944			
945			$.post('index.php?route=extension/module/uni_new_data/setDefaultView', {view: 'compact'});
946		}
947		
948		$('.sorts-block__btn').addClass('selected').not('#compact-view').removeClass('selected');
949		
950		base.setItem('compact');
951	},
952	bind:function() {
953		var base = this;
954		$('#list-view').on('click', () => {
955			base.list();
956		});
957		$('#grid-view').on('click', () => {
958			base.grid();
959		});
960		$('#compact-view').on('click', () => {
961			base.compact();
962		});
963	},
964	setItem:function(display) {
965		var base = this, breakpoint = 992;
966		
967		localStorage.setItem('display', display);
968		localStorage.setItem('displayMFP', display);
969		if($(window).width() <= breakpoint) localStorage.setItem('displayMobile', display);
970	}
971};
972
973const uniChangeBtn = {
974	'init': function() {
975		var base = this;
976		
977		base.cart();
978		base.compare();
979		base.wishlist();
980	
981		$(document).ajaxStop(() => {
982			base.cart();
983			base.compare();
984			base.wishlist();
985		});
986	},
987	'productsInCart': function() {
988		const products = $('.header-cart__wrapper').data('products');
989		
990		return String(products).split(', ');
991	},
992	'cart': function(b, f) {
993		var base = this;
994		
995		const products = base.productsInCart();
996		
997		const changeBtnText = (btn, flag) => {
998			if(btn.hasClass('disabled')) return;
999				
1000			if(flag == 'normal') {
1001				btn.removeClass('in_cart');
1002				btn.children('i').attr('class', uniJsVars.cart_btn.icon);
1003				btn.children('span').text(uniJsVars.cart_btn.text);
1004			}
1005				
1006			if(flag == 'incart') {
1007				btn.addClass('in_cart');
1008				btn.children('i').attr('class', uniJsVars.cart_btn.icon_incart);
1009				btn.children('span').text(uniJsVars.cart_btn.text_incart);
1010			}
1011				
1012			if(flag == 'disabled') {
1013				btn.removeClass('in_cart');
1014				btn.children('i').attr('class', uniJsVars.cart_btn.icon_disabled);
1015				btn.text(uniJsVars.cart_btn.text_disabled);
1016			}
1017		};
1018		
1019		if(typeof(b) != 'undefined' && typeof(f) != 'undefined') {
1020			changeBtnText(b, f);
1021			return;
1022		}
1023		
1024		if(products != 'undefined') {
1025			const for_pp = products.filter(elem => elem.indexOf('_') === -1).map(Number);
1026			
1027			if(for_pp) {
1028				$('.product-page__add-to-cart').each(function() {
1029					if(for_pp.indexOf($(this).data('pid')) !== -1) {
1030						changeBtnText($(this), 'incart');
1031					}
1032				});
1033			};
1034			
1035			const for_cat = products.map(elem => Number(elem.split('_')[0]));
1036			
1037			if(for_cat) {
1038				$('.product-thumb__add-to-cart, .compare-page__cart').each(function() {
1039					if(for_cat.indexOf($(this).data('pid')) !== -1) {
1040						changeBtnText($(this), 'incart');
1041					}
1042				});
1043			};
1044			
1045			$('body').on('change', '.option input[type="checkbox"], .option input[type="radio"], .option select', function() {
1046				let elem = $(this).closest('.product-page'), btn = $('.product-page__add-to-cart');
1047				
1048				if($(this).closest('.product-thumb').length) {
1049					elem = $(this).closest('.product-thumb'); btn = elem.find('.product-thumb__add-to-cart');
1050				}
1051				
1052				if(elem.length)	checkedOptions(elem, btn);
1053			});
1054			
1055			const checkedOptions = (elem, btn) => {
1056				if(typeof(elem) == 'undefined')	{
1057					elem = $('.product-page'); btn = $('.product-page__add-to-cart');
1058				}
1059				
1060				let options = elem.find('.option input:checked, .option option:selected'), stat = 0;
1061				
1062				if(options.length) {
1063					options.each(function() {
1064						if(products.includes($(this).data('option-id'))) {
1065							stat++;
1066						} else {
1067							stat--;
1068						}
1069					});
1070
1071					changeBtnText(btn, (options.length == stat ? 'incart' : 'normal'));
1072				}
1073			};
1074			
1075			checkedOptions();			
1076		}
1077	},
1078	'compare': function() {
1079		let products = $('.top-menu__compare').data('products');
1080		
1081		if(!products) return;
1082		
1083		products = String(products).split(',').map(Number);
1084		
1085		$('.product-thumb__compare, .product-page__compare-btn').each(function() {
1086			const pid = Number($(this).attr('onclick').replace(/\D+/g,''));
1087			
1088			if(products.indexOf(pid) !== -1) {
1089				$(this).attr('onclick', $(this).attr('onclick').replace('compare.add', 'compare.remove')).attr('title', uniJsVars.compare_btn.text_remove).addClass('active').find('span').text(uniJsVars.compare_btn.text_remove);
1090			}
1091		});
1092	},
1093	'wishlist': function() {
1094		let products = $('.top-menu__wishlist').data('products');
1095		
1096		if(!products) return;
1097		
1098		products = String(products).split(',').map(Number);
1099		
1100		$('.product-thumb__wishlist, .product-page__wishlist-btn').each(function() {
1101			const pid = Number($(this).attr('onclick').replace(/\D+/g,''));
1102			
1103			if(products.indexOf(pid) !== -1) {
1104				$(this).attr('onclick', $(this).attr('onclick').replace('wishlist.add', 'wishlist.remove')).attr('title', uniJsVars.wishlist_btn.text_remove).addClass('active').find('span').text(uniJsVars.wishlist_btn.text_remove);
1105			}
1106		});
1107	}
1108};
1109
1110const cart = {
1111	'add': function(product_id, elem, several) {
1112		
1113		var $elem = $(elem).closest('.product-thumb, .product-thumb-related'),
1114			product_qty = $elem.find('input[name="quantity"]').val(), 
1115			product_options = $elem.find('.option input[type="text"], .option input[type="hidden"], .option input:checked, .option select, .option textarea'),
1116			data = 'product_id='+product_id+'&quantity='+(typeof(product_qty) != 'undefined' ? product_qty : 1);
1117			
1118		if (product_options.length) {
1119			data += '&'+product_options.serialize();
1120		}
1121		
1122		$.ajax({
1123			url: $('base').attr('href')+'index.php?route=checkout/cart/add',
1124			type: 'post',
1125			data: data,
1126			dataType: 'json',
1127			success: function(json) {
1128				$('.text-danger').remove();
1129				
1130				if (json['redirect'] && !json['error']['stock'] && (!$elem.find('.option [name^=\'option\']').length || $elem.find('.option').css('display') == 'none')) {
1131					window.location = json['redirect'];
1132					
1133					return;
1134				}
1135				
1136				$('.form-group').removeClass('has-error');
1137
1138				if (json['error']) {
1139					if (json['error']['option']) {
1140						for (i in json['error']['option']) {
1141							var elem = $('.option .input-option' + i.replace('_', '-')), elem2 = (elem.parent().hasClass('input-group')) ? elem.parent() : elem;
1142							
1143							elem2.after('<div class="text-danger">'+json['error']['option'][i]+'</div>');
1144							$('.option .text-danger').delay(5000).fadeOut();
1145							
1146							uniFlyAlert('danger', json['error']['option'][i])
1147						}
1148					}
1149					
1150					if (json['error']['stock']) {
1151						uniFlyAlert('danger', json['error']['stock']);
1152					}
1153				}
1154
1155				if (json['success']) {
1156					cart.uniCartUpd();
1157					
1158					cart.uniCartActionAfter(several, json['success']);
1159					
1160					dataLayer.push({
1161						'event': 'addToCart',
1162						'ecommerce':{
1163							'currencyCode':uniJsVars.currency.code,
1164							'add':{
1165								'products':[json['products']['products']]
1166							}
1167						}
1168					});
1169					
1170					if (typeof(gtag) === 'function') {
1171						dataLayer.push({
1172							'event': "add_to_cart",
1173							'ecommerce': {
1174								'currency': uniJsVars.currency.code,
1175								'items': [json['products']['items']]
1176							}
1177						});
1178						
1179						//gtag('event', 'add_to_cart', {'currency': uniJsVars.currency.code, 'items': json['success']['products']});
1180					}
1181					
1182					if(uniJsVars.cart_btn.metric_id && uniJsVars.cart_btn.metric_target) {
1183						if (typeof(ym) === 'function') {
1184							ym(uniJsVars.cart_btn.metric_id, 'reachGoal', uniJsVars.cart_btn.metric_target);
1185						} else {
1186							new Function('yaCounter'+uniJsVars.cart_btn.metric_id+'.reachGoal(\''+uniJsVars.cart_btn.metric_target+'\')')();
1187						}
1188					}
1189					
1190					if(uniJsVars.cart_btn.analytic_category && uniJsVars.cart_btn.analytic_action) {
1191						if (typeof(gtag) === 'function') {
1192							gtag('event', uniJsVars.cart_btn.analytic_action, {'event_category': uniJsVars.cart_btn.analytic_category});
1193						} else if (typeof(ga) === 'function') {
1194							ga('send', 'event', uniJsVars.cart_btn.analytic_category, uniJsVars.cart_btn.analytic_action);
1195						}
1196					}
1197				}
1198			},
1199	        error: function(xhr, ajaxOptions, thrownError) {
1200	            //alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
1201				alert(xhr.responseText);
1202	        }
1203		});
1204	},
1205	'update': function(key, quantity, product_id) {
1206		$.ajax({
1207			url: $('base').attr('href')+'index.php?route=checkout/cart/edit',
1208			type: 'post',
1209			data: 'quantity['+key+']='+quantity,
1210			dataType: 'html',
1211			beforeSend: function() {
1212				if(!$('#unicheckout').length) {
1213					$('.header-cart__wrapper, .checkout-cart__wrap').append('<div class="preloader"></div>');
1214				}
1215			},
1216			success: function() {
1217				cart.uniCartUpd(key);
1218			},
1219	        error: function(xhr, ajaxOptions, thrownError) {
1220	            //alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
1221				alert(xhr.responseText);
1222	        }
1223		});
1224	},
1225	'remove': function(key, product_id) {
1226		$.ajax({
1227			url: $('base').attr('href')+'index.php?route=checkout/cart/remove',
1228			type: 'post',
1229			data: 'key='+key,
1230			dataType: 'json',
1231			beforeSend: function() {
1232				if(!$('#unicheckout').length) {
1233					$('.header-cart__wrapper, .checkout-cart__wrap').append('<div class="preloader"></div>');
1234				}
1235			},
1236			success: function(json) {
1237				cart.uniCartUpd();
1238
1239				$('.product-thumb__add-to-cart, .product-page__add-to-cart').each(function(){
1240					if(product_id == $(this).data('pid')) {
1241						if($(this).hasClass('qty-0')) {
1242							uniChangeBtn.cart($(this), 'disabled');
1243						} else {
1244							uniChangeBtn.cart($(this), 'normal');
1245						}
1246					}
1247				});
1248			},
1249	        error: function(xhr, ajaxOptions, thrownError) {
1250	            //alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
1251				alert(xhr.responseText);
1252	        }
1253		});
1254	},
1255	'uniCartUpd': function(key) {
1256		$.get('index.php?route=common/cart/info', (data) => {
1257			$('.header-cart__dropdown').html($(data).find('.header-cart__dropdown').html());
1258			
1259			const items = '.header-cart__total-items, .fly-menu__cart-total', total = $(data).find('.header-cart__total-items').text();
1260			
1261			if(total > 0) {
1262				$(items).removeClass('hidden').text(total);
1263			} else {
1264				$(items).addClass('hidden');
1265			}
1266			
1267			if($('#modal-cart').length) {
1268				const wrapper = '#modal-cart .header-cart__wrapper', scroll_top = $(wrapper).scrollTop();
1269				
1270				$('#modal-cart .modal-body').html($(data).find('.header-cart__dropdown').html());
1271				
1272				$(wrapper).scrollTop(scroll_top);
1273				
1274				if($('#modal-cart .header-cart__empty').length) {
1275					setTimeout(() => { 
1276						$('#modal-cart').modal('hide');
1277					}, 3000);
1278				}
1279			}
1280			
1281			if($('#checkout-cart').length || $('#checkout-checkout').length) {
1282				window.location = 'index.php?route=checkout/cart';
1283			}
1284		});
1285		
1286		typeof(uniDelPageCache) === 'function' && uniDelPageCache();
1287		  
1288		$('#unicheckout').length && uniCheckoutUpdate();
1289	},
1290	'uniCartActionAfter': function(action, text) {
1291		if(action != 'several') {
1292			action = uniJsVars.cart_add_after;
1293		}
1294		
1295		if(!$('#unicheckout').length) {
1296			if(action == 'popup') {
1297				setTimeout(() => { 
1298					uniModalWindow('modal-cart', '', uniJsVars.modal_cart.text_heading, $('header').find('.header-cart__dropdown').html());
1299				}, 150);
1300						
1301				if(uniJsVars.modal_cart.autohide) {
1302					setTimeout(() => { 
1303						$('#modal-cart').modal('hide');
1304					}, uniJsVars.modal_cart.autohide_time * 1000);
1305				}
1306			} else if (action == 'alert') {
1307				uniFlyAlert('success', text);
1308			} else if (action == 'redirect') {
1309				window.location = $('base').attr('href')+'index.php?route=checkout/cart';
1310			}
1311		}
1312	}
1313};
1314
1315var voucher = {
1316	'add': function() {
1317
1318	},
1319	'remove': function(key) {
1320		$.ajax({
1321			url: $('base').attr('href')+'index.php?route=checkout/cart/remove',
1322			type: 'post',
1323			data: 'key=' + key,
1324			dataType: 'json',
1325			beforeSend: function() {
1326				if(!$('#unicheckout').length) {
1327					$('.header-cart__wrapper, .checkout-cart__wrap').append('<div class="preloader"></div>');
1328				}
1329			},
1330			success: function(json) {
1331				cart.uniCartUpd();
1332			},
1333	        error: function(xhr, ajaxOptions, thrownError) {
1334	            //alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
1335				alert(xhr.responseText);
1336	        }
1337		});
1338	}
1339}
1340
1341var wishlist = {
1342	'add': function(product_id) {
1343		$.ajax({
1344			url: $('base').attr('href')+'index.php?route=account/wishlist/add',
1345			type: 'post',
1346			data: 'product_id=' + product_id,
1347			dataType: 'json',
1348			success: function(json) {
1349				if (json['redirect']) {
1350					window.location = json['redirect'];
1351				}
1352
1353				if (json['success']) {
1354					if(json['success'].indexOf('account/login') !== -1) {
1355						uniFlyAlert('warning', json['success']);
1356					} else {
1357						uniFlyAlert('success', json['success']);
1358					}
1359					
1360					let wishlist_total = (json['success'].indexOf('account/login') == -1) ? json['total'].replace(/\s+/g, '').match(/(\d+)/g) : 0;
1361					
1362					wishlist.uniWishlistUpd(wishlist_total);
1363				}
1364			}
1365		});
1366	},
1367	'remove': function(product_id) {
1368		$.ajax({
1369			url: 'index.php?route=extension/module/uni_new_data/wishlistRemove',
1370			type: 'post',
1371			data: 'product_id='+product_id,
1372			dataType: 'json',
1373			success: function(json) {
1374				if (json['success']) {
1375					uniFlyAlert('warning', json['success']);
1376					
1377					wishlist.uniWishlistUpd(json['total']);
1378					
1379					$('.product-thumb__wishlist, .product-page__wishlist-btn').each(function() {
1380						let pid = Number($(this).attr('onclick').replace(/\D+/g,''));
1381			
1382						if(product_id == pid) {
1383							$(this).attr('onclick', $(this).attr('onclick').replace('wishlist.remove', 'wishlist.add')).attr('title', uniJsVars.wishlist_btn.text).removeClass('active').find('span').text(uniJsVars.wishlist_btn.text);
1384						}
1385					});
1386				}
1387			}
1388		});
1389	},
1390	'uniWishlistUpd': function(total){
1391		const items = '.fly-block__wishlist-total, .fly-menu__wishlist-total, .top-menu__wishlist-total, .header-wishlist__total-items';
1392		
1393		if(total > 0) {
1394			$(items).removeClass('hidden').text(total);
1395		} else {
1396			$(items).addClass('hidden');
1397		}
1398		
1399		typeof(uniDelPageCache) === 'function' && uniDelPageCache();
1400		
1401		$.get('index.php?route=account/wishlist', (data) => {
1402			$('.top-menu__wishlist').data('products', $(data).find('.top-menu__wishlist').data('products'));
1403		});
1404	}
1405}
1406
1407var compare = {
1408	'add': function(product_id) {
1409		$.ajax({
1410			url: 'index.php?route=product/compare/add',
1411			type: 'post',
1412			data: 'product_id=' + product_id,
1413			dataType: 'json',
1414			success: function(json) {
1415				if (json['success']) {
1416					uniFlyAlert('success', json['success']);
1417					
1418					$('#compare-total').html('<i class="compare-block__icon fas fa-align-right"></i>'+json['total']);
1419					
1420					let compare_total = json['total'].replace(/\s+/g, '').match(/(\d+)/g);
1421					
1422					compare.uniCompareUpd(compare_total);
1423				}
1424			}
1425		});
1426	},
1427	'remove': function(product_id) {
1428		$.ajax({
1429			url: 'index.php?route=extension/module/uni_new_data/compareRemove',
1430			type: 'post',
1431			data: 'product_id='+product_id,
1432			dataType: 'json',
1433			success: function(json) {
1434				if (json['success']) {
1435					uniFlyAlert('warning', json['success']);
1436					
1437					compare.uniCompareUpd(json['total']);
1438					
1439					$('.product-thumb__compare, .product-page__compare-btn').each(function() {
1440						let pid = Number($(this).attr('onclick').replace(/\D+/g,''));
1441			
1442						if(product_id == pid) {
1443							$(this).attr('onclick', $(this).attr('onclick').replace('compare.remove', 'compare.add')).attr('title', uniJsVars.compare_btn.text).removeClass('active').find('span').text(uniJsVars.compare_btn.text);
1444						}
1445					});
1446				}
1447			}
1448		});
1449	},
1450	'uniCompareUpd': function(total){
1451		const items = '.fly-block__compare-total, .fly-menu__compare-total, .top-menu__compare-total, .header-compare__total-items';
1452		
1453		if(total > 0) {
1454			$(items).removeClass('hidden').text(total);
1455		} else {
1456			$(items).addClass('hidden');
1457		}
1458		
1459		typeof(uniDelPageCache) === 'function' && uniDelPageCache();
1460		
1461		$.get('index.php?route=product/compare', (data) => {
1462			$('.top-menu__compare').data('products', $(data).find('.top-menu__compare').data('products'));
1463		});
1464	}
1465}
1466
1467$(document).on('click', '.agree', function(e) {
1468	e.preventDefault();
1469	
1470	var element = this;
1471
1472	$.ajax({
1473		url: $(element).attr('href'),
1474		type: 'get',
1475		dataType: 'html',
1476		success: function(data) {
1477			uniModalWindow('modal-agree', 'lg', $(element).text(), data);
1478		}
1479	});
1480});
1481
1482(function($) {
1483	$.fn.autocomplete = function(option) {
1484		return this.each(function() {
1485			this.timer = null;
1486			this.items = new Array();
1487
1488			$.extend(this, option);
1489
1490			$(this).attr('autocomplete', 'off');
1491
1492			$(this).on('focus', function() {
1493				this.request();
1494			});
1495
1496			$(this).on('blur', function() {
1497				setTimeout(function(object) {
1498					object.hide();
1499				}, 200, this);
1500			});
1501
1502			$(this).on('keydown', function(event) {
1503				switch(event.keyCode) {
1504					case 27: // escape
1505						this.hide();
1506						break;
1507					default:
1508						this.request();
1509						break;
1510				}
1511			});
1512
1513			this.click = function(event) {
1514				event.preventDefault();
1515
1516				value = $(event.target).parent().attr('data-value');
1517
1518				if (value && this.items[value]) {
1519					this.select(this.items[value]);
1520				}
1521			}
1522
1523			this.show = function() {
1524				var pos = $(this).position();
1525
1526				$(this).siblings('ul.dropdown-menu').css({
1527					top: pos.top + $(this).outerHeight(),
1528					left: pos.left
1529				});
1530
1531				$(this).siblings('ul.dropdown-menu').show();
1532			}
1533
1534			this.hide = function() {
1535				$(this).siblings('ul.dropdown-menu').hide();
1536			}
1537
1538			this.request = function() {
1539				clearTimeout(this.timer);
1540
1541				this.timer = setTimeout(function(object) {
1542					object.source($(object).val(), $.proxy(object.response, object));
1543				}, 200, this);
1544			}
1545
1546			this.response = function(json) {
1547				html = '';
1548
1549				if (json.length) {
1550					for (i = 0; i < json.length; i++) {
1551						this.items[json[i]['value']] = json[i];
1552					}
1553
1554					for (i = 0; i < json.length; i++) {
1555						if (!json[i]['category']) {
1556							html += '<li data-value="' + json[i]['value'] + '"><a href="#">' + json[i]['label'] + '</a></li>';
1557						}
1558					}
1559
1560					var category = new Array();
1561
1562					for (i = 0; i < json.length; i++) {
1563						if (json[i]['category']) {
1564							if (!category[json[i]['category']]) {
1565								category[json[i]['category']] = new Array();
1566								category[json[i]['category']]['name'] = json[i]['category'];
1567								category[json[i]['category']]['item'] = new Array();
1568							}
1569
1570							category[json[i]['category']]['item'].push(json[i]);
1571						}
1572					}
1573
1574					for (i in category) {
1575						html += '<li class="dropdown-header">' + category[i]['name'] + '</li>';
1576
1577						for (j = 0; j < category[i]['item'].length; j++) {
1578							html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#">&nbsp;&nbsp;&nbsp;' + category[i]['item'][j]['label'] + '</a></li>';
1579						}
1580					}
1581				}
1582
1583				if (html) {
1584					this.show();
1585				} else {
1586					this.hide();
1587				}
1588
1589				$(this).siblings('ul.dropdown-menu').html(html);
1590			}
1591
1592			$(this).after('<ul class="dropdown-menu"></ul>');
1593			$(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this));
1594
1595		});
1596	}
1597})(window.jQuery);

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.