/* ---------------------------------------------------------------------- *\
Function : editor_setmode
Description : change mode between WYSIWYG and HTML editor
Usage : editor_setmode(objname, mode);
Arguments : objname - button id string with editor and action name
mode - init, textedit, or wysiwyg
\* ---------------------------------------------------------------------- */
function editor_setmode(objname, mode) {
var config = document.all[objname].config;
var editor_obj = document.all["_" +objname + "_editor"];
// wait until document is fully loaded
if (document.readyState != 'complete') {
setTimeout(function() { editor_setmode(objname,mode) }, 25);
return;
}
else {
config.mode = "wysiwyg";
var contents = editor_obj.value;
if (mode == 'init') { contents = document.all[objname].value; } // on init use original textarea content
// create editor contents (and default styles for editor)
var html = "";
html += '<html><head>\n';
if (config.stylesheet) {
html += '<link href="' +config.stylesheet+ '" rel="stylesheet" type="text/css">\n';
}
html += '<style>\n';
html += 'body {' +config.bodyStyle+ '} \n';
for (var i in config.fontstyles) {
var fontstyle = config.fontstyles[i];
if (fontstyle.classStyle) {
html += '.' +fontstyle.className+ ' {' +fontstyle.classStyle+ '}\n';
}
}
html += '</style>\n'
+ '</head>\n'
+ '<body contenteditable="true" topmargin=1 leftmargin=1'
// still working on this
// + ' oncontextmenu="parent.editor_cMenu_generate(window,\'' +objname+ '\');"'
+'>'
+ contents
+ '</body>\n'
+ '</html>\n';
// write to editor window
var editdoc = editor_obj.contentWindow.document;