/** * $Id: editor_plugin_src.js 275 2007-05-01 15:35:08Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('media'); var TinyMCE_MediaPlugin = { getInfo : function() { return { longname : 'Media', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, initInstance : function(inst) { // Warn if user has flash plugin and media plugin at the same time if (inst.hasPlugin('flash') && !tinyMCE.flashWarn) { alert('Flash plugin is deprecated and should not be used together with the media plugin.'); tinyMCE.flashWarn = true; } if (!tinyMCE.settings['media_skip_plugin_css']) tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/media/css/content.css"); }, getControlHTML : function(cn) { switch (cn) { case "media": return tinyMCE.getButtonHTML(cn, 'lang_media_desc', '{$pluginurl}/images/media.gif', 'mceMedia'); } return ""; }, execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mceMedia": tinyMCE.openWindow({ file : '../../plugins/media/media.htm', width : 430 + tinyMCE.getLang('lang_media_delta_width', 0), height : 470 + tinyMCE.getLang('lang_media_delta_height', 0) }, { editor_id : editor_id, inline : "yes" }); return true; } // Pass to next handler in chain return false; }, cleanup : function(type, content, inst) { var nl, img, i, ne, d, s, ci; switch (type) { case "insert_to_editor": img = tinyMCE.getParam("theme_href") + '/images/spacer.gif'; content = content.replace(/]*>\s*write(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)\(\{([^\)]*)\}\);\s*<\/script>/gi, ''); content = content.replace(/]*)>/gi, '
'); content = content.replace(/]*)>/gi, '
'); content = content.replace(/<\/(object|embed)([^>]*)>/gi, '
'); content = content.replace(/]*)>/gi, '
'); content = content.replace(new RegExp('\\/ class="mceItemParam"><\\/div>', 'gi'), 'class="mceItemParam">
'); break; case "insert_to_editor_dom": d = inst.getDoc(); nl = content.getElementsByTagName("img"); for (i=0; i', startPos); attribs = TinyMCE_MediaPlugin._parseAttributes(content.substring(startPos + 4, endPos)); // Is not flash, skip it if (!/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(attribs['class'])) continue; endPos += 2; // Parse attributes at = attribs['title']; if (at) { at = at.replace(/&(#39|apos);/g, "'"); at = at.replace(/&#quot;/g, '"'); try { pl = eval('x={' + at + '};'); } catch (ex) { pl = {}; } } // Use object/embed if (!tinyMCE.getParam('media_use_script', false)) { switch (attribs['class']) { case 'mceItemFlash': ci = 'd27cdb6e-ae6d-11cf-96b8-444553540000'; cb = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'; mt = 'application/x-shockwave-flash'; break; case 'mceItemShockWave': ci = '166B1BCA-3F9C-11CF-8075-444553540000'; cb = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0'; mt = 'application/x-director'; break; case 'mceItemWindowsMedia': ci = tinyMCE.getParam('media_wmp6_compatible') ? '05589FA1-C356-11CE-BF01-00AA0055595A' : '6BF52A52-394A-11D3-B153-00C04F79FAA6'; cb = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; mt = 'application/x-mplayer2'; break; case 'mceItemQuickTime': ci = '02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'; cb = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0'; mt = 'video/quicktime'; break; case 'mceItemRealMedia': ci = 'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'; cb = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'; mt = 'audio/x-pn-realaudio-plugin'; break; } // Force absolute URL if (!tinyMCE.getParam("relative_urls")) pl.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], pl.src); embedHTML = TinyMCE_MediaPlugin._getEmbed(ci, cb, mt, pl, attribs); } else { // Use script version switch (attribs['class']) { case 'mceItemFlash': s = 'writeFlash'; break; case 'mceItemShockWave': s = 'writeShockWave'; break; case 'mceItemWindowsMedia': s = 'writeWindowsMedia'; break; case 'mceItemQuickTime': s = 'writeQuickTime'; break; case 'mceItemRealMedia': s = 'writeRealMedia'; break; } if (attribs.width) at = at.replace(/width:[^0-9]?[0-9]+%?[^0-9]?/g, "width:'" + attribs.width + "'"); if (attribs.height) at = at.replace(/height:[^0-9]?[0-9]+%?[^0-9]?/g, "height:'" + attribs.height + "'"); // Force absolute URL if (!tinyMCE.getParam("relative_urls")) { pl.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], pl.src); at = at.replace(new RegExp("src:'[^']*'", "g"), "src:'" + pl.src + "'"); } embedHTML = ''; } // Insert embed/object chunk chunkBefore = content.substring(0, startPos); chunkAfter = content.substring(endPos); content = chunkBefore + embedHTML + chunkAfter; } break; } return content; }, handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { if (node == null) return; do { if (node.nodeName == "IMG" && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(tinyMCE.getAttrib(node, 'class'))) { tinyMCE.switchClass(editor_id + '_media', 'mceButtonSelected'); return true; } } while ((node = node.parentNode)); tinyMCE.switchClass(editor_id + '_media', 'mceButtonNormal'); return true; }, _createImgFromEmbed : function(n, d, cl) { var ne, at, i, ti = '', an; ne = d.createElement('img'); ne.src = tinyMCE.getParam("theme_href") + '/images/spacer.gif'; ne.width = tinyMCE.getAttrib(n, 'width'); ne.height = tinyMCE.getAttrib(n, 'height'); ne.className = cl; at = n.attributes; for (i=0; i 0 ? ti.substring(0, ti.length - 1) : ti; ne.title = ti; n.parentNode.replaceChild(ne, n); }, _createImg : function(cl, d, n) { var i, nl, ti = "", an, av, al = new Array(); ne = d.createElement('img'); ne.src = tinyMCE.getParam("theme_href") + '/images/spacer.gif'; ne.width = tinyMCE.getAttrib(n, 'width'); ne.height = tinyMCE.getAttrib(n, 'height'); ne.className = cl; al.id = tinyMCE.getAttrib(n, 'id'); al.name = tinyMCE.getAttrib(n, 'name'); al.width = tinyMCE.getAttrib(n, 'width'); al.height = tinyMCE.getAttrib(n, 'height'); al.bgcolor = tinyMCE.getAttrib(n, 'bgcolor'); al.align = tinyMCE.getAttrib(n, 'align'); al.class_name = tinyMCE.getAttrib(n, 'mce_class'); nl = n.getElementsByTagName('div'); for (i=0; i 0 ? ti.substring(0, ti.length - 1) : ti; ne.title = ti; return ne; }, _getEmbed : function(cls, cb, mt, p, at) { var h = '', n; p.width = at.width ? at.width : p.width; p.height = at.height ? at.height : p.height; h += ''; // Add extra url parameter if it's an absolute URL on WMP if (n == 'src' && p[n].indexOf('://') != -1 && mt == 'application/x-mplayer2') h += ''; } } h += '