Changeset 24732
- Timestamp:
- 07/18/2013 04:35:19 PM (11 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/wp-admin.css
r24695 r24732 3555 3555 } 3556 3556 3557 .revisions .diff-error { 3558 position: absolute; 3559 text-align: center; 3560 margin: 0 auto; 3561 width: 100%; 3562 display: none; 3563 } 3564 3565 .revisions.diff-error .diff-error { 3566 display: block; 3567 } 3568 3557 3569 .revisions .loading-indicator { 3558 3570 position: absolute; 3559 text-align: center;3560 3571 vertical-align: middle; 3561 3572 opacity: 0; 3562 margin: 0 auto;3563 3573 width: 100%; 3564 height: 32px;3565 3574 top: 3em; 3566 background: #fff url(../images/wpspin_light-2x.gif) no-repeat center top;3567 3575 -webkit-transition: opacity 0.5s; 3568 3576 -moz-transition: opacity 0.5s; … … 3570 3578 -o-transition: opacity 0.5s; 3571 3579 transition: opacity 0.5s; 3580 } 3581 3582 .revisions .loading-indicator span.spinner { 3583 display: block; 3584 margin: 0 auto; 3585 float: none; 3572 3586 } 3573 3587 … … 3586 3600 .revisions.loading .diff { 3587 3601 opacity: 0.5; 3602 } 3603 3604 .revisions.diff-error .diff { 3605 visibility: hidden; 3588 3606 } 3589 3607 -
trunk/wp-admin/js/revisions.js
r24699 r24732 234 234 request.done( _.bind( function() { 235 235 deferred.resolveWith( context, [ this.get( id ) ] ); 236 }, this ) ); 236 }, this ) ).fail( _.bind( function() { 237 deferred.reject(); 238 }) ); 237 239 } 238 240 … … 257 259 if ( _.size( diffs ) > 0 ) { 258 260 this.load( diffs ).done( function() { 259 deferred.resolve(); 260 self._loadAll( allRevisionIds, centerId, num ); 261 self._loadAll( allRevisionIds, centerId, num ).done( function() { 262 deferred.resolve(); 263 }); 264 }).fail( function() { 265 if ( 1 === num ) { // Already tried 1. This just isn't working. Give up. 266 deferred.reject(); 267 } else { // Request fewer diffs this time 268 self._loadAll( allRevisionIds, centerId, Math.ceil( num / 2 ) ).done( function() { 269 deferred.resolve(); 270 }); 271 } 261 272 }); 262 return deferred.promise();263 273 } else { 264 return deferred.reject().promise(); 265 } 274 deferred.resolve(); 275 } 276 return deferred; 266 277 }, 267 278 … … 315 326 defaults: { 316 327 loading: false, 328 error: false, 317 329 compareTwoMode: false 318 330 }, … … 321 333 var properties = {}; 322 334 335 _.bindAll( this, 'receiveDiff' ); 323 336 this._debouncedEnsureDiff = _.debounce( this._ensureDiff, 200 ); 324 337 … … 352 365 353 366 updateLoadingStatus: function() { 367 this.set( 'error', false ); 354 368 this.set( 'loading', ! this.diff() ); 355 369 }, … … 400 414 // If we already have the diff, then immediately trigger the update. 401 415 if ( diff ) { 402 this. trigger( 'update:diff',diff );416 this.receiveDiff( diff ); 403 417 return $.Deferred().resolve().promise(); 404 418 // Otherwise, fetch the diff. … … 419 433 }, 420 434 435 receiveDiff: function( diff ) { 436 // Did we actually get a diff? 437 if ( _.isUndefined( diff ) || _.isUndefined( diff.id ) ) { 438 this.set({ 439 loading: false, 440 error: true 441 }); 442 } else if ( this._diffId === diff.id ) { // Make sure the current diff didn't change 443 this.trigger( 'update:diff', diff ); 444 } 445 }, 446 421 447 _ensureDiff: function() { 422 return this.diffs.ensure( this._diffId, this ).done( function( diff ) { 423 // Make sure the current diff didn't change while the request was in flight. 424 if ( this._diffId === diff.id ) 425 this.trigger( 'update:diff', diff ); 426 }); 448 return this.diffs.ensure( this._diffId, this ).always( this.receiveDiff ); 427 449 } 428 450 }); … … 444 466 this.listenTo( this.model, 'change:compareTwoMode', this.updateCompareTwoMode ); 445 467 this.listenTo( this.model, 'change:loading', this.updateLoadingStatus ); 468 this.listenTo( this.model, 'change:error', this.updateErrorStatus ); 446 469 447 470 this.views.set( '.revisions-control-frame', new revisions.view.Controls({ … … 469 492 updateLoadingStatus: function() { 470 493 this.$el.toggleClass( 'loading', this.model.get('loading') ); 494 }, 495 496 updateErrorStatus: function() { 497 this.$el.toggleClass( 'diff-error', this.model.get('error') ); 471 498 }, 472 499 -
trunk/wp-admin/revision.php
r24729 r24732 187 187 188 188 <script id="tmpl-revisions-diff" type="text/html"> 189 <div class="loading-indicator"></div> 189 <div class="loading-indicator"><span class="spinner"></span></div> 190 <div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div> 190 191 <div class="diff"> 191 192 <# _.each( data.fields, function( field ) { #>
Note: See TracChangeset
for help on using the changeset viewer.