mediawiki-extensions-Revisi.../modules/ext.RevisionSlider.init.js
addshore 91759f25bd Show useful error if either rev is not in our range
Bug: T135119
Change-Id: I48f3316f2285b987d1a7e4c4a622eb1291de6357
2016-05-12 16:44:34 +01:00

55 lines
1.6 KiB
JavaScript
Executable file

( function ( mw, $ ) {
mw.loader.using( [ 'jquery.ui.draggable', 'jquery.ui.tooltip', 'jquery.tipsy' ], function () {
$( function () {
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 = $( '#revision-slider-container' );
slider = new mw.libs.revisionSlider.Slider( revisionList );
slider.getView().render( $container );
$( '#revision-slider-placeholder' ).remove();
} catch ( err ) {
if ( err === 'RS-rev-out-of-range' ) {
$( '#revision-slider-placeholder' )
.html( mw.message( 'revisionslider-loading-out-of-range' ).text() );
console.log( err );
mw.track( 'counter.MediaWiki.RevisionSlider.error.outOfRange' );
} else {
$( '#revision-slider-placeholder' )
.html( mw.message( 'revisionslider-loading-failed' ).text() );
console.log( err );
mw.track( 'counter.MediaWiki.RevisionSlider.error.init' );
}
}
},
error: function ( err ) {
$( '#revision-slider-placeholder' )
.html( mw.message( 'revisionslider-loading-failed' ).text() );
console.log( err );
mw.track( 'counter.MediaWiki.RevisionSlider.error.init' );
}
} );
} );
} );
}( mediaWiki, jQuery ) );