PageSourceSearch

https://sashasoykinphd.com/wp-content/themes/sashasoykinphd/menu.js?ver=1.0.0

js sashasoykinphd.com collected 2026-10-08 12:00:02 UTC 12,012 bytes, 354 lines download raw bytes

1// /*
2
3// An accessible menu for WordPress
4// https://github.com/argenteum/accessible-nav-wp
5
6// Licensed GPL v.2 (http://www.gnu.org/licenses/gpl-2.0.html)
7
8// This work derived from:
9// https://github.com/WordPress/twentysixteen (GPL v.2)
10// https://github.com/wpaccessibility/a11ythemepatterns/tree/master/menu-keyboard-arrow-nav (GPL v.2)
11
12// */
13
14// (function(jQuery) {
15
16//     var menuContainer    = jQuery('.menu-container');
17//     var menuToggle       = menuContainer.find( '.menu-button' );
18//     var siteHeaderMenu   = menuContainer.find( '#site-header-menu' );
19//     var siteNavigation   = menuContainer.find( '#site-navigation' );
20
21//     // If you are using WordPress, and do not need to localize your script, or if you are not using WordPress, then uncomment the next line
22//     // var screenReaderText = {"expand":"Expand child menu","collapse":"Collapse child menu"};
23
24//  var screenReaderText = {
25//     expand: 'Expand', // You can set the actual text value here
26// };
27
28// var dropdownToggle = jQuery('<button />', {
29//     'class': 'dropdown-toggle',
30//     'aria-expanded': false
31// }).append(
32//     jQuery('<span />', {
33//         'class': 'screen-readers',
34//         text: screenReaderText.expand
35//     })
36// );
37
38// // jQuery('#dropdownContainer').append(dropdownToggle);
39
40// jQuery("li.menu-item-has-children").each(function () {
41//         var bob = jQuery(this).find(".menu-item-has-children a").text();
42
43//         jQuery(this).find(".menu-item-has-children a").attr("aria-label", + bob);            
44
45//     });
46//     // Toggles the menu button
47//     (function() {
48
49//         if (!menuToggle.length) {
50//         return;
51//         }
52
53//         menuToggle.add(siteNavigation).attr('aria-expanded', 'false');
54
55//         menuToggle.on('click', function() {
56//         jQuery(this).add(siteHeaderMenu).toggleClass('toggled-on');
57
58//         // jscs:disable
59//         jQuery(this).add( siteNavigation )
60//         .attr('aria-expanded', jQuery( this )
61//         .add( siteNavigation ).attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
62//         // jscs:enable
63
64//         } );
65//     } )();
66
67//     // Adds the dropdown toggle button
68//     jQuery('.menu-item-has-children > a').after(dropdownToggle);
69
70//     // Adds aria attribute
71//     siteHeaderMenu.find( '.menu-item-has-children' ).attr( 'aria-haspopup', 'true' );
72
73//     // Toggles the sub-menu when dropdown toggle button clicked
74//     siteHeaderMenu.find( '.dropdown-toggle' ).click( function(e) {
75
76//         screenReaderSpan = jQuery(this).find( '.screen-readers' );
77
78//         e.preventDefault();
79//         jQuery(this).toggleClass( 'toggled-on' );
80//         jQuery(this).nextAll( '.sub-menu' ).toggleClass( 'toggled-on' );
81
82//         // jscs:disable
83//         jQuery(this).attr( 'aria-expanded', jQuery(this).attr( 'aria-expanded' ) === 'false'
84//         ? 'true' : 'false' );
85//         // jscs:enable
86//         screenReaderSpan.text( screenReaderSpan.text() ===
87//         screenReaderText.expand ? screenReaderText.collapse :
88//         screenReaderText.expand );
89//     });
90
91//     // Adds a class to sub-menus for styling
92//     jQuery('.sub-menu .menu-item-has-children').parent('.sub-menu').addClass('has-sub-menu');
93
94//     // Keyboard navigation
95//     jQuery('.menu-item a, button.dropdown-toggle').on('keydown', function(e) {
96
97//         if ([37,38,39,40].indexOf(e.keyCode) == -1) {
98//             return;
99//         }
100
101//         switch(e.keyCode) {
102
103//             case 37: 				// left key
104//                 e.preventDefault();
105//                 e.stopPropagation();
106
107//                 if (jQuery(this).hasClass('dropdown-toggle')){
108//                     jQuery(this).prev('a').focus();
109//                 }
110//                 else {
111
112//                 if (jQuery(this).parent().prev().children('button.dropdown-toggle').length) {
113//                     jQuery(this).parent().prev().children('button.dropdown-toggle').focus();
114//                 }
115//                 else {
116//                     jQuery(this).parent().prev().children('a').focus();
117//                 }
118//                 }
119
120//                 if (jQuery(this).is('ul ul ul.sub-menu.toggled-on li:first-child a')) {
121//                     jQuery(this).parents('ul.sub-menu.toggled-on li').children('button.dropdown-toggle').focus();
122//                 }
123
124//                 break;
125
126//             case 39: 				// right key
127//                 e.preventDefault();
128//                 e.stopPropagation();
129
130//         if(jQuery(this).next('button.dropdown-toggle').length) {
131//                     jQuery(this).next('button.dropdown-toggle').focus();
132//                 }
133//                 else {
134//                     jQuery(this).parent().next().children('a').focus();
135//                 }
136
137//                 if (jQuery(this).is('ul.sub-menu .dropdown-toggle.toggled-on')){
138//                     jQuery(this).parent().find('ul.sub-menu li:first-child a').focus();
139//                 }
140
141//                 break;
142
143//           case 40: 				// down key
144//                 e.preventDefault();
145//                 e.stopPropagation();
146
147//         if(jQuery(this).next().length){
148//             jQuery(this).next().find('li:first-child a').first().focus();
149//         }
150//         else {
151//             jQuery(this).parent().next().children('a').focus();
152//         }
153
154//                 if ((jQuery(this).is('ul.sub-menu a')) && (jQuery(this).next('button.dropdown-toggle').length)) {
155//                     jQuery(this).parent().next().children('a').focus();
156//                 }
157
158//                 if ((jQuery(this).is('ul.sub-menu .dropdown-toggle')) && (jQuery(this).parent().next().children('.dropdown-toggle').length)) {
159//                     jQuery(this).parent().next().children('.dropdown-toggle').focus();
160//                 }
161
162//                 break;
163
164//             case 38: 				// up key
165//                 e.preventDefault();
166//                 e.stopPropagation();
167
168//         if(jQuery(this).parent().prev().length){
169//             jQuery(this).parent().prev().children('a').focus();
170//         }
171//         else {
172//             jQuery(this).parents('ul').first().prev('.dropdown-toggle.toggled-on').focus();
173//         }
174
175//                 if ((jQuery(this).is('ul.sub-menu .dropdown-toggle')) && (jQuery(this).parent().prev().children('.dropdown-toggle').length)) {
176//                     jQuery(this).parent().prev().children('.dropdown-toggle').focus();
177//                 }
178
179//                 break;
180
181//         }
182//     });
183// })(jQuery);
184
185/*
186
187An accessible menu for WordPress
188https://github.com/argenteum/accessible-nav-wp
189
190Licensed GPL v.2 (http://www.gnu.org/licenses/gpl-2.0.html)
191
192This work derived from:
193https://github.com/WordPress/twentysixteen (GPL v.2)
194https://github.com/wpaccessibility/a11ythemepatterns/tree/master/menu-keyboard-arrow-nav (GPL v.2)
195
196*/
197
198(function($) {
199
200    var menuContainer    = $('.menu-container');
201    var menuToggle       = menuContainer.find( '.menu-button' );
202    var siteHeaderMenu   = menuContainer.find( '#site-header-menu' );
203    var siteNavigation   = menuContainer.find( '#site-navigation' );
204
205    // If you are using WordPress, and do not need to localise your script, or if you are not using WordPress, then uncomment the next line
206    // var screenReaderText = {"expand":"Expand child menu","collapse":"Collapse child menu"};
207
208    var screenReaderText = {"expand":"Expand child menu","collapse":"Collapse child menu"};
209
210    var dropdownToggle = $('<button />', {'class': 'dropdown-toggle', 'aria-expanded': false})
211        .append($('<span />', {'class': 'screen-readers', text: screenReaderText.expand}));
212
213
214    // Toggles the menu button
215    (function() {
216
217        if (!menuToggle.length) {
218        return;
219        }
220
221        menuToggle.add(siteNavigation).attr('aria-expanded', 'false');
222
223        menuToggle.on('click', function() {
224        $(this).add(siteHeaderMenu).toggleClass('toggled-on');
225
226        // jscs:disable
227        $(this).add( siteNavigation )
228        .attr('aria-expanded', $( this )
229        .add( siteNavigation ).attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
230        // jscs:enable
231
232        } );
233    } )();
234
235    // Adds the dropdown toggle button
236    $('.menu-item-has-children > a').after(dropdownToggle);
237
238    // Adds aria attribute
239    siteHeaderMenu.find( '.menu-item-has-children' ).attr( 'aria-haspopup', 'true' );
240
241    // Toggles the sub-menu when dropdown toggle button clicked
242    siteHeaderMenu.find( '.dropdown-toggle' ).click( function(e) {
243
244        screenReaderSpan = $(this).find( '.screen-readers' );
245
246        e.preventDefault();
247        $(this).toggleClass( 'toggled-on' );
248        $(this).nextAll( '.sub-menu' ).toggleClass( 'toggled-on' );
249
250        // jscs:disable
251        $(this).attr( 'aria-expanded', $(this).attr( 'aria-expanded' ) === 'false'
252        ? 'true' : 'false' );
253        // jscs:enable
254        screenReaderSpan.text( screenReaderSpan.text() ===
255        screenReaderText.expand ? screenReaderText.collapse :
256        screenReaderText.expand );
257    });
258
259    // Adds a class to sub-menus for styling
260    $('.sub-menu .menu-item-has-children').parent('.sub-menu').addClass('has-sub-menu');
261
262
263    // Keyboard navigation
264    $('.menu-item a, button.dropdown-toggle').on('keydown', function(e) {
265
266        if ([37,38,39,40].indexOf(e.keyCode) == -1) {
267            return;
268        }
269
270        switch(e.keyCode) {
271
272            case 37: 				// left key
273                e.preventDefault();
274                e.stopPropagation();
275
276                if ($(this).hasClass('dropdown-toggle')){
277            		$(this).prev('a').focus();
278            	}
279            	else {
280
281                if ($(this).parent().prev().children('button.dropdown-toggle').length) {
282                	$(this).parent().prev().children('button.dropdown-toggle').focus();
283                }
284                else {
285                	$(this).parent().prev().children('a').focus();
286                }
287            	}
288
289            	if ($(this).is('ul ul ul.sub-menu.toggled-on li:first-child a')) {
290            		$(this).parents('ul.sub-menu.toggled-on li').children('button.dropdown-toggle').focus();
291            	}
292
293                break;
294
295	    case 39: 				// right key
296                e.preventDefault();
297                e.stopPropagation();
298
299		if($(this).next('button.dropdown-toggle').length) {
300            		$(this).next('button.dropdown-toggle').focus();
301            	}
302            	else {
303            		$(this).parent().next().children('a').focus();
304            	}
305
306            	if ($(this).is('ul.sub-menu .dropdown-toggle.toggled-on')){
307            		$(this).parent().find('ul.sub-menu li:first-child a').focus();
308            	}
309
310                break;
311
312
313           case 40: 				// down key
314                e.preventDefault();
315                e.stopPropagation();
316
317		if($(this).next().length){
318			$(this).next().find('li:first-child a').first().focus();
319		}
320		else {
321			$(this).parent().next().children('a').focus();
322		}
323
324            	if (($(this).is('ul.sub-menu a')) && ($(this).next('button.dropdown-toggle').length)) {
325            		$(this).parent().next().children('a').focus();
326            	}
327
328            	if (($(this).is('ul.sub-menu .dropdown-toggle')) && ($(this).parent().next().children('.dropdown-toggle').length)) {
329            		$(this).parent().next().children('.dropdown-toggle').focus();
330            	}
331
332                break;
333
334
335            case 38: 				// up key
336                e.preventDefault();
337                e.stopPropagation();
338
339		if($(this).parent().prev().length){
340			$(this).parent().prev().children('a').focus();
341		}
342		else {
343			$(this).parents('ul').first().prev('.dropdown-toggle.toggled-on').focus();
344		}
345
346            	if (($(this).is('ul.sub-menu .dropdown-toggle')) && ($(this).parent().prev().children('.dropdown-toggle').length)) {
347            		$(this).parent().prev().children('.dropdown-toggle').focus();
348            	}
349
350                break;
351
352        }
353    });
354})(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.