// // htmlArea v1.05 - Copyright (c) 2002 interactivetools.com, inc. // A free WYSIWYG editor replacement for ' + '' // + '' ; // create editor var contents = document.all[objname].value; // get original contents document.all[objname].outerHTML = editor; // create editor frame document.all['_'+objname+'_editor'].value = contents; // set contents editor_setmode('_' +objname+ '_HtmlMode', bckgrnd , 'init'); // switch to wysiwyg mode } /* ---------------------------------------------------------------------- *\ Function : editor_action Description : perform an editor command on selected editor content Usage : Arguments : button_id - button id string with editor and action name \* ---------------------------------------------------------------------- */ function editor_action(button_id) { var BtnParts = Array(); BtnParts = button_id.split("_"); var objname = button_id.replace(/^_(.*)_[^_]*$/, '$1'); var cmdID = BtnParts[ BtnParts.length-1 ]; var button_obj = document.all[button_id]; var editor_obj = document.all["_" +objname + "_editor"]; // check editor mode (don't perform actions in textedit mode) if (editor_obj.tagName.toLowerCase() == 'textarea') { return; } var editdoc = editor_obj.contentWindow.document; _editor_focus(editor_obj); // execute command for font pulldowns var idx = button_obj.selectedIndex; if (idx != null) { var val = button_obj[ idx ].value; editdoc.execCommand(cmdID,0,val); } // execute command for fgcolor & bgcolor buttons else if (cmdID == 'ForeColor' || cmdID == 'BackColor') { // figure our optimal window placement for popup dialog var posX = event.screenX; var posY = event.screenY + 20; var screenW = screen.width; // screen size var screenH = screen.height - 20; // take taskbar into account if (posX + 232 > screenW) { posX = posX - 232 - 40; } // if mouse too far right if (posY + 164 > screenH) { posY = posY - 164 - 80; } // if mouse too far down var wPosition = "dialogLeft:" +posX+ "; dialogTop:" +posY; var oldcolor = _dec_to_rgb(editdoc.queryCommandValue(cmdID)); var newcolor = showModalDialog(_editor_url + "select_color.html", oldcolor, "dialogWidth:238px; dialogHeight: 187px; " + "resizable: no; help: no; status: no; scroll: no; " + wPosition); if (newcolor != null) { editdoc.execCommand(cmdID, false, "#"+newcolor); } } // execute command for buttons else { // subscript & superscript, disable one before enabling the other if (cmdID.toLowerCase() == 'subscript' && editdoc.queryCommandState('superscript')) { editdoc.execCommand('superscript'); } if (cmdID.toLowerCase() == 'superscript' && editdoc.queryCommandState('subscript')) { editdoc.execCommand('subscript'); } // insert link if (cmdID.toLowerCase() == 'createlink'){ editdoc.execCommand(cmdID,1); } // insert image else if (cmdID.toLowerCase() == 'insertimage'){ showModalDialog(_editor_url + "insert_image.php", editdoc, "resizable: no; help: no; status: no; scroll: no; dialogHeight: 255px;"); // edited by wally: insert_image.html -> insert_image.php, added dialogHeight: 220px; } // show about {corrected by wally} else if (cmdID.toLowerCase() == 'about'){ var html = 'About\n' + '\n' + '\n\n' + 'htmlArea by interactivetools.com
\n' + 'A free WYSIWYG editor replacement for <textarea> fields.
\n\n' + '

\n\n' + '

For more information visit:
\n' + 'http://www.interactivetools.com/products/htmlarea/

\n' + '\n\n'; var popup = window.open('', 'ColorPicker', "location=no,menubar=no,toolbar=no,directories=no,status=no," + "height=275,width=450,resizable=no,scrollbars=no"); popup.document.write(html); } else if (cmdID.toLowerCase() == 'linebreak'){ // added by wally editor_insertHTML(objname,'
'); } // all other commands else { editdoc.execCommand(cmdID); } } editor_updateUI(objname); } /* ---------------------------------------------------------------------- *\ Function : editor_updateUI Description : update button status, selected fonts, and hidden output field. Usage : Arguments : objname - ID of textarea to replace runDelay: -1 = run now, no matter what 0 = run now, if allowed 1000 = run in 1 sec, if allowed at that point \* ---------------------------------------------------------------------- */ function editor_updateUI(objname,runDelay) { var editor_obj = document.all["_" +objname+ "_editor"]; // html editor object if (runDelay == null) { runDelay = 0; } var editdoc, editEvent; // setup timer for delayed updates (some events take time to complete) if (runDelay > 0) { return setTimeout(function(){ editor_updateUI(objname); }, runDelay); } // don't execute more than 3 times a second (eg: too soon after last execution) if (this.tooSoon == 1 && runDelay >= 0) { this.queue = 1; return; } // queue all but urgent events this.tooSoon = 1; setTimeout(function(){ this.tooSoon = 0; if (this.queue) { editor_updateUI(objname,-1); }; this.queue = 0; }, 333); // 1/3 second // check editor mode and update hidden output field if (editor_obj.tagName.toLowerCase() == 'textarea') { // textedit mode document.all[objname].value = editor_obj.value; // update hidden output field return; } else { // WYSIWYG mode editdoc = editor_obj.contentWindow.document; // get iframe editor document object editEvent = editor_obj.contentWindow.event; _fix_placeholder_urls(editdoc); document.all[objname].value = editdoc.body.innerHTML; // update hidden output field } // update button states var IDList = Array('Bold','Italic','Underline','JustifyLeft','JustifyCenter','JustifyRight','InsertOrderedList','InsertUnorderedList'); for (i=0; i'; var RichEdit = ''; // // Switch to TEXTEDIT mode // if (mode == "textedit" || editor_obj.tagName.toLowerCase() == 'iframe') { editdoc = editor_obj.contentWindow.document; var contents = editdoc.body.createTextRange().htmlText; editor_obj.outerHTML = TextEdit; editor_obj = document.all["_" +objname + "_editor"]; editor_obj.value = contents; editor_updateUI(objname); // disable buttons var IDList = Array('Bold','Italic','Underline','StrikeThrough','SubScript','SuperScript','JustifyLeft','JustifyCenter','JustifyRight','InsertOrderedList','InsertUnorderedList','Outdent','Indent','ForeColor','BackColor','InsertHorizontalRule','CreateLink','InsertImage','LineBreak'); // LineBreak added by wally for (i=0; i