14 button = nav.find( '.menu-toggle' ); |
14 button = nav.find( '.menu-toggle' ); |
15 menu = nav.find( '.nav-menu' ); |
15 menu = nav.find( '.nav-menu' ); |
16 |
16 |
17 // Enable menu toggle for small screens. |
17 // Enable menu toggle for small screens. |
18 ( function() { |
18 ( function() { |
19 if ( ! nav || ! button ) { |
19 if ( ! nav.length || ! button.length ) { |
20 return; |
20 return; |
21 } |
21 } |
22 |
22 |
23 // Hide button if menu is missing or empty. |
23 // Hide button if menu is missing or empty. |
24 if ( ! menu || ! menu.children().length ) { |
24 if ( ! menu.length || ! menu.children().length ) { |
25 button.hide(); |
25 button.hide(); |
26 return; |
26 return; |
27 } |
27 } |
28 |
28 |
29 button.on( 'click.twentyfourteen', function() { |
29 button.on( 'click.twentyfourteen', function() { |
120 $( this ).parents().toggleClass( 'focus' ); |
120 $( this ).parents().toggleClass( 'focus' ); |
121 } ); |
121 } ); |
122 } ); |
122 } ); |
123 |
123 |
124 /** |
124 /** |
125 * @summary Add or remove ARIA attributes. |
125 * Add or remove ARIA attributes. |
|
126 * |
126 * Uses jQuery's width() function to determine the size of the window and add |
127 * Uses jQuery's width() function to determine the size of the window and add |
127 * the default ARIA attributes for the menu toggle if it's visible. |
128 * the default ARIA attributes for the menu toggle if it's visible. |
128 * @since Twenty Fourteen 1.4 |
129 * @since Twenty Fourteen 1.4 |
129 */ |
130 */ |
130 function onResizeARIA() { |
131 function onResizeARIA() { |
144 .on( 'resize.twentyfourteen', function() { |
145 .on( 'resize.twentyfourteen', function() { |
145 onResizeARIA(); |
146 onResizeARIA(); |
146 } ); |
147 } ); |
147 |
148 |
148 _window.load( function() { |
149 _window.load( function() { |
|
150 var footerSidebar, |
|
151 isCustomizeSelectiveRefresh = ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ); |
|
152 |
149 // Arrange footer widgets vertically. |
153 // Arrange footer widgets vertically. |
150 if ( $.isFunction( $.fn.masonry ) ) { |
154 if ( $.isFunction( $.fn.masonry ) ) { |
151 $( '#footer-sidebar' ).masonry( { |
155 footerSidebar = $( '#footer-sidebar' ); |
|
156 footerSidebar.masonry( { |
152 itemSelector: '.widget', |
157 itemSelector: '.widget', |
153 columnWidth: function( containerWidth ) { |
158 columnWidth: function( containerWidth ) { |
154 return containerWidth / 4; |
159 return containerWidth / 4; |
155 }, |
160 }, |
156 gutterWidth: 0, |
161 gutterWidth: 0, |
157 isResizable: true, |
162 isResizable: true, |
158 isRTL: $( 'body' ).is( '.rtl' ) |
163 isRTL: $( 'body' ).is( '.rtl' ) |
159 } ); |
164 } ); |
|
165 |
|
166 if ( isCustomizeSelectiveRefresh ) { |
|
167 |
|
168 // Retain previous masonry-brick initial position. |
|
169 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { |
|
170 var copyPosition = ( |
|
171 placement.partial.extended( wp.customize.widgetsPreview.WidgetPartial ) && |
|
172 placement.removedNodes instanceof jQuery && |
|
173 placement.removedNodes.is( '.masonry-brick' ) && |
|
174 placement.container instanceof jQuery |
|
175 ); |
|
176 if ( copyPosition ) { |
|
177 placement.container.css( { |
|
178 position: placement.removedNodes.css( 'position' ), |
|
179 top: placement.removedNodes.css( 'top' ), |
|
180 left: placement.removedNodes.css( 'left' ) |
|
181 } ); |
|
182 } |
|
183 } ); |
|
184 |
|
185 // Re-arrange footer widgets after selective refresh event. |
|
186 wp.customize.selectiveRefresh.bind( 'sidebar-updated', function( sidebarPartial ) { |
|
187 if ( 'sidebar-3' === sidebarPartial.sidebarId ) { |
|
188 footerSidebar.masonry( 'reloadItems' ); |
|
189 footerSidebar.masonry( 'layout' ); |
|
190 } |
|
191 } ); |
|
192 } |
|
193 } |
|
194 |
|
195 // Initialize audio and video players in Twenty_Fourteen_Ephemera_Widget widget when selectively refreshed in Customizer. |
|
196 if ( isCustomizeSelectiveRefresh && wp.mediaelement ) { |
|
197 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() { |
|
198 wp.mediaelement.initialize(); |
|
199 } ); |
160 } |
200 } |
161 |
201 |
162 // Initialize Featured Content slider. |
202 // Initialize Featured Content slider. |
163 if ( body.is( '.slider' ) ) { |
203 if ( body.is( '.slider' ) ) { |
164 $( '.featured-content' ).featuredslider( { |
204 $( '.featured-content' ).featuredslider( { |