// htmlArea v3.0 - Copyright (c) 2002, 2003 interactivetools.com, inc.
// This copyright notice MUST stay intact for use (see license.txt).
//
-// Portions (c) dynarch.com, 2003
+// Portions (c) dynarch.com, 2003-2004
//
// A free WYSIWYG editor replacement for <textarea> fields.
// For full source code and docs, visit http://www.interactivetools.com/
if (typeof _editor_url == "string") {
// Leave exactly one backslash at the end of _editor_url
- _editor_url = _editor_url.replace(/\/*$/, '/');
+ _editor_url = _editor_url.replace(/\x2f*$/, '/');
} else {
//alert("WARNING: _editor_url is not set! You should set this variable to the editor files path; it should preferably be an absolute path, like in '/htmlarea', but it can be relative if you prefer. Further we will try to load the editor files correctly but we'll probably fail.");
_editor_url = '<?php print ($CFG->wwwroot); ?>/lib/editor/';
/** Helper function: replaces the TEXTAREA with the given ID with HTMLArea. */
HTMLArea.replace = function(id, config) {
- var ta = document.getElementById(id);
+ var ta = HTMLArea.getElementById("textarea", id);
return ta ? (new HTMLArea(ta, config)).generate() : null;
};
_stopEvent(is_ie ? window.event : ev);
}
});
- el.innerHTML = '<img src="'+ btn[1] +'" width="18" height="18">';
+ var img = document.createElement("img");
+ img.src = btn[1];
+ img.style.width = "18px";
+ img.style.height = "18px";
+ el.appendChild(img);
} else if (!el) {
el = createSelect(txt);
}
var textarea = this._textArea;
if (typeof textarea == "string") {
// it's not element but ID
- this._textArea = textarea = document.getElementById(textarea);
+ this._textArea = textarea = HTMLArea.getElementById("textarea", textarea);
}
this._ta_size = {
w: textarea.offsetWidth,
// we need to refresh that info for Moz-1.3a
try {
this._doc.designMode = "on";
- this._doc.focus();
+ //this._doc.focus();
} catch(e) {};
}
if (this.config.statusBar) {
break;
case "unlink": this._removelink(); break;
case "popupeditor":
+ // this object will be passed to the newly opened window
+ HTMLArea._object = this;
if (HTMLArea.is_ie) {
//if (confirm(HTMLArea.I18N.msg["IE-sucks-full-screen"]))
{
"toolbar=no,menubar=no,personalbar=no,width=800,height=600," +
"scrollbars=no,resizable=yes");
}
- // pass this object to the newly opened window
- HTMLArea._object = this;
break;
case "undo":
case "redo":
HTMLArea.prototype._editorEvent = function(ev) {
var editor = this;
var keyEvent = (HTMLArea.is_ie && ev.type == "keydown") || (ev.type == "keypress");
+ if (keyEvent) {
+ for (var i in editor.plugins) {
+ var plugin = editor.plugins[i].instance;
+ if (typeof plugin.onKeyPress == "function") plugin.onKeyPress(ev);
+ }
+ }
if (keyEvent && ev.ctrlKey && ! ev.altKey) {
var sel = null;
var range = null;
continue;
}
var name = a.nodeName.toLowerCase();
- if (/_moz|contenteditable/.test(name)) {
+ if (/_moz|contenteditable|_msh/.test(name)) {
// avoid certain attributes
continue;
}
}
break;
case 3: // Node.TEXT_NODE
- html = HTMLArea.htmlEncode(root.data);
+ // If a text node is alone in an element and all spaces, replace it with an non breaking one
+ // This partially undoes the damage done by moz, which translates ' 's into spaces in the data element
+ if ( !root.previousSibling && !root.nextSibling && root.data.match(/^\s*$/i) ) html = ' ';
+ else html = HTMLArea.htmlEncode(root.data);
break;
case 8: // Node.COMMENT_NODE
html = "<!--" + root.data + "-->";
return url;
};
+/**
+ * FIX: Internet Explorer returns an item having the _name_ equal to the given
+ * id, even if it's not having any id. This way it can return a different form
+ * field even if it's not a textarea. This workarounds the problem by
+ * specifically looking to search only elements having a certain tag name.
+ */
+HTMLArea.getElementById = function(tag, id) {
+ var el, i, objs = document.getElementsByTagName(tag);
+ for (i = objs.length; --i >= 0 && (el = objs[i]);)
+ if (el.id == id)
+ return el;
+ return null;
+};
+
+
+
// EOF
// Local variables: //
// c-basic-offset:8 //