PageSourceSearch

https://slady.ru/t/v4561/images/js/main.js

js slady.ru collected 2026-10-09 01:06:16 UTC 48,452 bytes, 2,012 lines download raw bytes

1var menuMethods = {
2	init : function(options) {
3		var settings = $.extend( {
4			'direction'	: 'down', //down, left, right, down-center
5			'more'	 	: true,
6			'more_class': 'more',
7			'more_width': 36,
8			'more_text'	: '...'
9		}, options);
10
11		return this.each(function() {
12			var $this 			= $(this),
13				$li 			= $this.children().toArray(),
14				$li_total_width = 0,
15				$li_width 		= $li.map(function(el) {
16					$li_total_width += el.offsetWidth;
17					return el.getBoundingClientRect().width;
18				}),
19
20				$more = $('<li data-more><a>' + settings.more_text + '</a><ul /></li>')
21					.addClass(settings.more_class)
22					.css({'width': settings.more_width});
23
24			if (settings.more) {
25				$(window)
26					.on('resize.menu', menuMethods.build.call($this, $more, $li_width, $li_total_width, settings, $li))
27					.trigger('resize');
28			}
29
30			menuMethods.popup.call($this);
31		});
32	},
33
34	build: function(button, width_arr, all_li_width, sett, li) {
35
36		var menu = this;
37
38		return function() {
39			var $ul_width 	= menu.get(0).offsetWidth,
40				acc 		= 0;
41
42			if ( $ul_width > all_li_width ) {
43				width_arr.forEach(function(item, i, arr) {
44					$(li[i]).appendTo(menu);
45				});
46
47				button.remove();
48				
49			} else {
50				button.appendTo(menu);
51				
52				width_arr.forEach(function(item, i, arr) {
53					acc += item;
54
55					if ( acc > $ul_width - sett.more_width ) {
56						$(li[i]).appendTo(button.children('ul'));
57					} else {
58						if ( $(li[i]).closest(button).length ) {
59							$(li[i]).insertBefore(button);
60						}
61					}
62				});
63			};
64		}
65	},
66
67	dismantle: function(menu, li, button) {
68		li.forEach(function(item, i, arr) {
69			$(item).appendTo(menu);
70		});
71		button.remove();
72	},
73
74	popup: function() {
75		var $menu = this,
76			$li = $menu.find('li'),
77			timer;
78
79		$menu.on('mouseenter', 'li', function() {
80			var $this 		= $(this),
81				$sub 		= $this.children('ul'),
82				subWidth 	= 0,
83				position 	= {};
84
85			clearTimeout(timer);
86
87			$this
88				.addClass('hover')
89				.siblings('li')
90				.removeClass('hover');
91
92			if ( !$sub.length ) return;
93
94			subWidth = $sub.outerWidth();
95
96			if ( !$this.parentsUntil($this).filter('li').length ) {
97
98				position.top 	= $this.outerHeight();
99				position.left 	= 0;
100
101				if ( Math.ceil($this.offset().left) + subWidth > $(window).width() ) {
102					position.left = $this.outerWidth() - subWidth;
103				}
104
105			} else {
106
107				position.top 	= 0;
108				position.left 	= $this.outerWidth();
109
110				if ( Math.ceil($this.offset().left) + $this.outerWidth() + subWidth > $(window).width() ) {
111					position.left = 0 - subWidth;
112				}
113			}
114
115			$sub.css({'top': position.top, 'left': position.left});
116		});
117
118		$menu.on('mouseleave', 'li', function() {
119			var $this = $(this);
120
121			timer = setTimeout(function() {
122				$this.removeClass("hover");
123			}, 500);
124		});
125	},
126
127	destroy : function( ) {
128		return this.each(function() {
129			var $this 	= $(this),
130				$more 	= $this.find('[data-more]'),
131				$li 	= $more.children('ul').children().toArray();
132
133			$(window).off('resize.menu');
134			
135			menuMethods.dismantle($this, $li, $more);
136		});
137	}
138};
139
140$.fn.responsiveMenu = function( method ) {	
141	if ( menuMethods[method] ) {
142		return menuMethods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
143	} else if ( typeof method === 'object' || ! method ) {
144		return menuMethods.init.apply( this, arguments );
145	} else {
146		$.error( 'Метод с именем ' +  method + ' не существует для jQuery.responsiveMenu' );
147	}
148};
149
150$.fn.bindImageLoad = function (callback) {
151	function isImageLoaded(img) {
152		if (!img.complete) {
153			return false;
154		}
155		if (typeof img.naturalWidth !== "undefined" && img.naturalWidth === 0) {
156			return false;
157		}
158		return true;
159	}
160
161	return this.each(function () {
162		var ele = $(this);
163		if (ele.is("img") && $.isFunction(callback)) {
164			ele.one("load", callback);
165			if (isImageLoaded(this)) {
166				ele.trigger("load");
167			}
168		}
169	});
170};
171
172$.fn.mgStyler = function() {
173	return this.each(function() {
174		var $this 			= $(this),
175			isChecked		= $this.is(':checked'),
176			isDisabled 		= $this.is(':disabled'),
177			isRadio			= $this.is(':radio'),
178			jqLabel			= $this.parent('label')
179			radioClass		= "mg-styler-label--radio",
180			checkboxClass	= "mg-styler-label--checkbox",
181			labelClass		= isRadio ? radioClass : checkboxClass;
182			
183		if (jqLabel.length) {
184
185			jqLabel.addClass(labelClass);
186
187		} else {
188
189			jqLabel = $this
190						.wrap('<label></label>')
191						.parent('label')
192						.addClass(labelClass);
193		}
194		
195		jqLabel.toggleClass('disabled', isDisabled);
196		
197		jqLabel
198			.on('click.mgStyler', function(e){
199				toggle($(this));
200				e.preventDefault();
201				setTimeout(function() {
202					$('[data-styler] select').not('[multiple]').trigger('refresh');
203				});
204			});
205
206		if (isChecked) {
207			jqLabel.addClass('checked');
208		}
209
210		function toggle(jqInput) {
211			if ( jqInput.find('input').is(':radio') ) {
212
213				var radioGroup = jqInput.find('input').attr('name');
214				$('input[name="' + radioGroup + '"]').closest('.' + radioClass).removeClass('checked');
215				
216				jqInput.addClass('checked').find('input[type=radio]').prop('checked', true);
217			} else {
218
219				jqInput.toggleClass('checked').find('input[type=checkbox]').prop('checked', !jqInput.find('input[type=checkbox]').prop('checked'));
220
221			}
222		}
223	});
224};
225
226if(shop2.my.gr_amount_init){
227
228function amountInit() {
229	$('.shop2-product-form, .shop2-product-form-view, .shop2-cart-item-product').each(function() {
230		var $this       = $(this);
231		var $amountWrap = $this.find('.shop2-product-amount');
232		var $input      = $amountWrap.find('input[type="text"]');
233		var $buttons    = $amountWrap.find('button');
234		var $minus      = $amountWrap.find('button.amount-minus');
235		var $plus       = $amountWrap.find('button.amount-plus');
236		var min 		= $amountWrap.find('input').data('min');
237		var inputVal    = +$input.val();
238		
239
240		if (inputVal<=min) {
241			$minus.attr('disabled', 'disabled');
242		}
243		
244		$buttons.on('click', function(){
245			var parent = $(this).parent();
246			var input  = parent.find('input');
247
248			setTimeout(function(){
249				var inputVal = +input.val();
250				
251				if (inputVal<=min) {
252					$minus.attr('disabled', 'disabled');
253				} else {
254					$minus.removeAttr('disabled');
255				}
256			}, 100);
257		});
258		
259		$input.on('change', function(e) {
260        	var curVal = +$(this).val();
261        	
262        	if (curVal < min) {
263        		$(this).val(min);
264        	} else if (curVal == min) {
265        		$minus.attr('disabled', 'disabled');
266        	} else if (curVal > min) {
267        		$minus.removeAttr('disabled');
268        	}
269        });
270	});
271};
272
273}
274
275shop2.queue.product = function() {
276	shop2.product._reload = function(node) {
277		var $node = $(node);
278		var kinds = shop2.product.getNodeData(node, 'kinds', true);
279		var paramName = shop2.product.getNodeData(node, 'name');
280		var paramValue = shop2.product.getNodeData(node, 'value');
281		var $form = $node.closest('form');
282		var form = $form.get(0);
283		var meta;
284		var kind_id;
285		var product_id;
286		var keys = {};
287
288		if (kinds && $.type(paramName) !== 'undefined' && $.type(paramValue) !== 'undefined' && form) {
289
290			meta = $form.find('input[name=meta]').val();
291
292			product_id = $form.find('input[name=product_id]').val();
293
294			$form.find('[name=submit]').prop('disabled', true);
295
296			$form.find('select.shop2-cf>option, li.shop2-cf, li.shop2-color-ext-selected, ul.shop2-color-ext-list>li').each(function() {
297				var name = $(this).data('name');
298				if (name) {
299					keys[name] = true;
300				}
301			});
302
303			kind_id = shop2.product.findKindId(product_id, kinds, paramName, paramValue, meta, keys);
304
305			if (shop2.mode == 'product') {
306
307				if (shop2.uri) {
308					document.location = shop2.uri + '/product/' + kind_id;
309				} else {
310					document.location = document.location.href.replace(/\/product\/.+/, '/product/' + kind_id);
311				}
312
313			} else {
314
315				shop2.product.getProductListItem(product_id, kind_id, function(d, status) {
316					var cont, newCont, body;
317					if (status === 'success') {
318
319						cont = $node.closest('.shop2-product-item');
320						cont.hide();
321
322						body = $.trim(d.data.body);
323						newCont = $(body).insertBefore(cont);
324
325						cont.remove();
326						
327						$('[data-styler] select', newCont).styler();
328						window.shop2_gr.methods.productView($('.view .active-view').data('value'), newCont);
329
330						shop2.queue.heights();
331					}
332
333				});
334
335			}
336		}
337
338	};
339	
340	var reload = shop2.product._reload;
341	
342	shop2.product._reload = function(node) {
343	    var args = Array.prototype.slice.call(arguments, 0);
344	    var popoverDiv = $(node).closest('.popup-product-wrap');
345	    
346	    if (popoverDiv.length) {
347	        reloadProduct(node);
348	    } else {
349	        reload.apply(this, args);
350	    }
351	}
352
353	$.on('select.shop2-cf', {
354		change: function() {
355			shop2.product._reload(this);
356		}
357	});
358
359	$.on('li.shop2-cf:not(.active-color, .active-texture)', {
360		click: function() {
361			shop2.product._reload(this);
362		}
363	});
364};
365
366function reloadProduct(node) {
367    var $node = $(node),
368        kinds = shop2.product.getNodeData(node, 'kinds', true),
369        paramName = shop2.product.getNodeData(node, 'name'),
370        paramValue = shop2.product.getNodeData(node, 'value'),
371        $form = $node.closest('form'),
372        form = $form.get(0),
373        meta, kind_id, product_id;
374        
375    var $wr = $('.popup-product-wrap');
376
377    if (kinds && $.type(paramName) !== 'undefined' && $.type(paramValue) !== 'undefined' && form) {
378
379        if (form.elements.meta) {
380            meta = $.parseJSON(form.elements.meta.value);
381        }
382
383        product_id = form.elements.product_id.value;
384
385        $form.find('[name=submit]').prop('disabled', true);
386
387        kind_id = shop2.product.findKindId(product_id, kinds, paramName, paramValue, meta);
388
389        if (kind_id === 0) return false;
390
391        var url = window.location.protocol + "//" + window.location.host + shop2.uri + "/product/" + kind_id;
392        
393		$.ajax({
394			url: url,
395			data: {"fast_view": 1},
396			success: function(data, stutus) {
397				var $response = $(data);
398				
399				$wr.empty().append($response).attr('data-id',kind_id);
400				
401				setTimeout(function() {
402					$('[data-product-images]', $response).addClass('owl-carousel').owlCarousel({
403						items: 1,
404						margin: 0,
405						nav: true,
406						loop: true,
407						dots: true
408					});
409					
410					$('select:not([multiple])', $response).styler();
411				}, 300);
412			}
413		});
414    }
415}
416
417shop2.queue.colorSelect = function() {
418
419	var select = $('<div id="shop2-color-ext-select"><ins></ins></div>');
420	var colors = null;
421	var input = null;
422
423	$(document.body).append(select);
424
425	function hide() {
426		if (select.is(':visible')) {
427			
428			select.hide();
429			$('.shop2-color-ext-select').removeClass('open');
430			
431			return true;
432		}
433	}
434
435	$(document).on('click', hide);
436
437	$.on('.shop2-color-ext-select', {
438
439		click: function() {
440
441			if (hide()) {
442				return;
443			}
444
445			var wrap = $(this);
446			var ul = wrap.find('.shop2-color-ext-options');
447			var offset = {
448				top: wrap.offset().top + wrap.outerHeight(),
449				left: wrap.offset().left
450			}
451
452			var html =
453				'<div class="baron-wrapper">' +
454				'	<div class="baron-scroller">' +
455				'		<div class="baron-container">' +
456				'			<div class="shop2-color-ext-options">' +
457				ul.html() +
458				'			</div>' +
459				'		</div>' +
460				'		<div class="baron-scroller-bar"></div>' +
461				'	</div>' +
462				'</div>';
463
464			colors = ul.children('li');
465			input = wrap.find('input');
466
467			select.html(html)
468			select.show();
469			
470			wrap.addClass('open');
471
472			var wrapWidth = wrap.get(0).getBoundingClientRect().width;
473			
474			var selectWidth = select.data('width') || (function() {
475					var width = select.width();
476					select.data('width', width);
477					return width;
478				})();
479				
480			select.css('width', wrapWidth);
481			
482			baron(select, {
483				scroller: '.baron-scroller',
484				container: '.baron-container',
485				bar: '.baron-scroller-bar'
486			});
487
488			select.css(offset);
489
490			return false;
491
492		}
493
494	});
495
496	$.on('#shop2-color-ext-select li:not(.shop2-color-ext-selected)', {
497
498		click: function() {
499			var $this = $(this);
500			var index = $this.index();
501			var data = $this.data();
502
503			$this.addClass('shop2-color-ext-selected').siblings().removeClass('shop2-color-ext-selected');
504			colors.removeClass('shop2-color-ext-selected');
505			colors.eq(index).addClass('shop2-color-ext-selected');
506			
507			if (data.kinds) {
508				shop2.product._reload(colors.get(index));
509			} else {
510				input.val(data.value);
511			}
512		}
513	});
514
515};
516
517shop2.queue.sort = function() {
518	var wrap = $('.sorting');
519
520	wrap.find('.sort-param').on('click', function(e) {
521		var $this = $(this),
522			name = $this.data('name');
523
524		e.preventDefault();
525		shop2.filter.sort(name, $(this));
526		shop2.filter.go();
527	});
528
529	wrap.find('.sort-reset').on('click', function(e) {
530		e.preventDefault();
531		shop2.filter.remove('s[sort_by]');
532		shop2.filter.go();
533	});
534	
535	wrap.find('.sort-title').on('click', function(e) {
536		$(this).parent().toggleClass('open');
537		e.preventDefault();
538	});
539	
540	$(document).on('click', function(e) {
541		if ( $('.sorting').hasClass('open') && !$(e.target).closest('.sort-body, .sort-title').length ) {
542			$('.sorting').removeClass('open');
543		}
544	});
545};
546
547shop2.filter.sort = function(name, el) {
548	var re = new RegExp(this.escape('s[sort_by]') + '=([^&]*)'),
549		params = this.str.match(re),
550		desc = el.hasClass('sort-param-asc') ? name + ' asc' : name + ' desc';
551
552	params = (params && params.length > 1) ? params[1] : '';
553	
554	params = desc;
555
556	this.remove('s[sort_by]');
557	this.add('s[sort_by]', params);
558		
559	return this;
560};
561
562shop2.queue.views = function() {
563
564	var $productList 	= $('.product-list')
565		$productItems 	= $('.shop2-product-item'),
566		$tr 			= $('.product-list-tr');
567
568	$('.view a').on('click', function(e) {
569		var $this 			= $(this),
570			value 			= $this.data('value'),
571			$productItems 	= $('.shop2-product-item', $productList);
572
573		if ( value == 'list' ) {
574			$tr.removeClass('hidden');
575		} else {
576			$tr.addClass('hidden');
577		}
578
579		$this
580			.addClass('active-view')
581			.siblings()
582			.removeClass('active-view');
583
584		$productItems
585			.removeClass($productItems.attr('class').replace( /[a-zA-Z0-9_-]+(?=\s)/, "" ))
586			.addClass(value);
587
588		$productList
589			.removeClass($productList.attr('class').replace( /[a-zA-Z0-9_-]+(?=\s)/, "" ))
590			.addClass(value);
591
592		createCookie('views', value, 7);
593
594		// setTimeout(function() {
595		// 	$.fn.matchHeight._update();
596		// }, 300);
597		
598		window.shop2_gr.methods.productView(value, $productItems);
599
600		e.preventDefault();
601
602		return false;
603	});
604	
605	window.shop2_gr.methods.productView($('.view .active-view').data('value'), $productItems);
606};
607
608shop2.queue.discounts = function() {
609
610	$(document).on('click', '.shop2-product-actions .item-action', function(e) {
611		var $this = $(this),
612			win = $this.next(),
613			left = $this.position().left;
614
615		e.stopPropagation();
616
617		if (win.is(':hidden')) {
618			$('.shop2-product-actions .item-action-des').hide();
619			win.show();
620		} else {
621			win.hide();
622		}
623	});
624
625	$(document).on('click', function() {
626		$('.shop2-product-actions .item-action-des').hide();
627	});
628};
629
630if(!shop2.my.gr_amount_init){
631
632shop2.queue.amount = function() {
633
634	var $document = $(document);
635
636	function validate(input) {
637		var kind = input.data('kind'),
638			max = input.data('max'),
639			val = Number(input.val()),
640			amount = 0,
641			available;
642			
643		if (kind && max > 0) {
644			$('input[data-kind=' + kind + ']').each(function() {
645				amount += Number(this.value);
646			});
647
648			if (amount > max) {
649				available = max - amount + val;
650				input.val(available);
651				shop2.msg(_s3Lang.JS_AVAILABLE_ONLY + ' ' + available, input);
652			}
653		}
654	}
655
656	$document.on('click', '.amount-minus', function() {
657		var $this = $(this),
658			text = $this.siblings('input:text'),
659			value = text.getVal();
660
661		if (value) {
662			value = value[0];
663		}
664		value -= shop2.options.amountDefaultInc;
665		value = value.toFixed(5) - 0;
666
667		if (value <= shop2.options.amountDefaultValue) {
668			value = shop2.options.amountDefaultValue;
669
670			$this.addClass('disab');
671		}
672
673		text.val(value);
674		text.trigger('keyup');
675	});
676
677	$document.on('click', '.amount-plus', function() {
678
679		var $this = $(this),
680			text = $this.siblings('input:text'),
681			value = text.getVal();
682
683		if (value) {
684			value = value[0];
685		}
686
687		value += shop2.options.amountDefaultInc;
688		value = value.toFixed(5) - 0;
689
690		text.val(value);
691		text.trigger('keyup');
692
693		text.siblings().removeClass('disab');
694	});
695
696	$document.on('keyup', '.shop2-product-amount input:text', function() {
697		var $this = $(this);
698		validate($this);
699	});
700
701	$document.keyFilter('.shop2-product-amount input:text', {
702		type: shop2.options.amountType
703	});
704};
705
706}
707
708shop2.queue.question = function() {
709	var cls = '.price-old.question, .shop2-cart-total .question',
710		isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
711		
712	if ( isMobile ) {
713		$(cls).on('click', function() {
714			var $this = $(this),
715				win = $this.next().show(),
716				position = $this.position(),
717				height = win.outerHeight(true);
718		
719			win.css({
720				top: position.top - height - 5,
721				left: position.left
722			});
723		});
724		$(document).on('touchend', function(e) {
725			if ( $(e.target).closest(cls).length ) return;
726			$(cls).next().hide();
727		});
728	} else {
729		$(document).on('mouseenter', cls, function() {
730			var $this = $(this),
731				win = $this.next().show(),
732				position = $this.position(),
733				height = win.outerHeight(true);
734		
735			win.css({
736				top: position.top - height - 5,
737				left: position.left
738			});
739		
740		}).on('mouseleave', cls, function() {
741		
742			var $this = $(this),
743				win = $this.next();
744		
745			win.hide();
746		});
747	}
748},
749
750shop2.msg = function(text, obj) {
751	var selector = '#shop2-msg',
752		msg = $(selector),
753		offset = obj.offset(),
754		width = obj.outerWidth(true),
755		height = obj.outerHeight(true);
756
757	if (!msg.get(0)) {
758		msg = $('<div id="shop2-msg">');
759		$(document.body).append(msg);
760		msg = $(selector);
761	}
762
763	msg.html(text).show();
764
765	var msgWidth = msg.outerWidth();
766	var left = offset.left + width/2 - msgWidth/2;
767	var top = offset.top + height;
768
769	msg.css({
770		left: left,
771		top: top
772	});
773
774	$.s3throttle('msg', function() {
775		msg.hide();
776	}, shop2.options.msgTime);
777
778};
779
780(function($, self) {
781
782	var gr = {
783		queue: {},
784		methods : {},
785		scrollTop: 0,
786
787		init: function(settings) {
788
789			$(function() {
790				$('table').wrap('<div class="table-wrapper"></div>');
791				var queue  = gr.queue;
792
793				$.each(queue, function(method) {
794					var f = queue[method];
795					if ($.isFunction(f)) {
796						f();
797					}
798				});
799				
800				gr.methods.stylerSelect();
801				gr.methods.stylerRadio();
802				gr.methods.rangeSlider();
803				gr.methods.datePicker.params();
804				gr.methods.datePicker.enable();
805				
806				// $.ajaxSetup({
807				// 	complete: function() {
808				// 		gr.methods.stylerSelect();
809				// 		gr.methods.rangeSlider();
810				// 		$('[data-styler] select').not('[multiple]').trigger('refresh');
811				// 		//$.fn.matchHeight._update();
812				// 	}
813				// });
814			});
815		}
816	};
817
818	gr.queue = {
819		disableHS: function() {
820			$('.shop2-compare-product-image a img, .shop2-compare-data a img, .shop2-product .product-image a img, .shop2-product .product-thumbnails li a img, .cart-product-image a img, .cart-product-param a img').closest('a').off('click').removeClass('highslide');
821		},
822
823		panel: function() {
824			$(document.documentElement).on({
825				'keydown': function(event) {
826					if ( event.keyCode == 27 ) {
827						gr.methods.panel.closePanel();
828						$('.close', '.top-panel').click();
829					}
830				},
831				'click': function(event) {
832					var $panel 		= $('.panel'),
833						$exceptions = $panel.children().not('.popup-form-wrapper, [data-search-scroll], .shop2-login-wrap');
834						
835					if ( $panel.hasClass('open') && ( !$(event.target).closest($exceptions).length && !$(event.target).closest('#ui-datepicker-div, .ui-corner-all, .buy_one_click, #shop2-color-ext-select, .view-button, [id^="p1cal"], .popup-form-wrapper .tpl-anketa, [data-menu-button]').length ) ) {
836						gr.methods.panel.closePanel();
837
838						$('[data-menu-button]').removeClass('open');
839					}
840
841					if ( !$(event.target).closest('.site-search, .search-toggle, .shop2-search-form, #shop2-color-ext-select').length && $('.search-wrap').hasClass('open') ) {
842						$('.search-wrap').removeClass('open');
843						$('.shop2-search-form').hide();
844						$('.shop-search-toggle').removeClass('open');
845					}
846					
847					if ( !$(event.target).closest('.top-panel').length && $('.top-panel').is(':visible') ) {
848						console.log(4454564);
849						$('.close', '.top-panel').click();
850					}
851					
852					if ( !$(event.target).closest('.site-menu').length ) {
853						$('[data-menu-button]').removeClass('open');
854					}
855					
856					if ( !$(event.target).closest('.categories, [data-folder-button]').length ) {
857						$('[data-folder-button]').removeClass('open');
858					}
859				}
860			});
861		},
862		
863		amountBlock: function() {
864			
865			if(shop2.my.gr_amount_init){
866
867			amountInit();
868			
869			}
870
871		}, /*Количество*/
872
873		filter: function() {
874			var $filterWrap		= $('.filter-wrap'),
875				$filter 		= $('.shop2-filter'),
876				$colorSelect 	= $filter.find('.shop2-col-ext-list'),
877				$filterToggle 	= $('.filter-title');
878			
879			$filterToggle.on('click', function(e) {
880				$filterWrap.toggleClass('open');
881				e.preventDefault;
882			});
883			
884			$colorSelect.on('click', 'li', function() {
885				var $this	= $(this),
886					data 	= $this.data();
887				
888				$this.toggleClass('shop2-color-ext-selected');
889				shop2.filter.toggle(data.name, data.value);
890				shop2.filter.count();
891			});
892
893			$(document).on('click', function(e) {
894				if ( $filterWrap.hasClass('open') && (!$(e.target).closest($filter).length && !$(e.target).closest($filterToggle).length) ) {
895					$filterWrap.removeClass('open');
896				}
897			});
898		},
899
900		constacts: function() {
901			var $button 	= $('.contacts-toggle span'),
902				$contact 	= $('.top-panel .contacts');
903
904			$button.on('click', gr.methods.panel.topPanel($contact));
905		},
906
907		login: function() {
908			var $button 	= $('.user-toggle'),
909				$login 	= $('.top-panel .login-form');
910
911			$button.on('click', gr.methods.panel.topPanel($login));
912		},
913
914		topPanelClose: function() {
915			var $panel = $('.top-panel'),
916				$close = $('.close', $panel);
917
918			$close.on('click', function(event) {
919				$('.site-header__top').slideDown();
920
921				$panel.slideUp();
922
923				event.preventDefault();
924			});
925		},
926
927		search: function() {
928			var	isMobile 		= /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
929				$search 		= $('.search-wrap'),
930				$searchSiToggle = $('.search-toggle'),
931				$searchShToggle = $('.shop-search-toggle'),
932				$shopSearch 	= $('.shop2-search-form'),
933				$more 			= $search.find('.more');
934
935			$searchSiToggle.on('click', function() {
936				$search.toggleClass('open');
937			});
938
939			$searchShToggle.on('click', function() {
940				$(this).toggleClass('open');
941				$shopSearch.slideToggle();
942			});
943
944			$('.site-search input[type="text"]', $search).on('focus', function() {
945				$search.addClass('open');
946			});
947
948			$search.on('click', '.row', function() {
949				var $this 		= $(this),
950					$title 		= $('.row-title', $this),
951					$body 		= $('.row-body', $this);
952
953				$this
954					.siblings()
955					.children('.row-title')
956					.removeClass('open');
957					
958				$this
959					.siblings()
960					.children('.row-body')
961					.slideUp();
962
963				$title.addClass('open');
964				$body.slideDown();
965			});
966			
967			$more.each(function(index, el) {
968				$(this).on('click', gr.methods.showMore($(this)));
969			});
970		},
971
972		singleSlider: function() {
973			var $slider = $('[data-single-slider]');
974
975			$slider.addClass('owl-carousel').owlCarousel({
976				items: 1,
977				margin: 0,
978				loop: true,
979				single: true,
980				autoplay: true,
981				smartSpeed: 1000,
982				fluidSpeed: 1000,
983				responsive : {
984					0 : {
985						dots: true,
986						nav: false
987					},
988					768 : {
989						dots: true,
990						nav: true
991					}
992				}
993			});
994		},
995
996		siteMenu: function() {
997			var isMobile 	= /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
998				$nav 		= $('.site-menu'),
999				$menu 		= $nav.children('ul'),
1000				$burger		= $('[data-menu-button]'),
1001				$flag 		= undefined;
1002
1003			if ( !$nav.length ) return;
1004
1005			$burger.on('click', function(event) {
1006				var $this = $(this);
1007				$this.toggleClass('open');
1008			});	
1009
1010			$menu.find('a').each(function() {
1011				if ( $(this).next('ul').length )
1012				$(this).addClass('has').append('<ins><svg xmlns="http://www.w3.org/2000/svg" width="4" height="3" viewBox="0 0 4 3"><path d="M3657.01,26l-2-3h4.01Z" transform="translate(-3655 -23)"/></svg></ins>');
1013			});
1014
1015			function func() {
1016				if ( window.matchMedia('(max-width: 1023px)' ).matches || isMobile ) {
1017					if ( $flag === true ) return;
1018					
1019					$('.has', $menu).on('click', function() {
1020						var $this = $(this);
1021						
1022						if ( !$this.hasClass('act') ) {
1023							$this.addClass('act');
1024							return false;
1025						}
1026					});
1027
1028					$nav.removeClass('desktop')
1029						.addClass('mobile');
1030						
1031					setTimeout(function() {
1032						$menu.responsiveMenu('destroy');
1033					}, 300);
1034					
1035					$flag = true;
1036					
1037				} else {
1038					if ( $flag === false ) return;
1039					
1040					$('.has', $menu).off('click');
1041
1042					$nav.addClass('desktop')
1043						.removeClass('mobile');
1044
1045					setTimeout(function() {
1046						$menu.responsiveMenu();
1047					}, 300);
1048					
1049					$flag = false;
1050				}
1051			}
1052
1053			$(window).on('resize', func).trigger('resize');
1054		},
1055
1056		folderMenu: function() {
1057			var isMobile 	= /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
1058				$nav 		= $('.categories-nav'),
1059				$menu 		= $nav.children('ul'),
1060				$li 		= $menu.children(),
1061				$burger		= $('[data-folder-button]'),
1062				$logo 		= $('.company'),
1063				$mobWrap 	= $('.site-header__mid .width-wrap'),
1064				$desWRap 	= $('.site-header'),
1065				flag 		= undefined,
1066				timer;
1067
1068			$burger.on('click', function(event) {
1069				$(this).toggleClass('open');
1070				return false;
1071			});
1072			
1073			$('span.back', $menu).on('click', function() {
1074				$('li', $menu).removeClass('active hide');
1075			});
1076			
1077			function events(bul) {
1078				if (bul) {
1079					$('a.has', $menu).on('click', function() {
1080						var $this 	= $(this),
1081							$li 	= $this.parent();
1082							
1083						if ( !$li.hasClass('active') && $this.hasClass('has') ) {
1084							$li
1085								.addClass('active')
1086								.siblings()
1087								.addClass('hide');
1088								
1089							return false;
1090						}
1091					});
1092					
1093					$('a.sub', $menu).off('click');
1094					
1095					$li.on('mouseenter', function() {
1096						var $this 		= $(this),
1097							offsetTop 	= $this.position().top + $this.outerHeight();
1098							
1099						clearTimeout(timer);
1100						
1101						$('li', $menu).removeClass('active hide');
1102						
1103						$this
1104							.siblings('li')
1105							.removeClass('hover')
1106							.children('ul')
1107							.removeAttr('style');
1108							
1109						$this
1110							.addClass('hover')
1111							.children('ul')
1112							.css({'top': offsetTop});
1113					});
1114					
1115					$li.on('mouseleave', function() {
1116						var $this = $(this);
1117		
1118						timer = setTimeout(function() {
1119							$this
1120								.removeClass('hover')
1121								.children('ul')
1122								.removeAttr('style');
1123								
1124							$('li', $menu).removeClass('active hide');
1125						}, 300);
1126					});
1127				} else {
1128					$li.off('mouseenter').off('mouseleave');
1129					
1130					$('a.has', $menu).off('click');
1131					
1132					$('a.sub', $menu).on('click', function() {
1133						var $this 	= $(this),
1134							$li 	= $this.parent();
1135							
1136						if ( !$li.hasClass('active') ) {
1137							$li
1138								.addClass('active')
1139								.siblings()
1140								.addClass('hide');
1141								
1142							return false;
1143						}
1144					});
1145				}
1146			}
1147			
1148			function cols() {
1149				var $list = $('.categories > li > ul');
1150				
1151				$list.each(function() {
1152					var $this 		= $(this);
1153						$children 	= $this.children().not('.block');
1154						
1155					$children.wrapAll('<li class="col"></li>');
1156				});
1157			};
1158			
1159			function func() {
1160				if ( window.matchMedia('(max-width: 1023px)' ).matches || isMobile ) {
1161					if ( flag === true ) return;
1162					
1163					$('li', $menu).removeClass('active hide');
1164					
1165					$nav
1166						.removeClass('desktop')
1167						.addClass('mobile')
1168						.prependTo($mobWrap);
1169						
1170					$('li.col').each(function() {
1171						$(this).children().unwrap();
1172					});
1173					
1174					events(false);
1175					
1176					$logo
1177						.addClass('mobile')
1178						.appendTo($desWRap);
1179						
1180					flag = true;
1181				
1182				} else {
1183					if ( flag === false ) return;
1184					
1185					$('li', $menu).removeClass('active hide');
1186					
1187					$nav
1188						.removeClass('mobile')
1189						.addClass('desktop')
1190						.appendTo($desWRap);
1191
1192					$logo
1193						.removeClass('mobile')
1194						.appendTo($mobWrap);
1195						
1196					cols();
1197					
1198					events(true);
1199						
1200					flag = false;
1201				}
1202			};
1203
1204			$(window).on('resize', func);
1205		},
1206
1207		folders: function() {
1208			var $folder 	= $('.folder-block-body'),
1209				$items 		= $folder.children(),
1210				$itms 		= $items.slice(4);
1211				$imageWrap 	= $('.item__image', $folder),
1212				$all 		= $('.show-more span', '.folder-block-wrap');
1213
1214			function func() {
1215				var padding = 	window.matchMedia('(max-width: 1023px)').matches ? Math.round($folder.outerWidth() / 3.04) :
1216								window.matchMedia('(max-width: 1179px)').matches ? Math.round($folder.outerWidth() / 2.98) : Math.round($folder.outerWidth() / 2.95);
1217
1218				if (window.matchMedia('(max-width: 639px)' ).matches) {
1219					$imageWrap.removeAttr('style');
1220				} else {
1221					$imageWrap.css({'paddingTop': padding});
1222				}
1223
1224				gr.methods.imageCover($folder);
1225			};
1226
1227			gr.methods.imageCover($folder);
1228
1229			$itms.hide();
1230
1231			$all.on('click', function() {
1232				if ( $all.text() == 'Показать еще' ) {
1233					$itms.each(function(index, el) {
1234						var $this = $(this);
1235
1236						setTimeout(function() {
1237							$this.fadeToggle();
1238						}, index * 200);
1239					});
1240
1241					$all
1242						.text('Скрыть')
1243						.addClass('showen');
1244				} else {
1245					$itms.slideUp();
1246					$all
1247						.text('Показать еще')
1248						.removeClass('showen');
1249				}
1250			});
1251
1252			$(window).on('resize', func).trigger('resize');
1253		},
1254
1255		news: function() {
1256			var $news = $('[data-news]');
1257			
1258			$news.addClass('owl-carousel').owlCarousel({
1259				items: 3,
1260				margin: 0,
1261				loop: false,
1262				responsive : {
1263					0 : {
1264						items: 1,
1265						dots: true,
1266						nav: false,
1267						single: true
1268					},
1269					640 : {
1270						items: 2,
1271						margin: 60,
1272						nav: false,
1273						dots: false
1274					},
1275					1024 : {
1276						items: 3,
1277						margin: 35,
1278						nav: false,
1279						dots: false
1280					},
1281					1180 : {
1282						items: 3,
1283						margin: 50,
1284						nav: false,
1285						dots: false
1286					}
1287				}
1288			});
1289		},
1290		
1291		brend: function() {
1292			var $slider = $('[data-brend]');
1293			
1294			$slider.addClass('owl-carousel').owlCarousel({
1295				items: 3,
1296				margin: 0,
1297				loop: true,
1298				responsive : {
1299					0 : {
1300						dots: false,
1301						nav: false,
1302						margin: 20,
1303					    loop: true,
1304					    autoWidth: true,
1305					    items: 3
1306					},
1307					480 : {
1308						items: 3,
1309						nav: true,
1310						dots: false
1311					},
1312					768 : {
1313						items: 4,
1314						nav: true,
1315						dots: false
1316					},
1317					1024 : {
1318						items: 5,
1319						nav: true,
1320						dots: false
1321					},
1322					1180 : {
1323						items: 7,
1324						nav: true,
1325						dots: false
1326					}
1327				}
1328			});
1329		},
1330
1331		productSlider: function() {
1332			var $slider = $('.product-image-inner'),
1333				$thumbs = $('.product-thumbnails ul');
1334				
1335			$('.product-image-inner:not(.slick-slider)').lightGallery({
1336		        thumbnail: false,
1337			    download: true,
1338			    loop: false,
1339			    counter: false,
1340			    getCaptionFromTitleOrAlt: true,
1341			    zoom: true,
1342			    showZoomInOutIcons: true,
1343				share: false,
1344		        height: '100%',
1345		    });
1346				
1347			if ( $slider.children('a').length < 2 ) return;
1348			
1349			$slider.on('init', function() {
1350				$slider.lightGallery({
1351			        selector: "a:not(.slick-cloned)",
1352			        thumbnail: false,
1353				    download: true,
1354				    loop: false,
1355				    counter: false,
1356				    getCaptionFromTitleOrAlt: true,
1357				    zoom: true,
1358				    showZoomInOutIcons: true,
1359					share: false,
1360			        height: '100%',
1361			    });
1362			});
1363
1364			$slider.slick({
1365				fade: true,
1366				arrows: false,
1367				slidesToShow: 1,
1368				slidesToScroll: 1,
1369				centerMode: false,
1370				asNavFor: $thumbs,
1371				responsive: [
1372					{
1373						breakpoint: 1024,
1374						settings: {
1375							dots: true,
1376							fade: false,
1377							centerMode: true,
1378							centerPadding: '139px'
1379						}
1380					},
1381					{
1382						breakpoint: 640,
1383						settings: {
1384							dots: true,
1385							fade: false,
1386							centerMode: true,
1387							centerPadding: '60px'
1388						}
1389					},
1390					{
1391						breakpoint: 480,
1392						settings: {
1393							dots: true,
1394							fade: false,
1395							centerMode: false,
1396							centerPadding: 0
1397						}
1398					}
1399				]
1400			});
1401
1402			$thumbs.slick({
1403				vertical: true,
1404				slidesToShow: 5,
1405				slidesToScroll: 1,
1406				asNavFor: $slider,
1407				dots: false,
1408				centerPadding: 0,
1409				centerMode: false,
1410				focusOnSelect: true,
1411				responsive: [
1412					{
1413						breakpoint: 1180,
1414							settings: {
1415							slidesToShow: 5,
1416							slidesToScroll: 1,
1417							vertical: false
1418						}
1419					}
1420				]
1421			});
1422		},
1423
1424		accordion: function() {
1425			var $wrap = $('.shop2-product-data'),
1426				$item = $('.item-acc', $wrap);
1427
1428			$item.on('click', '.ac_title', function(event) {
1429				var $this 	= $(this)
1430					$other 	= $('.ac_title', $wrap).not($this);
1431
1432				$other.removeClass('open')
1433					.next()
1434					.slideUp();
1435				
1436				$this
1437					.toggleClass('open')
1438					.next()
1439					.slideToggle();
1440					
1441				setTimeout(function() {
1442					$('[data-modification]').trigger('refresh.owl.carousel');
1443				}, 300);
1444			});
1445		},
1446		mainBlocks: function() {
1447			var $blocks = $('[main_blocks]');
1448				
1449			if (!$blocks.length) return;
1450				
1451			$blocks.each(function() {
1452				var $this 	= $(this),
1453					$length	= $('.shop2-product-item', $this);
1454					
1455				$(this).addClass('owl-carousel').owlCarousel({
1456					margin: 20,
1457					dots: false,
1458					loop: false,
1459					responsive:{
1460						0:{
1461							dots: false,
1462							nav: false,
1463							margin: 20,
1464						    loop: $length.length > 1 ? true : false,
1465						    autoWidth: true,
1466						    items: 2
1467						},
1468						480:{
1469							items:2,
1470							nav: true
1471						},
1472						640:{
1473							items:3,
1474							nav: true
1475						},
1476						1024:{
1477							items: 4,
1478							nav: true
1479						},
1480						1180:{
1481							items: 4,
1482							nav: true
1483						}
1484					}
1485				});
1486			});
1487		},
1488
1489		productCollection: function() {
1490			$('[data-collection]').each(function() {
1491				
1492				var slider = $(this).addClass('owl-carousel').owlCarousel({
1493					loop: false,
1494					dots: false,
1495					responsive:{
1496						0:{
1497							dots: true,
1498							nav: false,
1499							margin:20,
1500						    loop: true,
1501						    autoWidth: true,
1502						    items: 2
1503						},
1504						480:{
1505							items: 3,
1506							margin: 20,
1507							dots: true,
1508							nav: false
1509						},
1510						768:{
1511							items:3,
1512							margin: 20,
1513							dots: true,
1514							nav: false
1515						},
1516						1024:{
1517							items: 4,
1518							margin: 20,
1519							dots: false,
1520							nav: true
1521						},
1522						1440:{
1523							items: 5,
1524							margin: 20,
1525							dots: false,
1526							nav: true
1527						}
1528					}
1529				});
1530			})
1531		},
1532		
1533		modification: function() {
1534			$('[data-modification]').addClass('owl-carousel').owlCarousel({
1535				loop: false,
1536				dots: false,
1537				autoplay: true,
1538				responsive:{
1539					0:{
1540						dots: true,
1541						nav: false,
1542						margin:20,
1543					    loop: true,
1544					    autoWidth: true,
1545					    items: 2
1546					},
1547					480:{
1548						items: 3,
1549						margin: 20,
1550						dots: false,
1551						nav: false
1552					},
1553					768:{
1554						items:3,
1555						margin: 20,
1556						dots: false,
1557						nav: false
1558					},
1559					1024:{
1560						items: 2,
1561						margin: 20,
1562						dots: false,
1563						nav: false
1564					}
1565				}
1566			});
1567		},
1568
1569		cart: function() {
1570			var $more = $('.more_opt span');
1571				$wrap = $('.shop2-cart-item-product');
1572
1573			$more.on('click', cl());
1574
1575			$(window).on('resize', func).trigger('resize');
1576
1577			function func() {
1578				$wrap.each(function(index, el) {
1579					var $this = $(this),
1580						$elem = $this.find('.cart-price, .cart-amount, .cart-delete');
1581
1582					if ( window.matchMedia('(max-width: 767px)' ).matches ) {
1583						if ( $this.find('.cart-product2').length ) return;
1584						$elem.wrapAll('<div class="cart-product2"></div>');
1585						flag_ = true;
1586					} else {
1587						if ( !$this.find('.cart-product2').length ) return;
1588						$this.find('.cart-product2').children().unwrap();
1589						flag_ = false;
1590					}
1591				});
1592			}
1593
1594			function cl(e) {
1595				var counter = 3;
1596				
1597				return function() {
1598					var $this 		= $(this),
1599						$optWrap 	= $this.parent().siblings('.cart-product-param'),
1600						$optItem 	= $optWrap.children()
1601						length 		= $optItem.length;
1602
1603					if ( counter < length ) {
1604						$optItem
1605							.slice(counter, counter + 3)
1606							.removeClass('hide');
1607
1608						counter += 3;
1609
1610						if ( counter >= length ) {
1611							$this.text('Скрыть')
1612						}
1613
1614					} else {
1615						$this.text('еще параметры');
1616						$optItem.slice(3)
1617								.addClass('hide');
1618
1619						counter = 3;
1620					}
1621				};
1622			};
1623		},
1624
1625		matchHeight: function() {
1626			var elemArray = [
1627					$('.shop2-product-item .product-name'),
1628					$('.shop2-kind-item .kind-name')
1629				],
1630				params = {
1631					byRow: true,
1632					property: 'min-height'
1633				}
1634				
1635			elemArray.forEach(function(item, i, arr) {
1636				item.matchHeight(params);
1637			});
1638			
1639			if(!shop2.my.gr_image_height){
1640			
1641			$(function() {
1642				
1643				//1552
1644			
1645				$('.match_height_blocks').matchHeight({
1646				    byRow: true,
1647				    property: 'height',
1648				    target: null,
1649				    remove: false
1650				});
1651			});
1652			
1653			}
1654		},
1655
1656		buyOneClick: function() {
1657			var $panel = $('.panel');
1658			
1659			$('[data-oneclick]').on('click', function() {
1660				var $this 	= $(this),
1661					name 	= $(document.body).find('h1').text(),
1662					amt 	= $this.closest('.shop2-product-form').find('.shop2-product-amount input[type="text"]').val(),
1663					$wrap 	= $('.tpl-anketa', $panel),
1664					$forms 	= $('.tpl-anketa form', $panel).length;
1665					
1666				if (!$forms) {
1667					if ( $wrap.length ) {
1668						$formsWr.remove();
1669					}
1670					
1671					$.ajax({
1672						url: $this.data('api-url'),
1673						dataType: 'json',
1674						success: function(response){
1675							if (!response.result.error) {
1676								$(response.result.html).appendTo('.panel').wrap('<div class="popup-form-wrapper"></div>');
1677								
1678								$('.popup-form-wrapper').find('.prodname input').val( name + '  (Количество: ' + amt + ')' );
1679								$('.popup-form-wrapper').find('.prodlink input').val(document.location.href);
1680								
1681								s3From.initForms($('.popup-form-wrapper'), gr.methods.datePicker.enable());
1682								
1683								gr.methods.panel.openPanel($('.popup-form-wrapper'))();
1684							}
1685						}
1686					});
1687					
1688					return false;
1689				} else {
1690					
1691					gr.methods.panel.openPanel($('.popup-form-wrapper'))();
1692					
1693					return false;
1694				}
1695			});
1696		},
1697		
1698		cartUpdate: function() {
1699			$('.shop2-cart-update-btn').on('click', function(e) {
1700				e.preventDefault();
1701				shop2.cart.update($('#shop2-cart'));
1702				return false;
1703			})
1704		},
1705		
1706		fastView: function() {
1707			var $buttons 	= $('.view-button'),
1708				$panel 		= $('.panel');
1709				
1710			$(document).on('click', '.view-button', function() {
1711				var $this 	= $(this),
1712					link 	= $this.data('link'),
1713					id 		= $this.data('id'),
1714					$wrap 	= $('.popup-product-wrap', $panel);
1715					
1716				if ( $wrap.length ) {
1717					if ( $wrap.data('id') == id ) {
1718						
1719						gr.methods.panel.openPanel($('.popup-product-wrap', $panel))();
1720						
1721					} else {
1722						$wrap.remove();
1723						ajfunc(link, id);
1724					}
1725				} else {
1726					ajfunc(link, id);
1727				}
1728			});
1729			
1730			function ajfunc(l, i) {
1731				$.ajax({
1732					url: l,
1733					data: {"fast_view": 1},
1734					success: function(data, stutus) {
1735						var $response = $(data);
1736						
1737						$response
1738							.appendTo($panel)
1739							.wrapAll('<div class="popup-product-wrap" data-id="' + i + '"></div>');
1740							
1741						gr.methods.panel.openPanel($('.popup-product-wrap', $panel))();
1742						
1743						if(shop2.my.gr_amount_init){
1744						
1745						amountInit();
1746						
1747						}
1748						
1749						setTimeout(function() {
1750							$('[data-product-images]', $response).addClass('owl-carousel').owlCarousel({
1751								items: 1,
1752								margin: 0,
1753								nav: true,
1754								loop: true,
1755								dots: true
1756							});
1757							
1758							$('select:not([multiple])', $response).styler();
1759							
1760							$('[data-fastview-close]', $panel).on('click', gr.methods.panel.closePanel);
1761						}, 300);
1762					}
1763				});
1764			};
1765		},
1766		
1767		up: function() {
1768			$('.go-up').on('click', function () {
1769				$('body,html').animate({
1770					scrollTop: 0
1771				}, 800);
1772				return false;
1773			});
1774		},
1775		
1776		sizeTable: function() {
1777			$(document).on('click', function(e) {
1778				if ( $(e.target).closest('.option-table__title, .option-table__body').length ) {
1779					$(e.target).toggleClass('open');
1780					return false;
1781				} else {
1782					if ( $('.option-table__title').hasClass('open') ) {
1783						$('.option-table__title').removeClass('open');
1784					}
1785				}
1786			});
1787		}
1788	};
1789
1790	gr.methods = {
1791		stylerSelect: function() {
1792			$('[data-styler] select').not('[multiple]').styler();
1793		},
1794		
1795		stylerRadio: function() {
1796			$('.options-list input[type="checkbox"], .options-list input[type="radio"]').mgStyler();
1797		},
1798		
1799		imageCover : function(imgWr) {
1800			var imgs = $(imgWr).find('img');
1801
1802			imgs.bindImageLoad(function() {
1803				var blockWidth = $(this).parents('.item__image').outerWidth(),
1804					blockHeight = $(this).parents('.item__image').outerHeight(),
1805					wrRatio = blockHeight / blockWidth;
1806
1807				var imgRatio = $(this).prop('naturalHeight') / $(this).prop('naturalWidth');
1808
1809				if ( wrRatio > imgRatio ) {
1810					$(this).parent().removeClass('height').addClass('width');
1811				} else {
1812					$(this).parent().removeClass('width').addClass('height');
1813				}
1814			});
1815		},
1816
1817		panel: {
1818			topPanel: function(elem) {
1819				return function() {
1820					var $height = elem.outerHeight(),
1821						$header = $('.site-header__top'),
1822						$panel = $('.top-panel');
1823
1824					elem
1825						.show()
1826						.siblings()
1827						.not('.close')
1828						.hide();
1829
1830					$header.slideUp();
1831					
1832					$panel.slideDown();
1833					
1834					return false;
1835				}
1836			},
1837			openPanel: function(elem) {
1838				return function() {
1839					gr.scrollTop = $(document).scrollTop();
1840					
1841					$(document.body)
1842						.addClass('overflowhidden');
1843						
1844					// $(document.body)
1845					// 	.addClass('overflowhidden')
1846					// 	.css({
1847					// 		"top": -gr.scrollTop,
1848					// 		"padding-right": gr.scrollWidth
1849					// 	});
1850
1851					$('.panel').addClass('open');
1852
1853					elem
1854						.show()
1855						.siblings()
1856						.hide();
1857					
1858					setTimeout(function() {
1859						elem.addClass('open')
1860					}, 100);
1861					
1862					return false;
1863				}
1864			},
1865			closePanel: function() {				
1866				$('.panel').children().removeClass('open');
1867				
1868				setTimeout(function() {
1869					$('.panel').removeClass('open');
1870					$(document.body)
1871						.removeClass('overflowhidden')
1872						.removeAttr('style');
1873					//$(document).scrollTop(gr.scrollTop);
1874				}, 200);
1875			}
1876		},
1877		
1878		productView: function(a, items) {
1879			if( a != 'simple' ) {
1880			
1881				if( !items.eq(0).find('.product-mid-bot').length ) return;
1882				
1883				items.each(function() {
1884					var $this 	= $(this),
1885						$elem	= $this.find('.product-mid, .product-bot');
1886						
1887					$elem.unwrap();
1888				});
1889			} else {
1890				
1891				if( items.eq(0).find('.product-mid-bot').length ) return;
1892				
1893				items.each(function() {
1894					var $this 	= $(this),
1895						$elem	= $this.find('.product-mid, .product-bot');
1896					
1897					$elem.wrapAll('<div class="product-mid-bot"></div>');
1898				});
1899			}
1900		},
1901		
1902		rangeSlider: function() {
1903			$('[range-slider]').each(function(index, element) {
1904				
1905				var $this 			= $(this),
1906					$lower 			= $this.closest('.range').find('.from'),
1907					$upper 			= $this.closest('.range').find('.to'),
1908					priceMin 		= 0,
1909					priceMax 		= 40000,
1910					inputRangeMax 	= ( $upper.val() ) ? parseInt($upper.val()) : 40000,
1911					val 			= [$lower.val() ? $lower.val() : 0, inputRangeMax];
1912					
1913				$this.slider({
1914					range: true,
1915					min: priceMin,
1916					max: priceMax,
1917					values: val,
1918					step: 100,
1919					slide: function( event, ui ) {
1920						$lower.val( ui.values[ 0 ] );
1921						$upper.val( ui.values[ 1 ] );
1922						$lower.trigger('keyup');
1923						$upper.trigger('keyup');
1924					}
1925				});
1926				
1927				function func() {
1928					var fr = $lower.val() ? $lower.val() : undefined,
1929						to = $upper.val() ? $upper.val() : undefined;
1930						
1931					$this.slider( "values", [ $lower.val(), $upper.val() ] );
1932				};
1933				
1934				$lower.on('input', func);
1935		
1936				$upper.on('input', func);
1937			});
1938		},
1939		
1940		datePicker: {
1941			params: function() {
1942				$.datepicker.regional['ru'] = {
1943					closeText: 'Закрыть',
1944					prevText: '&#x3C;Пред',
1945					nextText: 'След&#x3E;',
1946					currentText: 'Сегодня',
1947					monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь',
1948					'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
1949					monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн',
1950					'Июл','Авг','Сен','Окт','Ноя','Дек'],
1951					dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
1952					dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'],
1953					dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
1954					weekHeader: 'Нед',
1955					dateFormat: 'dd.mm.yy',
1956					firstDay: 0,
1957					isRTL: false,
1958					showMonthAfterYear: false,
1959					yearSuffix: ''
1960				};
1961				$.datepicker.setDefaults($.datepicker.regional['ru']);
1962			},
1963			enable: function() {
1964				var $single = $('.type-calendar input'),
1965					$range = $('.type-calendar_interval .data-range-value');
1966					
1967				$single.each(function() {
1968					$(this).datepicker({
1969						minDate: 0,
1970						altField: "#actualDate"
1971					});
1972				});
1973				
1974				$range.each(function() {
1975					var $this 	= $(this),
1976						$from 	= $this.parent().find('input.from'),
1977						$to 	= $this.parent().find('input.to');
1978						
1979					$from.datepicker({
1980						defaultDate: "+1w",
1981						minDate: 0,
1982						onClose: function() {
1983							$to.datepicker( "option", "minDate", this.value );
1984							$this.val( 'от ' + $from.val() + ' до ' + $to.val() )
1985						}
1986					});
1987													
1988					$to.datepicker({
1989						defaultDate: "+1w",
1990						minDate: 0,
1991						onClose: function() {
1992							$from.datepicker( "option", "maxDate", this.value );
1993							$this.val( 'от ' + $from.val() + ' до ' + $to.val() )
1994						}
1995					});
1996				});
1997			}
1998		},		
1999	};
2000
2001	gr.init();
2002
2003	self.shop2_gr = gr;
2004	
2005})(jQuery, window);
2006//Ленивая загрузка картинок
2007$(document).ready(function(){
2008	if (shop2.my.gr_img_lazyload) {
2009	    var myLazyLoad = new LazyLoad();
2010        myLazyLoad.update();
2011	}	
2012});

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.