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