PageSourceSearch

https://kryshar.by/g/templates/shop2/2.110.2/food-store-online/js/plugins.js

js kryshar.by collected 2026-09-29 21:43:54 UTC 6,226 bytes, 214 lines download raw bytes

1$.fn.mgStyler = function() {
2	return this.each(function() {
3		var $this      	  = $(this),
4			isChecked  	  = $this.is(':checked'),
5			isDisabled 	  = $this.is(':disabled'),
6			isRadio 	  = $this.is(':radio'),
7			jqLabel    	  = $this.parent('label')
8			radioClass 	  = "mg-styler-label--radio",
9			checkboxClass = "mg-styler-label--checkbox",
10			labelClass    = isRadio ? radioClass : checkboxClass;
11			
12		if (jqLabel.length) {
13			jqLabel.addClass(labelClass);
14		} else {
15			jqLabel = $this
16						.wrap('<label></label>')
17						.parent('label')
18						.addClass(labelClass);
19		}
20		
21		jqLabel.toggleClass('disabled', isDisabled);
22		
23		jqLabel
24			.on('click.mgStyler', function(e){
25				toggle($(this));
26				e.preventDefault();
27			});
28
29		if (isChecked) {
30			jqLabel.addClass('checked');
31		}
32
33		function toggle(jqInput) {
34			if ( jqInput.find('input').is(':radio') ) {
35				var radioGroup = jqInput.find('input').attr('name');
36				$('input[name="' + radioGroup + '"]').closest('.' + radioClass).removeClass('checked');
37				
38				jqInput.addClass('checked').find('input[type=radio]').prop('checked', true);
39			} else {
40				jqInput.toggleClass('checked').find('input[type=checkbox]').prop('checked', !jqInput.find('input[type=checkbox]').prop('checked'));
41			}
42		}
43	});
44};
45
46function setEqualHeight(columns, callback) {
47    var tallestcolumn = 0;
48    var itemsLength = columns.length;
49    var itemsCounter = 0;
50    var hasCallback = callback == undefined;
51
52    columns.removeAttr('style');
53    columns.each(function(){
54        currentHeight = $(this).height();
55        if(currentHeight > tallestcolumn) {
56            tallestcolumn = currentHeight;
57        }
58        itemsCounter++;
59
60    });
61    columns.height(tallestcolumn);
62
63    if (itemsLength == itemsCounter && !hasCallback) {
64	    callback();
65    }
66};
67
68
69function resizeController() {
70	var $win = $(window),
71		winWidth = window.innerWidth,
72		range = [],
73		func = [],
74		toggleState = [undefined, undefined];
75
76	if (!!arguments.length) {
77		for (var i = 0; i <= arguments.length-1; i++) {
78			
79			if ($.isArray(arguments[i])) {
80				range = arguments[i];
81			} else if ($.isNumeric(arguments[i])) {
82				range.push(arguments[i]);
83			} else if ($.isFunction(arguments[i])) {
84				func.push(arguments[i]);
85			} 
86		};
87	}
88
89	$win.resize(function(event) {
90		winWidth = window.innerWidth;
91		
92		if (range.length > 1) {
93			if (winWidth >= range[0] && winWidth <= range[range.length-1] && typeof toggleState[0] === "undefined") {
94				func[0]();
95				toggleState[0] = true;
96				toggleState[1] = undefined;												
97			} else if ((winWidth < range[0] || winWidth > range[range.length-1]) && typeof toggleState[1] === "undefined") {						
98				toggleState[0] = undefined;
99				toggleState[1] = true;
100
101				if ($.isFunction(func[1])) {
102					func[1]();
103				}
104			}
105		} else if (range.length == 1) {
106			if (winWidth <= range[0] && typeof toggleState[0] === "undefined") {
107				func[0]();
108				toggleState[0] = true;
109				toggleState[1] = undefined;
110			} else if (winWidth > range[0] && typeof toggleState[1] === "undefined") {
111				toggleState[0] = undefined;
112				toggleState[1] = true;
113
114				if ($.isFunction(func[1])) {
115					func[1]();
116				}
117			}
118		}
119	}).trigger('resize');
120};
121
122$.fn.rowMenu = function(options) {
123	return this.each(function() {
124		var timeout;
125		var $menu = $(this);
126		var $li = $menu.find('>li');
127
128		var settings = $.extend( {
129			'moreText'         			: 'Еще',
130			'moreWidth'        			: 100,
131			'resizeTimeout'        		: 10,
132			'moreHideTimeout'        	: 500,
133			'moreBtnClass'	   			: 'row-menu-btn',
134			'moreContainerClass'	    : 'row-menu-container'
135	    }, options);
136
137		rowMenuInit();
138
139		$(window).on('resize', function(){
140			if (timeout!=='undefined') {
141				clearTimeout(timeout);
142			};
143			timeout = setTimeout(function(){
144				resizeRowMenu();
145			}, settings.resizeTimeout);
146		});
147
148		function rowMenuInit() {
149			var menuWdith = 0;
150			var menuMaxWdith = $menu.outerWidth();
151
152			$li.each(function() {
153				var $this = $(this);
154				var thisWidth = $this.outerWidth(true);
155
156				menuWdith += thisWidth;
157
158				if ((menuWdith+settings.moreWidth)>=menuMaxWdith) {
159					$this.attr('data-append', 1);
160
161					if ($menu.find('.' + settings.moreBtnClass).length<1) {
162						$menu.append('<li class="'+settings.moreBtnClass+'"><a href="javascript:void(0);">'+settings.moreText+'</a><ul class="'+settings.moreContainerClass+'"></ul></li>');
163						$menu.find('.' + settings.moreBtnClass).insertBefore($menu.find('[data-append="1"]').first());
164					};
165					$menu.find('[data-append="1"]').appendTo($menu.find('.' + settings.moreContainerClass));
166				};
167
168				return menuWdith;
169			});
170
171			$menu.find('li').removeAttr('data-append');
172
173			$menu.find('.' + settings.moreBtnClass).find('ul').parent().each(function() {
174	            var o = $(this);
175	            var s = o.find('>ul');
176	            var l = o.parents('ul').length;
177	            var k = false;
178	            o.hover(
179	                function() {
180	                    o.find('>a').addClass('active').removeClass('normal');
181	                    for (i=$menu.find('.' + settings.moreBtnClass).find('ul').length; i>=0; i--){
182	                        o.parent().find('>li').not(o).find('ul').eq(i).hide();
183	                    }
184	                    k = true;
185
186	                    s.show();
187
188	                    if ($(document).outerWidth()>$(window).outerWidth()) {
189	                    	o.find('>ul').addClass('row-right-level');
190	                    };
191	                },
192	                function() {
193	                    o.find('>a').removeClass('active').addClass('normal');
194	                    k = false;
195	                    window.setTimeout(function() {
196	                        if (!k) {
197	                        	s.hide()
198	                        	o.find('>ul').removeClass('row-right-level');                        
199	                        };
200	                    }, settings.moreHideTimeout);
201	                }
202	            );
203	        });
204		};
205
206		function resizeRowMenu() {
207			$menu.find('.' + settings.moreContainerClass).insertAfter($menu.find('.' + settings.moreBtnClass));
208			$menu.find('.' + settings.moreContainerClass + '> li').unwrap();
209			$menu.find('.' + settings.moreBtnClass).remove();
210
211			rowMenuInit();
212		};
213	});
214};

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.