Make WordPress Core

Ticket #24425: 24425.draft.33.diff

File 24425.draft.33.diff, 3.0 KB (added by adamsilverstein, 12 years ago)

routing fixes, other minor changes

  • wp-admin/js/revisions.js

     
    394394                template: wp.template( 'revisions-tooltip' ),
    395395
    396396                initialize: function() {
    397                         this.listenTo( this.model, 'change:sliderHovering', this.sliderHoveringChanged );
     397                        this.listenTo( this.model, 'change:showTooltip', this.sliderHoveringChanged );
    398398                        this.listenTo( this.model, 'change:tooltipPosition', this.tooltipPositionChanged );
    399399                },
    400400
    401401                ready: function() {
    402402                },
    403403
    404                 // Show or hide tooltip based on sliderHovering is true
     404                // Show or hide tooltip based on showTooltip is true
    405405                sliderHoveringChanged: function() {
    406                         if ( this.model.get( 'sliderHovering' ) ) {
     406                        if ( this.model.get( 'showTooltip' ) ) {
    407407                                this.$el.show();
    408408                        } else {
    409409                                this.$el.hide();
     
    521521                        // Find the initially selected revision
    522522                        var initiallySelectedRevisionIndex =
    523523                                this.model.revisions.indexOf(
    524                                         this.model.revisions.findWhere(  { id: Number( revisions.settings.selectedRevision ) } ) );
     524                                        this.model.revisions.findWhere( { id: Number( revisions.settings.selectedRevision ) } ) );
    525525
    526526                        this.settings = new revisions.model.Slider({
    527527                                max:   latestRevisionIndex,
     
    533533                },
    534534
    535535                ready: function() {
     536                        // Refresh the currently selected revision position in case router has set it.
     537                        this.settings.attributes.value = this.model.revisions.indexOf(
     538                                this.model.revisions.findWhere( { id: Number( revisions.settings.selectedRevision ) } ) );
     539                        this.slide( '', this.settings.attributes );
     540
    536541                        this.$el.slider( this.settings.toJSON() );
    537542
    538543                        // Listen for changes in Compare Two Mode setting
    539544                        this.listenTo( this.model, 'change:compareTwoMode', this.updateSliderSettings );
    540545
    541                         this.settings.on( 'change', function( model, options ) {
     546                        this.settings.on( 'change', function() {
    542547                                this.updateSliderSettings();
    543548                        }, this );
    544549
    545550                        // Listen for changes in the diffId
    546551                        this.listenTo( this.model, 'change:diffId', this.diffIdChanged );
    547552
    548                         // Reset to the initially selected revision
    549                         this.slide( '', this.settings.attributes );
    550 
    551553                },
    552554
    553555                mousemove: function( e ) {
     
    574576                },
    575577
    576578                mouseenter: function( e ) {
    577                         this.model.set( 'sliderHovering', true );
     579                        this.model.set( 'showTooltip', true );
    578580                },
    579581
    580582                mouseleave: function( e ) {
    581                         this.model.set( 'sliderHovering', false );
     583                        this.model.set( 'showTooltip', false );
    582584                },
    583585
    584586                updateSliderSettings: function() {
     
    740742                }, 250 ),
    741743
    742744                gotoRevisionId: function( from, to, handles ) {
    743                         if ( '2' === handles ) {
    744                                 this.model.set( { compareTwoMode: true } );
    745                         } else {
    746                                 this.model.set( { compareTwoMode: false } );
    747                         }
     745                        this.model.set( { compareTwoMode: '2' === handles } );
    748746
    749747                        if ( 'undefined' !== typeof this.model ) {
    750748                                var selectedToRevision =
     
    756754                                        to:   selectedToRevision,
    757755                                        from: selectedFromRevision } );
    758756                        }
     757                        revisions.settings.selectedRevision = to;
    759758                }
    760759        });
    761760