PageSourceSearch

https://www.snofalls.com/wp-content/plugins/responsive-menu-pro/v4…/assets/js/rmp-menu.js?ver=4.7.3.1789178234

js snofalls.com collected 2026-10-04 08:42:12 UTC 29,158 bytes, 913 lines download raw bytes

1/**
2 * This file contain the scrips for menu frontend.
3 * @author ExpressTech System
4 *
5 * @since 4.0.0
6 */
7
8jQuery( document ).ready( function( jQuery ) {
9
10	/**
11	 * RmpMenu Class
12	 * This RMP class is handling the frontend events and action on menu elements.
13	 * @since      4.0.0
14	 * @access     public
15	 *
16	 * @class      RmpMenu
17	 */
18	class RmpMenu {
19
20		/**
21		 * This is constructor function which is initialize the elements and options.
22		 * @access public
23		 * @since 4.0.0
24		 * @param {Array} options List of options.
25		 */
26		constructor( options ) {
27			RmpMenu.activeToggleClass        = 'is-active';
28			RmpMenu.openContainerClass       = 'rmp-menu-open';
29			RmpMenu.activeSubMenuArrowClass  = 'rmp-menu-subarrow-active';
30			RmpMenu.subMenuClass             = '.rmp-submenu';
31			RmpMenu.activeTopMenuClass = 'rmp-topmenu-active';
32
33			this.options = options;
34			this.menuId  = this.options['menu_id'];
35			this.trigger = '#rmp_menu_trigger-' + this.menuId;
36
37			this.isOpen  = false;
38
39			this.container    =  '#rmp-container-' + this.menuId;
40			this.headerBar    =  '#rmp-header-bar-' + this.menuId;
41			this.menuWrap     =  'ul#rmp-menu-'+ this.menuId;
42			this.pageOverlay  =  '#rmp-page-overlay-' + this.menuId;
43			this.subMenuArrow = '.rmp-menu-subarrow';
44			this.wrapper      = '.rmp-container';
45			this.linkElement  = '.rmp-menu-item-link';
46			this.pageWrapper  = this.options['page_wrapper'];
47			this.use_desktop_menu = this.options['use_desktop_menu'];
48			this.originalHeight = '',
49			this.animationSpeed        =  this.options['animation_speed'] * 1000;
50			this.hamburgerBreakpoint   =  this.options['tablet_breakpoint'];
51			this.subMenuTransitionTime =  this.options['sub_menu_speed'] * 1000;
52			this.smoothScrollSpeed     = this.options['smooth_scroll_speed'] * 1000;
53
54			if ( this.options['button_click_trigger'].length > 0 ) {
55				this.trigger = this.trigger +' , '+ this.options['button_click_trigger'];
56			}
57
58			//Append hamburger icon inside an element
59			if ( this.options['button_position_type'] == 'inside-element' ) {
60				var destination = jQuery(this.trigger).attr('data-destination');
61				jQuery(this.trigger).appendTo(jQuery(destination).parent());
62			}
63
64			this.init();
65		}
66
67		/**
68		 * Function to smooth scroll.
69		 * @param {Event} event
70		 */
71		smoothScrollToLocation( event ) {
72			if(event.target.hash) {
73				jQuery('html, body').animate({
74					scrollTop: jQuery(event.target.hash).offset().top
75				}, 500);
76			}
77		}
78
79		/**
80		 * This function register the events and initiate the menu settings.
81		 */
82		init() {
83			const self = this;
84
85			// If option is enable from Toggle Button > others >  Toggle menu on click.
86			if (  'on' == this.options['button_trigger_type_click'] ) {
87
88				/**
89				 * Register click event of trigger.
90				 * @fires click
91				 */
92				jQuery( this.trigger ).on( 'click', function( e ) {
93					e.stopPropagation();
94					self.triggerMenu();
95				} );
96			}
97
98			// If option is enable from Toggle Button > others >  Toggle menu on hover.
99			if ( 'on' == this.options['button_trigger_type_hover'] ) {
100
101				/**
102				 * Register mouseover event of trigger.
103				 * @fires mouseover
104				 */
105				jQuery( this.trigger ).on( 'mouseover', function( e ) {
106					e.stopPropagation();
107					self.triggerMenu();
108				} );
109			}
110
111			// Show/Hide sub menu item when click on item toggle.
112			jQuery( self.menuWrap ).find( self.subMenuArrow ).on( 'click', function( e ) {
113				e.preventDefault();
114				e.stopPropagation();
115				self.triggerSubArrow( this );
116			});
117
118			if ( 'on' == self.options['menu_close_on_body_click'] ) {
119				jQuery( document ).on( 'click', 'body', function ( e ) {
120					if ( jQuery( window ).width() < self.hamburgerBreakpoint ) {
121						if ( self.isOpen ) {
122							if ( jQuery( e.target ).closest( self.container ).length || jQuery( e.target ).closest( self.target ).length ) {
123								return;
124							}
125						}
126						self.closeMenu();
127					}
128				});
129			}
130
131			if ( 'on'  == self.options['menu_close_on_scroll'] ) {
132				jQuery( window ).scroll( function( e ) {
133					if ( jQuery( window ).width() < self.hamburgerBreakpoint ) {
134						const menuSearchBox = jQuery( '.rmp-search-box' );
135
136						// If focus is on search-box then menu will not be close.
137						if ( menuSearchBox && menuSearchBox.is( ':focus' ) ) {
138							return;
139						} else if ( self.isOpen ) {
140							self.closeMenu();
141						}
142					}
143				} );
144			}
145
146			jQuery(document).on('keydown', function (event) {
147				let menuOpen = jQuery('.rmp-container.rmp-menu-open');
148				if (menuOpen.length) {
149					let activeMenu = menuOpen.find('.rmp-selected-menu-item').length ? menuOpen.find('.rmp-selected-menu-item') : menuOpen.find('.rmp-menu-current-item');
150					let parentContainer = jQuery('.rmp-container.rmp-menu-open');
151					let menuItems = menuOpen.find('.rmp-menu-item');
152
153					if (event.keyCode === 9) {
154						menuItems.removeClass('rmp-selected-menu-item');
155						if (activeMenu.length) {
156							if (activeMenu.hasClass('rmp-menu-item-has-children')) {
157								activeMenu.children('.rmp-menu-item-link').first().find('.rmp-menu-subarrow').click();
158								let firstChild = activeMenu.find('.rmp-submenu').children('.rmp-menu-item').first();
159								firstChild.addClass('rmp-selected-menu-item').children('.rmp-menu-item-link').first().focus();
160							} else {
161								let nextMenu = activeMenu.next('.rmp-menu-item');
162								if (nextMenu.length) {
163									nextMenu.addClass('rmp-selected-menu-item').children('.rmp-menu-item-link').first().focus();
164								} else {
165									let parentSubmenu = activeMenu.closest('.rmp-submenu');
166									if (parentSubmenu.length) {
167										let parentMenu = parentSubmenu.closest('.rmp-menu-item');
168										let nextSibling = parentMenu.next('.rmp-menu-item');
169										parentMenu.children('.rmp-menu-item-link').first().find('.rmp-menu-subarrow').click();
170										if (nextSibling.length) {
171											nextSibling.addClass('rmp-selected-menu-item').children('.rmp-menu-item-link').first().focus();
172										} else {
173											let parentSibling = parentMenu.closest('.rmp-submenu').closest('.rmp-menu-item').next('.rmp-menu-item');
174											if (parentSibling.length) {
175												parentSibling.find('.rmp-menu-item-link').addClass('rmp-selected-menu-item').children('.rmp-menu-item-link').first().focus();
176											} else {
177												parentContainer.find('.rmp-menu-item').first().addClass('rmp-selected-menu-item').children('.rmp-menu-item-link').first().focus();
178											}
179										}
180									} else {
181										parentContainer.find('.rmp-menu-item').first().addClass('rmp-selected-menu-item').children('.rmp-menu-item-link').first().focus();
182									}
183								}
184							}
185						} else {
186							menuItems.first().addClass('rmp-selected-menu-item').children('.rmp-menu-item-link').first().focus();
187						}
188						event.preventDefault();
189					}
190
191					if (event.keyCode === 13 && activeMenu.length) {
192						activeMenu.click();
193					}
194				}
195			});
196
197			/**
198			 * This scripts enable the touch gestures.
199			 */
200			if ( self.options['enable_touch_gestures'] == 'on' ) {
201
202				// Close menu touch gestures.
203				let close_gesture = self.options['menu_appear_from'];
204
205				if ( self.options['menu_appear_from'] == 'top' ) {
206					close_gesture = 'up';
207				} else if ( self.options['menu_appear_from'] == 'bottom' ) {
208					close_gesture = 'down';
209				}
210
211				let pageScroll = "horizontal";
212				if ( close_gesture == 'left' || close_gesture == 'right' ) {
213					pageScroll = "vertical";
214				}
215
216				jQuery( self.container ).swipe( {
217					swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
218						if( jQuery(window).width() < self.hamburgerBreakpoint ) {
219							if ( direction == close_gesture ) {
220								self.closeMenu();
221							}
222						}
223					},
224					threshold: 25,
225					allowPageScroll : pageScroll,
226					excludedElements: "button, input, select, textarea, a, .noSwipe, .rmp-search-box"
227				} );
228			}
229
230			/**
231			 * Close the menu when click on menu item link before load.
232			 */
233			if ( self.options['menu_close_on_link_click'] == 'on') {
234
235				jQuery( this.menuWrap +' '+ self.linkElement ).on( 'click', function(e) {
236
237					if( jQuery(window).width() < self.hamburgerBreakpoint ) {
238						e.preventDefault();
239
240						// When close menu on parent clicks is on.
241						if ( self.options['menu_item_click_to_trigger_submenu'] == 'on' ) {
242							if( jQuery(this).is( '.rmp-menu-item-has-children > ' + self.linkElement ) ) {
243								return;
244							}
245						}
246
247						let _href = jQuery(this).attr('href');
248						let _target = ( typeof jQuery(this).attr('target') ) == 'undefined' ? '_self' : jQuery(this).attr('target');
249
250						if( self.isOpen ) {
251							if( jQuery(e.target).closest(this.subMenuArrow).length) {
252								return;
253							}
254							if( typeof _href != 'undefined' ) {
255								self.closeMenu();
256								setTimeout(function() {
257									window.open( _href, _target);
258								}, self.animationSpeed);
259							}
260						}
261					}
262				});
263			}
264
265			/** Multi screen slide effect */
266			if ( self.options['use_slide_effect'] == 'on' ) {
267				jQuery( '.rmp-go-back' ).on( 'click', function() {
268					self.backUpSlide(this);
269				});
270			}
271
272			//Show menu on page load section.
273			if ( 'on' == self.options['show_menu_on_page_load'] ) {
274				if ( jQuery(window).width() < self.hamburgerBreakpoint ) {
275					self.openMenu();
276				}
277			}
278
279			// Keyboard shortcut menu open/close.
280			jQuery(document).on( 'keyup', function(e) {
281				if ( jQuery(window).width() < self.hamburgerBreakpoint ) {
282					let pressedKeyCode = e.keyCode.toString();
283					let openKeyCodes   = self.options['keyboard_shortcut_open_menu'];
284					let closeKeyCodes  = self.options['keyboard_shortcut_close_menu'];
285
286					if ( jQuery.isArray( openKeyCodes ) &&  jQuery.inArray( pressedKeyCode, openKeyCodes ) !== -1 && ! self.isOpen ) {
287						self.openMenu();
288					} else if ( jQuery.isArray( closeKeyCodes ) && jQuery.inArray( pressedKeyCode, closeKeyCodes ) !== -1 && self.isOpen ) {
289						self.closeMenu();
290					}
291				}
292			});
293
294			// Expand Sub items on Parent Item Click.
295			if ( 'on' == self.options['menu_item_click_to_trigger_submenu']  ) {
296				jQuery( this.menuWrap +' .rmp-menu-item-has-children > ' + self.linkElement ).on( 'click', function(e) {
297					if ( jQuery(window).width() < self.hamburgerBreakpoint ) {
298						e.preventDefault();
299						self.triggerSubArrow(
300							jQuery(this).children( '.rmp-menu-subarrow' ).first()
301						);
302					}
303				});
304			}
305
306			//Smooth scrolling enable.
307			if ( self.options['smooth_scroll_on'] == 'on' ) {
308				jQuery( this.menuWrap +' '+ self.linkElement).on( 'click', function(e) {
309					self.smoothScrollToLocation(e);
310				});
311			}
312
313			//Open submenu on click.
314			if ( self.options[ 'desktop_submenu_open_on_click' ] == 'on' ) {
315
316				jQuery( self.menuWrap + ' li.rmp-menu-item-has-children a.rmp-menu-item-link' ).on( 'click', function( e ) {
317
318					if ( jQuery(window).width() > self.hamburgerBreakpoint ) {
319						e.stopPropagation();
320						e.preventDefault();
321						e.stopImmediatePropagation();
322						var submenu = jQuery(this).siblings('.rmp-submenu');
323						if ( ! submenu.length || jQuery(this).attr( 'data-click') ) {
324							window.location = this.href;
325						} else {
326							jQuery(this).attr( 'data-click', true );
327							submenu.addClass( 'rmp-submenu-animate-on' );
328							submenu.show();
329							return false;
330						}
331					}
332
333				});
334			}
335
336			/* Desktop menu : Hide on scroll down / Show on scroll Up */
337			if ( self.options['use_desktop_menu'] == 'on' && self.options['desktop_menu_hide_and_show'] == 'on' ) {
338				var lastScrollTop, currentScrollPos = 0;
339				var desktop_header = jQuery(self.container);
340
341				if ( self.options['use_header_bar'] == 'on') {
342					desktop_header = jQuery(self.headerBar);
343				}
344
345				jQuery( window ).scroll( function () {
346
347					if ( jQuery(window).width() > self.hamburgerBreakpoint ) {
348						var desktop_header_height = desktop_header.height();
349						currentScrollPos = jQuery(window).scrollTop();
350						if ( lastScrollTop < currentScrollPos && currentScrollPos > desktop_header_height) {
351							desktop_header.fadeOut(100);
352							desktop_header.css({
353								'transform' : 'translateY( -'+ desktop_header_height +'px )'
354							});
355						} else {
356							desktop_header.fadeIn(100);
357							desktop_header.css( { 'transform' : '' } );
358						}
359
360						lastScrollTop = currentScrollPos;
361					}
362				});
363			}
364
365			// Change the color of header on scrolling.
366			if ( 'on' == self.options['use_header_bar'] && 'on' == self.options['header_bar_scroll_enable'] ) {
367				jQuery( window ).scroll( function () {
368					const headerBar = jQuery( self.headerBar );
369					if ( jQuery(window).scrollTop() > headerBar.height() ) {
370						headerBar.addClass('header-scolling-bg-color');
371					} else {
372						headerBar.removeClass('header-scolling-bg-color');
373					}
374				});
375			}
376
377			// Add rmp-topmenu-active class to current menu item on load
378			this.setActiveMenuItemOnLoad();
379
380			// Initialize Mini Cart Drawer and cart updates
381			this.initMiniCartDrawer();
382			this.initMiniCartUpdates();
383
384		}
385
386		/**
387		 * Initialize Mini Cart Drawer events
388		 */
389		initMiniCartDrawer() {
390			const self = this;
391			const triggerSelector = this.container + ' .rmp-mini-cart-drawer-trigger, ' + this.headerBar + ' .rmp-mini-cart-drawer-trigger';
392
393			jQuery(document).on('click', triggerSelector, function(e) {
394				e.preventDefault();
395				e.stopPropagation();
396				const wrapper = jQuery(this).closest('.rmp-woocommerce-mini-cart--drawer');
397				const menuId  = wrapper.data('rmp-menu-id');
398				const context = wrapper.data('rmp-context');
399				const drawer  = jQuery('.rmp-mini-cart-drawer[data-rmp-menu-id="' + menuId + '"][data-rmp-context="' + context + '"]');
400				
401				if (drawer.length) {
402					// Close other drawers first
403					jQuery('.rmp-mini-cart-drawer').removeClass('rmp-mini-cart-drawer-open');
404					
405					drawer.addClass('rmp-mini-cart-drawer-open');
406					jQuery('body').addClass('rmp-mini-cart-drawer-active');
407					
408					if ( jQuery('.rmp-mini-cart-overlay').length === 0 ) {
409						jQuery('body').append('<div class="rmp-mini-cart-overlay"></div>');
410					}
411					// Small delay to allow transition
412					setTimeout(function(){
413						jQuery('.rmp-mini-cart-overlay').addClass('rmp-mini-cart-overlay-open');
414					}, 10);
415				}
416			});
417
418			// Close events - ensure we don't bind multiple times
419			if (!window.rmpMiniCartEventsBound) {
420				jQuery(document).on('click', '.rmp-mini-cart-drawer-close, .rmp-mini-cart-overlay', function(e) {
421					e.preventDefault();
422					jQuery('.rmp-mini-cart-drawer').removeClass('rmp-mini-cart-drawer-open');
423					jQuery('body').removeClass('rmp-mini-cart-drawer-active');
424					jQuery('.rmp-mini-cart-overlay').removeClass('rmp-mini-cart-overlay-open');
425				});
426				window.rmpMiniCartEventsBound = true;
427			}
428
429			this.attachMiniCartDrawers();
430		}
431
432		initMiniCartUpdates() {
433			const self = this;
434			const eventNamespace = '.rmpMiniCart' + self.menuId;
435
436			jQuery( document.body )
437				.off( 'added_to_cart' + eventNamespace + ' removed_from_cart' + eventNamespace )
438				.on( 'added_to_cart' + eventNamespace + ' removed_from_cart' + eventNamespace, function( event, fragments ) {
439					if ( ! self.applyMiniCartFragments( fragments ) ) {
440						self.requestMiniCartRefresh();
441					}
442				} );
443
444			jQuery( document.body )
445				.off( 'updated_wc_div' + eventNamespace + ' updated_cart_totals' + eventNamespace )
446				.on( 'updated_wc_div' + eventNamespace + ' updated_cart_totals' + eventNamespace, function() {
447					self.scheduleMiniCartRefresh();
448				} );
449
450			jQuery( document.body )
451				.off( 'wc_fragments_loaded' + eventNamespace + ' wc_fragments_refreshed' + eventNamespace )
452				.on( 'wc_fragments_loaded' + eventNamespace + ' wc_fragments_refreshed' + eventNamespace, function() {
453					self.attachMiniCartDrawers();
454				} );
455
456			jQuery( document )
457				.off( 'click' + eventNamespace, '.rmp-mini-cart-item-remove .remove' )
458				.on( 'click' + eventNamespace, '.rmp-mini-cart-item-remove .remove', function() {
459					setTimeout( function() {
460						self.requestMiniCartRefresh();
461					}, 300 );
462				} );
463
464			jQuery( document )
465				.off( 'click' + eventNamespace, '.add_to_cart_button, .single_add_to_cart_button' )
466				.on( 'click' + eventNamespace, '.add_to_cart_button, .single_add_to_cart_button', function() {
467					self.scheduleMiniCartRefresh();
468				} );
469
470			jQuery( document )
471				.off( 'submit' + eventNamespace, 'form.cart' )
472				.on( 'submit' + eventNamespace, 'form.cart', function() {
473					self.scheduleMiniCartRefresh();
474				} );
475		}
476
477		attachMiniCartDrawers() {
478			const self = this;
479			const seenContexts = {};
480
481			jQuery('.rmp-mini-cart-drawer[data-rmp-menu-id="' + self.menuId + '"]').each(function() {
482				const drawer = jQuery(this);
483				const context = drawer.data('rmp-context') || 'mobile';
484
485				if ( seenContexts[context] ) {
486					drawer.remove();
487					return;
488				}
489
490				seenContexts[context] = true;
491
492				if (!drawer.parent().is('body')) {
493					drawer.appendTo('body');
494				}
495			});
496		}
497
498		getMiniCartDrawerSelector( context ) {
499			return '.rmp-mini-cart-drawer[data-rmp-menu-id="' + this.menuId + '"][data-rmp-context="' + context + '"]';
500		}
501
502		getMiniCartContexts() {
503			return [ 'header', 'mobile', 'desktop' ];
504		}
505
506		applyMiniCartFragments( fragments ) {
507			const self = this;
508			let updated = false;
509
510			if ( ! fragments ) {
511				return false;
512			}
513
514			jQuery.each( self.getMiniCartContexts(), function( index, context ) {
515				const selector = '#rmp-mini-cart-' + self.menuId + '-' + context;
516				const target = jQuery( selector );
517
518				if ( ! target.length || ! fragments[ selector ] ) {
519					return;
520				}
521
522				jQuery( self.getMiniCartDrawerSelector( context ) ).remove();
523				target.replaceWith( fragments[ selector ] );
524				updated = true;
525			} );
526
527			if ( updated ) {
528				self.attachMiniCartDrawers();
529			}
530
531			return updated;
532		}
533
534		scheduleMiniCartRefresh() {
535			const self = this;
536			const delays = [ 600, 1400, 2800 ];
537
538			if ( self.miniCartRefreshTimers ) {
539				jQuery.each( self.miniCartRefreshTimers, function( index, timer ) {
540					clearTimeout( timer );
541				} );
542			}
543
544			self.miniCartRefreshTimers = jQuery.map( delays, function( delay ) {
545				return setTimeout( function() {
546					self.requestMiniCartRefresh();
547				}, delay );
548			} );
549		}
550
551		requestMiniCartRefresh() {
552			if ( typeof wc_cart_fragments_params !== 'undefined' ) {
553				jQuery( document.body ).trigger( 'wc_fragment_refresh' );
554				return;
555			}
556
557			this.refreshMiniCart();
558		}
559
560		refreshMiniCart() {
561			const self = this;
562			const contexts = self.getMiniCartContexts();
563
564			if ( typeof rmp_menu === 'undefined' || ! rmp_menu.ajaxURL ) {
565				return;
566			}
567
568			jQuery.each( contexts, function( index, context ) {
569				const selector = '#rmp-mini-cart-' + self.menuId + '-' + context;
570				const target   = jQuery( selector );
571
572				if ( ! target.length ) {
573					return;
574				}
575
576				jQuery.post(
577					rmp_menu.ajaxURL,
578					{
579						action: 'rmp_get_mini_cart',
580						ajax_nonce: rmp_menu.wp_nonce,
581						menu_id: self.menuId,
582						context: context,
583					},
584					function( response ) {
585						if ( response && response.success && response.data && response.data.html ) {
586							jQuery( self.getMiniCartDrawerSelector( context ) ).remove();
587							target.replaceWith( response.data.html );
588							self.attachMiniCartDrawers();
589						}
590					}
591				);
592			} );
593		}
594
595		// Add rmp-topmenu-active class to current menu item on load
596		setActiveMenuItemOnLoad() {
597			const currentURL = window.location.href;
598			const menuItems = jQuery(this.menuWrap).find('a');
599
600			menuItems.each(function() {
601				if (this.href === currentURL) {
602					jQuery(this).closest('.rmp-menu-item-has-children').addClass(RmpMenu.activeTopMenuClass);
603					return false; // Exit the loop once we've found and marked the current item
604				}
605			});
606		}
607
608		/**
609		 * Set push translate for toggle and page wrapper.
610		 */
611		setWrapperTranslate() {
612
613			let translate,translateContainer;
614			switch( this.options['menu_appear_from'] ) {
615				case 'left':
616					translate = 'translateX(' + this.menuWidth() + 'px)';
617					translateContainer = 'translateX(-' + this.menuWidth() + 'px)';
618					break;
619				case 'right':
620					translate = 'translateX(-' + this.menuWidth() + 'px)';
621					translateContainer = 'translateX(' + this.menuWidth() + 'px)';
622					break;
623				case 'top':
624					translate = 'translateY(' + this.wrapperHeight() + 'px)';
625					translateContainer = 'translateY(-' + this.menuHeight() + 'px)';
626					break;
627				case 'bottom':
628					translate = 'translateY(-' + this.menuHeight() + 'px)';
629					translateContainer = 'translateY(' + this.menuHeight() + 'px)';
630					break;
631			}
632
633			if ( this.options['animation_type'] == 'push' ) {
634
635				jQuery(this.pageWrapper).css( { 'transform':translate } );
636
637				//If push Wrapper has body element then handle menu position.
638				if	( 'body' == this.pageWrapper ) {
639					jQuery( this.container ).css( { 'transform' : translateContainer } );
640				}
641			}
642
643			if ( this.options['button_push_with_animation'] == 'on' ) {
644				jQuery( this.trigger ).css( { 'transform' : translate } );
645			}
646
647		}
648
649		/**
650		 * Clear push translate on button and page wrapper.
651		 */
652		clearWrapperTranslate() {
653
654			if ( this.options['animation_type'] == 'push' ) {
655				jQuery(this.pageWrapper).css( { 'transform' : '' } );
656			}
657
658			if ( this.options['button_push_with_animation'] == 'on' ) {
659				jQuery( this.trigger ).css( { 'transform' : '' } );
660			}
661		}
662
663		/**
664		 * Function to fadeIn the hamburger menu container.
665		 */
666		fadeMenuIn() {
667			jQuery(this.container).fadeIn(this.animationSpeed);
668		}
669
670		/**
671		 * Function to fadeOut the hamburger menu container.
672		 */
673		fadeMenuOut() {
674			jQuery(this.container)
675				.fadeOut(this.animationSpeed, function() {
676					jQuery(this).css('display', '');
677				});
678		}
679
680		/**
681		 * Function is use to open the hamburger menu.
682		 *
683		 * @since 4.0.0
684		 */
685		openMenu() {
686			var self = this;
687			jQuery(this.trigger).addClass(RmpMenu.activeToggleClass);
688			jQuery(this.container).addClass(RmpMenu.openContainerClass);
689
690			if ( this.options['menu_overlay'] == 'on') {
691				jQuery(this.pageOverlay).addClass(RmpMenu.activeToggleClass);
692			}
693
694			//this.pushMenuTrigger();
695
696			if ( this.options['animation_type'] == 'fade'){
697				this.fadeMenuIn();
698			} else {
699				this.setWrapperTranslate();
700			}
701
702			/**
703			 * Fading items from slid.
704			 */
705			if ( self.options['fade_submenus'] == 'on' ) {
706
707				jQuery( ".rmp-menu > li" ).each( function(index) {
708					jQuery(this).show();
709					jQuery(this).animate( { opacity: 0 }, 0 );
710
711					if ( self.options['fade_submenus_side'] == 'left' ) {
712						jQuery(this).animate( { 'margin-left':'-150px' } ,0 );
713					}
714
715					if ( self.options['fade_submenus_side'] == 'right' ) {
716						jQuery(this).animate({'margin-left':'150px'},0);
717					}
718
719					jQuery( this ).delay( self.options[ 'fade_submenus_delay' ] * index ).animate({
720						'margin-left': "0",
721						'opacity': 1
722					}, self.options['fade_submenus_delay'] );
723				});
724			}
725
726
727			if ( self.options['use_slide_effect'] == 'on' ) {
728				if( jQuery(window).width() <= self.hamburgerBreakpoint ) {
729					jQuery( self.menuWrap ).promise().done( function () {
730						self.originalHeight = jQuery( self.menuWrap ).height();
731						jQuery( self.menuWrap ).css({'height': self.originalHeight});
732					});
733				}
734			}
735
736			// Disable the background scrolling.
737			if ( 'on' == self.options['menu_disable_scrolling'] ) {
738				jQuery('body').css('overflow','hidden');
739			}
740
741			this.isOpen = true;
742		}
743
744		/**
745		 * Function is use to close the hamburger menu.
746		 *
747		 * @since 4.0.0
748		 */
749		closeMenu() {
750			jQuery(this.trigger).removeClass(RmpMenu.activeToggleClass);
751			jQuery(this.container).removeClass(RmpMenu.openContainerClass);
752
753			if ( this.options['menu_overlay'] == 'on') {
754				jQuery(this.pageOverlay).removeClass(RmpMenu.activeToggleClass);
755			}
756
757			if ( this.options['animation_type'] == 'fade') {
758				this.fadeMenuOut();
759			} else {
760				this.clearWrapperTranslate();
761			}
762
763			// Release the blocking scrolling.
764			if ( 'on' == this.options['menu_disable_scrolling'] ) {
765				jQuery('body').css('overflow','auto');
766			}
767
768			this.isOpen = false;
769		}
770
771		/**
772		 * Function is responsible for checking the menu is open or close.
773		 *
774		 * @since 4.0.0
775		 * @param {Event} e
776		 */
777		triggerMenu() {
778			this.isOpen ? this.closeMenu() : this.openMenu();
779		}
780
781		triggerSubArrow( subArrow ) {
782			var self = this;
783			var sub_menu = jQuery( subArrow ).parent().siblings( RmpMenu.subMenuClass );
784
785
786			// Use sliding effect.
787			if ( self.options['use_slide_effect'] == 'on' ) {
788				if( jQuery(window).width() <= self.hamburgerBreakpoint ) {
789					jQuery(self.container).find( '.rmp-submenu-open').removeClass('rmp-submenu-open');
790					sub_menu.addClass('rmp-submenu-open');
791					sub_menu.parentsUntil(self.menuWrap).addClass( 'rmp-submenu-open' );
792					let current_depth = jQuery(subArrow).parents('.rmp-submenu').data('depth');
793					current_depth = typeof current_depth == 'undefined' ? 1 : current_depth;
794					let translation_amount = current_depth * 100;
795					jQuery(self.menuWrap).css({'transform': 'translateX(-' + translation_amount + '%)'});
796					jQuery(self.menuWrap).css({'height': sub_menu.height() + 'px'});
797				}
798			} else {
799
800				//Accordion animation.
801				if ( self.options['accordion_animation'] == 'on' ) {
802					// Get Top Most Parent and the siblings.
803					var top_siblings   = sub_menu.parents('.rmp-menu-item-has-children').last().siblings('.rmp-menu-item-has-children');
804					var first_siblings = sub_menu.parents('.rmp-menu-item-has-children').first().siblings('.rmp-menu-item-has-children');
805
806					// Close up just the top level parents to key the rest as it was.
807					top_siblings.children('.rmp-submenu').slideUp(self.subMenuTransitionTime, 'linear').removeClass('rmp-submenu-open');
808
809					// Set each parent arrow to inactive.
810					top_siblings.each(function() {
811						jQuery(this).find(self.subMenuArrow).first().html(self.options['inactive_toggle_contents']);
812						jQuery(this).find(self.subMenuArrow).first().removeClass(RmpMenu.activeSubMenuArrowClass);
813					});
814
815					// Now Repeat for the current item siblings.
816					first_siblings.children('.rmp-submenu').slideUp(self.subMenuTransitionTime, 'linear').removeClass('rmp-submenu-open');
817					first_siblings.each(function() {
818						jQuery(this).find(self.subMenuArrow).first().html(self.options['inactive_toggle_contents']);
819						jQuery(this).find(self.subMenuArrow).first().removeClass(RmpMenu.activeSubMenuArrowClass);
820					});
821				}
822
823				// Active sub menu as default behavior.
824				if( sub_menu.hasClass('rmp-submenu-open') ) {
825					sub_menu.slideUp(self.subMenuTransitionTime, 'linear',function() {
826						jQuery(this).css( 'display', '' );
827					} ).removeClass('rmp-submenu-open');
828					jQuery( subArrow ).html( self.options['inactive_toggle_contents'] );
829					jQuery(subArrow).removeClass(RmpMenu.activeSubMenuArrowClass);
830				} else {
831					sub_menu.slideDown(self.subMenuTransitionTime, 'linear').addClass( 'rmp-submenu-open' );
832					jQuery( subArrow ).html(self.options['active_toggle_contents'] );
833					jQuery(subArrow).addClass(RmpMenu.activeSubMenuArrowClass);
834				}
835			}
836		}
837
838		/**
839		 * Function to add tranform style on trigger.
840		 *
841		 * @version 4.0.0
842		 *
843		 * @param {Event} e Event object.
844		 */
845		pushMenuTrigger( e ) {
846			if ( 'on' == this.options['button_push_with_animation'] ) {
847				jQuery( this.trigger ).css( { 'transform' : this.menuWidth() } );
848			}
849		}
850
851		/**
852		 * Returns the height of container.
853		 *
854		 * @version 4.0.0
855		 *
856		 * @return Number
857		 */
858		menuHeight() {
859			return jQuery( this.container ).height();
860		}
861
862		/**
863		 * Returns the width of the container.
864		 *
865		 * @version 4.0.0
866		 *
867		 * @return Number
868		 */
869		menuWidth() {
870			return jQuery( this.container ).width();
871		}
872
873		wrapperHeight() {
874			return jQuery( this.wrapper ).height();
875		}
876
877		backUpSlide( backButton ) {
878			let translateTo = parseInt( jQuery( this.menuWrap )[0].style.transform.replace( /^\D+/g, '' ) ) - 100;
879			jQuery( this.menuWrap ).css( { 'transform': 'translateX(-' + translateTo + '%)' } );
880			let previousSubmenuHeight = jQuery( backButton ).parent( 'ul' ).parent( 'li' ).parent( '.rmp-submenu' ).height();
881			if ( ! previousSubmenuHeight ) {
882				jQuery( this.menuWrap ).css( { 'height': this.originalHeight } );
883			} else {
884				jQuery( this.menuWrap + this.menuId ).css( { 'height': previousSubmenuHeight + 'px' } );
885			}
886		}
887	}
888
889	/**
890	 * Create multiple instance of menu and pass the options.
891	 *
892	 * @version 4.0.0
893	 */
894	for ( let index = 0; index < rmp_menu.menu.length; index++ ) {
895		let rmp = new RmpMenu( rmp_menu.menu[index] );
896	}
897
898	// Twenty twenty theme support.
899	if ( typeof twentytwenty != 'undefined' ) {
900		jQuery( 'header#site-header' ).find('ul.primary-menu').removeClass('primary-menu');
901	}
902
903	jQuery('.rmp-mega-menu-container').each( function(){
904		var menu_position = jQuery(this).parent().offset();
905		var mega_menu_right_position = jQuery('body').width() - menu_position.left;
906		var mega_menu_width = jQuery(this).width();
907		if( jQuery(window).width() > rmp_menu.menu[0].tablet_breakpoint && mega_menu_width > mega_menu_right_position){
908			var mega_menu_position = mega_menu_width - mega_menu_right_position;
909			jQuery(this).css('margin-left', '-'+mega_menu_position+'px');
910		}
911	});
912
913});

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.