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

 
== Customization==
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].
 
=== General Guidelines ===
Here are some rules and tips for writing code on for your toolbar:
 
* 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.
* You should not reuse internal names within your entire toolbar. If you use the same internal name multiple times then either strange things will happen or the toolbar will simply break.
* To add a comment put <code>//</code> at the beginning of a line followed by the text of the comment. Whatever you write after a <code>//</code> will not affect your code.
 
* Inserting <code>' + '</code> between two pieces of text can have effects on your <code>common.js</code> page (as will be discussed below), but will not appear on a page when the action is called. For example, both <code><nowiki><br /></nowiki></code> and <code><nowiki><' + 'br /></nowiki></code> will produce the same result (<code><nowiki><br /></nowiki></code>) on the page when they are called.
* 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 <code>common.js</code> page. For example, instead of writing <code><nowiki>{{SUBST:PAGENAME}}</nowiki></code> you should write <code><nowiki>{' + '{SUBST:PAGENAME}}</nowiki></code>.
* You cannot reuse internal names within your entire toolbar.
* To add a comment put <code>//</code> at the beginning of a line followed by the text of the comment. Whatever you write after a <code>//</code> will not affect your code.
 
==== Actions ====
While there are other types of actions that you can do with buttons, 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 text before the highlighted text (or you cursor) and a second snippet after the highlighted text. The second snippet (<code>post:</code>) can be deleted if you only want to insert one snippet of text.
 
The code for this action is as follows, and this format is the same for both dropdowns, booklets and buttons. <!--If I include other options then change this-->
 
<pre>
 
=== Booklets ===
Booklets are a type of section within the editing toolbar. The <code>Special characters</code> and <code>Help</code> sections of the default toolbar are examples of booklets. BookletsHere we will tell you how to create booklets that contain pages of characters (which can eitheralso containbe [[#Actions]]). For other things you can do with booklets see [https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization Mediawiki's guide].
 
Booklets and dropdowns perform similar functions and which of the two you choose to use is mainly a matter of personal preference.
 
To create a new booklet section add the following code to your <code>/common.js</code> page:
 
<pre>
//Optional description
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'AAAA': {
'type': 'booklet',
'label': 'BBBB',
'pages': {
</pre>
 
Followed by this:
 
<pre>
}
}
}
});
</pre>
 
Pages you create for this booklet section will go between these two sections of code.
 
==== Pages ====
To create a new page for a booklet insert the following code
<pre>
//Optional description
'section-CCCC': {
'label': 'DDDD',
'layout': 'characters',
'characters': [
</pre>
 
Place the characters you want in this page here followed by this:
 
<pre>
]
},
</pre>
 
 
{| class="mw-collapsible mw-collapsed" width=100%
|-
|
|-
|
<pre>
//add new section to editing toolbar
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'snippets': {
'type': 'booklet',
'label': 'Useful Stuff',
'pages': {
//page of commonly used infoboxes
'section-infoboxes': {
'label': 'Infoboxes',
'layout': 'characters',
'characters': [
'{'+'{architecture',
'{'+'{business',
'{'+'{character',
'{'+'{event',
'{'+'{food',
'{'+'{geography',
'{'+'{group',
'{'+'{item',
'{'+'{lifeform',
'{'+'{literature',
'{'+'{location',
'{'+'{settlement',
'{'+'{vehicle',
]
},
//page of commonly used infobox parameters
'section-params': {
'label': 'Infobox Parameters',
'layout': 'characters',
'characters': [
'\n' + '|residence=',
'\n' + '|profession=',
'\n' + '|#profession=',
'\n' + '|species=',
'\n' + '|abilities=',
'\n' + '|ethnicity=',
'\n' + '|born=',
'\n' + '|died=',
'\n' + '|nationality=',
'\n' + '|image=',
'\n' + '|residence=',
'\n' + '|world=Scadrial',
'\n' + '|world=Roshar',
'\n' + '|world=Nalthis',
'\n' + '|world=Taldain',
'\n' + '|earth=Alcatraz',
'\n' + '|universe=[[Cosmere]]',
'\n' + '|books=[[Mistborn Era 1]]',
'\n' + '|books=[[Mistborn Era 2]]',
'\n' + '|books=[[The Stormlight Archive]]',
'\n' + '|books=[[Warbreaker]]',
//Alcatraz is very long so it has to be done differently
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '\n' + '|books=[[Alcatraz Versus the Evil Librarians (series)|Alcatraz Versus the Evil Librarians]]'
}
},
'label': '|books=Alcatraz'
},
]
},
//page of stuff commonly used at the end of an article
'section-bottom': {
'label': 'Bottom of Page',
'layout': 'characters',
'characters': [
'== Notes ==',
'\n' + '<' + 'references/>',
'\n' + '{' + '{stub}}',
'\n' + '{' + '{partial}}',
'\n' + '{' + '{complete}}',
'\n' + '{' + '{Alcatraz}}',
'\n' + '{' + '{Elantris}}',
'\n' + '{' + '{Mistborn|Era 1}}',
'\n' + '{' + '{Mistborn|Era 2}}',
'\n' + '{' + '{Reckoners}}',
'\n' + '{' + '{Skyward}}',
'\n' + '{' + '{Stormlight}}',
'\n' + '{' + '{Warbreaker}}',
'\n' + '{' + '{White Sand}}',
]
},
//page of other useful stuff
'section-tags': {
'label': 'Other Stuff',
'layout': 'characters',
'characters': [
'\n' + '{' + '{spoiler|sa4}}',
'\n' + '{' + '{update|sa4}}',
'\n' + '{' + '{demoted|sa4}}',
'{' + '{for|/Gallery|more images}}',
'\n' + '{' + '{columns|count=2|',
'<br/>',
'{' + '{expand}}',
'{' + '{cite}}',
'{' + '{clarify}}',
'{' + '{disputed}}',
'{' + '{delete}}',
'{' + '{move|}}',
'{' + '{merge|}}',
'{' + '{anchor|}}',
'{' + '{theory}}',
'{' + '{uncanonical}}',
'{' + '{copyright}}',
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '{' + '{cat tag|',
'post': '}}'
}
},
'label': '{' + '{cat tag|}}'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '{' + '{tag+|',
'post': '}}'
}
},
'label': '{' + '{tag+|}}'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '{' + '{tag|',
'post': '}}'
}
},
'label': '{' + '{tag|}}'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<' + 'pre>',
'post': '<' + '/pre>'
}
},
'label': '<' + 'pre>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<code>',
'post': '</code>'
}
},
'label': '<code>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<strike>',
'post': '</strike>'
}
},
'label': '<strike>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<DynamicPageList>' + '\n' + 'mode=ordered' + '\n' + 'category=' + '\n' + 'notcategory=' + '\n' + 'namespace=' + '\n' + 'ordermethod=sortkey' + '\n' + 'order=ascending' + '\n' + '</DynamicPageList>'
}
},
'label': '<dynamicpagelist>'
},
'{' + '{for|:Category:Residents of {' + '{SUBST:PAGENAME}}|a full list see}}',
'{' + '{Special:PrefixIndex/{' + '{FULLPAGENAME}}/|stripprefix=1}}',
]
}
}
}
}
});
</pre>
|}
 
=== Removing default elements ===
Autopatrolled, Editors
8,718

edits