]> git.mxchange.org Git - friendica.git/blobdiff - library/tinymce/jscripts/tiny_mce/plugins/media/editor_plugin_src.js
TinyMCE 3.5.8 update; some fixes
[friendica.git] / library / tinymce / jscripts / tiny_mce / plugins / media / editor_plugin_src.js
index ea79db18a765137be9209c32b95dbaa3aebf8e21..33a58050eac93143222e27abdd72987423ac6ebd 100644 (file)
                ["Audio"]\r
        ];\r
 \r
+       function normalizeSize(size) {\r
+               return typeof(size) == "string" ? size.replace(/[^0-9%]/g, '') : size;\r
+       }\r
+\r
        function toArray(obj) {\r
                var undef, out, i;\r
 \r
                                'data-mce-json' : JSON.serialize(data, "'")\r
                        });\r
 \r
-                       img.width = data.width || (data.type == 'audio' ? "300" : "320");\r
-                       img.height = data.height || (data.type == 'audio' ? "32" : "240");\r
+                       img.width = data.width = normalizeSize(data.width || (data.type == 'audio' ? "300" : "320"));\r
+                       img.height = data.height = normalizeSize(data.height || (data.type == 'audio' ? "32" : "240"));\r
 \r
                        return img;\r
                },\r
                        data = JSON.parse(data);\r
                        typeItem = this.getType(node.attr('class'));\r
 \r
-                       style = node.attr('data-mce-style')\r
+                       style = node.attr('data-mce-style');\r
                        if (!style) {\r
                                style = node.attr('style');\r
 \r
                                        style = editor.dom.serializeStyle(editor.dom.parseStyle(style, 'img'));\r
                        }\r
 \r
+                       // Use node width/height to override the data width/height when the placeholder is resized\r
+                       data.width = node.attr('width') || data.width;\r
+                       data.height = node.attr('height') || data.height;\r
+\r
                        // Handle iframe\r
                        if (typeItem.name === 'Iframe') {\r
                                replacement = new Node('iframe', 1);\r
                                // Create new object element\r
                                video = new Node('video', 1).attr(tinymce.extend({\r
                                        id : node.attr('id'),\r
-                                       width: node.attr('width'),\r
-                                       height: node.attr('height'),\r
+                                       width: normalizeSize(node.attr('width')),\r
+                                       height: normalizeSize(node.attr('height')),\r
                                        style : style\r
                                }, data.video.attrs));\r
 \r
                                // Create new object element\r
                                audio = new Node('audio', 1).attr(tinymce.extend({\r
                                        id : node.attr('id'),\r
-                                       width: node.attr('width'),\r
-                                       height: node.attr('height'),\r
+                                       width: normalizeSize(node.attr('width')),\r
+                                       height: normalizeSize(node.attr('height')),\r
                                        style : style\r
                                }, data.video.attrs));\r
 \r
                                embed.shortEnded = true;\r
                                embed.attr({\r
                                        id: node.attr('id'),\r
-                                       width: node.attr('width'),\r
-                                       height: node.attr('height'),\r
+                                       width: normalizeSize(node.attr('width')),\r
+                                       height: normalizeSize(node.attr('height')),\r
                                        style : style,\r
                                        type: node.attr('type')\r
                                });\r
                                // Create new object element\r
                                object = new Node('object', 1).attr({\r
                                        id : node.attr('id'),\r
-                                       width: node.attr('width'),\r
-                                       height: node.attr('height'),\r
+                                       width: normalizeSize(node.attr('width')),\r
+                                       height: normalizeSize(node.attr('height')),\r
                                        style : style\r
                                });\r
 \r
                                        embed.shortEnded = true;\r
                                        embed.attr({\r
                                                id: node.attr('id'),\r
-                                               width: node.attr('width'),\r
-                                               height: node.attr('height'),\r
+                                               width: normalizeSize(node.attr('width')),\r
+                                               height: normalizeSize(node.attr('height')),\r
                                                style : style,\r
                                                type: typeItem.mimes[0]\r
                                        });\r
 \r
                        if (iframe) {\r
                                // Get width/height\r
-                               width = iframe.attr('width');\r
-                               height = iframe.attr('height');\r
+                               width = normalizeSize(iframe.attr('width'));\r
+                               height = normalizeSize(iframe.attr('height'));\r
                                style = style || iframe.attr('style');\r
                                id = iframe.attr('id');\r
                                hspace = iframe.attr('hspace');\r