Firefox PHP

New editor tools module for Phorum 5.1+

Posted by Maurice Makaay 
Re: New editor tools module for Phorum 5.1+
August 12, 2006 04:36PM
Thank you for the translation nicola. I will include it in the next release!


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: New editor tools module for Phorum 5.1+
August 13, 2006 12:01PM
Salve

Now I tried the Phorum 5.15 with this editor-tools.
Works fine.

Then I tried to extend the editor tools with special math characters.
I copied the size-function in editor-tools.js - but
it doesn't work.

Now I generate a little and empty popup-box on the position of the size-popup (without any javascript-mistakes). Thats all.

I give up.

Hints and tips wanted.
Dead or alive ;-)

frihu



Edited 2 time(s). Last edit at 08/13/2006 12:02PM by frihu.
Re: New editor tools module for Phorum 5.1+
August 13, 2006 12:36PM
How did you try to extend the editor tools? Through a separate mod I hope?

I really cannot tell what is going wrong for you. "it doesn't work" is quite sparse, even for educated guessing. So maybe post a URL or so, where we can look at your page?


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: New editor tools module for Phorum 5.1+
August 13, 2006 01:12PM
Quote
mmakaay
How did you try to extend the editor tools? Through a separate mod I hope?

Hrm - not really.
But it was the next thing.
For the first, it was your (modified) editor-tool.

Quote

I really cannot tell what is going wrong for you. "it doesn't work" is quite sparse, even for educated guessing. So maybe post a URL or so, where we can look at your page?


Url ist secret ;-)
here is the code from editor-tools.js
//****************************************
var editor_tools_math_picker_obj = null;

// special chars e.g. Ω √ ...
var editor_tools_math_picker_chars = new Array(
    'Ohm',
    'Wurzel'
);

/**************************************************************************************
// Create another NEW popup window for math-chars.
function editor_tools_construct_popup1(create_id, anchor)
{
    // Create the outer div for the popup window.
    var popup_obj = document.createElement('div');
    popup_obj.id = create_id;
    popup_obj.className = 'editor-tools-popup';
    popup_obj.style.display = 'none';
    document.body.appendChild(popup_obj);

    popup_obj._anchor = anchor;

    // Create the inner content div.
    var content_obj = document.createElement('div');
    content_obj.id = 'editor-tools-math-picker-content';
    popup_obj.appendChild(content_obj);

    return new Array(popup_obj, content_obj);
}

// *****************************************************************************************
function editor_tools_handle_math()
{
    editor_tools_store_range();

    // Create the size picker on first access.
    if (!editor_tools_math_picker_obj)
    {
        // Create a new popup.
        var popup = editor_tools_construct_popup1('editor_tools_math_picker','l');
        editor_tools_math_picker_obj = popup[0];
        var content_obj = popup[1];



        // Populate the new popup.

        for (var i = 0; i < editor_tools_math_picker.length; i++)
        {
            var mathchar = editor_tools_math_picker;
            var a_obj = document.createElement('a');
            a_obj.href = 'javascript:editor_tools_handle_math_select("' + mathchar + '")';
            a_obj.style.fontSize = mathchar;
            a_obj.innerHTML = editor_tools_translate(mathchar);
            content_obj.appendChild(a_obj);

            var br_obj = document.createElement('br');
            content_obj.appendChild(br_obj);
        }




        // Register the popup with the editor tools.
        editor_tools_register_popup_object(editor_tools_math_picker_obj);

    }

    // Display the popup.
    var button_obj = document.getElementById('editor-tools-img-size');
    editor_tools_toggle_popup(editor_tools_math_picker_obj, button_obj);

}

function editor_tools_handle_math_select(mathchar)
{
    editor_tools_hide_all_popups();
    editor_tools_restore_range();
    size = editor_tools_strip_whitespace(mathchar);
    editor_tools_add_tags('[Ohm]');  // this is for testing
    editor_tools_focus_textarea();
}


Additional Code in defaults.php

    array("bbcode",  array('math',          NULL, NULL, NULL, NULL, NULL)),


Thats all.
I cant' get the elemets of editor_tools_math_picker_chars. or a great popup.
Nothing. Nada.

I know there is a mistake. But where ist it?
See the pic.


frihu



Edited 2 time(s). Last edit at 08/13/2006 01:18PM by frihu.


Re: New editor tools module for Phorum 5.1+
August 13, 2006 05:33PM
You are using this in the function editor_tools_handle_math:
var button_obj = document.getElementById('editor-tools-img-size');
That's at least one problem there is. You take the size button as the button to display the math tool under. You created a math tool, for which thhe button has the id editor-tools-img-math.

Also, why create your custom function for creating popups? The function editor_tools_construct_popup() is the designated function for that. Look how all popups (size, smiley and help) use this function in my code. I see that there is a problem in the code, which might have thrown you on the wrong foot though. The content div has a static id, but that should be create_id + "-content" instead. I'll fix that for the next release. Unless you are using the id for the content div somewhere, this is no problem for the functionality of the tools.

As a whole, better not hack the distribution code. Look at the bottom of the PHP file and read the README file. There you will find information on how to write a module to add functionality to the editor tools.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: New editor tools module for Phorum 5.1+
August 13, 2006 10:55PM
Quote
mmakaay
You are using this in the function editor_tools_handle_math:
var button_obj = document.getElementById('editor-tools-img-size');
That's at least one problem there is. You take the size button as the button to display the math tool under. You created a math tool, for which thhe button has the id editor-tools-img-math.

Also, why create your custom function for creating popups? The function editor_tools_construct_popup() is the designated function for that. Look how all popups (size, smiley and help) use this function in my code. I see that there is a problem in the code, which might have thrown you on the wrong foot though. The content div has a static id, but that should be create_id + "-content" instead. I'll fix that for the next release. Unless you are using the id for the content div somewhere, this is no problem for the functionality of the tools.

As a whole, better not hack the distribution code. Look at the bottom of the PHP file and read the README file. There you will find information on how to write a module to add functionality to the editor tools.

Morning

After 6 hours searching and testing I walk another way.
I put the 6 most important Symbols as simple Math-Buttons in the editor-tools like "B" (bold) oder "I" (italic) for e.g. Radic, Sigma, O(o)mega. Together with the Ashec-Modul it works.

IMHO the static-id is not only the problem (I supposed so). A "universal Container" where you can put in what you want, would be appreciated and a "killer-feature" (IMHO). ;-)

Sometimes I need my "Code-hacking". It's my spleen but I thing, in the future I don't need many hacks because there a lots of moduls for the 5-Version of Phorum (at this time I have only Phorum 3.4.x - with hacks, of course ;-) )

frihu
Re: New editor tools module for Phorum 5.1+
August 14, 2006 02:54AM
Define "universal container". The editor_tools_construct_popup() function creates what I think of as a universal container. The <div> setup that is returned can be used for filling with tools that you need. Of course you need Javascript code for doing that, so it's a universal container for filling with Javascript. If you want to fill one of these beasts with HTML code, you could of course use innerHTML in Javascript to set the contents.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: New editor tools module for Phorum 5.1+
August 16, 2006 09:50AM
i posted earlier about having broken 'strike.gif', etc images on upload.

i have just deleted all the icon images and replaced with the files in the TAR (i was previously using the ones in the ZIP).

now all buttons show up properly.

just posting this in case anyone else has this mysterious problem.
Re: New editor tools module for Phorum 5.1+
August 16, 2006 10:56AM
I downloaded both files in Windows and Unix and unpacked them on both systems. The result was that in all situations, the icon images were binary the same and therefor all images worked. What zip tool are you using to unpack the zip-file?


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: New editor tools module for Phorum 5.1+
August 16, 2006 11:35AM
just unpacked them in windows using the usual compressed folder options.
i know, this is a very odd problem, but i couldn't resolve it any other way (delete all files, re-upload, overwrite without deleting... ftp in binary, then in auto... reload all icons individually in browser, clear cache... upload through cpanel, etc).
Sorry, only registered users may post in this forum.

Click here to login