From 958d3f1e2c3315ce6d98b3deb821af10d6573d98 Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 17 May 2009 07:47:04 +0000 Subject: [PATCH] MDL-19184 more tinymce integration and upgrade related improvements --- .../extra/patches/tinymce_plugin_media.patch | 94 +++++++++---------- lib/editor/tinymce/plugins/media/js/media.js | 24 ++++- lib/editor/tinymce/readme_moodle.txt | 10 +- 3 files changed, 74 insertions(+), 54 deletions(-) diff --git a/lib/editor/tinymce/extra/patches/tinymce_plugin_media.patch b/lib/editor/tinymce/extra/patches/tinymce_plugin_media.patch index 5251ca0cc1..15e102c3c2 100644 --- a/lib/editor/tinymce/extra/patches/tinymce_plugin_media.patch +++ b/lib/editor/tinymce/extra/patches/tinymce_plugin_media.patch @@ -1,54 +1,50 @@ -Index: tinymce/plugins/media/js/media.js +Index: lib/editor/tinymce/plugins/media/js/media.js =================================================================== RCS file: /cvsroot/moodle/moodle/lib/editor/tinymce/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) { +retrieving revision 1.1 +diff -u -r1.1 media.js +--- lib/editor/tinymce/plugins/media/js/media.js 16 May 2009 20:54:41 -0000 1.1 ++++ lib/editor/tinymce/plugins/media/js/media.js 17 May 2009 07:44:27 -0000 +@@ -263,6 +263,13 @@ + + h += ' />'; + ++ var is_youtube = repo_hook(f.src.value); ++ if (is_youtube) { + var re = new RegExp("v\/(.+)\#(.+)", "i"); + var result = f.src.value.match(re); + h = ''+result[2]+''; -+ } -+ - 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'; -- } -+ } else if (v.match(/v\/(.+)(.*)/)) { -+ f.width.value = '425'; -+ f.height.value = '350'; -+ return 'flash'; -+ } - - // 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); ++ } ++ + ed.execCommand('mceInsertContent', false, h); + } + +@@ -310,7 +317,11 @@ + 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'; ++ return 'flash'; ++ } + + // Google video + if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) { +@@ -627,4 +638,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/plugins/media/js/media.js b/lib/editor/tinymce/plugins/media/js/media.js index 86cfa98563..380d073a47 100644 --- a/lib/editor/tinymce/plugins/media/js/media.js +++ b/lib/editor/tinymce/plugins/media/js/media.js @@ -263,6 +263,13 @@ function insertMedia() { h += ' />'; + var is_youtube = repo_hook(f.src.value); + if (is_youtube) { + var re = new RegExp("v\/(.+)\#(.+)", "i"); + var result = f.src.value.match(re); + h = ''+result[2]+''; + } + ed.execCommand('mceInsertContent', false, h); } @@ -310,7 +317,11 @@ function getType(v) { 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'; + return 'flash'; + } // Google video if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) { @@ -627,4 +638,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); diff --git a/lib/editor/tinymce/readme_moodle.txt b/lib/editor/tinymce/readme_moodle.txt index cf24d02b65..ce921aa665 100644 --- a/lib/editor/tinymce/readme_moodle.txt +++ b/lib/editor/tinymce/readme_moodle.txt @@ -8,12 +8,14 @@ Upgrade procedure: 1/ Download latest dev package from http://tinymce.moxiecode.com/download.php 2/ replace tiny_mce*.* files, themes/*, utils/* and plugins/* (keep dragmath, moodlenolink, spellchecker) 3/ copy tinymce/jscripts/tiny_mce/classes/Popup.js to Popup.js - 4/ apply patches - 5/ compress modified js files using yuicompressor.jar from dev package, use shell file extra/tools/compress.sh - 6/ download all TinyMCE lang files and update moodle lang string files + 4/ apply plugins/media/* (extra/tinymce_plugin_media.patch) - MDL-16650 + 5/ apply strings patch + 6/ compress modified js files using yuicompressor.jar from dev package, use shell file extra/tools/compress.sh + 7/ download all TinyMCE lang files and update moodle lang string files + 8/ rebuild string files TODO: - * apply plugins/media/* (extra/tinymce_plugin_media.patch) - MDL-16650 + * lang string handling * customize spellchecker * finish update with info from http://docs.moodle.org/en/Development:TinyMCE_Upgrade -- 2.39.5