From 91518f00700dfd0146cccabda57ccdb8c1c239dc Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Mon, 6 Apr 2015 00:59:16 +0000 Subject: [PATCH] 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 --- src/wp-admin/js/updates.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wp-admin/js/updates.js b/src/wp-admin/js/updates.js index 7f5f3b413d..ca4e597828 100644 --- a/src/wp-admin/js/updates.js +++ b/src/wp-admin/js/updates.js @@ -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 );