]> code.citadel.org Git - citadel.git/blobdiff - webcit/tiny_mce/plugins/flash/editor_plugin_src.js
src/crypto.c: possible fix for memory leak related
[citadel.git] / webcit / tiny_mce / plugins / flash / editor_plugin_src.js
index eb20eb84e260b1dee337cdfd4f9cca8ccb4d549c..e4fa86327e4a5d8c37e820d8fdfaa10b4c78dd15 100644 (file)
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('flash', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl,da,he,no,hu');
-
-function TinyMCE_flash_getInfo() {
-       return {
-               longname : 'Flash',
-               author : 'Moxiecode Systems',
-               authorurl : 'http://tinymce.moxiecode.com',
-               infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_flash.html',
-               version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
-       };
-};
-
-function TinyMCE_flash_initInstance(inst) {
-       if (!tinyMCE.settings['flash_skip_plugin_css'])
-               tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/flash/css/content.css");
-}
-
-function TinyMCE_flash_getControlHTML(control_name) {
-    switch (control_name) {
-        case "flash":
-            return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceFlash\');" target="_self" onmousedown="return false;"><img id="{$editor_id}_flash" src="{$pluginurl}/images/flash.gif" title="{$lang_flash_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
-    }
-
-    return "";
-}
-
-function TinyMCE_flash_parseAttributes(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<attribute_string.length; i++) {
-               var chr = attribute_string.charAt(i);
-
-               if ((chr == '"' || chr == "'") && !withInValue)
-                       withInValue = true;
-               else if ((chr == '"' || chr == "'") && withInValue) {
-                       withInValue = false;
-
-                       var pos = attributeName.lastIndexOf(' ');
-                       if (pos != -1)
-                               attributeName = attributeName.substring(pos+1);
-
-                       attributes[attributeName.toLowerCase()] = attributeValue.substring(1);
-
-                       attributeName = "";
-                       attributeValue = "";
-               } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
-                       withInName = true;
-
-               if (chr == '=' && withInName)
-                       withInName = false;
-
-               if (withInName)
-                       attributeName += chr;
-
-               if (withInValue)
-                       attributeValue += chr;
-       }
-
-       return attributes;
-}
-
-function TinyMCE_flash_execCommand(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');
-                               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;
-}
-
-function TinyMCE_flash_cleanup(type, content) {
-       switch (type) {
-               case "insert_to_editor_dom":
-                       var imgs = content.getElementsByTagName("img");
-                       for (var i=0; i<imgs.length; i++) {
-                               if (tinyMCE.getAttrib(imgs[i], "class") == "mceItemFlash") {
-                                       var src = tinyMCE.getAttrib(imgs[i], "alt");
-
-                                       src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src);
-
-                                       imgs[i].setAttribute('alt', src);
-                               }
-                       }
-                       break;
-
-               case "get_from_editor_dom":
-                       var imgs = content.getElementsByTagName("img");
-                       for (var i=0; i<imgs.length; i++) {
-                               if (tinyMCE.getAttrib(imgs[i], "class") == "mceItemFlash") {
-                                       var src = tinyMCE.getAttrib(imgs[i], "alt");
-
-                                       src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
-
-                                       imgs[i].setAttribute('alt', src);
-                               }
-                       }
-                       break;
-
-               case "insert_to_editor":
-                       var startPos = 0;
-                       var embedList = new Array();
-
-                       // Fix the embed and object elements
-                       content = content.replace(new RegExp('<[ ]*embed','gi'),'<embed');
-                       content = content.replace(new RegExp('<[ ]*/embed[ ]*>','gi'),'</embed>');
-                       content = content.replace(new RegExp('<[ ]*object','gi'),'<object');
-                       content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');
-
-                       // Parse all embed tags
-                       while ((startPos = content.indexOf('<embed', startPos+1)) != -1) {
-                               var endPos = content.indexOf('>', startPos);
-                               var attribs = TinyMCE_flash_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('<object', startPos)) != -1) {
-                               if (index >= embedList.length)
-                                       break;
-
-                               var attribs = embedList[index];
-
-                               // Find end of object
-                               endPos = content.indexOf('</object>', startPos);
-                               endPos += 9;
-
-                               // Insert image
-                               var contentAfter = content.substring(endPos);
-                               content = content.substring(0, startPos);
-                               content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';
-                               content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"';
-                               content += ' alt="' + attribs["src"] + '" class="mceItemFlash" />' + 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('<img', startPos+1)) != -1) {
-                               var endPos = content.indexOf('/>', startPos);
-                               var attribs = TinyMCE_flash_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 += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
-                               embedHTML += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';
-                               embedHTML += ' width="' + attribs["width"] + '" height="' + attribs["height"] + '">';
-                               embedHTML += '<param name="movie" value="' + attribs["title"] + '" />';
-                               embedHTML += '<param name="quality" value="' + quality + '" />';
-                               embedHTML += '<param name="menu" value="' + menu + '" />';
-                               embedHTML += '<param name="wmode" value="' + wmode + '" />';
-                               embedHTML += '<embed src="' + attribs["title"] + '" wmode="' + wmode + '" quality="' + quality + '" menu="' + menu + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + attribs["width"] + '" height="' + attribs["height"] + '"></embed></object>';
-
-                               // 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;
-}
-
-function TinyMCE_flash_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
-       tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonNormal');
-
-       if (node == null)
-               return;
-
-       do {
-               if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mceItemFlash') == 0)
-                       tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonSelected');
-       } while ((node = node.parentNode));
-
-       return true;
-}
+/* Import plugin specific language pack */\r
+tinyMCE.importPluginLanguagePack('flash', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,zh_tw,zh_tw_utf8,sk,pt_br');\r
+\r
+function TinyMCE_flash_getInfo() {\r
+       return {\r
+               longname : 'Flash',\r
+               author : 'Moxiecode Systems',\r
+               authorurl : 'http://tinymce.moxiecode.com',\r
+               infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_flash.html',\r
+               version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion\r
+       };\r
+};\r
+\r
+function TinyMCE_flash_initInstance(inst) {\r
+       if (!tinyMCE.settings['flash_skip_plugin_css'])\r
+               tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/flash/css/content.css");\r
+}\r
+\r
+function TinyMCE_flash_getControlHTML(control_name) {\r
+    switch (control_name) {\r
+        case "flash":\r
+                       var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceFlash\');return false;';\r
+            return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_flash" src="{$pluginurl}/images/flash.gif" title="{$lang_flash_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';\r
+    }\r
+\r
+    return "";\r
+}\r
+\r
+function TinyMCE_flash_parseAttributes(attribute_string) {\r
+       var attributeName = "";\r
+       var attributeValue = "";\r
+       var withInName;\r
+       var withInValue;\r
+       var attributes = new Array();\r
+       var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');\r
+\r
+       if (attribute_string == null || attribute_string.length < 2)\r
+               return null;\r
+\r
+       withInName = withInValue = false;\r
+\r
+       for (var i=0; i<attribute_string.length; i++) {\r
+               var chr = attribute_string.charAt(i);\r
+\r
+               if ((chr == '"' || chr == "'") && !withInValue)\r
+                       withInValue = true;\r
+               else if ((chr == '"' || chr == "'") && withInValue) {\r
+                       withInValue = false;\r
+\r
+                       var pos = attributeName.lastIndexOf(' ');\r
+                       if (pos != -1)\r
+                               attributeName = attributeName.substring(pos+1);\r
+\r
+                       attributes[attributeName.toLowerCase()] = attributeValue.substring(1);\r
+\r
+                       attributeName = "";\r
+                       attributeValue = "";\r
+               } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)\r
+                       withInName = true;\r
+\r
+               if (chr == '=' && withInName)\r
+                       withInName = false;\r
+\r
+               if (withInName)\r
+                       attributeName += chr;\r
+\r
+               if (withInValue)\r
+                       attributeValue += chr;\r
+       }\r
+\r
+       return attributes;\r
+}\r
+\r
+function TinyMCE_flash_execCommand(editor_id, element, command, user_interface, value) {\r
+    // Handle commands\r
+    switch (command) {\r
+        case "mceFlash":\r
+                       var name = "", swffile = "", swfwidth = "", swfheight = "", action = "insert";\r
+            var template = new Array();\r
+                       var inst = tinyMCE.getInstanceById(editor_id);\r
+                       var focusElm = inst.getFocusElement();\r
+\r
+            template['file']   = '../../plugins/flash/flash.htm'; // Relative to theme\r
+            template['width']  = 430;\r
+            template['height'] = 175;\r
+\r
+                       template['width'] += tinyMCE.getLang('lang_flash_delta_width', 0);\r
+                       template['height'] += tinyMCE.getLang('lang_flash_delta_height', 0);\r
+\r
+                       // Is selection a image\r
+            if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {\r
+                               name = tinyMCE.getAttrib(focusElm, 'class');\r
+\r
+                               if (name.indexOf('mceItemFlash') == -1) // Not a Flash\r
+                                       return true;\r
+\r
+                               // Get rest of Flash items\r
+                               swffile = tinyMCE.getAttrib(focusElm, 'alt');\r
+\r
+                               if (tinyMCE.getParam('convert_urls'))\r
+                                       swffile = eval(tinyMCE.settings['urlconverter_callback'] + "(swffile, null, true);");\r
+\r
+                               swfwidth = tinyMCE.getAttrib(focusElm, 'width');\r
+                               swfheight = tinyMCE.getAttrib(focusElm, 'height');\r
+                               action = "update";\r
+            }\r
+\r
+            tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", swffile : swffile, swfwidth : swfwidth, swfheight : swfheight, action : action});\r
+               return true;\r
+   }\r
+\r
+   // Pass to next handler in chain\r
+   return false;\r
+}\r
+\r
+function TinyMCE_flash_cleanup(type, content) {\r
+       switch (type) {\r
+               case "insert_to_editor_dom":\r
+                       // Force relative/absolute\r
+                       if (tinyMCE.getParam('convert_urls')) {\r
+                               var imgs = content.getElementsByTagName("img");\r
+                               for (var i=0; i<imgs.length; i++) {\r
+                                       if (tinyMCE.getAttrib(imgs[i], "class") == "mceItemFlash") {\r
+                                               var src = tinyMCE.getAttrib(imgs[i], "alt");\r
+\r
+                                               if (tinyMCE.getParam('convert_urls'))\r
+                                                       src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");\r
+\r
+                                               imgs[i].setAttribute('alt', src);\r
+                                               imgs[i].setAttribute('title', src);\r
+                                       }\r
+                               }\r
+                       }\r
+                       break;\r
+\r
+               case "get_from_editor_dom":\r
+                       var imgs = content.getElementsByTagName("img");\r
+                       for (var i=0; i<imgs.length; i++) {\r
+                               if (tinyMCE.getAttrib(imgs[i], "class") == "mceItemFlash") {\r
+                                       var src = tinyMCE.getAttrib(imgs[i], "alt");\r
+\r
+                                       if (tinyMCE.getParam('convert_urls'))\r
+                                               src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");\r
+\r
+                                       imgs[i].setAttribute('alt', src);\r
+                                       imgs[i].setAttribute('title', src);\r
+                               }\r
+                       }\r
+                       break;\r
+\r
+               case "insert_to_editor":\r
+                       var startPos = 0;\r
+                       var embedList = new Array();\r
+\r
+                       // Fix the embed and object elements\r
+                       content = content.replace(new RegExp('<[ ]*embed','gi'),'<embed');\r
+                       content = content.replace(new RegExp('<[ ]*/embed[ ]*>','gi'),'</embed>');\r
+                       content = content.replace(new RegExp('<[ ]*object','gi'),'<object');\r
+                       content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');\r
+\r
+                       // Parse all embed tags\r
+                       while ((startPos = content.indexOf('<embed', startPos+1)) != -1) {\r
+                               var endPos = content.indexOf('>', startPos);\r
+                               var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 6, endPos));\r
+                               embedList[embedList.length] = attribs;\r
+                       }\r
+\r
+                       // Parse all object tags and replace them with images from the embed data\r
+                       var index = 0;\r
+                       while ((startPos = content.indexOf('<object', startPos)) != -1) {\r
+                               if (index >= embedList.length)\r
+                                       break;\r
+\r
+                               var attribs = embedList[index];\r
+\r
+                               // Find end of object\r
+                               endPos = content.indexOf('</object>', startPos);\r
+                               endPos += 9;\r
+\r
+                               // Insert image\r
+                               var contentAfter = content.substring(endPos);\r
+                               content = content.substring(0, startPos);\r
+                               content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';\r
+                               content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"';\r
+                               content += ' alt="' + attribs["src"] + '" class="mceItemFlash" />' + content.substring(endPos);\r
+                               content += contentAfter;\r
+                               index++;\r
+\r
+                               startPos++;\r
+                       }\r
+\r
+                       // Parse all embed tags and replace them with images from the embed data\r
+                       var index = 0;\r
+                       while ((startPos = content.indexOf('<embed', startPos)) != -1) {\r
+                               if (index >= embedList.length)\r
+                                       break;\r
+\r
+                               var attribs = embedList[index];\r
+\r
+                               // Find end of embed\r
+                               endPos = content.indexOf('>', startPos);\r
+                               endPos += 9;\r
+\r
+                               // Insert image\r
+                               var contentAfter = content.substring(endPos);\r
+                               content = content.substring(0, startPos);\r
+                               content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';\r
+                               content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"';\r
+                               content += ' alt="' + attribs["src"] + '" class="mceItemFlash" />' + content.substring(endPos);\r
+                               content += contentAfter;\r
+                               index++;\r
+\r
+                               startPos++;\r
+                       }\r
+\r
+                       break;\r
+\r
+               case "get_from_editor":\r
+                       // Parse all img tags and replace them with object+embed\r
+                       var startPos = -1;\r
+                       while ((startPos = content.indexOf('<img', startPos+1)) != -1) {\r
+                               var endPos = content.indexOf('/>', startPos);\r
+                               var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 4, endPos));\r
+\r
+                               // Is not flash, skip it\r
+                               if (attribs['class'] != "mceItemFlash")\r
+                                       continue;\r
+\r
+                               endPos += 2;\r
+\r
+                               var embedHTML = '';\r
+                               var wmode = tinyMCE.getParam("flash_wmode", "");\r
+                               var quality = tinyMCE.getParam("flash_quality", "high");\r
+                               var menu = tinyMCE.getParam("flash_menu", "false");\r
+\r
+                               // Insert object + embed\r
+                               embedHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';\r
+                               embedHTML += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';\r
+                               embedHTML += ' width="' + attribs["width"] + '" height="' + attribs["height"] + '">';\r
+                               embedHTML += '<param name="movie" value="' + attribs["title"] + '" />';\r
+                               embedHTML += '<param name="quality" value="' + quality + '" />';\r
+                               embedHTML += '<param name="menu" value="' + menu + '" />';\r
+                               embedHTML += '<param name="wmode" value="' + wmode + '" />';\r
+                               embedHTML += '<embed src="' + attribs["title"] + '" wmode="' + wmode + '" quality="' + quality + '" menu="' + menu + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + attribs["width"] + '" height="' + attribs["height"] + '"></embed></object>';\r
+\r
+                               // Insert embed/object chunk\r
+                               chunkBefore = content.substring(0, startPos);\r
+                               chunkAfter = content.substring(endPos);\r
+                               content = chunkBefore + embedHTML + chunkAfter;\r
+                       }\r
+                       break;\r
+       }\r
+\r
+       // Pass through to next handler in chain\r
+       return content;\r
+}\r
+\r
+function TinyMCE_flash_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {\r
+       tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonNormal');\r
+\r
+       if (node == null)\r
+               return;\r
+\r
+       do {\r
+               if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mceItemFlash') == 0)\r
+                       tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonSelected');\r
+       } while ((node = node.parentNode));\r
+\r
+       return true;\r
+}\r