PageSourceSearch

https://townofelsmere.com/wp-content/plugins/wp-responsive-menu/assets/js/wprmenu.js?ver=1783699961

js townofelsmere.com collected 2026-10-01 16:17:15 UTC 10,210 bytes, 359 lines download raw bytes

1( function( window ) {
2
3'use strict';
4
5function classReg( className ) {
6  return new  ("(^|\\s+)" + className + "(\\s+|$)");
7}
8// classList support for class management
9// although to be fair, the api sucks because it won't accept multiple classes at once
10var hasClass, addClass, removeClass;
11
12if ( 'classList' in document.documentElement ) {
13  hasClass = function( elem, c ) {
14    return elem.classList.contains( c );
15  };
16  addClass = function( elem, c ) {
17    elem.classList.add( c );
18  };
19  removeClass = function( elem, c ) {
20    elem.classList.remove( c );
21  };
22}
23else {
24  hasClass = function( elem, c ) {
25    return classReg( c ).test( elem.className );
26  };
27  addClass = function( elem, c ) {
28    if ( !hasClass( elem, c ) ) {
29      elem.className = elem.className + ' ' + c;
30    }
31  };
32  removeClass = function( elem, c ) {
33    elem.className = elem.className.replace( classReg( c ), ' ' );
34  };
35}
36
37function toggleClass( elem, c ) {
38  var fn = hasClass( elem, c ) ? removeClass : addClass;
39  fn( elem, c );
40}
41
42window.classie = {
43  // full names
44  hasClass: hasClass,
45  addClass: addClass,
46  removeClass: removeClass,
47  toggleClass: toggleClass,
48  // short names
49  has: hasClass,
50  add: addClass,
51  remove: removeClass,
52  toggle: toggleClass
53};
54
55})( window );
56
57jQuery( document ).ready( function( $ ) {
58	
59  var	Mgwprm = document.getElementById( 'mg-wprm-wrap' );
60	var	wprm_menuDir = document.getElementById( 'wprMenu' );
61	body = document.body;
62  
63  /**
64  ----------------------------------------
65  * 
66  * Body slide from one side ( left, right or top )
67  *
68  ----------------------------------------
69  **/
70  if( jQuery('.wprmenu_bar').hasClass('bodyslide') )
71    jQuery('body').addClass('cbp-spmenu-push');
72
73  jQuery('.wprmenu_bar, #custom_menu_icon').on('keydown', function(e) {
74    if (e.key === 'Enter' || e.key === ' ') {
75      e.preventDefault();
76      jQuery(this).trigger('click');
77    }
78  });
79
80  jQuery(document).on('keydown', function(e) {
81    if (e.key === 'Escape' && jQuery('#mg-wprm-wrap').hasClass('cbp-spmenu-open')) {
82      var menu_el = jQuery('.wprmenu_bar');
83      if (menu_el.hasClass('active')) {
84        menu_el.trigger('click');
85      }
86    }
87  });
88
89	jQuery('.wprmenu_bar').click( function(e) {
90		if( $(e.target).hasClass('bar_logo') )
91			return;
92    
93    
94
95		classie.toggle( this, 'active' );
96		jQuery(this).find('div.hamburger').toggleClass('is-active');
97    
98		if( jQuery(this).hasClass('active') ) {
99		  jQuery('html').addClass('wprmenu-body-fixed');
100      
101			if( wprmenu.enable_overlay == '1' ) {
102			 jQuery('div.wprm-wrapper').find('.wprm-overlay').addClass('active');
103       
104       
105			}
106		}
107		else {
108			jQuery('html').removeClass('wprmenu-body-fixed');
109      
110			if( wprmenu.enable_overlay == '1' ) {
111				jQuery('div.wprm-wrapper').find('.wprm-overlay').removeClass('active');
112			}
113
114      
115		}
116
117    /**
118    ----------------------------------------
119    * 
120    * Right side body push
121    *
122    ----------------------------------------
123    **/
124		if ( !jQuery(this).hasClass('normalslide') && jQuery(this).hasClass('left')) {
125			doc_width = jQuery(document).width() * (wprmenu.menu_width/100);
126			push_width = (wprmenu.push_width != '' && wprmenu.push_width < doc_width) ? wprmenu.push_width : doc_width;
127			classie.toggle(body, 'cbp-spmenu-push-toright');
128			
129      if( jQuery('body').hasClass('cbp-spmenu-push-toright') )
130				jQuery('body').css('left', push_width + 'px');
131			else
132				$('body').css('left','0px');
133		}
134
135		 /**
136    ----------------------------------------
137    * 
138    * Left side body push
139    *
140    ----------------------------------------
141    **/
142		if ( !jQuery(this).hasClass('normalslide') && jQuery(this).hasClass('right')) {
143			doc_width = jQuery(document).width() * (wprmenu.menu_width/100);
144			push_width = (wprmenu.push_width != '' && wprmenu.push_width < doc_width) ? wprmenu.push_width : doc_width;
145			classie.toggle(body, 'cbp-spmenu-push-toleft');
146			
147      if( jQuery('body').hasClass('cbp-spmenu-push-toleft') )
148				jQuery('body').css('left','-'+push_width+'px');
149			else
150				jQuery('body').css('left','0px');
151		}
152    
153		classie.toggle(Mgwprm, 'cbp-spmenu-open');
154
155    var wprmenuDemoId = wprmenu.wprmenuDemoId;
156    
157    if ( wprmenuDemoId ==  15 ) {
158      
159      jQuery('div.wprm-wrapper').addClass('wp-responsive-menu-demo15');
160      
161    }else if ( wprmenuDemoId ==  16 ) {
162
163      jQuery('div.wprm-wrapper').addClass('wp-responsive-menu-demo16');
164      
165    }else if ( wprmenuDemoId ==  17 ) {
166
167      jQuery('div.wprm-wrapper').addClass('wp-responsive-menu-demo17');
168     
169    }
170
171		close_sub_uls();
172
173	});
174
175  /**
176  -------------------------------------------------------------
177  * 
178  * Fix the scaling issue by adding/replacing viewport metatag
179  *
180  -------------------------------------------------------------
181  **/
182  var mt = $('meta[name=viewport]');
183  mt = mt.length ? mt : $('<meta name="viewport" />').appendTo('head');
184  if(wprmenu.zooming == 0) {
185    mt.attr('content', 'user-scalable=no, width=device-width, maximum-scale=1, minimum-scale=1');
186  } else {
187    mt.attr('content', 'user-scalable=yes, width=device-width, initial-scale=1.0, minimum-scale=1');
188  }
189
190	/**
191  ----------------------------------------
192  * 
193  * Click on body to remove the menu
194  *
195  ----------------------------------------
196  **/
197  $('body').click( function( event ) {
198    if ( $( '#wprmenu_bar' ).hasClass( 'active' ) ) {
199      $('#wprmenu_bar .wprmenu_icon').addClass('open');
200    } 
201    else {
202      $('#wprmenu_bar .wprmenu_icon').removeClass('open');
203    }
204  });
205
206	var menu = jQuery('#mg-wprm-wrap');
207	var menu_ul = jQuery('#wprmenu_menu_ul'); //the menu ul
208
209	jQuery(document).mouseup(function (e) {
210		if ( ($(e.target).hasClass('wprmenu_bar') || $(e.target).parents('.wprmenu_bar').length == 0) && 
211			($(e.target).hasClass('cbp-spmenu') || $(e.target).parents('.cbp-spmenu').length == 0)) {
212    		if(menu.is(':visible') ) {
213				$('.hamburger.is-active').trigger('click');
214			}
215		}
216	});
217
218	//add arrow element to the parent li items and chide its child uls
219	menu.find('ul.sub-menu').each(function() {
220		var sub_ul = $(this),
221		parent_a = sub_ul.prev('a'),
222		parent_li = parent_a.parent('li').first();
223
224		parent_a.addClass('wprmenu_parent_item');
225		parent_li.addClass('wprmenu_parent_item_li');
226
227		var expand = parent_a.before('<span class="wprmenu_icon wprmenu_icon_par icon_default"></span> ').find('.wprmenu_icon_par');
228		sub_ul.hide();
229	});
230
231
232	//expand / collapse action (SUBLEVELS)
233	$('.wprmenu_icon_par').on('click',function() {
234		var t = $(this),
235		child_ul = t.parent('li').find('ul.sub-menu').first(); 
236		child_ul.slideToggle('300');
237		t.toggleClass('wprmenu_par_opened');
238		t.parent('li').first().toggleClass('wprmenu_no_border_bottom');
239	});
240
241	//helper - close all submenus when menu is hiding
242	function close_sub_uls() {
243		menu.find('ul.sub-menu').each(function() {
244			var ul = $(this),
245			icon = ul.parent('li').find('.wprmenu_icon_par'),
246			li = ul.parent('li');
247
248			if(ul.is(':visible')) ul.slideUp(300);
249			icon.removeClass('wprmenu_par_opened');
250			li.removeClass('wprmenu_no_border_bottom');
251		});
252	}
253
254	//submenu opened
255	function open_sub_uls() {
256		menu.find('ul.sub-menu').each(function() {
257			var ul = $(this),
258			icon = ul.parent('li').find('.wprmenu_icon_par'),
259			li = ul.parent('li');
260
261			ul.slideDown(300);
262			icon.removeClass('wprmenu_par_opened');
263			icon.addClass('wprmenu_par_opened');
264		});
265	}
266
267	if( menu.hasClass('cbp-spmenu-top') && $('body').hasClass('cbp-spmenu-push') ){
268		$('body').prepend(menu);
269		//show / hide the menu
270		$('#wprmenu_bar,#custom_menu_icon').on('click', function(e) {
271			if( $(e.target).hasClass('bar_logo') )
272				return;
273			//scroll window top
274			$("html, body").animate({ scrollTop: 0 }, 300);
275
276			close_sub_uls();
277			menu.stop(true, false).slideToggle(300);
278		});
279	}
280	if( wprmenu.parent_click == 'yes' ) {
281		$('a.wprmenu_parent_item').on('click', function( event ){
282			event.preventDefault();
283      var t = $(this);
284      // Find the corresponding menu icon and trigger its click
285      t.parent('li').find('.wprmenu_icon_par').first().trigger('click');
286		});
287	}
288	$('#wprmenu_menu_ul a').click(function(){
289		if( wprmenu.parent_click !='yes' || (wprmenu.parent_click == 'yes' && !$(this).hasClass('wprmenu_parent_item')) )
290			$('.hamburger.is-active').trigger('click');
291	});
292
293
294  /**
295  ----------------------------------------
296  * 
297  * Swipe Enable Function
298  *
299  ----------------------------------------
300  **/
301	if( wprmenu.swipe == '1' ) {
302		var touchstartX = 0;
303		var touchendX = 0;
304		var touchstartY = 0;
305		var touchendY = 0;
306
307		document.addEventListener('touchstart', function(e) {
308			touchstartX = e.changedTouches[0].screenX;
309			touchstartY = e.changedTouches[0].screenY;
310		}, { passive: true });
311
312		document.addEventListener('touchend', function(e) {
313			var target = e.target;
314			if (jQuery(target).is('button, input, select, textarea, .noSwipe') || jQuery(target).parents('button, input, select, textarea, .noSwipe').length > 0) {
315				return;
316			}
317			
318			touchendX = e.changedTouches[0].screenX;
319			touchendY = e.changedTouches[0].screenY;
320			handleSwipe();
321		}, { passive: true });
322
323		function handleSwipe() {
324			var swipeX = touchendX - touchstartX;
325			var swipeY = touchendY - touchstartY;
326			var threshold = 100;
327
328			if (Math.abs(swipeX) > Math.abs(swipeY) && Math.abs(swipeX) > threshold) {
329				var menu_el = jQuery('.wprmenu_bar .hamburger, .wprmenu_bar .wpr-custom-menu');
330				
331				if (swipeX < 0 && menu_el.hasClass('is-active')) {
332					menu_el.trigger('click');
333				} else if (swipeX > 0 && !menu_el.hasClass('is-active')) {
334					menu_el.trigger('click');
335				}
336			}
337		}
338	}
339
340  function toggle_sub_uls($action) {
341    $('#mg-wprm-wrap').find('ul.sub-menu').each(function() {
342      var ul = $(this),
343      icon = ul.parent('li').find('.wprmenu_icon_par'),
344      li = ul.parent('li');
345
346      if( $action == 'open' ) {
347        ul.slideDown(300);
348        icon.removeClass( wprmenu.submenu_open_icon ).addClass( wprmenu.submenu_close_icon );
349      }
350      else {
351        if(ul.is(':visible')) ul.slideUp(300);
352        icon.removeClass( wprmenu.submenu_close_icon ).addClass( wprmenu.submenu_open_icon );
353        li.removeClass('wprmenu_no_border_bottom');
354      }
355      
356    });
357  }
358
359});

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.