PageSourceSearch

https://samura-online.ru/catalog/view/theme/shaver/js/common.js?ver=1791149045

js samura-online.ru collected 2026-10-04 21:25:10 UTC 21,218 bytes, 776 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
25function jivo_onLoadCallback(){
26	jivo_api.setUserToken(getCookie('_ga'));
27}
28
29function mobileToggleColumn(){
30
31//alert($(window).width());
32
33	if (!$('#column-right .megnorcategory').hasClass('catalog_menu')) {
34
35		$('#column-right .megnorcategory').addClass('catalog_menu');
36
37	}
38
39	if ($(window).width() < 980) {
40
41		$('#column-left, #column-right').appendTo('.home_row');
42
43		$('#column-left, #column-right').insertAfter('#content');
44
45		$("#column-left .box-heading .mobile_togglemenu, #column-right .box-heading .mobile_togglemenu").remove();
46
47		$("#column-left .box-heading ,#column-right .box-heading").append( "<a class='mobile_togglemenu'>&nbsp;</a>" );
48
49		$("#column-left .box-heading, #column-right .box-heading").addClass('toggle');
50
51		$("#column-right .box-heading .mobile_togglemenu").click(function(){
52
53			$(this).parent().toggleClass('active').parent().find('.box-content,.filterbox,.list-group').slideToggle('slow');
54
55		})
56
57
58
59		$('.catalog_menu').appendTo('.res-menu-main-wrapper');
60
61		// $('.category-left-box').appendTo('.res-menu-main-wrapper');
62
63		$('.category-left-box').addClass('mobile-menu-item catalog active');
64
65        $('#megamenu-item').addClass('mobile-menu-item menu');
66
67        $('#megamenu-item').appendTo('.res-menu-main-wrapper');
68		if ($('#column-right .category-left-box .box-content').length) {
69	$( "#column-right .category-left-box .box-content" ).clone().appendTo( ".catalog_menu.mobile-menu-item" ); // вставляем клонированный элемент
70	}
71	if ($('#column-left .category-left-box .box-content').length) {
72	$( "#column-left .category-left-box .box-content" ).clone().appendTo( ".catalog_menu.mobile-menu-item" ); // вставляем клонированный элемент
73	}
74		$('.mobile-menu-item')
75
76    }else{
77
78		 
79
80	}
81
82}
83
84//$(document).ready(function(){mobileToggleColumn();});
85
86//$(window).resize(function(){mobileToggleColumn();});
87
88$(document).ready(function() {
89	
90	$('.expandable, .res-menu-main-toggle').click(function () {
91
92        $('body').toggleClass('menu-opened');
93
94    });
95	
96	$('.res-menu-main-header-link').click(function () {
97
98		$('.res-menu-main-header-link').removeClass('active');
99
100		$(this).addClass('active');
101
102		var target = $(this).data('target');
103
104		$('.mobile-menu-item').removeClass('active');
105
106		$('.mobile-menu-item.'+target).addClass('active');
107
108    });
109	// Highlight any found errors
110	$('.lazyYT').lazyYT('AIzaSyCawA87g_pgTbSNPhiWAemy-mFKszJGl4M');
111
112	if ($('.category-tags a').length > 12){
113		$('.category-tags').after('<div class="category-tags-buttons"><a class="show-more-tags">Показать все</a></div>');
114	}
115	
116	
117	
118	$('.catalog-header-wrapper .catalog_menu .box-heading').click(function(event) {
119
120		$('.catalog-header-wrapper .catalog_menu .box-content').slideToggle(400);
121
122		$(this).toggleClass('active');
123
124	});
125
126	$(document).on('click', '.show-more-tags', function(event) {
127		event.preventDefault();
128		
129		$('.category-tags').addClass('show-tags');
130		$(this).remove();
131	});
132
133	// $('input[type="tel"]').mask('+7 (999) 999-99-99');
134	// $('input[type="tel"]').keydown(function(event) {
135	// 	if ($(this).val() == '+7 (8__) ___-__-__') {
136	// 		$(this).unmask();
137	// 		$(this).focus();
138	// 		$(this).mask('+7 (999) 999-99-99');
139	// 	}
140	// });
141	//
142	// $('.trigger-popup-toggle').magnificPopup({
143	// 	type: 'inline',
144	// 	preloader: false,
145	// 	callbacks: {
146	// 		beforeOpen: function() {
147	// 			
148	// 		}
149	// 	}
150	// });
151
152	$('.text-danger').each(function() {
153		var element = $(this).parent().parent();
154
155		if (element.hasClass('form-group')) {
156			element.addClass('has-error');
157		}
158	});
159
160	// To open mobile cart in modal window .mobile-header-cart
161
162	// $('.header-cart').click(function(event) {
163	// 	$(this).toggleClass('active');
164	// });
165
166	// Currency
167	$('#form-currency .currency-select').on('click', function(e) {
168		e.preventDefault();
169
170		$('#form-currency input[name=\'code\']').val($(this).attr('name'));
171
172		$('#form-currency').submit();
173	});
174
175	// Language
176	$('#form-language .language-select').on('click', function(e) {
177		e.preventDefault();
178
179		$('#form-language input[name=\'code\']').val($(this).attr('name'));
180
181		$('#form-language').submit();
182	});
183
184	/* Search */
185	$('#search input[name=\'search\']').parent().find('button').on('click', function() {
186		var url = $('base').attr('href') + 'index.php?route=product/isearch';
187
188		var value = $(this).parent().parent().parent().find('input[name=\'search\']').val();
189
190		if (value) {
191			url += '&search=' + encodeURIComponent(value);
192		}
193
194		location = url;
195	});
196
197	$('#search input[name=\'search\']').on('keydown', function(e) {
198		if (e.keyCode == 13) {
199			$('header #search input[name=\'search\']').parent().find('button').trigger('click');
200		}
201	});
202
203	// Menu
204	$('#menu .dropdown-menu').each(function() {
205		var menu = $('#menu').offset();
206		var dropdown = $(this).parent().offset();
207
208		var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth());
209
210		if (i > 0) {
211			$(this).css('margin-left', '-' + (i + 10) + 'px');
212		}
213	});
214
215	// Product List
216	$('.product-view-mode li a').click(function(event) {
217		var href = $(this).attr('href');
218	});
219
220	$('#list-view').click(function() {
221		$('#grid').removeClass('show active');
222		$('#list').addClass('show active');
223		localStorage.setItem('display', 'list');
224	});
225
226	// Product Grid
227	$('#grid-view').click(function() {
228		$('#list').removeClass('show active');
229		$('#grid').addClass('show active');
230		localStorage.setItem('display', 'grid');
231	});
232
233	if (localStorage.getItem('display') == 'list') {
234		$('#list-view').trigger('click');
235	} else {
236		$('#grid-view').trigger('click');
237	}
238
239	// Checkout
240	$(document).on('keydown', '#collapse-checkout-option input[name=\'email\'], #collapse-checkout-option input[name=\'password\']', function(e) {
241		if (e.keyCode == 13) {
242			$('#collapse-checkout-option #button-login').trigger('click');
243		}
244	});
245
246	// tooltips on hover
247	$('[data-toggle=\'tooltip\']').tooltip({container: 'body',trigger: 'hover'});
248
249	// Makes tooltips work on ajax generated content
250	$(document).ajaxStop(function() {
251		$('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
252	});
253
254	$(document).on('click', '.close-alert', function(event) {
255		$(this).closest('.alert-card-wrapper').remove();
256	});
257});
258
259// Cart add remove functions
260var cart = {
261	'add': function(product_id, quantity) {
262		$.ajax({
263			url: 'index.php?route=checkout/cart/add',
264			type: 'post',
265			data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
266			dataType: 'json',
267			beforeSend: function() {
268				// $('#cart > button').button('loading');
269			},
270			complete: function() {
271				// $('#cart > button').button('reset');
272			},
273			success: function(json) {
274				$('.alert, .text-danger').remove();
275
276				if (json['redirect']) {
277					location = json['redirect'];
278				}
279
280				if (json['success']) {
281					// $('#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>');
282
283					// Need to set timeout otherwise it wont update the total
284					// edits odenzzz
285					// setTimeout(function () {
286					// 	$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
287					// }, 100);
288
289					// $('html, body').animate({ scrollTop: 0 }, 'slow');
290					$('.alert-wrapper').append(json['success']);
291					var target = $('.alert-wrapper .alert-card-wrapper').last();
292					target.animate({opacity: 1}, 500);
293					setTimeout(function() {
294						target.animate({
295							opacity: 0
296						},500, function() {
297							target.remove();
298						});
299					}, 10000);
300					// /edits odenzzz
301
302					$('#cart > ul').load('index.php?route=common/cart/info ul li');
303					// edits odenzzz
304					$('.menu-target').load('index.php?route=common/cart/info');
305					// /edits odenzzz
306				}
307			},
308			error: function(xhr, ajaxOptions, thrownError) {
309				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
310			}
311		});
312	},
313	'update': function(key, quantity) {
314		$.ajax({
315			url: 'index.php?route=checkout/cart/edit',
316			type: 'post',
317			data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
318			dataType: 'json',
319			beforeSend: function() {
320				// $('#cart > button').button('loading');
321			},
322			complete: function() {
323				// $('#cart > button').button('reset');
324			},
325			success: function(json) {
326				// Need to set timeout otherwise it wont update the total
327				setTimeout(function () {
328					$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
329				}, 100);
330
331				if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
332					location = 'index.php?route=checkout/cart';
333				} else {
334					$('#cart > ul').load('index.php?route=common/cart/info ul li');
335				}
336			},
337			error: function(xhr, ajaxOptions, thrownError) {
338				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
339			}
340		});
341	},
342	'remove': function(key) {
343		$.ajax({
344			url: 'index.php?route=checkout/cart/remove',
345			type: 'post',
346			data: 'key=' + key,
347			dataType: 'json',
348			beforeSend: function() {
349				// $('#cart > button').button('loading');
350			},
351			complete: function() {
352				// $('#cart > button').button('reset');
353			},
354			success: function(json) {
355				// Need to set timeout otherwise it wont update the total
356				setTimeout(function () {
357					$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
358				}, 100);
359				
360				var now_location = String(document.location.pathname);
361
362				if ((now_location == '/cart/') || (now_location == '/checkout/') || (getURLVar('route') == 'checkout/cart') || (getURLVar('route') == 'checkout/checkout')) {
363					location = 'index.php?route=checkout/cart';
364				} else {
365					$('#cart > ul').load('index.php?route=common/cart/info ul li');
366				}
367			},
368			error: function(xhr, ajaxOptions, thrownError) {
369				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
370			}
371		});
372	}
373}
374
375var voucher = {
376	'add': function() {
377
378	},
379	'remove': function(key) {
380		$.ajax({
381			url: 'index.php?route=checkout/cart/remove',
382			type: 'post',
383			data: 'key=' + key,
384			dataType: 'json',
385			beforeSend: function() {
386				// $('#cart > button').button('loading');
387			},
388			complete: function() {
389				// $('#cart > button').button('reset');
390			},
391			success: function(json) {
392				// Need to set timeout otherwise it wont update the total
393				setTimeout(function () {
394					$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
395				}, 100);
396
397				if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
398					location = 'index.php?route=checkout/cart';
399				} else {
400					$('#cart > ul').load('index.php?route=common/cart/info ul li');
401				}
402			},
403			error: function(xhr, ajaxOptions, thrownError) {
404				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
405			}
406		});
407	}
408}
409
410var wishlist = {
411	'add': function(product_id) {
412		$.ajax({
413			url: 'index.php?route=account/wishlist/add',
414			type: 'post',
415			data: 'product_id=' + product_id,
416			dataType: 'json',
417			success: function(json) {
418				$('.alert').remove();
419
420				if (json['redirect']) {
421					location = json['redirect'];
422				}
423				// edits odenzzz
424				// if (json['success']) {
425				// 	$('#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>');
426				// }
427				if (json['success']) {
428					$('.alert-wrapper').append(json['success']);
429					var target = $('.alert-wrapper .alert-card-wrapper').last();
430					target.animate({opacity: 1}, 500);
431					setTimeout(function() {
432						target.animate({
433							opacity: 0
434						},500, function() {
435							target.remove();
436						});
437					}, 10000)
438				}
439				$('.wishlist-counter').html(json['total']);
440
441				// $('#wishlist-total span').html(json['total']);
442				// $('#wishlist-total').attr('title', json['total']);
443
444				// $('html, body').animate({ scrollTop: 0 }, 'slow');
445				// edits odenzzz
446			},
447			error: function(xhr, ajaxOptions, thrownError) {
448				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
449			}
450		});
451	},
452	'remove': function() {
453
454	}
455}
456
457var compare = {
458	'add': function(product_id) {
459		$.ajax({
460			url: 'index.php?route=product/compare/add',
461			type: 'post',
462			data: 'product_id=' + product_id,
463			dataType: 'json',
464			success: function(json) {
465				$('.alert').remove();
466				// edits odenzzz
467				// if (json['success']) {
468				// 	$('#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>');
469
470				// 	$('#compare-total').html(json['total']);
471
472				// 	$('html, body').animate({ scrollTop: 0 }, 'slow');
473				// }
474				if (json['success']) {
475					if (json['success']) {
476						$('.alert-wrapper').append(json['success']);
477						var target = $('.alert-wrapper .alert-card-wrapper').last();
478						target.animate({opacity: 1}, 500);
479						setTimeout(function() {
480							target.animate({
481								opacity: 0
482							},500, function() {
483								target.remove();
484							});
485						}, 10000)
486					}
487					$('.compare-counter').html(json['total']);
488				}
489				// /edits odenzzz
490			},
491			error: function(xhr, ajaxOptions, thrownError) {
492				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
493			}
494		});
495	},
496	'remove': function() {
497
498	}
499}
500
501/* Agree to Terms */
502$(document).delegate('.agree', 'click', function(e) {
503	e.preventDefault();
504
505	$('#modal-agree').remove();
506
507	var element = this;
508
509	$.ajax({
510		url: $(element).attr('href'),
511		type: 'get',
512		dataType: 'html',
513		success: function(data) {
514			html  = '<div id="modal-agree" class="modal">';
515			html += '  <div class="modal-dialog">';
516			html += '    <div class="modal-content">';
517			html += '      <div class="modal-header">';
518			html += '        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>';
519			html += '        <h4 class="modal-title">' + $(element).text() + '</h4>';
520			html += '      </div>';
521			html += '      <div class="modal-body">' + data + '</div>';
522			html += '    </div';
523			html += '  </div>';
524			html += '</div>';
525
526			$('body').append(html);
527
528			$('#modal-agree').modal('show');
529		}
530	});
531});
532
533// Autocomplete */
534(function($) {
535	$.fn.autocomplete = function(option) {
536		return this.each(function() {
537			this.timer = null;
538			this.items = new Array();
539
540			$.extend(this, option);
541
542			$(this).attr('autocomplete', 'off');
543
544			// Focus
545			$(this).on('focus', function() {
546				this.request();
547			});
548
549			// Blur
550			$(this).on('blur', function() {
551				setTimeout(function(object) {
552					object.hide();
553				}, 200, this);
554			});
555
556			// Keydown
557			$(this).on('keydown', function(event) {
558				switch(event.keyCode) {
559					case 27: // escape
560						this.hide();
561						break;
562					default:
563						this.request();
564						break;
565				}
566			});
567
568			// Click
569			this.click = function(event) {
570				event.preventDefault();
571
572				value = $(event.target).parent().attr('data-value');
573
574				if (value && this.items[value]) {
575					this.select(this.items[value]);
576				}
577			}
578
579			// Show
580			this.show = function() {
581				var pos = $(this).position();
582
583				$(this).siblings('ul.dropdown-menu').css({
584					top: pos.top + $(this).outerHeight(),
585					left: pos.left
586				});
587
588				$(this).siblings('ul.dropdown-menu').show();
589			}
590
591			// Hide
592			this.hide = function() {
593				$(this).siblings('ul.dropdown-menu').hide();
594			}
595
596			// Request
597			this.request = function() {
598				clearTimeout(this.timer);
599
600				this.timer = setTimeout(function(object) {
601					object.source($(object).val(), $.proxy(object.response, object));
602				}, 200, this);
603			}
604
605			// Response
606			this.response = function(json) {
607				html = '';
608
609				if (json.length) {
610					for (i = 0; i < json.length; i++) {
611						this.items[json[i]['value']] = json[i];
612					}
613
614					for (i = 0; i < json.length; i++) {
615						if (!json[i]['category']) {
616							html += '<li data-value="' + json[i]['value'] + '"><a href="#">' + json[i]['label'] + '</a></li>';
617						}
618					}
619
620					// Get all the ones with a categories
621					var category = new Array();
622
623					for (i = 0; i < json.length; i++) {
624						if (json[i]['category']) {
625							if (!category[json[i]['category']]) {
626								category[json[i]['category']] = new Array();
627								category[json[i]['category']]['name'] = json[i]['category'];
628								category[json[i]['category']]['item'] = new Array();
629							}
630
631							category[json[i]['category']]['item'].push(json[i]);
632						}
633					}
634
635					for (i in category) {
636						html += '<li class="dropdown-header">' + category[i]['name'] + '</li>';
637
638						for (j = 0; j < category[i]['item'].length; j++) {
639							html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#">&nbsp;&nbsp;&nbsp;' + category[i]['item'][j]['label'] + '</a></li>';
640						}
641					}
642				}
643
644				if (html) {
645					this.show();
646				} else {
647					this.hide();
648				}
649
650				$(this).siblings('ul.dropdown-menu').html(html);
651			}
652
653			$(this).after('<ul class="dropdown-menu"></ul>');
654			$(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this));
655
656		});
657	}
658})(window.jQuery);
659
660//itser
661// Image Manager
662$(document).on('click', 'a[data-toggle=\'image\']', function(e) {
663	var $element = $(this);
664	var $popover = $element.data('bs.popover'); // element has bs popover?
665
666	e.preventDefault();
667
668	// destroy all image popovers
669	$('a[data-toggle="image"]').popover('destroy');
670
671	// remove flickering (do not re-add popover when clicking for removal)
672	if ($popover) {
673		return;
674	}
675
676	$element.popover({
677		html: true,
678		placement: 'right',
679		trigger: 'manual',
680		content: function() {
681			return '<button type="button" id="button-image" class="btn btn-primary"><i class="fa fa-pencil"></i></button> <button type="button" id="button-clear" class="btn btn-danger">
681<i class="fa fa-trash-o"></i></button>';
682		}
683	});
684
685	$element.popover('show');
686
687	$('#button-image').on('click', function() {
688		var $button = $(this);
689		var $icon   = $button.find('> i');
690
691		$('#modal-image').remove();
692
693		$.ajax({
694			url: 'index.php?route=common/filemanager&target=' + $element.parent().find('input').attr('id') + '&thumb=' + $element.attr('id'),
695			dataType: 'html',
696			beforeSend: function() {
697				$button.prop('disabled', true);
698				if ($icon.length) {
699					$icon.attr('class', 'fa fa-circle-o-notch fa-spin');
700				}
701			},
702			complete: function() {
703				$button.prop('disabled', false);
704				if ($icon.length) {
705					$icon.attr('class', 'fa fa-pencil');
706				}
707			},
708			success: function(html) {
709				$('body').append('<div id="modal-image" class="modal">' + html + '</div>');
710
711				$('#modal-image').modal('show');
712			}
713		});
714
715		$element.popover('destroy');
716	});
717
718	$('#button-clear').on('click', function() {
719		$element.find('img').attr('src', $element.find('img').attr('data-placeholder'));
720
721		$element.parent().find('input').val('');
722
723		$element.popover('destroy');
724	});
725});
726
727$(document).ready(function() {
728	$('.options-category input').click(function(){
729		//если есть скрытый элемент с данными
730
731		var option_data_element = ".product_option_value_info" + $(this).val();
732		if($("input").is(option_data_element)){
733			var option_image = $(option_data_element).data('option_image');
734			var product_image = $(option_data_element).data('product_image');
735
736			if (option_image){
737				$(this).closest('.product-thumb').find('.image img').attr('src',option_image);
738			}else{
739				$(this).closest('.product-thumb').find('.image img').attr('src',product_image);
740			}
741		}
742	})
743});
744$(document).ready(function() {
745	$('#button-cart,.add-to-cart').on('click', function() {
746		gtag('event','TO_CART');
747	});
748	$(window).resize(function() {
749		if ( $('body').width() < 767 ) {
750			$('#cart-checkout').insertAfter('#bonus');
751		} 
752	})
753	$(window).trigger('resize');
754	$('.productpage .product-right .list-group-item').tooltip('disable');
755
756	$('.productpage .product-right .list-group-item').on('click', function() {
757
758		var trigger_desc = '<div class="trigger-desc">' + $(this).data('title') + '</div>';
759		trigger_desc+= $('.trigger-content').html();
760
761		$('.trigger-content').html(trigger_desc);
762
763		$('.trigger-wrapper').toggleClass('active');
764		$('body').css('position', 'relative');
765		$('html').css('overflow', 'hidden');
766	});
767
768	$('body').on('click', '.trigger-wrapper .trigger-content .close_btn',  function() {
769		$('.trigger-content').find('.trigger-desc').remove();
770		$('.trigger-wrapper').removeClass('active');
771		$('body').css('position', 'static');
772		$('html').css('overflow', 'auto');
773	});
774
775});
776

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.