mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-15 11:40:43 +00:00
f9471bcfbc
If something goes wrong with the initial api rquest the slider would either load in a broken state or say that it is loading forever. Now a message will be displayed to the user as well as the error logged to the console. Change-Id: Id763f31432feb7bd0e9ecbbeb2dd40f7ca6acaaf
48 lines
1.3 KiB
JavaScript
Executable file
48 lines
1.3 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 ) {
|
|
$( '#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 ) );
|