Make WordPress Core

Ticket #59689: 59689.6.diff

File 59689.6.diff, 2.5 KB (added by joedolson, 2 years ago)

Updated patch

  • src/js/_enqueues/admin/common.js

     
    21292129/**
    21302130 * Freeze animated plugin icons when reduced motion is enabled.
    21312131 *
    2132  * When the user has enabled the 'prefers-reduced-motion' setting, this module 
    2133  * stops animations for all GIFs on the page with the class 'plugin-icon' or 
     2132 * When the user has enabled the 'prefers-reduced-motion' setting, this module
     2133 * stops animations for all GIFs on the page with the class 'plugin-icon' or
    21342134 * plugin icon images in the update plugins table.
    21352135 *
    21362136 * @since 6.4.0
     
    21562156                        var width = img.width;
    21572157                        var height = img.height;
    21582158                        var canvas = document.createElement( 'canvas' );
    2159                        
     2159
    21602160                        // Set canvas dimensions.
    21612161                        canvas.width = width;
    21622162                        canvas.height = height;
     
    22192219
    22202220        // Listen for jQuery AJAX events.
    22212221        ( function( $ ) {
    2222                 $( document ).ajaxComplete( function( event, xhr, settings ) {
    2223                         // Check if this is the 'search-install-plugins' request.
    2224                         if ( settings.data && settings.data.includes( 'action=search-install-plugins' ) ) {
    2225                                 // Recheck if the user prefers reduced motion.
    2226                                 if ( window.matchMedia ) {
    2227                                         var mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' );
    2228                                         if ( mediaQuery.matches ) {
    2229                                                 pub.freezeAll();
     2222                if ( window.pagenow === 'plugin-install' ) {
     2223                        // Only listen for ajaxComplete if this is the plugin-install.php page.
     2224                        $( document ).ajaxComplete( function( event, xhr, settings ) {
     2225
     2226                                // Check if this is the 'search-install-plugins' request.
     2227                                if ( settings.data && typeof settings.data === 'string' && settings.data.includes( 'action=search-install-plugins' ) ) {
     2228                                        // Recheck if the user prefers reduced motion.
     2229                                        if ( window.matchMedia ) {
     2230                                                var mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' );
     2231                                                if ( mediaQuery.matches ) {
     2232                                                        pub.freezeAll();
     2233                                                }
     2234                                        } else {
     2235                                                // Fallback for browsers that don't support matchMedia.
     2236                                                if ( true === priv.pauseAll ) {
     2237                                                        pub.freezeAll();
     2238                                                }
    22302239                                        }
    2231                                 } else {
    2232                                         // Fallback for browsers that don't support matchMedia.
    2233                                         if ( true === priv.pauseAll ) {
    2234                                                 pub.freezeAll();
    2235                                         }
    22362240                                }
    2237                         }
    2238                 } );
     2241                        } );
     2242                }
    22392243        } )( jQuery );
    22402244
    22412245        // Expose public methods.