PageSourceSearch

https://www.aromaya.com.ua/catalog/view/javascript/common.js?ver=1.1.1

js aromaya.com.ua collected 2026-10-06 19:40:49 UTC 16,897 bytes, 641 lines download raw bytes

1function getURLVar(key) {
2	var value = [];
3
4	var query = document.location.search.split('?');
5
6	if (query[1]) {
7		var part = query[1].split('&');
8
9		for (i = 0; i < part.length; i++) {
10			var data = part[i].split('=');
11
12			if (data[0] && data[1]) {
13				value[data[0]] = data[1];
14			}
15		}
16
17		if (value[key]) {
18			return value[key];
19		} else {
20			return '';
21		}
22	}
23}
24
25$(document).ready(function() {
26
27	ocdw_in_stock_alert_action();
28
29	// Highlight any found errors
30	$('.text-danger').each(function() {
31		var element = $(this).parent().parent();
32
33		if (element.hasClass('form-group')) {
34			element.addClass('has-error');
35		}
36	});
37
38	// Currency
39	$('#form-currency .currency-select').on('click', function(e) {
40		e.preventDefault();
41
42		$('#form-currency input[name=\'code\']').val($(this).attr('name'));
43
44		$('#form-currency').submit();
45	});
46
47	// Language
48	$('.form-language .language-select').on('click', function(e) {
49		e.preventDefault();
50
51		$('.form-language input[name=\'code\']').val($(this).attr('name'));
52
53		$('.form-language').submit();
54	});
55
56	/* Search */
57	$('#search input[name=\'search\']').parent().find('button').on('click', function() {
58		var url = $('base').attr('href') + 'index.php?route=product/search';
59
60		var value = $('header #search input[name=\'search\']').val();
61
62		if (value) {
63			url += '&search=' + encodeURIComponent(value);
64		}
65
66		location = url;
67	});
68
69	$('#search input[name=\'search\']').on('keydown', function(e) {
70		if (e.keyCode == 13) {
71			$('header #search input[name=\'search\']').parent().find('button').trigger('click');
72		}
73	});
74
75	// Menu
76	$('#menu .dropdown-menu').each(function() {
77		var menu = $('#menu').offset();
78		var dropdown = $(this).parent().offset();
79
80		var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth());
81
82		if (i > 0) {
83			$(this).css('margin-left', '-' + (i + 10) + 'px');
84		}
85	});
86
87	// Product List
88	// $('#list-view').click(function() {
89	// 	$('#content .product-grid > .clearfix').remove();
90
91	// 	$('#content .row > .product-grid').attr('class', 'product-layout product-list col-xs-12');
92	// 	$('#grid-view').removeClass('active');
93	// 	$('#list-view').addClass('active');
94
95	// 	localStorage.setItem('display', 'list');
96	// });
97
98	// Product Grid
99	// $('#grid-view').click(function() {
100	// 	// What a shame bootstrap does not take into account dynamically loaded columns
101	// 	var cols = $('#column-right, #column-left').length;
102
103	// 	if (cols == 2) {
104	// 		$('#content .product-list').attr('class', 'product-layout product-grid col-lg-6 col-md-6 col-sm-12 col-xs-12');
105	// 	} else if (cols == 1) {
106	// 		$('#content .product-list').attr('class', 'product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-12');
107	// 	} else {
108	// 		$('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-3 col-sm-6 col-xs-12');
109	// 	}
110
111	// 	$('#list-view').removeClass('active');
112	// 	$('#grid-view').addClass('active');
113
114	// 	localStorage.setItem('display', 'grid');
115	// });
116
117	// if (localStorage.getItem('display') == 'list') {
118	// 	$('#list-view').trigger('click');
119	// 	$('#list-view').addClass('active');
120	// } else {
121	// 	$('#grid-view').trigger('click');
122	// 	$('#grid-view').addClass('active');
123	// }
124
125	// Checkout
126	$(document).on('keydown', '#collapse-checkout-option input[name=\'email\'], #collapse-checkout-option input[name=\'password\']', function(e) {
127		if (e.keyCode == 13) {
128			$('#collapse-checkout-option #button-login').trigger('click');
129		}
130	});
131
132	// tooltips on hover
133	$('[data-toggle=\'tooltip\']').tooltip({container: 'body',trigger: 'hover'});
134
135	// Makes tooltips work on ajax generated content
136	$(document).ajaxStop(function() {
137		$('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
138	});
139
140	//SCROLL_TO_TOP
141	$(window).scroll(function () {
142		if ($(this).scrollTop() > 300) {
143			$('#to-top').fadeIn();
144		} else {
145			$('#to-top').fadeOut();
146		}
147	});
148	$('#to-top').on('click', function () {
149		console.log('test');
150		$('body,html').animate({
151			scrollTop: 0
152		}, 750);
153		return false;
154	});
155//SCROLL_TO_TOP
156
157
158//MOBILE MENU
159$('#mobile-menu-button').on('click', function() {
160	if (!$(this).hasClass('is-active')) {
161		$(this).addClass('is-active');
162		$(this).parent().addClass('menu-active');
163		$('#menu').slideDown().addClass('opened');
164		$('#mobile-wrapper').fadeIn();
165	} else {
166		$(this).removeClass('is-active');
167		$(this).parent().removeClass('menu-active');
168
169		$('#cart').removeClass('open');
170		// $('#cart button').attr('aria-expanded', 'false');
171
172		$('#mobile-register').slideUp().removeClass('opened');
173		$('#account-button').removeClass('opened');
174
175		$('#menu').slideUp().removeClass('opened');
176		$('#mobile-wrapper').fadeOut();
177	}
178	
179	
180});
181$('#cart button').on('click', function() {
182	if (!$(this).parent().hasClass('open')) {
183		$(this).parent().addClass('open');
184		if ($('.mobile-menu-button-wrap').is(':visible')) {
185			$('#mobile-menu-button').addClass('is-active');
186			$('.mobile-menu-button-wrap').addClass('menu-active');
187
188			$('#mobile-wrapper').fadeIn();
189		}
190	} else {
191		$(this).parent().removeClass('open');
192		$('#mobile-wrapper').fadeOut();
193	}
194});
195
196$('#account-button').on('click', function() {
197	if (!$(this).hasClass('opened')) {
198		$('#mobile-register').slideDown().addClass('opened');
199		$(this).addClass('opened');
200
201		if ($('.mobile-menu-button-wrap').is(':visible')) {
202			$('#mobile-menu-button').addClass('is-active');
203			$('.mobile-menu-button-wrap').addClass('menu-active');			
204		}
205		$('#mobile-wrapper').fadeIn();
206	} else {
207		$('#mobile-register').slideUp().removeClass('opened');
208		$(this).removeClass('opened');
209		$('#mobile-wrapper').fadeOut();
210	}
211});
212
213$('#menu li a').on('click', function(e) {
214	if ($(this).next().length && $('.mobile-menu-button-wrap').is(':visible')) {
215		e.preventDefault();
216		$(this).toggleClass('opened').next().slideToggle().toggleClass('opened');
217	}
218});
219
220
221//MOBILE MENU
222
223$('body').on('click', '.checkbox', function(e) {
224	
225	e.preventDefault();
226	if ($(this).hasClass('disabled')) {
227		return false;
228	}
229	var target = $(this).find('label input[type="checkbox"]');
230	if (target.prop('checked')==true) {
231		$(this).removeClass('checked');
232		target.prop('checked', false);
233	} else {
234		$(this).addClass('checked');
235		target.prop('checked', true);
236	}
237});
238
239
240$('body').on('click', '.radio-box', function(e) {
241	
242	e.preventDefault();
243	var target = $(this).find('label input[type="radio"]');
244	if (target.prop('checked')!=true) {
245		$(this).addClass('checked');
246		target.prop('checked', true);
247		$(this).siblings('.radio-box').removeClass('checked');
248	} 
249});
250
251
252if ($(window).outerWidth() < 992) {
253	$('.product-thumb').on('click', 'a', function(e) {
254		if (!$(this).hasClass('hover')) {
255			e.preventDefault();
256		}
257		$('#content .product-thumb a').each(function(i, item) {			
258			$(item).removeClass('hover');
259		});
260		$(this).addClass('hover').closest('.product-layout').trigger('hover');
261	});
262}
263
264$('#filter-button').on('click', function() {
265	$(this).toggleClass('active').parent().toggleClass('active');
266});
267
268
269new WOW().init();
270
271});
272
273// Cart add remove functions
274var cart = {
275	'add': function(product_id, quantity) {
276		$.ajax({
277			url: 'index.php?route=checkout/cart/add',
278			type: 'post',
279			data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
280			dataType: 'json',
281			beforeSend: function() {
282				// $('#cart > button').button('loading');
283			},
284			complete: function() {
285				// $('#cart > button').button('reset');
286			},
287			success: function(json) {
288				$('.alert, .text-danger').remove();
289
290				if (json['redirect']) {
291					location = json['redirect'];
292				}
293
294				if (json['success']) {
295					$('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
296					setTimeout(function () {
297						$('.alert').fadeOut(500);
298					}, 4000);
299
300					// Need to set timeout otherwise it wont update the total
301					setTimeout(function () {
302						$('#cart #cart-total').html(json['total']);
303					}, 100);
304
305					// $('html, body').animate({ scrollTop: 0 }, 'slow');
306
307					$('#cart > ul').load('index.php?route=common/cart/info ul li');
308				}
309			},
310			error: function(xhr, ajaxOptions, thrownError) {
311				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
312			}
313		});
314	},
315	'update': function(key, quantity) {
316		$.ajax({
317			url: 'index.php?route=checkout/cart/edit',
318			type: 'post',
319			data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
320			dataType: 'json',
321			beforeSend: function() {
322				// $('#cart > button').button('loading');
323			},
324			complete: function() {
325				// $('#cart > button').button('reset');
326			},
327			success: function(json) {
328				// Need to set timeout otherwise it wont update the total
329				setTimeout(function () {
330					$('#cart #cart-total').html(json['total']);
331				}, 100);
332
333				if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
334					location = 'index.php?route=checkout/cart';
335				} else {
336					$('#cart > ul').load('index.php?route=common/cart/info ul li');
337				}
338			},
339			error: function(xhr, ajaxOptions, thrownError) {
340				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
341			}
342		});
343	},
344	'remove': function(key) {
345		$.ajax({
346			url: 'index.php?route=checkout/cart/remove',
347			type: 'post',
348			data: 'key=' + key,
349			dataType: 'json',
350			beforeSend: function() {
351				// $('#cart > button').button('loading');
352			},
353			complete: function() {
354				// $('#cart > button').button('reset');
355			},
356			success: function(json) {
357				// Need to set timeout otherwise it wont update the total
358				setTimeout(function () {
359					$('#cart #cart-total').html(json['total']);
360				}, 100);
361				
362				var now_location = String(document.location.pathname);
363
364				if ((now_location == '/cart/') || (now_location == '/checkout/') || (getURLVar('route') == 'checkout/cart') || (getURLVar('route') == 'checkout/checkout')) {
365					location = 'index.php?route=checkout/cart';
366				} else {
367					$('#cart > ul').load('index.php?route=common/cart/info ul li');
368				}
369			},
370			error: function(xhr, ajaxOptions, thrownError) {
371				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
372			}
373		});
374	}
375}
376
377var voucher = {
378	'add': function() {
379
380	},
381	'remove': function(key) {
382		$.ajax({
383			url: 'index.php?route=checkout/cart/remove',
384			type: 'post',
385			data: 'key=' + key,
386			dataType: 'json',
387			beforeSend: function() {
388				// $('#cart > button').button('loading');
389			},
390			complete: function() {
391				// $('#cart > button').button('reset');
392			},
393			success: function(json) {
394				// Need to set timeout otherwise it wont update the total
395				setTimeout(function () {
396					$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
397				}, 100);
398
399				if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
400					location = 'index.php?route=checkout/cart';
401				} else {
402					$('#cart > ul').load('index.php?route=common/cart/info ul li');
403				}
404			},
405			error: function(xhr, ajaxOptions, thrownError) {
406				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
407			}
408		});
409	}
410}
411
412var wishlist = {
413	'add': function(product_id) {
414		$.ajax({
415			url: 'index.php?route=account/wishlist/add',
416			type: 'post',
417			data: 'product_id=' + product_id,
418			dataType: 'json',
419			success: function(json) {
420				$('.alert').remove();
421
422				if (json['redirect']) {
423					location = json['redirect'];
424				}
425
426				if (json['success']) {
427					$('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
428					setTimeout(function () {
429						$('.alert').fadeOut(500);
430					}, 4000);
431				}
432
433				$('#wishlist-total span').html(json['total']);
434				$('#wishlist-total').attr('title', json['total']);
435
436				// $('html, body').animate({ scrollTop: 0 }, 'slow');
437			},
438			error: function(xhr, ajaxOptions, thrownError) {
439				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
440			}
441		});
442	},
443	'remove': function() {
444
445	}
446}
447
448var compare = {
449	'add': function(product_id) {
450		$.ajax({
451			url: 'index.php?route=product/compare/add',
452			type: 'post',
453			data: 'product_id=' + product_id,
454			dataType: 'json',
455			success: function(json) {
456				$('.alert').remove();
457
458				if (json['success']) {
459					$('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
460					setTimeout(function () {
461						$('.alert').fadeOut(500);
462					}, 4000);
463
464					$('#compare-total').html(json['total']);
465					$('.compare-count').html(json['count']);
466
467					// $('html, body').animate({ scrollTop: 0 }, 'slow');
468				}
469			},
470			error: function(xhr, ajaxOptions, thrownError) {
471				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
472			}
473		});
474	},
475	'remove': function() {
476
477	}
478}
479
480
481
482/* Agree to Terms */
483$(document).delegate('.agree', 'click', function(e) {
484	e.preventDefault();
485
486	$('#modal-agree').remove();
487
488	var element = this;
489
490	$.ajax({
491		url: $(element).attr('href'),
492		type: 'get',
493		dataType: 'html',
494		success: function(data) {
495			html  = '<div id="modal-agree" class="modal">';
496			html += '  <div class="modal-dialog">';
497			html += '    <div class="modal-content">';
498			html += '      <div class="modal-header">';
499			html += '        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>';
500			html += '        <h4 class="modal-title">' + $(element).text() + '</h4>';
501			html += '      </div>';
502			html += '      <div class="modal-body">' + data + '</div>';
503			html += '    </div';
504			html += '  </div>';
505			html += '</div>';
506
507			$('body').append(html);
508
509			$('#modal-agree').modal('show');
510		}
511	});
512});
513
514
515
516// Autocomplete */
517(function($) {
518	$.fn.autocomplete = function(option) {
519		return this.each(function() {
520			this.timer = null;
521			this.items = new Array();
522
523			$.extend(this, option);
524
525			$(this).attr('autocomplete', 'off');
526
527			// Focus
528			$(this).on('focus', function() {
529				this.request();
530			});
531
532			// Blur
533			$(this).on('blur', function() {
534				setTimeout(function(object) {
535					object.hide();
536				}, 200, this);
537			});
538
539			// Keydown
540			$(this).on('keydown', function(event) {
541				switch(event.keyCode) {
542					case 27: // escape
543					this.hide();
544					break;
545					default:
546					this.request();
547					break;
548				}
549			});
550
551			// Click
552			this.click = function(event) {
553				event.preventDefault();
554
555				value = $(event.target).parent().attr('data-value');
556
557				if (value && this.items[value]) {
558					this.select(this.items[value]);
559				}
560			}
561
562			// Show
563			this.show = function() {
564				var pos = $(this).position();
565
566				$(this).siblings('ul.dropdown-menu').css({
567					top: pos.top + $(this).outerHeight(),
568					left: pos.left
569				});
570
571				$(this).siblings('ul.dropdown-menu').show();
572			}
573
574			// Hide
575			this.hide = function() {
576				$(this).siblings('ul.dropdown-menu').hide();
577			}
578
579			// Request
580			this.request = function() {
581				clearTimeout(this.timer);
582
583				this.timer = setTimeout(function(object) {
584					object.source($(object).val(), $.proxy(object.response, object));
585				}, 200, this);
586			}
587
588			// Response
589			this.response = function(json) {
590				html = '';
591
592				if (json.length) {
593					for (i = 0; i < json.length; i++) {
594						this.items[json[i]['value']] = json[i];
595					}
596
597					for (i = 0; i < json.length; i++) {
598						if (!json[i]['category']) {
599							html += '<li data-value="' + json[i]['value'] + '"><a href="#">' + json[i]['label'] + '</a></li>';
600						}
601					}
602
603					// Get all the ones with a categories
604					var category = new Array();
605
606					for (i = 0; i < json.length; i++) {
607						if (json[i]['category']) {
608							if (!category[json[i]['category']]) {
609								category[json[i]['category']] = new Array();
610								category[json[i]['category']]['name'] = json[i]['category'];
611								category[json[i]['category']]['item'] = new Array();
612							}
613
614							category[json[i]['category']]['item'].push(json[i]);
615						}
616					}
617
618					for (i in category) {
619						html += '<li class="dropdown-header">' + category[i]['name'] + '</li>';
620
621						for (j = 0; j < category[i]['item'].length; j++) {
622							html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#">&nbsp;&nbsp;&nbsp;' + category[i]['item'][j]['label'] + '</a></li>';
623						}
624					}
625				}
626
627				if (html) {
628					this.show();
629				} else {
630					this.hide();
631				}
632
633				$(this).siblings('ul.dropdown-menu').html(html);
634			}
635
636			$(this).after('<ul class="dropdown-menu"></ul>');
637			$(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this));
638
639		});
640	}
641})(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.