mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-24 07:23:41 +00:00
Let revision bars leave space for the pointer line end border
The end border for the pointer lines can not be displayed because the bars on the biggest revisions used all the height. This patch reduces the max height of the bars slightly and refactores the calculating method. Bug: T163436 Change-Id: Idfa6bdb9f85221063e13f3ec16b22fcfbe6cbd9c
This commit is contained in:
parent
3c4c9fed0d
commit
72d19630ad
|
@ -20,6 +20,16 @@
|
|||
*/
|
||||
revisionWidth: 16,
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
minRevisionHeight: 5,
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
maxRevisionHeight: 66,
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
|
@ -59,7 +69,7 @@
|
|||
|
||||
for ( i = 0; i < revs.length; i++ ) {
|
||||
diffSize = revs[ i ].getRelativeSize();
|
||||
relativeChangeSize = diffSize !== 0 ? Math.ceil( 65.0 * Math.log( Math.abs( diffSize ) ) / maxChangeSizeLogged ) + 5 : 0;
|
||||
relativeChangeSize = this.calcRelativeChangeSize( diffSize, maxChangeSizeLogged );
|
||||
|
||||
this.$html
|
||||
.append( $( '<div>' )
|
||||
|
@ -95,9 +105,11 @@
|
|||
var revs = this.revisionList.getRevisions(),
|
||||
maxChangeSizeLogged = Math.log( this.revisionList.getBiggestChangeSize() ),
|
||||
i, diffSize, relativeChangeSize;
|
||||
|
||||
for ( i = 0; i < revs.length; i++ ) {
|
||||
diffSize = revs[ i ].getRelativeSize();
|
||||
relativeChangeSize = diffSize !== 0 ? Math.ceil( 65.0 * Math.log( Math.abs( diffSize ) ) / maxChangeSizeLogged ) + 5 : 0;
|
||||
relativeChangeSize = this.calcRelativeChangeSize( diffSize, maxChangeSizeLogged );
|
||||
|
||||
$renderedList.find( '.mw-revslider-revision[data-pos="' + ( i + 1 ) + '"]' ).css( {
|
||||
height: relativeChangeSize + 'px',
|
||||
top: diffSize > 0 ? '-' + relativeChangeSize + 'px' : 0
|
||||
|
@ -105,6 +117,16 @@
|
|||
}
|
||||
},
|
||||
|
||||
calcRelativeChangeSize: function( diffSize, maxChangeSizeLogged ) {
|
||||
if ( diffSize === 0 ) {
|
||||
return 0;
|
||||
}
|
||||
return Math.ceil(
|
||||
( this.maxRevisionHeight - this.minRevisionHeight ) *
|
||||
Math.log( Math.abs( diffSize ) ) / maxChangeSizeLogged
|
||||
) + this.minRevisionHeight;
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides the current tooltip immediately
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
assert.equal( $( $revisionDivs[ 0 ] ).attr( 'data-revid' ), 1 );
|
||||
assert.equal( $( $revisionDivs[ 2 ] ).attr( 'data-revid' ), 37 );
|
||||
assert.equal( $( $revisionDivs[ 1 ] ).css( 'width' ), '11px' );
|
||||
assert.equal( $( $revisionDivs[ 1 ] ).css( 'height' ), '70px' ); // max relative size
|
||||
assert.equal( $( $revisionDivs[ 1 ] ).css( 'height' ), '66px' ); // max relative size
|
||||
assert.ok( $( $revisionDivs[ 1 ] ).hasClass( 'mw-revslider-revision-up' ) );
|
||||
assert.ok( $( $revisionDivs[ 2 ] ).hasClass( 'mw-revslider-revision-down' ) );
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue