PageSourceSearch

https://npo-ecofood.ru/local/js/menu/pushy/pushy.js?15230266886880

js npo-ecofood.ru collected 2026-10-10 02:26:29 UTC 6,880 bytes, 243 lines download raw bytes

1/*! Pushy - v1.0.0 - 2016-3-1
2* Pushy is a responsive off-canvas navigation menu using CSS transforms & transitions.
3* https://github.com/christophery/pushy/
4* by Christopher Yee */
5
6(function ($) {
7	var cssTransforms3d = (function csstransforms3d() {
8		var el = document.createElement('p'),
9		supported = false,
10		transforms = { 'webkitTransform':'-webkit-transform', 'OTransform':'-o-transform', 'msTransform':'-ms-transform', 'MozTransform':'-moz-transform', 'transform':'transform'};
11
12		if(document.body === null)
13			return false;
14
15		// Add it to the body to get the computed style
16		document.body.insertBefore(el, null);
17
18		for(var t in transforms)
19		if( el.style[t] !== undefined ) {
20			el.style[t] = 'translate3d(1px,1px,1px)';
21			supported = window.getComputedStyle(el).getPropertyValue(transforms[t]);
22		}
23
24		document.body.removeChild(el);
25
26		return (supported !== undefined && supported.length > 0 && supported !== "none");
27	})();
28	
29	var allMenu = [];
30	//close menu w/ esc key
31	$(document).keyup(function(e) {
32		var fmenu = (allMenu.length == 1) ? allMenu[0] : null;
33		//check if esc key is pressed
34		if (e.keyCode == 27) {
35			var i, n = allMenu.length;
36			for(i = 0; i < n; i++)
37				if(allMenu[i].isOpened())
38					allMenu[i].close();
39		}
40		else if (fmenu && (e.keyCode == 37)) { // left
41			if(fmenu.isLeft())
42				fmenu.isOpened() ? fmenu.close() : null;
43			//else
44			//	fmenu.isOpened() ? null : fmenu.open();
45		}
46		else if (fmenu && (e.keyCode == 39)) { // right
47			if(!fmenu.isLeft())
48			//	fmenu.isOpened() ? null : fmenu.open();
49			//else
50				fmenu.isOpened() ? fmenu.close() : null;
51		}
52	});
53
54	var body = $('body'),
55		siteOverlay = document.body.appendChild(document.createElement('div')),
56		tmpDiv = document.createElement('div'),
57		pushyLeft = 'pushy-left', //css class for left menu position
58		pushyOpenLeft = 'pushy-open-left', //css class when menu is open (left position)
59		pushyOpenRight = 'pushy-open-right', //css class when menu is open (right position)
60		container = $('.page-wrapper'), //container css class
61		menuSpeed = 200; //jQuery fallback menu speed
62	siteOverlay.className = 'site-overlay';
63	tmpDiv.style.display = 'none';
64	
65	var pushyMenu = function(node, params) {
66		this.node = node;
67		this.closeNode = null;
68		this.bOpened = false;
69		this.bHolded = false;
70		this.target = null;
71		this.params = $.sigma.getOpts(node, params, 'pm');
72		this.menuWidth = 0;
73	}
74	pushyMenu.prototype = {
75		init: function() {
76			var that = this, pos, targetId = '';
77			if(this.node.tagName.toLowerCase()=='a') {
78				targetId = this.node.href;
79				pos = targetId.indexOf('#');
80				if(pos >= 0)
81					targetId = targetId.substr(pos + 1);
82			}
83			else {
84				targetId = this.node.getAttribute('data-href');
85			}
86			if(targetId)
87				this.target = document.getElementById(targetId);
88				
89			if(!this.target) return;
90
91			if(cssTransforms3d) {
92				//make menu visible
93				this.target.style.visibility = 'visible';
94				$(this.target).bind(
95					'webkitTransitionEnd transitionend msTransitionEnd oTransitionEnd', 
96					function(e) { if(that.target == e.target) that.transitionEnd.apply(that); }
97				);
98			}
99			else {
100				//add css class to body
101				body.addClass('no-csstransforms3d');
102				this.menuWidth = this.target.offsetWidth;
103				
104				//hide menu by default
105				this.isLeft() ? 
106					(this.target.style.left = "-"+this.menuWidth+"px") :
107					(this.target.style.right = "-"+this.menuWidth+"px"); 
108
109				//make menu visible
110				this.target.style.visibility = 'visible';
111				//fixes IE scrollbar issue
112				container.css({"overflow-x": "hidden"});
113			}
114			
115			this.node.onclick = function() {
116				that.toggle();
117				return false;
118			}
119			siteOverlay.onclick = function() {
120				that.close();
121				return false;
122			}
123			
124			this.closeNode = this.target.appendChild(document.createElement('i'));
125			this.closeNode.className = 'pushy-btn-close';
126			this.closeNode.innerHTML = this.params.closeLabel;
127			this.closeNode.onclick = function() {
128				that.close();
129				return false;
130			}
131		},
132		toggle: function() {
133			this.bOpened ? this.close() : this.open();
134		},
135		isHolded: function(value) {
136			if(typeof value != 'undefined')
137				this.bHolded = !!value;
138			return this.bHolded;
139		},
140		isLeft: function() {
141			return (this.target.className.indexOf(pushyLeft)>=0);
142		},
143		isOpened: function() {
144			return this.bOpened;
145		},
146		open: function() {
147			var that = this;
148			if(this.isHolded()) return;
149			this.isHolded(true);
150			this.replaceTarget();
151			setTimeout(function() {
152				if(cssTransforms3d) {
153					that.isLeft() ? body.addClass(pushyOpenLeft) :
154						body.addClass(pushyOpenRight);
155				}
156				else
157					that.openFallback();
158			}, 10);
159		},
160		close: function() {
161			if(this.isHolded()) return;
162			this.isHolded(true);
163			if(cssTransforms3d) {
164				this.isLeft() ? body.removeClass(pushyOpenLeft) :
165					body.removeClass(pushyOpenRight);
166			}
167			else
168				this.closeFallback();
169		},
170		transitionEnd: function() { console.log(44);
171			if(this.bOpened)
172				this.replaceTarget();
173			this.bOpened = !this.bOpened;
174			this.isHolded(false);
175		},
176		replaceTarget: function() {
177			if(!this.bOpened) {
178				this.target.parentNode.insertBefore(tmpDiv, this.target);
179				document.body.appendChild(
180					this.target.parentNode.removeChild(this.target)
181				);
182				$(this.target).addClass('pushy-active');
183			}
184			else {
185				tmpDiv.parentNode.insertBefore(
186					this.target.parentNode.removeChild(this.target), 
187					tmpDiv
188				);
189				tmpDiv.parentNode.removeChild(tmpDiv);
190				$(this.target).removeClass('pushy-active');
191			}
192		},
193		openFallback: function() {
194			var that = this;
195			//animate menu position based on CSS class
196			if(this.isLeft()) {
197				body.addClass(pushyOpenLeft);
198				$(this.target).animate({left: 0}, menuSpeed);
199				container.animate({left: this.menuWidth}, menuSpeed, function() {
200					that.transitionEnd.apply();
201				});
202			}
203			else {
204				body.addClass(pushyOpenRight);
205				$(this.target).animate({right: 0}, menuSpeed);
206				container.animate({right: this.menuWidth}, menuSpeed, function() {
207					that.transitionEnd.apply();
208				});
209			}
210		},
211		closeFallback: function () {
212			var that = this;
213			//animate menu position based on CSS class
214			if(this.isLeft()) {
215				body.removeClass(pushyOpenLeft);
216				$(this.target).animate({left: "-" + this.menuWidth}, menuSpeed, function() {
217					that.transitionEnd.apply();
218				});
219				container.animate({left: 0}, this.menuSpeed);
220			}
221			else {
222				body.removeClass(pushyOpenRight);
223				$(this.target).animate({right: "-" + this.menuWidth}, menuSpeed, function() {
224					that.transitionEnd.apply();
225				});
226				container.animate({right: 0}, this.menuSpeed);
227			}
228		}
229	}
230
231	$.fn.pushy = function(params) 
232	{
233		var params = $.extend({}, {
234			closeLabel: 'Закрыть'
235		}, params);
236		
237		return this.each(function() {
238			var menu = new pushyMenu(this, params);
239			menu.init();
240			allMenu[allMenu.length] = menu;
241		});
242	}	
243}(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.