Ticket #23901: 23901.10-b.diff
File 23901.10-b.diff, 10.6 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
2164 2164 2165 2165 $all_the_revisions = array ( 2166 2166 'diff' => $content, 2167 'lines _deleted' => $lines_deleted,2168 'lines _added' => $lines_added2167 'linesDeleted' => $lines_deleted, 2168 'linesAdded' => $lines_added 2169 2169 ); 2170 2170 2171 2171 echo json_encode( $all_the_revisions ); … … 2273 2273 2274 2274 if ( ( $compare_two_mode || -1 !== $previous_revision_id ) ) { 2275 2275 $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, 2284 2283 ); 2285 2284 } 2286 2285 $previous_revision_id = $revision->ID; -
wp-admin/js/revisions.js
59 59 } 60 60 }, 61 61 62 reloadToLoadRevisions: function( models, reverse_direction) {62 loadDiffs: function( models ) { 63 63 var self = this, 64 revisionsToLoad = models.where( { revision_toload: true } ),64 revisionsToLoad = models.where( { completed: false } ), 65 65 delay = 0; 66 66 67 67 // match slider to passed revision_id … … 77 77 add: false, 78 78 remove: false, 79 79 success: function( model ) { 80 model.set( ' revision_toload', 'false');80 model.set( 'completed', true ); 81 81 82 82 // stop spinner when all models are loaded 83 if ( 0 === models.where( { revision_toload: true } ).length )83 if ( 0 === models.where( { completed: false } ).length ) 84 84 self.stopModelLoadingSpinner(); 85 85 86 86 self.tickmarkView.render(); 87 87 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'; 90 90 91 91 // Note: hard coded scope of changes 92 92 // 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'; 101 101 } 102 model.set( 'scope _of_changes', scope_of_changes );102 model.set( 'scopeOfChanges', scopeOfChanges ); 103 103 if ( 0 !== self.rightDiff && 104 104 model.get( 'ID' ) === self.revisions.at( self.rightDiff - 1 ).get( 'ID' ) ) { 105 105 // reload if current model refreshed … … 149 149 reloadModelSingle: function() { 150 150 var self = this; 151 151 152 // TODO: Only updates the query args yet 152 self.startRightModelLoading(); 153 153 154 self.revisions.reload({ 155 options: { 154 156 'showAutosaves': self.autosaves, 155 157 'showSplitView': self.showSplitView 156 });158 }, 157 159 158 self.startRightModelLoading();159 self.revisions.fetch({ // reload revision data160 160 success: function() { 161 161 var revisionCount = self.revisions.length; 162 162 self.revisionView.model = self.revisions; 163 163 self.revisionView.render(); 164 self. reloadToLoadRevisions( self.revisions );164 self.loadDiffs( self.revisions ); 165 165 self.tickmarkView.model = self.revisions; 166 166 self.tickmarkView.render(); 167 167 self.slider.refresh({ … … 173 173 error: function() { 174 174 self.stopRightModelLoading(); 175 175 } 176 177 176 }); 178 177 }, 179 178 … … 191 190 self.leftHandleRevisions.fetch({ 192 191 success: function(){ 193 192 self.stopLeftModelLoading(); 194 self. reloadToLoadRevisions( self.leftHandleRevisions );193 self.loadDiffs( self.leftHandleRevisions ); 195 194 self.tickmarkView.model = self.leftHandleRevisions; 196 195 self.slider.refresh({ 197 196 'max': self.revisions.length … … 222 221 self.rightHandleRevisions.fetch({ 223 222 success: function(){ 224 223 self.stopRightModelLoading(); 225 self. reloadToLoadRevisions( self.rightHandleRevisions );224 self.loadDiffs( self.rightHandleRevisions ); 226 225 self.tickmarkView.model = self.rightHandleRevisions; 227 226 self.slider.refresh({ 228 227 'max': self.revisions.length, … … 250 249 }); 251 250 this.revisionView.render(); 252 251 253 this. reloadToLoadRevisions( this.revisions );252 this.loadDiffs( this.revisions ); 254 253 255 254 this.revisionsInteractions = new revisions.view.Interact({ 256 255 model: this.revisions … … 262 261 }); 263 262 this.tickmarkView.render(); 264 263 this.tickmarkView.resetTicks(); 265 266 264 } 267 265 }); 268 266 … … 449 447 model: Revision, 450 448 451 449 resetTicks: function() { 452 var sliderMax = Diff.slider.option( 'max' );450 var sliderMax = Diff.slider.option( 'max' ); 453 451 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 ) ); 456 454 457 455 // TODO: adjust right margins for wider ticks so they stay centered on handle stop point 458 456 … … 473 471 $(this).css( 'margin-right', tickWidth - 1 + 'px'); // space the ticks out using right margin 474 472 }); 475 473 476 if( ! Diff.singleRevision ) {477 $( '.revision-tick' ).first().remove(); // TODO - remove the check478 }479 474 $( '.revision-tick' ).last().css( 'margin-right', '0' ); // last tick gets no right margin 480 475 } 481 476 … … 633 628 this.toggleCompareTwoCheckbox(); 634 629 635 630 // 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' ) ); 637 632 638 633 return this; 639 634 }, … … 686 681 */ 687 682 Revision = revisions.model.Revision = Backbone.Model.extend({ 688 683 idAttribute: 'ID', 689 urlRoot: ajaxurl + '?action=revisions-data' + 690 '&show_autosaves=true&show_split_view=true&nonce=' + revisions.model.settings.nonce, 684 691 685 defaults: { 692 686 ID: 0, 693 687 titleTo: '', … … 695 689 titleFrom: '', 696 690 diff: '<div class="diff-loading"><div class="spinner"></div></div>', 697 691 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: false692 completed: false, 693 linesAdded: 0, 694 linesDeleted: 0, 695 scopeOfChanges: 'none', 696 previousID: 0, 697 isCurrent: false 704 698 }, 705 699 706 700 url: function() { 707 701 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 + 709 707 '&single_revision_id=' + this.id + 710 '&compare_to=' + this.get( 'previous _revision_id' ) +708 '&compare_to=' + this.get( 'previousID' ) + 711 709 '&post_id=' + revisions.model.settings.post_id; 712 710 } else { 713 711 return this.collection.url() + '&single_revision_id=' + this.id; … … 721 719 */ 722 720 Revisions = revisions.Revisions = Backbone.Collection.extend({ 723 721 model: Revision, 724 urlRoot: ajaxurl + '?action=revisions-data',725 722 726 723 initialize: function( models, options ) { 727 724 this.options = _.defaults( options || {}, { … … 736 733 }, 737 734 738 735 url: function() { 739 return this.urlRoot + 736 return ajaxurl + 737 '?action=revisions-data' + 740 738 '&compare_to=' + this.options.compareTo + 741 739 '&post_id=' + this.options.post_id + 742 740 '&show_autosaves=' + this.options.showAutosaves + … … 747 745 }, 748 746 749 747 reload: function( options ) { 750 this.options = _.defaults( options || {}, this.options );748 this.options = _.defaults( options.options || {}, this.options ); 751 749 752 // TODO 753 //this.fetch(); 750 this.fetch({ 751 success: options.success || null, 752 error: options.error || null 753 }); 754 754 } 755 755 756 756 } ); -
wp-admin/revision.php
157 157 </script> 158 158 159 159 <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> 161 161 </script> 162 162 <?php 163 163 require_once( './admin-footer.php' ); -
wp-admin/css/colors-fresh.css
1377 1377 background-color: #f7f7f7; 1378 1378 } 1379 1379 1380 .revision-tick. loading-true {1380 .revision-tick.completed-false { 1381 1381 background-color: #9999cc; 1382 1382 background: url(../images/wpspin_light.gif) no-repeat; 1383 1383 background-position: middle; 1384 1384 background-size: 1px 10px; 1385 1385 } 1386 1386 1387 .revision-tick. loading-false {1387 .revision-tick.completed-true { 1388 1388 background-color: #aaa; 1389 1389 } 1390 1390 -
wp-admin/css/colors-classic.css
1483 1483 color: #0080aa; 1484 1484 } 1485 1485 1486 .revision-tick. loading-true {1486 .revision-tick.completed-false { 1487 1487 background-color: #9999cc; 1488 1488 background: url(../images/wpspin_light.gif) no-repeat; 1489 1489 background-position: middle; 1490 1490 background-size: 1px 10px; 1491 1491 } 1492 1492 1493 .revision-tick. loading-false {1493 .revision-tick.completed-true { 1494 1494 background-color: #aaa; 1495 1495 } 1496 1496