diff --git a/modules/ext.RevisionSlider.RevisionListView.js b/modules/ext.RevisionSlider.RevisionListView.js index 8e0fec37..5f1bb5e8 100644 --- a/modules/ext.RevisionSlider.RevisionListView.js +++ b/modules/ext.RevisionSlider.RevisionListView.js @@ -30,14 +30,18 @@ */ dir: null, + /** + * @type {jQuery} + */ + html: null, + /** * @param {number} revisionTickWidth * @param {number} positionOffset * @return {jQuery} */ render: function ( revisionTickWidth, positionOffset ) { - var $html = $( '
' ).addClass( 'mw-revslider-revisions' ), - revs = this.revisionList.getRevisions(), + var revs = this.revisionList.getRevisions(), maxChangeSizeLogged = Math.log( this.revisionList.getBiggestChangeSize() ), self = this, i, diffSize, relativeChangeSize, @@ -51,11 +55,13 @@ positionOffset = positionOffset || 0; this.revisionWidth = revisionTickWidth; + this.$html = $( '
' ).addClass( 'mw-revslider-revisions' ); + 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; - $html + this.$html .append( $( '
' ) .addClass( 'mw-revslider-revision-wrapper' ) .width( this.revisionWidth ) @@ -79,7 +85,7 @@ this.keepTooltipsOnHover(); this.closeTooltipsOnClick(); - return $html; + return this.$html; }, /** @@ -348,6 +354,13 @@ */ setDir: function ( dir ) { this.dir = dir; + }, + + /** + * @return {jQuery} + */ + getElement: function() { + return this.$html; } } ); diff --git a/modules/ext.RevisionSlider.SliderViewTwo.js b/modules/ext.RevisionSlider.SliderViewTwo.js index 4e4a64e9..7e30edef 100644 --- a/modules/ext.RevisionSlider.SliderViewTwo.js +++ b/modules/ext.RevisionSlider.SliderViewTwo.js @@ -108,7 +108,7 @@ return pos; } - $revisions = $( '.mw-revslider-revisions' ); + $revisions = this.getRevisionsElement(); $hoveredRevisionWrapper = this.getRevElementAtPosition( $revisions, pos ).parent(); this.slider.getRevisions().getView().showTooltip( $hoveredRevisionWrapper ); @@ -151,7 +151,7 @@ return; } - $revisions = this.$element.find( '.mw-revslider-revisions' ); + $revisions = this.getRevisionsElement(); $clickedRev = this.getRevElementAtPosition( $revisions, pos ); pointerMoved.setPosition( pos ); @@ -165,7 +165,7 @@ }, getRevisionPositionFromLeftOffset: function( leftOffset ) { - var $revisions = $( '.mw-revslider-revisions' ), + var $revisions = this.getRevisionsElement(), revisionsX = $revisions.offset().left, pos = Math.ceil( Math.abs( leftOffset - revisionsX ) / this.revisionWidth ); @@ -241,6 +241,10 @@ return this.pointerNewer.getPosition() - this.pointerOlder.getPosition(); }, + getRevisionsElement: function() { + return this.slider.getRevisions().getView().getElement(); + }, + revisionWrapperClickHandler: function() { } } );