Jump to content

MediaWiki:Common.js/edit: Difference between revisions

m (→‎Defining new buttons: wording/formatting)
Line 171: Line 171:


==Re-ordering the buttons==
==Re-ordering the buttons==
XEB parses a string variable called <tt>XEBOrder</tt> to know which buttons to place in the toolbar in which order.  If there is no <tt>XEBOrder</tt> variable defined already, it supplies the value for <tt>XEBOrder</tt> from the hardcoded variable <tt>XEBOrder2</tt>. Therefore, you can use the custom JavaScript page provided by MediaWiki, [[Special:MyPage/monobook.js|monobook.js]], to set <tt>XEBOrder</tt>, and if you then run the XEB code afterwards, it will use your own button-order string.
XEB parses a string variable called <tt>XEBOrder</tt> to know which buttons to place in the toolbar in which order.  If there is no string passed in to set <tt>XEBOrder</tt>, it uses its own hardcoded value in order to provide a default editing toolbar. To set this variable and get your own custom toolbar, you use a custom JavaScript page under your user name, such as [[Special:MyPage/monobook.js|User:YourName/monobook.js]] or [[Special:MyPage/vector.js|User:YourName/vector.js]].


First, look at the page with [[XEB]]'s code -- find the <tt>initButtons()</tt> function, and you'll see the default button order:
First, look at [[MediaWiki:Common.js/edit.js|the edit.js page]] with XEB's code -- find the <tt>initButtons()</tt> function, and you'll see the default button order (actually called <tt>XEBOrder2</tt>):


<code>
<code>
Line 179: Line 179:
</code>
</code>


Let's say that you wanted to move the "Insert signature" button from the right to the left side of the toolbar. Looking at the table on the right, you can see that the signature button has the ID "9", so you would add this text to [[Special:MyPage/monobook.js|your monobook.js]]:
Let's say that you wanted to move the "Insert signature" button from the right to the left side of the toolbar. Looking at the table on the right, you can see that the signature button has the ID "9", so you would add this text to your custom JS page:
<code>
<code>
XEBOrder="9,0,1,U,F,D,C,D1,4,A,2,3,E,G,8,H";
XEBOrder="9,0,1,U,F,D,C,D1,4,A,2,3,E,G,8,H";
Line 185: Line 185:
</code>
</code>


Notice that the "9" comes first now.  You will not see the "Insert signature" button move up in the actual toolbar, however, until your cache is cleared. [[wikipedia:Bypass_your_cache|Here are some instructions]] from Wikipedia, but if you are using a Mac and Google Chrome, you should be hitting Shift-Reload to refresh the cache for the page. Note that you will have to be on a wiki page in editing mode before trying this if you want to see the change take effect before your eyes.
Notice that the "9" comes first now.  You will not see the "Insert signature" button move up in the actual toolbar, however, until your [[wikipedia:WP:BYPASS|cache is cleared]]. Note that you will have to be on a wiki page in editing mode before trying this if you want to see the change take effect before your eyes.


==Adding buttons==
==Adding buttons==