[wp-trac] [WordPress Trac] #24145: Confirm page close when writing on WordPress.org forums
WordPress Trac
noreply at wordpress.org
Sat Apr 20 20:06:05 UTC 2013
#24145: Confirm page close when writing on WordPress.org forums
--------------------------------+------------------------------
Reporter: Daedalon | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: WordPress.org site | Version:
Severity: normal | Resolution:
Keywords: |
--------------------------------+------------------------------
Comment (by Daedalon):
Here's a jQuery solution for confirming page close when any of the new
post fields have been modified.
{{{
var requireCloseConfirmation = false;
function confirmPageClose(){
if ( requireCloseConfirmation ) {
return 'Are you sure you want to close this page? All
changes will be lost.';
}
}
jQuery('#postform input[type=text], #postform select, #postform
textarea').change( function(){
requireCloseConfirmation = true;
});
if( jQuery('#postform').length ){
window.onbeforeunload = confirmPageClose;
}
}}}
This is triggered only if any one of these text areas has been changed
'''and''' it has lost focus at least once. In other words this protects
from most accidental closings except when user has changed only one field
without clicking outside it or otherwise moving focus away from it. This
should catch the vast majority of cases.
A timer-based script could cover even those that this does not. It would
check every XX seconds if any of the fields are non-empty, and if, sets
requireCloseConfirmation = true and terminates itself.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24145#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list