Don't open multiple error dialogs

If a Scribunto error dialog is open and the user clicks another error,
or the same error again, don't open another dialog window, instead close
the old one and reuse it.

Change-Id: I50b8d48ee551cfb8cb4e1e672a0e36e15b5ae216
This commit is contained in:
Tim Starling 2012-05-23 14:53:16 +10:00 committed by Victor Vasiliev
parent 8fcaa128ac
commit 886c6ae06d

View file

@ -10,6 +10,12 @@ mw.scribunto = {
'init': function () {
var regex = /^mw-scribunto-error-(\d+)/;
var that = this;
var 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 ) {
@ -26,12 +32,11 @@ mw.scribunto = {
return;
}
var error = that.errors[ errorId ];
$( '<div/>' )
dialog
.dialog( 'close' )
.html( error )
.dialog({
'title': mw.msg( 'scribunto-parser-dialog-title' ),
'position': [ evt.clientX + 5, evt.clientY + 5 ],
});
.dialog( 'option', 'position', [ evt.clientX + 5, evt.clientY + 5 ] )
.dialog( 'open' );
} );
} );
}