Ticket #24425: 24425.history-debounce.diff
File 24425.history-debounce.diff, 2.2 KB (added by , 10 years ago) |
---|
-
wp-admin/js/revisions.js
window.wp = window.wp || {}; 195 195 this.diffs = new revisions.model.Diffs( [], {revisions: this.revisions} ); 196 196 this.listenTo( this, 'change:from', this.updateDiffFrom ); 197 197 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 }); 200 199 }, 201 200 202 201 updateDiffTo: function() { 203 202 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 ); 206 204 }, 207 205 208 206 updateDiffFrom: function() { … … window.wp = window.wp || {}; 268 266 this.views.set( '.revisions-diff-frame', new revisions.view.Diff({ 269 267 model: diff 270 268 })); 269 this.model.trigger( 'renderDiff' ); 271 270 }); 272 271 } 273 272 }); … … window.wp = window.wp || {}; 684 683 this.model.unset('from', { silent: true }); 685 684 } 686 685 this.model.set( attributes ); 687 688 // Maintain state history when dragging689 this.model.revisionsRouter.navigateRoute( attributes.to.id, ( attributes.from ? attributes.from.id : 0 ) );690 686 }, 691 687 692 688 stop: function( event, ui ) { … … window.wp = window.wp || {}; 717 713 // The revisions router 718 714 // takes URLs with #hash fragments and routes them 719 715 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 }, 721 722 722 723 routes: { 723 724 'revision/from/:from/to/:to/handles/:handles': 'gotoRevisionId' … … window.wp = window.wp || {}; 733 734 this.navigate( navigateTo ); 734 735 }, 735 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 ), 741 736 742 gotoRevisionId: function( from, to, handles ) { 737 743 if ( '2' === handles ) { 738 744 this.model.set( { compareTwoMode: true } );