Make WordPress Core

Changeset 24019


Ignore:
Timestamp:
04/17/2013 07:34:21 PM (12 years ago)
Author:
ocean90
Message:

Revisions: Clean up JavaScript variable names, see #23901.

Location:
trunk/wp-admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/colors-classic.css

    r23995 r24019  
    14841484}
    14851485
    1486 .revision-tick.loading-true {
     1486.revision-tick.completed-false {
    14871487    background-color: #9999cc;
    14881488    background: url(../images/wpspin_light.gif) no-repeat;
     
    14911491}
    14921492
    1493 .revision-tick.loading-false {
     1493.revision-tick.completed-true {
    14941494    background-color: #aaa;
    14951495}
  • trunk/wp-admin/css/colors-fresh.css

    r23995 r24019  
    13781378}
    13791379
    1380 .revision-tick.loading-true {
     1380.revision-tick.completed-false {
    13811381    background-color: #9999cc;
    13821382    background: url(../images/wpspin_light.gif) no-repeat;
     
    13851385}
    13861386
    1387 .revision-tick.loading-false {
     1387.revision-tick.completed-true {
    13881388    background-color: #aaa;
    13891389}
  • trunk/wp-admin/includes/ajax-actions.php

    r23994 r24019  
    21652165        $all_the_revisions = array (
    21662166            'diff'          => $content,
    2167             'lines_deleted' => $lines_deleted,
    2168             'lines_added'   => $lines_added
     2167            'linesDeleted' => $lines_deleted,
     2168            'linesAdded'   => $lines_added
    21692169        );
    21702170
     
    22742274        if ( ( $compare_two_mode || -1 !== $previous_revision_id ) ) {
    22752275            $all_the_revisions[] = array (
    2276                 'ID'                   => $revision->ID,
    2277                 'titleTo'              => $revision_date_author,
    2278                 'titleFrom'            => $revision_from_date_author,
    2279                 'titleTooltip'         => $revision_date_author_short,
    2280                 'restoreLink'          => urldecode( $restore_link ),
    2281                 'revision_toload'      => true,
    2282                 'previous_revision_id' => $previous_revision_id,
    2283                 'is_current_revision'  => $is_current_revision,
     2276                'ID'           => $revision->ID,
     2277                'titleTo'      => $revision_date_author,
     2278                'titleFrom'    => $revision_from_date_author,
     2279                'titleTooltip' => $revision_date_author_short,
     2280                'restoreLink'  => urldecode( $restore_link ),
     2281                'previousID'   => $previous_revision_id,
     2282                'isCurrent'    => $is_current_revision,
    22842283            );
    22852284        }
  • trunk/wp-admin/js/revisions.js

    r23915 r24019  
    6060        },
    6161
    62         reloadToLoadRevisions: function( models, reverse_direction ) {
     62        loadDiffs: function( models ) {
    6363            var self = this,
    64                 revisionsToLoad = models.where( { revision_toload: true } ),
     64                revisionsToLoad = models.where( { completed: false } ),
    6565                delay = 0;
    6666
     
    7878                            remove: false,
    7979                            success: function( model ) {
    80                                 model.set( 'revision_toload', 'false' );
     80                                model.set( 'completed', true );
    8181
    8282                                // stop spinner when all models are loaded
    83                                 if ( 0 === models.where( { revision_toload: true } ).length )
     83                                if ( 0 === models.where( { completed: false } ).length )
    8484                                    self.stopModelLoadingSpinner();
    8585
    8686                                self.tickmarkView.render();
    8787
    88                                 var total_changes = model.get( 'lines_added' ) + model.get( 'lines_deleted'),
    89                                     scope_of_changes = 'vsmall';
     88                                var totalChanges = model.get( 'linesAdded' ) + model.get( 'linesDeleted' ),
     89                                    scopeOfChanges = 'vsmall';
    9090
    9191                                // Note: hard coded scope of changes
    9292                                // TODO change to dynamic based on range of values
    93                                 if  ( total_changes > 1 && total_changes <= 3 ) {
    94                                     scope_of_changes = 'small';
    95                                 } else if( total_changes > 3 && total_changes <= 5 ) {
    96                                     scope_of_changes = 'med';
    97                                 } else if( total_changes > 5 && total_changes <= 10 ) {
    98                                     scope_of_changes = 'large';
    99                                 } else if( total_changes > 10 ) {
    100                                     scope_of_changes = 'vlarge';
     93                                if ( totalChanges > 1 && totalChanges <= 3 ) {
     94                                    scopeOfChanges = 'small';
     95                                } else if ( totalChanges > 3 && totalChanges <= 5 ) {
     96                                    scopeOfChanges = 'med';
     97                                } else if ( totalChanges > 5 && totalChanges <= 10 ) {
     98                                    scopeOfChanges = 'large';
     99                                } else if ( totalChanges > 10 ) {
     100                                    scopeOfChanges = 'vlarge';
    101101                                }
    102                                 model.set( 'scope_of_changes', scope_of_changes );
     102                                model.set( 'scopeOfChanges', scopeOfChanges );
    103103                                if ( 0 !== self.rightDiff &&
    104104                                    model.get( 'ID' ) === self.revisions.at( self.rightDiff - 1 ).get( 'ID' ) ) {
     
    150150            var self = this;
    151151
    152             // TODO: Only updates the query args yet
     152            self.startRightModelLoading();
     153
    153154            self.revisions.reload({
     155                options: {
    154156                'showAutosaves': self.autosaves,
    155157                'showSplitView': self.showSplitView
    156             });
    157 
    158             self.startRightModelLoading();
    159             self.revisions.fetch({ // reload revision data
     158                },
     159
    160160                success: function() {
    161161                    var revisionCount = self.revisions.length;
    162162                    self.revisionView.model = self.revisions;
    163163                    self.revisionView.render();
    164                     self.reloadToLoadRevisions( self.revisions );
     164                    self.loadDiffs( self.revisions );
    165165                    self.tickmarkView.model = self.revisions;
    166166                    self.tickmarkView.render();
     
    174174                    self.stopRightModelLoading();
    175175                }
    176 
    177176            });
    178177        },
     
    192191                success: function(){
    193192                    self.stopLeftModelLoading();
    194                     self.reloadToLoadRevisions( self.leftHandleRevisions );
     193                    self.loadDiffs( self.leftHandleRevisions );
    195194                    self.tickmarkView.model = self.leftHandleRevisions;
    196195                    self.slider.refresh({
     
    223222                success: function(){
    224223                    self.stopRightModelLoading();
    225                     self.reloadToLoadRevisions( self.rightHandleRevisions );
     224                    self.loadDiffs( self.rightHandleRevisions );
    226225                    self.tickmarkView.model = self.rightHandleRevisions;
    227226                    self.slider.refresh({
     
    251250            this.revisionView.render();
    252251
    253             this.reloadToLoadRevisions( this.revisions );
     252            this.loadDiffs( this.revisions );
    254253
    255254            this.revisionsInteractions = new revisions.view.Interact({
     
    263262            this.tickmarkView.render();
    264263            this.tickmarkView.resetTicks();
    265 
    266264        }
    267265    });
     
    450448
    451449        resetTicks: function() {
    452             var sliderMax = Diff.slider.option( 'max' );
     450            var sliderMax   = Diff.slider.option( 'max' );
    453451            var sliderWidth = Diff.slider.width();
    454             var adjustMax = Diff.singleRevision ? 0 : 1;
    455             var tickWidth = Math.floor( sliderWidth / ( sliderMax - adjustMax ) );
     452            var adjustMax   = Diff.singleRevision ? 0 : 1;
     453            var tickWidth   = Math.floor( sliderWidth / ( sliderMax - adjustMax ) );
    456454
    457455            // TODO: adjust right margins for wider ticks so they stay centered on handle stop point
     
    474472                });
    475473
    476                 if( ! Diff.singleRevision ) {
    477                     $( '.revision-tick' ).first().remove(); // TODO - remove the check
    478                 }
    479474                $( '.revision-tick' ).last().css( 'margin-right', '0' ); // last tick gets no right margin
    480475            }
     
    634629
    635630            // hide the restore button when on the last sport/current post data
    636             $( '#restore-revision' ).toggle( ! Diff.revisions.at( Diff.rightDiff - 1 ).get( 'is_current_revision' ) );
     631            $( '#restore-revision' ).toggle( ! Diff.revisions.at( Diff.rightDiff - 1 ).get( 'isCurrent' ) );
    637632
    638633            return this;
     
    687682    Revision = revisions.model.Revision = Backbone.Model.extend({
    688683        idAttribute: 'ID',
    689         urlRoot: ajaxurl +  '?action=revisions-data' +
    690             '&show_autosaves=true&show_split_view=true&nonce=' + revisions.model.settings.nonce,
     684
    691685        defaults: {
    692686            ID: 0,
     
    696690            diff: '<div class="diff-loading"><div class="spinner"></div></div>',
    697691            restoreLink: '',
    698             revision_toload: false,
    699             lines_added: 0,
    700             lines_deleted: 0,
    701             scope_of_changes: 'none',
    702             previous_revision_id: 0,
    703             is_current_revision: false
     692            completed: false,
     693            linesAdded: 0,
     694            linesDeleted: 0,
     695            scopeOfChanges: 'none',
     696            previousID: 0,
     697            isCurrent: false
    704698        },
    705699
    706700        url: function() {
    707701            if ( Diff.singleRevision ) {
    708                 return this.urlRoot +
     702                return ajaxurl +
     703                    '?action=revisions-data' +
     704                    '&show_autosaves=true' +
     705                    '&show_split_view=true' +
     706                    '&nonce=' + revisions.model.settings.nonce +
    709707                    '&single_revision_id=' + this.id +
    710                     '&compare_to=' + this.get( 'previous_revision_id' ) +
     708                    '&compare_to=' + this.get( 'previousID' ) +
    711709                    '&post_id=' + revisions.model.settings.post_id;
    712710            } else {
     
    722720    Revisions = revisions.Revisions = Backbone.Collection.extend({
    723721        model: Revision,
    724         urlRoot: ajaxurl + '?action=revisions-data',
    725722
    726723        initialize: function( models, options ) {
     
    737734
    738735        url: function() {
    739             return this.urlRoot +
     736            return ajaxurl +
     737                '?action=revisions-data' +
    740738                '&compare_to=' + this.options.compareTo +
    741739                '&post_id=' + this.options.post_id +
     
    748746
    749747        reload: function( options ) {
    750             this.options = _.defaults( options || {}, this.options );
    751 
    752             // TODO
    753             //this.fetch();
     748            this.options = _.defaults( options.options || {}, this.options );
     749
     750            this.fetch({
     751                success: options.success || null,
     752                error: options.error || null
     753            });
    754754        }
    755755
  • trunk/wp-admin/revision.php

    r23994 r24019  
    158158
    159159<script id="tmpl-revision-ticks" type="text/html">
    160     <div class="revision-tick loading-{{{ data.revision_toload }}} scope-of-changes-{{{ data.scope_of_changes }}}"></div>
     160    <div class="revision-tick completed-{{{ data.completed }}} scope-of-changes-{{{ data.scopeOfChanges }}}"></div>
    161161</script>
    162162<?php
Note: See TracChangeset for help on using the changeset viewer.