Make WordPress Core

Ticket #26035: 26035.patch

File 26035.patch, 4.1 KB (added by seanchayes, 12 years ago)
  • src/wp-includes/js/autosave.js

     
    1 var autosave, autosaveLast = '', autosavePeriodical, autosaveDelayPreview = false, notSaved = true, blockSave = false, fullscreen, autosaveLockRelease = true;
     1/* global switchEditors, autosaveL10n, tinymce, ajaxurl, wpAjax, makeSlugeditClickable, wpCookies  */
     2var autosave, autosaveLast = '', autosavePeriodical, autosaveDelayPreview = false, notSaved = true, blockSave = false, fullscreen, autosaveLockRelease = true, doPreview;
    23
    34jQuery(document).ready( function($) {
    45
     
    1516        autosavePeriodical = $.schedule({time: autosaveL10n.autosaveInterval * 1000, func: function() { autosave(); }, repeat: true, protect: true});
    1617
    1718        //Disable autosave after the form has been submitted
    18         $("#post").submit(function() {
     19        $('#post').submit(function() {
    1920                $.cancel(autosavePeriodical);
    2021                autosaveLockRelease = false;
    2122        });
     
    106107                }
    107108
    108109                $('input#wp-preview').val('');
    109         }
     110        };
    110111
    111112        // This code is meant to allow tabbing from Title to Post content.
    112113        $('#title').on('keydown.editor-focus', function(e) {
     
    120121                                ed = tinymce.get('content');
    121122
    122123                        if ( ed && !ed.isHidden() ) {
    123                                 $(this).one('keyup', function(e){
     124                                $(this).one('keyup', function(){
    124125                                        $('#content_tbl td.mceToolbar > a').focus();
    125126                                });
    126127                        } else {
     
    282283                return false;
    283284
    284285        // No autosave while thickbox is open (media buttons)
    285         if ( jQuery("#TB_window").css('display') == 'block' )
     286        if ( jQuery('#TB_window').css('display') == 'block' )
    286287                return false;
    287288
    288289        compareString = wp.autosave.getCompareString( post_data );
     
    292293                return false;
    293294
    294295        autosaveLast = compareString;
    295         jQuery(document).triggerHandler('wpcountwords', [ post_data["content"] ]);
     296        jQuery(document).triggerHandler('wpcountwords', [ post_data.content ]);
    296297
    297298        // Disable buttons until we know the save completed.
    298299        autosave_disable_buttons();
    299300
    300         if ( post_data["auto_draft"] == '1' ) {
     301        if ( post_data.auto_draft == '1' ) {
    301302                successCallback = autosave_saved_new; // new post
    302303        } else {
    303304                successCallback = autosave_saved; // pre-existing post
     
    306307        jQuery.ajax({
    307308                data: post_data,
    308309                beforeSend: autosave_loading,
    309                 type: "POST",
     310                type: 'POST',
    310311                url: ajaxurl,
    311312                success: successCallback
    312313        });
    313314
    314315        return true;
    315 }
     316};
    316317
    317318// Autosave in localStorage
    318319// set as simple object/mixin for now
     
    347348        }
    348349
    349350        if ( typeof fullscreen != 'undefined' && fullscreen.settings.visible ) {
    350                 data['post_title'] = $('#wp-fullscreen-title').val() || '';
    351                 data['content'] = $('#wp_mce_fullscreen').val() || '';
     351                data.post_title = $('#wp-fullscreen-title').val() || '';
     352                data.content = $('#wp_mce_fullscreen').val() || '';
    352353        } else {
    353                 data['post_title'] = $('#title').val() || '';
    354                 data['content'] = $('#content').val() || '';
     354                data.post_title = $('#title').val() || '';
     355                data.content = $('#content').val() || '';
    355356        }
    356357
    357358        /*
     
    364365        $('input[id^="in-category-"]:checked').each( function() {
    365366                cats.push(this.value);
    366367        });
    367         data['catslist'] = cats.join(',');
     368        data.catslist = cats.join(',');
    368369
    369370        if ( post_name = $('#post_name').val() )
    370                 data['post_name'] = post_name;
     371                data.post_name = post_name;
    371372
    372373        if ( parent_id = $('#parent_id').val() )
    373                 data['parent_id'] = parent_id;
     374                data.parent_id = parent_id;
    374375
    375376        if ( $('#comment_status').prop('checked') )
    376                 data['comment_status'] = 'open';
     377                data.comment_status = 'open';
    377378
    378379        if ( $('#ping_status').prop('checked') )
    379                 data['ping_status'] = 'open';
     380                data.ping_status = 'open';
    380381
    381382        if ( $('#auto_draft').val() == '1' )
    382                 data['auto_draft'] = '1';
     383                data.auto_draft = '1';
    383384
    384385        return data;
    385386};
     
    520521                if ( compareString == this.lastSavedData )
    521522                        return false;
    522523
    523                 post_data['save_time'] = (new Date()).getTime();
    524                 post_data['status'] = $('#post_status').val() || '';
     524                post_data.save_time = (new Date()).getTime();
     525                post_data.status = $('#post_status').val() || '';
    525526                result = this.setData( post_data );
    526527
    527528                if ( result )