MDL-14741: use better names for tinymce-specific javascript functions, add function to trigger the save event of tinymce on form save.
This commit is contained in:
@@ -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;
|
||||
?>
|
||||
|
||||
+3
-1
@@ -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()).'\');
|
||||
//]]>
|
||||
|
||||
Reference in New Issue
Block a user