Merge "Update diff view on pointer move."

This commit is contained in:
jenkins-bot 2016-05-11 10:09:58 +00:00 committed by Gerrit Code Review
commit 28407bb283
3 changed files with 40 additions and 0 deletions

View file

@ -76,6 +76,7 @@
],
"dependencies": [
"ext.RevisionSlider.SectionLegend",
"ext.RevisionSlider.DiffPage",
"ext.RevisionSlider.Pointer"
]
},
@ -87,6 +88,11 @@
"ext.RevisionSlider.rainbow"
]
},
"ext.RevisionSlider.DiffPage": {
"scripts": [
"modules/ext.RevisionSlider.DiffPage.js"
]
},
"ext.RevisionSlider.RevisionList": {
"scripts": [
"modules/ext.RevisionSlider.RevisionList.js"

View file

@ -0,0 +1,25 @@
( function ( mw, $ ) {
var DiffPage = function () {
};
$.extend( DiffPage.prototype, {
refresh: function ( oldId, newId ) {
$.ajax( {
url: mw.util.wikiScript( 'index' ),
data: {
diff: newId,
oldid: oldId
},
success: function ( data ) {
data = $( '<div/>' ).html( data ).contents();
$( 'body' )
.find( 'table.diff[data-mw=\'interface\']' )
.html( data.find( 'table.diff[data-mw=\'interface\']' ) );
}
} );
}
} );
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
mw.libs.revisionSlider.DiffPage = DiffPage;
}( mediaWiki, jQuery ) );

View file

@ -31,6 +31,7 @@
render: function ( $container ) {
var containerWidth = this.calculateSliderContainerWidth(),
sectionLegend = new mw.libs.revisionSlider.SectionLegend( this.slider.getRevisions() ),
diffPage = new mw.libs.revisionSlider.DiffPage( this.slider.getRevisions() ),
$revisions = this.slider.getRevisions().getView().render( this.revisionWidth, sectionLegend.getSectionColorMap() ),
$slider = $( '<div class="revision-slider"/>' ),
self = this;
@ -76,6 +77,14 @@
pointer = self.whichPointer( $p ),
pos = parseInt( $p.css( 'left' ), 10 );
pointer.setPosition( self.slider.getFirstVisibleRevisionIndex() + Math.floor( pos / self.revisionWidth ) );
diffPage.refresh(
$revisions
.find( 'div.revision[data-pos=\'' + self.leftPointer.getPosition() + '\']' )
.attr( 'data-revid' ),
$revisions
.find( 'div.revision[data-pos=\'' + self.rightPointer.getPosition() + '\']' )
.attr( 'data-revid' )
);
}
} );