mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-12-04 19:58:29 +00:00
b86be90b06
This patch mainly reintroduces the option to click on bars and move the pointers with it. To do this, 'ghost' pointers are introduced to show what would happen when bars are clicked. The pointers moved differ depending on where the user clicks on a bar. Pointers are still not allowed to change positions, so in some cases booth pointers move with one click. See the task description. The patch also includes some renaming and also refactoring of the click handling in general. Furthermore bar hover mechanics are handled by the RevisionListView class now. Moving both pointers is not possible when it would push one of them of limits. Bug: T172092, T173566 Change-Id: I32a8256f7667e03081324d54accdf03a17454faf
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
( function ( mw ) {
|
|
var Slider = mw.libs.revisionSlider.Slider,
|
|
RevisionList = mw.libs.revisionSlider.RevisionList,
|
|
Revision = mw.libs.revisionSlider.Revision,
|
|
makeNRevisions = function ( n ) {
|
|
var revs = [],
|
|
i;
|
|
for ( i = 0; i < n; i++ ) {
|
|
revs.push( new Revision( { revid: i + 1, user: 'Fooo' } ) );
|
|
}
|
|
return new RevisionList( revs );
|
|
};
|
|
|
|
QUnit.module( 'ext.RevisionSlider.Slider' );
|
|
|
|
QUnit.test( 'has revisions', function ( assert ) {
|
|
var revs = new RevisionList( [
|
|
new Revision( { revid: 1 } ),
|
|
new Revision( { revid: 2 } )
|
|
] ),
|
|
slider = new Slider( revs );
|
|
|
|
assert.equal( slider.getRevisionList(), revs );
|
|
} );
|
|
|
|
QUnit.test( 'Given no revisions, first visible revision index is 0', function ( assert ) {
|
|
var slider = new Slider( makeNRevisions( 0 ) );
|
|
|
|
assert.equal( slider.getOldestVisibleRevisionIndex(), 0 );
|
|
} );
|
|
|
|
QUnit.test( 'Given 200 revisions sliding once increases oldestVisibleRevisionIndex by the number of revisions per window', function ( assert ) {
|
|
var slider = new Slider( makeNRevisions( 200 ) );
|
|
slider.setRevisionsPerWindow( 50 );
|
|
slider.slide( 1 );
|
|
|
|
assert.equal( slider.getOldestVisibleRevisionIndex(), 50 );
|
|
} );
|
|
|
|
QUnit.test( 'oldestVisibleRevisionIndex cannot be higher than revisions.length - revisionsPerWindow', function ( assert ) {
|
|
var slider = new Slider( makeNRevisions( 75 ) );
|
|
slider.setRevisionsPerWindow( 50 );
|
|
slider.slide( 1 );
|
|
|
|
assert.equal( slider.getOldestVisibleRevisionIndex(), 25 );
|
|
} );
|
|
|
|
QUnit.test( 'oldestVisibleRevisionIndex cannot be lower than 0', function ( assert ) {
|
|
var slider = new Slider( makeNRevisions( 50 ) );
|
|
slider.oldestVisibleRevisionIndex = 10;
|
|
slider.setRevisionsPerWindow( 20 );
|
|
slider.slide( -1 );
|
|
|
|
assert.equal( slider.getOldestVisibleRevisionIndex(), 0 );
|
|
} );
|
|
|
|
}( mediaWiki ) );
|