PageSourceSearch

https://upline.es/wp-content/themes/maker-pro/js/responsive-menu.js?ver=1.0.1

js upline.es collected 2026-10-07 20:01:24 UTC 4,655 bytes, 170 lines download raw bytes

1( function ( document, $, undefined ) {
2
3	$( 'body' ).addClass( 'js' );
4
5	'use strict';
6
7	var maker            = {},
8		mainMenuButtonClass = 'menu-toggle',
9		subMenuButtonClass  = 'sub-menu-toggle';
10
11	maker.init = function() {
12		var toggleButtons = {
13			menu : $( '<button />', {
14				'class' : mainMenuButtonClass,
15				'aria-expanded' : false,
16				'aria-pressed' : false,
17				'role' : 'button'
18				} )
19				.append( maker.params.mainMenu ),
20			submenu : $( '<button />', {
21				'class' : subMenuButtonClass,
22				'aria-expanded' : false,
23				'aria-pressed' : false,
24				'role' : 'button'
25				} )
26				.append( $( '<span />', {
27					'class' : 'screen-reader-text',
28					text : maker.params.subMenu
29				} ) )
30		};
31		$( '.nav-primary' ).before( toggleButtons.menu ); // add the main nav buttons
32		$( 'nav .sub-menu' ).before( toggleButtons.submenu ); // add the submenu nav buttons
33		$( '.' + mainMenuButtonClass ).each( _addClassID );
34		$( window ).on( 'resize.maker', _doResize ).triggerHandler( 'resize.maker' );
35		$( '.' + mainMenuButtonClass ).on( 'click.maker-mainbutton', _mainmenuToggle );
36		$( '.' + subMenuButtonClass ).on( 'click.maker-subbutton', _submenuToggle );
37	};
38
39	// add nav class and ID to related button
40	function _addClassID() {
41		var $this = $( this ),
42			nav   = $this.next( 'nav' ),
43			id    = 'class';
44		$this.addClass( $( nav ).attr( 'class' ) );
45		if ( $( nav ).attr( 'id' ) ) {
46			id = 'id';
47		}
48		$this.attr( 'id', 'mobile-' + $( nav ).attr( id ) );
49	}
50
51	// Change Skiplinks and Superfish
52	function _doResize() {
53		var buttons = $( 'button[id^=mobile-]' ).attr( 'id' );
54		if ( typeof buttons === 'undefined' ) {
55			return;
56		}
57		_superfishToggle( buttons );
58		_changeSkipLink( buttons );
59		_maybeClose( buttons );
60	}
61
62	/**
63	 * action to happen when the main menu button is clicked
64	 */
65	function _mainmenuToggle() {
66		var $this = $( this );
67		_toggleAria( $this, 'aria-pressed' );
68		_toggleAria( $this, 'aria-expanded' );
69		$this.toggleClass( 'activated' );
70		$( 'nav.nav-primary' ).slideToggle( 'fast' ); //changed to .nav-primary since we're not toggling .nav-secondary
71	}
72
73	/**
74	 * action for submenu toggles
75	 */
76	function _submenuToggle() {
77
78		var $this  = $( this ),
79			others = $this.closest( '.menu-item' ).siblings();
80		_toggleAria( $this, 'aria-pressed' );
81		_toggleAria( $this, 'aria-expanded' );
82		$this.toggleClass( 'activated' );
83		$this.next( '.sub-menu' ).slideToggle( 'fast' );
84
85		others.find( '.' + subMenuButtonClass ).removeClass( 'activated' ).attr( 'aria-pressed', 'false' );
86		others.find( '.sub-menu' ).slideUp( 'fast' );
87
88	}
89
90	/**
91	 * activate/deactivate superfish
92	 */
93	function _superfishToggle( buttons ) {
94		if ( typeof $( '.js-superfish' ).superfish !== 'function' ) {
95			return;
96		}
97		if ( 'none' === _getDisplayValue( buttons ) ) {
98			$( '.js-superfish' ).superfish( {
99				'delay': 100,
100				'animation': {'opacity': 'show', 'height': 'show'},
101				'dropShadows': false
102			});
103		} else {
104			$( '.js-superfish' ).superfish( 'destroy' );
105		}
106	}
107
108	/**
109	 * modify skip links to match mobile buttons
110	 */
111	function _changeSkipLink( buttons ) {
112		var startLink = 'genesis-nav',
113			endLink   = 'mobile-genesis-nav';
114		if ( 'none' === _getDisplayValue( buttons ) ) {
115			startLink = 'mobile-genesis-nav';
116			endLink   = 'genesis-nav';
117		}
118		$( '.genesis-skip-link a[href^="#' + startLink + '"]' ).each( function() {
119			var link = $( this ).attr( 'href' );
120			link = link.replace( startLink, endLink );
121			$( this ).attr( 'href', link );
122		});
123	}
124
125	function _maybeClose( buttons ) {
126		if ( 'none' !== _getDisplayValue( buttons ) ) {
127			return;
128		}
129		$( '.menu-toggle, .sub-menu-toggle' )
130			.removeClass( 'activated' )
131			.attr( 'aria-expanded', false )
132			.attr( 'aria-pressed', false );
133		$( 'nav, .sub-menu' )
134			.attr( 'style', '' );
135	}
136
137	/**
138	 * generic function to get the display value of an element
139	 * @param  {id} $id ID to check
140	 * @return {string}     CSS value of display property
141	 */
142	function _getDisplayValue( $id ) {
143		var element = document.getElementById( $id ),
144			style   = window.getComputedStyle( element );
145		return style.getPropertyValue( 'display' );
146	}
147
148	/**
149	 * Toggle aria attributes
150	 * @param  {button} $this     passed through
151	 * @param  {aria-xx} attribute aria attribute to toggle
152	 * @return {bool}           from _ariaReturn
153	 */
154	function _toggleAria( $this, attribute ) {
155		$this.attr( attribute, function( index, value ) {
156			return 'false' === value;
157		});
158	}
159
160	$(document).ready(function () {
161
162		maker.params = typeof ShowcaseL10n === 'undefined' ? '' : ShowcaseL10n;
163
164		if ( typeof maker.params !== 'undefined' ) {
165			maker.init();
166		}
167
168	});
169
170})( document, 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.