Conditionally add AYS to leaving shiny updates

When a shiny update is happening or pending, we should make sure users don't accidentally leave the page. This simple notification should help prevent users from accidentally not updating when they want to update.

See #31769
Props ericlewis and adamsilverstein for initial patch



git-svn-id: https://develop.svn.wordpress.org/trunk@32052 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Aaron Jorbin 2015-04-06 00:59:16 +00:00
parent f64bf71719
commit 91518f0070
1 changed files with 10 additions and 0 deletions

View File

@ -510,4 +510,14 @@ window.wp = window.wp || {};
} );
/*
* If an update is on-going and a user attempts to leave the page,
* open an "Are you sure?" alert.
*/
$( window ).on( 'beforeunload', function() {
if ( wp.updates.updateLock ) {
return wp.updates.l10n.beforeunload;
}
});
})( jQuery, window.wp, window.pagenow, window.ajaxurl );