Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315620

Change subject: Prevent selecting the same revision twice
......................................................................

Prevent selecting the same revision twice

Bug: T141254
Change-Id: Ic51605dca1484ce66ce9764a2291c8a947f9d376
---
M modules/ext.RevisionSlider.SliderView.js
1 file changed, 17 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RevisionSlider 
refs/changes/20/315620/1

diff --git a/modules/ext.RevisionSlider.SliderView.js 
b/modules/ext.RevisionSlider.SliderView.js
index 5b49fe8..baa6421 100644
--- a/modules/ext.RevisionSlider.SliderView.js
+++ b/modules/ext.RevisionSlider.SliderView.js
@@ -83,6 +83,7 @@
                                pointerContainerPosition = 53,
                                pointerContainerWidth = containerWidth + 
this.revisionWidth - 1,
                                pointerContainerStyle,
+                               lastValidLeftPos,
                                $revisions = 
this.slider.getRevisions().getView().render( this.revisionWidth ),
                                $slider = $( '<div>' )
                                        .addClass( 
'mw-revslider-revision-slider' )
@@ -225,18 +226,24 @@
                                        $( '.mw-revslider-revision-wrapper' 
).removeClass( 'mw-revslider-pointer-cursor' );
                                },
                                drag: function ( event, ui ) {
-                                       var newestVisibleRevisionLeftPos = $( 
'.mw-revslider-revisions-container' ).width() - self.revisionWidth;
+                                       var olderLeftPos, newerLeftPos,
+                                               isNew = $( this ).hasClass( 
'mw-revslider-pointer-newer' ),
+                                               newestVisibleRevisionLeftPos = 
$( '.mw-revslider-revisions-container' ).width() - self.revisionWidth;
+
                                        ui.position.left = Math.min( 
ui.position.left, newestVisibleRevisionLeftPos );
-                                       if ( self.dir === 'ltr' ) {
-                                               
self.resetPointerColorsBasedOnValues(
-                                                       
self.pointerOlder.getView().getElement().offset().left,
-                                                       
self.pointerNewer.getView().getElement().offset().left
-                                               );
+
+                                       olderLeftPos = 
self.pointerOlder.getView().getElement().position().left;
+                                       newerLeftPos = 
self.pointerNewer.getView().getElement().position().left;
+
+                                       if ( ui.position.left === ( isNew ? 
olderLeftPos : newerLeftPos ) ) {
+                                               ui.position.left = 
lastValidLeftPos;
                                        } else {
-                                               
self.resetPointerColorsBasedOnValues(
-                                                       
self.pointerNewer.getView().getElement().offset().left,
-                                                       
self.pointerOlder.getView().getElement().offset().left
-                                               );
+                                               lastValidLeftPos = 
ui.position.left;
+                                               if ( self.dir === 'ltr' ) {
+                                                       
self.resetPointerColorsBasedOnValues( olderLeftPos, newerLeftPos );
+                                               } else {
+                                                       
self.resetPointerColorsBasedOnValues( newerLeftPos, olderLeftPos );
+                                               }
                                        }
                                }
                        } );

-- 
To view, visit https://gerrit.wikimedia.org/r/315620
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic51605dca1484ce66ce9764a2291c8a947f9d376
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/RevisionSlider
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to