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>
This commit is contained in:
Jeff Nichols 2009-01-28 22:29:29 +08:00 committed by Dmitry Baranovskiy
parent c064e970ea
commit 399f9560a7
1 changed files with 24 additions and 10 deletions

34
raphael.js Normal file → Executable file
View File

@ -590,6 +590,18 @@ var Raphael = (function (type) {
}
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 g = document.createElement("rvml:group");
var o = document.createElement("rvml:oval");
@ -1257,6 +1269,18 @@ var Raphael = (function (type) {
}
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 el = document.createElementNS(svg.svgns, "circle");
el.setAttribute("cx", x);
@ -1700,16 +1724,6 @@ var Raphael = (function (type) {
})();
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) {
var commands = {