Ticket #24425: 24425.draft.37.diff
File 24425.draft.37.diff, 5.3 KB (added by , 12 years ago) |
---|
-
wp-admin/js/revisions.js
357 357 358 358 initialize: function() { 359 359 this.$el.html( this.template() ); 360 this.listenTo( this.model, 'change:compareTwoMode', this.updateCompareTwoMode );361 360 }, 362 361 363 362 updateCompareTwoMode: function() { 364 363 if ( this.model.get( 'compareTwoMode' ) ) { 365 $( '.compare-two-revisions' ).p arent().css('border', '1px solid #f00;').prop( 'checked', true );364 $( '.compare-two-revisions' ).prop( 'checked', true ); 366 365 $( '.revisions-control-frame' ).addClass( 'comparing-two-revisions' ); 367 366 // in RTL mode the 'left handle' is the second in the slider, 'right' is first 368 367 $( '.wp-slider a.ui-slider-handle' ).first().addClass( isRtl ? 'right-handle' : 'left-handle' ); … … 392 391 // Hide compare two mode toggle when fewer than three revisions. 393 392 if ( this.model.revisions.length < 3 ) 394 393 $( '.revision-toggle-compare-mode' ).hide(); 394 395 this.listenTo( this.model, 'change:compareTwoMode', this.updateCompareTwoMode ); 396 397 // Update the mode in case route has set it 398 this.updateCompareTwoMode(); 395 399 } 396 400 397 401 }); … … 542 546 this.settings.attributes.value = this.model.revisions.indexOf( 543 547 this.model.revisions.findWhere( { id: Number( revisions.settings.selectedRevision ) } ) ); 544 548 549 // And update the slider in case the route has set it. 550 this.updateSliderSettings(); 551 545 552 this.slide( '', this.settings.attributes ); 546 553 547 554 this.$el.slider( this.settings.toJSON() ); … … 556 563 // Listen for changes in the diffId 557 564 this.listenTo( this.model, 'change:diffId', this.diffIdChanged ); 558 565 566 567 559 568 }, 560 569 561 570 mousemove: function( e ) { … … 589 598 }, 590 599 591 600 updateSliderSettings: function() { 592 if ( isRtl ) { 593 this.$el.slider( { // Order reversed in RTL mode 594 value: this.model.revisions.length - this.model.revisions.indexOf( this.model.get( 'to' ) ) - 1 601 if ( this.model.get( 'compareTwoMode' ) ) { 602 var leftValue, rightValue; 603 604 // In single handle mode, the 1st stored revision is 'blank' and the 'from' model is not set 605 // In this case we move the to index over one 606 if ( 'undefined' == typeof this.model.get( 'from' ) ) { 607 if ( isRtl ) { 608 leftValue = this.model.revisions.length - this.model.revisions.indexOf( this.model.get( 'to' ) ) - 2; 609 rightValue = leftValue + 1; 610 } else { 611 leftValue = this.model.revisions.indexOf( this.model.get( 'to' ) ); 612 rightValue = leftValue + 1; 613 } 614 } else { 615 leftValue = isRtl ? this.model.revisions.length - this.model.revisions.indexOf( this.model.get( 'to' ) ) - 1 : 616 this.model.revisions.indexOf( this.model.get( 'from' ) ), 617 rightValue = isRtl ? this.model.revisions.length - this.model.revisions.indexOf( this.model.get( 'from' ) ) - 1 : 618 this.model.revisions.indexOf( this.model.get( 'to' ) ); 619 } 620 621 // Set handles to current from / to models. 622 // Reverse order for RTL 623 this.$el.slider( { 624 values: [ 625 leftValue, 626 rightValue 627 ], 628 value: null, 629 range: true // Range mode ensures handles can't cross 595 630 } ); 596 631 } else { 597 if ( this.model.get( 'compareTwoMode' ) ) { 598 this.$el.slider( { // Set handles to current from/to models 599 values: [ 600 this.model.revisions.indexOf( this.model.get( 'from' ) ), 601 this.model.revisions.indexOf( this.model.get( 'to' ) ) 602 ], 603 value: null, 604 range: true // Range mode ensures handles can't cross 605 } ); 606 } else { 607 this.$el.slider( { // Set handle to current to model 608 value: this.model.revisions.indexOf( this.model.get( 'to' ) ), 609 values: null, // Clear existing two handled values 610 range: false 611 } ); 612 } 632 this.$el.slider( { // Set handle to current to model 633 // Reverse order for RTL. 634 value: isRtl ? this.model.revisions.length - this.model.revisions.indexOf( this.model.get( 'to' ) ) - 1 : 635 this.model.revisions.indexOf( this.model.get( 'to' ) ), 636 values: null, // Clear existing two handled values 637 range: false 638 } ); 613 639 } 614 640 if ( this.model.get( 'compareTwoMode' ) ){ 615 641 $( '.revisions' ).addClass( 'comparing-two-revisions' ); … … 675 701 return false; 676 702 677 703 attributes = { 678 to: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.values[ 1] - 1 : ui.values[1] ), // Reverse directions for RTL.679 from: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.values[ 0] - 1 : ui.values[0] ) // Reverse directions for RTL.704 to: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.values[0] - 1 : ui.values[1] ), // Reverse directions for RTL. 705 from: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.values[1] - 1 : ui.values[0] ) // Reverse directions for RTL. 680 706 }; 707 681 708 } else { 682 709 // Compare single revision mode 683 710 var sliderPosition = this.getSliderPosition( ui ); -
wp-admin/css/wp-admin.css
3520 3520 display: none; 3521 3521 } 3522 3522 3523 .comparing-two-revisions .revisions-controls { 3524 height: 80px; 3525 } 3523 3526 .revisions-previous { 3524 3527 float: left; 3525 3528 }