PageSourceSearch

https://elster.com.ua/catalog/view/theme/oct_ultrastore/js/main.js

js elster.com.ua collected 2026-10-03 02:05:30 UTC 15,308 bytes, 546 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, selector) {
30
31	var octMap = $(selector);
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/*********** Function Show More Product in modules ***********/
228function octShowMoreModule(module_id, lozadEnable = 0, button_id, html_module_id, page_id, path = 0) {
229    let page = parseInt(document.querySelector("#" + page_id).value) + 1;
230
231    $.ajax({
232        type: 'post',
233        dataType: 'html',
234        url: 'index.php?route=extension/module/oct_product_modules/modulePage',
235        data: 'module_id=' + module_id + '&page=' + page + '&oct_path=' + path,
236        cache: false,
237        beforeSend: function() {
238            // enable loader
239            masked('body', true);
240
241            document.querySelector('#' + button_id).classList.add('oct-animated');
242        },
243        complete: function() {
244            // check lozad
245            if (lozadEnable == 1) {
246                lozad('.oct-lazy').observe();
247            }
248
249            // remove loader
250            masked('body', false);
251
252            document.querySelector('#' + button_id).classList.remove('oct-animated');
253        },
254        success: function(octContent) {
255            // parce octProducts
256            let wrapper = document.createElement('div');
257            wrapper.innerHTML = octContent;
258
259            // find and write new products
260            let productsToFind = wrapper.querySelectorAll('.us-item');
261            const productsArray = Array.from(productsToFind);
262            let newProducts = document.querySelector("#" + html_module_id);
263            productsArray.forEach(element => newProducts.insertAdjacentElement('beforeend', element));
264
265            // check and write new button
266            let buttonToFind = wrapper.querySelectorAll("#" + button_id);
267            const buttonArray = Array.from(buttonToFind);
268
269            document.querySelector("#" + page_id).value = page;
270			// remove old button
271			let checkButton = wrapper.querySelector(".oct-load-more-button-wrapper");
272
273			if (checkButton === null) {
274				document.querySelector('#' + html_module_id).nextElementSibling.classList.add('d-none');
275			}
276        }
277    });
278}
279
280/*********** Mask function ***********/
281function usInputMask(selector, mask) {
282	$(selector).inputmask({'mask': mask});
283}
284
285$(document).ready(function() {
286	/*********** Desktop Dropdowns ***********/
287	$('body').on('click', '.us-dropdown-box', function() {
288		$(this).addClass('active');
289		$('#us_overlay').addClass('active');
290	});
291	/*********** End of Desktop Dropdowns ***********/
292	/*********** Header locations ***********/
293    $('body').on('click', '.us-header-location', function() {
294        $('.us-header-location').not(this).removeClass('active');
295        $(this).addClass('active');
296    });
297
298	$('body').on('click', '.us-plus', function(){
299        const oldVal = $(this).prev().val();
300        var newVal = (parseInt($(this).prev().val(),10) +1);
301		$(this).prev().val(newVal);
302    });
303
304	$('body').on('click', '.us-minus', function(){
305        const oldVal = $(this).next().val();
306        const minimum = $(this).parent().find('.min-qty').val();
307        if (oldVal > 1) {
308            var newVal = (parseInt($(this).next().val(),10) -1);
309        } else {
310	        newVal = 1;
311        }
312        if (newVal < minimum) {
313	        newVal = minimum;
314        }
315        $(this).next().val(newVal);
316    });
317
318    $('body').on('click', '.us-cat-button-cart', function(){
319        const productID = $(this).prev().find('input[name="product_id"]').val();
320        const quantity = $(this).prev().find('.form-control').val();
321        cart.add(productID, quantity);
322    });
323
324	function viewport() {
325		var e = window,
326			a = 'inner';
327		if (!('innerWidth' in window)) {
328			a = 'client';
329			e = document.documentElement || document.body;
330		}
331		return {
332			width: e[a + 'Width'],
333			height: e[a + 'Height']
334		};
335	}
336
337	/*********** To top button ***********/
338
339	$("#back-top").hide(),
340	$(function() {
341	    $(window).scroll(function() {
342	        $(this).scrollTop() > 450 ? $("#back-top").fadeIn() : $("#back-top").fadeOut()
343	    }),
344	    $("#back-top a").click(function() {
345	        return $("body,html").animate({
346	            scrollTop: 0
347	        }, 800),
348	        !1
349	    })
350	});
351
352	/*********** Fixed contacts ***********/
353
354	$('#us_fixed_contact_button').on('click', function () {
355		$(this).toggleClass('clicked');
356		$('.us-fixed-contact-dropdown').toggleClass('expanded');
357		$('.us-fixed-contact-icon .fa-comment-dots').toggleClass('d-none');
358		$('.us-fixed-contact-icon .fa-times').toggleClass('d-none');
359		$('#us_fixed_contact_substrate').toggleClass('active');
360	});
361
362	$('#us_fixed_contact_substrate').on('click', function () {
363		$(this).removeClass('active');
364		$('.us-fixed-contact-dropdown').removeClass('expanded');
365		$('.us-fixed-contact-icon .fa-comment-dots').removeClass('d-none');
366		$('.us-fixed-contact-icon .fa-times').toggleClass('d-none');
367		$('#us_fixed_contact_button').removeClass('clicked');
368	});
369
370	$('.shedule-dropdown-menu, .us-fixed-contact-dropdown').click(function(e){
371		e.stopPropagation();
372	});
373
374	$('#us_overlay').on('click', function() {
375		$(this).removeClass('active');
376		$('.ocf-offcanvas, .us-dropdown-box').removeClass('active');
377		$('body').removeClass('modal-open');
378		clearLiveSearch();
379	});
380
381	/*********** Category column module ***********/
382
383	$('.us-categories-toggle').on('click', function () {
384		if ($(this).hasClass('clicked') || $(this).parent().parent().hasClass('active')) {
385			$(this).parent().parent().removeClass('active');
386			$(this).parent().next().removeClass('expanded');
387			$(this).removeClass('clicked');
388		} else {
389			$(this).toggleClass('clicked');
390			$(this).parent().next().toggleClass('expanded');
391		}
392	});
393
394	$('.us-product-nav-item').on('click', function () {
395		$('.us-product-nav-item').removeClass('us-product-nav-item-active');
396		$(this).addClass('us-product-nav-item-active');
397	});
398
399	/*********** Mobile scprits ***********/
400
401	var screenWidth = viewport().width;
402
403	var resizeId;
404
405	function makeResize() {
406		// for ajax menu
407		//$('#us_menu_mobile_content').append($('#oct-menu-ul'));
408		$('#us_info_mobile .nav-dropdown-menu-content').prepend($('#currency'));
409		$('#us_info_mobile .nav-dropdown-menu-content').prepend($('#language'));
410	}
411
412	function unResize() {
413		// for ajax menu
414		//$('#oct-menu-dropdown-menu').append($('#oct-menu-ul'));
415		$('#top-links').prepend($('#currency'));
416		$('#top-links').prepend($('#language'));
417	}
418
419	window.addEventListener('resize', function() {
420	    clearTimeout(resizeId);
421	    resizeId = setTimeout(doneResizing, 500);
422	});
423
424	function doneResizing(){
425		var screenWidth = viewport().width;
426	    if (screenWidth > 767 && screenWidth < 1024) {
427			makeResize();
428		}
429		if (screenWidth > 1023) {
430			unResize();
431		}
432		if (screenWidth < 768) {
433			$('.us-footer-contact-box').append($('.us-footer-social'));
434		} else {
435			$('.us-footer-shedule-box').append($('.us-footer-social'));
436		}
437	}
438
439	function mobileMenu() {
440		var screenWidth = viewport().width;
441
442		if (screenWidth < 992) {
443
444			$('#us_menu_mobile_close').on('click', function () {
445				$('#us_menu_mobile_box').removeClass('expanded');
446				// $('body').removeClass('no-scroll');
447				setTimeout(() => {
448					$('.oct-menu-child-ul').removeClass('opened');
449				}, 600);
450			});
451
452			$('.oct-menu-toggle').on('click', function () {
453				$(this).parent().next().addClass('opened');
454			});
455
456			$('.oct-menu-back').on('click', function () {
457				$(this).parent().removeClass('opened');
458			});
459		} else {
460			$('.oct-menu-li').hover(function () {
461				$(this).children('.oct-menu-child-ul').addClass('oct-menu-child-ul-active');
462			});
463
464			$('.oct-menu-li').on('mouseleave', function () {
465				$(this).children('.oct-menu-child-ul').removeClass('oct-menu-child-ul-active');
466			});
467
468			$('.oct-mm-link').hover(function () {
469				$(this).children('.oct-mm-dropdown').addClass('oct-mm-dropdown-active');
470			});
471
472			$('.oct-mm-link').on('mouseleave', function () {
473				$(this).children('.oct-mm-dropdown').removeClass('oct-mm-dropdown-active');
474			});
475			unResize();
476		}
477	}
478
479	/*
480	for ajax menu
481	$('#us_menu_mobile_button').on('click', function () {
482		$('#us_menu_mobile_box').addClass('expanded');
483		$('body').addClass('no-scroll');
484	});
485	*/
486
487	$('#us_menu_mobile_button').on('click', function () {
488
489		const $menuId = $('#us_menu_mobile_content').html().length == 0;
490
491	    if (!$menuId) {
492
493        	$('#us_menu_mobile_box').addClass('expanded');
494			// $('body').addClass('no-scroll');
495
496	    } else {
497			masked('body', true);
498			$.ajax({
499		        type: 'post',
500		        dataType: 'html',
501		        url: 'index.php?route=octemplates/module/oct_megamenu',
502		        data: 'mobile=1',
503		        	cache: false,
504		        success: function(data) {
505			        $("#us_menu_mobile_content").html(data);
506			        $('#us_menu_mobile_box').addClass('expanded');
507					// $('body').addClass('no-scroll');
508
509					mobileMenu();
510					masked('body', false);
511		        }
512		    });
513		}
514	});
515
516	// Info mobile
517
518	$('body').on('click', '#dropdown_menu_info', function() {
519		$('#us_info_mobile').addClass('expanded');
520		// $('body').addClass('no-scroll');
521	});
522	$('body').on('click', '#us_info_mobile_close', function(e) {
523		$('#us_info_mobile').removeClass('expanded');
524		// $('body').removeClass('no-scroll');
525		e.stopPropagation();
526	});
527
528	if (screenWidth < 992) {
529		makeResize();
530
531		$('body').on('click', '.us-footer-title', function() {
532			$(this).next().slideToggle();
533			$(this).toggleClass('open');
534		});
535
536	} else {
537		unResize();
538	}
539
540	if (screenWidth < 768) {
541		$('.us-footer-contact-box').append($('.us-footer-social'));
542	} else {
543		$('.us-footer-shedule-box').append($('.us-footer-social'));
544	}
545
546});

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.