WordPress.org

Make WordPress Core

Changeset 32126


Ignore:
Timestamp:
04/14/2015 04:41:24 PM (4 years ago)
Author:
jorbin
Message:

Use named function instead of anonymous function

The named function is testable and replaceable.

Fixes #31964
Props DavidAnderson, adamsilverstein, jorbin

File:
1 edited

Legend:

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

    r32082 r32126  
    418418        wp.a11y.speak( wp.updates.l10n.updateCancel );
    419419    };
     420    /**
     421     * Potentially add an AYS to a user attempting to leave the page
     422     *
     423     * If an update is on-going and a user attempts to leave the page,
     424     * open an "Are you sure?" alert.
     425     *
     426     * @since 4.2.0
     427     */
     428
     429    wp.updates.beforeunload = function() {
     430        if ( wp.updates.updateLock ) {
     431            return wp.updates.l10n.beforeunload;
     432        }
     433    };
     434
    420435
    421436    $( document ).ready( function() {
     
    531546        }
    532547
    533 
    534 
    535548    } );
    536549
    537     /*
    538      * If an update is on-going and a user attempts to leave the page,
    539      * open an "Are you sure?" alert.
    540      */
    541     $( window ).on( 'beforeunload', function() {
    542         if ( wp.updates.updateLock ) {
    543             return wp.updates.l10n.beforeunload;
    544         }
    545     });
     550    $( window ).on( 'beforeunload', wp.updates.beforeunload );
    546551
    547552})( jQuery, window.wp, window.pagenow, window.ajaxurl );
Note: See TracChangeset for help on using the changeset viewer.