2 * @file Functionality for the plugin install screens. |
2 * @file Functionality for the plugin install screens. |
3 * |
3 * |
4 * @output wp-admin/js/plugin-install.js |
4 * @output wp-admin/js/plugin-install.js |
5 */ |
5 */ |
6 |
6 |
7 /* global plugininstallL10n, tb_click, tb_remove, tb_position */ |
7 /* global tb_click, tb_remove, tb_position */ |
8 |
8 |
9 jQuery( document ).ready( function( $ ) { |
9 jQuery( document ).ready( function( $ ) { |
10 |
10 |
11 var tbWindow, |
11 var tbWindow, |
12 $iframeBody, |
12 $iframeBody, |
148 } |
148 } |
149 } |
149 } |
150 |
150 |
151 /* |
151 /* |
152 * Open the Plugin details modal. The event is delegated to get also the links |
152 * Open the Plugin details modal. The event is delegated to get also the links |
153 * in the plugins search tab, after the AJAX search rebuilds the HTML. It's |
153 * in the plugins search tab, after the Ajax search rebuilds the HTML. It's |
154 * delegated on the closest ancestor and not on the body to avoid conflicts |
154 * delegated on the closest ancestor and not on the body to avoid conflicts |
155 * with other handlers, see Trac ticket #43082. |
155 * with other handlers, see Trac ticket #43082. |
156 */ |
156 */ |
157 $( '.wrap' ).on( 'click', '.thickbox.open-plugin-details-modal', function( e ) { |
157 $( '.wrap' ).on( 'click', '.thickbox.open-plugin-details-modal', function( e ) { |
158 // The `data-title` attribute is used only in the Plugin screens. |
158 // The `data-title` attribute is used only in the Plugin screens. |
159 var title = $( this ).data( 'title' ) ? plugininstallL10n.plugin_information + ' ' + $( this ).data( 'title' ) : plugininstallL10n.plugin_modal_label; |
159 var title = $( this ).data( 'title' ) ? |
|
160 wp.i18n.sprintf( |
|
161 // translators: %s: Plugin name. |
|
162 wp.i18n.__( 'Plugin: %s' ), |
|
163 $( this ).data( 'title' ) |
|
164 ) : |
|
165 wp.i18n.__( 'Plugin details' ); |
160 |
166 |
161 e.preventDefault(); |
167 e.preventDefault(); |
162 e.stopPropagation(); |
168 e.stopPropagation(); |
163 |
169 |
164 // Store the element that has focus before opening the modal dialog, i.e. the control which opens it. |
170 // Store the element that has focus before opening the modal dialog, i.e. the control which opens it. |
168 |
174 |
169 // Set ARIA role, ARIA label, and add a CSS class. |
175 // Set ARIA role, ARIA label, and add a CSS class. |
170 tbWindow |
176 tbWindow |
171 .attr({ |
177 .attr({ |
172 'role': 'dialog', |
178 'role': 'dialog', |
173 'aria-label': plugininstallL10n.plugin_modal_label |
179 'aria-label': wp.i18n.__( 'Plugin details' ) |
174 }) |
180 }) |
175 .addClass( 'plugin-details-modal' ); |
181 .addClass( 'plugin-details-modal' ); |
176 |
182 |
177 // Set title attribute on the iframe. |
183 // Set title attribute on the iframe. |
178 tbWindow.find( '#TB_iframeContent' ).attr( 'title', title ); |
184 tbWindow.find( '#TB_iframeContent' ).attr( 'title', title ); |
181 /* Plugin install related JS */ |
187 /* Plugin install related JS */ |
182 $( '#plugin-information-tabs a' ).click( function( event ) { |
188 $( '#plugin-information-tabs a' ).click( function( event ) { |
183 var tab = $( this ).attr( 'name' ); |
189 var tab = $( this ).attr( 'name' ); |
184 event.preventDefault(); |
190 event.preventDefault(); |
185 |
191 |
186 // Flip the tab |
192 // Flip the tab. |
187 $( '#plugin-information-tabs a.current' ).removeClass( 'current' ); |
193 $( '#plugin-information-tabs a.current' ).removeClass( 'current' ); |
188 $( this ).addClass( 'current' ); |
194 $( this ).addClass( 'current' ); |
189 |
195 |
190 // Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top. |
196 // Only show the fyi box in the description section, on smaller screen, |
|
197 // where it's otherwise always displayed at the top. |
191 if ( 'description' !== tab && $( window ).width() < 772 ) { |
198 if ( 'description' !== tab && $( window ).width() < 772 ) { |
192 $( '#plugin-information-content' ).find( '.fyi' ).hide(); |
199 $( '#plugin-information-content' ).find( '.fyi' ).hide(); |
193 } else { |
200 } else { |
194 $( '#plugin-information-content' ).find( '.fyi' ).show(); |
201 $( '#plugin-information-content' ).find( '.fyi' ).show(); |
195 } |
202 } |