WMDE-leszek has submitted this change and it was merged. Change subject: Resume slider scroll position after refresh. ......................................................................
Resume slider scroll position after refresh. This fixes a bug that caused the slider to always show the first "page" after a refresh even if a different page was selected before the refresh. Change-Id: Ic5defd28f699617be6cf2ae5827e90f294d616b5 --- M modules/ext.RevisionSlider.DiffPage.js 1 file changed, 16 insertions(+), 8 deletions(-) Approvals: WMDE-leszek: Verified; Looks good to me, approved diff --git a/modules/ext.RevisionSlider.DiffPage.js b/modules/ext.RevisionSlider.DiffPage.js index aa83bae..8f9c0ff 100644 --- a/modules/ext.RevisionSlider.DiffPage.js +++ b/modules/ext.RevisionSlider.DiffPage.js @@ -4,8 +4,7 @@ $.extend( DiffPage.prototype, { refresh: function ( revId1, revId2 ) { - $( 'body' ) - .find( 'table.diff[data-mw=\'interface\']' ) + $( 'table.diff[data-mw=\'interface\']' ) .append( '<div id="revision-slider-darkness"></div>' ); $.ajax( { url: mw.util.wikiScript( 'index' ), @@ -16,11 +15,14 @@ tryCount: 0, retryLimit: 2, success: function ( data ) { - data = $( '<div/>' ).html( data ).contents(); - data.find( '#revision-slider-container' ).replaceWith( $( '#revision-slider-container' ) ); - $( 'body' ) - .find( '#mw-content-text' ) - .html( data.find( '#mw-content-text' ) ); + var $container = $( '#revision-slider-container' ), + scrollLeft = $container.find( '.revisions-container' ).scrollLeft(); + + data = $( data ); + data.find( '#revision-slider-container' ) + .replaceWith( $container ); + $( '#mw-content-text' ).html( data.find( '#mw-content-text' ) ) + .find( '.revisions-container' ).scrollLeft( scrollLeft ); }, error: function ( err ) { this.tryCount++; @@ -38,7 +40,13 @@ pushState: function ( revId1, revId2, sliderView ) { history.pushState( - { revid1: revId1, revid2: revId2, leftPos: sliderView.pointerOne.getPosition(), rightPos: sliderView.pointerTwo.getPosition(), sliderPos: sliderView.slider.getFirstVisibleRevisionIndex() }, + { + revid1: revId1, + revid2: revId2, + leftPos: sliderView.pointerOne.getPosition(), + rightPos: sliderView.pointerTwo.getPosition(), + sliderPos: sliderView.slider.getFirstVisibleRevisionIndex() + }, $( document ).find( 'title' ).text(), mw.util.wikiScript( 'index' ) + '?diff=' + Math.max( revId1, revId2 ) + '&oldid=' + Math.min( revId1, revId2 ) ); -- To view, visit https://gerrit.wikimedia.org/r/289646 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic5defd28f699617be6cf2ae5827e90f294d616b5 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/RevisionSlider Gerrit-Branch: master Gerrit-Owner: Jakob <jakob.warkot...@wikimedia.de> Gerrit-Reviewer: Jakob <jakob.warkot...@wikimedia.de> Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits