MDL-21400 converting forms stuff to new M namespace and using standardised JS module...
[moodle.git] / lib / editor / tinymce / module.js
CommitLineData
4c508047
PS
1// This file is part of Moodle - http://moodle.org/
2//
3// Moodle is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// Moodle is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15
16/**
17 * TinyMCE helper javascript functions
18 *
19 * @package moodlecore
20 * @subpackage editor
21 * @copyright 2010 Petr Skoda (skodak) info@skoda.org
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25M.editor_tinymce = M.editor_tinymce || {};
26
27M.editor_tinymce.editor_options = M.editor_tinymce.options || {};
28M.editor_tinymce.filepicker_options = M.editor_tinymce.filepicker_options || {};
29
30M.editor_tinymce.init_editor = function(Y, editorid, options) {
31 M.editor_tinymce.editor_options[editorid] = options;
32 tinyMCE.init(options);
33
34 var item = document.getElementById(editorid+'_filemanager');
35 if (item) {
36 item.parentNode.removeChild(item);
37 }
38};
39
40M.editor_tinymce.init_filepicker = function(Y, editorid, options) {
41 M.editor_tinymce.filepicker_options[editorid] = options;
42};
43
44M.editor_tinymce.toggle = function(id) {
45 tinyMCE.execCommand('mceToggleEditor', false, id);
46};
47
48M.editor_tinymce.filepicker_callback = function(args) {
49};
50
51M.editor_tinymce.filepicker = function(target_id, url, type, win) {
52 YUI(M.yui.loader).use('core_filepicker', function (Y) {
53 var editor_id = tinyMCE.selectedInstance.editorId;
54 var options = M.editor_tinymce.filepicker_options[editor_id];
55
56 options.formcallback = M.editor_tinymce.filepicker_callback;
57 options.editor_target = win.document.getElementById(target_id);
58
59 M.core_filepicker.show(Y, options);
60 });
61};
62