+ /**\r
+ * Converts the JSON data object to a HTML string.\r
+ */\r
+ dataToHtml : function(data, force_absolute) {\r
+ return this.editor.serializer.serialize(this.dataToImg(data, force_absolute), {forced_root_block : '', force_absolute : force_absolute});\r
+ },\r
+\r
+ /**\r
+ * Converts the JSON data object to a HTML string.\r
+ */\r
+ htmlToData : function(html) {\r
+ var fragment, img, data;\r
+\r
+ data = {\r
+ type : 'flash',\r
+ video: {sources:[]},\r
+ params: {}\r
+ };\r
+\r
+ fragment = this.editor.parser.parse(html);\r
+ img = fragment.getAll('img')[0];\r
+\r
+ if (img) {\r
+ data = JSON.parse(img.attr('data-mce-json'));\r
+ data.type = this.getType(img.attr('class')).name.toLowerCase();\r
+\r
+ // Add some extra properties to the data object\r
+ tinymce.each(rootAttributes, function(name) {\r
+ var value = img.attr(name);\r
+\r
+ if (value)\r
+ data[name] = value;\r
+ });\r
+ }\r
+\r
+ return data;\r
+ },\r
+\r
+ /**\r
+ * Get type item by extension, class, clsid or mime type.\r
+ *\r
+ * @method getType\r
+ * @param {String} value Value to get type item by.\r
+ * @return {Object} Type item object or undefined.\r
+ */\r
+ getType : function(value) {\r
+ var i, values, typeItem;\r
+\r
+ // Find type by checking the classes\r
+ values = tinymce.explode(value, ' ');\r
+ for (i = 0; i < values.length; i++) {\r
+ typeItem = this.lookup[values[i]];\r
+\r
+ if (typeItem)\r
+ return typeItem;\r
+ }\r
+ },\r
+\r
+ /**\r
+ * Converts a tinymce.html.Node image element to video/object/embed.\r
+ */\r
+ imgToObject : function(node, args) {\r
+ var self = this, editor = self.editor, video, object, embed, iframe, name, value, data,\r
+ source, sources, params, param, typeItem, i, item, mp4Source, replacement,\r
+ posterSrc, style, audio;\r
+\r
+ // Adds the flash player\r
+ function addPlayer(video_src, poster_src) {\r
+ var baseUri, flashVars, flashVarsOutput, params, flashPlayer;\r
+\r
+ flashPlayer = editor.getParam('flash_video_player_url', self.convertUrl(self.url + '/moxieplayer.swf'));\r
+ if (flashPlayer) {\r
+ baseUri = editor.documentBaseURI;\r
+ data.params.src = flashPlayer;\r
+\r
+ // Convert the movie url to absolute urls\r
+ if (editor.getParam('flash_video_player_absvideourl', true)) {\r
+ video_src = baseUri.toAbsolute(video_src || '', true);\r
+ poster_src = baseUri.toAbsolute(poster_src || '', true);\r
+ }\r
+\r
+ // Generate flash vars\r
+ flashVarsOutput = '';\r
+ flashVars = editor.getParam('flash_video_player_flashvars', {url : '$url', poster : '$poster'});\r
+ tinymce.each(flashVars, function(value, name) {\r
+ // Replace $url and $poster variables in flashvars value\r
+ value = value.replace(/\$url/, video_src || '');\r
+ value = value.replace(/\$poster/, poster_src || '');\r
+\r
+ if (value.length > 0)\r
+ flashVarsOutput += (flashVarsOutput ? '&' : '') + name + '=' + escape(value);\r
+ });\r
+\r
+ if (flashVarsOutput.length)\r
+ data.params.flashvars = flashVarsOutput;\r
+\r
+ params = editor.getParam('flash_video_player_params', {\r
+ allowfullscreen: true,\r
+ allowscriptaccess: true\r
+ });\r
+\r
+ tinymce.each(params, function(value, name) {\r
+ data.params[name] = "" + value;\r
+ });\r
+ }\r
+ };\r
+\r
+ data = node.attr('data-mce-json');\r
+ if (!data)\r
+ return;\r
+\r
+ data = JSON.parse(data);\r
+ typeItem = this.getType(node.attr('class'));\r
+\r
+ style = node.attr('data-mce-style')\r
+ if (!style) {\r
+ style = node.attr('style');\r
+\r
+ if (style)\r
+ style = editor.dom.serializeStyle(editor.dom.parseStyle(style, 'img'));\r
+ }\r
+\r
+ // Handle iframe\r
+ if (typeItem.name === 'Iframe') {\r
+ replacement = new Node('iframe', 1);\r
+\r
+ tinymce.each(rootAttributes, function(name) {\r
+ var value = node.attr(name);\r
+\r
+ if (name == 'class' && value)\r
+ value = value.replace(/mceItem.+ ?/g, '');\r
+\r
+ if (value && value.length > 0)\r
+ replacement.attr(name, value);\r