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': 'Grid Icons'			},			'misc': {				'label': 'Misc'			}		}	}); $('#wpTextbox1').wikiEditor('addToToolbar', {		'section': 'templates',		'group': 'infoboxes',		'tools': {			'main': {				label: 'Block/Item',				type: 'button',				icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/3/3b/Icon_Block_Item.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: '//hydra-media.cursecdn.com/ftb.gamepedia.com/5/51/Icon_Mod.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: '//hydra-media.cursecdn.com/ftb.gamepedia.com/d/df/Icon_Crafting_Table.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: '//hydra-media.cursecdn.com/ftb.gamepedia.com/1/18/Icon_Furnace.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: '//hydra-media.cursecdn.com/ftb.gamepedia.com/0/05/Icon_Item.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{Gc|mod=AABR|dis=false|Item',						post: '}}'					}				}			},			'ore': {				label: 'Ore Dictionary',				type: 'button',				icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/0/0e/Icon_Ore_Dictionary.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{O|entry',						post: '}}'					}				}			},			'liquid': {				label: 'Liquid',				type: 'button',				icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/d/d7/Icon_Liquid.png',				action: {					type: 'encapsulate',					options: {						pre: '{' + '{T|Liquid|amount',						post: '}}'					}				}			},			'string': {				label: 'String', type: 'button', icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/c/c8/Icon_String.png', action: { type: 'encapsulate', options: { pre: '{' + '{S|Text', post: '}}' }				}			}		}	});	$('#wpTextbox1').wikiEditor('addToToolbar', { 'section': 'templates', 'group': 'misc', 'tools': { 'pn': { label: 'Icon with Link', type: 'button', icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/f/f9/Icon_Icon_with_Link.png', action: { type: 'encapsulate', options: { pre: '{' + '{Pn|Item', post: '|ABBR}}' }				}			},			'p': { label: 'Icon', type: 'button', icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/e/ec/Icon_Icon.png', action: { type: 'encapsulate', options: { pre: '{' + '{P|Item', post: '|ABBR}}' }				}			},			'l': { label: 'Language Link', type: 'button', icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/b/b8/Icon_Language_Link.png', action: { type: 'encapsulate', options: { pre: '{' + '{L|Link', post: '}}' }				}			},			'dis': { label: 'Disambiguation', type: 'button', icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/3/30/Icon_Disambiguation.png', action: { type: 'encapsulate', options: { pre: '{' + '{Disambiguation}}' }				}			},			'stub': { label: 'Stub', type: 'button', icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/d/d7/Icon_Stub.png', action: { type: 'encapsulate', options: { pre: '{' + '{Stub|date={' + '{subst:#time:F Y}}}}' }				}			},			'cleanup': { label: 'Cleanup', type: 'button', icon: '//hydra-media.cursecdn.com/ftb.gamepedia.com/2/29/Icon_Cleanup.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);		}	}); }