MediaWiki:Gadget-Special characters.js

/* Change MediaWiki:Edittools into true buttons. */

$(document).ready( function($) {	var	$sc = $('#specialchars'),		$sb = $sc.find('.specialbasic'),		$sel,		$placeholder,		bl = $sb.length,		ci = 0;	$placeholder = $(' ');	$sc = $sc.before($placeholder).detach;	if ( bl > 1 ) {		ci = Number( $.cookie('mw-charinsert') ) || 0;		if ( ci > bl ) {			$.cookie( 'mw-charinsert', 0, { expires: 30, path: '/' } );			ci = 0;		}		$sel = $( ' ' ).change( function(e) { var	$this = $( this ), i = Number( $this.val ), last = Number( $.cookie('mw-charinsert') ) || 0; if ( last !== i ) { $sb.eq( last ).css( 'display', 'none' ); $sb.eq( i ).css( 'display', 'inline' ); $.cookie( 'mw-charinsert', i, { expires: 30, path: '/' } ); }		});	}	$.eachAsync($sb, { 'delay': 1, 'bulk': 0, 'loop': function(i,v) { var id = $(this) .css('display', i !== ci ? 'none' : 'inline') .find('a').replaceWith( function {					var $this = $(this), onclick = $this.attr( 'onclick' );					return $( ' ', { type: 'button', text: $this.text } )						.blur						.click( $.isFunction( onclick ) ? onclick : Function( onclick ) );				}) .end .attr( 'id' ) .replace( /\.([0-9A-F]{2})/g, '%$1' ) .replace( /_/g, ' ' ); if ( bl > 1 ) { $sel.append(						''						+ decodeURIComponent( id )						+ ' '				); }		},		'end': function { $sc.prepend($sel); $sel.change; $placeholder.after($sc).remove; }	}); });