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,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,zh_tw,zh_tw_utf8,sk,pt_br');
\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 var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceFlash\');return false;';
\r
23 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
29 function TinyMCE_flash_parseAttributes(attribute_string) {
\r
30 var attributeName = "";
\r
31 var attributeValue = "";
\r
34 var attributes = new Array();
\r
35 var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
\r
37 if (attribute_string == null || attribute_string.length < 2)
\r
40 withInName = withInValue = false;
\r
42 for (var i=0; i<attribute_string.length; i++) {
\r
43 var chr = attribute_string.charAt(i);
\r
45 if ((chr == '"' || chr == "'") && !withInValue)
\r
47 else if ((chr == '"' || chr == "'") && withInValue) {
\r
48 withInValue = false;
\r
50 var pos = attributeName.lastIndexOf(' ');
\r
52 attributeName = attributeName.substring(pos+1);
\r
54 attributes[attributeName.toLowerCase()] = attributeValue.substring(1);
\r
57 attributeValue = "";
\r
58 } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
\r
61 if (chr == '=' && withInName)
\r
65 attributeName += chr;
\r
68 attributeValue += chr;
\r
74 function TinyMCE_flash_execCommand(editor_id, element, command, user_interface, value) {
\r
78 var name = "", swffile = "", swfwidth = "", swfheight = "", action = "insert";
\r
79 var template = new Array();
\r
80 var inst = tinyMCE.getInstanceById(editor_id);
\r
81 var focusElm = inst.getFocusElement();
\r
83 template['file'] = '../../plugins/flash/flash.htm'; // Relative to theme
\r
84 template['width'] = 430;
\r
85 template['height'] = 175;
\r
87 template['width'] += tinyMCE.getLang('lang_flash_delta_width', 0);
\r
88 template['height'] += tinyMCE.getLang('lang_flash_delta_height', 0);
\r
90 // Is selection a image
\r
91 if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
\r
92 name = tinyMCE.getAttrib(focusElm, 'class');
\r
94 if (name.indexOf('mceItemFlash') == -1) // Not a Flash
\r
97 // Get rest of Flash items
\r
98 swffile = tinyMCE.getAttrib(focusElm, 'alt');
\r
100 if (tinyMCE.getParam('convert_urls'))
\r
101 swffile = eval(tinyMCE.settings['urlconverter_callback'] + "(swffile, null, true);");
\r
103 swfwidth = tinyMCE.getAttrib(focusElm, 'width');
\r
104 swfheight = tinyMCE.getAttrib(focusElm, 'height');
\r
108 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", swffile : swffile, swfwidth : swfwidth, swfheight : swfheight, action : action});
\r
112 // Pass to next handler in chain
\r
116 function TinyMCE_flash_cleanup(type, content) {
\r
118 case "insert_to_editor_dom":
\r
119 // Force relative/absolute
\r
120 if (tinyMCE.getParam('convert_urls')) {
\r
121 var imgs = content.getElementsByTagName("img");
\r
122 for (var i=0; i<imgs.length; i++) {
\r
123 if (tinyMCE.getAttrib(imgs[i], "class") == "mceItemFlash") {
\r
124 var src = tinyMCE.getAttrib(imgs[i], "alt");
\r
126 if (tinyMCE.getParam('convert_urls'))
\r
127 src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
\r
129 imgs[i].setAttribute('alt', src);
\r
130 imgs[i].setAttribute('title', src);
\r
136 case "get_from_editor_dom":
\r
137 var imgs = content.getElementsByTagName("img");
\r
138 for (var i=0; i<imgs.length; i++) {
\r
139 if (tinyMCE.getAttrib(imgs[i], "class") == "mceItemFlash") {
\r
140 var src = tinyMCE.getAttrib(imgs[i], "alt");
\r
142 if (tinyMCE.getParam('convert_urls'))
\r
143 src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
\r
145 imgs[i].setAttribute('alt', src);
\r
146 imgs[i].setAttribute('title', src);
\r
151 case "insert_to_editor":
\r
153 var embedList = new Array();
\r
155 // Fix the embed and object elements
\r
156 content = content.replace(new RegExp('<[ ]*embed','gi'),'<embed');
\r
157 content = content.replace(new RegExp('<[ ]*/embed[ ]*>','gi'),'</embed>');
\r
158 content = content.replace(new RegExp('<[ ]*object','gi'),'<object');
\r
159 content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');
\r
161 // Parse all embed tags
\r
162 while ((startPos = content.indexOf('<embed', startPos+1)) != -1) {
\r
163 var endPos = content.indexOf('>', startPos);
\r
164 var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 6, endPos));
\r
165 embedList[embedList.length] = attribs;
\r
168 // Parse all object tags and replace them with images from the embed data
\r
170 while ((startPos = content.indexOf('<object', startPos)) != -1) {
\r
171 if (index >= embedList.length)
\r
174 var attribs = embedList[index];
\r
176 // Find end of object
\r
177 endPos = content.indexOf('</object>', startPos);
\r
181 var contentAfter = content.substring(endPos);
\r
182 content = content.substring(0, startPos);
\r
183 content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';
\r
184 content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"';
\r
185 content += ' alt="' + attribs["src"] + '" class="mceItemFlash" />' + content.substring(endPos);
\r
186 content += contentAfter;
\r
192 // Parse all embed tags and replace them with images from the embed data
\r
194 while ((startPos = content.indexOf('<embed', startPos)) != -1) {
\r
195 if (index >= embedList.length)
\r
198 var attribs = embedList[index];
\r
200 // Find end of embed
\r
201 endPos = content.indexOf('>', startPos);
\r
205 var contentAfter = content.substring(endPos);
\r
206 content = content.substring(0, startPos);
\r
207 content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';
\r
208 content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"';
\r
209 content += ' alt="' + attribs["src"] + '" class="mceItemFlash" />' + content.substring(endPos);
\r
210 content += contentAfter;
\r
218 case "get_from_editor":
\r
219 // Parse all img tags and replace them with object+embed
\r
221 while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
\r
222 var endPos = content.indexOf('/>', startPos);
\r
223 var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 4, endPos));
\r
225 // Is not flash, skip it
\r
226 if (attribs['class'] != "mceItemFlash")
\r
231 var embedHTML = '';
\r
232 var wmode = tinyMCE.getParam("flash_wmode", "");
\r
233 var quality = tinyMCE.getParam("flash_quality", "high");
\r
234 var menu = tinyMCE.getParam("flash_menu", "false");
\r
236 // Insert object + embed
\r
237 embedHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
\r
238 embedHTML += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';
\r
239 embedHTML += ' width="' + attribs["width"] + '" height="' + attribs["height"] + '">';
\r
240 embedHTML += '<param name="movie" value="' + attribs["title"] + '" />';
\r
241 embedHTML += '<param name="quality" value="' + quality + '" />';
\r
242 embedHTML += '<param name="menu" value="' + menu + '" />';
\r
243 embedHTML += '<param name="wmode" value="' + wmode + '" />';
\r
244 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
246 // Insert embed/object chunk
\r
247 chunkBefore = content.substring(0, startPos);
\r
248 chunkAfter = content.substring(endPos);
\r
249 content = chunkBefore + embedHTML + chunkAfter;
\r
254 // Pass through to next handler in chain
\r
258 function TinyMCE_flash_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
\r
259 tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonNormal');
\r
265 if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mceItemFlash') == 0)
\r
266 tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonSelected');
\r
267 } while ((node = node.parentNode));
\r