PageSourceSearch

http://kolesopiter.ru/catalog/view/theme/oct_ultrastore/js/main.js

js kolesopiter.ru collected 2026-10-06 12:43:54 UTC 13,325 bytes, 492 lines download raw bytes

1/*********** Function viewport ***********/
2function viewport() {
3	var e = window,
4		a = 'inner';
5	if (!('innerWidth' in window)) {
6		a = 'client';
7		e = document.documentElement || document.body;
8	}
9	return {
10		width: e[a + 'Width'],
11		height: e[a + 'Height']
12	};
13}
14
15/*********** Function preloader ***********/
16
17function masked(element, status) {
18  if (status == true) {
19    $('<div/>').attr({ 'class':'masked' }).prependTo(element);
20    $('<div class="masked_loading" />').insertAfter($('.masked'));
21  } else {
22    $('.masked').remove();
23    $('.masked_loading').remove();
24  }
25}
26
27/*********** Function Show Location Map ***********/
28
29function octShowMap(content) {
30
31	var octMap = $('#oct-contact-map');
32
33	if (octMap.hasClass('not_in')) {
34		octMap.html(content);
35		octMap.removeClass('not_in');
36	}
37
38}
39
40/*********** Function popups ***********/
41
42function octPopupCallPhone() {
43	masked('body', true);
44	$( ".modal-backdrop" ).remove();
45	$.ajax({
46        type: 'post',
47        dataType: 'html',
48        url: 'index.php?route=octemplates/module/oct_popup_call_phone',
49        	cache: false,
50        success: function(data) {
51	        masked('body', false);
52            $(".modal-holder").html(data);
53            $("#us-callback-modal").modal("show");
54        }
55    });
56}
57
58function octPopupCart() {
59	masked('body', true);
60	$( ".modal-backdrop" ).remove();
61	$.ajax({
62        type: 'get',
63        dataType: 'html',
64        url: 'index.php?route=octemplates/module/oct_popup_cart',
65        	cache: false,
66        success: function(data) {
67	        masked('body', false);
68            $(".modal-holder").html(data);
69            $("#us-cart-modal").modal("show");
70        }
71    });
72}
73
74function octPopupSubscribe() {
75	if($(".modal-backdrop").length > 0) {
76	    return;
77	}
78	masked('body', true);
79	$( ".modal-backdrop" ).remove();
80	$.ajax({
81        type: 'post',
82        dataType: 'html',
83        url: 'index.php?route=octemplates/module/oct_subscribe',
84        	cache: false,
85        success: function(data) {
86	        masked('body', false);
87            $(".modal-holder").html(data);
88            $("#us-subscribe-modal").modal("show");
89        }
90    });
91}
92
93function octPopupFoundCheaper(product_id) {
94	masked('body', true);
95	$( ".modal-backdrop" ).remove();
96	$.ajax({
97        type: 'post',
98        dataType: 'html',
99        url: 'index.php?route=octemplates/module/oct_popup_found_cheaper',
100        data: 'product_id=' + product_id,
101        	cache: false,
102        success: function(data) {
103	        masked('body', false);
104            $(".modal-holder").html(data);
105            $("#us-cheaper-modal").modal("show");
106        }
107    });
108}
109
110function octPopupLogin() {
111	masked('body', true);
112	$( ".modal-backdrop" ).remove();
113    $.ajax({
114        type: "post",
115        url: 'index.php?route=octemplates/module/oct_popup_login',
116        data: $(this).serialize(),
117        	cache: false,
118        success: function(data) {
119	        masked('body', false);
120            $(".modal-holder").html(data);
121            $("#loginModal").modal("show");
122        }
123    });
124}
125
126function octPopUpView(product_id) {
127	masked('body', true);
128	$( ".modal-backdrop" ).remove();
129	$.ajax({
130        type: 'post',
131        dataType: 'html',
132        url: 'index.php?route=octemplates/module/oct_popup_view',
133        data: 'product_id=' + product_id,
134        	cache: false,
135        success: function(data) {
136	        masked('body', false);
137            $(".modal-holder").html(data);
138            $("#us-quickview-modal").modal("show");
139        }
140    });
141}
142
143function octPopPurchase(product_id) {
144	masked('body', true);
145	$( ".modal-backdrop" ).remove();
146	$.ajax({
147        type: 'post',
148        dataType: 'html',
149        url: 'index.php?route=octemplates/module/oct_popup_purchase',
150        data: 'product_id=' + product_id,
151        	cache: false,
152        success: function(data) {
153	        masked('body', false);
154            $(".modal-holder").html(data);
155            $("#us-one-click-modal").modal("show");
156        }
157    });
158}
159
160/*********** Button column ***********/
161
162function octShowColumnProducts(octButtonPrevID, octButtonNextID, octModuleID) {
163	const buttonPrevID = octButtonPrevID;
164	const buttonNextID = octButtonNextID;
165	const moduleID = octModuleID + ' > .us-item';
166	$("#" + moduleID).slice(0, 1).show();
167	$("#" + octButtonNextID).click(function () {
168		const visibleProduct = $("#" + moduleID + ":visible");
169		const NextProduct = visibleProduct.next();
170		if (NextProduct.length > 0) {
171			visibleProduct.css('display', 'none');
172			NextProduct.fadeIn("slow");
173		} else {
174			visibleProduct.css('display', 'none');
175			$("#" + moduleID + ":hidden:first").fadeIn('slow');
176		}
177	});
178	$("#" + buttonPrevID).click(function () {
179		const visibleProduct = $("#" + moduleID + ":visible");
180		const NextProduct = visibleProduct.prev();
181		if (NextProduct.length > 0) {
182			visibleProduct.css('display', 'none');
183			NextProduct.fadeIn("slow");
184		} else {
185			visibleProduct.css('display', 'none');
186			$("#" + moduleID + ":hidden:last").fadeIn('slow');
187		}
188	});
189}
190
191function getOCTCookie(name) {
192	var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"));
193
194	return matches ? decodeURIComponent(matches[1]) : 'undefined';
195}
196
197/*********** Animate scroll to element function ***********/
198
199function scrollToElement(hrefTo) {
200	const top = $(hrefTo).offset().top-50;
201	$('body,html').animate({scrollTop: top}, 1000);
202}
203
204/*********** Notify function ***********/
205
206function usNotify(type, text) {
207	var iconType = 'info';
208	switch (type) {
209	  case 'success':
210	    iconType = 'fas fa-check';
211	    break;
212	  case 'danger':
213	    iconType = 'fas fa-times';
214	    break;
215	  case 'warning':
216	    iconType = 'fas fa-exclamation';
217	    break;
218	}
219	$.notify({
220		message: text,
221		icon: iconType
222	},{
223		type: type
224	});
225}
226
227/*********** Mask function ***********/
228
229function usInputMask(selector, mask) {
230	$(selector).inputmask({'mask': mask});
231}
232
233$(document).ready(function() {
234
235	//add lazy loading
236	lozad('.oct-lazy').observe();
237
238	$('.us-plus').on('click', function(){
239        const oldVal = $(this).prev().val();
240        var newVal = (parseInt($(this).prev().val(),10) +1);
241		$(this).prev().val(newVal);
242    });
243
244    $('.us-minus').on('click', function(){
245        const oldVal = $(this).next().val();
246        const minimum = $(this).parent().find('.min-qty').val();
247        if (oldVal > 1) {
248            var newVal = (parseInt($(this).next().val(),10) -1);
249        } else {
250	        newVal = 1;
251        }
252        if (newVal < minimum) {
253	        newVal = minimum;
254        }
255        $(this).next().val(newVal);
256    });
257
258    $('.us-cat-button-cart').on('click', function(){
259        const productID = $(this).prev().find('input[name="product_id"]').val();
260        const quantity = $(this).prev().find('.form-control').val();
261        cart.add(productID, quantity);
262    });
263
264	function viewport() {
265		var e = window,
266			a = 'inner';
267		if (!('innerWidth' in window)) {
268			a = 'client';
269			e = document.documentElement || document.body;
270		}
271		return {
272			width: e[a + 'Width'],
273			height: e[a + 'Height']
274		};
275	}
276
277	/*********** To top button ***********/
278
279	$("#back-top").hide(),
280	$(function() {
281	    $(window).scroll(function() {
282	        $(this).scrollTop() > 450 ? $("#back-top").fadeIn() : $("#back-top").fadeOut()
283	    }),
284	    $("#back-top a").click(function() {
285	        return $("body,html").animate({
286	            scrollTop: 0
287	        }, 800),
288	        !1
289	    })
290	});
291
292	/*********** Fixed contacts ***********/
293
294	$('#us_fixed_contact_button').on('click', function () {
295		$(this).toggleClass('clicked');
296		$('.us-fixed-contact-dropdown').toggleClass('expanded');
297		$('.us-fixed-contact-icon .fa-comment-dots').toggleClass('d-none');
298		$('.us-fixed-contact-icon .fa-times').toggleClass('d-none');
299		$('#us_fixed_contact_substrate').toggleClass('active');
300	});
301
302	$('#us_fixed_contact_substrate').on('click', function () {
303		$(this).removeClass('active');
304		$('.us-fixed-contact-dropdown').removeClass('expanded');
305		$('.us-fixed-contact-icon .fa-comment-dots').removeClass('d-none');
306		$('.us-fixed-contact-icon .fa-times').toggleClass('d-none');
307		$('#us_fixed_contact_button').removeClass('clicked');
308	});
309
310	$('.address-dropdown-menu, .shedule-dropdown-menu, .us-fixed-contact-dropdown').click(function(e){
311		e.stopPropagation();
312	});
313
314	$('#us_overlay').on('click', function() {
315		$(this).removeClass('active');
316		$('.ocf-offcanvas').removeClass('active');
317		$('body').removeClass('modal-open');
318		clearLiveSearch();
319	});
320
321	/*********** Category column module ***********/
322
323	$('.us-categories-toggle').on('click', function () {
324		if ($(this).hasClass('clicked') || $(this).parent().parent().hasClass('active')) {
325			$(this).parent().parent().removeClass('active');
326			$(this).parent().next().removeClass('expanded');
327			$(this).removeClass('clicked');
328		} else {
329			$(this).toggleClass('clicked');
330			$(this).parent().next().toggleClass('expanded');
331		}
332	});
333
334	$('.us-product-nav-item').on('click', function () {
335		$('.us-product-nav-item').removeClass('us-product-nav-item-active');
336		$(this).addClass('us-product-nav-item-active');
337	});
338
339	/*********** Mobile scprits ***********/
340
341	var screenWidth = viewport().width;
342
343	var resizeId;
344
345	function makeResize() {
346		// for ajax menu
347		//$('#us_menu_mobile_content').append($('#oct-menu-ul'));
348		$('#us_info_mobile .mobile-address-box').append($('.address-dropdown-menu li'));
349		$('#us_info_mobile .mobile-shedule-box').append($('.shedule-dropdown-menu li'));
350		$('#us_info_mobile .nav-dropdown-menu-content').prepend($('#currency'));
351		$('#us_info_mobile .nav-dropdown-menu-content').prepend($('#language'));
352	}
353
354	function unResize() {
355		// for ajax menu
356		//$('#oct-menu-dropdown-menu').append($('#oct-menu-ul'));
357		$('.address-dropdown-menu').append($('#us_info_mobile .mobile-address-box li.us-dropdown-item, #us_info_mobile .mobile-address-box .us-mobile-map-box'));
358		$('.shedule-dropdown-menu').append($('#us_info_mobile .mobile-shedule-box li.us-dropdown-item'));
359		$('#top-links').prepend($('#currency'));
360		$('#top-links').prepend($('#language'));
361	}
362
363	window.addEventListener('resize', function() {
364	    clearTimeout(resizeId);
365	    resizeId = setTimeout(doneResizing, 500);
366	});
367
368	function doneResizing(){
369		var screenWidth = viewport().width;
370	    if (screenWidth > 767 && screenWidth < 1024) {
371			makeResize();
372		}
373		if (screenWidth > 1023) {
374			unResize();
375		}
376		// if (screenWidth < 768) {
377		// 	$('.us-footer-contact-box').append($('.us-footer-social'));
378		// } else {
379		// 	$('.us-footer-shedule-box').append($('.us-footer-social'));
380		// }
381	}
382
383	function mobileMenu() {
384		var screenWidth = viewport().width;
385
386		if (screenWidth < 992) {
387
388			$('#us_menu_mobile_close').on('click', function () {
389				$('#us_menu_mobile_box').removeClass('expanded');
390				$('body').removeClass('no-scroll');
391				$('.oct-menu-child-ul').removeClass('opened');
392			});
393
394			$('.oct-menu-toggle').on('click', function () {
395				$(this).parent().next().addClass('opened');
396			});
397
398			$('.oct-menu-back').on('click', function () {
399				$(this).parent().removeClass('opened');
400			});
401		} else {
402
403			$('.oct-menu-li').hover(function () {
404				$(this).children('.oct-menu-child-ul').addClass('oct-menu-child-ul-active');
405			});
406
407			$('.oct-menu-li').on('mouseleave', function () {
408				$(this).children('.oct-menu-child-ul').removeClass('oct-menu-child-ul-active');
409			});
410
411			$('.oct-mm-link').hover(function () {
412				$(this).children('.oct-mm-dropdown').addClass('oct-mm-dropdown-active');
413			});
414
415			$('.oct-mm-link').on('mouseleave', function () {
416				$(this).children('.oct-mm-dropdown').removeClass('oct-mm-dropdown-active');
417			});
418			unResize();
419		}
420	}
421
422	/*
423	for ajax menu
424	$('#us_menu_mobile_button').on('click', function () {
425		$('#us_menu_mobile_box').addClass('expanded');
426		$('body').addClass('no-scroll');
427	});
428	*/
429
430	$('#us_menu_mobile_button').on('click', function () {
431
432		const $menuId = $('#us_menu_mobile_content').html().length == 0;
433
434	    if (!$menuId) {
435
436	        	$('#us_menu_mobile_box').addClass('expanded');
437			$('body').addClass('no-scroll');
438
439	    } else {
440			masked('body', true);
441			$.ajax({
442		        type: 'post',
443		        dataType: 'html',
444		        url: 'index.php?route=octemplates/module/oct_megamenu',
445		        data: 'mobile=1',
446		        	cache: false,
447		        success: function(data) {
448			        $("#us_menu_mobile_content").html(data);
449			        $('#us_menu_mobile_box').addClass('expanded');
450					$('body').addClass('no-scroll');
451
452					mobileMenu();
453					masked('body', false);
454		        }
455		    });
456		}
457	});
458
459	// Info mobile
460
461	$('#dropdown_menu_info').on('click', function () {
462		$('#us_info_mobile').addClass('expanded');
463		$('body').addClass('no-scroll');
464	});
465
466	$('#us_info_mobile').on('click', function (e) {
467		  e.stopPropagation();
468	});
469	$('#us_info_mobile_close').on('click', function () {
470		$('#us_info_mobile').removeClass('expanded');
471		$('body').removeClass('no-scroll');
472	});
473
474	if (screenWidth < 992) {
475		makeResize();
476
477		$('.us-footer-title').on('click', function () {
478			$(this).next().slideToggle();
479			$(this).toggleClass('open');
480		});
481
482	} else {
483		unResize();
484	}
485
486	// if (screenWidth < 768) {
487	// 	$('.us-footer-contact-box').append($('.us-footer-social'));
488	// } else {
489	// 	$('.us-footer-shedule-box').append($('.us-footer-social'));
490	// }
491
492});

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.