From f536910483d31e39c5a1c60f7720bb9944df4308 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Tue, 25 Nov 2008 10:44:04 +0000 Subject: [PATCH] HTML_EDITOR, REPOSITORY/MDL-16650 Modify tinymce to return a youtube link instead a object tag. When media filter enabled, this link will be translated to proper youtube video. --- lib/editor/tinymce/jscripts/moodle_readme.txt | 1 + .../jscripts/patch-tinymce_plugin_media.txt | 53 +++++++++++++++++++ .../tiny_mce/plugins/media/js/media.js | 24 +++++++-- 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 lib/editor/tinymce/jscripts/patch-tinymce_plugin_media.txt diff --git a/lib/editor/tinymce/jscripts/moodle_readme.txt b/lib/editor/tinymce/jscripts/moodle_readme.txt index 2c21f64744..1b09243e8f 100644 --- a/lib/editor/tinymce/jscripts/moodle_readme.txt +++ b/lib/editor/tinymce/jscripts/moodle_readme.txt @@ -3,6 +3,7 @@ Description of TinyMCE library import into Moodle Our changes: + added plugins: dragmath, moodlenolink and customised spellchecker * modified string handling: see patch-tinymce_strings.txt +* modified media plugin: see patch-tinymce_plugin_media.txt (MDL-16650) TODO: * spellchecker integration in spellchecker/config.php (MDL-16639) diff --git a/lib/editor/tinymce/jscripts/patch-tinymce_plugin_media.txt b/lib/editor/tinymce/jscripts/patch-tinymce_plugin_media.txt new file mode 100644 index 0000000000..5917167770 --- /dev/null +++ b/lib/editor/tinymce/jscripts/patch-tinymce_plugin_media.txt @@ -0,0 +1,53 @@ +Index: tiny_mce/plugins/media/js/media.js +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/editor/tinymce/jscripts/tiny_mce/plugins/media/js/media.js,v +retrieving revision 1.3 +diff -u -r1.3 media.js +--- tiny_mce/plugins/media/js/media.js 23 Sep 2008 04:10:42 -0000 1.3 ++++ tiny_mce/plugins/media/js/media.js 25 Nov 2008 10:39:39 -0000 +@@ -263,6 +263,11 @@ + + h += ' />'; + ++ var is_youtube = repo_hook(f.src.value); ++ if (is_youtube) { ++ h = 'youtube video'; ++ } ++ + ed.execCommand('mceInsertContent', false, h); + } + +@@ -305,12 +310,14 @@ + fo = ed.getParam("media_types", "flash=swf;flv=flv;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';'); + + // YouTube +- if (v.match(/watch\?v=(.+)(.*)/)) { ++ if (v.match(/watch\?v=(.+)(.*)/)) { + f.width.value = '425'; + f.height.value = '350'; + f.src.value = 'http://www.youtube.com/v/' + v.match(/v=(.*)(.*)/)[0].split('=')[1]; +- return 'flash'; +- } ++ } else if (v.match(/v\/(.+)(.*)/)) { ++ f.width.value = '425'; ++ f.height.value = '350'; ++ } + + // Google video + if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) { +@@ -625,4 +632,15 @@ + p.innerHTML = "" + h; + } + ++function repo_hook(url){ ++ var f = document.forms[0]; ++ if (url.match(/v\/(.+)(.*)/)) { ++ f.width.value = '425'; ++ f.height.value = '350'; ++ return true; ++ } else { ++ return false; ++ } ++} ++ + tinyMCEPopup.onInit.add(init); diff --git a/lib/editor/tinymce/jscripts/tiny_mce/plugins/media/js/media.js b/lib/editor/tinymce/jscripts/tiny_mce/plugins/media/js/media.js index 28816d1e18..ab469b6ceb 100644 --- a/lib/editor/tinymce/jscripts/tiny_mce/plugins/media/js/media.js +++ b/lib/editor/tinymce/jscripts/tiny_mce/plugins/media/js/media.js @@ -263,6 +263,11 @@ function insertMedia() { h += ' />'; + var is_youtube = repo_hook(f.src.value); + if (is_youtube) { + h = 'youtube video'; + } + ed.execCommand('mceInsertContent', false, h); } @@ -305,12 +310,14 @@ function getType(v) { fo = ed.getParam("media_types", "flash=swf;flv=flv;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';'); // YouTube - if (v.match(/watch\?v=(.+)(.*)/)) { + if (v.match(/watch\?v=(.+)(.*)/)) { f.width.value = '425'; f.height.value = '350'; f.src.value = 'http://www.youtube.com/v/' + v.match(/v=(.*)(.*)/)[0].split('=')[1]; - return 'flash'; - } + } else if (v.match(/v\/(.+)(.*)/)) { + f.width.value = '425'; + f.height.value = '350'; + } // Google video if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) { @@ -625,4 +632,15 @@ function generatePreview(c) { p.innerHTML = "" + h; } +function repo_hook(url){ + var f = document.forms[0]; + if (url.match(/v\/(.+)(.*)/)) { + f.width.value = '425'; + f.height.value = '350'; + return true; + } else { + return false; + } +} + tinyMCEPopup.onInit.add(init); -- 2.39.5