1 /* Import plugin specific language pack */
\r
2 tinyMCE.importPluginLanguagePack('flash', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl,da,he,no,hu');
\r
4 function TinyMCE_flash_getInfo() {
\r
7 author : 'Moxiecode Systems',
\r
8 authorurl : 'http://tinymce.moxiecode.com',
\r
9 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_flash.html',
\r
10 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
\r
14 function TinyMCE_flash_initInstance(inst) {
\r
15 if (!tinyMCE.settings['flash_skip_plugin_css'])
\r
16 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/flash/css/content.css");
\r
19 function TinyMCE_flash_getControlHTML(control_name) {
\r
20 switch (control_name) {
\r
22 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>';
\r
28 function TinyMCE_flash_parseAttributes(attribute_string) {
\r
29 var attributeName = "";
\r
30 var attributeValue = "";
\r
33 var attributes = new Array();
\r
34 var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
\r
36 if (attribute_string == null || attribute_string.length < 2)
\r
39 withInName = withInValue = false;
\r
41 for (var i=0; i<attribute_string.length; i++) {
\r
42 var chr = attribute_string.charAt(i);
\r
44 if ((chr == '"' || chr == "'") && !withInValue)
\r
46 else if ((chr == '"' || chr == "'") && withInValue) {
\r
47 withInValue = false;
\r
49 var pos = attributeName.lastIndexOf(' ');
\r
51 attributeName = attributeName.substring(pos+1);
\r
53 attributes[attributeName.toLowerCase()] = attributeValue.substring(1);
\r
56 attributeValue = "";
\r
57 } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
\r
60 if (chr == '=' && withInName)
\r
64 attributeName += chr;
\r
67 attributeValue += chr;
\r
73 function TinyMCE_flash_execCommand(editor_id, element, command, user_interface, value) {
\r
77 var name = "", swffile = "", swfwidth = "", swfheight = "", action = "insert";
\r
78 var template = new Array();
\r
79 var inst = tinyMCE.getInstanceById(editor_id);
\r
80 var focusElm = inst.getFocusElement();
\r
82 template['file'] = '../../plugins/flash/flash.htm'; // Relative to theme
\r
83 template['width'] = 430;
\r
84 template['height'] = 175;
\r
86 template['width'] += tinyMCE.getLang('lang_flash_delta_width', 0);
\r
87 template['height'] += tinyMCE.getLang('lang_flash_delta_height', 0);
\r
89 // Is selection a image
\r
90 if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
\r
91 name = tinyMCE.getAttrib(focusElm, 'class');
\r
93 if (name.indexOf('mceItemFlash') == -1) // Not a Flash
\r
96 // Get rest of Flash items
\r
97 swffile = tinyMCE.getAttrib(focusElm, 'alt');
\r
98 swffile = eval(tinyMCE.settings['urlconverter_callback'] + "(swffile, null, true);");
\r
99 swfwidth = tinyMCE.getAttrib(focusElm, 'width');
\r
100 swfheight = tinyMCE.getAttrib(focusElm, 'height');
\r
104 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", swffile : swffile, swfwidth : swfwidth, swfheight : swfheight, action : action});
\r
108 // Pass to next handler in chain
\r
112 function TinyMCE_flash_cleanup(type, content) {
\r
114 case "insert_to_editor_dom":
\r
115 var imgs = content.getElementsByTagName("img");
\r
116 for (var i=0; i<imgs.length; i++) {
\r
117 if (tinyMCE.getAttrib(imgs[i], "class") == "mceItemFlash") {
\r
118 var src = tinyMCE.getAttrib(imgs[i], "alt");
\r
120 src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src);
\r
122 imgs[i].setAttribute('alt', src);
\r
127 case "get_from_editor_dom":
\r
128 var imgs = content.getElementsByTagName("img");
\r
129 for (var i=0; i<imgs.length; i++) {
\r
130 if (tinyMCE.getAttrib(imgs[i], "class") == "mceItemFlash") {
\r
131 var src = tinyMCE.getAttrib(imgs[i], "alt");
\r
133 src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
\r
135 imgs[i].setAttribute('alt', src);
\r
140 case "insert_to_editor":
\r
142 var embedList = new Array();
\r
144 // Fix the embed and object elements
\r
145 content = content.replace(new RegExp('<[ ]*embed','gi'),'<embed');
\r
146 content = content.replace(new RegExp('<[ ]*/embed[ ]*>','gi'),'</embed>');
\r
147 content = content.replace(new RegExp('<[ ]*object','gi'),'<object');
\r
148 content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');
\r
150 // Parse all embed tags
\r
151 while ((startPos = content.indexOf('<embed', startPos+1)) != -1) {
\r
152 var endPos = content.indexOf('>', startPos);
\r
153 var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 6, endPos));
\r
154 embedList[embedList.length] = attribs;
\r
157 // Parse all object tags and replace them with images from the embed data
\r
159 while ((startPos = content.indexOf('<object', startPos)) != -1) {
\r
160 if (index >= embedList.length)
\r
163 var attribs = embedList[index];
\r
165 // Find end of object
\r
166 endPos = content.indexOf('</object>', startPos);
\r
170 var contentAfter = content.substring(endPos);
\r
171 content = content.substring(0, startPos);
\r
172 content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';
\r
173 content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"';
\r
174 content += ' alt="' + attribs["src"] + '" class="mceItemFlash" />' + content.substring(endPos);
\r
175 content += contentAfter;
\r
182 case "get_from_editor":
\r
183 // Parse all img tags and replace them with object+embed
\r
185 while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
\r
186 var endPos = content.indexOf('/>', startPos);
\r
187 var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 4, endPos));
\r
189 // Is not flash, skip it
\r
190 if (attribs['class'] != "mceItemFlash")
\r
195 var embedHTML = '';
\r
196 var wmode = tinyMCE.getParam("flash_wmode", "");
\r
197 var quality = tinyMCE.getParam("flash_quality", "high");
\r
198 var menu = tinyMCE.getParam("flash_menu", "false");
\r
200 // Insert object + embed
\r
201 embedHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
\r
202 embedHTML += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';
\r
203 embedHTML += ' width="' + attribs["width"] + '" height="' + attribs["height"] + '">';
\r
204 embedHTML += '<param name="movie" value="' + attribs["title"] + '" />';
\r
205 embedHTML += '<param name="quality" value="' + quality + '" />';
\r
206 embedHTML += '<param name="menu" value="' + menu + '" />';
\r
207 embedHTML += '<param name="wmode" value="' + wmode + '" />';
\r
208 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
210 // Insert embed/object chunk
\r
211 chunkBefore = content.substring(0, startPos);
\r
212 chunkAfter = content.substring(endPos);
\r
213 content = chunkBefore + embedHTML + chunkAfter;
\r
218 // Pass through to next handler in chain
\r
222 function TinyMCE_flash_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
\r
223 tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonNormal');
\r
229 if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mceItemFlash') == 0)
\r
230 tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonSelected');
\r
231 } while ((node = node.parentNode));
\r