MediaWiki:Gadget-Edittools.js: Difference between revisions

no edit summary
(Created page with "/** * EditTools support: add a selector, change <a> into buttons. * The special characters to insert are defined at MediaWiki:Edittools. * * @author Arnomane, 2006 (on...")
 
No edit summary
 
Line 117: Line 117:
$links = $section.find('a');
$links = $section.find('a');
$links.each(function (i, a) {
$links.each(function (i, a) {
var $a, button;
var $a, $button, start, end;
$a = $(a);
$a = $(a);
button = document.createElement('input');
$button = $( '<input>' ).attr( 'type', 'button' );
button.type = 'button';
start = $a.data( 'mw-charinsert-start' );
button.onclick = a.onclick;
end = $a.data( 'mw-charinsert-end' );
button.value = $a.text();
if ( start !== undefined && end !== undefined ) {
$a.replaceWith(button);
$button.click( function( e ) {
e.preventDefault();
mw.toolbar.insertTags( start, end, '' );
} );
} else {
$button[0].onclick = a.onclick;
                                }
$button[0].value = $a.text();
$a.replaceWith($button);
});
});
}
}