PageSourceSearch

https://bip.lu/wp-content/themes/bip/js/functions.js?ver=20150315

js bip.lu collected 2026-10-02 20:48:55 UTC 4,530 bytes, 171 lines download raw bytes

1/**
2 * Theme functions file
3 *
4 * Contains handlers for navigation, accessibility, header sizing
5 * footer widgets and Featured Content slider
6 *
7 */
8
9( function( $ ) {
10	var body    = $( 'body' ),
11		_window = $( window ),
12		nav, button, menu;
13
14	nav = $( '#primary-navigation' );
15	button = nav.find( '.menu-toggle' );
16	menu = nav.find( '.nav-menu' );
17
18	// Enable menu toggle for small screens.
19	( function() {
20		if ( ! nav || ! button ) {
21			return;
22		}
23
24		// Hide button if menu is missing or empty.
25		if ( ! menu || ! menu.children().length ) {
26			button.hide();
27			return;
28		}
29
30		button.on( 'click.twentyfourteen', function() {
31			nav.toggleClass( 'toggled-on' );
32			if ( nav.hasClass( 'toggled-on' ) ) {
33				$( this ).attr( 'aria-expanded', 'true' );
34				menu.attr( 'aria-expanded', 'true' );
35			} else {
36				$( this ).attr( 'aria-expanded', 'false' );
37				menu.attr( 'aria-expanded', 'false' );
38			}
39		} );
40	} )();
41
42	/*
43	 * Makes "skip to content" link work correctly in IE9 and Chrome for better
44	 * accessibility.
45	 *
46	 * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
47	 */
48	_window.on( 'hashchange.twentyfourteen', function() {
49		var hash = location.hash.substring( 1 ), element;
50
51		if ( ! hash ) {
52			return;
53		}
54
55		element = document.getElementById( hash );
56
57		if ( element ) {
58			if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) {
59				element.tabIndex = -1;
60			}
61
62			element.focus();
63
64			// Repositions the window on jump-to-anchor to account for header height.
65			window.scrollBy( 0, -80 );
66		}
67	} );
68
69	$( function() {
70		// Search toggle.
71		$( '.search-toggle' ).on( 'click.twentyfourteen', function( event ) {
72			var that    = $( this ),
73				wrapper = $( '#search-container' ),
74				container = that.find( 'a' );
75
76			that.toggleClass( 'active' );
77			wrapper.toggleClass( 'hide' );
78
79			if ( that.hasClass( 'active' ) ) {
80				container.attr( 'aria-expanded', 'true' );
81			} else {
82				container.attr( 'aria-expanded', 'false' );
83			}
84
85			if ( that.is( '.active' ) || $( '.search-toggle .screen-reader-text' )[0] === event.target ) {
86				wrapper.find( '.search-field' ).focus();
87			}
88		} );
89
90		/*
91		 * Fixed header for large screen.
92		 * If the header becomes more than 48px tall, unfix the header.
93		 *
94		 * The callback on the scroll event is only added if there is a header
95		 * image and we are not on mobile.
96		 */
97		if ( _window.width() > 781 ) {
98			var mastheadHeight = $( '#masthead' ).height(),
99				toolbarOffset, mastheadOffset;
100
101			if ( mastheadHeight > 48 ) {
102				body.removeClass( 'masthead-fixed' );
103			}
104
105			if ( body.is( '.header-image' ) ) {
106				toolbarOffset  = body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
107				mastheadOffset = $( '#masthead' ).offset().top - toolbarOffset;
108
109				_window.on( 'scroll.twentyfourteen', function() {
110					if ( _window.scrollTop() > mastheadOffset && mastheadHeight < 49 ) {
111						body.addClass( 'masthead-fixed' );
112					} else {
113						body.removeClass( 'masthead-fixed' );
114					}
115				} );
116			}
117		}
118
119		// Focus styles for menus.
120		$( '.primary-navigation, .secondary-navigation' ).find( 'a' ).on( 'focus.twentyfourteen blur.twentyfourteen', function() {
121			$( this ).parents().toggleClass( 'focus' );
122		} );
123	} );
124
125	/**
126	 * @summary Add or remove ARIA attributes.
127	 * Uses jQuery's width() function to determine the size of the window and add
128	 * the default ARIA attributes for the menu toggle if it's visible.
129	 * @since Twenty Fourteen 1.4
130	 */
131	function onResizeARIA() {
132		if ( 781 > _window.width() ) {
133			button.attr( 'aria-expanded', 'false' );
134			menu.attr( 'aria-expanded', 'false' );
135			button.attr( 'aria-controls', 'primary-menu' );
136		} else {
137			button.removeAttr( 'aria-expanded' );
138			menu.removeAttr( 'aria-expanded' );
139			button.removeAttr( 'aria-controls' );
140		}
141	}
142
143	_window
144		.on( 'load.twentyfourteen', onResizeARIA )
145		.on( 'resize.twentyfourteen', function() {
146			onResizeARIA();
147	} );
148
149	_window.load( function() {
150		// Arrange footer widgets vertically.
151		if ( $.isFunction( $.fn.masonry ) ) {
152			$( '#footer-sidebar' ).masonry( {
153				itemSelector: '.widget',
154				columnWidth: function( containerWidth ) {
155					return containerWidth / 4;
156				},
157				gutterWidth: 0,
158				isResizable: true,
159				isRTL: $( 'body' ).is( '.rtl' )
160			} );
161		}
162
163		// Initialize Featured Content slider.
164		if ( body.is( '.slider' ) ) {
165			$( '.featured-content' ).featuredslider( {
166				selector: '.featured-content-inner > article',
167				controlsContainer: '.featured-content'
168			} );
169		}
170	} );
171} )( 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.