Ticket #24425: 24425.draft.17b.diff
File 24425.draft.17b.diff, 5.9 KB (added by , 12 years ago) |
---|
-
wp-admin/css/wp-admin-rtl.css
975 975 left: 6px; 976 976 } 977 977 978 #toggle-revision-compare-mode {978 .revision-toggle-compare-mode { 979 979 right: auto; 980 980 left: 0; 981 981 padding: 9px 0 0 9px; 982 982 } 983 983 984 #diff-next-revision{984 .revisions-next { 985 985 float: left; 986 986 } 987 987 988 #diff-previous-revision{988 .revisions-previous { 989 989 float: right; 990 990 } 991 991 -
wp-admin/js/revisions.js
30 30 31 31 comparator: function( revision ) { 32 32 return revision.id; 33 } ,33 } 34 34 }); 35 35 36 36 revisions.model.Field = Backbone.Model.extend({}); … … 101 101 return this.fetch({ data: { compare: comparisons }, remove: false }); 102 102 }, 103 103 104 /**/105 104 loadLast: function( num ) { 106 105 num = num || 1; 107 106 var ids = this.getProximalDiffIds(); … … 273 272 274 273 initialize: function() { 275 274 // Add the button view 276 this.views.add( new revisions.view.Buttons({ 275 this.views.add( new revisions.view.Buttons({ 277 276 model: this.model 278 277 })); 279 278 … … 314 313 if( this.model.get( 'to' ).attributes.current ) { 315 314 $( '#restore-revision' ).prop( 'disabled', true); 316 315 } else { 317 $( '#restore-revision' ).prop( 'disabled', false) 316 $( '#restore-revision' ).prop( 'disabled', false); 318 317 } 319 318 } 320 319 }); … … 328 327 template: wp.template('revisions-controls'), 329 328 330 329 initialize: function() { 331 this.$el.html( this.template() ) 330 this.$el.html( this.template() ); 332 331 }, 333 332 334 333 events: { 335 334 'click #next': 'nextRevision', 336 335 'click #previous': 'previousRevision' 337 336 }, 338 337 339 338 gotoModel: function( toIndex ) { 340 339 var attributes = { 341 340 to: this.model.revisions.at( isRtl ? this.model.revisions.length - toIndex - 1 : toIndex ) // Reverse directions for Rtl … … 350 349 }, 351 350 352 351 nextRevision: function() { 353 var toIndex = this.model.revisions.indexOf( this.model.get( 'to' ) );352 var toIndex = isRtl ? this.model.revisions.length - this.model.revisions.indexOf( this.model.get( 'to' ) ) - 1 : this.model.revisions.indexOf( this.model.get( 'to' ) ); 354 353 toIndex = isRtl ? toIndex - 1 : toIndex + 1; 355 354 this.gotoModel( toIndex ); 356 355 }, 357 356 358 357 previousRevision: function() { 359 var toIndex = this.model.revisions.indexOf( this.model.get('to') );358 var toIndex = isRtl ? this.model.revisions.length - this.model.revisions.indexOf( this.model.get( 'to' ) ) - 1 : this.model.revisions.indexOf( this.model.get( 'to' ) ); 360 359 toIndex = isRtl ? toIndex + 1 : toIndex - 1; 361 360 this.gotoModel( toIndex ); 362 361 }, … … 367 366 368 367 // Check to see if the Previous or Next buttons need to be disabled or enabled 369 368 disabledButtonCheck: function() { 370 var maxVal = isRtl ? 0 :this.model.revisions.length - 1,371 minVal = isRtl ? this.model.revisions.length - 1 :0,369 var maxVal = this.model.revisions.length - 1, 370 minVal = 0, 372 371 next = $( '.revisions-next .button' ), 373 372 previous = $( '.revisions-previous .button' ), 374 373 val = this.model.revisions.indexOf( this.model.get( 'to' ) ); … … 384 383 previous.prop( 'disabled', true ); 385 384 else 386 385 previous.prop( 'disabled', false ); 387 }, 388 389 386 } 390 387 }); 391 388 392 389 // The slider view. … … 404 401 405 402 // Find the initially selected revision 406 403 var initiallySelectedRevisionIndex = 407 this.model.revisions.indexOf( 404 this.model.revisions.indexOf( 408 405 this.model.revisions.findWhere( { id: Number( revisions.settings.selectedRevision ) } ) ); 409 406 410 407 this.settings = new revisions.model.Slider({ … … 420 417 this.$el.slider( this.settings.toJSON() ); 421 418 this.settings.on( 'change', function( model, options ) { 422 419 // Apply changes to slider settings here. 423 this.$el.slider( { value: this.model.revisions.indexOf( this.model.get( 'to' ) ) } ); // Set handle to current to model 420 if ( isRtl ) { 421 this.$el.slider( { // Order reversed in RTL mode 422 value: this.model.revisions.length - this.model.revisions.indexOf( this.model.get( 'to' ) ) - 1 423 } ); 424 } else { 425 this.$el.slider( { // Set handle to current to model 426 value: this.model.revisions.indexOf( this.model.get( 'to' ) ) 427 } ); 428 } 424 429 }, this ); 425 430 // Reset to the initially selected revision 426 431 this.slide( '', this.settings.attributes ); 427 432 428 433 // Listen for changes in the diffId 429 434 this.listenTo( this.model, 'change:diffId', this.diffIdChanged ); 430 431 435 }, 432 436 433 437 diffIdChanged: function() { … … 436 440 }, 437 441 438 442 start: function( event, ui ) { 439 // Track the mouse position to enable smooth dragging, overrides default jquery ui step behaviour 440 $( window ).mousemove( function( e ) { 443 // Track the mouse position to enable smooth dragging, overrides default jquery ui step behaviour 444 $( window ).mousemove( function( e ) { 441 445 var sliderLeft = $( '.wp-slider' ).offset().left, 442 446 sliderRight = sliderLeft + $( '.wp-slider' ).width(); 443 447 … … 449 453 } else { 450 454 $( ui.handle ).css( 'left', e.clientX - sliderLeft ); // Mouse in slider 451 455 } 452 } ); // End mousemove 456 } ); // End mousemove 453 457 }, 454 458 455 459 slide: function( event, ui ) { 456 460 var attributes = { 457 to: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.value - 1 : ui.value ) // Reverse directions for R tl461 to: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.value - 1 : ui.value ) // Reverse directions for RTL 458 462 }; 459 463 460 464 // If we're at the first revision, unset 'from'. 461 if ( isRtl ? this.model.revisions.length - ui.value - 1 : ui.value ) // Reverse directions for R tl465 if ( isRtl ? this.model.revisions.length - ui.value - 1 : ui.value ) // Reverse directions for RTL 462 466 attributes.from = this.model.revisions.at( isRtl ? this.model.revisions.length - ui.value - 2 : ui.value - 1 ); 463 467 else 464 468 this.model.unset('from', { silent: true });