[Mozile] New to Mozile - attempting javascript integration

Henrik Pettersen henrik.pettersen at gmail.com
Tue Nov 21 15:38:39 PST 2006


All,

I am rather new to Mozile, so please forgive me if I am asking for
information that is allready well documented or has allready been
answered.

Mozile is an application that very much impressed me when I first came
across it, and I think it looks and interacts miles better than any
other (non-inline) HTML editors out there, e.g. FCKEditor.

I am currently engaged in a project where I am using the Orbeon Forms
web application framework:
http://www.orbeon.com

(If you are not familiar with Orbeon Forms, I recomend you take a look
at it - they are doing some very interesting things with XForms.)

Currently, Orbeon Forms is using the FCKEditor for editing text/html:
http://www.orbeon.com/ops/goto-example/xforms-html-area

While FCKEditor is not a bad application, I would prefer to use Mozile.

But to my question: I was wondering if you had some reference examples
or documentation on how to integrate the Mozile javascript with other
javascript code. What I have found out so far, is this
(doc/html/ch01s03.html#SavingChanges):

> Of course, you can write your own code for saving changes. The first step is
> to create a new instance of the mozile.save.Method class.
> You can also make use of the mozile.save.getContent() method, which takes a
> Node or a Document as its argument and returns a string representation.

And the mozile.save.Method javadoc:
http://mozile.mozdev.org/0.8/doc/jsdoc/index.html

How do I go about "creating a new instance of the mozile.save.Method
class", that can handle the integration between Mozile and my own
javascript?

I'll have to apologize for my javascript skills - I am in no way a
master of this art, but have done some work with other functional
programming languages.

This is how Orbeon currently integrate with FCKEditor (which I wish to
replace) - I'm not sure if this is helpfull, but it's allways good to
have some context.

{...
        //Initialize
        var fckEditor = new FCKeditor(htmlArea.name);
        fckEditor.BasePath = BASE_URL + "/ops/fckeditor/";
        fckEditor.ToolbarSet = "OPS";

        //store the fckEditor instance for future reference
        ORBEON.xforms.Globals.fckEditorsToLoad.push(fckEditor);
...}


 * Called by FCKeditor when an editor is fully loaded. This is our opportunity
 * to listen for events on this editor.
 */
function FCKeditor_OnComplete(editorInstance) {
    // Save reference to XForms element (textarea)
    // in document for event handlers that receive the document
    editorInstance.EditorDocument.xformsElement = editorInstance.LinkedField;
    // Register value change handler when in incremental mode
    if (ORBEON.util.Dom.hasClass(editorInstance.LinkedField,
"xforms-incremental"))
        editorInstance.Events.AttachEvent("OnSelectionChange",
xformsHtmlEditorChange);
    // Register focus/blur events for Gecko
    YAHOO.util.Event.addListener(editorInstance.EditorDocument,
"focus", ORBEON.xforms.Events.focus);
    YAHOO.util.Event.addListener(editorInstance.EditorDocument,
"blur", ORBEON.xforms.Events.blur);
    // Register focus/blur events for IE
    YAHOO.util.Event.addListener(editorInstance.EditorDocument,
"focusin", ORBEON.xforms.Events.focus);
    YAHOO.util.Event.addListener(editorInstance.EditorDocument,
"focusout", ORBEON.xforms.Events.blur);
    // Load other editors in the queue
    if (ORBEON.xforms.Globals.fckEditorsToLoad.length > 0) {
        var fckEditor = ORBEON.xforms.Globals.fckEditorsToLoad.shift();
        fckEditor.ReplaceTextarea();
        ORBEON.xforms.Controls.updateHTMLAreaClasses(document.getElementById(fckEditor.InstanceName));
    } else {
        ORBEON.xforms.Globals.fckEditorLoading = false;
    }
}


For Mozile, there seems to be only a single instance of the mozile
editor for the entire page, compared to having to create an instance
of FCKeditor for each field (I might be incorrect here).

If I can figure out how to create a custom function and assign it to
mozile.save.Method, how do I make sure that I can read the text
entered by the user when the save button is pressed?

---

OK, that was a long email. If anyone has any pointers or can guide me
to some documentation or examples, it would be greatly appreciated.

Mozile is a great application, and definitely another feather in the
cap for the Mozilla Foundation. I hope I can bring your efforts to the
Orbeon Forms community, as well!

Sincerely,
Henrik Pettersen
Advanced Computation Laboratory
Cancer Research UK


More information about the Mozile mailing list