| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 var oldWidth, oldHeight; 2 var url = tinyMCE.getParam("media_external_list_url"); 3 if (url != null) { 4 // Fix relative 5 if (url.charAt(0) != '/' && url.indexOf('://') == -1) 6 url = tinyMCE.documentBasePath + "/" + url; 7 8 document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></sc'+'ript>'); 9 } 10 11 function init() { 12 var pl = "", f, val; 13 var type = "flash", fe, i; 14 15 tinyMCEPopup.resizeToInnerSize(); 16 f = document.forms[0] 17 18 fe = tinyMCE.selectedInstance.getFocusElement(); 19 if (/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(tinyMCE.getAttrib(fe, 'class'))) { 20 pl = "x={" + fe.title + "};"; 21 22 switch (tinyMCE.getAttrib(fe, 'class')) { 23 case 'mceItemFlash': 24 type = 'flash'; 25 break; 26 27 case 'mceItemShockWave': 28 type = 'shockwave'; 29 break; 30 31 case 'mceItemWindowsMedia': 32 type = 'wmp'; 33 break; 34 35 case 'mceItemQuickTime': 36 type = 'qt'; 37 break; 38 39 case 'mceItemRealMedia': 40 type = 'rmp'; 41 break; 42 } 43 44 document.forms[0].insert.value = tinyMCE.getLang('lang_update', 'Insert', true); 45 } 46 47 document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media'); 48 document.getElementById('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','qt_qtsrc','media','media'); 49 document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor'); 50 51 var html = getMediaListHTML('filebrowser','src','media','media'); 52 if (html == "") 53 document.getElementById("linklistrow").style.display = 'none'; 54 else 55 document.getElementById("linklistcontainer").innerHTML = html; 56 57 // Resize some elements 58 if (isVisible('filebrowsercontainer')) 59 document.getElementById('src').style.width = '230px'; 60 61 // Setup form 62 if (pl != "") { 63 pl = eval(pl); 64 65 switch (type) { 66 case "flash": 67 setBool(pl, 'flash', 'play'); 68 setBool(pl, 'flash', 'loop'); 69 setBool(pl, 'flash', 'menu'); 70 setBool(pl, 'flash', 'swliveconnect'); 71 setStr(pl, 'flash', 'quality'); 72 setStr(pl, 'flash', 'scale'); 73 setStr(pl, 'flash', 'salign'); 74 setStr(pl, 'flash', 'wmode'); 75 setStr(pl, 'flash', 'base'); 76 setStr(pl, 'flash', 'flashvars'); 77 break; 78 79 case "qt": 80 setBool(pl, 'qt', 'loop'); 81 setBool(pl, 'qt', 'autoplay'); 82 setBool(pl, 'qt', 'cache'); 83 setBool(pl, 'qt', 'controller'); 84 setBool(pl, 'qt', 'correction'); 85 setBool(pl, 'qt', 'enablejavascript'); 86 setBool(pl, 'qt', 'kioskmode'); 87 setBool(pl, 'qt', 'autohref'); 88 setBool(pl, 'qt', 'playeveryframe'); 89 setBool(pl, 'qt', 'tarsetcache'); 90 setStr(pl, 'qt', 'scale'); 91 setStr(pl, 'qt', 'starttime'); 92 setStr(pl, 'qt', 'endtime'); 93 setStr(pl, 'qt', 'tarset'); 94 setStr(pl, 'qt', 'qtsrcchokespeed'); 95 setStr(pl, 'qt', 'volume'); 96 setStr(pl, 'qt', 'qtsrc'); 97 break; 98 99 case "shockwave": 100 setBool(pl, 'shockwave', 'sound'); 101 setBool(pl, 'shockwave', 'progress'); 102 setBool(pl, 'shockwave', 'autostart'); 103 setBool(pl, 'shockwave', 'swliveconnect'); 104 setStr(pl, 'shockwave', 'swvolume'); 105 setStr(pl, 'shockwave', 'swstretchstyle'); 106 setStr(pl, 'shockwave', 'swstretchhalign'); 107 setStr(pl, 'shockwave', 'swstretchvalign'); 108 break; 109 110 case "wmp": 111 setBool(pl, 'wmp', 'autostart'); 112 setBool(pl, 'wmp', 'enabled'); 113 setBool(pl, 'wmp', 'enablecontextmenu'); 114 setBool(pl, 'wmp', 'fullscreen'); 115 setBool(pl, 'wmp', 'invokeurls'); 116 setBool(pl, 'wmp', 'mute'); 117 setBool(pl, 'wmp', 'stretchtofit'); 118 setBool(pl, 'wmp', 'windowlessvideo'); 119 setStr(pl, 'wmp', 'balance'); 120 setStr(pl, 'wmp', 'baseurl'); 121 setStr(pl, 'wmp', 'captioningid'); 122 setStr(pl, 'wmp', 'currentmarker'); 123 setStr(pl, 'wmp', 'currentposition'); 124 setStr(pl, 'wmp', 'defaultframe'); 125 setStr(pl, 'wmp', 'playcount'); 126 setStr(pl, 'wmp', 'rate'); 127 setStr(pl, 'wmp', 'uimode'); 128 setStr(pl, 'wmp', 'volume'); 129 break; 130 131 case "rmp": 132 setBool(pl, 'rmp', 'autostart'); 133 setBool(pl, 'rmp', 'loop'); 134 setBool(pl, 'rmp', 'autogotourl'); 135 setBool(pl, 'rmp', 'center'); 136 setBool(pl, 'rmp', 'imagestatus'); 137 setBool(pl, 'rmp', 'maintainaspect'); 138 setBool(pl, 'rmp', 'nojava'); 139 setBool(pl, 'rmp', 'prefetch'); 140 setBool(pl, 'rmp', 'shuffle'); 141 setStr(pl, 'rmp', 'console'); 142 setStr(pl, 'rmp', 'controls'); 143 setStr(pl, 'rmp', 'numloop'); 144 setStr(pl, 'rmp', 'scriptcallbacks'); 145 break; 146 } 147 148 setStr(pl, null, 'src'); 149 setStr(pl, null, 'id'); 150 setStr(pl, null, 'name'); 151 setStr(pl, null, 'vspace'); 152 setStr(pl, null, 'hspace'); 153 setStr(pl, null, 'bgcolor'); 154 setStr(pl, null, 'align'); 155 setStr(pl, null, 'width'); 156 setStr(pl, null, 'height'); 157 158 if ((val = tinyMCE.getAttrib(fe, "width")) != "") 159 pl.width = f.width.value = val; 160 161 if ((val = tinyMCE.getAttrib(fe, "height")) != "") 162 pl.height = f.height.value = val; 163 164 oldWidth = pl.width ? parseInt(pl.width) : 0; 165 oldHeight = pl.height ? parseInt(pl.height) : 0; 166 } else 167 oldWidth = oldHeight = 0; 168 169 selectByValue(f, 'media_type', type); 170 changedType(type); 171 updateColor('bgcolor_pick', 'bgcolor'); 172 173 TinyMCE_EditableSelects.init(); 174 generatePreview(); 175 } 176 177 function insertMedia() { 178 var fe, f = document.forms[0], h; 179 180 if (!AutoValidator.validate(f)) { 181 alert(tinyMCE.getLang('lang_invalid_data')); 182 return false; 183 } 184 185 f.width.value = f.width.value == "" ? 100 : f.width.value; 186 f.height.value = f.height.value == "" ? 100 : f.height.value; 187 188 fe = tinyMCE.selectedInstance.getFocusElement(); 189 if (fe != null && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(tinyMCE.getAttrib(fe, 'class'))) { 190 switch (f.media_type.options[f.media_type.selectedIndex].value) { 191 case "flash": 192 fe.className = "mceItemFlash"; 193 break; 194 195 case "shockwave": 196 fe.className = "mceItemShockWave"; 197 break; 198 199 case "qt": 200 fe.className = "mceItemQuickTime"; 201 break; 202 203 case "wmp": 204 fe.className = "mceItemWindowsMedia"; 205 break; 206 207 case "rmp": 208 fe.className = "mceItemRealMedia"; 209 break; 210 } 211 212 if (fe.width != f.width.value || fe.height != f.height.height) 213 tinyMCE.selectedInstance.repaint(); 214 215 fe.title = serializeParameters(); 216 fe.width = f.width.value; 217 fe.height = f.height.value; 218 fe.style.width = f.width.value + (f.width.value.indexOf('%') == -1 ? 'px' : ''); 219 fe.style.height = f.height.value + (f.height.value.indexOf('%') == -1 ? 'px' : ''); 220 fe.align = f.align.options[f.align.selectedIndex].value; 221 } else { 222 h = '<img src="' + tinyMCE.getParam("theme_href") + '/images/spacer.gif"' ; 223 224 switch (f.media_type.options[f.media_type.selectedIndex].value) { 225 case "flash": 226 h += ' class="mceItemFlash"'; 227 break; 228 229 case "shockwave": 230 h += ' class="mceItemShockWave"'; 231 break; 232 233 case "qt": 234 h += ' class="mceItemQuickTime"'; 235 break; 236 237 case "wmp": 238 h += ' class="mceItemWindowsMedia"'; 239 break; 240 241 case "rmp": 242 h += ' class="mceItemRealMedia"'; 243 break; 244 } 245 246 h += ' title="' + serializeParameters() + '"'; 247 h += ' width="' + f.width.value + '"'; 248 h += ' height="' + f.height.value + '"'; 249 h += ' align="' + f.align.options[f.align.selectedIndex].value + '"'; 250 251 h += ' />'; 252 253 tinyMCE.selectedInstance.execCommand('mceInsertContent', false, h); 254 } 255 256 tinyMCEPopup.close(); 257 } 258 259 function getMediaListHTML() { 260 if (typeof(tinyMCEMediaList) != "undefined" && tinyMCEMediaList.length > 0) { 261 var html = ""; 262 263 html += '<select id="linklist" name="linklist" style="width: 250px" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="this.form.src.value=this.options[this.selectedIndex].value;">'; 264 html += '<option value="">---</option>'; 265 266 for (var i=0; i<tinyMCEMediaList.length; i++) 267 html += '<option value="' + tinyMCEMediaList[i][1] + '">' + tinyMCEMediaList[i][0] + '</option>'; 268 269 html += '</select>'; 270 271 return html; 272 } 273 274 return ""; 275 } 276 277 function getType(v) { 278 var fo, i, c, el, x, f = document.forms[0]; 279 280 fo = tinyMCE.getParam("media_types", "flash=swf;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';'); 281 282 // YouTube 283 if (v.indexOf('http://www.youtube.com/watch?v=') == 0) { 284 f.width.value = '425'; 285 f.height.value = '350'; 286 f.src.value = 'http://www.youtube.com/v/' + v.substring('http://www.youtube.com/watch?v='.length); 287 return 'flash'; 288 } 289 290 // Google video 291 if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) { 292 f.width.value = '425'; 293 f.height.value = '326'; 294 f.src.value = 'http://video.google.com/googleplayer.swf?docId=' + v.substring('http://video.google.com/videoplay?docid='.length) + '&hl=en'; 295 return 'flash'; 296 } 297 298 for (i=0; i<fo.length; i++) { 299 c = fo[i].split('='); 300 301 el = c[1].split(','); 302 for (x=0; x<el.length; x++) 303 if (v.indexOf('.' + el[x]) != -1) 304 return c[0]; 305 } 306 307 return null; 308 } 309 310 function switchType(v) { 311 var t = getType(v), d = document, f = d.forms[0]; 312 313 if (!t) 314 return; 315 316 selectByValue(d.forms[0], 'media_type', t); 317 changedType(t); 318 319 // Update qtsrc also 320 if (t == 'qt' && f.src.value.toLowerCase().indexOf('rtsp://') != -1) { 321 alert(tinyMCE.getLang("lang_media_qt_stream_warn")); 322 323 if (f.qt_qtsrc.value == '') 324 f.qt_qtsrc.value = f.src.value; 325 } 326 } 327 328 function changedType(t) { 329 var d = document; 330 331 d.getElementById('flash_options').style.display = 'none'; 332 d.getElementById('qt_options').style.display = 'none'; 333 d.getElementById('shockwave_options').style.display = 'none'; 334 d.getElementById('wmp_options').style.display = 'none'; 335 d.getElementById('rmp_options').style.display = 'none'; 336 d.getElementById(t + '_options').style.display = 'block'; 337 } 338 339 function serializeParameters() { 340 var d = document, f = d.forms[0], s = ''; 341 342 switch (f.media_type.options[f.media_type.selectedIndex].value) { 343 case "flash": 344 s += getBool('flash', 'play', true); 345 s += getBool('flash', 'loop', true); 346 s += getBool('flash', 'menu', true); 347 s += getBool('flash', 'swliveconnect', false); 348 s += getStr('flash', 'quality'); 349 s += getStr('flash', 'scale'); 350 s += getStr('flash', 'salign'); 351 s += getStr('flash', 'wmode'); 352 s += getStr('flash', 'base'); 353 s += getStr('flash', 'flashvars'); 354 break; 355 356 case "qt": 357 s += getBool('qt', 'loop', false); 358 s += getBool('qt', 'autoplay', true); 359 s += getBool('qt', 'cache', false); 360 s += getBool('qt', 'controller', true); 361 s += getBool('qt', 'correction', false, 'none', 'full'); 362 s += getBool('qt', 'enablejavascript', false); 363 s += getBool('qt', 'kioskmode', false); 364 s += getBool('qt', 'autohref', false); 365 s += getBool('qt', 'playeveryframe', false); 366 s += getBool('qt', 'targetcache', false); 367 s += getStr('qt', 'scale'); 368 s += getStr('qt', 'starttime'); 369 s += getStr('qt', 'endtime'); 370 s += getStr('qt', 'target'); 371 s += getStr('qt', 'qtsrcchokespeed'); 372 s += getStr('qt', 'volume'); 373 s += getStr('qt', 'qtsrc'); 374 break; 375 376 case "shockwave": 377 s += getBool('shockwave', 'sound'); 378 s += getBool('shockwave', 'progress'); 379 s += getBool('shockwave', 'autostart'); 380 s += getBool('shockwave', 'swliveconnect'); 381 s += getStr('shockwave', 'swvolume'); 382 s += getStr('shockwave', 'swstretchstyle'); 383 s += getStr('shockwave', 'swstretchhalign'); 384 s += getStr('shockwave', 'swstretchvalign'); 385 break; 386 387 case "wmp": 388 s += getBool('wmp', 'autostart', true); 389 s += getBool('wmp', 'enabled', false); 390 s += getBool('wmp', 'enablecontextmenu', true); 391 s += getBool('wmp', 'fullscreen', false); 392 s += getBool('wmp', 'invokeurls', true); 393 s += getBool('wmp', 'mute', false); 394 s += getBool('wmp', 'stretchtofit', false); 395 s += getBool('wmp', 'windowlessvideo', false); 396 s += getStr('wmp', 'balance'); 397 s += getStr('wmp', 'baseurl'); 398 s += getStr('wmp', 'captioningid'); 399 s += getStr('wmp', 'currentmarker'); 400 s += getStr('wmp', 'currentposition'); 401 s += getStr('wmp', 'defaultframe'); 402 s += getStr('wmp', 'playcount'); 403 s += getStr('wmp', 'rate'); 404 s += getStr('wmp', 'uimode'); 405 s += getStr('wmp', 'volume'); 406 break; 407 408 case "rmp": 409 s += getBool('rmp', 'autostart', false); 410 s += getBool('rmp', 'loop', false); 411 s += getBool('rmp', 'autogotourl', true); 412 s += getBool('rmp', 'center', false); 413 s += getBool('rmp', 'imagestatus', true); 414 s += getBool('rmp', 'maintainaspect', false); 415 s += getBool('rmp', 'nojava', false); 416 s += getBool('rmp', 'prefetch', false); 417 s += getBool('rmp', 'shuffle', false); 418 s += getStr('rmp', 'console'); 419 s += getStr('rmp', 'controls'); 420 s += getStr('rmp', 'numloop'); 421 s += getStr('rmp', 'scriptcallbacks'); 422 break; 423 } 424 425 s += getStr(null, 'id'); 426 s += getStr(null, 'name'); 427 s += getStr(null, 'src'); 428 s += getStr(null, 'align'); 429 s += getStr(null, 'bgcolor'); 430 s += getInt(null, 'vspace'); 431 s += getInt(null, 'hspace'); 432 s += getStr(null, 'width'); 433 s += getStr(null, 'height'); 434 435 s = s.length > 0 ? s.substring(0, s.length - 1) : s; 436 437 return s; 438 } 439 440 function setBool(pl, p, n) { 441 if (typeof(pl[n]) == "undefined") 442 return; 443 444 document.forms[0].elements[p + "_" + n].checked = pl[n]; 445 } 446 447 function setStr(pl, p, n) { 448 var f = document.forms[0], e = f.elements[(p != null ? p + "_" : '') + n]; 449 450 if (typeof(pl[n]) == "undefined") 451 return; 452 453 if (e.type == "text") 454 e.value = pl[n]; 455 else 456 selectByValue(f, (p != null ? p + "_" : '') + n, pl[n]); 457 } 458 459 function getBool(p, n, d, tv, fv) { 460 var v = document.forms[0].elements[p + "_" + n].checked; 461 462 tv = typeof(tv) == 'undefined' ? 'true' : "'" + jsEncode(tv) + "'"; 463 fv = typeof(fv) == 'undefined' ? 'false' : "'" + jsEncode(fv) + "'"; 464 465 return (v == d) ? '' : n + (v ? ':' + tv + ',' : ':' + fv + ','); 466 } 467 468 function getStr(p, n, d) { 469 var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; 470 var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; 471 472 return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',"); 473 } 474 475 function getInt(p, n, d) { 476 var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; 477 var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; 478 479 return ((n == d || v == '') ? '' : n + ":" + v.replace(/[^0-9]+/g, '') + ","); 480 } 481 482 function jsEncode(s) { 483 s = s.replace(new RegExp('\\\\', 'g'), '\\\\'); 484 s = s.replace(new RegExp('"', 'g'), '\\"'); 485 s = s.replace(new RegExp("'", 'g'), "\\'"); 486 487 return s; 488 } 489 490 function generatePreview(c) { 491 var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh; 492 493 p.innerHTML = '<!-- x --->'; 494 495 nw = parseInt(f.width.value); 496 nh = parseInt(f.height.value); 497 498 if (f.width.value != "" && f.height.value != "") { 499 if (f.constrain.checked) { 500 if (c == 'width' && oldWidth != 0) { 501 wp = nw / oldWidth; 502 nh = Math.round(wp * nh); 503 f.height.value = nh; 504 } else if (c == 'height' && oldHeight != 0) { 505 hp = nh / oldHeight; 506 nw = Math.round(hp * nw); 507 f.width.value = nw; 508 } 509 } 510 } 511 512 if (f.width.value != "") 513 oldWidth = nw; 514 515 if (f.height.value != "") 516 oldHeight = nh; 517 518 // After constrain 519 pl = serializeParameters(); 520 521 switch (f.media_type.options[f.media_type.selectedIndex].value) { 522 case "flash": 523 cls = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; 524 codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'; 525 type = 'application/x-shockwave-flash'; 526 break; 527 528 case "shockwave": 529 cls = 'clsid:166B1BCA-3F9C-11CF-8075-444553540000'; 530 codebase = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0'; 531 type = 'application/x-director'; 532 break; 533 534 case "qt": 535 cls = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'; 536 codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0'; 537 type = 'video/quicktime'; 538 break; 539 540 case "wmp": 541 cls = tinyMCE.getParam('media_wmp6_compatible') ? 'clsid:05589FA1-C356-11CE-BF01-00AA0055595A' : 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'; 542 codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; 543 type = 'application/x-mplayer2'; 544 break; 545 546 case "rmp": 547 cls = 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'; 548 codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; 549 type = 'audio/x-pn-realaudio-plugin'; 550 break; 551 } 552 553 if (pl == '') { 554 p.innerHTML = ''; 555 return; 556 } 557 558 pl = eval('x={' + pl + '};'); 559 560 if (!pl.src) { 561 p.innerHTML = ''; 562 return; 563 } 564 565 pl.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], pl.src); 566 pl.width = !pl.width ? 100 : pl.width; 567 pl.height = !pl.height ? 100 : pl.height; 568 pl.id = !pl.id ? 'obj' : pl.id; 569 pl.name = !pl.name ? 'eobj' : pl.name; 570 pl.align = !pl.align ? '' : pl.align; 571 572 h += '<object classid="clsid:' + cls + '" codebase="' + codebase + '" width="' + pl.width + '" height="' + pl.height + '" id="' + pl.id + '" name="' + pl.name + '" align="' + pl.align + '">'; 573 574 for (n in pl) { 575 h += '<param name="' + n + '" value="' + pl[n] + '">'; 576 577 // Add extra url parameter if it's an absolute URL 578 if (n == 'src' && pl[n].indexOf('://') != -1) 579 h += '<param name="url" value="' + pl[n] + '" />'; 580 } 581 582 h += '<embed type="' + type + '" '; 583 584 for (n in pl) 585 h += n + '="' + pl[n] + '" '; 586 587 h += '></embed></object>'; 588 589 p.innerHTML = "<!-- x --->" + h; 590 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Dec 1 03:56:46 2008 | Cross-referenced by PHPXref 0.7 |