Changeset 24679
- Timestamp:
- 07/12/2013 06:14:23 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/revisions.js
r24678 r24679 738 738 739 739 // Update the tooltip model 740 this.model.set({ 741 'hoveredRevision': this.model.revisions.at( currentModelIndex ) 742 }); 740 this.model.set({ hoveredRevision: this.model.revisions.at( currentModelIndex ) }); 743 741 }, 744 742 … … 828 826 // Responds to slide events 829 827 slide: function( event, ui ) { 830 var attributes, movedRevision ;828 var attributes, movedRevision, sliderPosition; 831 829 // Compare two revisions mode 832 if ( ! _.isUndefined( ui.values ) &&this.model.get('compareTwoMode') ) {830 if ( this.model.get('compareTwoMode') ) { 833 831 // Prevent sliders from occupying same spot 834 832 if ( ui.values[1] === ui.values[0] ) … … 836 834 837 835 attributes = { 838 to: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.values[0] - 1 : ui.values[1] ), // Reverse directions for RTL.839 from: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.values[1] - 1 : ui.values[0] ) // Reverse directions for RTL.836 to: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.values[0] - 1 : ui.values[1] ), 837 from: this.model.revisions.at( isRtl ? this.model.revisions.length - ui.values[1] - 1 : ui.values[0] ) 840 838 }; 841 839 movedRevision = ! isRtl && ui.value === ui.values[0] ? attributes.from : attributes.to; 842 840 } else { 843 // Compare single revision mode 844 var sliderPosition = this.getSliderPosition( ui ); 841 sliderPosition = this.getSliderPosition( ui ); 845 842 attributes = { 846 843 to: this.model.revisions.at( sliderPosition ) … … 885 882 initialize: function( options ) { 886 883 this.model = options.model; 887 this.routes = this.getRoutes(); 888 889 // Maintain state history when dragging/clicking 884 this.routes = _.object([ 885 [ this.baseUrl( '?from=:from&to=:to' ), 'handleRoute' ], 886 [ this.baseUrl( '?from=:from&to=:to' ), 'handleRoute' ] 887 ]); 888 // Maintain state and history when navigating 890 889 this.listenTo( this.model, 'update:diff', _.debounce( this.updateUrl, 250 ) ); 891 890 this.listenTo( this.model, 'change:compareTwoMode', this.updateUrl ); 892 },893 894 getRoutes: function() {895 var routes = {};896 routes[this.baseUrl( '?from=:from&to=:to' )] = 'handleRoute';897 routes[this.baseUrl( '?revision=:to' )] = 'handleRoute';898 return routes;899 891 }, 900 892 … … 913 905 914 906 handleRoute: function( a, b ) { 915 var from, to, compareTwo; 916 917 // If `b` is undefined, this is an 'at/:to' route, for a single revision 918 if ( _.isUndefined( b ) ) { 907 var from, to, compareTwo = _.isUndefined( b ); 908 909 if ( ! compareTwo ) { 919 910 b = this.model.revisions.get( a ); 920 911 a = this.model.revisions.prev( b ); 921 912 b = b ? b.id : 0; 922 913 a = a ? a.id : 0; 923 compareTwo = false;924 } else {925 compareTwo = true;926 914 } 927 915 928 from = parseInt( a, 10 ); 929 to = parseInt( b, 10 ); 930 931 this.model.set({ compareTwoMode: compareTwo }); 932 933 if ( ! _.isUndefined( this.model ) ) { 934 var selectedToRevision = this.model.revisions.get( to ), 935 selectedFromRevision = this.model.revisions.get( from ); 936 937 this.model.set({ 938 to: selectedToRevision, 939 from: selectedFromRevision 940 }); 941 } 942 revisions.settings.to = to; 916 this.model.set({ 917 from: this.model.revisions.get( parseInt( a, 10 ) ), 918 to: this.model.revisions.get( parseInt( a, 10 ) ), 919 compareTwoMode: compareTwo 920 }); 943 921 } 944 922 });
Note: See TracChangeset
for help on using the changeset viewer.