Make WordPress Core

Changeset 29052


Ignore:
Timestamp:
07/10/2014 12:59:13 AM (11 years ago)
Author:
SergeyBiryukov
Message:

Revisions: Explicitly set the 'from' handle position when switching from two-handled mode back to single-handled mode.

props adamsilverstein.
fixes #26793.

File:
1 edited

Legend:

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

    r27273 r29052  
    400400
    401401        changeMode: function( model, value ) {
    402             // If we were on the first revision before switching, we have to bump them over one
    403             if ( value && 0 === this.revisions.indexOf( this.get('to') ) ) {
     402            var toIndex = this.revisions.indexOf( this.get( 'to' ) );
     403
     404            // If we were on the first revision before switching to two-handled mode,
     405            // bump the 'to' position over one
     406            if ( value && 0 === toIndex ) {
    404407                this.set({
    405                     from: this.revisions.at(0),
    406                     to: this.revisions.at(1)
     408                    from: this.revisions.at( toIndex ),
     409                    to:   this.revisions.at( toIndex + 1 )
     410                });
     411            }
     412
     413            // When switching back to single-handled mode, reset 'from' model to
     414            // one position before the 'to' model
     415            if ( ! value && 0 !== toIndex ) { // '! value' means switching to single-handled mode
     416                this.set({
     417                    from: this.revisions.at( toIndex - 1 ),
     418                    to:   this.revisions.at( toIndex )
    407419                });
    408420            }
Note: See TracChangeset for help on using the changeset viewer.