mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-19 03:12:52 +00:00
1eea8281c9
This replaces the use of ParserOutput::addJsConfigVars(), deprecated since 1.38, and ensures that the IDs used for error messages are independent of page parse order. (See T300979.) This is an improved replacement for Ibd3fbcbc774491179b0d4fe29ba3b6a128220703 which was reverted (T346094). Bug: T300307 Bug: T305161 Bug: T346094 Change-Id: I2c660972b289bbad730ceee1325d70d5ba75d27e
39 lines
1,011 B
JavaScript
39 lines
1,011 B
JavaScript
( function () {
|
|
|
|
mw.hook( 'wikipage.content' ).add( function () {
|
|
var regex = /^mw-scribunto-error-(\w+)/,
|
|
popup;
|
|
|
|
$( '.scribunto-error' ).each( function ( index, span ) {
|
|
var matches = regex.exec( span.id );
|
|
if ( matches === null ) {
|
|
mw.log( 'mw.scribunto.errors: regex mismatch!' );
|
|
return;
|
|
}
|
|
var $span = $( span );
|
|
$span.on( 'click', function () {
|
|
var error = mw.config.get( 'ScribuntoErrors-' + matches[ 1 ] );
|
|
if ( typeof error !== 'string' ) {
|
|
mw.log( 'mw.scribunto.errors: error ' + matches[ 1 ] + ' not found.' );
|
|
return;
|
|
}
|
|
|
|
if ( !popup ) {
|
|
popup = new OO.ui.PopupWidget( {
|
|
padded: true,
|
|
head: true,
|
|
label: $( '<div>' )
|
|
.text( mw.msg( 'scribunto-parser-dialog-title' ) )
|
|
.addClass( 'scribunto-error-label' )
|
|
} );
|
|
OO.ui.getDefaultOverlay().append( popup.$element );
|
|
}
|
|
popup.$body.html( error );
|
|
popup.setFloatableContainer( $span );
|
|
popup.toggle( true );
|
|
} );
|
|
} );
|
|
} );
|
|
|
|
}() );
|