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) {
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 elm.checked = value.toLowerCase() === 'true' ? true : false;
33 elm.checked = !!value;
43 this.editor = editor = tinyMCEPopup.editor;
45 // Setup file browsers and color pickers
46 get('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media');
47 get('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','quicktime_qtsrc','media','media');
48 get('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
49 get('video_altsource1_filebrowser').innerHTML = getBrowserHTML('filebrowser_altsource1','video_altsource1','media','media');
50 get('video_altsource2_filebrowser').innerHTML = getBrowserHTML('filebrowser_altsource2','video_altsource2','media','media');
51 get('video_poster_filebrowser').innerHTML = getBrowserHTML('filebrowser_poster','video_poster','media','image');
53 html = this.getMediaListHTML('medialist', 'src', 'media', 'media');
55 get("linklistrow").style.display = 'none';
57 get("linklistcontainer").innerHTML = html;
59 if (isVisible('filebrowser'))
60 get('src').style.width = '230px';
62 if (isVisible('filebrowser_altsource1'))
63 get('video_altsource1').style.width = '220px';
65 if (isVisible('filebrowser_altsource2'))
66 get('video_altsource2').style.width = '220px';
68 if (isVisible('filebrowser_poster'))
69 get('video_poster').style.width = '220px';
71 this.data = tinyMCEPopup.getWindowArg('data');
77 var editor = tinyMCEPopup.editor;
80 editor.execCommand('mceRepaint');
81 tinyMCEPopup.restoreSelection();
82 editor.selection.setNode(editor.plugins.media.dataToImg(this.data));
86 preview : function() {
87 get('prev').innerHTML = this.editor.plugins.media.dataToHtml(this.data, true);
90 moveStates : function(to_form, field) {
91 var data = this.data, editor = this.editor, data = this.data,
92 mediaPlugin = editor.plugins.media, ext, src, typeInfo, defaultStates, src;
96 quicktime_autoplay : true,
97 quicktime_controller : true,
105 windowsmedia_autostart : true,
106 windowsmedia_enablecontextmenu : true,
107 windowsmedia_invokeurls : true,
110 realmedia_autogotourl : true,
111 realmedia_imagestatus : true
114 function parseQueryParams(str) {
118 tinymce.each(str.split('&'), function(item) {
119 var parts = item.split('=');
121 out[unescape(parts[0])] = unescape(parts[1]);
128 function setOptions(type, names) {
129 var i, name, formItemName, value, list;
131 if (type == data.type || type == 'global') {
132 names = tinymce.explode(names);
133 for (i = 0; i < names.length; i++) {
135 formItemName = type == 'global' ? name : type + '_' + name;
137 if (type == 'global')
139 else if (type == 'video') {
140 list = data.video.attrs;
142 if (!list && !to_form)
143 data.video.attrs = list = {};
149 setVal(formItemName, list[name]);
153 value = getVal(formItemName);
154 if (type == 'video' && value === true)
157 if (defaultStates[formItemName]) {
158 if (value !== defaultStates[formItemName]) {
173 data.type = get('media_type').options[get('media_type').selectedIndex].value;
174 data.width = getVal('width');
175 data.height = getVal('height');
177 // Switch type based on extension
179 if (field == 'src') {
180 ext = src.replace(/^.*\.([^.]+)$/, '$1');
181 if (typeInfo = mediaPlugin.getType(ext))
182 data.type = typeInfo.name.toLowerCase();
184 setVal('media_type', data.type);
187 if (data.type == "video") {
188 if (!data.video.sources)
189 data.video.sources = [];
191 data.video.sources[0] = {src: getVal('src')};
195 // Hide all fieldsets and show the one active
196 get('video_options').style.display = 'none';
197 get('flash_options').style.display = 'none';
198 get('quicktime_options').style.display = 'none';
199 get('shockwave_options').style.display = 'none';
200 get('windowsmedia_options').style.display = 'none';
201 get('realmedia_options').style.display = 'none';
203 if (get(data.type + '_options'))
204 get(data.type + '_options').style.display = 'block';
206 setVal('media_type', data.type);
208 setOptions('flash', 'play,loop,menu,swliveconnect,quality,scale,salign,wmode,base,flashvars');
209 setOptions('quicktime', 'loop,autoplay,cache,controller,correction,enablejavascript,kioskmode,autohref,playeveryframe,targetcache,scale,starttime,endtime,target,qtsrcchokespeed,volume,qtsrc');
210 setOptions('shockwave', 'sound,progress,autostart,swliveconnect,swvolume,swstretchstyle,swstretchhalign,swstretchvalign');
211 setOptions('windowsmedia', 'autostart,enabled,enablecontextmenu,fullscreen,invokeurls,mute,stretchtofit,windowlessvideo,balance,baseurl,captioningid,currentmarker,currentposition,defaultframe,playcount,rate,uimode,volume');
212 setOptions('realmedia', 'autostart,loop,autogotourl,center,imagestatus,maintainaspect,nojava,prefetch,shuffle,console,controls,numloop,scriptcallbacks');
213 setOptions('video', 'poster,autoplay,loop,preload,controls');
214 setOptions('global', 'id,name,vspace,hspace,bgcolor,align,width,height');
217 if (data.type == 'video') {
218 if (data.video.sources[0])
219 setVal('src', data.video.sources[0].src);
221 src = data.video.sources[1];
223 setVal('video_altsource1', src.src);
225 src = data.video.sources[2];
227 setVal('video_altsource2', src.src);
230 if (data.type == 'flash') {
231 tinymce.each(editor.getParam('flash_video_player_flashvars', {url : '$url', poster : '$poster'}), function(value, name) {
233 data.params.src = parseQueryParams(data.params.flashvars)[name] || data.params.src;
237 setVal('src', data.params.src);
243 if (src.match(/youtube.com(.+)v=([^&]+)/)) {
246 data.params.frameborder = '0';
247 data.type = 'iframe';
248 src = 'http://www.youtube.com/embed/' + src.match(/v=([^&]+)/)[1];
250 setVal('media_type', data.type);
254 if (src.match(/video.google.com(.+)docid=([^&]+)/)) {
258 src = 'http://video.google.com/googleplayer.swf?docId=' + src.match(/docid=([^&]+)/)[1] + '&hl=en';
260 setVal('media_type', data.type);
263 if (data.type == 'video') {
264 if (!data.video.sources)
265 data.video.sources = [];
267 data.video.sources[0] = {src : src};
269 src = getVal("video_altsource1");
271 data.video.sources[1] = {src : src};
273 src = getVal("video_altsource2");
275 data.video.sources[2] = {src : src};
277 data.params.src = src;
280 setVal('width', data.width || 320);
281 setVal('height', data.height || 240);
285 dataToForm : function() {
286 this.moveStates(true);
289 formToData : function(field) {
290 if (field == "width" || field == "height")
291 this.changeSize(field);
293 if (field == 'source') {
294 this.moveStates(false, field);
295 setVal('source', this.editor.plugins.media.dataToHtml(this.data));
296 this.panel = 'source';
298 if (this.panel == 'source') {
299 this.data = this.editor.plugins.media.htmlToData(getVal('source'));
304 this.moveStates(false, field);
309 beforeResize : function() {
310 this.width = parseInt(getVal('width') || "320", 10);
311 this.height = parseInt(getVal('height') || "240", 10);
314 changeSize : function(type) {
315 var width, height, scale, size;
317 if (get('constrain').checked) {
318 width = parseInt(getVal('width') || "320", 10);
319 height = parseInt(getVal('height') || "240", 10);
321 if (type == 'width') {
322 this.height = Math.round((width / this.width) * height);
323 setVal('height', this.height);
325 this.width = Math.round((height / this.height) * width);
326 setVal('width', this.width);
331 getMediaListHTML : function() {
332 if (typeof(tinyMCEMediaList) != "undefined" && tinyMCEMediaList.length > 0) {
335 html += '<select id="linklist" name="linklist" style="width: 250px" onchange="this.form.src.value=this.options[this.selectedIndex].value;Media.formToData(\'src\');">';
336 html += '<option value="">---</option>';
338 for (var i=0; i<tinyMCEMediaList.length; i++)
339 html += '<option value="' + tinyMCEMediaList[i][1] + '">' + tinyMCEMediaList[i][0] + '</option>';
350 tinyMCEPopup.requireLangPack();
351 tinyMCEPopup.onInit.add(function() {