[wp-meta] [Making WordPress.org] #155: Confirm page close when writing on WordPress.org forums

Making WordPress.org noreply at wordpress.org
Fri Sep 13 17:55:15 UTC 2013


#155: Confirm page close when writing on WordPress.org forums
--------------------------+------------------------------------
  Reporter:  Daedalon     |      Owner:
      Type:  enhancement  |     Status:  new
  Priority:  lowest       |  Component:  Support Forums
Resolution:               |   Keywords:  has-patch dev-feedback
--------------------------+------------------------------------
Changes (by Daedalon):

 * keywords:   => has-patch dev-feedback


Comment:

 Here's an improved solution based on the earlier one in #wp24145 and
 comments in Stack Overflow. Uses addEventListener to avoid overriding
 other listeners and includes a workaround for clients that don't support
 it.

 {{{
 if( $('#postform').length ){
     requireConfirmClose = false;
     $('#postform input[type=text], #postform select, #postform
 textarea').change( function(){
         requireConfirmClose = true;
     });
     $('input#postformsub').click( function(){
         requireConfirmClose = false;
     });
     // Workaround for browsers without addEventListener support
     if (typeof window.addEventListener === 'undefined') {
         window.addEventListener = function(e, callback) {
             return window.attachEvent('on' + e, callback);
         }
     }
     window.addEventListener('beforeunload', function(eventObject) {
         if ( requireConfirmClose ) {
             eventObject.returnValue = 'Are you sure you want to close this
 page? All changes will be lost.';
         }
     });
 }
 }}}

--
Ticket URL: <http://meta.trac.wordpress.org/ticket/155#comment:1>
Making WordPress.org <http://meta.trac.wordpress.org/>
WordPress blogging software


More information about the wp-meta mailing list