+ function retainAttributesAndInnerHtml(sourceNode, targetNode) {
+ var attrName, attrValue, attribs, ai, innerHtml;
+
+ // Prefix all attributes except width, height and style since we
+ // will add these to the placeholder
+ attribs = sourceNode.attributes;
+ ai = attribs.length;
+ while (ai--) {
+ attrName = attribs[ai].name;
+ attrValue = attribs[ai].value;
+
+ if (attrName !== "width" && attrName !== "height" && attrName !== "style") {
+ if (attrName == "data" || attrName == "src") {
+ attrValue = editor.convertURL(attrValue, attrName);
+ }
+
+ targetNode.attr('data-mce-p-' + attrName, attrValue);
+ }
+ }
+
+ // Place the inner HTML contents inside an escaped attribute
+ // This enables us to copy/paste the fake object
+ innerHtml = sourceNode.firstChild && sourceNode.firstChild.value;
+ if (innerHtml) {
+ targetNode.attr("data-mce-html", escape(innerHtml));
+ targetNode.firstChild = null;
+ }
+ }
+
+ function createPlaceholderNode(node) {
+ var placeHolder, name = node.name;
+
+ placeHolder = new tinymce.html.Node('img', 1);
+ placeHolder.shortEnded = true;
+
+ retainAttributesAndInnerHtml(node, placeHolder);
+
+ placeHolder.attr({
+ width: node.attr('width') || "300",
+ height: node.attr('height') || (name == "audio" ? "30" : "150"),
+ style: node.attr('style'),
+ src: tinymce.Env.transparentSrc,
+ "data-mce-object": name,
+ "class": "mce-object mce-object-" + name
+ });
+
+ return placeHolder;
+ }
+
+ function createPreviewNode(node) {
+ var previewWrapper, previewNode, shimNode, name = node.name;
+
+ previewWrapper = new tinymce.html.Node('span', 1);
+ previewWrapper.attr({
+ contentEditable: 'false',
+ style: node.attr('style'),
+ "data-mce-object": name,
+ "class": "mce-preview-object mce-object-" + name
+ });
+
+ retainAttributesAndInnerHtml(node, previewWrapper);
+
+ previewNode = new tinymce.html.Node(name, 1);
+ previewNode.attr({
+ src: node.attr('src'),
+ allowfullscreen: node.attr('allowfullscreen'),
+ width: node.attr('width') || "300",
+ height: node.attr('height') || (name == "audio" ? "30" : "150"),
+ frameborder: '0'
+ });
+
+ shimNode = new tinymce.html.Node('span', 1);
+ shimNode.attr('class', 'mce-shim');
+
+ previewWrapper.append(previewNode);
+ previewWrapper.append(shimNode);
+
+ return previewWrapper;
+ }
+