PageSourceSearch

https://section-26.fr/wp-content/plugins/wp-sticky-menu/public/js/wp-sticky-menu-public.js?ver=1.0.0

js section-26.fr collected 2026-10-02 08:02:57 UTC 4,688 bytes, 143 lines download raw bytes

1(function( $ ) {
2	'use strict';
3
4	var body, masthead, menuToggle, siteNavigation, socialNavigation, siteHeaderMenu, resizeTimer;
5
6	function WPStickyMenu( container ) {
7
8		// Add dropdown toggle that display child menu items.
9		var dropdownToggle = $( '<button />', {
10			'class': 'wpsm-toggle',
11			'aria-expanded': false
12		} ).append( $( '<span />', {
13			'class': 'screen-reader-text',
14			text: screenReaderText.expand
15		} ) );
16
17		container.find( '.menu-item-has-children > a' ).after( dropdownToggle );
18
19		// Toggle buttons and submenu items with active children menu items.
20		container.find( '.current-menu-ancestor > button' ).addClass( 'toggled-on' );
21		container.find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' );
22
23		// Add menu items with submenus to aria-haspopup="true".
24		container.find( '.menu-item-has-children' ).attr( 'aria-haspopup', 'true' );
25
26		container.find( '.wpsm-toggle' ).click( function( e ) {
27			var _this            = $( this ),
28				screenReaderSpan = _this.find( '.screen-reader-text' );
29
30			e.preventDefault();
31			_this.toggleClass( 'toggled-on' );
32			_this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
33
34			// jscs:disable
35			_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
36			// jscs:enable
37			screenReaderSpan.text( screenReaderSpan.text() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand );
38		} );
39	}
40	WPStickyMenu( $( '.wpsm-navigation' ) );
41
42	masthead         = $( '#wp-sticky-menu' );
43	menuToggle       = masthead.find( '#wpsm-menu-toggle' );
44	siteHeaderMenu   = masthead.find( '#wpsm-inner' );
45	siteNavigation   = masthead.find( '#wpsm-navigation' );
46	socialNavigation = masthead.find( '#social-navigation' );
47
48	// Enable menuToggle.
49	( function() {
50
51		// Return early if menuToggle is missing.
52		if ( ! menuToggle.length ) {
53			return;
54		}
55
56		// Add an initial values for the attribute.
57		menuToggle.add( siteNavigation ).add( socialNavigation ).attr( 'aria-expanded', 'false' );
58
59		menuToggle.on( 'click.wpsm', function() {
60			$( this ).add( siteHeaderMenu ).toggleClass( 'toggled-on' );
61
62			// jscs:disable
63			$( this ).add( siteNavigation ).add( socialNavigation ).attr( 'aria-expanded', $( this ).add( siteNavigation ).add( socialNavigation ).attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
64			// jscs:enable
65		} );
66	} )();
67
68	// Fix sub-menus for touch devices and better focus for hidden submenu items for accessibility.
69	( function() {
70		if ( ! siteNavigation.length || ! siteNavigation.children().length ) {
71			return;
72		}
73
74		// Toggle `focus` class to allow submenu access on tablets.
75		function toggleFocusClassTouchScreen() {
76			if ( window.innerWidth > 910 ) {
77				siteNavigation.find( '.menu-item-has-children > a' ).on( 'touchstart.wpstickymenu', function( e ) {
78					var el = $( this ).parent( 'li' );
79
80					if ( ! el.hasClass( 'focus' ) ) {
81						e.preventDefault();
82						el.toggleClass( 'focus' );
83						el.siblings( '.focus' ).removeClass( 'focus' );
84					}
85				} );
86			} else {
87				siteNavigation.find( '.menu-item-has-children > a' ).unbind( 'touchstart.wpstickymenu' );
88			}
89		}
90
91		if ( 'ontouchstart' in window ) {
92			$( window ).on( 'resize.wpstickymenu', toggleFocusClassTouchScreen );
93			toggleFocusClassTouchScreen();
94		}
95
96		siteNavigation.find( 'a' ).on( 'focus.wpstickymenu blur.wpstickymenu', function() {
97			$( this ).parents( '.menu-item' ).toggleClass( 'focus' );
98		} );
99	} )();
100
101	// Add the default ARIA attributes for the menu toggle and the navigations.
102	function onResizeARIA() {
103		if ( window.innerWidth < 910 ) {
104			if ( menuToggle.hasClass( 'toggled-on' ) ) {
105				menuToggle.attr( 'aria-expanded', 'true' );
106			} else {
107				menuToggle.attr( 'aria-expanded', 'false' );
108			}
109
110			if ( siteHeaderMenu.hasClass( 'toggled-on' ) ) {
111				siteNavigation.attr( 'aria-expanded', 'true' );
112			} else {
113				siteNavigation.attr( 'aria-expanded', 'false' );
114			}
115
116			menuToggle.attr( 'aria-controls', 'site-navigation social-navigation' );
117		} else {
118			menuToggle.removeAttr( 'aria-expanded' );
119			siteNavigation.removeAttr( 'aria-expanded' );
120			menuToggle.removeAttr( 'aria-controls' );
121		}
122	}
123
124})( jQuery );
125
126/*---------------------------------------------------
127/*  sticky header
128/* -------------------------------------------------*/
129(function() {
130    var header = document.querySelector("#wp-sticky-menu"),
131    	offset = header.offsetHeight;
132
133	// construct an instance of Headroom, passing the element
134	new Headroom(header, {
135        offset : offset,
136        classes: {
137	          initial: "slide",
138	          pinned: "slide--reset",
139	          unpinned: "slide--up"
140        }
141    }).init(); 
142
143}());

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.