Revisions: Simplify how URLs are updated. See #24425.

git-svn-id: http://core.svn.wordpress.org/trunk@24606 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2013-07-09 08:14:38 +00:00
parent 2f9ef11796
commit c21c38722c
1 changed files with 9 additions and 16 deletions

View File

@ -412,7 +412,7 @@ window.wp = window.wp || {};
this.model.set({ compareTwoMode: $('.compare-two-revisions').prop('checked') }); this.model.set({ compareTwoMode: $('.compare-two-revisions').prop('checked') });
// Update route // Update route
this.model.revisionsRouter.navigateRoute( this.model.get('to').id, this.model.get('from').id ); this.model.revisionsRouter.updateUrl();
}, },
ready: function() { ready: function() {
@ -498,7 +498,7 @@ window.wp = window.wp || {};
this.model.set( attributes ); this.model.set( attributes );
// Update route // Update route
this.model.revisionsRouter.navigateRoute( attributes.to.id, attributes.from ? attributes.from.id : 0 ); this.model.revisionsRouter.updateUrl();
}, },
// Go to the 'next' revision, direction takes into account RTL mode. // Go to the 'next' revision, direction takes into account RTL mode.
@ -796,27 +796,20 @@ window.wp = window.wp || {};
this.model = options.model; this.model = options.model;
// Maintain state history when dragging // Maintain state history when dragging
this.listenTo( this.model, 'renderDiff', this.updateURL ); this.listenTo( this.model, 'renderDiff', _.debounce( this.updateUrl, 250 ) );
}, },
routes: { routes: {
'revision/from/:from/to/:to/handles/:handles': 'gotoRevisionId' 'revision/from/:from/to/:to/handles/:handles': 'gotoRevisionId'
}, },
navigateRoute: function( to, from ) { updateUrl: function() {
var navigateTo = '/revision/from/' + from + '/to/' + to + '/handles/'; var from = this.model.has('from') ? this.model.get('from').id : 0;
if ( this.model.get('compareTwoMode') ) { var to = this.model.get('to').id;
navigateTo += '2'; var handles = this.model.get('compareTwoMode') ? '2' : '1';
} else {
navigateTo += '1';
}
this.navigate( navigateTo );
},
updateURL: _.debounce( function() { this.navigate( '/revision/from/' + from + '/to/' + to + '/handles/' + handles );
var from = this.model.get('from'); },
this.navigateRoute( this.model.get('to').id, from ? from.id : 0 );
}, 250 ),
gotoRevisionId: function( from, to, handles ) { gotoRevisionId: function( from, to, handles ) {
from = parseInt( from, 10 ); from = parseInt( from, 10 );