Making WordPress.org

Changeset 304


Ignore:
Timestamp:
01/22/2014 05:05:33 AM (11 years ago)
Author:
nacin
Message:

Trac: Add onbeforeunload save alerts for new tickets and comments. fixes #290.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js

    r303 r304  
    143143                    window.open( $( this ).attr( 'href' ) );
    144144                });
     145
     146                // Rudimentary save alerts for new tickets (summary/description) and comments.
     147                window.onbeforeunload = function() {
     148                    if ( window.location.pathname === '/newticket' ) {
     149                        if ( 0 === $( '#field-description' ).val().length && 0 === $( '#field-summary' ).val().length ) {
     150                            return;
     151                        }
     152                    } else if ( 0 === $( '#comment' ).val().length ) {
     153                        return;
     154                    }
     155                    return 'The changes you made will be lost if you navigate away from this page.';
     156                };
    145157            }
    146158
Note: See TracChangeset for help on using the changeset viewer.