Difference between revisions of "User:King of Herdaz/Toolbar customization"

m
no edit summary
m (→‎Premade Buttons: put in alphabetical order)
m
 
(11 intermediate revisions by the same user not shown)
The editing toolbar is a versatile and very useful tool that can be used to make working on the wiki much easier. While the basic version (which is an option in your [[Special:Preferences#mw-prefsection-editing|preferences]]) has some use, the main benefit comes when you customize your toolbar. In this guide there are tested premade elements that you can use as well as guides to creating and modifying your own buttons, booklets, and dropdowns.
 
All modifications to the toolbar are made on your [[Special:MyPage/common.js|common.js]] subpage. To find thisyour common.js page youclick canon typethis out the url, or you can go to yourlink [[Special:Preferences#mw-prefsection-rendering|preferencesMyPage/common.js]] and click oncreate the redlink that will be found therepage (if you have not yetalready createddone the pageso).
 
While modifying your toolbar can seem scary, once you get the hang of it, it really isn't a big deal. Anything you do can be easily undone so feel free to play around and experiment with different things.
You do not need any knowledge of how the system works to use the premade elements on this page, simply copy-paste them into your toolbar as directed and you are good to go.
 
Changes you make to your [[Special:MyPage/common.js|common.js]] page only take effect after you save the page, so to check that the changes you have made worked you should save your [[Special:MyPage/common.js|common.js]] page and try to edit some other wiki page. If you see the default toolbar when you edit a page that means that your edits "broke" your toolbar. Consult the [[#General Guidelines|#general guidelines]] for help debugging your code.
 
If the changes you made are not working, or if you would like assistance creating your own toolbar you can DM <code>kingofherdaz</code> on Discord for help.
 
== Basic ==
group: 'insert',
tools: {
"code": {
label: 'Art infobox',
type: 'button',
group: 'insert',
tools: {
"artist-attribution"artistAttribution: {
label: 'Artist Attribution',
type: 'button',
type: 'encapsulate',
options: {
pre: '| <small><center>by {' + '{a|',
post: '}}</center></small>'
}
group: 'insert',
tools: {
"artist-page"artistPage: {
label: 'Artist Page',
type: 'button',
type: 'encapsulate',
options: {
pre: '{'+'{artist' + '\n' + '|image=' + '\n' + '|alias=' + '\n' + '|fb=' + '\n' + '|reddit=' + '\n' + '|behance=' + '\n' + '|da=' + '\n' + '|ig=' + '\n' + '|as=' + '\n' + '|tumblr=' + '\n' + '|twitter=' + '\n' + '|site=' + '\n' + '|license=all|some|none|official' + '\n' + '|contact=' + '\n' + '|type=fan|interior|cover|multimedia' + '\n' + '|no-notify=y' + '\n' + '}}' + '\n\n' + '<' + 'br style="clear:right;"/>' + '\n' + '== Gallery ==' + '\n' + '<' + 'gallery caption="Gallery" mode="packed" heights=200px>' + '\n\n' + '<' + '/gallery>' + '\n' + '{' + '{meta/done}}'
}
}
group: 'insert',
tools: {
"break": {
label: 'Break tag',
type: 'button',
group: 'insert',
tools: {
"category": {
label: 'Category',
type: 'button',
group: 'insert',
tools: {
"code": {
label: 'Code',
type: 'button',
group: 'insert',
tools: {
"columns": {
label: 'Columns',
type: 'button',
group: 'insert',
tools: {
"hidden": {
label: 'Hidden text',
type: 'button',
group: 'insert',
tools: {
"image": {
label: 'Image template',
type: 'button',
group: 'insert',
tools: {
"link": {
label: 'Link',
type: 'button',
group: 'insert',
tools: {
"wikipedia": {
label: 'Wikipedia',
type: 'button',
|
<pre>
//Add new references dropdown to the "advanced" section
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
groups: {
list: {
tools: {
references: {
label: 'referencesrefs',
type: 'select',
list: {
'book-ref': {
label: '{' + '{book ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{book ref|',
post: '}}'
}
}
},
'wob-ref': {
label: '{' + '{wob ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{wob ref|',
post: '}}'
}
}
},
'ref-plaintext': {
label: '{' + '{ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{ref|text=',
post: '}}'
}
}
},
'epigraph-ref': {
label: '{' + '{epigraph ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{epigraph ref|',
post: '}}'
}
}
},
'au-ref': {
label: '{' + '{au ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{au ref|',
post: '}}'
}
}
},
'msh-ref': {
label: '{' + '{msh ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{msh ref|',
post: '}}'
}
}
},
'tes-ref': {
label: '{' + '{tes ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{tes ref|',
post: '}}'
}
}
},
'file-ref': {
label: '{' + '{file ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{file ref|',
post: '}}'
}
}
},
'map-refmapref': {
label: '{' + '{map ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{map ref|',
post: '}}'
}
}
},
'url-ref': {
label: '{' + '{url ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{url ref|url=',
post: '|text=|date=|site=}}'
}
}
},
'17s-ref': {
label: '{' + '{17s ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{17s ref|topic/news/post',
post: '|id#|description|date=}}'
}
}
}
}
}
}
}
}
} );
</pre>
|}
|
<pre>
//Add new build-a-box dropdown to the "advanced" section
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
groups: {
list: {
tools: {
simplecharacterinfobox: {
label: 'build-a-box',
type: 'select',
list: {
'start': {
label: '{' + '{character',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{character'
}
}
},
'residence': {
label: '|residence=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|residence='
}
}
},
'imageparam': {
label: '|image=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|image='
}
}
},
'profession': {
label: '|profession=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|profession='
}
}
},
'#profession': {
label: '|#profession=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|#profession='
}
}
},
'skills': {
label: '|skills=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|skills='
}
}
},
'species': {
label: '|species=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|species='
}
}
},
'abilities': {
label: '|abilities=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|abilities='
}
}
},
'ethnicity': {
label: '|ethnicity=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|ethnicity='
}
}
},
'born': {
label: '|born=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|born='
}
}
},
'died': {
label: '|died=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|died='
}
}
},
'nationality': {
label: '|nationality=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|nationality='
}
}
},
'bonded': {
label: '|bonded=',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|bonded='
}
}
}
}
}
}
}
}
} );
</pre>
|}
|
<pre>
//Add new infobox endings dropdown to the "advanced" section
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
groups: {
list: {
tools: {
endings: {
label: 'ends',
type: 'select',
list: {
'sa': {
label: 'Stormlight',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|world=Roshar' + '\n' + '|universe=[[Cosmere]]' + '\n' + '|books=[[The Stormlight Archive]]' + '\n' + '}}'
}
}
},
'mbe1': {
label: 'MB Era 1',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|world=Scadrial' + '\n' + '|universe=[[Cosmere]]' + '\n' + '|books=[[Mistborn Era 1]]' + '\n' + '}}'
}
}
},
'mbe2': {
label: 'MB Era 2',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|world=Scadrial' + '\n' + '|universe=[[Cosmere]]' + '\n' + '|books=[[Mistborn Era 2]]' + '\n' + '}}'
}
}
},
'wb': {
label: 'Warbreaker',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|world=Nalthis' + '\n' + '|universe=[[Cosmere]]' + '\n' + '|books=[[Warbreaker]]' + '\n' + '}}'
}
}
},
'ela': {
label: 'Elantris',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|world=Sel' + '\n' + '|universe=[[Cosmere]]' + '\n' + '|books=[[Elantris (book)|Elantris]]' + '\n' + '}}'
}
}
},
'alc': {
label: 'Alcatraz',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|earth=Alcatraz' + '\n' + '|books=[[Alcatraz Versus the Evil Librarians (series)|Alcatraz Versus the Evil Librarians]]' + '\n' + '}}'
}
}
},
'ws': {
label: 'White Sand',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|world=Taldain' + '\n' + '|universe=[[Cosmere]]' + '\n' + '|books=[[White Sand]]' + '\n' + '}}'
}
}
},
'skywardfirst-born': {
label: 'SkywardFirstborn',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '|worldnation=High Empire' + '\n' + '|books=[[Firstborn]]' + '\n' + '}}',
}
post: '\n' + '|universe=[[Cytoverse]]' + '\n' + '|books=[[Skyward (series)]]' + '\n' + '}}'
}
},
} 'skyward': {
label: }'Skyward',
action: }{
type: 'encapsulate',
}
} options: {
pre: '\n' + '|world=',
}
post: '\n' + '|universe=[[Cytoverse]]' + '\n' + '|books=[[Skyward (series)]]' + '\n' + '}}'
} );
}
}
}
}
}
}
}
}
} );
</pre>
|}
|
<pre>
//Add new page ends dropdown to the "advanced" section
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
groups: {
list: {
tools: {
bottoms: {
label: 'bottoms',
type: 'select',
list: {
'pagename': {
label: '{' + '{SUBST:PAGENAME}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '\'\'\'{' + '{SUBST:PAGENAME}}\'\'\''
}
}
},
'notessubpagename': {
label: '=={' Notes+ =='{SUBST:SUBPAGENAME}}',
action: {
type: 'encapsulate',
options: {
pre: '\n\n' + '==\'\'\'{' Notes+ =='{SUBST:SUBPAGENAME}}\'\'\''
}
}
},
'refsectionnotes': {
label: '<'== +Notes 'references/>==',
action: {
type: 'encapsulate',
options: {
pre: '\n\n' + '<'== + 'referencesNotes />=='
}
}
},
'stubrefsection': {
label: '{<' + '{stub}}references/>',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{<' + '{stub}}references />'
}
}
},
'partialstub': {
label: '{' + '{partialstub}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{partialstub}}'
}
}
},
'completepartial': {
label: '{' + '{completepartial}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{completepartial}}'
}
}
},
'alcatrazcomplete': {
label: '{' + '{Alcatrazcomplete}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{Alcatrazcomplete}}'
}
}
},
'elantrisalcatraz': {
label: '{' + '{ElantrisAlcatraz}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{ElantrisAlcatraz}}'
}
}
},
'mbera1elantris': {
label: '{' + '{Mistborn|Era 1Elantris}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{Mistborn|Era 1Elantris}}'
}
}
},
'mbera2mbera1': {
label: '{' + '{Mistborn|Era 21}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{Mistborn|Era 21}}'
}
}
},
'reckonersmbera2': {
label: '{' + '{ReckonersMistborn|Era 2}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{ReckonersMistborn|Era 2}}'
}
}
},
'skyreckoners': {
label: '{' + '{SkywardReckoners}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{SkywardReckoners}}'
}
}
},
'stormlightsky': {
label: '{' + '{StormlightSkyward}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{StormlightSkyward}}'
}
}
},
'warbreakerstorm': {
label: '{' + '{WarbreakerStormlight}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{WarbreakerStormlight}}'
}
}
},
'whitesandwarbreaker': {
label: '{' + '{White SandWarbreaker}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{White SandWarbreaker}}'
}
}
},
} 'firstborn': {
label: '{' + '{Firstborn}}',
action: }{
type: 'encapsulate',
}
options: {
}
pre: '\n' + '{' + '{Firstborn}}'
} );
}
} },
'whitesand': {
label: '{' + '{White Sand}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{White Sand}}'
}
}
}
}
}
}
}
}
} );
</pre>
|}
//These next two reference templates are very long so they are done differently
{
'action': {
'type': 'encapsulate',
options: {
pre: '{' + '{url ref|url=',
}
},
'label': '{' + '{url ref}}'
},
{
'action': {
'type': 'encapsulate',
options: {
pre: '{' + '{17s ref|topic/news/post',
In this section we will present a guide to creating your own buttons, booklets and dropdowns for your toolbar. While there are other options and ways to do these things, for the sake of clarity and simplicity here we have limited this guide to the things that are the most useful and easiest to understand. For a more complete (though less clear) guide to the toolbar see [https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization Mediawiki's full guide].
 
If the changes you made are not working and you would like assistance you can DM <code>King of Herdaz#2300</code> on Discord for help.
 
=== General Guidelines ===
 
* If you are having trouble, look at the example elements presented above and use them as a guide. Or simply copy one of the sample elements and modify it following the steps presented in this guide.
* To add a one line comment put <code>//</code> at the beginning of a line followed by the text of the comment. Whatever you write after a <code>//</code> on that line will not affect your code.
* For multi line comments put your comments between <code>/*</code> and <code>*/</code>.
* Code for your toolbar must have the exact correct number of curly brackets (<code>{</code>), square brackets (<code>[</code>), apostrophes (<code>'</code>), parentheses (<code>(</code>), and commas (<code>,</code>) to work. If your toolbar breaks after you changed something check to see if you missed or added an extra one of these.
* While not strictly necessary, it is a good idea to split code in your toolbar over multiple lines and with whitespace differentiating each "level" of the toolbar in a manner similar to how it is done in the examples on this page. This will help you keep track of the different parts of your code and will help you keep track of the number of open and closed curly brackets in your code.
 
==== Strings ====
A string is a piece of text within the toolbar that is encased between two apostrophes {<code>'</code>). Strings are used in labels and actions. They should follow the following guidelines:, though some of them are not relevant to labels.
 
* Inserting <code>' + '</code> between two parts of a string can have effects on your [[Special:MyPage/common.js|common.js]] page (as will be discussed below), but will not appear on a page when the action is called, or be included in the label(s) on the actual toolbar. For example, both <code><nowiki><br />{{stub}}</nowiki></code> and <code><nowiki><{' + 'br />{stub}}</nowiki></code> will produce the same result (<code><nowiki><br />{{stub}}</nowiki></code>) on the page when they are called.
* When writing out templates, whether for a label or an action, you must insert <code>' + '</code> between the first two curly brackets. For example, instead of writing <code><nowiki>{{Stormlight}}</nowiki></code> you should write <code><nowiki>{' + '{Stormlight}}</nowiki></code>. This prevents the template from applying categories to your [[Special:MyPage/common.js|common.js]] page and also prevents it from being listed on the relevant template's list of pages that use it.
* For the same reason you must also do this when writing category tags. For example, instead of writing <code><nowiki>[[Category: Stormlight]]</nowiki></code> you should write <code><nowiki>[' + '[Category: Stormlight]]</nowiki></code>.
* When writing code for substitutions this is even more important, since if you do not do it then the substitution will be performed when you save your [[Special:MyPage/common.js|common.js]] page. For example, instead of writing <code><nowiki>{{SUBST:PAGENAME}}</nowiki></code> you should write <code><nowiki>{' + '{SUBST:PAGENAME}}</nowiki></code>.
 
==== DefinitionsInternal Names ====
;Internal Names:
Many things in the toolbar must be given internal names. Internal names help the program differentiate between different parts of the toolbar. What you use as an internal name will not affect the toolbar so you can use any string of characters.
 
Internal names must not contain any spaces. If you want an internal name to be more than one word you can use a dash (<code>-</code>) instead of a space. You should not reuse internal names within your entire toolbar. If you use the same internal name multiplemore timesthan once then either strange things will happen or the toolbar will simply break.
 
;==== Labels: ====
A label is the name of an element that will be displayed on the toolbar. For dropdowns these are displayed in the dropdown itself, while with buttons the label is shown when you hover your cursor over the icon for the button. Unlike internal names theselabels can be reused.
 
{{anchor|action}}{{anchor|actions}}
==== Actions ====
While there are other types of actions that you can do, in this guide we focus on the <code>encapsulate</code> action as it is the easiest to understand and use. This action pastes one snippet of textstring before the highlighted text (or you cursor) and a second snippetstring after the highlighted text. The second snippetstring (after <code>post:</code>) is optional and can be deleted if you only want to insert one string of text.
 
The code for this action is as follows, and this format is the same for dropdowns, booklets and buttons.
<code>XXXX</code> is replaced by the string that goes before the highlighted text/cursor, and <code>YYYY</code> is replaced by the string that goes after the highlighted text/cursor.
 
* To have an action include a line break insert <code>\n</code> into the snippetstring at the place you want it to be. For stylistic reasons some people will put <code>' + '</code> between instances of <code>\n</code> and other text in their snippetsstrings, but this does not have any effect on the output of the action and can be omitted if you want.
* To have an action include an apostrophe (<code>'</code>) within the string that it inserts, place <code>\'</code> into your code at the place you want the apostrophe to go. If you do not include the backslash (<code>\</code>) and type additional apostrophes in your code it will cause the toolbar to break. You must put an additional backslash with each additional apostrophe you add to a string.
 
=== Creating Your Own Buttons ===
group: 'BBBB',
tools: {
"CCCC": {
label: 'DDDD',
type: 'button',
type: 'select',
list: {
'WWWW': {
label: 'XXXX',
action: {
<pre>
},
'WWWW': {
label: 'XXXX',
action: {
<pre>
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'AAAA': {
'type': 'toolbar',
'label': 'BBBB'
}
}
<pre>
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section':: 'CCCC',
'groups': {
'DDDD': {
'label': 'EEEE'
}
}
Here we will tell you how to create booklets that contain pages of characters. For other things you can do with booklets see [https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization Mediawiki's guide].
 
A key difference between dropdowns and booklets is that while with dropdowns every option must be an action, with booklets that is not the case. Booklets contain <code>pages</code> of <code>characters</code> that when clicked paste text into the page. Characters can be either simple snippets of codestrings or [[#actions]]. This can make it easier to add items to booklets than to dropdowns, though booklets do have their complexities.
 
To create a new booklet section add the following code to your [[Special:MyPage/common.js|common.js]] page between the two [[#Basic]] sections and change the following things:
//Optional description
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'AAAA': {
'type': 'booklet',
'label': 'BBBB',
'pages': {
</pre>
 
<pre>
//Optional description
'section-CCCC': {
'label': 'DDDD',
'layout': 'characters',
'characters': [
</pre>
 
<pre>
{
'action': {
'type': 'encapsulate',
'options': {
'pre': 'XXXX',
'post': 'YYYY'
}
},
'label': 'ZZZZ'
},
</pre>
//Remove the default <ref> button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section':: 'main',
'group':: 'insert',
'tool':: 'reference'
});</pre>
|}
//remove the bulleted list button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section':: 'advanced',
'group':: 'format',
'tool':: 'ulist'
});</pre>
|}
//remove the numbered list button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section':: 'advanced',
'group':: 'format',
'tool':: 'olist'
});</pre>
|}
//remove the default <br> button (to replace it with a <br/> button which is preferred on the Coppermind)
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section':: 'advanced',
'group':: 'format',
'tool':: 'newline'
});</pre>
|}
//remove table button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section':: 'advanced',
'group':: 'insert',
'tool':: 'table'
});</pre>
|}
//remove File button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section':: 'main',
'group':: 'insert',
'tool':: 'file'
});</pre>
|}
//remove original link button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section':: 'main',
'group':: 'insert',
'tool':: 'link'
});</pre>
|}
<pre>
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section':: 'XXXX',
'group':: 'YYYY',
'tool':: 'ZZZZ'
});</pre>
|}
Autopatrolled, Editors
8,718

edits