1 tinyMCEPopup.requireLangPack();
3 var oldWidth, oldHeight, ed, url;
5 if (url = tinyMCEPopup.getParam("media_external_list_url"))
6 document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
10 var type = "flash", fe, i;
12 ed = tinyMCEPopup.editor;
14 tinyMCEPopup.resizeToInnerSize();
17 fe = ed.selection.getNode();
18 if (/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) {
21 switch (ed.dom.getAttrib(fe, 'class')) {
26 case 'mceItemFlashVideo':
30 case 'mceItemShockWave':
34 case 'mceItemWindowsMedia':
38 case 'mceItemQuickTime':
42 case 'mceItemRealMedia':
47 document.forms[0].insert.value = ed.getLang('update', 'Insert', true);
50 document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media');
51 document.getElementById('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','qt_qtsrc','media','media');
52 document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
54 var html = getMediaListHTML('medialist','src','media','media');
56 document.getElementById("linklistrow").style.display = 'none';
58 document.getElementById("linklistcontainer").innerHTML = html;
60 // Resize some elements
61 if (isVisible('filebrowser'))
62 document.getElementById('src').style.width = '230px';
66 pl = tinyMCEPopup.editor.plugins.media._parse(pl);
70 setBool(pl, 'flash', 'play');
71 setBool(pl, 'flash', 'loop');
72 setBool(pl, 'flash', 'menu');
73 setBool(pl, 'flash', 'swliveconnect');
74 setStr(pl, 'flash', 'quality');
75 setStr(pl, 'flash', 'scale');
76 setStr(pl, 'flash', 'salign');
77 setStr(pl, 'flash', 'wmode');
78 setStr(pl, 'flash', 'base');
79 setStr(pl, 'flash', 'flashvars');
83 setBool(pl, 'qt', 'loop');
84 setBool(pl, 'qt', 'autoplay');
85 setBool(pl, 'qt', 'cache');
86 setBool(pl, 'qt', 'controller');
87 setBool(pl, 'qt', 'correction');
88 setBool(pl, 'qt', 'enablejavascript');
89 setBool(pl, 'qt', 'kioskmode');
90 setBool(pl, 'qt', 'autohref');
91 setBool(pl, 'qt', 'playeveryframe');
92 setBool(pl, 'qt', 'tarsetcache');
93 setStr(pl, 'qt', 'scale');
94 setStr(pl, 'qt', 'starttime');
95 setStr(pl, 'qt', 'endtime');
96 setStr(pl, 'qt', 'tarset');
97 setStr(pl, 'qt', 'qtsrcchokespeed');
98 setStr(pl, 'qt', 'volume');
99 setStr(pl, 'qt', 'qtsrc');
103 setBool(pl, 'shockwave', 'sound');
104 setBool(pl, 'shockwave', 'progress');
105 setBool(pl, 'shockwave', 'autostart');
106 setBool(pl, 'shockwave', 'swliveconnect');
107 setStr(pl, 'shockwave', 'swvolume');
108 setStr(pl, 'shockwave', 'swstretchstyle');
109 setStr(pl, 'shockwave', 'swstretchhalign');
110 setStr(pl, 'shockwave', 'swstretchvalign');
114 setBool(pl, 'wmp', 'autostart');
115 setBool(pl, 'wmp', 'enabled');
116 setBool(pl, 'wmp', 'enablecontextmenu');
117 setBool(pl, 'wmp', 'fullscreen');
118 setBool(pl, 'wmp', 'invokeurls');
119 setBool(pl, 'wmp', 'mute');
120 setBool(pl, 'wmp', 'stretchtofit');
121 setBool(pl, 'wmp', 'windowlessvideo');
122 setStr(pl, 'wmp', 'balance');
123 setStr(pl, 'wmp', 'baseurl');
124 setStr(pl, 'wmp', 'captioningid');
125 setStr(pl, 'wmp', 'currentmarker');
126 setStr(pl, 'wmp', 'currentposition');
127 setStr(pl, 'wmp', 'defaultframe');
128 setStr(pl, 'wmp', 'playcount');
129 setStr(pl, 'wmp', 'rate');
130 setStr(pl, 'wmp', 'uimode');
131 setStr(pl, 'wmp', 'volume');
135 setBool(pl, 'rmp', 'autostart');
136 setBool(pl, 'rmp', 'loop');
137 setBool(pl, 'rmp', 'autogotourl');
138 setBool(pl, 'rmp', 'center');
139 setBool(pl, 'rmp', 'imagestatus');
140 setBool(pl, 'rmp', 'maintainaspect');
141 setBool(pl, 'rmp', 'nojava');
142 setBool(pl, 'rmp', 'prefetch');
143 setBool(pl, 'rmp', 'shuffle');
144 setStr(pl, 'rmp', 'console');
145 setStr(pl, 'rmp', 'controls');
146 setStr(pl, 'rmp', 'numloop');
147 setStr(pl, 'rmp', 'scriptcallbacks');
151 setStr(pl, null, 'src');
152 setStr(pl, null, 'id');
153 setStr(pl, null, 'name');
154 setStr(pl, null, 'vspace');
155 setStr(pl, null, 'hspace');
156 setStr(pl, null, 'bgcolor');
157 setStr(pl, null, 'align');
158 setStr(pl, null, 'width');
159 setStr(pl, null, 'height');
161 if ((val = ed.dom.getAttrib(fe, "width")) != "")
162 pl.width = f.width.value = val;
164 if ((val = ed.dom.getAttrib(fe, "height")) != "")
165 pl.height = f.height.value = val;
167 oldWidth = pl.width ? parseInt(pl.width) : 0;
168 oldHeight = pl.height ? parseInt(pl.height) : 0;
170 oldWidth = oldHeight = 0;
172 selectByValue(f, 'media_type', type);
174 updateColor('bgcolor_pick', 'bgcolor');
176 TinyMCE_EditableSelects.init();
180 function insertMedia() {
181 var fe, f = document.forms[0], h;
183 tinyMCEPopup.restoreSelection();
185 if (!AutoValidator.validate(f)) {
186 alert(ed.getLang('invalid_data'));
190 f.width.value = f.width.value == "" ? 100 : f.width.value;
191 f.height.value = f.height.value == "" ? 100 : f.height.value;
193 fe = ed.selection.getNode();
194 if (fe != null && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) {
195 switch (f.media_type.options[f.media_type.selectedIndex].value) {
197 fe.className = "mceItemFlash";
201 fe.className = "mceItemFlashVideo";
205 fe.className = "mceItemShockWave";
209 fe.className = "mceItemQuickTime";
213 fe.className = "mceItemWindowsMedia";
217 fe.className = "mceItemRealMedia";
221 if (fe.width != f.width.value || fe.height != f.height.height)
222 ed.execCommand('mceRepaint');
224 fe.title = serializeParameters();
225 fe.width = f.width.value;
226 fe.height = f.height.value;
227 fe.style.width = f.width.value + (f.width.value.indexOf('%') == -1 ? 'px' : '');
228 fe.style.height = f.height.value + (f.height.value.indexOf('%') == -1 ? 'px' : '');
229 fe.align = f.align.options[f.align.selectedIndex].value;
231 h = '<img src="' + tinyMCEPopup.getWindowArg("plugin_url") + '/img/trans.gif"' ;
233 switch (f.media_type.options[f.media_type.selectedIndex].value) {
235 h += ' class="mceItemFlash"';
239 h += ' class="mceItemFlashVideo"';
243 h += ' class="mceItemShockWave"';
247 h += ' class="mceItemQuickTime"';
251 h += ' class="mceItemWindowsMedia"';
255 h += ' class="mceItemRealMedia"';
259 h += ' title="' + serializeParameters() + '"';
260 h += ' width="' + f.width.value + '"';
261 h += ' height="' + f.height.value + '"';
262 h += ' align="' + f.align.options[f.align.selectedIndex].value + '"';
266 ed.execCommand('mceInsertContent', false, h);
269 tinyMCEPopup.close();
272 function updatePreview() {
273 var f = document.forms[0], type;
275 f.width.value = f.width.value || '320';
276 f.height.value = f.height.value || '240';
278 type = getType(f.src.value);
279 selectByValue(f, 'media_type', type);
284 function getMediaListHTML() {
285 if (typeof(tinyMCEMediaList) != "undefined" && tinyMCEMediaList.length > 0) {
288 html += '<select id="linklist" name="linklist" style="width: 250px" onchange="this.form.src.value=this.options[this.selectedIndex].value;updatePreview();">';
289 html += '<option value="">---</option>';
291 for (var i=0; i<tinyMCEMediaList.length; i++)
292 html += '<option value="' + tinyMCEMediaList[i][1] + '">' + tinyMCEMediaList[i][0] + '</option>';
302 function getType(v) {
303 var fo, i, c, el, x, f = document.forms[0];
305 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(';');
308 if (v.match(/watch\?v=(.+)(.*)/)) {
309 f.width.value = '425';
310 f.height.value = '350';
311 f.src.value = 'http://www.youtube.com/v/' + v.match(/v=(.*)(.*)/)[0].split('=')[1];
316 if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) {
317 f.width.value = '425';
318 f.height.value = '326';
319 f.src.value = 'http://video.google.com/googleplayer.swf?docId=' + v.substring('http://video.google.com/videoplay?docid='.length) + '&hl=en';
323 for (i=0; i<fo.length; i++) {
324 c = fo[i].split('=');
326 el = c[1].split(',');
327 for (x=0; x<el.length; x++)
328 if (v.indexOf('.' + el[x]) != -1)
335 function switchType(v) {
336 var t = getType(v), d = document, f = d.forms[0];
341 selectByValue(d.forms[0], 'media_type', t);
345 if (t == 'qt' && f.src.value.toLowerCase().indexOf('rtsp://') != -1) {
346 alert(ed.getLang("media_qt_stream_warn"));
348 if (f.qt_qtsrc.value == '')
349 f.qt_qtsrc.value = f.src.value;
353 function changedType(t) {
356 d.getElementById('flash_options').style.display = 'none';
357 d.getElementById('flv_options').style.display = 'none';
358 d.getElementById('qt_options').style.display = 'none';
359 d.getElementById('shockwave_options').style.display = 'none';
360 d.getElementById('wmp_options').style.display = 'none';
361 d.getElementById('rmp_options').style.display = 'none';
362 d.getElementById(t + '_options').style.display = 'block';
365 function serializeParameters() {
366 var d = document, f = d.forms[0], s = '';
368 switch (f.media_type.options[f.media_type.selectedIndex].value) {
370 s += getBool('flash', 'play', true);
371 s += getBool('flash', 'loop', true);
372 s += getBool('flash', 'menu', true);
373 s += getBool('flash', 'swliveconnect', false);
374 s += getStr('flash', 'quality');
375 s += getStr('flash', 'scale');
376 s += getStr('flash', 'salign');
377 s += getStr('flash', 'wmode');
378 s += getStr('flash', 'base');
379 s += getStr('flash', 'flashvars');
383 s += getBool('qt', 'loop', false);
384 s += getBool('qt', 'autoplay', true);
385 s += getBool('qt', 'cache', false);
386 s += getBool('qt', 'controller', true);
387 s += getBool('qt', 'correction', false, 'none', 'full');
388 s += getBool('qt', 'enablejavascript', false);
389 s += getBool('qt', 'kioskmode', false);
390 s += getBool('qt', 'autohref', false);
391 s += getBool('qt', 'playeveryframe', false);
392 s += getBool('qt', 'targetcache', false);
393 s += getStr('qt', 'scale');
394 s += getStr('qt', 'starttime');
395 s += getStr('qt', 'endtime');
396 s += getStr('qt', 'target');
397 s += getStr('qt', 'qtsrcchokespeed');
398 s += getStr('qt', 'volume');
399 s += getStr('qt', 'qtsrc');
403 s += getBool('shockwave', 'sound');
404 s += getBool('shockwave', 'progress');
405 s += getBool('shockwave', 'autostart');
406 s += getBool('shockwave', 'swliveconnect');
407 s += getStr('shockwave', 'swvolume');
408 s += getStr('shockwave', 'swstretchstyle');
409 s += getStr('shockwave', 'swstretchhalign');
410 s += getStr('shockwave', 'swstretchvalign');
414 s += getBool('wmp', 'autostart', true);
415 s += getBool('wmp', 'enabled', false);
416 s += getBool('wmp', 'enablecontextmenu', true);
417 s += getBool('wmp', 'fullscreen', false);
418 s += getBool('wmp', 'invokeurls', true);
419 s += getBool('wmp', 'mute', false);
420 s += getBool('wmp', 'stretchtofit', false);
421 s += getBool('wmp', 'windowlessvideo', false);
422 s += getStr('wmp', 'balance');
423 s += getStr('wmp', 'baseurl');
424 s += getStr('wmp', 'captioningid');
425 s += getStr('wmp', 'currentmarker');
426 s += getStr('wmp', 'currentposition');
427 s += getStr('wmp', 'defaultframe');
428 s += getStr('wmp', 'playcount');
429 s += getStr('wmp', 'rate');
430 s += getStr('wmp', 'uimode');
431 s += getStr('wmp', 'volume');
435 s += getBool('rmp', 'autostart', false);
436 s += getBool('rmp', 'loop', false);
437 s += getBool('rmp', 'autogotourl', true);
438 s += getBool('rmp', 'center', false);
439 s += getBool('rmp', 'imagestatus', true);
440 s += getBool('rmp', 'maintainaspect', false);
441 s += getBool('rmp', 'nojava', false);
442 s += getBool('rmp', 'prefetch', false);
443 s += getBool('rmp', 'shuffle', false);
444 s += getStr('rmp', 'console');
445 s += getStr('rmp', 'controls');
446 s += getStr('rmp', 'numloop');
447 s += getStr('rmp', 'scriptcallbacks');
451 s += getStr(null, 'id');
452 s += getStr(null, 'name');
453 s += getStr(null, 'src');
454 s += getStr(null, 'align');
455 s += getStr(null, 'bgcolor');
456 s += getInt(null, 'vspace');
457 s += getInt(null, 'hspace');
458 s += getStr(null, 'width');
459 s += getStr(null, 'height');
461 s = s.length > 0 ? s.substring(0, s.length - 1) : s;
466 function setBool(pl, p, n) {
467 if (typeof(pl[n]) == "undefined")
470 document.forms[0].elements[p + "_" + n].checked = pl[n];
473 function setStr(pl, p, n) {
474 var f = document.forms[0], e = f.elements[(p != null ? p + "_" : '') + n];
476 if (typeof(pl[n]) == "undefined")
479 if (e.type == "text")
482 selectByValue(f, (p != null ? p + "_" : '') + n, pl[n]);
485 function getBool(p, n, d, tv, fv) {
486 var v = document.forms[0].elements[p + "_" + n].checked;
488 tv = typeof(tv) == 'undefined' ? 'true' : "'" + jsEncode(tv) + "'";
489 fv = typeof(fv) == 'undefined' ? 'false' : "'" + jsEncode(fv) + "'";
491 return (v == d) ? '' : n + (v ? ':' + tv + ',' : ':' + fv + ',');
494 function getStr(p, n, d) {
495 var e = document.forms[0].elements[(p != null ? p + "_" : "") + n];
496 var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value;
499 v = tinyMCEPopup.editor.convertURL(v, 'src', null);
501 return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',");
504 function getInt(p, n, d) {
505 var e = document.forms[0].elements[(p != null ? p + "_" : "") + n];
506 var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value;
508 return ((n == d || v == '') ? '' : n + ":" + v.replace(/[^0-9]+/g, '') + ",");
511 function jsEncode(s) {
512 s = s.replace(new RegExp('\\\\', 'g'), '\\\\');
513 s = s.replace(new RegExp('"', 'g'), '\\"');
514 s = s.replace(new RegExp("'", 'g'), "\\'");
519 function generatePreview(c) {
520 var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh;
522 p.innerHTML = '<!-- x --->';
524 nw = parseInt(f.width.value);
525 nh = parseInt(f.height.value);
527 if (f.width.value != "" && f.height.value != "") {
528 if (f.constrain.checked) {
529 if (c == 'width' && oldWidth != 0) {
531 nh = Math.round(wp * nh);
533 } else if (c == 'height' && oldHeight != 0) {
535 nw = Math.round(hp * nw);
541 if (f.width.value != "")
544 if (f.height.value != "")
548 pl = serializeParameters();
550 switch (f.media_type.options[f.media_type.selectedIndex].value) {
552 cls = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
553 codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';
554 type = 'application/x-shockwave-flash';
558 cls = 'clsid:166B1BCA-3F9C-11CF-8075-444553540000';
559 codebase = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0';
560 type = 'application/x-director';
564 cls = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';
565 codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';
566 type = 'video/quicktime';
570 cls = ed.getParam('media_wmp6_compatible') ? 'clsid:05589FA1-C356-11CE-BF01-00AA0055595A' : 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6';
571 codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';
572 type = 'application/x-mplayer2';
576 cls = 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA';
577 codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';
578 type = 'audio/x-pn-realaudio-plugin';
587 pl = tinyMCEPopup.editor.plugins.media._parse(pl);
594 pl.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(pl.src);
595 pl.width = !pl.width ? 100 : pl.width;
596 pl.height = !pl.height ? 100 : pl.height;
597 pl.id = !pl.id ? 'obj' : pl.id;
598 pl.name = !pl.name ? 'eobj' : pl.name;
599 pl.align = !pl.align ? '' : pl.align;
601 h += '<object classid="clsid:' + cls + '" codebase="' + codebase + '" width="' + pl.width + '" height="' + pl.height + '" id="' + pl.id + '" name="' + pl.name + '" align="' + pl.align + '">';
604 h += '<param name="' + n + '" value="' + pl[n] + '">';
606 // Add extra url parameter if it's an absolute URL
607 if (n == 'src' && pl[n].indexOf('://') != -1)
608 h += '<param name="url" value="' + pl[n] + '" />';
611 h += '<embed type="' + type + '" ';
614 h += n + '="' + pl[n] + '" ';
616 h += '></embed></object>';
618 p.innerHTML = "<!-- x --->" + h;
621 tinyMCEPopup.onInit.add(init);