Changeset 24667
- Timestamp:
- 07/12/2013 05:11:56 AM (11 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/wp-admin.css
r24660 r24667 3539 3539 } 3540 3540 3541 .revisions .loading-indicator { 3542 position: absolute; 3543 text-align: center; 3544 vertical-align: middle; 3545 opacity: 0; 3546 margin: 0 auto; 3547 width: 100%; 3548 height: 32px; 3549 top: 3em; 3550 background: #fff url(../images/wpspin_light-2x.gif) no-repeat center top; 3551 -webkit-transition: opacity 0.5s; 3552 -moz-transition: opacity 0.5s; 3553 -ms-transition: opacity 0.5s; 3554 -o-transition: opacity 0.5s; 3555 transition: opacity 0.5s; 3556 } 3557 3558 .revisions.loading .loading-indicator { 3559 opacity: 1; 3560 } 3561 3562 .revisions .diff { 3563 -webkit-transition: opacity 0.5s; 3564 -moz-transition: opacity 0.5s; 3565 -ms-transition: opacity 0.5s; 3566 -o-transition: opacity 0.5s; 3567 transition: opacity 0.5s; 3568 } 3569 3570 .revisions.loading .diff { 3571 opacity: 0.5; 3572 } 3573 3541 3574 .revisions-meta { 3542 3575 margin-top: 15px; -
trunk/wp-admin/includes/ajax-actions.php
r24651 r24667 2093 2093 require ABSPATH . 'wp-admin/includes/revision.php'; 2094 2094 2095 // check_ajax_referer( 'revisions-ajax-nonce', 'nonce' );2096 2097 2095 if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) 2098 2096 wp_send_json_error(); -
trunk/wp-admin/includes/revision.php
r24664 r24667 67 67 $now_gmt = time(); 68 68 69 $revisions = wp_get_post_revisions( $post->ID );69 $revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC', 'orderby' => 'modified' ) ); 70 70 71 71 cache_users( wp_list_pluck( $revisions, 'post_author' ) ); 72 72 73 73 foreach ( $revisions as $revision ) { 74 $modified = strtotime( $revision->post_modified ); 74 75 $modified_gmt = strtotime( $revision->post_modified_gmt ); 75 76 $restore_link = wp_nonce_url( … … 89 90 'name' => get_the_author_meta( 'display_name', $revision->post_author ), 90 91 ), 91 'date' => date_i18n( __( 'M j, Y @ G:i' ), $modified_gmt ), 92 'dateShort' => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified_gmt ), 93 'dateUnix' => $modified_gmt, 92 'date' => date_i18n( __( 'M j, Y @ G:i' ), $modified ), 93 'dateShort' => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified ), 94 94 'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ), 95 95 'autosave' => wp_is_post_autosave( $revision ), … … 100 100 101 101 // Now, grab the initial diff 102 if ( ! $from ) { // Single mode 103 $initial_revisions = array_reverse( array_keys( array_slice( $revisions, array_search( $selected_revision_id, array_keys( $revisions ) ), 2, true ) ) ); 104 $compare_two_mode = false; 105 } else { // Compare two 106 $compare_two_mode = true; 107 $initial_revisions = array( $from, $selected_revision_id ); 108 } 102 $compare_two_mode = (bool) $from; 103 if ( ! $from ) // Single mode 104 $from = array_keys( array_slice( $revisions, array_search( $selected_revision_id, array_keys( $revisions ) ) - 1, 1, true ) )[0]; 105 109 106 $diffs = array( array( 110 'id' => $ initial_revisions[0] . ':' . $initial_revisions[1],111 'fields' => wp_get_revision_ui_diff( $post->ID, $ initial_revisions[0], $initial_revisions[1]),107 'id' => $from . ':' . $selected_revision_id, 108 'fields' => wp_get_revision_ui_diff( $post->ID, $from, $selected_revision_id ), 112 109 )); 113 110 … … 121 118 'baseUrl' => parse_url( admin_url( 'revision.php' ), PHP_URL_PATH ), 122 119 'compareTwoMode' => absint( $compare_two_mode ), // Apparently booleans are not allowed 120 'revisionIds' => array_keys( $revisions ), 123 121 ); 124 122 } -
trunk/wp-admin/js/revisions.js
r24666 r24667 128 128 initialize: function() { 129 129 _.bindAll( this, 'next', 'prev' ); 130 },131 132 comparator: function( a, b ) {133 var a_ = a.get('dateUnix');134 var b_ = b.get('dateUnix');135 var cmp = (a_ > b_) - (a_ < b_);136 if (cmp === 0 && a.id != b.id)137 cmp = a.id < b.id ? -1 : 1;138 return cmp;139 130 }, 140 131 … … 336 327 this.diffs.set( revisions.settings.diffData ); 337 328 338 // Set the initial revisions, baseUrl, and mode as provided through settings339 properties.to = this.revisions.get( revisions.settings.to );340 properties.from = this.revisions.get( revisions.settings.from ) || this.revisions.prev( properties.to );341 properties.compareTwoMode = revisions.settings.compareTwoMode;342 properties.baseUrl = revisions.settings.baseUrl;343 this.set( properties );344 345 // Start the router. This will trigger a navigate event and ensure that346 // the `from` and `to` revisions accurately reflect the hash.347 this.router = new revisions.Router({ model: this });348 Backbone.history.start({ pushState: true });349 350 329 // Set up internal listeners 351 330 this.listenTo( this, 'change:from', this.changeRevisionHandler ); … … 353 332 this.listenTo( this, 'update:revisions', this.loadSurrounding ); 354 333 this.listenTo( this, 'change:compareTwoMode', this.changedMode ); 334 this.listenTo( this.diffs, 'ensure:load', this.updateLoadingStatus ); 335 this.listenTo( this, 'update:diff', this.updateLoadingStatus ); 336 337 // Set the initial revisions, baseUrl, and mode as provided through settings 338 properties.to = this.revisions.get( revisions.settings.to ); 339 properties.from = this.revisions.get( revisions.settings.from ); 340 properties.compareTwoMode = revisions.settings.compareTwoMode; 341 properties.baseUrl = revisions.settings.baseUrl; 342 this.set( properties, { silent: true } ); 343 344 // Start the router 345 this.router = new revisions.Router({ model: this }); 346 Backbone.history.start({ pushState: true }); 355 347 }, 356 348 … … 358 350 // This isn't passed from/to so we grab them from the model 359 351 this.loadSurrounding( this.get( 'from' ), this.get( 'to' ) ); 352 }, 353 354 updateLoadingStatus: function() { 355 this.set( 'loading', ! this.diff() ); 360 356 }, 361 357 … … 442 438 443 439 initialize: function() { 444 // Generate the frame model.445 this.model = new revisions.model.FrameState({}, {446 revisions: this.collection447 });448 449 440 this.listenTo( this.model, 'update:diff', this.renderDiff ); 450 441 this.listenTo( this.model, 'change:compareTwoMode', this.updateCompareTwoMode ); 442 this.listenTo( this.model, 'change:loading', this.updateLoadingStatus ); 451 443 452 444 this.views.set( '.revisions-control-frame', new revisions.view.Controls({ … … 456 448 457 449 render: function() { 450 console.log( 'diff', this.model.diff() ); 458 451 this.model.updateDiff({ immediate: true }).done( _.bind( function() { 459 452 wp.Backbone.View.prototype.render.apply( this, arguments ); … … 471 464 model: diff 472 465 }) ); 466 }, 467 468 updateLoadingStatus: function() { 469 this.$el.toggleClass( 'loading', this.model.get('loading') ); 473 470 }, 474 471 … … 1014 1011 revisions.init = function() { 1015 1012 revisions.view.frame = new revisions.view.Frame({ 1016 collection: new revisions.model.Revisions( revisions.settings.revisionData ) 1013 model: new revisions.model.FrameState({}, { 1014 revisions: new revisions.model.Revisions( revisions.settings.revisionData ) 1015 }) 1017 1016 }).render(); 1018 1017 }; -
trunk/wp-admin/revision.php
r24664 r24667 186 186 187 187 <script id="tmpl-revisions-diff" type="text/html"> 188 <div class="loading-indicator"></div> 189 <div class="diff"> 188 190 <# _.each( data.fields, function( field ) { #> 189 191 <h3>{{{ field.name }}}</h3> 190 192 {{{ field.diff }}} 191 193 <# }); #> 194 </div> 192 195 </script> 193 196
Note: See TracChangeset
for help on using the changeset viewer.