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