From: moodler Date: Wed, 29 Oct 2003 07:51:46 +0000 (+0000) Subject: HTMLArea 3.0, slightly edited by Janne Mikkonen. Alpha version. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a800c948914e1453665800dc45dd9077355a642b;p=moodle.git HTMLArea 3.0, slightly edited by Janne Mikkonen. Alpha version. --- diff --git a/lib/editor/courseimages.php b/lib/editor/courseimages.php new file mode 100644 index 0000000000..36d919d89e --- /dev/null +++ b/lib/editor/courseimages.php @@ -0,0 +1,857 @@ +id); + + if (! isteacher($course->id) ) { + error("Only teachers can edit files"); + } + + function html_footer() { + echo ""; + } + + function html_header($course, $wdir, $formfield=""){ + + global $CFG; + + if (! $site = get_site()) { + error("Invalid site!"); + } + + if ($course->id == $site->id) { + $strfiles = get_string("sitefiles"); + } else { + $strfiles = get_string("files"); + } + + if ($wdir == "/") { + $fullnav = "$strfiles"; + } else { + $dirs = explode("/", $wdir); + $numdirs = count($dirs); + $link = ""; + $navigation = ""; + for ($i=1; $i<$numdirs; $i++) { + $navigation .= " -> "; + $link .= "/".urlencode($dirs[$i]); + $navigation .= "id&wdir=$link\">".$dirs[$i].""; + } + $fullnav = "id&wdir=/\">$strfiles $navigation"; + } + + print_header(); + ?> + + '; + echo ''; + echo ''; + echo ''."$course->shortname -> $fullnav".''; + echo ''; + echo ''; + echo ''; + + if ($course->id == $site->id) { + print_heading(get_string("publicsitefileswarning"), "center", 2); + } + + echo ""; + echo ""; + echo "\n"; +} + +function displaydir ($wdir) { +// $wdir == / or /a or /a/b/c/d etc + + global $basedir; + global $id; + global $USER, $CFG; + + $fullpath = $basedir.$wdir; + + $directory = opendir($fullpath); // Find all files + while ($file = readdir($directory)) { + if ($file == "." || $file == "..") { + continue; + } + + if (is_dir($fullpath."/".$file)) { + $dirlist[] = $file; + } else { + $filelist[] = $file; + } + } + closedir($directory); + + $strname = get_string("name"); + $strsize = get_string("size"); + $strmodified = get_string("modified"); + $straction = get_string("action"); + $strmakeafolder = get_string("makeafolder"); + $struploadafile = get_string("uploadafile"); + $strwithchosenfiles = get_string("withchosenfiles"); + $strmovetoanotherfolder = get_string("movetoanotherfolder"); + $strmovefilestohere = get_string("movefilestohere"); + $strdeletecompletely = get_string("deletecompletely"); + $strcreateziparchive = get_string("createziparchive"); + $strrename = get_string("rename"); + $stredit = get_string("edit"); + $strunzip = get_string("unzip"); + $strlist = get_string("list"); + $strchoose = get_string("choose"); + + + echo ""; + echo "
"; + } + + if (! $basedir = make_upload_directory("$course->id")) { + error("The site administrator needs to fix the file permissions"); + } + + $baseweb = $CFG->wwwroot; + +// End of configuration and access control + + + $regexp="\\.\\."; + if (ereg( $regexp, $file, $regs )| ereg( $regexp, $wdir,$regs )) { + $message = "Error: Directories can not contain \"..\""; + $wdir = "/"; + $action = ""; + } + + if (!$wdir) { + $wdir="/"; + } + + + switch ($action) { + + case "upload": + html_header($course, $wdir); + + if (!empty($_FILES['userfile'])) { + $userfile = $_FILES['userfile']; + } else { + $save = false; + } + if (!empty($save)) { + if (!is_uploaded_file($userfile['tmp_name']) or $userfile['size'] == 0) { + notify(get_string("uploadnofilefound")); + } else { + $userfile_name = clean_filename($userfile['name']); + if ($userfile_name) { + $newfile = "$basedir$wdir/$userfile_name"; + if (move_uploaded_file($userfile['tmp_name'], $newfile)) { + chmod($newfile, 0666); + $a = NULL; + $a->file = "$userfile_name (".$userfile['type'].")"; + $a->directory = $wdir; + print_string("uploadedfileto", "", $a); + } else { + notify(get_string("uploadproblem", "", $userfile_name)); + } + } + } + displaydir($wdir); + + } else { + $upload_max_filesize = get_max_upload_file_size(); + $filesize = display_size($upload_max_filesize); + + $struploadafile = get_string("uploadafile"); + $struploadthisfile = get_string("uploadthisfile"); + $strmaxsize = get_string("maxsize", "", $filesize); + $strcancel = get_string("cancel"); + + echo "

$struploadafile ($strmaxsize) --> $wdir"; + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo " "; + echo ""; + echo ""; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + } + html_footer(); + break; + + case "delete": + if (!empty($confirm)) { + html_header($course, $wdir); + foreach ($USER->filelist as $file) { + $fullfile = $basedir.$file; + if (! fulldelete($fullfile)) { + echo "
Error: Could not delete: $fullfile"; + } + } + clearfilelist(); + displaydir($wdir); + html_footer(); + + } else { + html_header($course, $wdir); + if (setfilelist($_POST)) { + echo "

".get_string("deletecheckwarning").":

"; + print_simple_box_start("center"); + printfilelist($USER->filelist); + print_simple_box_end(); + echo "
"; + notice_yesno (get_string("deletecheckfiles"), + "".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=delete&confirm=1", + "".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=cancel"); + } else { + displaydir($wdir); + } + html_footer(); + } + break; + + case "move": + html_header($course, $wdir); + if ($count = setfilelist($_POST)) { + $USER->fileop = $action; + $USER->filesource = $wdir; + echo "

"; + print_string("selectednowmove", "moodle", $count); + echo "

"; + } + displaydir($wdir); + html_footer(); + break; + + case "paste": + html_header($course, $wdir); + if (isset($USER->fileop) and $USER->fileop == "move") { + foreach ($USER->filelist as $file) { + $shortfile = basename($file); + $oldfile = $basedir.$file; + $newfile = $basedir.$wdir."/".$shortfile; + if (!rename($oldfile, $newfile)) { + echo "

Error: $shortfile not moved"; + } + } + } + clearfilelist(); + displaydir($wdir); + html_footer(); + break; + + case "rename": + if (!empty($name)) { + html_header($course, $wdir); + $name = clean_filename($name); + if (file_exists($basedir.$wdir."/".$name)) { + echo "Error: $name already exists!"; + } else if (!rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) { + echo "Error: could not rename $oldname to $name"; + } + displaydir($wdir); + + } else { + $strrename = get_string("rename"); + $strcancel = get_string("cancel"); + $strrenamefileto = get_string("renamefileto", "moodle", $file); + html_header($course, $wdir, "form.name"); + echo "

$strrenamefileto:"; + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + } + html_footer(); + break; + + case "mkdir": + if (!empty($name)) { + html_header($course, $wdir); + $name = clean_filename($name); + if (file_exists("$basedir$wdir/$name")) { + echo "Error: $name already exists!"; + } else if (! make_upload_directory("$course->id/$wdir/$name")) { + echo "Error: could not create $name"; + } + displaydir($wdir); + + } else { + $strcreate = get_string("create"); + $strcancel = get_string("cancel"); + $strcreatefolder = get_string("createfolder", "moodle", $wdir); + html_header($course, $wdir, "form.name"); + echo "

$strcreatefolder:"; + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + } + html_footer(); + break; + + case "edit": + html_header($course, $wdir); + if (isset($text)) { + $fileptr = fopen($basedir.$file,"w"); + fputs($fileptr, stripslashes($text)); + fclose($fileptr); + displaydir($wdir); + + } else { + $streditfile = get_string("edit", "", "$file"); + $fileptr = fopen($basedir.$file, "r"); + $contents = fread($fileptr, filesize($basedir.$file)); + fclose($fileptr); + + if (mimeinfo("type", $file) == "text/html") { + if ($usehtmleditor = can_use_richtext_editor()) { + $onsubmit = "onsubmit=\"copyrichtext(document.form.text);\""; + } else { + $onsubmit = ""; + } + } else { + $usehtmleditor = false; + $onsubmit = ""; + } + + print_heading("$streditfile"); + + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + print_textarea($usehtmleditor, 25, 80, 680, 400, "text", $contents); + echo "
"; + echo " "; + echo ""; + echo ""; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + + if ($usehtmleditor) { + print_richedit_javascript("form", "text", "yes"); + } + + + } + html_footer(); + break; + + case "zip": + if (!empty($name)) { + html_header($course, $wdir); + $name = clean_filename($name); + if (empty($CFG->zip)) { // Use built-in php-based zip function + $files = array(); + foreach ($USER->filelist as $file) { + $files[] = "$basedir/$file"; + } + include_once('../pclzip/pclzip.lib.php'); + $archive = new PclZip("$basedir/$wdir/$name"); + if (($list = $archive->create($files,'',"$basedir/$wdir/")) == 0) { + error($archive->errorInfo(true)); + } + } else { // Use external zip program + $files = ""; + foreach ($USER->filelist as $file) { + $files .= basename($file); + $files .= " "; + } + $command = "cd $basedir/$wdir ; $CFG->zip -r $name $files"; + Exec($command); + } + clearfilelist(); + displaydir($wdir); + + } else { + html_header($course, $wdir, "form.name"); + + if (setfilelist($_POST)) { + echo "

".get_string("youareabouttocreatezip").":

"; + print_simple_box_start("center"); + printfilelist($USER->filelist); + print_simple_box_end(); + echo "
"; + echo "

".get_string("whattocallzip"); + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + } else { + displaydir($wdir); + clearfilelist(); + } + } + html_footer(); + break; + + case "unzip": + html_header($course, $wdir); + if (!empty($file)) { + $strname = get_string("name"); + $strsize = get_string("size"); + $strmodified = get_string("modified"); + $strstatus = get_string("status"); + $strok = get_string("ok"); + $strunpacking = get_string("unpacking", "", $file); + + echo "

$strunpacking:

"; + + $file = basename($file); + + if (empty($CFG->unzip)) { // Use built-in php-based unzip function + include_once('../pclzip/pclzip.lib.php'); + $archive = new PclZip("$basedir/$wdir/$file"); + if (!$list = $archive->extract("$basedir/$wdir")) { + error($archive->errorInfo(true)); + } else { // print some output + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + foreach ($list as $item) { + echo ""; + $item['filename'] = str_replace("$basedir/$wdir/", "", $item['filename']); + print_cell("left", $item['filename']); + if (! $item['folder']) { + print_cell("right", display_size($item['size'])); + } else { + echo ""; + } + $filedate = userdate($item['mtime'], get_string("strftimedatetime")); + print_cell("right", $filedate); + print_cell("right", $item['status']); + echo ""; + } + echo "
$strname$strsize$strmodified$strstatus
 
"; + } + + } else { // Use external unzip program + print_simple_box_start("center"); + echo "
";
+                    $command = "cd $basedir/$wdir ; $CFG->unzip -o $file 2>&1";
+                    passthru($command);
+                    echo "
"; + print_simple_box_end(); + } + + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + } else { + displaydir($wdir); + } + html_footer(); + break; + + case "listzip": + html_header($course, $wdir); + if (!empty($file)) { + $strname = get_string("name"); + $strsize = get_string("size"); + $strmodified = get_string("modified"); + $strok = get_string("ok"); + $strlistfiles = get_string("listfiles", "", $file); + + echo "

$strlistfiles:

"; + $file = basename($file); + + include_once('../lib/pclzip/pclzip.lib.php'); + $archive = new PclZip("$basedir/$wdir/$file"); + if (!$list = $archive->listContent("$basedir/$wdir")) { + notify($archive->errorInfo(true)); + + } else { + echo ""; + echo ""; + foreach ($list as $item) { + echo ""; + print_cell("left", $item['filename']); + if (! $item['folder']) { + print_cell("right", display_size($item['size'])); + } else { + echo ""; + } + $filedate = userdate($item['mtime'], get_string("strftimedatetime")); + print_cell("right", $filedate); + echo ""; + } + echo "
$strname$strsize$strmodified
 
"; + } + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + } else { + displaydir($wdir); + } + html_footer(); + break; + + case "torte": + if($_POST) + { + while(list($key, $val) = each($_POST)) + { + if(ereg("file([0-9]+)", $key, $regs)) + { + $file = $val; + } + } + if(@filetype($CFG->dataroot ."/". $course->id . $file) == "file") + { + if(mimeinfo("icon", $file) == "image.gif") + { + $url = $CFG->wwwroot ."/file.php?file=/" .$course->id . $file; + runjavascript($url); + } + else + { + print "File is not a image!"; + } + } + else + { + print "You cannot insert FOLDER into richtext editor!!!"; + } + } + break; + case "cancel"; + clearfilelist(); + + default: + html_header($course, $wdir); + displaydir($wdir); + html_footer(); + break; +} + + +/// FILE FUNCTIONS /////////////////////////////////////////////////////////// + + +function fulldelete($location) { + if (is_dir($location)) { + $currdir = opendir($location); + while ($file = readdir($currdir)) { + if ($file <> ".." && $file <> ".") { + $fullfile = $location."/".$file; + if (is_dir($fullfile)) { + if (!fulldelete($fullfile)) { + return false; + } + } else { + if (!unlink($fullfile)) { + return false; + } + } + } + } + closedir($currdir); + if (! rmdir($location)) { + return false; + } + + } else { + if (!unlink($location)) { + return false; + } + } + return true; +} + + + +function setfilelist($VARS) { + global $USER; + + $USER->filelist = array (); + $USER->fileop = ""; + + $count = 0; + foreach ($VARS as $key => $val) { + if (substr($key,0,4) == "file") { + $count++; + $USER->filelist[] = rawurldecode($val); + } + } + return $count; +} + +function clearfilelist() { + global $USER; + + $USER->filelist = array (); + $USER->fileop = ""; +} + + +function printfilelist($filelist) { + global $basedir, $CFG; + + foreach ($filelist as $file) { + if (is_dir($basedir.$file)) { + echo "wwwroot/files/pix/folder.gif\" HEIGHT=16 WIDTH=16> $file
"; + $subfilelist = array(); + $currdir = opendir($basedir.$file); + while ($subfile = readdir($currdir)) { + if ($subfile <> ".." && $subfile <> ".") { + $subfilelist[] = $file."/".$subfile; + } + } + printfilelist($subfilelist); + + } else { + $icon = mimeinfo("icon", $file); + echo "wwwroot/files/pix/$icon\" HEIGHT=16 WIDTH=16> $file
"; + } + } +} + + +function print_cell($alignment="center", $text=" ") { + echo "
"; + echo ""; + echo "$text"; + echo ""; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + if ($wdir == "/") { + $wdir = ""; + } + + $count = 0; + + if (!empty($dirlist)) { + asort($dirlist); + foreach ($dirlist as $dir) { + + $count++; + + $filename = $fullpath."/".$dir; + $fileurl = rawurlencode($wdir."/".$dir); + $filesafe = rawurlencode($dir); + $filedate = userdate(filectime($filename), "%d %b %Y, %I:%M %p"); + + echo ""; + + print_cell("center", ""); + print_cell("left", "wwwroot/files/pix/folder.gif\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"Folder\">".htmlspecialchars($dir).""); + print_cell("right", "-"); + print_cell("right", $filedate); + print_cell("right", "$strrename"); + + echo ""; + } + } + + + if (!empty($filelist)) { + asort($filelist); + foreach ($filelist as $file) { + + $icon = mimeinfo("icon", $file); + + $count++; + $filename = $fullpath."/".$file; + $fileurl = "$wdir/$file"; + $filesafe = rawurlencode($file); + $fileurlsafe = rawurlencode($fileurl); + $filedate = userdate(filectime($filename), "%d %b %Y, %I:%M %p"); + + echo ""; + + print_cell("center", ""); + echo ""; + + $file_size = filesize($filename); + print_cell("right", display_size($file_size)); + print_cell("right", $filedate); + + if ($icon == "text.gif" || $icon == "html.gif") { + $edittext = "$stredit"; + } else if ($icon == "zip.gif") { + $edittext = "$strunzip "; + $edittext .= "$strlist "; + } else if ($icon == "image.gif") { + $edittext = "wwwroot$ffurl')\" href=\"\">$strchoose"; + } else { + $edittext = ""; + } + print_cell("right", "$edittext $strrename"); + + echo ""; + } + } + echo "
$strname$strsize$strmodified$straction
"; + if ($CFG->slasharguments) { + $ffurl = "/file.php/$id$fileurl"; + } else { + $ffurl = "/file.php?file=/$id$fileurl"; + } + link_to_popup_window ($ffurl, "display", + "wwwroot/files/pix/$icon\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"File\">", + 480, 640); + echo ""; + link_to_popup_window ($ffurl, "display", + htmlspecialchars($file), + 480, 640); + echo "
"; + echo "
"; + + if (empty($wdir)) { + $wdir = "/"; + } + + echo ""; + echo ""; + echo ""; + echo "
"; + echo ""; + echo " "; + $options = array ( + "move" => "$strmovetoanotherfolder", + "delete" => "$strdeletecompletely", + "zip" => "$strcreateziparchive" + ); + if (!empty($count)) { + choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:document.dirform.submit()"); + } + + echo ""; + echo ""; + if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) { + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + } + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + +} + +?> diff --git a/lib/editor/dialog.js b/lib/editor/dialog.js new file mode 100644 index 0000000000..435121ae6d --- /dev/null +++ b/lib/editor/dialog.js @@ -0,0 +1,72 @@ +// Though "Dialog" looks like an object, it isn't really an object. Instead +// it's just namespace for protecting global symbols. + +function Dialog(url, action, init) { + if (typeof init == "undefined") { + init = window; // pass this window object by default + } + if (document.all) { // here we hope that Mozilla will never support document.all + var value = + showModalDialog(url, init, + //window.open(url, '_blank', + "resizable: no; help: no; status: no; scroll: no"); + if (action) { + action(value); + } + } else { + return Dialog._geckoOpenModal(url, action, init); + } +}; + +Dialog._parentEvent = function(ev) { + if (Dialog._modal && !Dialog._modal.closed) { + Dialog._modal.focus(); + // we get here in Mozilla only, anyway, so we can safely use + // the DOM version. + ev.preventDefault(); + ev.stopPropagation(); + } +}; + +// should be a function, the return handler of the currently opened dialog. +Dialog._return = null; + +// constant, the currently opened dialog +Dialog._modal = null; + +// the dialog will read it's args from this variable +Dialog._arguments = null; + +Dialog._geckoOpenModal = function(url, action, init) { + var dlg = window.open(url, "ha_dialog", + "toolbar=no,menubar=no,personalbar=no,width=10,height=10," + + "scrollbars=no,resizable=no"); + Dialog._modal = dlg; + Dialog._arguments = init; + + // capture some window's events + function capwin(w) { + w.addEventListener("click", Dialog._parentEvent, true); + w.addEventListener("mousedown", Dialog._parentEvent, true); + w.addEventListener("focus", Dialog._parentEvent, true); + }; + // release the captured events + function relwin(w) { + w.removeEventListener("focus", Dialog._parentEvent, true); + w.removeEventListener("mousedown", Dialog._parentEvent, true); + w.removeEventListener("click", Dialog._parentEvent, true); + }; + capwin(window); + // capture other frames + //for (var i = 0; i < window.frames.length; capwin(window.frames[i++])); + // make up a function to be called when the Dialog ends. + Dialog._return = function (val) { + if (val && action) { + action(val); + } + relwin(window); + // capture other frames + //for (var i = 0; i < window.frames.length; relwin(window.frames[i++])); + Dialog._modal = null; + }; +}; diff --git a/lib/editor/htmlarea.css b/lib/editor/htmlarea.css new file mode 100644 index 0000000000..23bdf7d9db --- /dev/null +++ b/lib/editor/htmlarea.css @@ -0,0 +1,180 @@ +.htmlarea { background: #fff; } + +.htmlarea .toolbar { + cursor: default; + background: ButtonFace; + padding: 1px 1px 2px 1px; + border: 1px solid; + border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; +} +.htmlarea .toolbar table { font-family: tahoma,verdana,sans-serif; font-size: 11px; } +.htmlarea .toolbar img { border: none; } +.htmlarea .toolbar .label { padding: 0px 3px; } + +.htmlarea .toolbar .button { + background: ButtonFace; + color: ButtonText; + border: 1px solid ButtonFace; + padding: 1px; + margin: 0px; +} +.htmlarea .toolbar .buttonHover { + border: 1px solid; + border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; +} +.htmlarea .toolbar .buttonActive, .htmlarea .toolbar .buttonPressed { + padding: 2px 0px 0px 2px; + border: 1px solid; + border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; +} +.htmlarea .toolbar .buttonPressed { + background: ButtonHighlight; +} +.htmlarea .toolbar .indicator { + padding: 0px 3px; + overflow: hidden; + width: 20px; + text-align: center; + cursor: default; + border: 1px solid ButtonShadow; +} + +.htmlarea .toolbar .buttonDisabled { background-color: #aaa; } + +.htmlarea .toolbar .buttonDisabled img { + filter: alpha(opacity = 25); + -moz-opacity: 25%; +} + +.htmlarea .toolbar .separator { + position: relative; + margin: 3px; + border-left: 1px solid ButtonShadow; + border-right: 1px solid ButtonHighlight; + width: 0px; + height: 16px; + padding: 0px; +} + +.htmlarea .toolbar .space { width: 5px; } + +.htmlarea .toolbar select { font: 11px Tahoma,Verdana,sans-serif; } + +.htmlarea .toolbar select, +.htmlarea .toolbar select:hover, +.htmlarea .toolbar select:active { background: FieldFace; color: ButtonText; } + +.htmlarea .statusBar { + border: 1px solid; + border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; + padding: 2px 4px; + background-color: ButtonFace; + color: ButtonText; + font: 11px Tahoma,Verdana,sans-serif; +} + +.htmlarea .statusBar .statusBarTree a { + padding: 2px 5px; + color: #00f; +} + +.htmlarea .statusBar .statusBarTree a:visited { color: #00f; } +.htmlarea .statusBar .statusBarTree a:hover { + background-color: Highlight; + color: HighlightText; + padding: 1px 4px; + border: 1px solid HighlightText; +} + + +/* Hidden DIV popup dialogs (PopupDiv) */ + +.dialog { + color: ButtonText; + background: ButtonFace; +} + +.dialog .content { padding: 2px; } + +.dialog, .dialog button, .dialog input, .dialog select, .dialog textarea, .dialog table { + font: 11px Tahoma,Verdana,sans-serif; +} + +.dialog table { border-collapse: collapse; } + +.dialog .title { + background: #008; + color: #ff8; + border-bottom: 1px solid #000; + padding: 1px 0px 2px 5px; + font-size: 12px; + font-weight: bold; + cursor: default; +} + +.dialog .title .button { + float: right; + border: 1px solid #66a; + padding: 0px 1px 0px 2px; + margin-right: 1px; + color: #fff; + text-align: center; +} + +.dialog .title .button-hilite { border-color: #88f; background: #44c; } + +.dialog button { + width: 5em; + padding: 0px; +} + +.dialog .buttonColor { + padding: 1px; + cursor: default; + border: 1px solid; + border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; +} + +.dialog .buttonColor-hilite { + border-color: #000; +} + +.dialog .buttonColor .chooser, .dialog .buttonColor .nocolor { + height: 0.6em; + border: 1px solid; + padding: 0px 1em; + border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; +} + +.dialog .buttonColor .nocolor { padding: 0px; } +.dialog .buttonColor .nocolor-hilite { background-color: #fff; color: #f00; } + +.dialog .label { text-align: right; width: 6em; } +.dialog .value input { width: 100%; } +.dialog .buttons { text-align: right; padding: 2px 4px 0px 4px; } + +.dialog legend { font-weight: bold; } +.dialog fieldset table { margin: 2px 0px; } + +.popupdiv { + border: 2px solid; + border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; +} + +.popupwin { + padding: 0px; + margin: 0px; +} + +.popupwin .title { + background: #fff; + color: #000; + font-weight: bold; + font-size: 120%; + padding: 3px 10px; + margin-bottom: 10px; + border-bottom: 1px solid black; + letter-spacing: 2px; +} + +form { margin: 0px; border: none; } diff --git a/lib/editor/htmlarea.js b/lib/editor/htmlarea.js new file mode 100644 index 0000000000..b1008bda00 --- /dev/null +++ b/lib/editor/htmlarea.js @@ -0,0 +1,1839 @@ +// +// htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc. +// This copyright notice MUST stay intact for use (see license.txt). +// +// A free WYSIWYG editor replacement for + + + diff --git a/lib/editor/popups/fullscreen.php b/lib/editor/popups/fullscreen.php new file mode 100644 index 0000000000..ec007fc847 --- /dev/null +++ b/lib/editor/popups/fullscreen.php @@ -0,0 +1,164 @@ + + +Fullscreen Editor + + + + + + + + + + + + + +
+ +
+ + diff --git a/lib/editor/popups/insert_image.html b/lib/editor/popups/insert_image.html new file mode 100644 index 0000000000..292dd35822 --- /dev/null +++ b/lib/editor/popups/insert_image.html @@ -0,0 +1,215 @@ + + + + Insert Image + + + + + + + + + + + +
Insert Image
+ +
+ + + + + + + + + + + + + +
Image URL: + +
Alternate text:
+ +

+ +

+Layout + +
+ +
Alignment:
+ + +

+ +

Border thickness:
+ + +
+ +
+ +
+Spacing + +
+ +
Horizontal:
+ + +

+ +

Vertical:
+ + +
+ +
+ +
+
+ + +
+ +
+ + + diff --git a/lib/editor/popups/insert_image.php b/lib/editor/popups/insert_image.php new file mode 100644 index 0000000000..38b5a6a21f --- /dev/null +++ b/lib/editor/popups/insert_image.php @@ -0,0 +1,231 @@ +fullname = ""; // Just to keep display happy, though browsing may fail + } +?> + + + + Insert Image + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + +
: + +
:
+ +

+ +

+ + +
+ +
:
+ + +

+ +

:
+ + +
+ +
+ +
+ + +
+ +
:
+ + +

+ +

:
+ + +
+ +
+ +
+
+fullname\" type=\"button\" name=\"browse\" onclick=\"set_url_value()\">".get_string("browse","htmlarea")." \n":""; +?> + + +
+ +
+ + + diff --git a/lib/editor/popups/insert_table.html b/lib/editor/popups/insert_table.html new file mode 100644 index 0000000000..bdf527c210 --- /dev/null +++ b/lib/editor/popups/insert_table.html @@ -0,0 +1,173 @@ + + + + Insert Table + + + + + + + + + + + +
Insert Table
+ +
+ + + + + + + + + + + + + + + + + + + +
Rows:
Cols:Width:
+ +

+ +

+Layout + +
+ +
Alignment:
+ + +

+ +

Border thickness:
+ + +
+ +
+ +
+Spacing + +
+ +
Cell spacing:
+ + +

+ +

Cell padding:
+ + +
+ +
+ +
+
+ + +
+ +
+ + + diff --git a/lib/editor/popups/insert_table.php b/lib/editor/popups/insert_table.php new file mode 100644 index 0000000000..dfdad9d94d --- /dev/null +++ b/lib/editor/popups/insert_table.php @@ -0,0 +1,174 @@ + + + + + Insert Table + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + +
:
::
+ +

+ +

+ + +
+ +
:
+ + +

+ +

:
+ + +
+ +
+ +
+ + +
+ +
:
+ + +

+ +

:
+ + +
+ +
+ +
+
+ + +
+ +
+ + + diff --git a/lib/editor/popups/new_insert_image.html b/lib/editor/popups/new_insert_image.html new file mode 100644 index 0000000000..8936733c50 --- /dev/null +++ b/lib/editor/popups/new_insert_image.html @@ -0,0 +1,215 @@ + + + + Insert Image + + + + + + + + + + + +
Insert Image
+ +
+ + + + + + + + + + + + + +
Image URL: + +
Alternate text:
+ +

+ +

+Layout + +
+ +
Alignment:
+ + +

+ +

Border thickness:
+ + +
+ +
+ +
+Spacing + +
+ +
Horizontal:
+ + +

+ +

Vertical:
+ + +
+ +
+ +
+
+ + +
+ +
+ + + diff --git a/lib/editor/popups/popup.js b/lib/editor/popups/popup.js new file mode 100644 index 0000000000..0b075fcf37 --- /dev/null +++ b/lib/editor/popups/popup.js @@ -0,0 +1,43 @@ +function __dlg_onclose() { + if (!document.all) { + opener.Dialog._return(null); + } +}; + +function __dlg_init() { + if (!document.all) { + // init dialogArguments, as IE gets it + window.dialogArguments = opener.Dialog._arguments; + window.sizeToContent(); + window.sizeToContent(); // for reasons beyond understanding, + // only if we call it twice we get the + // correct size. + window.addEventListener("unload", __dlg_onclose, true); + // center on parent + var px1 = opener.screenX; + var px2 = opener.screenX + opener.outerWidth; + var py1 = opener.screenY; + var py2 = opener.screenY + opener.outerHeight; + var x = (px2 - px1 - window.outerWidth) / 2; + var y = (py2 - py1 - window.outerHeight) / 2; + window.moveTo(x, y); + var body = document.body; + window.innerHeight = body.offsetHeight + 10; + window.innerWidth = body.offsetWidth + 10; + window.focus(); + } else { + var body = document.body; + window.dialogWidth = body.offsetWidth + "px"; + window.dialogHeight = body.offsetHeight + 50 + "px"; + } +}; + +// closes the dialog and passes the return info upper. +function __dlg_close(val) { + if (document.all) { // IE + window.returnValue = val; + } else { + opener.Dialog._return(val); + } + window.close(); +}; diff --git a/lib/editor/popups/select_color.html b/lib/editor/popups/select_color.html new file mode 100644 index 0000000000..2209b92a13 --- /dev/null +++ b/lib/editor/popups/select_color.html @@ -0,0 +1,346 @@ + + +Select Color + + + + + + + +
+ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/lib/editor/popupwin.js b/lib/editor/popupwin.js new file mode 100644 index 0000000000..8d37f254fe --- /dev/null +++ b/lib/editor/popupwin.js @@ -0,0 +1,125 @@ +function PopupWin(editor, title, handler, initFunction) { + this.editor = editor; + this.handler = handler; + var dlg = window.open("", "__ha_dialog", + "toolbar=no,menubar=no,personalbar=no,width=600,height=600," + + "scrollbars=no,resizable=no"); + this.window = dlg; + var doc = dlg.document; + this.doc = doc; + var self = this; + + var base = document.baseURI || document.URL; + if (base && base.match(/(.*)\/([^\/]+)/)) { + base = RegExp.$1 + "/"; + } + this.baseURL = base; + + doc.open(); + var html = "" + title + "\n"; + // html += "\n"; + html += "\n"; + html += ""; + doc.write(html); + doc.close(); + + // sometimes I Hate Mozilla... ;-( + function init2() { + var body = doc.body; + if (!body) { + setTimeout(init2, 25); + return false; + } + dlg.title = title; + doc.documentElement.style.padding = "0px"; + doc.documentElement.style.margin = "0px"; + var content = doc.createElement("div"); + content.className = "content"; + self.content = content; + body.appendChild(content); + self.element = body; + initFunction(self); + dlg.focus(); + }; + init2(); +}; + +PopupWin.prototype.callHandler = function() { + var tags = ["input", "textarea", "select"]; + var params = new Object(); + for (var ti in tags) { + var tag = tags[ti]; + var els = this.content.getElementsByTagName(tag); + for (var j = 0; j < els.length; ++j) { + var el = els[j]; + var val = el.value; + if (el.tagName.toLowerCase() == "input") { + if (el.type == "checkbox") { + val = el.checked; + } + } + params[el.name] = val; + } + } + this.handler(this, params); + return false; +}; + +PopupWin.prototype.close = function() { + this.window.close(); +}; + +PopupWin.prototype.addButtons = function() { + var self = this; + var div = this.doc.createElement("div"); + this.content.appendChild(div); + div.className = "buttons"; + for (var i = 0; i < arguments.length; ++i) { + var btn = arguments[i]; + var button = this.doc.createElement("button"); + div.appendChild(button); + button.innerHTML = HTMLArea.I18N.buttons[btn]; + switch (btn) { + case "ok": + button.onclick = function() { + self.callHandler(); + self.close(); + return false; + }; + break; + case "cancel": + button.onclick = function() { + self.close(); + return false; + }; + break; + } + } +}; + +PopupWin.prototype.showAtElement = function() { + var self = this; + // Mozilla needs some time to realize what's goin' on.. + setTimeout(function() { + var w = self.content.offsetWidth + 4; + var h = self.content.offsetHeight + 4; + // size to content -- that's fuckin' buggy in all fuckin' browsers!!! + // so that we set a larger size for the dialog window and then center + // the element inside... phuck! + + // center... + var el = self.content; + var s = el.style; + // s.width = el.offsetWidth + "px"; + // s.height = el.offsetHeight + "px"; + s.position = "absolute"; + s.left = (w - el.offsetWidth) / 2 + "px"; + s.top = (h - el.offsetHeight) / 2 + "px"; + if (HTMLArea.is_gecko) { + self.window.innerWidth = w; + self.window.innerHeight = h; + } else { + self.window.resizeTo(w + 8, h + 35); + } + }, 25); +}; diff --git a/lib/editor/reference.html b/lib/editor/reference.html new file mode 100644 index 0000000000..81d617f6a3 --- /dev/null +++ b/lib/editor/reference.html @@ -0,0 +1,522 @@ + + +HTMLArea-3.0 Reference + + + + + + + + + + + + +

HTMLArea-3.0 Documentation

+ +
+ + This documentation contains valid information, but is outdated in the + terms that it does not covers all the features of HTMLArea. A new + documentation project will be started, based on LaTeX. + +
+ + +

Introduction

+ +

What is HTMLArea?

+ +

HTMLArea is a free WYSIWYG editor replacement for <textarea> +fields. By adding a few simple lines of JavaScript code to your web page +you can replace a regular textarea with a rich text editor that lets your +users do the following:

+ + + +

Some of the interesting features of HTMLArea that set's it apart from +other web based WYSIWYG editors are as follows:

+ + + +

Is it really free? What's the catch?

+ +

Yes! It's really free. You can use it, modify it, distribute it with your +software, or do just about anything you like with it.

+ +

What are the browser requirements?

+ +

HTMLArea requires Internet Explorer >= 5.5 +(Windows only), or Mozilla >= 1.3-Beta on any platform. +Any browser based on Gecko will +also work, provided that Gecko version is at least the one included in +Mozilla-1.3-Beta (for example, Galeon-1.2.8). However, it is backwards +compatible with other browsers. They will get a regular textarea field +instead of a WYSIWYG editor.

+ +

Can I see an example of what it looks like?

+ +

Just make sure you're using one of the browsers mentioned above and see +below.

+ +
+ +
+ +

Where can I find out more info, download the latest version and talk to +other HTMLArea users?

+ +

You can find out more about HTMLArea and download the latest version on +the HTMLArea +homepage and you can talk to other HTMLArea users and post any comments +or suggestions you have in the HTMLArea forum.

+ +

Keyboard shortcuts

+ +

The editor provides the following key combinations:

+ + + +

Installation

+ +

How do I add HTMLArea to my web page?

+ +

It's easy. First you need to upload HTMLArea files to your website. +Just follow these steps.

+ +
    +
  1. Download the latest version from the htmlArea + homepage.
  2. +
  3. Unzip the files onto your local computer (making sure to maintain the + directory structure contained in the zip).
  4. +
  5. Create a new folder on your website called /htmlarea/ (make sure it's + NOT inside the cgi-bin).
  6. +
  7. Transfer all the HTMLArea files from your local computer into the + /htmlarea/ folder on your website.
  8. +
  9. Open the example page /htmlarea/example.html with your browser to make + sure everything works.
  10. +
+ +

Once htmlArea is on your website all you need to do is add some +JavaScript to any pages that you want to add WYSIWYG editors to. Here's how +to do that.

+ +
    + +
  1. Include the "htmlarea.js" script: +
    <script type="text/javascript" src="/htmlarea/htmlarea.js"></script>
    +
  2. + +
  3. If you are using popup dialogs, i.e. for insert table, insert image, + select color, then you need to include the "dialog.js" file. This is + recommended anyway. +
    <script type="text/javascript" src="/htmlarea/dialog.js"></script>
    +
  4. + +
  5. Include the corresponding language definition file. Note: + internationalization is available only since version 3.0. Check the files + containing "lang" in the distribution ZIP. If your preferred language is + not there yet and you decide to write it, please consider sending it to + us so that it gets included in the next release. +
    <script type="text/javascript" src="/htmlarea/lang/en.js"></script>
    + +
  6. Include the stylesheet (be sure to put this inside the HEAD tag): +
    <style type="text/css">@import url(/htmlarea/htmlarea.css)</style>
    +
  7. + +
  8. If you want to change all your <textarea>-s into + HTMLArea-s then you can use the simplest way to create HTMLArea:

    +
    <script type="text/javascript" defer="1">
    +    HTMLArea.replaceAll();
    +</script>
    +

    Note: you can also add the + HTMLArea.replaceAll() code to the onload + event handler for the body element, if you find it more appropriate.

    + +

    A different approach, if you have more than one textarea and only want + to change one of them, is to use HTMLArea.replace("id") -- + pass the id of your textarea. Do not use the + name attribute anymore, it's not a standard solution!

    + +
+ +

I want to change the editor settings, how do I do that?

+ +

While it's true that all you need is one line of JavaScript to create an +htmlArea WYSIWYG editor, you can also specify more config settings in the +code to control how the editor works and looks. Here's an example of some of +the available settings:

+ +
var config = new HTMLArea.Config(); // create a new configuration object
+                                    // having all the default values
+config.width = '90%';
+config.height = '200px';
+
+// the following sets a style for the page body (black text on yellow page)
+// and makes all paragraphs be bold by default
+config.pageStyle =
+  'body { background-color: yellow; color: black; font-family: verdana,sans-serif } ' +
+  'p { font-width: bold; } ';
+
+// the following replaces the textarea with the given id with a new
+// HTMLArea object having the specified configuration
+HTMLArea.replace('id', config);
+ +

Important: It's recommended that you add +custom features and configuration to a separate file. This will ensure you +that when we release a new official version of HTMLArea you'll have no +trouble upgrading it.

+ +

How do I customize the toolbar?

+ +

Using the configuration object introduced above allows you to completely +control what the toolbar contains. Following is an example of a one-line, +customized toolbar, much simpler than the default one:

+ +
var config = new HTMLArea.Config();
+config.toolbar = [
+  ['fontname', 'space',
+   'fontsize', 'space',
+   'formatblock', 'space',
+   'bold', 'italic', 'underline']
+];
+HTMLArea.replace('id', config);
+ +

The toolbar is an Array of Array objects. Each array in the toolbar +defines a new line. The default toolbar looks like this:

+ +
config.toolbar = [
+[ "fontname", "space",
+  "fontsize", "space",
+  "formatblock", "space",
+  "bold", "italic", "underline", "separator",
+  "strikethrough", "subscript", "superscript", "separator",
+  "copy", "cut", "paste", "space", "undo", "redo" ],
+		
+[ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
+  "insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
+  "forecolor", "hilitecolor", "textindicator", "separator",
+  "inserthorizontalrule", "createlink", "insertimage", "inserttable", "htmlmode", "separator",
+  "popupeditor", "separator", "showhelp", "about" ]
+];
+ +

Except three strings, all others in the examples above need to be defined +in the config.btnList object (detailed a bit later in this +document). The three exceptions are: 'space', 'separator' and 'linebreak'. +These three have the following meaning, and need not be present in +btnList:

+ + + +

Important: It's recommended that you add +custom features and configuration to a separate file. This will ensure you +that when we release a new official version of HTMLArea you'll have no +trouble upgrading it.

+ +

How do I create custom buttons?

+ +

By design, the toolbar is easily extensible. For adding a custom button +one needs to follow two steps.

+ +

1. Register the button in config.btnList.

+ +

For each button in the toolbar, HTMLArea needs to know the following +information:

+ +

You need to provide all this information for registering a new button +too. The button ID can be any string identifier and it's used when +defining the toolbar, as you saw above. We recommend starting +it with "my-" so that it won't clash with the standard ID-s (those from +the default toolbar).

+ +

Register button example #1

+ +
// get a default configuration
+var config = new HTMLArea.Config();
+// register the new button using Config.registerButton.
+// parameters:        button ID,   tooltip,          image,           textMode,
+config.registerButton("my-hilite", "Highlight text", "my-hilite.gif", false,
+// function that gets called when the button is clicked
+  function(editor, id) {
+    editor.surroundHTML('<span class="hilite">', '</span>');
+  }
+);
+ +

An alternate way of calling registerButton is exemplified above. Though +the code might be a little bit larger, using this form makes your code more +maintainable. It doesn't even needs comments as it's pretty clear.

+ +

Register button example #2

+ +
var config = new HTMLArea.Config();
+config.registerButton({
+  id        : "my-hilite",
+  tooltip   : "Highlight text",
+  image     : "my-hilite.gif",
+  textMode  : false,
+  action    : function(editor, id) {
+                editor.surroundHTML('<span class="hilite">', '</span>');
+              }
+});
+ +

You might notice that the "action" function receives two parameters: +editor and id. In the examples above we only used the +editor parameter. But it could be helpful for you to understand +both:

+ + + +

2. Inserting it into the toolbar

+ +

At this step you need to specify where in the toolbar to insert the +button, or just create the whole toolbar again as you saw in the previous +section. You use the button ID, as shown in the examples of customizing the +toolbar in the previous section.

+ +

For the sake of completion, following there are another examples.

+ +

Append your button to the default toolbar

+ +
config.toolbar.push([ "my-hilite" ]);
+ +

Customized toolbar

+ +
config.toolbar = [
+  ['fontname', 'space',
+   'fontsize', 'space',
+   'formatblock', 'space',
+   'separator', 'my-hilite', 'separator', 'space', // here's your button
+   'bold', 'italic', 'underline', 'space']
+];
+ +

Note: in the example above our new button is +between two vertical separators. But this is by no means required. You can +put it wherever you like. Once registered in the btnList (step 1) your custom button behaves just like a default +button.

+ +

Important: It's recommended that you add +custom features and configuration to a separate file. This will ensure you +that when we release a new official version of HTMLArea you'll have no +trouble upgrading it.

+ +

A complete example

+ +

Please note that it is by no means necessary to include the following +code into the htmlarea.js file. On the contrary, it might not work there. +The configuration system is designed such that you can always customize the +editor from outside files, thus keeping the htmlarea.js file +intact. This will make it easy for you to upgrade your HTMLArea when we +release a new official version. OK, I promise it's the last time I said +this. ;)

+ +
// All our custom buttons will call this function when clicked.
+// We use the buttonId parameter to determine what button
+// triggered the call.
+function clickHandler(editor, buttonId) {
+  switch (buttonId) {
+    case "my-toc":
+      editor.insertHTML("<h1>Table Of Contents</h1>");
+      break;
+    case "my-date":
+      editor.insertHTML((new Date()).toString());
+      break;
+    case "my-bold":
+      editor.execCommand("bold");
+      editor.execCommand("italic");
+      break;
+    case "my-hilite":
+      editor.surroundHTML("<span class=\"hilite\">", "</span>");
+      break;
+  }
+};
+
+// Create a new configuration object
+var config = new HTMLArea.Config();
+
+// Register our custom buttons
+config.registerButton("my-toc",  "Insert TOC", "my-toc.gif", false, clickHandler);
+config.registerButton("my-date", "Insert date/time", "my-date.gif", false, clickHandler);
+config.registerButton("my-bold", "Toggle bold/italic", "my-bold.gif", false, clickHandler);
+config.registerButton("my-hilite", "Hilite selection", "my-hilite.gif", false, clickHandler);
+
+// Append the buttons to the default toolbar
+config.toolbar.push(["linebreak", "my-toc", "my-date", "my-bold", "my-hilite"]);
+
+// Replace an existing textarea with an HTMLArea object having the above config.
+HTMLArea.replace("textAreaID", config);
+ + +
+
© InteractiveTools.com 2002, 2003. +
+HTMLArea v3.0 developed by Mihai Bazon for +InteractiveTools.com. +
+Documentation written by Mihai Bazon. +
+ +Last modified on Sun Aug 3 16:11:23 2003 + + + diff --git a/lib/editor/release-notes.html b/lib/editor/release-notes.html new file mode 100644 index 0000000000..f37d40a160 --- /dev/null +++ b/lib/editor/release-notes.html @@ -0,0 +1,82 @@ + + + + HTMLArea-3.0-beta release notes + + + + +

HTMLArea-3.0-beta release notes

+ +

This release was compiled on Aug 11, 2003 [21:30] GMT.

+ + +

Changes since 3.0-Alpha:

+ + + +

Rationale for Beta

+ +

Why was this released as "Beta"? The code is quite stable and it + didn't deserve a "Beta" qualification. However, there are some things + left to do for the real 3.0 version. These things will not affect the + API to work with HTMLArea, in other words, you can install the Beta + right now and then install the final release without modifying your + code. That's if you don't modify HTMLArea itself. ;-)

+ +

To-Do before 3.0 final

+ +
    + +
  1. We should use a single popup interface. Currently there are two: + dialog.js and popupwin.js; dialog.js emulates modal dialogs, which + sucks when you want to open "select-color" from another popup and not + from the editor itself. Very buggy in IE. We should probably use only + modeless dialogs (that is, popupwin.js).
  2. + +
  3. Internationalization for the SpellChecker plugin.
  4. + +
  5. Internationalization for the TableOperations plugin.
  6. + +
  7. People who sent translations are invited to re-iterate through + their work and make it up-to-date with lang/en.js which is the main + lang file for HTMLArea-3.0. Some things have changed but not all + translations are updated.
  8. + +
  9. Documentation.
  10. + +
+ + +
+
Mihai Bazon
+ + +Last modified on Sun Aug 10 19:31:39 2003 + + + + + + diff --git a/lib/editor/test.js b/lib/editor/test.js new file mode 100644 index 0000000000..b5f57ac587 --- /dev/null +++ b/lib/editor/test.js @@ -0,0 +1,26 @@ +// All our custom buttons will call this function when clicked. +// We use the buttonId parameter to determine what button +// triggered the call. +function clickHandler(editor, buttonId) { + switch (buttonId) { + case "my-toc": + editor.insertHTML("

Table Of Contents

"); + break; + case "my-date": + editor.insertHTML((new Date()).toString()); + break; + } +}; + +// Create a new configuration object +var config = new HTMLArea.Config(); + +// Register our custom buttons +config.registerButton("my-toc", "Insert TOC", "images/em.icon.smile.gif", false, clickHandler); +config.registerButton("my-date", "Insert date/time", "icon_ins_char.gif", false, clickHandler); + +// Append the buttons to the default toolbar +config.toolbar.push(["linebreak", "my-toc", "my-date"]); + +// Replace an existing textarea with an HTMLArea object having the above config. +HTMLArea.replace("TA", config); \ No newline at end of file