mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-15 11:40:43 +00:00
079f5607c9
Bug: T137086 Change-Id: Ifef5c8451a53bf43b10418ace8e6651801480bb2
64 lines
2 KiB
JavaScript
64 lines
2 KiB
JavaScript
( function ( mw, $ ) {
|
|
mw.track( 'counter.MediaWiki.RevisionSlider.event.init' );
|
|
mw.libs.revisionSlider.userOffset = mw.user.options.values.timecorrection ? mw.user.options.values.timecorrection.split( '|' )[ 1 ] : mw.config.values.extRevisionSliderTimeOffset;
|
|
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();
|
|
|
|
if ( !mw.user.options.get( 'userjs-revslider-hidehelp' ) ) {
|
|
mw.libs.revisionSlider.HelpDialog.show();
|
|
( new mw.Api() ).saveOption( 'userjs-revslider-hidehelp', true );
|
|
}
|
|
|
|
$container.append(
|
|
$( '<button>' )
|
|
.click( function () {
|
|
mw.libs.revisionSlider.HelpDialog.show();
|
|
} )
|
|
.text( '?' )
|
|
.addClass( 'mw-show-help' )
|
|
);
|
|
} 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 ) );
|