WordPress.org

Make WordPress Core

Changeset 38227


Ignore:
Timestamp:
08/09/2016 10:38:28 AM (3 years ago)
Author:
ocean90
Message:

Updates: Add visual feedback when deleting themes/plugins.

This corrects the selector for the delete link in wp.updates.deletePlugin() so the text can be changed to 'Deleting…'. wp.updates.deleteTheme() already worked on wp-admin/themes.php but not on wp-admin/network/themes.php because the network screen is similar to the plugins list table, this is now fixed too.
The credential-modal-cancel handler has been updated to support canceled delete jobs.

Props swissspidy.
Props jorbin for review.
Fixes #37603.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/updates.js

    r38221 r38227  
    717717     */
    718718    wp.updates.deletePlugin = function( args ) {
    719         var $message = $( '[data-plugin="' + args.plugin + '"]' ).find( '.update-message p' );
     719        var $link = $( '[data-plugin="' + args.plugin + '"]' ).find( '.row-actions a.delete' );
    720720
    721721        args = _.extend( {
     
    724724        }, args );
    725725
    726         if ( $message.html() !== wp.updates.l10n.updating ) {
    727             $message.data( 'originaltext', $message.html() );
     726        if ( $link.html() !== wp.updates.l10n.deleting ) {
     727            $link
     728                .data( 'originaltext', $link.html() )
     729                .text( wp.updates.l10n.deleting );
    728730        }
    729731
     
    11691171     */
    11701172    wp.updates.deleteTheme = function( args ) {
    1171         var $button = $( '.theme-actions .delete-theme' );
     1173        var $button;
     1174
     1175        if ( 'themes' === pagenow ) {
     1176            $button = $( '.theme-actions .delete-theme' );
     1177        } else if ( 'themes-network' === pagenow ) {
     1178            $button = $( '[data-slug="' + args.slug + '"]' ).find( '.row-actions a.delete' );
     1179        }
    11721180
    11731181        args = _.extend( {
     
    11761184        }, args );
    11771185
    1178         if ( $button.html() !== wp.updates.l10n.deleting ) {
    1179             $button.data( 'originaltext', $button.html() );
    1180         }
    1181 
    1182         $button.text( wp.updates.l10n.deleting );
     1186        if ( $button && $button.html() !== wp.updates.l10n.deleting ) {
     1187            $button
     1188                .data( 'originaltext', $button.html() )
     1189                .text( wp.updates.l10n.deleting );
     1190        }
     1191
    11831192        wp.a11y.speak( wp.updates.l10n.deleting, 'polite' );
    11841193
     
    17111720                $updatingMessage.removeClass( 'updating-message' );
    17121721            } else if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
    1713                 $message = $( 'tr[data-plugin="' + job.data.plugin + '"]' ).find( '.update-message' );
     1722                if ( 'update-plugin' === job.action ) {
     1723                    $message = $( 'tr[data-plugin="' + job.data.plugin + '"]' ).find( '.update-message' );
     1724                } else if ( 'delete-plugin' === job.action ) {
     1725                    $message = $( '[data-plugin="' + job.data.plugin + '"]' ).find( '.row-actions a.delete' );
     1726                }
     1727            } else if ( 'themes' === pagenow || 'themes-network' === pagenow ) {
     1728                if ( 'update-theme' === job.action ) {
     1729                    $message = $( '[data-slug="' + job.data.slug + '"]' ).find( '.update-message' );
     1730                } else if ( 'delete-theme' === job.action && 'themes-network' === pagenow ) {
     1731                    $message = $( '[data-slug="' + job.data.slug + '"]' ).find( '.row-actions a.delete' );
     1732                } else if ( 'delete-theme' === job.action && 'themes' === pagenow ) {
     1733                    $message = $( '.theme-actions .delete-theme' );
     1734                }
    17141735            } else {
    17151736                $message = $updatingMessage;
Note: See TracChangeset for help on using the changeset viewer.