]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14741: Make tinymce loading simpler, and makes it work on pages with multiple...
authorscyrma <scyrma>
Fri, 18 Jul 2008 04:24:53 +0000 (04:24 +0000)
committerscyrma <scyrma>
Fri, 18 Jul 2008 04:24:53 +0000 (04:24 +0000)
lib/editor/tinymce.js.php
lib/weblib.php

index a63feed85a3339e8182ee32a3092f18877596818..233ab4c5786e886c12f02cfb8193f35c730559da 100644 (file)
@@ -148,7 +148,7 @@ EOF;
 
 echo <<<EOF
     tinyMCE.init({
-        mode: "none",
+        mode: "textareas",
         relative_urls: false,
         editor_selector: "form-textarea-simple",
         document_base_url: "$CFG->httpswwwroot",
@@ -162,7 +162,7 @@ echo <<<EOF
         plugins: "spellchecker,emoticons,paste,standardmenu,directionality,contextmenu"
     });
     tinyMCE.init({
-        mode: "none",
+        mode: "textareas",
         relative_urls: false,
         editor_selector: "form-textarea-advanced",
         document_base_url: "$CFG->httpswwwroot",
@@ -195,9 +195,9 @@ EOF;
 readfile('tinymce/xhtml_ruleset.txt');
 echo <<<EOF
     });
+
     function toggleEditor(id) {
-        var elm = document.getElementById(id);
-        tinyMCE.execCommand('mceToggleEditor',false,elm);
+        tinyMCE.execCommand('mceToggleEditor',false,id);
     }
     function moodlefilemanager(field_name, url, type, win) {
         tinyMCE.activeEditor.windowManager.open({
index 18cb0832c44eae53032559f49f29a5f12282121e..3a3a8f75a6b4918bbc03db6c8d8a8c00caeb7092 100644 (file)
@@ -4027,16 +4027,6 @@ function print_container_end($return=false) {
         $output = '</div>';
     }
 
-    if ($idbase == 'footer' and !empty($THEME->htmleditors)) {
-        $output .= "\n".'<script type="text/javascript">'."\n";
-        $output .= "\n//<![CDATA[\n";
-        foreach ($THEME->htmleditors as $editorid) {
-            $output .= 'tinyMCE.execCommand("mceToggleEditor", false, document.getElementById(\''. $editorid .'\'))'."\n";
-        }
-        $output .= "//]]>\n";
-        $output .= '</script>'."\n";
-    }
-
     if ($return) {
         return $output;
     } else {
@@ -4796,9 +4786,9 @@ function print_recent_activity_note($time, $user, $text, $link, $return=false, $
  * @param int $courseid Course ID to pass to the file manager (defaults to global $COURSE->id).
  * @param bool $return If false, will output string. If true, will return string value.
  * @param string $id CSS ID to add to the textarea element.
- * @param string $class CSS classes to add to the textarea element. Use 'form-textarea-simple' to get a basic editor. Defaults to 'form-textarea-advanced' (complete editor).
+ * @param string $editorclass CSS classes to add to the textarea element when using the htmleditor. Use 'form-textarea-simple' to get a basic editor. Defaults to 'form-textarea-advanced' (complete editor). If this is null or invalid, the htmleditor will not show for this field.
  */
-function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='', $class='form-textarea-advanced') {
+function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='', $editorclass='form-textarea-advanced') {
 /// $width and height are legacy fields and no longer used as pixels like they used to be.
 /// However, you can set them to zero to override the mincols and minrows values below.
 
@@ -4850,9 +4840,11 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
 
     if ($usehtmleditor) {
         $THEME->htmleditors[] = $id;
+    } else {
+        $editorclass = '';
     }
 
-    $str .= "\n".'<textarea class="form-textarea '. $class .'" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
+    $str .= "\n".'<textarea class="form-textarea '. $editorclass .'" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
     if ($usehtmleditor) {
         $str .= htmlspecialchars($value); // needed for editing of cleaned text!
     } else {