PageSourceSearch

https://abest.ru/bitrix/templates/abest20/js/script.js

js abest.ru collected 2026-09-24 09:44:27 UTC 5,631 bytes, 235 lines download raw bytes

1window.addEventListener('onBitrixLiveChat', function(event)
2{
3	var widget = event.detail.widget;
4
5	widget.subscribe({
6		type: BX.LiveChatWidget.SubscriptionType.widgetOpen,
7		callback: function(data) {
8			ym(67919182,'reachGoal','bitrix24_chatOpen');
9		}
10	});
11	widget.subscribe({
12		type: BX.LiveChatWidget.SubscriptionType.userMessage,
13		callback: function(data) {
14			ym(67919182,'reachGoal','bitrix24_userMessage');
15		}
16	});
17
18	widget.buttonInstance.buttons.container.getElementsByClassName('b24-widget-button-callback')[0].addEventListener('click', function (e) {
19		ym(67919182,'reachGoal','bitrix24_callbackOpen');
20	});
21});
22
23$(function(){
24	//Detect touch screen and enable scrollbar if necessary
25    function is_touch_device() {
26		try {
27			document.createEvent("TouchEvent");
28			return true;
29		} catch (e) {
30			return false;
31		}
32    }
33    if (is_touch_device()) {
34		$('#nav-mobile').css({ overflow: 'auto'});
35    }
36
37	var trigger = $('button.hamburger'),
38		overlay = $('.overlay'),
39		closebtn = $('.side-nav-close'),
40		isClosed = false, mobileMenuLoaded = 0;
41
42	trigger.click(function () {
43		hamburger_cross(true);      
44	});
45	
46	overlay.click(function () {
47		hamburger_cross(false);      
48	});
49	closebtn.click(function () {
50		hamburger_cross(false);      
51	});
52
53	function hamburger_cross(to_open) {
54		if (to_open) {
55			if(!mobileMenuLoaded){
56				$.ajax({
57					type: "GET",
58					url: '/include/ajax/mobile_menu_load.php',
59					dataType: "html",
60					success: function(data_ajax) {
61						$('.side-nav-in').html(data_ajax);
62						mobileMenuLoaded = 1;
63						
64						initMobileMenuToggle();
65						overlay.show();
66						$('#nav-mobile').addClass('is-open').focus();
67						isClosed = false;
68					}
69				});
70			}else{
71				overlay.show();
72				$('#nav-mobile').addClass('is-open').focus();
73				isClosed = false;
74			}
75		} else {
76			overlay.hide();
77			$('#nav-mobile').removeClass('is-open');
78			isClosed = true;
79		}
80		
81	}
82
83	$('#nav-mobile').mouseover(function() {
84		$( this ).removeClass("fixed");
85		$( this ).children(".side-nav-in").css("width","100%");
86	})
87	.mouseout(function() {
88		$( this ).addClass("fixed");
89		$( this ).children(".side-nav-in").css("width",$(this).width());
90	});
91
92	$('.nicesel').niceSelect();
93
94	$('.side-nav__geoselect, .geo__select').change(function(){
95		let option_sel = $(this).find('option:selected');
96		if (option_sel.length && option_sel.data('url')) {
97			let url_to_redirect = option_sel.data('url');
98			document.location.href = url_to_redirect;
99		}
100	});
101
102	$('.phone-top__link').click(function(e){
103		$('.phone-top__link.active').not(this).removeClass('active');
104		$(this).toggleClass('active');
105
106		e.preventDefault();
107		return false;
108	});
109
110	$('.phone-menu__link').click(function(e){
111		$(this).parents('.phone-menu').prev('.phone-top__link').click();
112		if (this.getAttribute("href").indexOf('tel:') !== 0) {
113			ym(67919182,'reachGoal','header_call_click');
114			console.log('header_call_click');
115		} else if (this.getAttribute("href").indexOf('whatsapp') !== 0) {
116			ym(67919182,'reachGoal','header_whatsapp_click');
117			console.log('header_whatsapp_click');
118		}
119	});
120});
121
122function scroll_to(elem, duration){
123	if (typeof duration == "undefined") duration = 300
124	if ($(elem).length) {
125		var top = $(elem).offset().top;
126		$('body,html').stop().animate({scrollTop: top}, duration);
127	}
128}
129
130function ajaxpostshow(datares, callback) {
131	urlres = "/include/basket.php";
132	wherecontent = "#basket";
133	$.ajax({
134		type: "POST",
135		url: urlres,
136		data: datares,
137		//dataType: "html",
138		success: function(filter) {
139			$(wherecontent).html(filter);
140			if (typeof callback == 'string') actions[callback]();
141			if (typeof callback == 'function') callback();
142		}
143	});
144}
145
146var actions = {
147    openAndScroll: function (){
148		$(".top-cart-dd", "#basket").addClass("opened").fadeTo(300, 1);
149		$("#top-cart-cover").fadeTo(300, 1);
150		scroll_to('#basket');
151		//$('.cart_wrap .dropdown_link').click();
152	}
153};
154
155function basketUpdate(basket) {
156	var param = "action=basket";
157	
158	ajaxpostshow(param);
159}
160
161function basketItemAdd(productid, quantity){
162	if (!productid.toString().match(/^\d+$/g)) 	return;
163	if (typeof quantity == "undefined") quantity = 1;
164
165	var param = "action=add&id="+productid+"&quantity=" + quantity;
166	
167	ajaxpostshow(param, 'openAndScroll');
168
169}
170
171function basketItemDelete($item){
172	if (!$item.data("productid")) return;
173
174	var param = "action=delete&id="+$item.data("productid");
175	
176	ajaxpostshow(param);
177}
178
179function basketClear(){
180	var param = "action=clear";
181	
182	ajaxpostshow(param);
183}
184
185function basketItemQuant($item, newquant){
186	if (!$item.data("productid")) return;
187
188	var param = "action=update&id="+$item.data("productid")+"&count=" + newquant;
189	
190	ajaxpostshow(param);
191}
192
193function initMobileMenuToggle(){
194	initLeftMenu();
195	$(".write-btn").click(SendWriteMsg);
196}
197
198var pcMenuLoaded = false;
199
200function initLeftMenu(){
201	$("ul.leftmenu a.parent").bind('click', function(e){
202		if ($(e.target).hasClass('arrow')){
203			var $t = $(this);
204
205			if($(e.target).hasClass('check-load')){
206				if(!pcMenuLoaded){
207					$.ajax({
208						type: "GET",
209						url: '/include/ajax/pc_menu_load.php',
210						dataType: "html",
211						success: function(data_ajax) {
212							var items = $(data_ajax).find('.js-left-sumbenu');
213							items.each(function(ind, item){
214								let index = $(item).data('ind'), html = $(item).html();
215								$('.js-left-sumbenu-'+index).html(html);
216							});
217
218							
219							$t.parent('li').toggleClass("opened");
220							$t.next("ul").slideToggle(300);
221
222							pcMenuLoaded = 1;
223						}
224					});
225					
226					return false;
227				}
228			}
229
230			$t.parent('li').toggleClass("opened");
231			$t.next("ul").slideToggle(300);
232			return false;
233		}
234	});
235}

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.