You are not logged in.
I looked at several of the plugins for help here, and I found that the SuperClean has a pretty good aproach for this, it loops through the buttons and replaces the one you want. Altering the code abit to a push instead we are almost happy.
I have this :
var t = editor.config.toolbar;
var done = false;
for(var i = 0; i < t.length && !done; i++)
{
for(var x = 0; x < t[i].length && !done; x++)
{
if(t[i][x] == 'insertimage')
{
t[i-1].push('insertpopup');
done = true;
}
}
}
if(!done)
{
t[t.length-1].push('insertpopup');
}
What Im trying to do is insert my imagepopup icon after the "insertimage" icon, what accually happends is that the "row" of icons where the "insertimage" is contains of 5 buttons in the default setup. When pushing the new button I get the button on the correct row, but in the beginning of the row and not beside the "insertimage" button. Obviously my lack of understanding javascript is my problem here.
In lamers terms I would hope this had worked :
if(t[i][x] == 'insertimage')
{
t[i][x].push('insertpopup');
done = true;
}
But this doesnt work, probably cause im stuffing a button array into a place it shouldnt be, or creating an array of something which isnt an array or something.
I understand Im not the only one having theese problems, are there any quick fixes to the above code to accomplish my goal, or do I have to edit the htmlarea.js file manually (Which I dont want to do to make updates easier for some odd reason, WinMerge is my friend however... But hey,
Offline
Well, seems I came up with a sollution anyhows. This sollution probably isnt very cost afficient for all I know regarding optimized flow of the code, but it works nontheless, heres is the final sollution to place a button exactly after another button in the toolbar.
var t = editor.config.toolbar;
var done = false;
for(var i = 0; i < t.length && !done; i++)
{
var y = t[i].length;
for(var x = 0; x < y && !done; x++)
{
if(t[i][x] == 'insertimage')
{
if(y == x){
t[i][x+1] = 'insertpopup';
done = true;
} else {
for(var z = 1; z < y-x; z++){
t[i][(y+1)-z] = t[i][(y)-z];
}
t[i][x+1] = 'insertpopup';
done = true;
}
}
}
}
if(!done)
{
t[t.length-1].push('insertpopup');
}
For reference the "insertpopup" would be the name of the button you want to look for, "insertpopup" would be the name of the button you are inserting.
Last edited by kimss (2005-04-27 08:33:04)
Offline
nice....
but isn't there something easier possible for such a simple task ("put a button after another")?
(yes, currently it looks like there isn't... there was allready a discussion if whe config.toolbar should be chaned to allow easier insertion of additional buttons)
Last edited by niko (2005-04-27 09:41:15)
Niko
Offline
I would like the buttons to be able to be overwritten by your config file, much like regular buttons. Shouldnt the plugins just add the buttons to the regular button config or something similar?
Offline