32 |
32 |
33 /** |
33 /** |
34 * Enables menu toggle for small screens. |
34 * Enables menu toggle for small screens. |
35 */ |
35 */ |
36 ( function() { |
36 ( function() { |
37 if ( ! nav || ! button ) { |
37 if ( ! nav.length || ! button.length ) { |
38 return; |
38 return; |
39 } |
39 } |
40 |
40 |
41 // Hide button if menu is missing or empty. |
41 // Hide button if menu is missing or empty. |
42 if ( ! menu || ! menu.children().length ) { |
42 if ( ! menu.length || ! menu.children().length ) { |
43 button.hide(); |
43 button.hide(); |
44 return; |
44 return; |
45 } |
45 } |
46 |
46 |
47 button.on( 'click.twentythirteen', function() { |
47 button.on( 'click.twentythirteen', function() { |
73 $( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' ); |
73 $( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' ); |
74 } ); |
74 } ); |
75 } )(); |
75 } )(); |
76 |
76 |
77 /** |
77 /** |
78 * @summary Add or remove ARIA attributes. |
78 * Add or remove ARIA attributes. |
|
79 * |
79 * Uses jQuery's width() function to determine the size of the window and add |
80 * Uses jQuery's width() function to determine the size of the window and add |
80 * the default ARIA attributes for the menu toggle if it's visible. |
81 * the default ARIA attributes for the menu toggle if it's visible. |
|
82 * |
81 * @since Twenty Thirteen 1.5 |
83 * @since Twenty Thirteen 1.5 |
82 */ |
84 */ |
83 function onResizeARIA() { |
85 function onResizeARIA() { |
84 if ( 643 > _window.width() ) { |
86 if ( 643 > _window.width() ) { |
85 button.attr( 'aria-expanded', 'false' ); |
87 button.attr( 'aria-expanded', 'false' ); |
117 } ); |
119 } ); |
118 |
120 |
119 /** |
121 /** |
120 * Arranges footer widgets vertically. |
122 * Arranges footer widgets vertically. |
121 */ |
123 */ |
122 if ( $.isFunction( $.fn.masonry ) ) { |
124 $( function() { |
123 var columnWidth = body.is( '.sidebar' ) ? 228 : 245; |
125 var columnWidth, widgetArea; |
|
126 if ( ! $.isFunction( $.fn.masonry ) ) { |
|
127 return; |
|
128 } |
|
129 columnWidth = body.is( '.sidebar' ) ? 228 : 245; |
|
130 widgetArea = $( '#secondary .widget-area' ); |
124 |
131 |
125 $( '#secondary .widget-area' ).masonry( { |
132 widgetArea.masonry( { |
126 itemSelector: '.widget', |
133 itemSelector: '.widget', |
127 columnWidth: columnWidth, |
134 columnWidth: columnWidth, |
128 gutterWidth: 20, |
135 gutterWidth: 20, |
129 isRTL: body.is( '.rtl' ) |
136 isRTL: body.is( '.rtl' ) |
130 } ); |
137 } ); |
131 } |
138 |
|
139 if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) { |
|
140 |
|
141 // Retain previous masonry-brick initial position. |
|
142 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { |
|
143 var copyPosition = ( |
|
144 placement.partial.extended( wp.customize.widgetsPreview.WidgetPartial ) && |
|
145 placement.removedNodes instanceof jQuery && |
|
146 placement.removedNodes.is( '.masonry-brick' ) && |
|
147 placement.container instanceof jQuery |
|
148 ); |
|
149 if ( copyPosition ) { |
|
150 placement.container.css( { |
|
151 position: placement.removedNodes.css( 'position' ), |
|
152 top: placement.removedNodes.css( 'top' ), |
|
153 left: placement.removedNodes.css( 'left' ) |
|
154 } ); |
|
155 } |
|
156 } ); |
|
157 |
|
158 // Re-arrange footer widgets when sidebar is updated via selective refresh in the Customizer. |
|
159 wp.customize.selectiveRefresh.bind( 'sidebar-updated', function( sidebarPartial ) { |
|
160 if ( 'sidebar-1' === sidebarPartial.sidebarId ) { |
|
161 widgetArea.masonry( 'reloadItems' ); |
|
162 widgetArea.masonry( 'layout' ); |
|
163 } |
|
164 } ); |
|
165 } |
|
166 } ); |
132 } )( jQuery ); |
167 } )( jQuery ); |