Make WordPress Core

Changeset 27951


Ignore:
Timestamp:
04/05/2014 01:28:35 AM (11 years ago)
Author:
azaozz
Message:

When autosaving a new post for the first time after a title was typed, cancel the autosave if the user is submitting the form. (Includes a precommit fix for customize-controls.css.) Props Nessworthy, davidmarichal, fixes #27657

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/customize-controls.css

    r27947 r27951  
    537537    top: 0; left: 0; bottom: 0; right: 0;
    538538    border: 4px solid #2ea2cc;
     539    -webkit-border-radius: 2px;
    539540    border-radius: 2px;
    540541}
  • trunk/src/wp-admin/js/post.js

    r27941 r27951  
    505505    if ( $( '#auto_draft' ).val() ) {
    506506        $( '#title' ).blur( function() {
     507            var cancel;
     508
    507509            if ( ! this.value || $('#edit-slug-box > *').length ) {
    508510                return;
    509511            }
    510512
    511             if ( wp.autosave ) {
    512                 wp.autosave.server.triggerSave();
    513             }
     513            // Cancel the autosave when the blur was triggered by the user submitting the form
     514            $('form#post').one( 'submit', function() {
     515                cancel = true;
     516            });
     517
     518            window.setTimeout( function() {
     519                if ( ! cancel && wp.autosave ) {
     520                    wp.autosave.server.triggerSave();
     521                }
     522            }, 200 );
    514523        });
    515524    }
Note: See TracChangeset for help on using the changeset viewer.