PageSourceSearch

https://tyzdrowieuroda.pl/wp-content/plugins/medicor-core/assets/js/libs/mlpushmenu.js

js tyzdrowieuroda.pl collected 2026-09-27 05:21:02 UTC 10,313 bytes, 251 lines download raw bytes

1/**
2 * mlpushmenu.js v1.0.0
3 * http://www.codrops.com
4 *
5 * Licensed under the MIT license.
6 * http://www.opensource.org/licenses/mit-license.php
7 * 
8 * Copyright 2013, Codrops
9 * http://www.codrops.com
10 */
11;( function( window ) {
12	
13	'use strict';
14
15	function extend( a, b ) {
16		for( var key in b ) { 
17			if( b.hasOwnProperty( key ) ) {
18				a[key] = b[key];
19			}
20		}
21		return a;
22	}
23
24	// taken from https://github.com/inuyaksa/jquery.nicescroll/blob/master/jquery.nicescroll.js
25	function hasParent( e, id ) {
26		if (!e) return false;
27		var el = e.target||e.srcElement||e||false;
28		while (el && el.id != id) {
29			el = el.parentNode||false;
30		}
31		return (el!==false);
32	}
33
34	// returns the depth of the element "e" relative to element with id=id
35	// for this calculation only parents with classname = waypoint are considered
36	function getLevelDepth( e, id, waypoint, cnt ) {
37		cnt = cnt || 0;
38		if ( e.id.indexOf( id ) >= 0 ) return cnt;
39		if( classie.has( e, waypoint ) ) {
40			++cnt;
41		}
42		return e.parentNode && getLevelDepth( e.parentNode, id, waypoint, cnt );
43	}
44
45	// http://coveroverflow.com/a/11381730/989439
46	function mobilecheck() {
47		var check = false;
48		(function(a){if(/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true})(navigator.userAgent||navigator.vendor||window.opera);
49		return check;
50	}
51
52	// returns the closest element to 'e' that has class "classname"
53	function closest( e, classname ) {
54		if( classie.has( e, classname ) ) {
55			return e;
56		}
57		return e.parentNode && closest( e.parentNode, classname );
58	}
59
60	function mlPushMenu( el, trigger, options ) {	
61		this.el = el;
62		this.trigger = trigger;
63		this.options = extend( this.defaults, options );
64		// support 3d transforms
65		this.support = Modernizr.csstransforms3d;
66		if( this.support ) {
67			this._init();
68		}
69	}
70
71	mlPushMenu.prototype = {
72		defaults : {
73			// overlap: there will be a gap between open levels
74			// cover: the open levels will be on top of any previous open level
75			type : 'overlap', // overlap || cover
76			// space between each overlaped level
77			levelSpacing : 40,
78			// classname for the element (if any) that when clicked closes the current level
79			backClass : 'mp-back'
80		},
81		_init : function() {
82			// if menu is open or not
83			this.open = false;
84			// level depth
85			this.level = 0;
86			// the moving wrapper
87			this.wrapper = document.getElementById( 'mp-pusher' );
88			// the mp-level elements
89			this.levels = Array.prototype.slice.call( this.el.querySelectorAll( 'div.mp-level' ) );
90			// save the depth of each of these mp-level elements
91			var self = this;
92			this.levels.forEach( function( el, i ) { el.setAttribute( 'data-level', getLevelDepth( el, self.el.id, 'mp-level' ) ); } );
93			// the menu items
94			this.menuItems = Array.prototype.slice.call( this.el.querySelectorAll( 'li' ) );
95			// if type == "cover" these will serve as hooks to move back to the previous level
96			this.levelBack = Array.prototype.slice.call( this.el.querySelectorAll( '.' + this.options.backClass ) );
97			// event type (if mobile use touch events)
98			this.eventtype = mobilecheck() ? 'touchstart' : 'click';
99			// add the class mp-overlap or mp-cover to the main element depending on options.type
100			classie.add( this.el, 'mp-' + this.options.type );
101			// initialize / bind the necessary events
102			this._initEvents();
103		},
104		_initEvents : function() {
105			var self = this;
106
107			// the menu should close if clicking somewhere on the body
108			var bodyClickFn = function( el ) {
109				self._resetMenu();
110				el.removeEventListener( self.eventtype, bodyClickFn );
111			};
112
113			// open (or close) the menu
114			this.trigger.addEventListener( this.eventtype, function( ev ) {
115				ev.stopPropagation();
116				ev.preventDefault();
117				if( self.open ) {
118					self._resetMenu();
119				}
120				else {
121					self._openMenu();
122					// the menu should close if clicking somewhere on the body (excluding clicks on the menu)
123					document.addEventListener( self.eventtype, function( ev ) {
124						if( self.open && !hasParent( ev.target, self.el.id ) ) {
125							bodyClickFn( this );
126							self.trigger.classList.remove('elementor-active');
127							if(document.querySelector('.forcefullwidth_wrapper_tp_banner .rev_slider_wrapper') !== null) {
128                                document.querySelector('.forcefullwidth_wrapper_tp_banner .rev_slider_wrapper').style.left = "0";
129                            }
130
131						}
132					} );
133				}
134			} );
135
136			// opening a sub level menu
137			this.menuItems.forEach( function( el, i ) {
138				// check if it has a sub level
139				var subLevel = el.querySelector( 'div.mp-level' );
140				if( subLevel ) {
141					el.querySelector( 'a .trigger' ).addEventListener( self.eventtype, function( ev ) {
142						ev.preventDefault();
143						var level = closest( el, 'mp-level' ).getAttribute( 'data-level' );
144						if( self.level <= level ) {
145							ev.stopPropagation();
146							classie.add( closest( el, 'mp-level' ), 'mp-level-overlay' );
147							self._openMenu( subLevel );
148						}
149					} );
150				}
151			} );
152
153			// closing the sub levels :
154			// by clicking on the visible part of the level element
155			this.levels.forEach( function( el, i ) {
156				el.addEventListener( self.eventtype, function( ev ) {
157					ev.stopPropagation();
158					var level = el.getAttribute( 'data-level' );
159					if( self.level > level ) {
160						self.level = level;
161						self._closeMenu();
162					}
163				} );
164			} );
165
166			// by clicking on a specific element
167			this.levelBack.forEach( function( el, i ) {
168				el.addEventListener( self.eventtype, function( ev ) {
169					ev.preventDefault();
170					var level = closest( el, 'mp-level' ).getAttribute( 'data-level' );
171					if( self.level <= level ) {
172						ev.stopPropagation();
173						self.level = closest( el, 'mp-level' ).getAttribute( 'data-level' ) - 1;
174						self.level === 0 ? self._resetMenu() : self._closeMenu();
175					}
176				} );
177			} );	
178		},
179		_openMenu : function( subLevel ) {
180			// increment level depth
181			++this.level;
182			// move the main wrapper
183
184			var levelFactor = ( this.level - 1 ) * this.options.levelSpacing,
185				translateVal = this.options.type === 'overlap' ? this.el.offsetWidth + levelFactor : this.el.offsetWidth;
186            classie.add(this.el, 'mp-menu-active');
187            var body = document.body;
188            body.classList.add("overflow-hidden");
189
190
191			if( subLevel ) {
192				// reset transform for sublevel
193				this._setTransform( '', subLevel );
194				// need to reset the translate value for the level menus that have the same level depth and are not open
195				for( var i = 0, len = this.levels.length; i < len; ++i ) {
196					var levelEl = this.levels[i];
197					if( levelEl != subLevel && !classie.has( levelEl, 'mp-level-open' ) ) {
198						this._setTransform( 'translate3d(-100%,0,0) translate3d(' + -1*levelFactor + 'px,0,0)', levelEl );
199					}
200				}
201			}
202			// add class mp-pushed to main wrapper if opening the first time
203			if( this.level === 1 ) {
204				//classie.add( this.wrapper, 'mp-pushed' );
205				this.open = true;
206			}
207			// add class mp-level-open to the opening level element
208			classie.add( subLevel || this.levels[0], 'mp-level-open' );
209		},
210		// close the menu
211		_resetMenu : function() {
212
213			this.level = 0;
214			// remove class mp-pushed from main wrapper
215			//classie.remove( this.wrapper, 'mp-pushed' );
216			this._toggleLevels();
217			this.open = false;
218            classie.remove(this.el, 'mp-menu-active');
219            var body = document.body;
220            body.classList.remove("overflow-hidden");
221		},
222		// close sub menus
223		_closeMenu : function() {
224			var translateVal = this.options.type === 'overlap' ? this.el.offsetWidth + ( this.level - 1 ) * this.options.levelSpacing : this.el.offsetWidth;
225			this._toggleLevels();
226		},
227		// translate the el
228		_setTransform : function( val, el ) {
229			el.style.WebkitTransform = val;
230			el.style.MozTransform = val;
231			el.style.transform = val;
232		},
233		// removes classes mp-level-open from closing levels
234		_toggleLevels : function() {
235			for( var i = 0, len = this.levels.length; i < len; ++i ) {
236				var levelEl = this.levels[i];
237				if( levelEl.getAttribute( 'data-level' ) >= this.level + 1 ) {
238					classie.remove( levelEl, 'mp-level-open' );
239					classie.remove( levelEl, 'mp-level-overlay' );
240				}
241				else if( Number( levelEl.getAttribute( 'data-level' ) ) == this.level ) {
242					classie.remove( levelEl, 'mp-level-overlay' );
243				}
244			}
245		}
246	}
247
248	// add to global namespace
249	window.mlPushMenu = mlPushMenu;
250
251} )( window );

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.