]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14741: use better names for tinymce-specific javascript functions, add function...
authorscyrma <scyrma>
Wed, 30 Jul 2008 06:26:26 +0000 (06:26 +0000)
committerscyrma <scyrma>
Wed, 30 Jul 2008 06:26:26 +0000 (06:26 +0000)
lib/editor/tinymce.js.php
lib/weblib.php

index a38737a3bab2ca72a172025ea851065c13b18631..486edaa53a5000c4573b237a80e07e36c9352b61 100644 (file)
@@ -137,9 +137,12 @@ function createHTMLArea(id) {
 
     });
 
-    script = "document.getElementById("+id+").form."+editorsubmit+" = document.getElementById("+id+").form.onsubmit;";
-    script = script + "document.getElementById("+id+").form.onsubmit = function() { tinyMCE.triggerSave(); document.getElementById("+id+").form."+editorsubmit+"(); document.getElementById("+id+").form."+editorsubmit+" = null;}";
-    eval(script);
+document.getElementById('ed').form.editorsubmit_43 = document.getElementById('ed').form.onsubmit;
+document.getElementById('ed').form.onsubmit = function() { 
+    tinyMCE.triggerSave(); 
+    document.getElementById('ed').form.editorsubmit_43(); 
+    document.getElementById('ed').form.editorsubmit_43 = null;
+}
 
 }
 
@@ -183,14 +186,14 @@ echo <<<EOF
         theme_advanced_buttons2: "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull",
         theme_advanced_buttons2_add: "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl",
         theme_advanced_buttons3: "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,emoticons,image,media,dragmath,advhr,nonbreaking,charmap",
-        theme_advanced_buttons3_add: "|,code,fullscreen,|,table,insertlayer,styleprops",
+        theme_advanced_buttons3_add: "|,table,insertlayer,styleprops,|,code,fullscreen",
         theme_advanced_fonts: "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings", 
         moodleimage_course_id: $courseid,
         theme_advanced_resize_horizontal: true,
         theme_advanced_resizing: true,
         theme_advanced_toolbar_location : "top",
         theme_advanced_statusbar_location : "bottom",
-        file_browser_callback : "moodlefilemanager",
+        file_browser_callback : "mce_moodlefilemanager",
 
 EOF;
 // the xhtml ruleset must be the last one - no comma at the end of the file
@@ -198,10 +201,10 @@ readfile('tinymce/xhtml_ruleset.txt');
 echo <<<EOF
     });
 
-    function toggleEditor(id) {
+    function mce_toggleEditor(id) {
         tinyMCE.execCommand('mceToggleEditor',false,id);
     }
-    function moodlefilemanager(field_name, url, type, win) {
+    function mce_moodlefilemanager(field_name, url, type, win) {
         tinyMCE.activeEditor.windowManager.open({
             file: "{$CFG->httpswwwroot}/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id={$courseid}",
             width: 480,  
@@ -215,5 +218,13 @@ echo <<<EOF
         });
         return false;
     }
+    function mce_saveOnSubmit(id) {
+        var prevOnSubmit = document.getElementById(id).form.onsubmit;
+        document.getElementById(id).form.onsubmit = function() { 
+            tinyMCE.triggerSave(); 
+            prevOnSubmit(); 
+            prevOnSubmit = null;
+        };
+    }
 EOF;
 ?>
index df3ab2cb384c79b02fd9a8c3c688040242837959..aa1d5bf048e4aeaa9f24edd8dd17e4cb69f3a0d4 100644 (file)
@@ -4870,11 +4870,13 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
     $str .= '</textarea>'."\n";
 
     if ($usehtmleditor) {
-        $str_toggle = '<span class="helplink"><a href="javascript:toggleEditor(\''. $id .'\');"><img width="50" height="17" src="'. $CFG->httpswwwroot .'/lib/editor/tinymce/images/toggle.gif" alt="'. get_string('editortoggle') .'" title="'. get_string('editortoggle') .'" class="icontoggle" /></a></span>';
+        $str_save = "alert('fdsalkjfdsa')";
+        $str_toggle = '<span class="helplink"><a href="javascript:mce_toggleEditor(\''. $id .'\');"><img width="50" height="17" src="'. $CFG->httpswwwroot .'/lib/editor/tinymce/images/toggle.gif" alt="'. get_string('editortoggle') .'" title="'. get_string('editortoggle') .'" class="icontoggle" /></a></span>';
         // Show shortcuts button if HTML editor is in use, but only if JavaScript is enabled (MDL-9556)
         $str .= '<div class="textareaicons">';
         $str .= '<script type="text/javascript">
 //<![CDATA[
+mce_saveOnSubmit(\''.addslashes_js($id).'\');
 document.write(\''.addslashes_js($str_toggle).'\');
 document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');
 //]]>