mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-25 00:26:44 +00:00
6d1c1e63ec
The Scribunto "Script error" can be clicked, which is indicated by a CSS cursor:pointer style. To make it more discoverable, also have it show an underline on hover (as links do by default). And while we're messing with it, let's remove that "style" attribute and use the already-existing CSS class to assign the styles. Bug: 45887 Change-Id: Ibbbf0ed268efd78e4b7844cc2639fe154ee3ab8a
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
( function ( $, mw ) {
|
|
|
|
mw.scribunto = {
|
|
errors: null,
|
|
|
|
'setErrors': function ( errors ) {
|
|
this.errors = errors;
|
|
},
|
|
|
|
'init': function () {
|
|
var regex = /^mw-scribunto-error-(\d+)/,
|
|
that = this,
|
|
dialog = $( '<div>' );
|
|
|
|
dialog.dialog( {
|
|
title: mw.msg( 'scribunto-parser-dialog-title' ),
|
|
autoOpen: false
|
|
} );
|
|
|
|
$( '.scribunto-error' ).each( function ( index, span ) {
|
|
var matches = regex.exec( span.id );
|
|
if ( matches === null ) {
|
|
console.log( "mw.scribunto.init: regex mismatch!" );
|
|
return;
|
|
}
|
|
var errorId = parseInt( matches[1] );
|
|
$( span )
|
|
.bind( 'click', function ( evt ) {
|
|
if ( typeof that.errors[ errorId ] !== 'string' ) {
|
|
console.log( "mw.scribunto.init: error " + matches[1] + " not found, " +
|
|
"mw.loader.using() callback may not have been called yet." );
|
|
return;
|
|
}
|
|
var error = that.errors[ errorId ];
|
|
dialog
|
|
.dialog( 'close' )
|
|
.html( error )
|
|
.dialog( 'option', 'position', [ evt.clientX + 5, evt.clientY + 5 ] )
|
|
.dialog( 'open' );
|
|
} );
|
|
} );
|
|
}
|
|
};
|
|
|
|
$( document ).ready( function () {
|
|
mw.scribunto.init();
|
|
} );
|
|
|
|
} ) ( jQuery, mediaWiki );
|
|
|