mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-14 19:24:42 +00:00
1a8a4312de
Also removed unused dependency. Bug: T135198 Change-Id: I1ee53ec9d7e123bdca84701b9557aeeeade815ff
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
( function ( mw, $ ) {
|
|
mw.track( 'counter.MediaWiki.RevisionSlider.event.init' );
|
|
mw.libs.revisionSlider.fetchRevisions( {
|
|
pageName: mw.config.get( 'wgPageName' ),
|
|
startId: mw.config.get( 'wgCurRevisionId' ),
|
|
|
|
success: function ( data ) {
|
|
var revs,
|
|
revisionList,
|
|
$container,
|
|
slider;
|
|
|
|
try {
|
|
revs = data.query.pages[ 0 ].revisions;
|
|
if ( !revs ) {
|
|
return;
|
|
}
|
|
revs.reverse();
|
|
|
|
revisionList = new mw.libs.revisionSlider.RevisionList( revs );
|
|
$container = $( '#mw-revision-slider-container' );
|
|
slider = new mw.libs.revisionSlider.Slider( revisionList );
|
|
slider.getView().render( $container );
|
|
|
|
$( '#mw-revision-slider-placeholder' ).remove();
|
|
} catch ( err ) {
|
|
if ( err === 'RS-rev-out-of-range' ) {
|
|
$( '#mw-revision-slider-placeholder' )
|
|
.text( mw.message( 'revisionslider-loading-out-of-range' ).text() );
|
|
console.log( err );
|
|
mw.track( 'counter.MediaWiki.RevisionSlider.error.outOfRange' );
|
|
} else {
|
|
$( '#mw-revision-slider-placeholder' )
|
|
.text( mw.message( 'revisionslider-loading-failed' ).text() );
|
|
console.log( err );
|
|
mw.track( 'counter.MediaWiki.RevisionSlider.error.init' );
|
|
}
|
|
}
|
|
|
|
},
|
|
error: function ( err ) {
|
|
$( '#mw-revision-slider-placeholder' )
|
|
.text( mw.message( 'revisionslider-loading-failed' ).text() );
|
|
console.log( err );
|
|
mw.track( 'counter.MediaWiki.RevisionSlider.error.init' );
|
|
}
|
|
} );
|
|
}( mediaWiki, jQuery ) );
|