Jump to content

Toolbar customization/Library

From Wikimedia Usability Initiative

To use these snippets, paste them into the User:Yourusername/vector.js or User:Yourusername/monobook.js page (depending on whether your skin is Vector, Monobook or something else). You can use multiple snippets by simply pasting them below each other.

Snippets requiring no customization

Strikethrough button

This puts the button in the "Advanced" section of the toolbar. To put it in the top section of the toolbar instead, replace 'advanced' with 'main'. The button uses the old toolbar's strikethrough image; to change this, change the URL after icon:.

if ( typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined' ) {
	$j( function() {
		$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'format',
			'tools': {
				'strikethrough': {
					label: 'Strike',
					type: 'button',
					icon: 'http://upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<s>",
							post: "</s>"
						}
					}
				}
			}
		} );
	} );
}

Horizontal line button

This puts the button in the "Advanced" section of the toolbar. To put it in the top section of the toolbar instead, replace 'advanced' with 'main'. The button uses the old toolbar's horizontal line image; to change this, change the URL after icon:.

if ( typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined' ) {
	$j( function() {
		$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'format',
			'tools': {
				'hline': {
					label: 'Horizontal line',
					type: 'button',
					icon: 'http://bits.wikimedia.org/skins-1.5/common/images/button_hr.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "----",
							ownline: true
						}
					}
				}
			}
		} );
	} );
}

Comment button

if ( typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined' ) {
	$j( function() {
		$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'format',
			'tools': {
				'comment': {
					label: 'Comment',
					type: 'button',
					icon: 'http://upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<!-- ",
							post: " -->"
						}
					}
				}
			}
		} );
	} );
}

Math button

if ( typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined' ) {
	$j( function() {
		$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'format',
			'tools': {
				'math': {
					label: 'Math',
					type: 'button',
					icon: 'http://bits.wikimedia.org/skins-1.5/common/images/button_math.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<math>",
							post: "</math>"
						}
					}
				}
			}
		} );
	} );
}

Snippets requiring trivial customization