User:Karl Dickman/Threads/06/11/27a
From Wikipedia, the free encyclopedia
[edit] Adding standard editbuttons to XEB script
Note: this comment is part of a synchronised thread. You can reply by clicking the [edit] link next to the comment's heading, or following this link. To ensure that you can see any further responses I make, add this page to your watchlist. Once you have replied, feel free to remove this boilerplate.
As you know, scripts exist to suppress the standard editbuttons (bold, italic, link, headline, image, etc.) I see this as a first step toward maximum customisation. For example, it make ssense to have purely formatting buttons, like underline, strike, bold, and italic right next to each other, and to have both the basic image button and the advanced image button right next to each other. The easiest way to do this would be to make the following change to User:MarkS/extraeditbuttons.js:
Current revision | Your text | ||
Line 23: | Line 23: | ||
} | } | ||
- |
var Isrc='http://upload.wikimedia.org/wikipedia/commons/'; |
+ |
//Converting Isrc into an array would probably be the easiest way to deal with the fact that the standard buttons and custombuttons are on different servers. The other options are: specify the whole URL in the code, or upload all of the standard buttons to the commons. |
+ | var Isrc[0]='http://upload.wikimedia.org/wikipedia/commons/'; | ||
+ | var Isrc[1]='http://en.wikipedia.org/skins-1.5/common/images/button_'; | ||
var BDict={ | var BDict={ | ||
+ | '0A':['bold.png','Bold text','\'\'\,'\'\'\,'Bold text'], | ||
+ | '0B':['italic.png','Italic text','\'\,'\'\,'Italic text'], | ||
+ | '0C':['link.png','Internal link','[[',']]','Link title'], | ||
+ | '0D':['extlink.png','External link (remember http:// prefix)','[',']','http://www.example.com link title'], | ||
+ | '0E':['headline.png','Level 2 headline','\n== ',' ==\n','Headline text'], | ||
+ | '0F':['image.png','Embedded image','[[Image:',']]','Example.jpg'], | ||
+ | '0G':['media.png','Media file link','[[Media:',']]','Example.ogg'], | ||
+ | '0H':['math.png','Mathematical formula (LaTeX)','<math>','<\/math>','Insert formula here'], | ||
+ | '0I':['nowiki.png','Ignore wiki formatting','<nowiki>','<\/nowiki>','Insert non-formatted text here'], | ||
+ | '0J':['sig.png','Your signature with timestamp','--~~~~',,], | ||
+ | '0K':['hr.png','Horizontal line (use sparingly)','\n----\n',,], | ||
'A':['e/e9/Button_headline2.png','Secondary headline','\n===','===','Secondary headline'], | 'A':['e/e9/Button_headline2.png','Secondary headline','\n===','===','Secondary headline'], | ||
'B':['1/13/Button_enter.png','Line break','<br />',,], | 'B':['1/13/Button_enter.png','Line break','<br />',,], | ||
Line 70: | Line 81: | ||
for (var b in XEBOrder) { | for (var b in XEBOrder) { | ||
var bc = BDict[XEBOrder[b]]; | var bc = BDict[XEBOrder[b]]; | ||
+ | //Not sure what to do about Isrc here | ||
addCustomButton(Isrc+bc[0],bc[1],bc[2],bc[3],bc[4]) | addCustomButton(Isrc+bc[0],bc[1],bc[2],bc[3],bc[4]) | ||
} | } |
Karl Dickman talk 00:00, 28 November 2006 (UTC)
- I defintely think its a good idea to include the standard buttons within XEB so you can then group similar buttons together.
- Isrc is a just a way of keeping the urls in each button definition line short. Just like you I can't see a way to do the final section of code if we use an array. The only alternative I can think of is to add Isrc to the rest of the url when each button is declared. This would make each button line slightly longer but would still be manageble.
- I have just been looking at the German version by Olliminatore. As far as I can see he has added some really nice pieces of extra code. Firstly he has something to remove the standard toolbar buttons (which would go nicely with being able to add them back in whereever you want with XEB) and he looks to have some code to extend the functionality of the buttons - it looks like when you press the table button you get a popup asking what size table you want.
- I will get the standard buttons added asap and then look at seeing if we can copy some of the German code over. --MarkS (talk) 17:27, 30 November 2006 (UTC)
I seem to remember a popup for tables being imported here from the French Wikipedia, but it didn't work in Internet Explorer. Just something for you to check. Karl Dickman talk 19:23, 30 November 2006 (UTC)
Update: I successfully added said buttons to the script. My apologies if you feel I've trespassed in any way by doing so.
Cheers and good luck, Karl Dickman talk 08:01, 1 December 2006 (UTC)
-
- That XEB buttons are not really needed, we can load these from
mwEditButtons
to add these to BDict (and give these simply the indexes as names (1-10)), but we need BDict first load inaddOnloadHook
. These give us a additional possibility to add an optional parameter for additional custom user buttons (what you've requested too). I think I will do these for the german version. —Olliminatore 12:48, 1 December 2006 (UTC)
- That XEB buttons are not really needed, we can load these from
- Thanks for adding the buttons to the script. I have now added Olliminatore's remove buttons function to the dev version. This seems to be working for me. You just need to add something like var rmEditButtons = [2,6,7,10]; to your monobook.js to remove the buttons. The index of the buttons to remove starts from 0. I haven't tested this in IE or Opera at the moment. I also think it might be nice to make this a little simpler perhaps for people who want to remove all the buttons (for example we could have rmEditButtons="All"). I'll look into this and testing the code asap so we can get it on the live version.--MarkS (talk) 16:35, 1 December 2006 (UTC)
-
- Here the alternative code with paramter (var myButtons, I hope you'll give it a try). Good idea to do them with rmEditButtons="All". p.s. browser compatibility: it works for me in Opera and IE too. Cheers, looking forward —Olliminatore 17:31, 1 December 2006 (UTC)
- Well I've added an "all" option and it sort of works. However, it highlights a problem in Olliminatore's remove edit buttons function. Olliminatore's function is added to the page load event to remove the buttons. However, when the page is loading there are only 11 buttons in mwEditButtons. The media wiki software must be adding the 10 other standard buttons later. The remove buttons functions works fine with these 11 buttons but can't remove the other 10 standard buttons (because they don't exist when the function runs). It might be possible to run the remove buttons function later but that would risk removing any buttons the user has added themself. The only answer I can think of is to delete the buttons when XEB is running by searching for the individual buttons themselves. This seems a heavy handed way to do it. Will need to think about this or hope Olliminatore has a good idea.
- Haven't looked at your alternative code yet. Will do when I get a chance. --MarkS (talk) 18:54, 1 December 2006 (UTC)
By the 'ten other standard buttons', do you mean the ones that have been MediaWiki:Common.js? If so, you can suppress them (thanks, Olliminatore) by adding mwCustomEditButtons = [];
to your local javascript file, or to the XEB script page. Karl Dickman talk 19:12, 1 December 2006 (UTC)
-
- Yes, Karl Dickman is right (I forgot the other custom buttons are now standard too), we should delete them all (if we would extend the
eraseButtons
function (you can correct my typo "erease", or better called removeButtons!?), it must be indexes from 0-20. That would be too complicated/ elaborated for an user friendly parameter). —Olliminatore 20:39, 1 December 2006 (UTC)
- Yes, Karl Dickman is right (I forgot the other custom buttons are now standard too), we should delete them all (if we would extend the
Plus, I don't think that extending the indices on your script would work, i.e. I don't think that ereaseButtons(15,20);
would successfully erase the sixteenth and twenty-first buttons in the toolbar. I seem to remember trying that, and didn't succeed. Karl Dickman talk 23:14, 1 December 2006 (UTC)
- At the moment you are right, because the function is not modified (in de: are no custom standard buttons). But if you really want it, it would be easy to do, connect both lists:
- first made a copy:
var mwCustomEditButtonsOld = mwCustomEditButtons;
- then erase those:
mwCustomEditButtons = [];
- Because the mwEditButtons is filled after the mwCustomEditButtons. Then put this line in the erase function:
for (i in mwCustomEditButtonsOld) mwEditButtons.push(mwCustomEditButtonsOld[i]);
. —Olliminatore 23:54, 1 December 2006 (UTC)
-
- For the record (and this is just summarizing what Olliminatore has already said) and so that I don't forget, the buttons are working like this:
- mwCustomEditButtons is populated with the 10 extra standard buttons
- monobook.js is called and we add the XEB buttons
- mwEditButtons is populated with the standard buttons
- The eraseButtons function is run which removes the standard buttons from mwEditButtons
- Olliminatore's proposed code should work fine and would allow any of the 21 standard buttons to be removed by index number. However, I would need to adapt the remove all function I added and probably hard code it to remove 21 buttons. I think this overall approach is the best way forward. I'll test it on the dev version as soon as possible. --MarkS (talk) 07:24, 2 December 2006 (UTC)
- I have now changed the rmEraseButtons function so it can remove all the standard buttons. You can now specify either
rmEditButtons=[2,3,4]
orrmEditButtons="all"
. The code is currently in the dev version. I also want to have a look at Karl Dickman's alternative code for adding the standard buttons in and then test again before moving this up to live. That might need to wait until this evening. If you want to test the code or suggest/make any other changes that would be helpful --MarkS (talk) 07:53, 2 December 2006 (UTC)
- I have now changed the rmEraseButtons function so it can remove all the standard buttons. You can now specify either
- For the record (and this is just summarizing what Olliminatore has already said) and so that I don't forget, the buttons are working like this: