From 94dfd8ab9d61a969453fdd3b9be14b58e1576816 Mon Sep 17 00:00:00 2001 From: alecpl Date: Sun, 27 Mar 2011 15:14:12 +0000 Subject: - TinyMCE 3.4.1 --- program/js/tiny_mce/plugins/media/css/content.css | 6 - program/js/tiny_mce/plugins/media/css/media.css | 9 +- program/js/tiny_mce/plugins/media/editor_plugin.js | 2 +- .../js/tiny_mce/plugins/media/editor_plugin_src.js | 948 ++++++++++++++------- program/js/tiny_mce/plugins/media/img/flash.gif | Bin 241 -> 0 bytes .../js/tiny_mce/plugins/media/img/flv_player.swf | Bin 11668 -> 0 bytes .../js/tiny_mce/plugins/media/img/quicktime.gif | Bin 303 -> 0 bytes .../js/tiny_mce/plugins/media/img/realmedia.gif | Bin 439 -> 0 bytes .../js/tiny_mce/plugins/media/img/shockwave.gif | Bin 387 -> 0 bytes program/js/tiny_mce/plugins/media/img/trans.gif | Bin 43 -> 0 bytes .../js/tiny_mce/plugins/media/img/windowsmedia.gif | Bin 415 -> 0 bytes program/js/tiny_mce/plugins/media/js/media.js | 930 +++++++------------- program/js/tiny_mce/plugins/media/langs/ar_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/az_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/be_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/bg_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/bn_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/br_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/bs_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ca_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/cs_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/cy_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/da_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/de_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/el_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/en_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/es_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/et_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/fa_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/fi_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/fr_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/gl_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/he_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/hi_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/hr_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/hu_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/hy_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ia_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/id_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/is_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/it_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ja_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ka_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ko_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/lt_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/lv_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/mk_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ms_dlg.js | 103 +-- program/js/tiny_mce/plugins/media/langs/nb_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/nl_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/nn_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/no_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/pl_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ps_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/pt_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ro_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ru_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/si_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/sk_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/sl_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/sq_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/sr_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/sv_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/ta_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/te_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/th_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/tr_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/tw_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/uk_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/vi_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/langs/zh_dlg.js | 104 +-- program/js/tiny_mce/plugins/media/media.htm | 571 ++++++------- program/js/tiny_mce/plugins/media/moxieplayer.swf | Bin 0 -> 33931 bytes 73 files changed, 1327 insertions(+), 7274 deletions(-) delete mode 100644 program/js/tiny_mce/plugins/media/css/content.css delete mode 100644 program/js/tiny_mce/plugins/media/img/flash.gif delete mode 100644 program/js/tiny_mce/plugins/media/img/flv_player.swf delete mode 100644 program/js/tiny_mce/plugins/media/img/quicktime.gif delete mode 100644 program/js/tiny_mce/plugins/media/img/realmedia.gif delete mode 100644 program/js/tiny_mce/plugins/media/img/shockwave.gif delete mode 100644 program/js/tiny_mce/plugins/media/img/trans.gif delete mode 100644 program/js/tiny_mce/plugins/media/img/windowsmedia.gif create mode 100644 program/js/tiny_mce/plugins/media/moxieplayer.swf (limited to 'program/js/tiny_mce/plugins/media') diff --git a/program/js/tiny_mce/plugins/media/css/content.css b/program/js/tiny_mce/plugins/media/css/content.css deleted file mode 100644 index 1bf6a7586..000000000 --- a/program/js/tiny_mce/plugins/media/css/content.css +++ /dev/null @@ -1,6 +0,0 @@ -.mceItemFlash, .mceItemShockWave, .mceItemQuickTime, .mceItemWindowsMedia, .mceItemRealMedia {border:1px dotted #cc0000; background-position:center; background-repeat:no-repeat; background-color:#ffffcc;} -.mceItemShockWave {background-image: url(../img/shockwave.gif);} -.mceItemFlash {background-image:url(../img/flash.gif);} -.mceItemQuickTime {background-image:url(../img/quicktime.gif);} -.mceItemWindowsMedia {background-image:url(../img/windowsmedia.gif);} -.mceItemRealMedia {background-image:url(../img/realmedia.gif);} diff --git a/program/js/tiny_mce/plugins/media/css/media.css b/program/js/tiny_mce/plugins/media/css/media.css index 2d087944d..0c45c7ff6 100644 --- a/program/js/tiny_mce/plugins/media/css/media.css +++ b/program/js/tiny_mce/plugins/media/css/media.css @@ -1,12 +1,12 @@ -#id, #name, #hspace, #vspace, #class_name, #align { width: 100px } +#id, #name, #hspace, #vspace, #class_name, #align { width: 100px } #hspace, #vspace { width: 50px } #flash_quality, #flash_align, #flash_scale, #flash_salign, #flash_wmode { width: 100px } -#flash_base, #flash_flashvars { width: 240px } +#flash_base, #flash_flashvars, #html5_altsource1, #html5_altsource2, #html5_poster { width: 240px } #width, #height { width: 40px } #src, #media_type { width: 250px } #class { width: 120px } -#prev { margin: 0; border: 1px solid black; width: 380px; height: 230px; overflow: auto } -.panel_wrapper div.current { height: 390px; overflow: auto } +#prev { margin: 0; border: 1px solid black; width: 380px; height: 260px; overflow: auto } +.panel_wrapper div.current { height: 420px; overflow: auto } #flash_options, #shockwave_options, #qt_options, #wmp_options, #rmp_options { display: none } .mceAddSelectValue { background-color: #DDDDDD } #qt_starttime, #qt_endtime, #qt_fov, #qt_href, #qt_moveid, #qt_moviename, #qt_node, #qt_pan, #qt_qtsrc, #qt_qtsrcchokespeed, #qt_target, #qt_tilt, #qt_urlsubstituten, #qt_volume { width: 70px } @@ -14,3 +14,4 @@ #rmp_console, #rmp_numloop, #rmp_controls, #rmp_scriptcallbacks { width: 70px } #shockwave_swvolume, #shockwave_swframe, #shockwave_swurl, #shockwave_swstretchvalign, #shockwave_swstretchhalign, #shockwave_swstretchstyle { width: 90px } #qt_qtsrc { width: 200px } +iframe {border: 1px solid gray} diff --git a/program/js/tiny_mce/plugins/media/editor_plugin.js b/program/js/tiny_mce/plugins/media/editor_plugin.js index 4bbe367e3..66219078c 100644 --- a/program/js/tiny_mce/plugins/media/editor_plugin.js +++ b/program/js/tiny_mce/plugins/media/editor_plugin.js @@ -1 +1 @@ -(function(){var a=tinymce.each;tinymce.create("tinymce.plugins.MediaPlugin",{init:function(b,c){var e=this;e.editor=b;e.url=c;function f(g){return/^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(g.className)}b.onPreInit.add(function(){b.serializer.addRules("param[name|value|_mce_value]")});b.addCommand("mceMedia",function(){b.windowManager.open({file:c+"/media.htm",width:430+parseInt(b.getLang("media.delta_width",0)),height:470+parseInt(b.getLang("media.delta_height",0)),inline:1},{plugin_url:c})});b.addButton("media",{title:"media.desc",cmd:"mceMedia"});b.onNodeChange.add(function(h,g,i){g.setActive("media",i.nodeName=="IMG"&&f(i))});b.onInit.add(function(){var g={mceItemFlash:"flash",mceItemShockWave:"shockwave",mceItemWindowsMedia:"windowsmedia",mceItemQuickTime:"quicktime",mceItemRealMedia:"realmedia"};b.selection.onSetContent.add(function(){e._spansToImgs(b.getBody())});b.selection.onBeforeSetContent.add(e._objectsToSpans,e);if(b.settings.content_css!==false){b.dom.loadCSS(c+"/css/content.css")}if(b.theme&&b.theme.onResolveName){b.theme.onResolveName.add(function(h,i){if(i.name=="img"){a(g,function(l,j){if(b.dom.hasClass(i.node,j)){i.name=l;i.title=b.dom.getAttrib(i.node,"title");return false}})}})}if(b&&b.plugins.contextmenu){b.plugins.contextmenu.onContextMenu.add(function(i,h,j){if(j.nodeName=="IMG"&&/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(j.className)){h.add({title:"media.edit",icon:"media",cmd:"mceMedia"})}})}});b.onBeforeSetContent.add(e._objectsToSpans,e);b.onSetContent.add(function(){e._spansToImgs(b.getBody())});b.onPreProcess.add(function(g,i){var h=g.dom;if(i.set){e._spansToImgs(i.node);a(h.select("IMG",i.node),function(k){var j;if(f(k)){j=e._parse(k.title);h.setAttrib(k,"width",h.getAttrib(k,"width",j.width||100));h.setAttrib(k,"height",h.getAttrib(k,"height",j.height||100))}})}if(i.get){a(h.select("IMG",i.node),function(m){var l,j,k;if(g.getParam("media_use_script")){if(f(m)){m.className=m.className.replace(/mceItem/g,"mceTemp")}return}switch(m.className){case"mceItemFlash":l="d27cdb6e-ae6d-11cf-96b8-444553540000";j="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0";k="application/x-shockwave-flash";break;case"mceItemShockWave":l="166b1bca-3f9c-11cf-8075-444553540000";j="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0";k="application/x-director";break;case"mceItemWindowsMedia":l=g.getParam("media_wmp6_compatible")?"05589fa1-c356-11ce-bf01-00aa0055595a":"6bf52a52-394a-11d3-b153-00c04f79faa6";j="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701";k="application/x-mplayer2";break;case"mceItemQuickTime":l="02bf25d5-8c17-4b23-bc80-d3488abddc6b";j="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0";k="video/quicktime";break;case"mceItemRealMedia":l="cfcdaa03-8be4-11cf-b84b-0020afbbccfa";j="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0";k="audio/x-pn-realaudio-plugin";break}if(l){h.replace(e._buildObj({classid:l,codebase:j,type:k},m),m)}})}});b.onPostProcess.add(function(g,h){h.content=h.content.replace(/_mce_value=/g,"value=")});function d(g,h){h=new RegExp(h+'="([^"]+)"',"g").exec(g);return h?b.dom.decode(h[1]):""}b.onPostProcess.add(function(g,h){if(g.getParam("media_use_script")){h.content=h.content.replace(/]+>/g,function(j){var i=d(j,"class");if(/^(mceTempFlash|mceTempShockWave|mceTempWindowsMedia|mceTempQuickTime|mceTempRealMedia)$/.test(i)){at=e._parse(d(j,"title"));at.width=d(j,"width");at.height=d(j,"height");j=''; - } + if (!url) + return url; - return im; - }); - } - }); + if (force_absolute) + return editor.documentBaseURI.toAbsolute(url); + + return urlConverter.call(urlConverterScope, url, 'src', 'object'); }, getInfo : function() { @@ -202,210 +220,548 @@ }; }, - // Private methods - _objectsToSpans : function(ed, o) { - var t = this, h = o.content; + /** + * Converts the JSON data object to an img node. + */ + dataToImg : function(data, force_absolute) { + var self = this, editor = self.editor, baseUri = editor.documentBaseURI, sources, attrs, img, i; + + data.params.src = self.convertUrl(data.params.src, force_absolute); - h = h.replace(/]*>\s*write(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)\(\{([^\)]*)\}\);\s*<\/script>/gi, function(a, b, c) { - var o = t._parse(c); + attrs = data.video.attrs; + if (attrs) + attrs.src = self.convertUrl(attrs.src, force_absolute); - return '' + if (attrs) + attrs.poster = self.convertUrl(attrs.poster, force_absolute); + + sources = toArray(data.video.sources); + if (sources) { + for (i = 0; i < sources.length; i++) + sources[i].src = self.convertUrl(sources[i].src, force_absolute); + } + + img = self.editor.dom.create('img', { + id : data.id, + style : data.style, + align : data.align, + src : self.editor.theme.url + '/img/trans.gif', + 'class' : 'mceItemMedia mceItem' + self.getType(data.type).name, + 'data-mce-json' : JSON.serialize(data, "'") }); - h = h.replace(/]*)>/gi, ''); - h = h.replace(/]*)\/?>/gi, ''); - h = h.replace(/]*)>/gi, ''); - h = h.replace(/<\/(object)([^>]*)>/gi, ''); - h = h.replace(/<\/embed>/gi, ''); - h = h.replace(/]*)>/gi, function(a, b) {return ''}); - h = h.replace(/\/ class=\"mceItemParam\"><\/span>/gi, 'class="mceItemParam">'); + img.width = data.width || "320"; + img.height = data.height || "240"; - o.content = h; + return img; }, - _buildObj : function(o, n) { - var ob, ed = this.editor, dom = ed.dom, p = this._parse(n.title), stc; - - stc = ed.getParam('media_strict', true) && o.type == 'application/x-shockwave-flash'; - - p.width = o.width = dom.getAttrib(n, 'width') || 100; - p.height = o.height = dom.getAttrib(n, 'height') || 100; - - if (p.src) - p.src = ed.convertURL(p.src, 'src', n); - - if (stc) { - ob = dom.create('span', { - id : p.id, - _mce_name : 'object', - type : 'application/x-shockwave-flash', - data : p.src, - style : dom.getAttrib(n, 'style'), - width : o.width, - height : o.height - }); - } else { - ob = dom.create('span', { - id : p.id, - _mce_name : 'object', - classid : "clsid:" + o.classid, - style : dom.getAttrib(n, 'style'), - codebase : o.codebase, - width : o.width, - height : o.height + /** + * Converts the JSON data object to a HTML string. + */ + dataToHtml : function(data, force_absolute) { + return this.editor.serializer.serialize(this.dataToImg(data, force_absolute), {force_absolute : force_absolute}); + }, + + /** + * Converts the JSON data object to a HTML string. + */ + htmlToData : function(html) { + var fragment, img, data; + + data = { + type : 'flash', + video: {sources:[]}, + params: {} + }; + + fragment = this.editor.parser.parse(html); + img = fragment.getAll('img')[0]; + + if (img) { + data = JSON.parse(img.attr('data-mce-json')); + data.type = this.getType(img.attr('class')).name.toLowerCase(); + + // Add some extra properties to the data object + tinymce.each(rootAttributes, function(name) { + var value = img.attr(name); + + if (value) + data[name] = value; }); } - each (p, function(v, k) { - if (!/^(width|height|codebase|classid|id|_cx|_cy)$/.test(k)) { - // Use url instead of src in IE for Windows media - if (o.type == 'application/x-mplayer2' && k == 'src' && !p.url) - k = 'url'; + return data; + }, + + /** + * Get type item by extension, class, clsid or mime type. + * + * @method getType + * @param {String} value Value to get type item by. + * @return {Object} Type item object or undefined. + */ + getType : function(value) { + var i, values, typeItem; + + // Find type by checking the classes + values = tinymce.explode(value, ' '); + for (i = 0; i < values.length; i++) { + typeItem = this.lookup[values[i]]; + + if (typeItem) + return typeItem; + } + }, + + /** + * Converts a tinymce.html.Node image element to video/object/embed. + */ + imgToObject : function(node, args) { + var self = this, editor = self.editor, video, object, embed, iframe, name, value, data, + source, sources, params, param, typeItem, i, item, mp4Source, replacement, + posterSrc, style; + + // Adds the flash player + function addPlayer(video_src, poster_src) { + var baseUri, flashVars, flashVarsOutput, params, flashPlayer; + + flashPlayer = editor.getParam('flash_video_player_url', self.convertUrl(self.url + '/moxieplayer.swf')); + if (flashPlayer) { + baseUri = editor.documentBaseURI; + data.params.src = flashPlayer; + + // Convert the movie url to absolute urls + if (editor.getParam('flash_video_player_absvideourl', true)) { + video_src = baseUri.toAbsolute(video_src || '', true); + poster_src = baseUri.toAbsolute(poster_src || '', true); + } + + // Generate flash vars + flashVarsOutput = ''; + flashVars = editor.getParam('flash_video_player_flashvars', {url : '$url', poster : '$poster'}); + tinymce.each(flashVars, function(value, name) { + // Replace $url and $poster variables in flashvars value + value = value.replace(/\$url/, video_src || ''); + value = value.replace(/\$poster/, poster_src || ''); + + if (value.length > 0) + flashVarsOutput += (flashVarsOutput ? '&' : '') + name + '=' + escape(value); + }); + + if (flashVarsOutput.length) + data.params.flashvars = flashVarsOutput; - if (v) - dom.add(ob, 'span', {_mce_name : 'param', name : k, '_mce_value' : v}); + params = editor.getParam('flash_video_player_params', { + allowfullscreen: true, + allowscriptaccess: true + }); + + tinymce.each(params, function(value, name) { + data.params[name] = "" + value; + }); } - }); + }; - if (!stc) - dom.add(ob, 'span', tinymce.extend({_mce_name : 'embed', type : o.type, style : dom.getAttrib(n, 'style')}, p)); + data = JSON.parse(node.attr('data-mce-json')); + typeItem = this.getType(node.attr('class')); - return ob; - }, + style = node.attr('data-mce-style') + if (!style) { + style = node.attr('style'); - _spansToImgs : function(p) { - var t = this, dom = t.editor.dom, im, ci; + if (style) + style = editor.dom.serializeStyle(editor.dom.parseStyle(style, 'img')); + } - each(dom.select('span', p), function(n) { - // Convert object into image - if (dom.getAttrib(n, 'class') == 'mceItemObject') { - ci = dom.getAttrib(n, "classid").toLowerCase().replace(/\s+/g, ''); + // Handle iframe + if (typeItem.name === 'Iframe') { + replacement = new Node('iframe', 1); - switch (ci) { - case 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000': - dom.replace(t._createImg('mceItemFlash', n), n); - break; + tinymce.each(rootAttributes, function(name) { + var value = node.attr(name); - case 'clsid:166b1bca-3f9c-11cf-8075-444553540000': - dom.replace(t._createImg('mceItemShockWave', n), n); - break; + if (name == 'class' && value) + value = value.replace(/mceItem.+ ?/g, ''); - case 'clsid:6bf52a52-394a-11d3-b153-00c04f79faa6': - case 'clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95': - case 'clsid:05589fa1-c356-11ce-bf01-00aa0055595a': - dom.replace(t._createImg('mceItemWindowsMedia', n), n); - break; + if (value && value.length > 0) + replacement.attr(name, value); + }); - case 'clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b': - dom.replace(t._createImg('mceItemQuickTime', n), n); - break; + for (name in data.params) + replacement.attr(name, data.params[name]); - case 'clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa': - dom.replace(t._createImg('mceItemRealMedia', n), n); - break; + replacement.attr({ + style: style, + src: data.params.src + }); - default: - dom.replace(t._createImg('mceItemFlash', n), n); - } - - return; + node.replace(replacement); + + return; + } + + // Handle scripts + if (this.editor.settings.media_use_script) { + replacement = new Node('script', 1).attr('type', 'text/javascript'); + + value = new Node('#text', 3); + value.value = 'write' + typeItem.name + '(' + JSON.serialize(tinymce.extend(data.params, { + width: node.attr('width'), + height: node.attr('height') + })) + ');'; + + replacement.append(value); + node.replace(replacement); + + return; + } + + // Add HTML5 video element + if (typeItem.name === 'Video' && data.video.sources[0]) { + // Create new object element + video = new Node('video', 1).attr(tinymce.extend({ + id : node.attr('id'), + width: node.attr('width'), + height: node.attr('height'), + style : style + }, data.video.attrs)); + + // Get poster source and use that for flash fallback + if (data.video.attrs) + posterSrc = data.video.attrs.poster; + + sources = data.video.sources = toArray(data.video.sources); + for (i = 0; i < sources.length; i++) { + if (/\.mp4$/.test(sources[i].src)) + mp4Source = sources[i].src; } - // Convert embed into image - if (dom.getAttrib(n, 'class') == 'mceItemEmbed') { - switch (dom.getAttrib(n, 'type')) { - case 'application/x-shockwave-flash': - dom.replace(t._createImg('mceItemFlash', n), n); - break; + if (!sources[0].type) { + video.attr('src', sources[0].src); + sources.splice(0, 1); + } - case 'application/x-director': - dom.replace(t._createImg('mceItemShockWave', n), n); - break; + for (i = 0; i < sources.length; i++) { + source = new Node('source', 1).attr(sources[i]); + source.shortEnded = true; + video.append(source); + } - case 'application/x-mplayer2': - dom.replace(t._createImg('mceItemWindowsMedia', n), n); - break; + // Create flash fallback for video if we have a mp4 source + if (mp4Source) { + addPlayer(mp4Source, posterSrc); + typeItem = self.getType('flash'); + } else + data.params.src = ''; + } - case 'video/quicktime': - dom.replace(t._createImg('mceItemQuickTime', n), n); - break; + // Do we have a params src then we can generate object + if (data.params.src) { + // Is flv movie add player for it + if (/\.flv$/i.test(data.params.src)) + addPlayer(data.params.src, ''); + + if (args && args.force_absolute) + data.params.src = editor.documentBaseURI.toAbsolute(data.params.src); + + // Create new object element + object = new Node('object', 1).attr({ + id : node.attr('id'), + width: node.attr('width'), + height: node.attr('height'), + style : style + }); - case 'audio/x-pn-realaudio-plugin': - dom.replace(t._createImg('mceItemRealMedia', n), n); - break; + tinymce.each(rootAttributes, function(name) { + if (data[name] && name != 'type') + object.attr(name, data[name]); + }); - default: - dom.replace(t._createImg('mceItemFlash', n), n); - } - } - }); + // Add params + for (name in data.params) { + param = new Node('param', 1); + param.shortEnded = true; + value = data.params[name]; + + // Windows media needs to use url instead of src for the media URL + if (name === 'src' && typeItem.name === 'WindowsMedia') + name = 'url'; + + param.attr({name: name, value: value}); + object.append(param); + } + + // Setup add type and classid if strict is disabled + if (this.editor.getParam('media_strict', true)) { + object.attr({ + data: data.params.src, + type: typeItem.mimes[0] + }); + } else { + object.attr({ + classid: "clsid:" + typeItem.clsids[0], + codebase: typeItem.codebase + }); + + embed = new Node('embed', 1); + embed.shortEnded = true; + embed.attr({ + id: node.attr('id'), + width: node.attr('width'), + height: node.attr('height'), + style : style, + type: typeItem.mimes[0] + }); + + for (name in data.params) + embed.attr(name, data.params[name]); + + tinymce.each(rootAttributes, function(name) { + if (data[name] && name != 'type') + embed.attr(name, data[name]); + }); + + object.append(embed); + } + + // Insert raw HTML + if (data.object_html) { + value = new Node('#text', 3); + value.raw = true; + value.value = data.object_html; + object.append(value); + } + + // Append object to video element if it exists + if (video) + video.append(object); + } + + if (video) { + // Insert raw HTML + if (data.video_html) { + value = new Node('#text', 3); + value.raw = true; + value.value = data.video_html; + video.append(value); + } + } + + if (video || object) + node.replace(video || object); + else + node.remove(); }, - _createImg : function(cl, n) { - var im, dom = this.editor.dom, pa = {}, ti = '', args; + /** + * Converts a tinymce.html.Node video/object/embed to an img element. + * + * The video/object/embed will be converted into an image placeholder with a JSON data attribute like this: + * + * + * The JSON structure will be like this: + * {'params':{'flashvars':'something','quality':'high','src':'someurl'}, 'video':{'sources':[{src: 'someurl', type: 'video/mp4'}]}} + */ + objectToImg : function(node) { + var object, embed, video, iframe, img, name, id, width, height, style, i, html, + param, params, source, sources, data, type, lookup = this.lookup, + matches, attrs, urlConverter = this.editor.settings.url_converter, + urlConverterScope = this.editor.settings.url_converter_scope; + + function getInnerHTML(node) { + return new tinymce.html.Serializer({ + inner: true, + validate: false + }).serialize(node); + }; - args = ['id', 'name', 'width', 'height', 'bgcolor', 'align', 'flashvars', 'src', 'wmode', 'allowfullscreen', 'quality', 'data']; + // If node isn't in document + if (!node.parent) + return; - // Create image - im = dom.create('img', { - src : this.url + '/img/trans.gif', - width : dom.getAttrib(n, 'width') || 100, - height : dom.getAttrib(n, 'height') || 100, - style : dom.getAttrib(n, 'style'), - 'class' : cl - }); + // Handle media scripts + if (node.name === 'script') { + if (node.firstChild) + matches = scriptRegExp.exec(node.firstChild.value); - // Setup base parameters - each(args, function(na) { - var v = dom.getAttrib(n, na); + if (!matches) + return; - if (v) - pa[na] = v; - }); + type = matches[1]; + data = {video : {}, params : JSON.parse(matches[2])}; + width = data.params.width; + height = data.params.height; + } + + // Setup data objects + data = data || { + video : {}, + params : {} + }; - // Add optional parameters - each(dom.select('span', n), function(n) { - if (dom.hasClass(n, 'mceItemParam')) - pa[dom.getAttrib(n, 'name')] = dom.getAttrib(n, '_mce_value'); + // Setup new image object + img = new Node('img', 1); + img.attr({ + src : this.editor.theme.url + '/img/trans.gif' }); - // Use src not movie - if (pa.movie) { - pa.src = pa.movie; - delete pa.movie; + // Video element + name = node.name; + if (name === 'video') { + video = node; + object = node.getAll('object')[0]; + embed = node.getAll('embed')[0]; + width = video.attr('width'); + height = video.attr('height'); + id = video.attr('id'); + data.video = {attrs : {}, sources : []}; + + // Get all video attributes + attrs = data.video.attrs; + for (name in video.attributes.map) + attrs[name] = video.attributes.map[name]; + + source = node.attr('src'); + if (source) + data.video.sources.push({src : urlConverter.call(urlConverterScope, source, 'src', 'video')}); + + // Get all sources + sources = video.getAll("source"); + for (i = 0; i < sources.length; i++) { + source = sources[i].remove(); + + data.video.sources.push({ + src: urlConverter.call(urlConverterScope, source.attr('src'), 'src', 'source'), + type: source.attr('type'), + media: source.attr('media') + }); + } + + // Convert the poster URL + if (attrs.poster) + attrs.poster = urlConverter.call(urlConverterScope, attrs.poster, 'poster', 'video'); + } + + // Object element + if (node.name === 'object') { + object = node; + embed = node.getAll('embed')[0]; + } + + // Embed element + if (node.name === 'embed') + embed = node; + + // Iframe element + if (node.name === 'iframe') { + iframe = node; + type = 'Iframe'; + } + + if (object) { + // Get width/height + width = width || object.attr('width'); + height = height || object.attr('height'); + style = style || object.attr('style'); + id = id || object.attr('id'); + + // Get all object params + params = object.getAll("param"); + for (i = 0; i < params.length; i++) { + param = params[i]; + name = param.remove().attr('name'); + + if (!excludedAttrs[name]) + data.params[name] = param.attr('value'); + } + + data.params.src = data.params.src || object.attr('data'); } - // No src try data - if (!pa.src) { - pa.src = pa.data; - delete pa.data; + if (embed) { + // Get width/height + width = width || embed.attr('width'); + height = height || embed.attr('height'); + style = style || embed.attr('style'); + id = id || embed.attr('id'); + + // Get all embed attributes + for (name in embed.attributes.map) { + if (!excludedAttrs[name] && !data.params[name]) + data.params[name] = embed.attributes.map[name]; + } } - // Merge with embed args - n = dom.select('.mceItemEmbed', n)[0]; - if (n) { - each(args, function(na) { - var v = dom.getAttrib(n, na); + if (iframe) { + // Get width/height + width = iframe.attr('width'); + height = iframe.attr('height'); + style = style || iframe.attr('style'); + id = iframe.attr('id'); - if (v && !pa[na]) - pa[na] = v; + tinymce.each(rootAttributes, function(name) { + img.attr(name, iframe.attr(name)); }); + + // Get all iframe attributes + for (name in iframe.attributes.map) { + if (!excludedAttrs[name] && !data.params[name]) + data.params[name] = iframe.attributes.map[name]; + } } - delete pa.width; - delete pa.height; + // Use src not movie + if (data.params.movie) { + data.params.src = data.params.src || data.params.movie; + delete data.params.movie; + } - im.title = this._serialize(pa); + // Convert the URL to relative/absolute depending on configuration + if (data.params.src) + data.params.src = urlConverter.call(urlConverterScope, data.params.src, 'src', 'object'); - return im; - }, + if (video) + type = lookup.video.name; - _parse : function(s) { - return tinymce.util.JSON.parse('{' + s + '}'); - }, + if (object && !type) + type = (lookup[(object.attr('clsid') || '').toLowerCase()] || lookup[(object.attr('type') || '').toLowerCase()] || {}).name; - _serialize : function(o) { - return tinymce.util.JSON.serialize(o).replace(/[{}]/g, ''); + if (embed && !type) + type = (lookup[(embed.attr('type') || '').toLowerCase()] || {}).name; + + // Replace the video/object/embed element with a placeholder image containing the data + node.replace(img); + + // Remove embed + if (embed) + embed.remove(); + + // Serialize the inner HTML of the object element + if (object) { + html = getInnerHTML(object.remove()); + + if (html) + data.object_html = html; + } + + // Serialize the inner HTML of the video element + if (video) { + html = getInnerHTML(video.remove()); + + if (html) + data.video_html = html; + } + + // Set width/height of placeholder + img.attr({ + id : id, + 'class' : 'mceItemMedia mceItem' + (type || 'Flash'), + style : style, + width : width || "320", + height : height || "240", + "data-mce-json" : JSON.serialize(data, "'") + }); } }); diff --git a/program/js/tiny_mce/plugins/media/img/flash.gif b/program/js/tiny_mce/plugins/media/img/flash.gif deleted file mode 100644 index cb192e6ce..000000000 Binary files a/program/js/tiny_mce/plugins/media/img/flash.gif and /dev/null differ diff --git a/program/js/tiny_mce/plugins/media/img/flv_player.swf b/program/js/tiny_mce/plugins/media/img/flv_player.swf deleted file mode 100644 index 042c2ab96..000000000 Binary files a/program/js/tiny_mce/plugins/media/img/flv_player.swf and /dev/null differ diff --git a/program/js/tiny_mce/plugins/media/img/quicktime.gif b/program/js/tiny_mce/plugins/media/img/quicktime.gif deleted file mode 100644 index 3b0499145..000000000 Binary files a/program/js/tiny_mce/plugins/media/img/quicktime.gif and /dev/null differ diff --git a/program/js/tiny_mce/plugins/media/img/realmedia.gif b/program/js/tiny_mce/plugins/media/img/realmedia.gif deleted file mode 100644 index fdfe0b9ac..000000000 Binary files a/program/js/tiny_mce/plugins/media/img/realmedia.gif and /dev/null differ diff --git a/program/js/tiny_mce/plugins/media/img/shockwave.gif b/program/js/tiny_mce/plugins/media/img/shockwave.gif deleted file mode 100644 index 5f235dfc7..000000000 Binary files a/program/js/tiny_mce/plugins/media/img/shockwave.gif and /dev/null differ diff --git a/program/js/tiny_mce/plugins/media/img/trans.gif b/program/js/tiny_mce/plugins/media/img/trans.gif deleted file mode 100644 index 388486517..000000000 Binary files a/program/js/tiny_mce/plugins/media/img/trans.gif and /dev/null differ diff --git a/program/js/tiny_mce/plugins/media/img/windowsmedia.gif b/program/js/tiny_mce/plugins/media/img/windowsmedia.gif deleted file mode 100644 index ab50f2d88..000000000 Binary files a/program/js/tiny_mce/plugins/media/img/windowsmedia.gif and /dev/null differ diff --git a/program/js/tiny_mce/plugins/media/js/media.js b/program/js/tiny_mce/plugins/media/js/media.js index 86cfa9856..30ad65617 100644 --- a/program/js/tiny_mce/plugins/media/js/media.js +++ b/program/js/tiny_mce/plugins/media/js/media.js @@ -1,630 +1,354 @@ -tinyMCEPopup.requireLangPack(); +(function() { + var url; -var oldWidth, oldHeight, ed, url; + if (url = tinyMCEPopup.getParam("media_external_list_url")) + document.write(''); -if (url = tinyMCEPopup.getParam("media_external_list_url")) - document.write(''); - -function init() { - var pl = "", f, val; - var type = "flash", fe, i; - - ed = tinyMCEPopup.editor; - - tinyMCEPopup.resizeToInnerSize(); - f = document.forms[0] - - fe = ed.selection.getNode(); - if (/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) { - pl = fe.title; - - switch (ed.dom.getAttrib(fe, 'class')) { - case 'mceItemFlash': - type = 'flash'; - break; - - case 'mceItemFlashVideo': - type = 'flv'; - break; - - case 'mceItemShockWave': - type = 'shockwave'; - break; - - case 'mceItemWindowsMedia': - type = 'wmp'; - break; - - case 'mceItemQuickTime': - type = 'qt'; - break; - - case 'mceItemRealMedia': - type = 'rmp'; - break; - } - - document.forms[0].insert.value = ed.getLang('update', 'Insert', true); + function get(id) { + return document.getElementById(id); } - document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media'); - document.getElementById('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','qt_qtsrc','media','media'); - document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor'); - - var html = getMediaListHTML('medialist','src','media','media'); - if (html == "") - document.getElementById("linklistrow").style.display = 'none'; - else - document.getElementById("linklistcontainer").innerHTML = html; - - // Resize some elements - if (isVisible('filebrowser')) - document.getElementById('src').style.width = '230px'; - - // Setup form - if (pl != "") { - pl = tinyMCEPopup.editor.plugins.media._parse(pl); - - switch (type) { - case "flash": - setBool(pl, 'flash', 'play'); - setBool(pl, 'flash', 'loop'); - setBool(pl, 'flash', 'menu'); - setBool(pl, 'flash', 'swliveconnect'); - setStr(pl, 'flash', 'quality'); - setStr(pl, 'flash', 'scale'); - setStr(pl, 'flash', 'salign'); - setStr(pl, 'flash', 'wmode'); - setStr(pl, 'flash', 'base'); - setStr(pl, 'flash', 'flashvars'); - break; - - case "qt": - setBool(pl, 'qt', 'loop'); - setBool(pl, 'qt', 'autoplay'); - setBool(pl, 'qt', 'cache'); - setBool(pl, 'qt', 'controller'); - setBool(pl, 'qt', 'correction'); - setBool(pl, 'qt', 'enablejavascript'); - setBool(pl, 'qt', 'kioskmode'); - setBool(pl, 'qt', 'autohref'); - setBool(pl, 'qt', 'playeveryframe'); - setBool(pl, 'qt', 'tarsetcache'); - setStr(pl, 'qt', 'scale'); - setStr(pl, 'qt', 'starttime'); - setStr(pl, 'qt', 'endtime'); - setStr(pl, 'qt', 'tarset'); - setStr(pl, 'qt', 'qtsrcchokespeed'); - setStr(pl, 'qt', 'volume'); - setStr(pl, 'qt', 'qtsrc'); - break; - - case "shockwave": - setBool(pl, 'shockwave', 'sound'); - setBool(pl, 'shockwave', 'progress'); - setBool(pl, 'shockwave', 'autostart'); - setBool(pl, 'shockwave', 'swliveconnect'); - setStr(pl, 'shockwave', 'swvolume'); - setStr(pl, 'shockwave', 'swstretchstyle'); - setStr(pl, 'shockwave', 'swstretchhalign'); - setStr(pl, 'shockwave', 'swstretchvalign'); - break; - - case "wmp": - setBool(pl, 'wmp', 'autostart'); - setBool(pl, 'wmp', 'enabled'); - setBool(pl, 'wmp', 'enablecontextmenu'); - setBool(pl, 'wmp', 'fullscreen'); - setBool(pl, 'wmp', 'invokeurls'); - setBool(pl, 'wmp', 'mute'); - setBool(pl, 'wmp', 'stretchtofit'); - setBool(pl, 'wmp', 'windowlessvideo'); - setStr(pl, 'wmp', 'balance'); - setStr(pl, 'wmp', 'baseurl'); - setStr(pl, 'wmp', 'captioningid'); - setStr(pl, 'wmp', 'currentmarker'); - setStr(pl, 'wmp', 'currentposition'); - setStr(pl, 'wmp', 'defaultframe'); - setStr(pl, 'wmp', 'playcount'); - setStr(pl, 'wmp', 'rate'); - setStr(pl, 'wmp', 'uimode'); - setStr(pl, 'wmp', 'volume'); - break; - - case "rmp": - setBool(pl, 'rmp', 'autostart'); - setBool(pl, 'rmp', 'loop'); - setBool(pl, 'rmp', 'autogotourl'); - setBool(pl, 'rmp', 'center'); - setBool(pl, 'rmp', 'imagestatus'); - setBool(pl, 'rmp', 'maintainaspect'); - setBool(pl, 'rmp', 'nojava'); - setBool(pl, 'rmp', 'prefetch'); - setBool(pl, 'rmp', 'shuffle'); - setStr(pl, 'rmp', 'console'); - setStr(pl, 'rmp', 'controls'); - setStr(pl, 'rmp', 'numloop'); - setStr(pl, 'rmp', 'scriptcallbacks'); - break; - } - - setStr(pl, null, 'src'); - setStr(pl, null, 'id'); - setStr(pl, null, 'name'); - setStr(pl, null, 'vspace'); - setStr(pl, null, 'hspace'); - setStr(pl, null, 'bgcolor'); - setStr(pl, null, 'align'); - setStr(pl, null, 'width'); - setStr(pl, null, 'height'); - - if ((val = ed.dom.getAttrib(fe, "width")) != "") - pl.width = f.width.value = val; - - if ((val = ed.dom.getAttrib(fe, "height")) != "") - pl.height = f.height.value = val; - - oldWidth = pl.width ? parseInt(pl.width) : 0; - oldHeight = pl.height ? parseInt(pl.height) : 0; - } else - oldWidth = oldHeight = 0; - - selectByValue(f, 'media_type', type); - changedType(type); - updateColor('bgcolor_pick', 'bgcolor'); + function getVal(id) { + var elm = get(id); - TinyMCE_EditableSelects.init(); - generatePreview(); -} + if (elm.nodeName == "SELECT") + return elm.options[elm.selectedIndex].value; -function insertMedia() { - var fe, f = document.forms[0], h; + if (elm.type == "checkbox") + return elm.checked; - tinyMCEPopup.restoreSelection(); - - if (!AutoValidator.validate(f)) { - tinyMCEPopup.alert(ed.getLang('invalid_data')); - return false; + return elm.value; } - f.width.value = f.width.value == "" ? 100 : f.width.value; - f.height.value = f.height.value == "" ? 100 : f.height.value; - - fe = ed.selection.getNode(); - if (fe != null && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) { - switch (f.media_type.options[f.media_type.selectedIndex].value) { - case "flash": - fe.className = "mceItemFlash"; - break; - - case "flv": - fe.className = "mceItemFlashVideo"; - break; - - case "shockwave": - fe.className = "mceItemShockWave"; - break; - - case "qt": - fe.className = "mceItemQuickTime"; - break; - - case "wmp": - fe.className = "mceItemWindowsMedia"; - break; - - case "rmp": - fe.className = "mceItemRealMedia"; - break; - } - - if (fe.width != f.width.value || fe.height != f.height.value) - ed.execCommand('mceRepaint'); - - fe.title = serializeParameters(); - fe.width = f.width.value; - fe.height = f.height.value; - fe.style.width = f.width.value + (f.width.value.indexOf('%') == -1 ? 'px' : ''); - fe.style.height = f.height.value + (f.height.value.indexOf('%') == -1 ? 'px' : ''); - fe.align = f.align.options[f.align.selectedIndex].value; - } else { - h = ' 0) { - var html = ""; - - html += ''; - - return html; - } - - return ""; -} - -function getType(v) { - var fo, i, c, el, x, f = document.forms[0]; - - 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=(.+)(.*)/)) { - f.width.value = '425'; - f.height.value = '350'; - f.src.value = 'http://www.youtube.com/v/' + v.match(/v=(.*)(.*)/)[0].split('=')[1]; - return 'flash'; - } - - // Google video - if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) { - f.width.value = '425'; - f.height.value = '326'; - f.src.value = 'http://video.google.com/googleplayer.swf?docId=' + v.substring('http://video.google.com/videoplay?docid='.length) + '&hl=en'; - return 'flash'; - } - - for (i=0; i 0 ? s.substring(0, s.length - 1) : s; - - return s; -} - -function setBool(pl, p, n) { - if (typeof(pl[n]) == "undefined") - return; - - document.forms[0].elements[p + "_" + n].checked = pl[n] != 'false'; -} - -function setStr(pl, p, n) { - var f = document.forms[0], e = f.elements[(p != null ? p + "_" : '') + n]; - - if (typeof(pl[n]) == "undefined") - return; - - if (e.type == "text") - e.value = pl[n]; - else - selectByValue(f, (p != null ? p + "_" : '') + n, pl[n]); -} - -function getBool(p, n, d, tv, fv) { - var v = document.forms[0].elements[p + "_" + n].checked; - - tv = typeof(tv) == 'undefined' ? 'true' : "'" + jsEncode(tv) + "'"; - fv = typeof(fv) == 'undefined' ? 'false' : "'" + jsEncode(fv) + "'"; - - return (v == d) ? '' : n + (v ? ':' + tv + ',' : ":\'" + fv + "\',"); -} - -function getStr(p, n, d) { - var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; - var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; - - if (n == 'src') - v = tinyMCEPopup.editor.convertURL(v, 'src', null); - - return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',"); -} - -function getInt(p, n, d) { - var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; - var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; - - return ((n == d || v == '') ? '' : n + ":" + v.replace(/[^0-9]+/g, '') + ","); -} - -function jsEncode(s) { - s = s.replace(new RegExp('\\\\', 'g'), '\\\\'); - s = s.replace(new RegExp('"', 'g'), '\\"'); - s = s.replace(new RegExp("'", 'g'), "\\'"); + window.Media = { + init : function() { + var html, editor; + + this.editor = editor = tinyMCEPopup.editor; + + // Setup file browsers and color pickers + get('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media'); + get('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','quicktime_qtsrc','media','media'); + get('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor'); + get('video_altsource1_filebrowser').innerHTML = getBrowserHTML('filebrowser_altsource1','video_altsource1','media','media'); + get('video_altsource2_filebrowser').innerHTML = getBrowserHTML('filebrowser_altsource2','video_altsource2','media','media'); + get('video_poster_filebrowser').innerHTML = getBrowserHTML('filebrowser_poster','video_poster','media','image'); + + html = this.getMediaListHTML('medialist', 'src', 'media', 'media'); + if (html == "") + get("linklistrow").style.display = 'none'; + else + get("linklistcontainer").innerHTML = html; + + if (isVisible('filebrowser')) + get('src').style.width = '230px'; + + if (isVisible('filebrowser_altsource1')) + get('video_altsource1').style.width = '220px'; + + if (isVisible('filebrowser_altsource2')) + get('video_altsource2').style.width = '220px'; + + if (isVisible('filebrowser_poster')) + get('video_poster').style.width = '220px'; + + this.data = tinyMCEPopup.getWindowArg('data'); + this.dataToForm(); + this.preview(); + }, + + insert : function() { + var editor = tinyMCEPopup.editor; + + this.formToData(); + editor.execCommand('mceRepaint'); + tinyMCEPopup.restoreSelection(); + editor.selection.setNode(editor.plugins.media.dataToImg(this.data)); + tinyMCEPopup.close(); + }, + + preview : function() { + get('prev').innerHTML = this.editor.plugins.media.dataToHtml(this.data, true); + }, + + moveStates : function(to_form, field) { + var data = this.data, editor = this.editor, data = this.data, + mediaPlugin = editor.plugins.media, ext, src, typeInfo, defaultStates, src; + + defaultStates = { + // QuickTime + quicktime_autoplay : true, + quicktime_controller : true, + + // Flash + flash_play : true, + flash_loop : true, + flash_menu : true, + + // WindowsMedia + windowsmedia_autostart : true, + windowsmedia_enablecontextmenu : true, + windowsmedia_invokeurls : true, + + // RealMedia + realmedia_autogotourl : true, + realmedia_imagestatus : true + }; + + function parseQueryParams(str) { + var out = {}; + + if (str) { + tinymce.each(str.split('&'), function(item) { + var parts = item.split('='); + + out[unescape(parts[0])] = unescape(parts[1]); + }); + } + + return out; + }; + + function setOptions(type, names) { + var i, name, formItemName, value, list; + + if (type == data.type || type == 'global') { + names = tinymce.explode(names); + for (i = 0; i < names.length; i++) { + name = names[i]; + formItemName = type == 'global' ? name : type + '_' + name; + + if (type == 'global') + list = data; + else if (type == 'video') { + list = data.video.attrs; + + if (!list && !to_form) + data.video.attrs = list = {}; + } else + list = data.params; + + if (list) { + if (to_form) { + setVal(formItemName, list[name]); + } else { + delete list[name]; + + value = getVal(formItemName); + if (type == 'video' && value === true) + value = name; + + if (defaultStates[formItemName]) { + if (value !== defaultStates[formItemName]) { + value = "" + value; + list[name] = value; + } + } else if (value) { + value = "" + value; + list[name] = value; + } + } + } + } + } + } - return s; -} + if (!to_form) { + data.type = get('media_type').options[get('media_type').selectedIndex].value; + data.width = getVal('width'); + data.height = getVal('height'); -function generatePreview(c) { - var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh; + // Switch type based on extension + src = getVal('src'); + if (field == 'src') { + ext = src.replace(/^.*\.([^.]+)$/, '$1'); + if (typeInfo = mediaPlugin.getType(ext)) + data.type = typeInfo.name.toLowerCase(); - p.innerHTML = ''; + setVal('media_type', data.type); + } - nw = parseInt(f.width.value); - nh = parseInt(f.height.value); + if (data.type == "video") { + if (!data.video.sources) + data.video.sources = []; - if (f.width.value != "" && f.height.value != "") { - if (f.constrain.checked) { - if (c == 'width' && oldWidth != 0) { - wp = nw / oldWidth; - nh = Math.round(wp * nh); - f.height.value = nh; - } else if (c == 'height' && oldHeight != 0) { - hp = nh / oldHeight; - nw = Math.round(hp * nw); - f.width.value = nw; + data.video.sources[0] = {src: getVal('src')}; + } } - } - } - if (f.width.value != "") - oldWidth = nw; - - if (f.height.value != "") - oldHeight = nh; - - // After constrain - pl = serializeParameters(); - - switch (f.media_type.options[f.media_type.selectedIndex].value) { - case "flash": - cls = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; - codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'; - type = 'application/x-shockwave-flash'; - break; - - case "shockwave": - cls = 'clsid:166B1BCA-3F9C-11CF-8075-444553540000'; - codebase = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0'; - type = 'application/x-director'; - break; - - case "qt": - cls = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'; - codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0'; - type = 'video/quicktime'; - break; - - case "wmp": - cls = ed.getParam('media_wmp6_compatible') ? 'clsid:05589FA1-C356-11CE-BF01-00AA0055595A' : 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'; - codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; - type = 'application/x-mplayer2'; - break; - - case "rmp": - cls = 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'; - codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; - type = 'audio/x-pn-realaudio-plugin'; - break; - } - - if (pl == '') { - p.innerHTML = ''; - return; - } + // Hide all fieldsets and show the one active + get('video_options').style.display = 'none'; + get('flash_options').style.display = 'none'; + get('quicktime_options').style.display = 'none'; + get('shockwave_options').style.display = 'none'; + get('windowsmedia_options').style.display = 'none'; + get('realmedia_options').style.display = 'none'; + + if (get(data.type + '_options')) + get(data.type + '_options').style.display = 'block'; + + setVal('media_type', data.type); + + setOptions('flash', 'play,loop,menu,swliveconnect,quality,scale,salign,wmode,base,flashvars'); + setOptions('quicktime', 'loop,autoplay,cache,controller,correction,enablejavascript,kioskmode,autohref,playeveryframe,targetcache,scale,starttime,endtime,target,qtsrcchokespeed,volume,qtsrc'); + setOptions('shockwave', 'sound,progress,autostart,swliveconnect,swvolume,swstretchstyle,swstretchhalign,swstretchvalign'); + setOptions('windowsmedia', 'autostart,enabled,enablecontextmenu,fullscreen,invokeurls,mute,stretchtofit,windowlessvideo,balance,baseurl,captioningid,currentmarker,currentposition,defaultframe,playcount,rate,uimode,volume'); + setOptions('realmedia', 'autostart,loop,autogotourl,center,imagestatus,maintainaspect,nojava,prefetch,shuffle,console,controls,numloop,scriptcallbacks'); + setOptions('video', 'poster,autoplay,loop,preload,controls'); + setOptions('global', 'id,name,vspace,hspace,bgcolor,align,width,height'); + + if (to_form) { + if (data.type == 'video') { + if (data.video.sources[0]) + setVal('src', data.video.sources[0].src); + + src = data.video.sources[1]; + if (src) + setVal('video_altsource1', src.src); + + src = data.video.sources[2]; + if (src) + setVal('video_altsource2', src.src); + } else { + // Check flash vars + if (data.type == 'flash') { + tinymce.each(editor.getParam('flash_video_player_flashvars', {url : '$url', poster : '$poster'}), function(value, name) { + if (value == '$url') + data.params.src = parseQueryParams(data.params.flashvars)[name] || data.params.src; + }); + } + + setVal('src', data.params.src); + } + } else { + src = getVal("src"); + + // YouTube + if (src.match(/youtube.com(.+)v=([^&]+)/)) { + data.width = 425; + data.height = 350; + data.params.frameborder = '0'; + data.type = 'iframe'; + src = 'http://www.youtube.com/embed/' + src.match(/v=([^&]+)/)[1]; + setVal('src', src); + setVal('media_type', data.type); + } + + // Google video + if (src.match(/video.google.com(.+)docid=([^&]+)/)) { + data.width = 425; + data.height = 326; + data.type = 'flash'; + src = 'http://video.google.com/googleplayer.swf?docId=' + src.match(/docid=([^&]+)/)[1] + '&hl=en'; + setVal('src', src); + setVal('media_type', data.type); + } + + if (data.type == 'video') { + if (!data.video.sources) + data.video.sources = []; + + data.video.sources[0] = {src : src}; + + src = getVal("video_altsource1"); + if (src) + data.video.sources[1] = {src : src}; + + src = getVal("video_altsource2"); + if (src) + data.video.sources[2] = {src : src}; + } else + data.params.src = src; + + // Set default size + setVal('width', data.width || 320); + setVal('height', data.height || 240); + } + }, + + dataToForm : function() { + this.moveStates(true); + }, + + formToData : function(field) { + if (field == "width" || field == "height") + this.changeSize(field); + + if (field == 'source') { + this.moveStates(false, field); + setVal('source', this.editor.plugins.media.dataToHtml(this.data)); + this.panel = 'source'; + } else { + if (this.panel == 'source') { + this.data = this.editor.plugins.media.htmlToData(getVal('source')); + this.dataToForm(); + this.panel = ''; + } + + this.moveStates(false, field); + this.preview(); + } + }, + + beforeResize : function() { + this.width = parseInt(getVal('width') || "320", 10); + this.height = parseInt(getVal('height') || "240", 10); + }, + + changeSize : function(type) { + var width, height, scale, size; + + if (get('constrain').checked) { + width = parseInt(getVal('width') || "320", 10); + height = parseInt(getVal('height') || "240", 10); + + if (type == 'width') { + this.height = Math.round((width / this.width) * height); + setVal('height', this.height); + } else { + this.width = Math.round((height / this.height) * width); + setVal('width', this.width); + } + } + }, - pl = tinyMCEPopup.editor.plugins.media._parse(pl); + getMediaListHTML : function() { + if (typeof(tinyMCEMediaList) != "undefined" && tinyMCEMediaList.length > 0) { + var html = ""; - if (!pl.src) { - p.innerHTML = ''; - return; - } + html += ''; - for (n in pl) { - h += ''; + return html; + } - // Add extra url parameter if it's an absolute URL - if (n == 'src' && pl[n].indexOf('://') != -1) - h += ''; + return ""; } - } - - h += ' - -
-
+ + + @@ -24,28 +25,29 @@
{#media_dlg.general} - +
-
- + - - + - - + + +
- - - + @@ -56,10 +58,10 @@
+ + + - +
 
- +
- - + +
x    x   
@@ -78,18 +80,18 @@
{#media_dlg.advanced} - +
- + - + - + - + + +
- @@ -100,9 +102,9 @@ - +
- +
 
@@ -111,9 +113,91 @@
+
+ +
+ {#media_dlg.html5_video_options} + + + + + + + + + + + + + + + + +
+ + + + + +
 
+
+ + + + + +
 
+
+ + + + + +
 
+
+ + + + + + + + + +
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
@@ -121,11 +205,11 @@
{#media_dlg.flash_options} - +
- @@ -137,7 +221,7 @@ - @@ -150,7 +234,7 @@
- @@ -160,7 +244,7 @@ - @@ -176,18 +260,18 @@
- +
- +
- +
- +
@@ -196,18 +280,18 @@
- +
- +
- +
- +
@@ -215,134 +299,38 @@
- +
- + - - -
-
- -
- {#media_dlg.flv_options} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
- -
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
-
+
{#media_dlg.qt_options} - +
@@ -350,19 +338,19 @@ @@ -370,19 +358,19 @@ @@ -390,19 +378,19 @@ @@ -410,27 +398,27 @@ - - + - - + + - - + + - - + + - - + + - - + + - - + + - +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- - - - - -
 
+ + + + + +
 
-
+
{#media_dlg.wmp_options} - +
@@ -504,19 +492,19 @@ @@ -524,19 +512,19 @@ @@ -544,86 +532,86 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
-
+
{#media_dlg.rmp_options} - +
@@ -631,19 +619,19 @@ @@ -651,19 +639,19 @@ @@ -671,19 +659,19 @@ @@ -691,10 +679,10 @@ @@ -705,19 +693,19 @@ - - + + - - + + - - + + - - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
- +
- - + +
@@ -725,11 +713,11 @@
{#media_dlg.shockwave_options} - +
- +
- @@ -738,13 +726,13 @@
- @@ -754,7 +742,7 @@ - @@ -765,18 +753,18 @@
- +
- +
- +
- +
@@ -786,18 +774,18 @@
- +
- +
- +
- +
@@ -806,6 +794,13 @@
+ +
+
+ {#media_dlg.source} + +
+
diff --git a/program/js/tiny_mce/plugins/media/moxieplayer.swf b/program/js/tiny_mce/plugins/media/moxieplayer.swf new file mode 100644 index 000000000..2a040358d Binary files /dev/null and b/program/js/tiny_mce/plugins/media/moxieplayer.swf differ -- cgit v1.2.3