From ca97e64c503e25a1d0785d752336753abbb56374 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 10 Jul 2014 00:59:13 +0000 Subject: [PATCH] Revisions: Explicitly set the 'from' handle position when switching from two-handled mode back to single-handled mode. props adamsilverstein. fixes #26793. git-svn-id: https://develop.svn.wordpress.org/trunk@29052 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/revisions.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/js/revisions.js b/src/wp-admin/js/revisions.js index 48866d6ffc..521e55ce09 100644 --- a/src/wp-admin/js/revisions.js +++ b/src/wp-admin/js/revisions.js @@ -399,11 +399,23 @@ window.wp = window.wp || {}; }, changeMode: function( model, value ) { - // If we were on the first revision before switching, we have to bump them over one - if ( value && 0 === this.revisions.indexOf( this.get('to') ) ) { + var toIndex = this.revisions.indexOf( this.get( 'to' ) ); + + // If we were on the first revision before switching to two-handled mode, + // bump the 'to' position over one + if ( value && 0 === toIndex ) { this.set({ - from: this.revisions.at(0), - to: this.revisions.at(1) + from: this.revisions.at( toIndex ), + to: this.revisions.at( toIndex + 1 ) + }); + } + + // When switching back to single-handled mode, reset 'from' model to + // one position before the 'to' model + if ( ! value && 0 !== toIndex ) { // '! value' means switching to single-handled mode + this.set({ + from: this.revisions.at( toIndex - 1 ), + to: this.revisions.at( toIndex ) }); } },