4 if (url = tinyMCEPopup.getParam("media_external_list_url"))
5 document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
8 return document.getElementById(id);
14 if (elm.nodeName == "SELECT")
15 return elm.options[elm.selectedIndex].value;
17 if (elm.type == "checkbox")
23 function setVal(id, value, name) {
24 if (typeof(value) != 'undefined') {
27 if (elm.nodeName == "SELECT")
28 selectByValue(document.forms[0], id, value);
29 else if (elm.type == "checkbox") {
30 if (typeof(value) == 'string') {
31 value = value.toLowerCase();
32 value = (!name && value === 'true') || (name && value === name.toLowerCase());
34 elm.checked = !!value;
44 this.editor = editor = tinyMCEPopup.editor;
46 // Setup file browsers and color pickers
47 get('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media');
48 get('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','quicktime_qtsrc','media','media');
49 get('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
50 get('video_altsource1_filebrowser').innerHTML = getBrowserHTML('video_filebrowser_altsource1','video_altsource1','media','media');
51 get('video_altsource2_filebrowser').innerHTML = getBrowserHTML('video_filebrowser_altsource2','video_altsource2','media','media');
52 get('audio_altsource1_filebrowser').innerHTML = getBrowserHTML('audio_filebrowser_altsource1','audio_altsource1','media','media');
53 get('audio_altsource2_filebrowser').innerHTML = getBrowserHTML('audio_filebrowser_altsource2','audio_altsource2','media','media');
54 get('video_poster_filebrowser').innerHTML = getBrowserHTML('filebrowser_poster','video_poster','media','image');
56 html = this.getMediaListHTML('medialist', 'src', 'media', 'media');
58 get("linklistrow").style.display = 'none';
60 get("linklistcontainer").innerHTML = html;
62 if (isVisible('filebrowser'))
63 get('src').style.width = '230px';
65 if (isVisible('video_filebrowser_altsource1'))
66 get('video_altsource1').style.width = '220px';
68 if (isVisible('video_filebrowser_altsource2'))
69 get('video_altsource2').style.width = '220px';
71 if (isVisible('audio_filebrowser_altsource1'))
72 get('audio_altsource1').style.width = '220px';
74 if (isVisible('audio_filebrowser_altsource2'))
75 get('audio_altsource2').style.width = '220px';
77 if (isVisible('filebrowser_poster'))
78 get('video_poster').style.width = '220px';
80 this.data = tinyMCEPopup.getWindowArg('data');
86 var editor = tinyMCEPopup.editor;
89 editor.execCommand('mceRepaint');
90 tinyMCEPopup.restoreSelection();
91 editor.selection.setNode(editor.plugins.media.dataToImg(this.data));
95 preview : function() {
96 get('prev').innerHTML = this.editor.plugins.media.dataToHtml(this.data, true);
99 moveStates : function(to_form, field) {
100 var data = this.data, editor = this.editor, data = this.data,
101 mediaPlugin = editor.plugins.media, ext, src, typeInfo, defaultStates, src;
105 quicktime_autoplay : true,
106 quicktime_controller : true,
114 windowsmedia_autostart : true,
115 windowsmedia_enablecontextmenu : true,
116 windowsmedia_invokeurls : true,
119 realmedia_autogotourl : true,
120 realmedia_imagestatus : true
123 function parseQueryParams(str) {
127 tinymce.each(str.split('&'), function(item) {
128 var parts = item.split('=');
130 out[unescape(parts[0])] = unescape(parts[1]);
137 function setOptions(type, names) {
138 var i, name, formItemName, value, list;
140 if (type == data.type || type == 'global') {
141 names = tinymce.explode(names);
142 for (i = 0; i < names.length; i++) {
144 formItemName = type == 'global' ? name : type + '_' + name;
146 if (type == 'global')
148 else if (type == 'video' || type == 'audio') {
149 list = data.video.attrs;
151 if (!list && !to_form)
152 data.video.attrs = list = {};
158 setVal(formItemName, list[name], type == 'video' || type == 'audio' ? name : '');
162 value = getVal(formItemName);
163 if ((type == 'video' || type == 'audio') && value === true)
166 if (defaultStates[formItemName]) {
167 if (value !== defaultStates[formItemName]) {
182 data.type = get('media_type').options[get('media_type').selectedIndex].value;
183 data.width = getVal('width');
184 data.height = getVal('height');
186 // Switch type based on extension
188 if (field == 'src') {
189 ext = src.replace(/^.*\.([^.]+)$/, '$1');
190 if (typeInfo = mediaPlugin.getType(ext))
191 data.type = typeInfo.name.toLowerCase();
193 setVal('media_type', data.type);
196 if (data.type == "video" || data.type == "audio") {
197 if (!data.video.sources)
198 data.video.sources = [];
200 data.video.sources[0] = {src: getVal('src')};
204 // Hide all fieldsets and show the one active
205 get('video_options').style.display = 'none';
206 get('audio_options').style.display = 'none';
207 get('flash_options').style.display = 'none';
208 get('quicktime_options').style.display = 'none';
209 get('shockwave_options').style.display = 'none';
210 get('windowsmedia_options').style.display = 'none';
211 get('realmedia_options').style.display = 'none';
213 if (get(data.type + '_options'))
214 get(data.type + '_options').style.display = 'block';
216 setVal('media_type', data.type);
218 setOptions('flash', 'play,loop,menu,swliveconnect,quality,scale,salign,wmode,base,flashvars');
219 setOptions('quicktime', 'loop,autoplay,cache,controller,correction,enablejavascript,kioskmode,autohref,playeveryframe,targetcache,scale,starttime,endtime,target,qtsrcchokespeed,volume,qtsrc');
220 setOptions('shockwave', 'sound,progress,autostart,swliveconnect,swvolume,swstretchstyle,swstretchhalign,swstretchvalign');
221 setOptions('windowsmedia', 'autostart,enabled,enablecontextmenu,fullscreen,invokeurls,mute,stretchtofit,windowlessvideo,balance,baseurl,captioningid,currentmarker,currentposition,defaultframe,playcount,rate,uimode,volume');
222 setOptions('realmedia', 'autostart,loop,autogotourl,center,imagestatus,maintainaspect,nojava,prefetch,shuffle,console,controls,numloop,scriptcallbacks');
223 setOptions('video', 'poster,autoplay,loop,muted,preload,controls');
224 setOptions('audio', 'autoplay,loop,preload,controls');
225 setOptions('global', 'id,name,vspace,hspace,bgcolor,align,width,height');
228 if (data.type == 'video') {
229 if (data.video.sources[0])
230 setVal('src', data.video.sources[0].src);
232 src = data.video.sources[1];
234 setVal('video_altsource1', src.src);
236 src = data.video.sources[2];
238 setVal('video_altsource2', src.src);
239 } else if (data.type == 'audio') {
240 if (data.video.sources[0])
241 setVal('src', data.video.sources[0].src);
243 src = data.video.sources[1];
245 setVal('audio_altsource1', src.src);
247 src = data.video.sources[2];
249 setVal('audio_altsource2', src.src);
252 if (data.type == 'flash') {
253 tinymce.each(editor.getParam('flash_video_player_flashvars', {url : '$url', poster : '$poster'}), function(value, name) {
255 data.params.src = parseQueryParams(data.params.flashvars)[name] || data.params.src;
259 setVal('src', data.params.src);
265 if (src.match(/youtube.com(.+)v=([^&]+)/)) {
268 data.params.frameborder = '0';
269 data.type = 'iframe';
270 src = 'http://www.youtube.com/embed/' + src.match(/v=([^&]+)/)[1];
272 setVal('media_type', data.type);
276 if (src.match(/video.google.com(.+)docid=([^&]+)/)) {
280 src = 'http://video.google.com/googleplayer.swf?docId=' + src.match(/docid=([^&]+)/)[1] + '&hl=en';
282 setVal('media_type', data.type);
285 if (data.type == 'video') {
286 if (!data.video.sources)
287 data.video.sources = [];
289 data.video.sources[0] = {src : src};
291 src = getVal("video_altsource1");
293 data.video.sources[1] = {src : src};
295 src = getVal("video_altsource2");
297 data.video.sources[2] = {src : src};
298 } else if (data.type == 'audio') {
299 if (!data.video.sources)
300 data.video.sources = [];
302 data.video.sources[0] = {src : src};
304 src = getVal("audio_altsource1");
306 data.video.sources[1] = {src : src};
308 src = getVal("audio_altsource2");
310 data.video.sources[2] = {src : src};
312 data.params.src = src;
315 setVal('width', data.width || (data.type == 'audio' ? 300 : 320));
316 setVal('height', data.height || (data.type == 'audio' ? 32 : 240));
320 dataToForm : function() {
321 this.moveStates(true);
324 formToData : function(field) {
325 if (field == "width" || field == "height")
326 this.changeSize(field);
328 if (field == 'source') {
329 this.moveStates(false, field);
330 setVal('source', this.editor.plugins.media.dataToHtml(this.data));
331 this.panel = 'source';
333 if (this.panel == 'source') {
334 this.data = this.editor.plugins.media.htmlToData(getVal('source'));
339 this.moveStates(false, field);
344 beforeResize : function() {
345 this.width = parseInt(getVal('width') || (this.data.type == 'audio' ? "300" : "320"), 10);
346 this.height = parseInt(getVal('height') || (this.data.type == 'audio' ? "32" : "240"), 10);
349 changeSize : function(type) {
350 var width, height, scale, size;
352 if (get('constrain').checked) {
353 width = parseInt(getVal('width') || (this.data.type == 'audio' ? "300" : "320"), 10);
354 height = parseInt(getVal('height') || (this.data.type == 'audio' ? "32" : "240"), 10);
356 if (type == 'width') {
357 this.height = Math.round((width / this.width) * height);
358 setVal('height', this.height);
360 this.width = Math.round((height / this.height) * width);
361 setVal('width', this.width);
366 getMediaListHTML : function() {
367 if (typeof(tinyMCEMediaList) != "undefined" && tinyMCEMediaList.length > 0) {
370 html += '<select id="linklist" name="linklist" style="width: 250px" onchange="this.form.src.value=this.options[this.selectedIndex].value;Media.formToData(\'src\');">';
371 html += '<option value="">---</option>';
373 for (var i=0; i<tinyMCEMediaList.length; i++)
374 html += '<option value="' + tinyMCEMediaList[i][1] + '">' + tinyMCEMediaList[i][0] + '</option>';
385 tinyMCEPopup.requireLangPack();
386 tinyMCEPopup.onInit.add(function() {