Make WordPress Core

Changeset 24556


Ignore:
Timestamp:
07/04/2013 08:30:36 AM (13 years ago)
Author:
markjaquith
Message:

Debounce the Revisions UI URL updates as you scrub, for a massive speedup and a reduction in URL history detritus.

see #24425

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/revisions.js

    r24549 r24556  
    196196                        this.listenTo( this, 'change:from', this.updateDiffFrom );
    197197                        this.listenTo( this, 'change:to', this.updateDiffTo );
    198                         this.revisionsRouter = new revisions.router.Router();
    199                         this.revisionsRouter.model = this;
     198                        this.revisionsRouter = new revisions.router.Router({ model: this });
    200199                },
    201200
    202201                updateDiffTo: function() {
    203202                        var from = this.get( 'from' );
    204                         var to   = this.get( 'to' );
    205                         this.set( 'diffId', (from ? from.id : '0' ) + ':' + to.id );
     203                        this.set( 'diffId', (from ? from.id : '0' ) + ':' + this.get('to').id );
    206204                },
    207205
    … …  
    269267                                        model: diff
    270268                                }));
     269                                this.model.trigger( 'renderDiff' );
    271270                        });
    272271                }
    … …  
    685684                        }
    686685                        this.model.set( attributes );
    687 
    688                         // Maintain state history when dragging
    689                         this.model.revisionsRouter.navigateRoute( attributes.to.id, ( attributes.from ? attributes.from.id : 0 ) );
    690686                },
    691687
    … …  
    718714        // takes URLs with #hash fragments and routes them
    719715        revisions.router.Router = Backbone.Router.extend({
    720                 model: null,
     716                initialize: function( options ) {
     717                        this.model = options.model;
     718
     719                        // Maintain state history when dragging
     720                        this.listenTo( this.model, 'renderDiff', this.updateURL );
     721                },
    721722
    722723                routes: {
    … …  
    733734                        this.navigate( navigateTo );
    734735                },
     736
     737                updateURL: _.debounce( function() {
     738                        var from = this.model.get('from');
     739                        this.navigateRoute( this.model.get('to').id, from ? from.id : 0 );
     740                }, 250 ),
    735741
    736742                gotoRevisionId: function( from, to, handles ) {
Note: See TracChangeset for help on using the changeset viewer.