MediaWiki:Gadget-toolbar.js

/** * Creates a new section in WikiEditor, for FTB Wiki-related templates. * * @author User:Xbony2 * Based off of: * * mw:Extension:WikiEditor/Toolbar customization * */ var customizeToolbar = function { var page = mw.config.get("wgPageName"); $('#wpTextbox1').wikiEditor('addToToolbar', {		'sections': {			'templates': {				'type': 'toolbar',				'label': 'Templates'			}		}	}); $('#wpTextbox1').wikiEditor('addToToolbar', {		'section': 'templates',		'groups': {			'infoboxes': {				'label': 'Infoboxes'			},			'cg': {				'label': 'Crafting Grids'			},			'grids': {				'label': 'Grids'			},			'misc': {				'label': 'Misc'			}		}	}); $('#wpTextbox1').wikiEditor('addToToolbar', {		'section': 'templates',		'group': 'infoboxes',		'tools': {			'main': {				label: 'Block/Item',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{Infobox\n|name=' + page + '\n|imageicon=\n|type=item\n|mod=Mod\n}}'					}				}			},			'mod': {				label: 'Mod',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{Infobox mod\n|name=' + page + '\n|image=' + page + ' Icon.png\n|author=Author\n|version=1\n|url=http://example.com\n}}'					}				}			}		}	}); $('#wpTextbox1').wikiEditor('addToToolbar', {		'section': 'templates',		'group': 'cg',		'tools': {			'crafting': {				label: 'Crafting Table',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{Cg/Crafting Table\n|A1=\n|B1=\n|C1=\n|A2=\n|B2=\n|C2=\n|A3=\n|B3=\n|C3=\n|O={' + '{Gc|mod=ABBR|link=none|' + page + '}}\n}}'					}				}			},			'furnace': {				label: 'Furnace',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{Cg/Furnace\n|I=\n|O={' + '{Gc|mod=ABBR|link=none|' + page + '}}\n}}'					}				}			}		}	}); $('#wpTextbox1').wikiEditor('addToToolbar', {		'section': 'templates',		'group': 'grids',		'tools': {			'item': {				label: 'Item',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{Gc|mod=AABR|dis=false|Item}}'					}				}			},			'ore': {				label: 'Ore Dictionary',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{O|entry}}'					}				}			},			'liquid': {				label: 'Liquid',				type: 'button',				icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{T|Liquid|amount}}' }				}			},			'string': { label: 'String', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', action: { type: 'encapsulate', options: { pre: '{' + '{S|Text}}' }				}			}		}	});	$('#wpTextbox1').wikiEditor('addToToolbar', { 'section': 'templates', 'group': 'misc', 'tools': { 'pn': { label: 'Icon with Link', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', action: { type: 'encapsulate', options: { pre: '{' + '{Pn|Item|ABBR}}' }				}			},			'p': { label: 'Icon', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', action: { type: 'encapsulate', options: { pre: '{' + '{P|Item|ABBR}}' }				}			},			'l': { label: 'Language Link', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', action: { type: 'encapsulate', options: { pre: '{' + '{L|Link}}' }				}			},			'dis': { label: 'Disambiguation', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', action: { type: 'encapsulate', options: { pre: '{' + '{Disambiguation}}' }				}			},			'stub': { label: 'Stub', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', action: { type: 'encapsulate', options: { pre: '{' + '{Stub|date={' + '{subst:#time:F Y}}}}' }				}			},			'cleanup': { label: 'Cleanup', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', action: { type: 'encapsulate', options: { pre: '{' + '{Cleanup|date={' + '{subst:#time:F Y}}}}' }				}			},		}	}); };

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */ if($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1){ mw.loader.using('user.options', function{		// This can be the string "0" if the user disabled the preference (mw:phab:T54542)		if(mw.user.options.get('usebetatoolbar') == 1){			$.when(mw.loader.using('ext.wikiEditor.toolbar'), $.ready).then(customizeToolbar);		}	}); }