Commit f7a7f262 by Dmitry Baranovskiy

Oops, forgot to add vars. And also fix for IE getBBox for text elements.

parent b0b2ee94
...@@ -454,7 +454,7 @@ function Raphael() { ...@@ -454,7 +454,7 @@ function Raphael() {
// SVG // SVG
if (R.svg) { if (R.svg) {
thePath = function (params, pathString, SVG) { var thePath = function (params, pathString, SVG) {
var el = document.createElementNS(SVG.svgns, "path"); var el = document.createElementNS(SVG.svgns, "path");
el.setAttribute("fill", "none"); el.setAttribute("fill", "none");
if (SVG.canvas) { if (SVG.canvas) {
...@@ -640,7 +640,7 @@ function Raphael() { ...@@ -640,7 +640,7 @@ function Raphael() {
} }
return p; return p;
}; };
addGrdientFill = function (o, gradient, SVG) { var addGrdientFill = function (o, gradient, SVG) {
var el = document.createElementNS(SVG.svgns, gradient.type + "Gradient"); var el = document.createElementNS(SVG.svgns, gradient.type + "Gradient");
el.id = "raphael-gradient-" + Raphael.idGenerator++; el.id = "raphael-gradient-" + Raphael.idGenerator++;
if (gradient.vector && gradient.vector.length) { if (gradient.vector && gradient.vector.length) {
...@@ -661,13 +661,13 @@ function Raphael() { ...@@ -661,13 +661,13 @@ function Raphael() {
}; };
o.setAttribute("fill", "url(#" + el.id + ")"); o.setAttribute("fill", "url(#" + el.id + ")");
}; };
updatePosition = function (o) { var updatePosition = function (o) {
if (o.pattern) { if (o.pattern) {
var bbox = o.node.getBBox(); var bbox = o.node.getBBox();
o.pattern.setAttribute("patternTransform", "translate(" + [bbox.x, bbox.y].join(",") + ")"); o.pattern.setAttribute("patternTransform", "translate(" + [bbox.x, bbox.y].join(",") + ")");
} }
}; };
setFillAndStroke = function (o, params) { var setFillAndStroke = function (o, params) {
var dasharray = { var dasharray = {
"-": [3, 1], "-": [3, 1],
".": [1, 1], ".": [1, 1],
...@@ -916,7 +916,7 @@ function Raphael() { ...@@ -916,7 +916,7 @@ function Raphael() {
element.node.parentNode.insertBefore(this.node, element.node); element.node.parentNode.insertBefore(this.node, element.node);
return this; return this;
}; };
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);
el.setAttribute("cy", y); el.setAttribute("cy", y);
...@@ -935,7 +935,7 @@ function Raphael() { ...@@ -935,7 +935,7 @@ function Raphael() {
res.type = "circle"; res.type = "circle";
return res; return res;
}; };
theRect = function (svg, x, y, w, h, r) { var theRect = function (svg, x, y, w, h, r) {
var el = document.createElementNS(svg.svgns, "rect"); var el = document.createElementNS(svg.svgns, "rect");
el.setAttribute("x", x); el.setAttribute("x", x);
el.setAttribute("y", y); el.setAttribute("y", y);
...@@ -963,7 +963,7 @@ function Raphael() { ...@@ -963,7 +963,7 @@ function Raphael() {
res.type = "rect"; res.type = "rect";
return res; return res;
}; };
theEllipse = function (svg, x, y, rx, ry) { var theEllipse = function (svg, x, y, rx, ry) {
var el = document.createElementNS(svg.svgns, "ellipse"); var el = document.createElementNS(svg.svgns, "ellipse");
el.setAttribute("cx", x); el.setAttribute("cx", x);
el.setAttribute("cy", y); el.setAttribute("cy", y);
...@@ -984,7 +984,7 @@ function Raphael() { ...@@ -984,7 +984,7 @@ function Raphael() {
res.type = "ellipse"; res.type = "ellipse";
return res; return res;
}; };
theImage = function (svg, src, x, y, w, h) { var theImage = function (svg, src, x, y, w, h) {
var el = document.createElementNS(svg.svgns, "image"); var el = document.createElementNS(svg.svgns, "image");
el.setAttribute("x", x); el.setAttribute("x", x);
el.setAttribute("y", y); el.setAttribute("y", y);
...@@ -1004,7 +1004,7 @@ function Raphael() { ...@@ -1004,7 +1004,7 @@ function Raphael() {
res.type = "image"; res.type = "image";
return res; return res;
}; };
theText = function (svg, x, y, text) { var theText = function (svg, x, y, text) {
var el = document.createElementNS(svg.svgns, "text"); var el = document.createElementNS(svg.svgns, "text");
el.setAttribute("x", x); el.setAttribute("x", x);
el.setAttribute("y", y); el.setAttribute("y", y);
...@@ -1023,7 +1023,7 @@ function Raphael() { ...@@ -1023,7 +1023,7 @@ function Raphael() {
setFillAndStroke(res, {font: '10px "Arial"', stroke: "none", fill: "#000"}); setFillAndStroke(res, {font: '10px "Arial"', stroke: "none", fill: "#000"});
return res; return res;
}; };
theGroup = function (svg) { var theGroup = function (svg) {
var el = document.createElementNS(svg.svgns, "g"); var el = document.createElementNS(svg.svgns, "g");
if (svg.canvas) { if (svg.canvas) {
svg.canvas.appendChild(el); svg.canvas.appendChild(el);
...@@ -1352,7 +1352,7 @@ function Raphael() { ...@@ -1352,7 +1352,7 @@ function Raphael() {
} }
return p; return p;
}; };
setFillAndStroke = function (o, params) { var setFillAndStroke = function (o, params) {
var s = o.node.style, var s = o.node.style,
res = o; res = o;
o.attrs = o.attrs || {}; o.attrs = o.attrs || {};
...@@ -1457,7 +1457,18 @@ function Raphael() { ...@@ -1457,7 +1457,18 @@ function Raphael() {
res.node.parentNode.removeChild(span); res.node.parentNode.removeChild(span);
} }
}; };
addGrdientFill = function (o, gradient) { var getAngle = function (a, b, c, d) {
var angle = Math.round(Math.atan((parseFloat(c, 10) - parseFloat(a, 10)) / (parseFloat(d, 10) - parseFloat(b, 10))) * 57.29) || 0;
if (!angle && parseFloat(a, 10) < parseFloat(b, 10)) {
angle = 180;
}
angle -= 180;
if (angle < 0) {
angle += 360;
}
return angle;
};
var addGrdientFill = function (o, gradient) {
o.attrs = o.attrs || {}; o.attrs = o.attrs || {};
o.attrs.gradient = gradient; o.attrs.gradient = gradient;
o = o.shape || o[0]; o = o.shape || o[0];
...@@ -1483,8 +1494,8 @@ function Raphael() { ...@@ -1483,8 +1494,8 @@ function Raphael() {
colors.push(gradient.dots[i].offset + " " + gradient.dots[i].color); colors.push(gradient.dots[i].offset + " " + gradient.dots[i].color);
} }
}; };
var fillOpacity = gradient.dots[0].opacity || 1; var fillOpacity = typeof gradient.dots[0].opacity == "undefined" ? 1 : gradient.dots[0].opacity;
var fillOpacity2 = gradient.dots[gradient.dots.length - 1].opacity || 1; var fillOpacity2 = typeof gradient.dots[gradient.dots.length - 1].opacity == "undefined" ? 1 : gradient.dots[gradient.dots.length - 1].opacity;
if (colors) { if (colors) {
fill.colors.value = colors.join(","); fill.colors.value = colors.join(",");
fillOpacity2 += fillOpacity; fillOpacity2 += fillOpacity;
...@@ -1494,8 +1505,7 @@ function Raphael() { ...@@ -1494,8 +1505,7 @@ function Raphael() {
fill.setAttribute("opacity", fillOpacity); fill.setAttribute("opacity", fillOpacity);
fill.setAttribute("opacity2", fillOpacity2); fill.setAttribute("opacity2", fillOpacity2);
if (gradient.vector) { if (gradient.vector) {
var angle = Math.round(Math.atan((parseFloat(gradient.vector[3], 10) - parseFloat(gradient.vector[1], 10)) / (parseFloat(gradient.vector[2], 10) - parseFloat(gradient.vector[0], 10))) * 57.29) || 0; fill.angle = getAngle.apply(null, gradient.vector);
fill.angle = 270 - angle;
} }
if (gradient.type.toLowerCase() == "radial") { if (gradient.type.toLowerCase() == "radial") {
fill.focus = "100%"; fill.focus = "100%";
...@@ -1670,7 +1680,7 @@ function Raphael() { ...@@ -1670,7 +1680,7 @@ function Raphael() {
}; };
return values; return values;
} }
if (this[0].tagName.toLowerCase() == "group") { if (this.node.tagName.toLowerCase() == "group") {
var children = this[0].childNodes; var children = this[0].childNodes;
this.attrs = this.attrs || {}; this.attrs = this.attrs || {};
if (arguments.length == 2) { if (arguments.length == 2) {
...@@ -1730,7 +1740,7 @@ function Raphael() { ...@@ -1730,7 +1740,7 @@ function Raphael() {
element.Group.parentNode.insertBefore(this.Group, element.Group); element.Group.parentNode.insertBefore(this.Group, element.Group);
return this; return this;
}; };
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");
g.appendChild(o); g.appendChild(o);
...@@ -1744,7 +1754,7 @@ function Raphael() { ...@@ -1744,7 +1754,7 @@ function Raphael() {
res.attrs.r = r; res.attrs.r = r;
return res; return res;
}; };
theRect = function (vml, x, y, w, h, r) { var theRect = function (vml, x, y, w, h, r) {
var g = document.createElement("rvml:group"); var g = document.createElement("rvml:group");
var o = document.createElement(r ? "rvml:roundrect" : "rvml:rect"); var o = document.createElement(r ? "rvml:roundrect" : "rvml:rect");
if (r) { if (r) {
...@@ -1763,7 +1773,7 @@ function Raphael() { ...@@ -1763,7 +1773,7 @@ function Raphael() {
res.attrs.r = r; res.attrs.r = r;
return res; return res;
}; };
theEllipse = function (vml, x, y, rx, ry) { var theEllipse = function (vml, x, y, rx, ry) {
var g = document.createElement("rvml:group"); var g = document.createElement("rvml:group");
var o = document.createElement("rvml:oval"); var o = document.createElement("rvml:oval");
g.appendChild(o); g.appendChild(o);
...@@ -1778,7 +1788,7 @@ function Raphael() { ...@@ -1778,7 +1788,7 @@ function Raphael() {
res.attrs.ry = ry; res.attrs.ry = ry;
return res; return res;
}; };
theImage = function (vml, src, x, y, w, h) { var theImage = function (vml, src, x, y, w, h) {
var g = document.createElement("rvml:group"); var g = document.createElement("rvml:group");
var o = document.createElement("rvml:image"); var o = document.createElement("rvml:image");
o.src = src; o.src = src;
...@@ -1793,7 +1803,7 @@ function Raphael() { ...@@ -1793,7 +1803,7 @@ function Raphael() {
res.attrs.h = h; res.attrs.h = h;
return res; return res;
}; };
theText = function (vml, x, y, text) { var theText = function (vml, x, y, text) {
var g = document.createElement("rvml:group"), gs = g.style; var g = document.createElement("rvml:group"), gs = g.style;
var el = document.createElement("rvml:shape"), ol = el.style; var el = document.createElement("rvml:shape"), ol = el.style;
var path = document.createElement("rvml:path"), ps = path.style; var path = document.createElement("rvml:path"), ps = path.style;
...@@ -1826,7 +1836,7 @@ function Raphael() { ...@@ -1826,7 +1836,7 @@ function Raphael() {
setFillAndStroke(res, {font: '10px "Arial"', stroke: "none", fill: "#000"}); setFillAndStroke(res, {font: '10px "Arial"', stroke: "none", fill: "#000"});
return res; return res;
}; };
theGroup = function (vml) { var theGroup = function (vml) {
return this; return this;
}; };
R._create = function () { R._create = function () {
......
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