From b83f54f895d3f9dc45fd0f8d08129b8756443d58 Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Wed, 15 Dec 2010 13:56:05 +0800 Subject: [PATCH] MDL-23930 fixed javascript insert into tinymce --- mod/data/data.js | 16 +++++++++------- mod/data/templates.php | 7 ------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/mod/data/data.js b/mod/data/data.js index 8031ea179b4..18861e79cab 100644 --- a/mod/data/data.js +++ b/mod/data/data.js @@ -3,13 +3,15 @@ * Used when editing a data template */ function insert_field_tags(selectlist) { - if (typeof(currEditor) != 'undefined' && currEditor._editMode == 'wysiwyg') { - // HTMLArea-specific - currEditor.insertHTML(selectlist.options[selectlist.selectedIndex].value); - } else { - // For inserting when in HTMLArea code view or for normal textareas - insertAtCursor(currTextarea, selectlist.options[selectlist.selectedIndex].value); - } + var value = selectlist.options[selectlist.selectedIndex].value; + var editorname = 'template'; + if (typeof tinyMCE == 'undefined') { + var element = document.getElementsByName(editorname)[0]; + // For inserting when in normal textareas + insertAtCursor(element, value); + } else { + tinyMCE.execInstanceCommand(editorname, 'mceInsertContent', false, value); + } } /** diff --git a/mod/data/templates.php b/mod/data/templates.php index ebfebde296f..90cf012aa0e 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -82,13 +82,6 @@ $strdata = get_string('modulenameplural','data'); // For the javascript for inserting template tags: initialise the default textarea to // 'edit_template' - it is always present in all different possible views. -$editorobj = 'editor_'.md5('template'); - -$bodytag = 'onload="'; -$bodytag .= 'if (typeof('.$editorobj.') != \'undefined\') { currEditor = '.$editorobj.'; } '; -$bodytag .= 'currTextarea = document.getElementById(\'tempform\').template;'; -$bodytag .= '" '; - if ($mode == 'singletemplate') { $PAGE->navbar->add(get_string($mode,'data')); } -- 2.43.0