[dokuwiki] Re: How to add a drop-down list to the edit toolbar?

Hi Tom!

Thanks very much for your reply. It's pretty close to what I'm looking for.
But there is one difference which gives me some headache.

The options I'll need for my select aren't static values. I'll have to generate
them by a php function.
Though the whole toolbar is generated by Javascript I have enormous problems to
find "the right place" to transfer my options to the javascript.
And secondly am I not the Javascript-Guru.

Thought about difference possibilities:
- add a script to the main.php in case $ACT='edit'
- use the TOOLBAR_DEFINE event in my action plugin
- edit the toolbar.php/ edit.js files

I'm afraid that this is too complicated for me.
So further help ist very much appreciated!

Gunther

TNHarris schrieb:
> On Sat, 22 Sep 2007 14:41:34 +0200, "Gunther Pilz"
> <dokuwiki@xxxxxxxxxxxxxx> said:
> > I want to add a drop-down list to my edit toolbar.
> >
>
> I did this with my 'Format+' plugin. In the plugin's style.js I have an
> initialization function that looks like this (simplified for clarity):
>
>     function initFormatPlusToolbar(){
>       var editObj = $('wiki__text');
>       if (editObj && !editObj.readOnly){
>         var toolbarObj = $('tool__bar');
>         var menuObj = document.createElement('select');
>         menuObj.className = 'toolbutton';
>         var opt = document.createElement('option');
>         opt.innerHTML = '+Format+';
>         menuObj.appendChild(opt);
>         for (var i=0; i<FormatPlusOptions.length; i++){
>           opt = document.createElement('option');
>           opt.innerHTML = FormatPlusOptions[i].label;
>           menuObj.appendChild(opt);
>         }
>         menuObj.onchange =
>         function(){selectFormatPlusOption(menuObj);return false;};
>         toolbarObj.appendChild(menuObj);
>       }
>     }
>
> The FormatPlusOptions global is an array of the items that can be
> selected. The selectFormatPlusOption function gets the information from
> this array to insert text.
>
>     function selectFormatPlusOption(menuObj){
>       if (menuObj.selectedIndex > 0){
>         var opt = FormatPlusOptions[menuObj.selectedIndex-1];
>         insertTags('wiki__text', opt.opentag, opt.closetag, opt.title);
>         menuObj.selectedIndex = 0;
>       }
>     }
>
> -- tom
> telliamed@xxxxxxxxxxx
>
-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: