mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-18 02:41:09 +00:00
a978a00d00
Bug: T334853 Change-Id: I33ce4c07613a53ef394b4addee0e2b1b6c58455c
39 lines
998 B
JavaScript
39 lines
998 B
JavaScript
( () => {
|
|
|
|
mw.hook( 'wikipage.content' ).add( () => {
|
|
const regex = /^mw-scribunto-error-(\w+)/;
|
|
let popup;
|
|
|
|
$( '.scribunto-error' ).each( ( index, span ) => {
|
|
const matches = regex.exec( span.id );
|
|
if ( matches === null ) {
|
|
mw.log( 'mw.scribunto.errors: regex mismatch!' );
|
|
return;
|
|
}
|
|
const $span = $( span );
|
|
$span.on( 'click', () => {
|
|
const 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 );
|
|
} );
|
|
} );
|
|
} );
|
|
|
|
} )();
|