Commit 399f9560 by Jeff Nichols Committed by Dmitry Baranovskiy

Changed insertBefore() and insertAfter() to have different implementations for…

Changed insertBefore() and insertAfter() to have different implementations for VML and SVG (was broken in VML). Also changed these functions to return 'this' for chaining.

Signed-off-by: Dmitry Baranovskiy <dmitry.baranovskiy@gmail.com>
parent c064e970
...@@ -590,6 +590,18 @@ var Raphael = (function (type) { ...@@ -590,6 +590,18 @@ var Raphael = (function (type) {
} }
return this; return this;
}; };
Element.prototype.insertAfter = function (element) {
if (element.Group.nextSibling) {
element.Group.parentNode.insertBefore(this.Group, element.Group.nextSibling);
} else {
element.Group.parentNode.appendChild(this.Group);
}
return this;
};
Element.prototype.insertBefore = function (element) {
element.Group.parentNode.insertBefore(this.Group, element.Group);
return this;
};
var theCircle = function (vml, x, y, r) { var theCircle = function (vml, x, y, r) {
var g = document.createElement("rvml:group"); var g = document.createElement("rvml:group");
var o = document.createElement("rvml:oval"); var o = document.createElement("rvml:oval");
...@@ -1257,6 +1269,18 @@ var Raphael = (function (type) { ...@@ -1257,6 +1269,18 @@ var Raphael = (function (type) {
} }
return this; return this;
}; };
Element.prototype.insertAfter = function (element) {
if (element.node.nextSibling) {
element.node.parentNode.insertBefore(this.node, element.node.nextSibling);
} else {
element.node.parentNode.appendChild(this.node);
}
return this;
};
Element.prototype.insertBefore = function (element) {
element.node.parentNode.insertBefore(this.node, element.node);
return this;
};
var theCircle = function (svg, x, y, r) { var theCircle = function (svg, x, y, r) {
var el = document.createElementNS(svg.svgns, "circle"); var el = document.createElementNS(svg.svgns, "circle");
el.setAttribute("cx", x); el.setAttribute("cx", x);
...@@ -1700,16 +1724,6 @@ var Raphael = (function (type) { ...@@ -1700,16 +1724,6 @@ var Raphael = (function (type) {
})(); })();
return this; return this;
}; };
Element.prototype.insertAfter = function (element) {
if (element.node.nextSibling) {
element.node.parentNode.insertBefore(this.node, element.node.nextSibling);
} else {
element.node.parentNode.appendChild(this.node);
}
};
Element.prototype.insertBefore = function (element) {
element.node.parentNode.insertBefore(this.node, element.node);
};
C.pathfinder = function (p, path) { C.pathfinder = function (p, path) {
var commands = { var commands = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment