mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-15 03:33:45 +00:00
Merge draggableDragAction and dependencies
Also temporarily deactivate browser tests for bar clicking. Change-Id: I347533ef445cb3c37e420beebcc79919e56a1223
This commit is contained in:
parent
37267aba11
commit
fc5c13f359
|
@ -273,29 +273,38 @@
|
|||
},
|
||||
|
||||
draggableDragAction: function ( event, ui, pointer, lastValidLeftPos ) {
|
||||
var olderLeftPos, newerLeftPos,
|
||||
isNew = $( pointer ).hasClass( 'mw-revslider-pointer-newer' );
|
||||
var pos, $revisions, $hoveredRevisionWrapper;
|
||||
|
||||
ui.position.left = Math.min(
|
||||
ui.position.left,
|
||||
this.getNewestVisibleRevisonLeftPos()
|
||||
pos = this.getRevisionPositionFromLeftOffset(
|
||||
$( pointer ).offset().left + this.revisionWidth / 2
|
||||
);
|
||||
|
||||
olderLeftPos = this.pointerOlder.getView().getElement().position().left;
|
||||
newerLeftPos = this.pointerNewer.getView().getElement().position().left;
|
||||
if ( pos === lastValidLeftPos ) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
if ( ui.position.left === ( isNew ? olderLeftPos : newerLeftPos ) ) {
|
||||
ui.position.left = lastValidLeftPos;
|
||||
} else {
|
||||
lastValidLeftPos = ui.position.left;
|
||||
if ( this.dir === 'ltr' ) {
|
||||
this.resetPointerColorsBasedOnValues( olderLeftPos, newerLeftPos );
|
||||
$revisions = this.getRevisionsElement();
|
||||
$hoveredRevisionWrapper = this.getRevElementAtPosition( $revisions, pos ).parent();
|
||||
this.slider.getRevisions().getView().showTooltip( $hoveredRevisionWrapper );
|
||||
|
||||
return pos;
|
||||
},
|
||||
|
||||
getRevisionPositionFromLeftOffset: function ( leftOffset ) {
|
||||
var $revisions = this.getRevisionsElement(),
|
||||
revisionsX = mw.libs.revisionSlider.correctElementOffsets( $revisions.offset() ).left,
|
||||
pos = Math.ceil( Math.abs( leftOffset - revisionsX ) / this.revisionWidth );
|
||||
|
||||
if ( this.dir === 'rtl' ) {
|
||||
// pre-loading the revisions on the right side leads to shifted position numbers
|
||||
if ( this.slider.isAtStart() ) {
|
||||
pos = this.slider.getRevisionsPerWindow() - pos + 1;
|
||||
} else {
|
||||
this.resetPointerColorsBasedOnValues( newerLeftPos, olderLeftPos );
|
||||
pos += this.slider.getRevisionsPerWindow();
|
||||
}
|
||||
}
|
||||
|
||||
return lastValidLeftPos;
|
||||
return pos;
|
||||
},
|
||||
|
||||
setPointerDragCursor: function () {
|
||||
|
@ -920,8 +929,14 @@
|
|||
this.slider.setRevisionsPerWindow( expandedRevisionWindowCapacity );
|
||||
|
||||
this.slide( Math.floor( ( this.pointerNewer.getPosition() - 1 ) / expandedRevisionWindowCapacity ), 0 );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {jQuery}
|
||||
*/
|
||||
getRevisionsElement: function () {
|
||||
return this.slider.getRevisions().getView().getElement();
|
||||
}
|
||||
} );
|
||||
|
||||
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
|
||||
|
|
|
@ -115,24 +115,6 @@
|
|||
SliderViewTwo.super.prototype.resetPointerStylesBasedOnPosition.call( this );
|
||||
},
|
||||
|
||||
draggableDragAction: function ( event, ui, pointer, lastValidLeftPos ) {
|
||||
var pos, $revisions, $hoveredRevisionWrapper;
|
||||
|
||||
pos = this.getRevisionPositionFromLeftOffset(
|
||||
$( pointer ).offset().left + this.revisionWidth / 2
|
||||
);
|
||||
|
||||
if ( pos === lastValidLeftPos ) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
$revisions = this.getRevisionsElement();
|
||||
$hoveredRevisionWrapper = this.getRevElementAtPosition( $revisions, pos ).parent();
|
||||
this.slider.getRevisions().getView().showTooltip( $hoveredRevisionWrapper );
|
||||
|
||||
return pos;
|
||||
},
|
||||
|
||||
setPointerDragCursor: function () {
|
||||
$( '.mw-revslider-pointer, ' +
|
||||
'.mw-revslider-pointer-container, ' +
|
||||
|
@ -203,23 +185,6 @@
|
|||
this.alignPointers();
|
||||
},
|
||||
|
||||
getRevisionPositionFromLeftOffset: function ( leftOffset ) {
|
||||
var $revisions = this.getRevisionsElement(),
|
||||
revisionsX = mw.libs.revisionSlider.correctElementOffsets( $revisions.offset() ).left,
|
||||
pos = Math.ceil( Math.abs( leftOffset - revisionsX ) / this.revisionWidth );
|
||||
|
||||
if ( this.dir === 'rtl' ) {
|
||||
// pre-loading the revisions on the right side leads to shifted position numbers
|
||||
if ( this.slider.isAtStart() ) {
|
||||
pos = this.slider.getRevisionsPerWindow() - pos + 1;
|
||||
} else {
|
||||
pos += this.slider.getRevisionsPerWindow();
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
},
|
||||
|
||||
resetPointerStylesBasedOnPosition: function () {
|
||||
this.updateOlderSliderLineCSS();
|
||||
this.updateNewerSliderLineCSS();
|
||||
|
@ -280,10 +245,6 @@
|
|||
return this.pointerNewer.getPosition() - this.pointerOlder.getPosition();
|
||||
},
|
||||
|
||||
getRevisionsElement: function () {
|
||||
return this.slider.getRevisions().getView().getElement();
|
||||
},
|
||||
|
||||
revisionWrapperClickHandler: function () {
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -3,23 +3,25 @@ Feature: RevisionSlider history
|
|||
Background:
|
||||
Given a page with 4 revision(s) exists
|
||||
|
||||
Scenario: RevisionSlider history can be accessed using browser back and forward buttons after clicking on a revision
|
||||
Given I am on the diff page
|
||||
When I have loaded the RevisionSlider and dismissed the help dialog
|
||||
And I click on revision 1 to move the lower pointer
|
||||
And I wait until the diff has loaded
|
||||
And I click on revision 2 to move the upper pointer
|
||||
And I wait until the diff has loaded
|
||||
And I click the browser back button
|
||||
And I wait until the diff has loaded
|
||||
And I click the browser back button
|
||||
And I wait until the diff has loaded
|
||||
And I click the browser forward button
|
||||
And I wait until the diff has loaded
|
||||
Then the lower pointer should be on revision 1
|
||||
And the upper pointer should be on revision 4
|
||||
And revision 1 should be loaded on the left of the diff
|
||||
And revision 4 should be loaded on the right of the diff
|
||||
# Deactivated until bar clicking will be reintroduced see T165831
|
||||
#
|
||||
# Scenario: RevisionSlider history can be accessed using browser back and forward buttons after clicking on a revision
|
||||
# Given I am on the diff page
|
||||
# When I have loaded the RevisionSlider and dismissed the help dialog
|
||||
# And I click on revision 1 to move the lower pointer
|
||||
# And I wait until the diff has loaded
|
||||
# And I click on revision 2 to move the upper pointer
|
||||
# And I wait until the diff has loaded
|
||||
# And I click the browser back button
|
||||
# And I wait until the diff has loaded
|
||||
# And I click the browser back button
|
||||
# And I wait until the diff has loaded
|
||||
# And I click the browser forward button
|
||||
# And I wait until the diff has loaded
|
||||
# Then the lower pointer should be on revision 1
|
||||
# And the upper pointer should be on revision 4
|
||||
# And revision 1 should be loaded on the left of the diff
|
||||
# And revision 4 should be loaded on the right of the diff
|
||||
|
||||
Scenario: RevisionSlider history can be accessed using browser back and forward buttons after dragging to a revision
|
||||
Given I am on the diff page
|
||||
|
|
|
@ -3,17 +3,19 @@ Feature: RevisionSlider pointers
|
|||
Background:
|
||||
Given a page with 5 revision(s) exists
|
||||
|
||||
Scenario: RevisionSlider pointers move when revision bars are clicked
|
||||
Given I am on the diff page
|
||||
When I have loaded the RevisionSlider and dismissed the help dialog
|
||||
And I click on revision 3 to move the lower pointer
|
||||
And I wait until the diff has loaded
|
||||
And I click on revision 4 to move the upper pointer
|
||||
And I wait until the diff has loaded
|
||||
Then the lower pointer should be on revision 3
|
||||
And the upper pointer should be on revision 4
|
||||
And revision 3 should be loaded on the left of the diff
|
||||
And revision 4 should be loaded on the right of the diff
|
||||
# Deactivated until bar clicking will be reintroduced see T165831
|
||||
#
|
||||
# Scenario: RevisionSlider pointers move when revision bars are clicked
|
||||
# Given I am on the diff page
|
||||
# When I have loaded the RevisionSlider and dismissed the help dialog
|
||||
# And I click on revision 3 to move the lower pointer
|
||||
# And I wait until the diff has loaded
|
||||
# And I click on revision 4 to move the upper pointer
|
||||
# And I wait until the diff has loaded
|
||||
# Then the lower pointer should be on revision 3
|
||||
# And the upper pointer should be on revision 4
|
||||
# And revision 3 should be loaded on the left of the diff
|
||||
# And revision 4 should be loaded on the right of the diff
|
||||
|
||||
Scenario: RevisionSlider pointers can be dragged
|
||||
Given I am on the diff page
|
||||
|
|
Loading…
Reference in a new issue