diff -r 902822492a68 -r fe660c52c48f includes/clientside/tinymce/plugins/flash/editor_plugin_src.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/includes/clientside/tinymce/plugins/flash/editor_plugin_src.js Wed Jun 13 16:07:17 2007 -0400 @@ -0,0 +1,285 @@ +/** + * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ + * + * @author Moxiecode + * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. + */ + +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('flash'); + +var TinyMCE_FlashPlugin = { + getInfo : function() { + return { + longname : 'Flash', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/flash', + version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion + }; + }, + + initInstance : function(inst) { + if (!tinyMCE.settings['flash_skip_plugin_css']) + tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/flash/css/content.css"); + }, + + getControlHTML : function(cn) { + switch (cn) { + case "flash": + return tinyMCE.getButtonHTML(cn, 'lang_flash_desc', '{$pluginurl}/images/flash.gif', 'mceFlash'); + } + + return ""; + }, + + execCommand : function(editor_id, element, command, user_interface, value) { + // Handle commands + switch (command) { + case "mceFlash": + var name = "", swffile = "", swfwidth = "", swfheight = "", action = "insert"; + var template = new Array(); + var inst = tinyMCE.getInstanceById(editor_id); + var focusElm = inst.getFocusElement(); + + template['file'] = '../../plugins/flash/flash.htm'; // Relative to theme + template['width'] = 430; + template['height'] = 175; + + template['width'] += tinyMCE.getLang('lang_flash_delta_width', 0); + template['height'] += tinyMCE.getLang('lang_flash_delta_height', 0); + + // Is selection a image + if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { + name = tinyMCE.getAttrib(focusElm, 'class'); + + if (name.indexOf('mceItemFlash') == -1) // Not a Flash + return true; + + // Get rest of Flash items + swffile = tinyMCE.getAttrib(focusElm, 'alt'); + + if (tinyMCE.getParam('convert_urls')) + swffile = eval(tinyMCE.settings['urlconverter_callback'] + "(swffile, null, true);"); + + swfwidth = tinyMCE.getAttrib(focusElm, 'width'); + swfheight = tinyMCE.getAttrib(focusElm, 'height'); + action = "update"; + } + + tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", swffile : swffile, swfwidth : swfwidth, swfheight : swfheight, action : action}); + return true; + } + + // Pass to next handler in chain + return false; + }, + + cleanup : function(type, content) { + switch (type) { + case "insert_to_editor_dom": + // Force relative/absolute + if (tinyMCE.getParam('convert_urls')) { + var imgs = content.getElementsByTagName("img"); + for (var i=0; i','gi'),''); + content = content.replace(new RegExp('<[ ]*object','gi'),'','gi'),''); + + // Parse all embed tags + while ((startPos = content.indexOf('', startPos); + var attribs = TinyMCE_FlashPlugin._parseAttributes(content.substring(startPos + 6, endPos)); + embedList[embedList.length] = attribs; + } + + // Parse all object tags and replace them with images from the embed data + var index = 0; + while ((startPos = content.indexOf('= embedList.length) + break; + + var attribs = embedList[index]; + + // Find end of object + endPos = content.indexOf('', startPos); + endPos += 9; + + // Insert image + var contentAfter = content.substring(endPos); + content = content.substring(0, startPos); + content += '' + content.substring(endPos); + content += contentAfter; + index++; + + startPos++; + } + + // Parse all embed tags and replace them with images from the embed data + var index = 0; + while ((startPos = content.indexOf('= embedList.length) + break; + + var attribs = embedList[index]; + + // Find end of embed + endPos = content.indexOf('>', startPos); + endPos += 9; + + // Insert image + var contentAfter = content.substring(endPos); + content = content.substring(0, startPos); + content += '' + content.substring(endPos); + content += contentAfter; + index++; + + startPos++; + } + + break; + + case "get_from_editor": + // Parse all img tags and replace them with object+embed + var startPos = -1; + + while ((startPos = content.indexOf('', startPos); + var attribs = TinyMCE_FlashPlugin._parseAttributes(content.substring(startPos + 4, endPos)); + + // Is not flash, skip it + if (attribs['class'] != "mceItemFlash") + continue; + + endPos += 2; + + var embedHTML = ''; + var wmode = tinyMCE.getParam("flash_wmode", ""); + var quality = tinyMCE.getParam("flash_quality", "high"); + var menu = tinyMCE.getParam("flash_menu", "false"); + + // Insert object + embed + embedHTML += ''; + embedHTML += ''; + embedHTML += ''; + embedHTML += ''; + embedHTML += ''; + embedHTML += ''; + + // Insert embed/object chunk + chunkBefore = content.substring(0, startPos); + chunkAfter = content.substring(endPos); + content = chunkBefore + embedHTML + chunkAfter; + } + break; + } + + // Pass through to next handler in chain + return content; + }, + + handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + if (node == null) + return; + + do { + if (node.nodeName == "IMG" && tinyMCE.getAttrib(node, 'class').indexOf('mceItemFlash') == 0) { + tinyMCE.switchClass(editor_id + '_flash', 'mceButtonSelected'); + return true; + } + } while ((node = node.parentNode)); + + tinyMCE.switchClass(editor_id + '_flash', 'mceButtonNormal'); + + return true; + }, + + // Private plugin internal functions + + _parseAttributes : function(attribute_string) { + var attributeName = ""; + var attributeValue = ""; + var withInName; + var withInValue; + var attributes = new Array(); + var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); + + if (attribute_string == null || attribute_string.length < 2) + return null; + + withInName = withInValue = false; + + for (var i=0; i