Plugin Install: fix edge-case where the tab=upload page can be accessed directly.

The `?tab=upload` page still exists for no-js support and for users who may
access it directly (e.g. from bookmarks or history) or plugins doing the same.
In this page, the "Browse plugins" link should always behave like a link.

Fixes #35429.

git-svn-id: https://develop.svn.wordpress.org/trunk@37681 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrea Fercia 2016-06-10 22:38:57 +00:00
parent 18ef7d6225
commit 2aebf33f9d
1 changed files with 20 additions and 16 deletions

View File

@ -11,7 +11,9 @@ jQuery( document ).ready( function( $ ) {
$iframeBody, $iframeBody,
$tabbables, $tabbables,
$firstTabbable, $firstTabbable,
$lastTabbable; $lastTabbable,
uploadViewToggle = $( '.upload-view-toggle' ),
$body = $( document.body );
tb_position = function() { tb_position = function() {
var width = $( window ).width(), var width = $( window ).width(),
@ -53,7 +55,7 @@ jQuery( document ).ready( function( $ ) {
* Custom events: when a Thickbox iframe has loaded and when the Thickbox * Custom events: when a Thickbox iframe has loaded and when the Thickbox
* modal gets removed from the DOM. * modal gets removed from the DOM.
*/ */
$( 'body' ) $body
.on( 'thickbox:iframe:loaded', tbWindow, function() { .on( 'thickbox:iframe:loaded', tbWindow, function() {
iframeLoaded(); iframeLoaded();
}) })
@ -180,19 +182,21 @@ jQuery( document ).ready( function( $ ) {
/* /*
* When a user presses the "Upload Plugin" button, show the upload form in place * When a user presses the "Upload Plugin" button, show the upload form in place
* rather than sending them to the devoted upload plugin page. * rather than sending them to the devoted upload plugin page.
* @todo consider to abstract this in a generic, reusable, utility, see theme.js * The `?tab=upload` page still exists for no-js support and for plugins that
* might access it directly (?). When we're in this page, let the link behave
* like a link. Otherwise we're in the normal plugin installer pages and the
* link should behave like a toggle button.
*/ */
var uploadViewToggle = $( '.upload-view-toggle' ), if ( ! uploadViewToggle.hasClass( 'upload-tab' ) ) {
$body = $( document.body ); uploadViewToggle
.attr({
uploadViewToggle role: 'button',
.attr({ 'aria-expanded': 'false'
role: 'button', })
'aria-expanded': 'false' .on( 'click', function( event ) {
}) event.preventDefault();
.on( 'click', function( event ) { $body.toggleClass( 'show-upload-view' );
event.preventDefault(); uploadViewToggle.attr( 'aria-expanded', $body.hasClass( 'show-upload-view' ) );
$body.toggleClass( 'show-upload-view' ); });
uploadViewToggle.attr( 'aria-expanded', $body.hasClass( 'show-upload-view' ) ); }
});
}); });