Browse files

updating raphael.js

  • Loading branch information...
1 parent f7416c3 commit 24c63f3e7103d664f2b56d170834f65f709c7ee8 @mockdeep committed Mar 24, 2012
View
2 lib/raphael-rails/version.rb
@@ -1,5 +1,5 @@
module Raphael
module Rails
- VERSION = "1.5.2"
+ VERSION = "2.1.0"
end
end
View
2 raphael-rails.gemspec
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.name = "raphael-rails"
s.version = Raphael::Rails::VERSION
s.platform = Gem::Platform::RUBY
- s.authors = ["Dmitry Baranovskiy", "Ben Poweski"]
+ s.authors = ["Dmitry Baranovskiy", "Ben Poweski", "Robert Fletcher"]
s.email = ["bpoweski@3factors.com"]
s.homepage = "http://github.com/bpoweski/raphael-rails"
s.summary = %q{Raphael JS as a Rubygem}
View
3,611 reference.html
2,476 additions, 1,135 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
3 vendor/assets/javascripts/README.markdown
@@ -0,0 +1,3 @@
+# Raphaël
+
+Cross-browser vector graphics the easy way. Visit the library website for more information: [http://raphaeljs.com](http://raphaeljs.com/)
View
82 vendor/assets/javascripts/history.md
@@ -0,0 +1,82 @@
+2.1.0 • 2012-03-14
+------------------
+
+ * Put all Eve events into “raphael.” namespace
+ * Refactored path caching
+ * Added x2 and y2 to returning bounding box values
+ * Fixed bug with matrix.f in animation
+ * Method [Paper.print](http://raphaeljs.com/reference.html#Paper.print) now returns all letters as one path without any transformations applied and supports multiline text
+ * New methods
+ * [Element.isPointInside](http://raphaeljs.com/reference.html#Element.isPointInside)
+ * [Paper.getElementsByPoint](http://raphaeljs.com/reference.html#Paper.getElementsByPoint)
+ * [Raphael.bezierBBox](http://raphaeljs.com/reference.html#Raphael.bezierBBox)
+ * [Raphael.isBBoxIntersect](http://raphaeljs.com/reference.html#Raphael.isBBoxIntersect)
+ * [Raphael.isPointInsideBBox](http://raphaeljs.com/reference.html#Raphael.isPointInsideBBox)
+ * [Raphael.isPointInsidePath](http://raphaeljs.com/reference.html#Raphael.isPointInsidePath)
+ * [Raphael.pathBBox](http://raphaeljs.com/reference.html#Raphael.pathBBox)
+ * [Raphael.pathIntersection](http://raphaeljs.com/reference.html#Raphael.pathIntersection)
+ * [Raphael.toMatrix](http://raphaeljs.com/reference.html#Raphael.toMatrix)
+ * [Raphael.transformPath](http://raphaeljs.com/reference.html#Raphael.transformPath)
+
+2.0.2 • 2012-02-08
+------------------
+
+ * Removing of linked element now removes `<a>` as well
+ * Fixed white space recognition in passed strings
+ * Added special case for path that has only one Catmull-Rom curve
+ * Fixed toTransformString method
+ * Fixed animateWith method
+ * Fixed “target” attribute clearing
+ * Fixed bug with changing fill from image to solid colour
+ * fixed renderfix method
+
+2.0.1 • 2011-11-18
+------------------
+
+ * Global variables leakage fix
+ * `toFront` fix for elements with links
+ * Gradient clean up
+ * Added `letter-spacing` attribute
+ * Fixed hsb methods
+ * Fixed image flickering
+ * Improved `toTransformString` method on `matrix`
+ * Fixed drag'n'drop
+ * New method [Paper.add](http://raphaeljs.com/reference.html#Paper.add)
+ * Fix for `clip-path`
+ * Doc update
+
+2.0.0 • 2011-10-03
+------------------
+
+ * Completely changed transformation handling:
+ * `translate()`, `rotate()` and `scale()` are deprecated
+ * `translation`, `rotation` and `scale` attributes are removed (!)
+ * new method `transform()` and new attribute `transform` were introduced
+ * chaining of transformations now allowed
+ * matrix transformation introduced
+ * see [docs](http://raphaeljs.com/reference.html#Element.transform)
+ * Animation API was updated (see [docs](http://raphaeljs.com/reference.html#Raphael.animation))
+ * delay, repeat, [setTime](http://raphaeljs.com/reference.html#Element.status), [status](http://raphaeljs.com/reference.html#Element.setTime)
+ * New methods:
+ * [Paper.setViewBox](http://raphaeljs.com/reference.html#Paper.setViewBox)
+ * [Paper.setStart](http://raphaeljs.com/reference.html#Paper.setStart)
+ * [Paper.setFinish](http://raphaeljs.com/reference.html#Paper.setFinish)
+ * [Paper.forEach](http://raphaeljs.com/reference.html#Paper.forEach)
+ * [Paper.getById](http://raphaeljs.com/reference.html#Paper.getById)
+ * [Paper.getElementByPoint](http://raphaeljs.com/reference.html#Paper.getElementByPoint)
+ * [Element.data](http://raphaeljs.com/reference.html#Element.data)
+ * [Element.glow](http://raphaeljs.com/reference.html#Element.glow)
+ * [Element.onDragOver](http://raphaeljs.com/reference.html#Element.onDragOver)
+ * [Element.removeData](http://raphaeljs.com/reference.html#Element.removeData)
+ * [Raphael.fullfill](http://raphaeljs.com/reference.html#Raphael.fullfill)
+ * [Raphael.matrix](http://raphaeljs.com/reference.html#Raphael.matrix)
+ * [Raphael.parseTransformString](http://raphaeljs.com/reference.html#Raphael.parseTransformString)
+ * [Set.clear](http://raphaeljs.com/reference.html#Set.clear)
+ * [Set.exclude](http://raphaeljs.com/reference.html#Set.exclude)
+ * [Set.forEach](http://raphaeljs.com/reference.html#Set.forEach)
+ * [Set.splice](http://raphaeljs.com/reference.html#Set.splice)
+ * VML completely rewritten
+ * `getBBox` was fixed to take transformations into account
+ * [eve](http://raphaeljs.com/reference.html#eve) was added to the project
+ * Whole new [documentation](http://raphaeljs.com/reference.html)
+ * Various bug fixes
View
21 vendor/assets/javascripts/license.txt
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2008-2010 Dmitry Baranovskiy
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
45 vendor/assets/javascripts/make
@@ -0,0 +1,45 @@
+#!/usr/bin/env node
+var setup = {
+ input: {
+ core: "raphael.core.js",
+ svg: "raphael.svg.js",
+ vml: "raphael.vml.js",
+ eve: "../mywork/eve/eve.js",
+ copy: "copy.js"
+ },
+ output: {
+ "raphael-min.js": function () {
+ return this.copy + "\n" + minify(this.eve + this.core + this.svg + this.vml);
+ },
+ "raphael.js": function () {
+ return this.copy + "\n" + this.eve + "\n\n" + this.core + "\n\n" + this.svg + "\n\n" + this.vml;
+ },
+ "raphael.pro-min.js": function () {
+ return this.copy + "\n" + minify(this.eve + this.core + this.svg);
+ },
+ "raphael.pro.js": function () {
+ return this.copy + "\n" + this.eve + "\n\n" + this.core + "\n\n" + this.svg ;
+ },
+ }
+ },
+ ujs = require("/Users/dmitry/Sites/UglifyJS/uglify-js.js"),
+ jsp = ujs.parser,
+ pro = ujs.uglify,
+ fs = require("fs"),
+ rxdr = /\/\*\\[\s\S]+?\\\*\//g;
+
+function minify(code) {
+ return pro.gen_code(pro.ast_squeeze(pro.ast_mangle(jsp.parse(code))));
+}
+
+var files = {};
+for (var file in setup.input) {
+ files[file] = String(fs.readFileSync(setup.input[file], "utf8")).replace(rxdr, "");
+}
+for (file in setup.output) {
+ (function (file) {
+ fs.writeFile(file, setup.output[file].call(files), function () {
+ console.log("Saved to \033[32m" + file + "\033[0m\n");
+ });
+ })(file);
+}
View
259 vendor/assets/javascripts/plugins/colorpicker.js
@@ -1,259 +0,0 @@
-/*!
- * Color Picker 0.1.0 - Raphael plugin
- *
- * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
- * Based on Color Wheel (http://jweir.github.com/colorwheel) by John Weir (http://famedriver.com)
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
- */
-
- /*
- * Usage
- * var cp = Raphael.colorpicker(x, y, size, "#fff"); // #fff is optional init color
- * cp.color(); // returns "#fff"
- * cp.color("#fc0"); // sets new color
- * cp.onchange = function (color) {
- * // do something with the color when user change it
- * }
- * cp.remove(); // removes widget
- */
-(function (Raphael) {
- Raphael.colorpicker = function (x, y, size, initcolor, element) {
- return new ColorPicker(x, y, size, initcolor, element);
- };
- Raphael.fn.colorPickerIcon = function (x, y, r) {
- var segments = pi * r * 2 / Math.min(r / 8, 4);
- var a = pi / 2 - pi * 2 / segments * 1.5,
- path = ["M", x, y - r, "A", r, r, 0, 0, 1, r * Math.cos(a) + x, y - r * Math.sin(a), "L", x, y, "z"].join();
- for (var i = 0; i < segments; i++) {
- this.path(path).attr({
- stroke: "none",
- fill: "hsb(" + (segments - i) * (255 / segments) + ", 255, 255)",
- rotation: [90 + (360 / segments) * i, x, y]
- });
- }
- return this.circle(x, y, r).attr({
- fill: "r#fff-#fff",
- "fill-opacity": 0,
- "stroke-width": Math.round(r * .03),
- stroke: "#fff"
- });
- };
- var pi = Math.PI;
- function angle(x, y) {
- return (x < 0) * 180 + Math.atan(-y / -x) * 180 / pi;
- }
- var doc = document, win = window,
- addEvent = (function () {
- if (doc.addEventListener) {
- return function (obj, type, fn, element) {
- var f = function (e) {
- return fn.call(element, e);
- };
- obj.addEventListener(type, f, false);
- return function () {
- obj.removeEventListener(type, f, false);
- return true;
- };
- };
- } else if (doc.attachEvent) {
- return function (obj, type, fn, element) {
- var f = function (e) {
- return fn.call(element, e || win.event);
- };
- obj.attachEvent("on" + type, f);
- var detacher = function () {
- obj.detachEvent("on" + type, f);
- return true;
- };
- return detacher;
- };
- }
- })(),
- ColorPicker = function (x, y, size, initcolor, element) {
- size = size || 200;
- var w3 = 3 * size / 200,
- w1 = size / 200,
- fi = 1.6180339887,
- size20 = size / 20,
- size2 = size / 2,
- padding = 2 * size / 200,
- height = size + size20 * 2 + padding * 3,
- t = this,
- H = 1, S = 1, B = 1, s = size - (size20 * 4),
- r = element ? Raphael(element, size, height) : Raphael(x, y, size, height),
- xy = s / 6 + size20 * 2 + padding,
- wh = s * 2 / 3 - padding * 2;
- w1 < 1 && (w1 = 1);
- w3 < 1 && (w3 = 1);
-
-
- r.colorPickerIcon(size2, size2, size2 - padding);
-
- t.cursor = r.set();
- t.cursor.push(r.circle(size2, size2, size20 / 2).attr({
- stroke: "#000",
- opacity: .5,
- "stroke-width": w3
- }));
- t.cursor.push(t.cursor[0].clone().attr({
- stroke: "#fff",
- opacity: 1,
- "stroke-width": w1
- }));
- t.disc = r.circle(size2, size2, size2 - padding).attr({
- fill: "#000",
- "fill-opacity": 0,
- stroke: "none",
- cursor: "crosshair"
- });
- var style = t.disc.node.style;
- style.unselectable = "on";
- style.MozUserSelect = "none";
- style.WebkitUserSelect= "none";
-
- // brightness drawing
- var h = size20 * 2 + 2;
- t.brect = r.rect(padding + h / fi / 2, size + padding * 2, size - padding * 2 - h / fi, h - padding * 2).attr({
- stroke: "#fff",
- fill: "180-#fff-#000"
- });
- t.cursorb = r.set();
- t.cursorb.push(r.rect(size - padding - h / fi, size + padding, ~~(h / fi), h, w3).attr({
- stroke: "#000",
- opacity: .5,
- "stroke-width": w3
- }));
- t.cursorb.push(t.cursorb[0].clone().attr({
- stroke: "#fff",
- opacity: 1,
- "stroke-width": w1
- }));
- t.btop = t.brect.clone().attr({
- stroke: "#000",
- fill: "#000",
- opacity: 0
- });
- style = t.btop.node.style;
- style.unselectable = "on";
- style.MozUserSelect = "none";
- style.WebkitUserSelect= "none";
-
- t.bwidth = ~~(h / fi) / 2;
- t.minx = padding + t.bwidth;
- t.maxx = size - h / fi - padding + t.bwidth;
-
- t.H = t.S = t.B = 1;
- t.padding = padding;
- t.raphael = r;
- t.size2 = size2;
- t.size20 = size20;
- t.x = x;
- t.y = y;
-
- // events
- t.hson = addEvent(t.disc.node, "mousedown", function (e) {
- var scrollY = doc.documentElement.scrollTop || doc.body.scrollTop,
- scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft;
- this.hsOnTheMove = true;
- this.setHS(e.clientX + scrollX - this.x, e.clientY + scrollY - this.y);
- this.docmove = addEvent(doc, "mousemove", this.docOnMove, this);
- this.docup = addEvent(doc, "mouseup", this.docOnUp, this);
- }, t);
- t.bon = addEvent(t.btop.node, "mousedown", function (e) {
- var scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft;
- this.bOnTheMove = true;
- this.setB(e.clientX + scrollX - this.x);
- this.docmove = addEvent(doc, "mousemove", this.docOnMove, this);
- this.docup = addEvent(doc, "mouseup", this.docOnUp, this);
- }, t);
- t.winunload = addEvent(win, "unload", function () {
- this.hson();
- this.bon();
- this.docmove && this.docmove();
- this.docup && this.docup();
- this.winunload();
- }, t);
-
- t.color(initcolor || "#fff");
- this.onchanged && this.onchanged(this.color());
- };
- ColorPicker.prototype.setB = function (x) {
- x < this.minx && (x = this.minx);
- x > this.maxx && (x = this.maxx);
- this.cursorb.attr({x: x - this.bwidth});
- this.B = (x - this.minx) / (this.maxx - this.minx);
- this.onchange && this.onchange(this.color());
- };
- ColorPicker.prototype.setHS = function (x, y) {
- var X = x - this.size2,
- Y = y - this.size2,
- R = this.size2 - this.size20 / 2 - this.padding,
- d = angle(X, Y),
- rd = d * pi / 180;
- isNaN(d) && (d = 0);
- if (X * X + Y * Y > R * R) {
- x = R * Math.cos(rd) + this.size2;
- y = R * Math.sin(rd) + this.size2;
- }
- this.cursor.attr({cx: x, cy: y});
- this.H = (1 - d / 360) % 1;
- this.S = Math.min((X * X + Y * Y) / R / R, 1);
- this.brect.attr({fill: "180-hsb(" + [this.H, this.S] + ",1)-#000"});
- this.onchange && this.onchange(this.color());
- };
- ColorPicker.prototype.docOnMove = function (e) {
- var scrollY = doc.documentElement.scrollTop || doc.body.scrollTop,
- scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft;
- if (this.hsOnTheMove) {
- this.setHS(e.clientX + scrollX - this.x, e.clientY + scrollY - this.y);
- }
- if (this.bOnTheMove) {
- this.setB(e.clientX + scrollX - this.x);
- }
- e.preventDefault && e.preventDefault();
- e.returnValue = false;
- return false;
- };
- ColorPicker.prototype.docOnUp = function (e) {
- this.hsOnTheMove = this.bOnTheMove = false;
- this.docmove();
- delete this.docmove;
- this.docup();
- delete this.docup;
- this.onchanged && this.onchanged(this.color());
- e.preventDefault && e.preventDefault();
- e.stopPropagation && e.stopPropagation();
- e.returnValue = false;
- return false;
- };
- ColorPicker.prototype.remove = function () {
- this.raphael.remove();
- this.color = function () {
- return false;
- };
- };
- ColorPicker.prototype.color = function (color) {
- if (color) {
- color = Raphael.getRGB(color);
- var hex = color.hex;
- color = Raphael.rgb2hsb(color.r, color.g, color.b);
- d = color.h * 360;
- this.H = color.h;
- this.S = color.s;
- this.B = color.b;
-
- this.cursorb.attr({x: this.B * (this.maxx - this.minx) + this.minx - this.bwidth});
- this.brect.attr({fill: "180-hsb(" + [this.H, this.S] + ",1)-#000"});
-
- var d = (1 - this.H) * 360,
- rd = d * pi / 180,
- R = (this.size2 - this.size20 / 2 - this.padding) * this.S,
- x = Math.cos(rd) * R + this.size2,
- y = Math.sin(rd) * R + this.size2;
- this.cursor.attr({cx: x, cy: y});
- return this;
- } else {
- return Raphael.hsb2rgb(this.H, this.S, this.B).hex;
- }
- };
-})(window.Raphael);
View
212 vendor/assets/javascripts/plugins/colorwheel.js
@@ -1,212 +0,0 @@
-(function (Raphael) {
- Raphael.colorwheel = function (x, y, size, initcolor, element) {
- return new ColorWheel(x, y, size, initcolor, element);
- };
- var pi = Math.PI;
- function angle(x, y) {
- return (x < 0) * 180 + Math.atan(-y / -x) * 180 / pi;
- }
- var doc = document, win = window;
- var addEvent = (function () {
- if (doc.addEventListener) {
- return function (obj, type, fn, element) {
- var f = function (e) {
- return fn.call(element, e);
- };
- obj.addEventListener(type, f, false);
- return function () {
- obj.removeEventListener(type, f, false);
- return true;
- };
- };
- } else if (doc.attachEvent) {
- return function (obj, type, fn, element) {
- var f = function (e) {
- return fn.call(element, e || win.event);
- };
- obj.attachEvent("on" + type, f);
- var detacher = function () {
- obj.detachEvent("on" + type, f);
- return true;
- };
- return detacher;
- };
- }
- })();
- var ColorWheel = function (x, y, size, initcolor, element) {
- size = size || 200;
- var w3 = 3 * size / 200,
- w1 = size / 200,
- fi = 1.6180339887,
- segments = pi * size / 5,
- size20 = size / 20,
- size2 = size / 2,
- padding = 2 * size / 200,
- t = this;
-
- var H = 1, S = 1, B = 1, s = size - (size20 * 4);
- var r = element ? Raphael(element, size, size) : Raphael(x, y, size, size),
- xy = s / 6 + size20 * 2 + padding,
- wh = s * 2 / 3 - padding * 2;
- w1 < 1 && (w1 = 1);
- w3 < 1 && (w3 = 1);
-
-
- // ring drawing
- var a = pi / 2 - pi * 2 / segments * 1.3,
- R = size2 - padding,
- R2 = size2 - padding - size20 * 2,
- path = ["M", size2, padding, "A", R, R, 0, 0, 1, R * Math.cos(a) + R + padding, R - R * Math.sin(a) + padding, "L", R2 * Math.cos(a) + R + padding, R - R2 * Math.sin(a) + padding, "A", R2, R2, 0, 0, 0, size2, padding + size20 * 2, "z"].join();
- for (var i = 0; i < segments; i++) {
- r.path(path).attr({
- stroke: "none",
- fill: "hsb(" + i * (255 / segments) + ", 255, 200)",
- rotation: [(360 / segments) * i, size2, size2]
- });
- }
- r.path(["M", size2, padding, "A", R, R, 0, 1, 1, size2 - 1, padding, "l1,0", "M", size2, padding + size20 * 2, "A", R2, R2, 0, 1, 1, size2 - 1, padding + size20 * 2, "l1,0"]).attr({
- "stroke-width": w3,
- stroke: "#fff"
- });
- t.cursorhsb = r.set();
- var h = size20 * 2 + 2;
- t.cursorhsb.push(r.rect(size2 - h / fi / 2, padding - 1, h / fi, h, 3 * size / 200).attr({
- stroke: "#000",
- opacity: .5,
- "stroke-width": w3
- }));
- t.cursorhsb.push(t.cursorhsb[0].clone().attr({
- stroke: "#fff",
- opacity: 1,
- "stroke-width": w1
- }));
- t.ring = r.path(["M", size2, padding, "A", R, R, 0, 1, 1, size2 - 1, padding, "l1,0M", size2, padding + size20 * 2, "A", R2, R2, 0, 1, 1, size2 - 1, padding + size20 * 2, "l1,0"]).attr({
- fill: "#000",
- opacity: 0,
- stroke: "none"
- });
-
- // rect drawing
- t.main = r.rect(xy, xy, wh, wh).attr({
- stroke: "none",
- fill: "#f00",
- opacity: 1
- });
- t.main.clone().attr({
- stroke: "none",
- fill: "0-#fff-#fff",
- opacity: 0
- });
- t.square = r.rect(xy - 1, xy - 1, wh + 2, wh + 2).attr({
- r: 2,
- stroke: "#fff",
- "stroke-width": w3,
- fill: "90-#000-#000",
- opacity: 0,
- cursor: "crosshair"
- });
- t.cursor = r.set();
- t.cursor.push(r.circle(size2, size2, size20 / 2).attr({
- stroke: "#000",
- opacity: .5,
- "stroke-width": w3
- }));
- t.cursor.push(t.cursor[0].clone().attr({
- stroke: "#fff",
- opacity: 1,
- "stroke-width": w1
- }));
- t.H = t.S = t.B = 1;
- t.raphael = r;
- t.size2 = size2;
- t.wh = wh;
- t.x = x;
- t.xy = xy;
- t.y = y;
-
- // events
- t.hsbon = addEvent(t.ring.node, "mousedown", function (e) {
- this.hsbOnTheMove = true;
- this.setH(e.clientX - this.x - this.size2, e.clientY - this.y - this.size2);
- this.docmove = addEvent(doc, "mousemove", this.docOnMove, this);
- this.docup = addEvent(doc, "mouseup", this.docOnUp, this);
- }, t);
- t.clron = addEvent(t.square.node, "mousedown", function (e) {
- this.clrOnTheMove = true;
- this.setSB(e.clientX - this.x, e.clientY - this.y);
- this.docmove = addEvent(doc, "mousemove", this.docOnMove, this);
- this.docup = addEvent(doc, "mouseup", this.docOnUp, this);
- }, t);
- t.winunload = addEvent(win, "unload", function () {
- this.hsbon();
- this.clron();
- this.docmove && this.docmove();
- this.docup && this.docup();
- this.winunload();
- }, t);
-
- t.color(initcolor || "#f00");
- this.onchanged && this.onchanged(this.color());
- };
- ColorWheel.prototype.setH = function (x, y) {
- var d = angle(x, y),
- rd = d * pi / 180;
- this.cursorhsb.rotate(d + 90, this.size2, this.size2);
- this.H = (d + 90) / 360;
- this.main.attr({fill: "hsb(" + this.H + ",1,1)"});
- this.onchange && this.onchange(this.color());
- };
- ColorWheel.prototype.setSB = function (x, y) {
- x < this.size2 - this.wh / 2 && (x = this.size2 - this.wh / 2);
- x > this.size2 + this.wh / 2 && (x = this.size2 + this.wh / 2);
- y < this.size2 - this.wh / 2 && (y = this.size2 - this.wh / 2);
- y > this.size2 + this.wh / 2 && (y = this.size2 + this.wh / 2);
- this.cursor.attr({cx: x, cy: y});
- this.B = 1 - (y - this.xy) / this.wh;
- this.S = (x - this.xy) / this.wh;
- this.onchange && this.onchange(this.color());
- };
- ColorWheel.prototype.docOnMove = function (e) {
- if (this.hsbOnTheMove) {
- this.setH(e.clientX - this.x - this.size2, e.clientY - this.y - this.size2);
- }
- if (this.clrOnTheMove) {
- this.setSB(e.clientX - this.x, e.clientY - this.y);
- }
- e.preventDefault && e.preventDefault();
- e.returnValue = false;
- return false;
- };
- ColorWheel.prototype.docOnUp = function (e) {
- this.hsbOnTheMove = this.clrOnTheMove = false;
- this.docmove();
- delete this.docmove;
- this.docup();
- delete this.docup;
- this.onchanged && this.onchanged(this.color());
- };
- ColorWheel.prototype.remove = function () {
- this.raphael.remove();
- this.color = function () {
- return false;
- };
- };
- ColorWheel.prototype.color = function (color) {
- if (color) {
- color = Raphael.getRGB(color);
- color = Raphael.rgb2hsb(color.r, color.g, color.b);
- var d = color.h * 360;
- this.H = color.h;
- this.S = color.s;
- this.B = color.b;
- this.cursorhsb.rotate(d, this.size2, this.size2);
- this.main.attr({fill: "hsb(" + this.H + ",1,1)"});
- var x = this.S * this.wh + this.xy,
- y = (1 - this.B) * this.wh + this.xy;
- this.cursor.attr({cx: x, cy: y});
- return this;
- } else {
- return Raphael.hsb2rgb(this.H, this.S, this.B).hex;
- }
- };
-})(window.Raphael);
View
16 vendor/assets/javascripts/plugins/jquery.colorpicker.js
@@ -1,16 +0,0 @@
-/*!
- * Color Picker 0.1.0 - Raphael plugin
- *
- * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
- * Based on Color Wheel (http://jweir.github.com/colorwheel) by John Weir (http://famedriver.com)
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
- */
-(function ($, R) {
- $.fn.colorpicker = function (size, initcolor) {
- if (R) {
- var offset = this.offset();
- return R.colorpicker(offset.left, offset.top, size, initcolor, this[0]);
- }
- return null;
- };
-})(window.jQuery, window.Raphael);
View
9 vendor/assets/javascripts/plugins/jquery.colorwheel.js
@@ -1,9 +0,0 @@
-(function ($, R) {
- $.fn.colorwheel = function (size, initcolor) {
- if (R) {
- var offset = this.offset();
- return R.colorwheel(offset.left, offset.top, size, initcolor, this[0]);
- }
- return null;
- };
-})(window.jQuery, window.Raphael);
View
53 vendor/assets/javascripts/plugins/raphael.blur.js
@@ -1,53 +0,0 @@
-/*!
- * Raphael Blur Plugin 0.1
- *
- * Copyright (c) 2009 Dmitry Baranovskiy (http://raphaeljs.com)
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
- */
-
-(function () {
- if (Raphael.vml) {
- var reg = / progid:\S+Blur\([^\)]+\)/g;
- Raphael.el.blur = function (size) {
- var s = this.node.style,
- f = s.filter;
- f = f.replace(reg, "");
- if (size != "none") {
- s.filter = f + " progid:DXImageTransform.Microsoft.Blur(pixelradius=" + (+size || 1.5) + ")";
- s.margin = Raphael.format("-{0}px 0 0 -{0}px", Math.round(+size || 1.5));
- } else {
- s.filter = f;
- s.margin = 0;
- }
- };
- } else {
- var $ = function (el, attr) {
- if (attr) {
- for (var key in attr) if (attr.hasOwnProperty(key)) {
- el.setAttribute(key, attr[key]);
- }
- } else {
- return doc.createElementNS("http://www.w3.org/2000/svg", el);
- }
- };
- Raphael.el.blur = function (size) {
- // Experimental. No WebKit support.
- if (size != "none") {
- var fltr = $("filter"),
- blur = $("feGaussianBlur");
- fltr.id = "r" + (Raphael.idGenerator++).toString(36);
- $(blur, {stdDeviation: +size || 1.5});
- fltr.appendChild(blur);
- this.paper.defs.appendChild(fltr);
- this._blur = fltr;
- $(this.node, {filter: "url(#" + fltr.id + ")"});
- } else {
- if (this._blur) {
- this._blur.parentNode.removeChild(this._blur);
- delete this._blur;
- }
- this.node.removeAttribute("filter");
- }
- };
- }
-})();
View
60 vendor/assets/javascripts/plugins/raphael.path.methods.js
@@ -1,60 +0,0 @@
-/*!
- * Raphael Path Methods Plugin 0.2
- *
- * Copyright (c) 2009 Dmitry Baranovskiy (http://raphaeljs.com)
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
- */
-
-Raphael.el.isAbsolute = true;
-Raphael.el.absolutely = function () {
- this.isAbsolute = 1;
- return this;
-};
-Raphael.el.relatively = function () {
- this.isAbsolute = 0;
- return this;
-};
-Raphael.el.moveTo = function (x, y) {
- this._last = {x: x, y: y};
- return this.attr({path: this.attrs.path + ["m", "M"][+this.isAbsolute] + parseFloat(x) + " " + parseFloat(y)});
-};
-Raphael.el.lineTo = function (x, y) {
- this._last = {x: x, y: y};
- return this.attr({path: this.attrs.path + ["l", "L"][+this.isAbsolute] + parseFloat(x) + " " + parseFloat(y)});
-};
-Raphael.el.arcTo = function (rx, ry, large_arc_flag, sweep_flag, x, y, angle) {
- this._last = {x: x, y: y};
- return this.attr({path: this.attrs.path + ["a", "A"][+this.isAbsolute] + [parseFloat(rx), parseFloat(ry), +angle, large_arc_flag, sweep_flag, parseFloat(x), parseFloat(y)].join(" ")});
-};
-Raphael.el.curveTo = function () {
- var args = Array.prototype.splice.call(arguments, 0, arguments.length),
- d = [0, 0, 0, 0, "s", 0, "c"][args.length] || "";
- this.isAbsolute && (d = d.toUpperCase());
- this._last = {x: args[args.length - 2], y: args[args.length - 1]};
- return this.attr({path: this.attrs.path + d + args});
-};
-Raphael.el.cplineTo = function (x, y, w) {
- this.attr({path: this.attrs.path + ["C", this._last.x + w, this._last.y, x - w, y, x, y]});
- this._last = {x: x, y: y};
- return this;
-};
-Raphael.el.qcurveTo = function () {
- var d = [0, 1, "t", 3, "q"][arguments.length],
- args = Array.prototype.splice.call(arguments, 0, arguments.length);
- if (this.isAbsolute) {
- d = d.toUpperCase();
- }
- this._last = {x: args[args.length - 2], y: args[args.length - 1]};
- return this.attr({path: this.attrs.path + d + args});
-};
-Raphael.el.addRoundedCorner = function (r, dir) {
- var rollback = this.isAbsolute;
- rollback && this.relatively();
- this._last = {x: r * (!!(dir.indexOf("r") + 1) * 2 - 1), y: r * (!!(dir.indexOf("d") + 1) * 2 - 1)};
- this.arcTo(r, r, 0, {"lu": 1, "rd": 1, "ur": 1, "dl": 1}[dir] || 0, this._last.x, this._last.y);
- rollback && this.absolutely();
- return this;
-};
-Raphael.el.andClose = function () {
- return this.attr({path: this.attrs.path + "z"});
-};
View
99 vendor/assets/javascripts/plugins/raphael.primitives.js
@@ -1,99 +0,0 @@
-/*!
- * Raphael Primitives Plugin 0.2
- *
- * Copyright (c) 2009 Dmitry Baranovskiy (http://raphaeljs.com)
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
- */
-
-Raphael.fn.star = function (cx, cy, r, r2, rays) {
- r2 = r2 || r * .382;
- rays = rays || 5;
- var points = ["M", cx, cy + r2, "L"],
- R;
- for (var i = 1; i < rays * 2; i++) {
- R = i % 2 ? r : r2;
- points = points.concat([(cx + R * Math.sin(i * Math.PI / rays)), (cy + R * Math.cos(i * Math.PI / rays))]);
- }
- points.push("z");
- return this.path(points.join());
-};
-Raphael.fn.flower = function (cx, cy, rout, rin, n) {
- rin = rin || rout * .5;
- n = +n < 3 || !n ? 5 : n;
- var points = ["M", cx, cy + rin, "Q"],
- R;
- for (var i = 1; i < n * 2 + 1; i++) {
- R = i % 2 ? rout : rin;
- points = points.concat([+(cx + R * Math.sin(i * Math.PI / n)).toFixed(3), +(cy + R * Math.cos(i * Math.PI / n)).toFixed(3)]);
- }
- points.push("z");
- return this.path(points);
-};
-Raphael.fn.spike = function (cx, cy, rout, rin, n) {
- rin = rin || rout * .5;
- n = +n < 3 || !n ? 5 : n;
- var points = ["M", cx, cy - rout, "Q"],
- R;
- for (var i = 1; i < n * 2 + 1; i++) {
- R = i % 2 ? rin : rout;
- points = points.concat([cx + R * Math.sin(i * Math.PI / n - Math.PI), cy + R * Math.cos(i * Math.PI / n - Math.PI)]);
- }
- points.push("z");
- return this.path(points);
-};
-Raphael.fn.polyline = function () {
- var points = "M".concat(arguments[0] || 0, ",", arguments[1] || 0, "L");
- for (var i = 2, ii = arguments.length - 1; i < ii; i++) {
- points += arguments[i] + "," + arguments[++i];
- }
- arguments[ii].toLowerCase() == "z" && (points += "z");
- return this.path(points);
-};
-Raphael.fn.polygon = function (cx, cy, r, n) {
- n = +n < 3 || !n ? 5 : n;
- var points = ["M", cx, cy - r, "L"],
- R;
- for (var i = 1; i < n; i++) {
- points = points.concat([cx + r * Math.sin(i * Math.PI * 2 / n - Math.PI), cy + r * Math.cos(i * Math.PI * 2 / n - Math.PI)]);
- }
- points.push("z");
- return this.path(points);
-};
-Raphael.fn.line = function (x1, y1, x2, y2) {
- return this.path(["M", x1, y1, "L", x2, y2]);
-};
-Raphael.fn.drawGrid = function (x, y, w, h, wv, hv, color) {
- color = color || "#000";
- var path = ["M", x, y, "L", x + w, y, x + w, y + h, x, y + h, x, y],
- rowHeight = h / hv,
- columnWidth = w / wv;
- for (var i = 1; i < hv; i++) {
- path = path.concat(["M", x, y + i * rowHeight, "L", x + w, y + i * rowHeight]);
- }
- for (var i = 1; i < wv; i++) {
- path = path.concat(["M", x + i * columnWidth, y, "L", x + i * columnWidth, y + h]);
- }
- return this.path(path.join(",")).attr({stroke: color});
-};
-Raphael.fn.square = function (cx, cy, r) {
- r = r * .7;
- return this.rect(cx - r, cy - r, 2 * r, 2 * r);
-};
-Raphael.fn.triangle = function (cx, cy, r) {
- r *= 1.75;
- return this.path("M".concat(cx, ",", cy, "m0-", r * .58, "l", r * .5, ",", r * .87, "-", r, ",0z"));
-};
-Raphael.fn.diamond = function (cx, cy, r) {
- return this.path(["M", cx, cy - r, "l", r, r, -r, r, -r, -r, r, -r, "z"]);
-};
-Raphael.fn.cross = function (cx, cy, r) {
- r = r / 2.5;
- return this.path("M".concat(cx - r, ",", cy, "l", [-r, -r, r, -r, r, r, r, -r, r, r, -r, r, r, r, -r, r, -r, -r, -r, r, -r, -r, "z"]));
-};
-Raphael.fn.plus = function (cx, cy, r) {
- r = r / 2;
- return this.path("M".concat(cx - r / 2, ",", cy - r / 2, "l", [0, -r, r, 0, 0, r, r, 0, 0, r, -r, 0, 0, r, -r, 0, 0, -r, -r, 0, 0, -r, "z"]));
-};
-Raphael.fn.arrow = function (cx, cy, r) {
- return this.path("M".concat(cx - r * .7, ",", cy - r * .4, "l", [r * .6, 0, 0, -r * .4, r, r * .8, -r, r * .8, 0, -r * .4, -r * .6, 0], "z"));
-};
View
52 vendor/assets/javascripts/plugins/raphael.shadow.js
@@ -1,52 +0,0 @@
-/*!
- * Raphael Shadow plugin 0.3
- *
- * Copyright (c) 2008 - 2009 Dmitry Baranovskiy (http://raphaeljs.com)
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
- */
-Raphael.shadow = function (x, y, w, h, options) {
- // options format: {
- // size: 0..1, shadow size
- // color: "#000", placeholder colour
- // stroke: "#000", placeholder stroke colour
- // shadow: "#000", shadow colour
- // target: "someID" | htmlElement
- // r: 5, radius of placeholder rounded corners
- // }
- options = options || {};
- var t = ~~(size * .3 + .5),
- size = (options.size || 1) * 10,
- color = options.color || "#fff",
- stroke = options.stroke || color,
- shadowColor = options.shadow || "#000",
- target = options.target || null,
- R = options.r == null ? 3 : options.r,
- s = size,
- b = size * 2,
- r = b + s,
- rg = this.format("r{0}-{0}", shadowColor),
- rect = "rect",
- none = "none",
- res,
- set;
-
- if (target) {
- res = this(target, w + (x = s) * 2, h + (y = t) + b);
- } else {
- res = this(x - s, y - t, w + (x = s) * 2, h + (y = t) + b);
- }
-
- set = res.set(
- res.rect(x - s, y - t, b + s, h + y + b).attr({stroke: none, fill: this.format("180-{0}-{0}", shadowColor), opacity: 0, "clip-rect": [x - s + 1, y - t + r, b, h + y + b - r * 2 + .9]}),
- res.rect(x + w - b, y - t, b + s, h + y + b).attr({stroke: none, fill: this.format("0-{0}-{0}", shadowColor), opacity: 0, "clip-rect": [x + w - s + 1, y - t + r, b, h + y + b - r * 2]}),
- res.rect(x + b - 1, y + h - s, w + b, b + s).attr({stroke: none, fill: this.format("270-{0}-{0}", shadowColor), opacity: 0, "clip-rect": [x + b, y + h - s, w + b - r * 2, b + s]}),
- res.rect(x + s - 1, y - t, w + b, b + s).attr({stroke: none, fill: this.format("90-{0}-{0}", shadowColor), opacity: 0, "clip-rect": [x + b, y - t, w + b - r * 2, s + t + 1]}),
- res.circle(x + b, y + h - s, r).attr({stroke: none, fill: rg, opacity: 0, "clip-rect": [x - s, y + h - s + .999, r, r]}),
- res.circle(x + w - b, y + h - s, r).attr({stroke: none, fill: rg, opacity: 0, "clip-rect": [x + w - b, y + h - s, r, r]}),
- res.circle(x + b, y - t + r, r).attr({stroke: none, fill: rg, opacity: 0, "clip-rect": [x - s, y - t, r, r]}),
- res.circle(x + w - b, y - t + r, r).attr({stroke: none, fill: rg, opacity: 0, "clip-rect": [x + w - b, y - t, r, r]}),
- res.rect(x, y, w, h, R).attr({fill: color, stroke: stroke})
- );
-
- return set[0].paper;
-};
View
17 vendor/assets/javascripts/raphael-min.js
10 additions, 7 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
5,189 vendor/assets/javascripts/raphael.core.js
5,189 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
6,868 vendor/assets/javascripts/raphael.js
4,479 additions, 2,389 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
1,360 vendor/assets/javascripts/raphael.svg.js
@@ -0,0 +1,1360 @@
+// ┌─────────────────────────────────────────────────────────────────────┐ \\
+// │ Raphaël - JavaScript Vector Library │ \\
+// ├─────────────────────────────────────────────────────────────────────┤ \\
+// │ SVG Module │ \\
+// ├─────────────────────────────────────────────────────────────────────┤ \\
+// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
+// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
+// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
+// └─────────────────────────────────────────────────────────────────────┘ \\
+window.Raphael.svg && function (R) {
+ var has = "hasOwnProperty",
+ Str = String,
+ toFloat = parseFloat,
+ toInt = parseInt,
+ math = Math,
+ mmax = math.max,
+ abs = math.abs,
+ pow = math.pow,
+ separator = /[, ]+/,
+ eve = R.eve,
+ E = "",
+ S = " ";
+ var xlink = "http://www.w3.org/1999/xlink",
+ markers = {
+ block: "M5,0 0,2.5 5,5z",
+ classic: "M5,0 0,2.5 5,5 3.5,3 3.5,2z",
+ diamond: "M2.5,0 5,2.5 2.5,5 0,2.5z",
+ open: "M6,1 1,3.5 6,6",
+ oval: "M2.5,0A2.5,2.5,0,0,1,2.5,5 2.5,2.5,0,0,1,2.5,0z"
+ },
+ markerCounter = {};
+ R.toString = function () {
+ return "Your browser supports SVG.\nYou are running Rapha\xebl " + this.version;
+ };
+ var $ = function (el, attr) {
+ if (attr) {
+ if (typeof el == "string") {
+ el = $(el);
+ }
+ for (var key in attr) if (attr[has](key)) {
+ if (key.substring(0, 6) == "xlink:") {
+ el.setAttributeNS(xlink, key.substring(6), Str(attr[key]));
+ } else {
+ el.setAttribute(key, Str(attr[key]));
+ }
+ }
+ } else {
+ el = R._g.doc.createElementNS("http://www.w3.org/2000/svg", el);
+ el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)");
+ }
+ return el;
+ },
+ addGradientFill = function (element, gradient) {
+ var type = "linear",
+ id = element.id + gradient,
+ fx = .5, fy = .5,
+ o = element.node,
+ SVG = element.paper,
+ s = o.style,
+ el = R._g.doc.getElementById(id);
+ if (!el) {
+ gradient = Str(gradient).replace(R._radial_gradient, function (all, _fx, _fy) {
+ type = "radial";
+ if (_fx && _fy) {
+ fx = toFloat(_fx);
+ fy = toFloat(_fy);
+ var dir = ((fy > .5) * 2 - 1);
+ pow(fx - .5, 2) + pow(fy - .5, 2) > .25 &&
+ (fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) &&
+ fy != .5 &&
+ (fy = fy.toFixed(5) - 1e-5 * dir);
+ }
+ return E;
+ });
+ gradient = gradient.split(/\s*\-\s*/);
+ if (type == "linear") {
+ var angle = gradient.shift();
+ angle = -toFloat(angle);
+ if (isNaN(angle)) {
+ return null;
+ }
+ var vector = [0, 0, math.cos(R.rad(angle)), math.sin(R.rad(angle))],
+ max = 1 / (mmax(abs(vector[2]), abs(vector[3])) || 1);
+ vector[2] *= max;
+ vector[3] *= max;
+ if (vector[2] < 0) {
+ vector[0] = -vector[2];
+ vector[2] = 0;
+ }
+ if (vector[3] < 0) {
+ vector[1] = -vector[3];
+ vector[3] = 0;
+ }
+ }
+ var dots = R._parseDots(gradient);
+ if (!dots) {
+ return null;
+ }
+ id = id.replace(/[\(\)\s,\xb0#]/g, "_");
+
+ if (element.gradient && id != element.gradient.id) {
+ SVG.defs.removeChild(element.gradient);
+ delete element.gradient;
+ }
+
+ if (!element.gradient) {
+ el = $(type + "Gradient", {id: id});
+ element.gradient = el;
+ $(el, type == "radial" ? {
+ fx: fx,
+ fy: fy
+ } : {
+ x1: vector[0],
+ y1: vector[1],
+ x2: vector[2],
+ y2: vector[3],
+ gradientTransform: element.matrix.invert()
+ });
+ SVG.defs.appendChild(el);
+ for (var i = 0, ii = dots.length; i < ii; i++) {
+ el.appendChild($("stop", {
+ offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%",
+ "stop-color": dots[i].color || "#fff"
+ }));
+ }
+ }
+ }
+ $(o, {
+ fill: "url(#" + id + ")",
+ opacity: 1,
+ "fill-opacity": 1
+ });
+ s.fill = E;
+ s.opacity = 1;
+ s.fillOpacity = 1;
+ return 1;
+ },
+ updatePosition = function (o) {
+ var bbox = o.getBBox(1);
+ $(o.pattern, {patternTransform: o.matrix.invert() + " translate(" + bbox.x + "," + bbox.y + ")"});
+ },
+ addArrow = function (o, value, isEnd) {
+ if (o.type == "path") {
+ var values = Str(value).toLowerCase().split("-"),
+ p = o.paper,
+ se = isEnd ? "end" : "start",
+ node = o.node,
+ attrs = o.attrs,
+ stroke = attrs["stroke-width"],
+ i = values.length,
+ type = "classic",
+ from,
+ to,
+ dx,
+ refX,
+ attr,
+ w = 3,
+ h = 3,
+ t = 5;
+ while (i--) {
+ switch (values[i]) {
+ case "block":
+ case "classic":
+ case "oval":
+ case "diamond":
+ case "open":
+ case "none":
+ type = values[i];
+ break;
+ case "wide": h = 5; break;
+ case "narrow": h = 2; break;
+ case "long": w = 5; break;
+ case "short": w = 2; break;
+ }
+ }
+ if (type == "open") {
+ w += 2;
+ h += 2;
+ t += 2;
+ dx = 1;
+ refX = isEnd ? 4 : 1;
+ attr = {
+ fill: "none",
+ stroke: attrs.stroke
+ };
+ } else {
+ refX = dx = w / 2;
+ attr = {
+ fill: attrs.stroke,
+ stroke: "none"
+ };
+ }
+ if (o._.arrows) {
+ if (isEnd) {
+ o._.arrows.endPath && markerCounter[o._.arrows.endPath]--;
+ o._.arrows.endMarker && markerCounter[o._.arrows.endMarker]--;
+ } else {
+ o._.arrows.startPath && markerCounter[o._.arrows.startPath]--;
+ o._.arrows.startMarker && markerCounter[o._.arrows.startMarker]--;
+ }
+ } else {
+ o._.arrows = {};
+ }
+ if (type != "none") {
+ var pathId = "raphael-marker-" + type,
+ markerId = "raphael-marker-" + se + type + w + h;
+ if (!R._g.doc.getElementById(pathId)) {
+ p.defs.appendChild($($("path"), {
+ "stroke-linecap": "round",
+ d: markers[type],
+ id: pathId
+ }));
+ markerCounter[pathId] = 1;
+ } else {
+ markerCounter[pathId]++;
+ }
+ var marker = R._g.doc.getElementById(markerId),
+ use;
+ if (!marker) {
+ marker = $($("marker"), {
+ id: markerId,
+ markerHeight: h,
+ markerWidth: w,
+ orient: "auto",
+ refX: refX,
+ refY: h / 2
+ });
+ use = $($("use"), {
+ "xlink:href": "#" + pathId,
+ transform: (isEnd ? "rotate(180 " + w / 2 + " " + h / 2 + ") " : E) + "scale(" + w / t + "," + h / t + ")",
+ "stroke-width": (1 / ((w / t + h / t) / 2)).toFixed(4)
+ });
+ marker.appendChild(use);
+ p.defs.appendChild(marker);
+ markerCounter[markerId] = 1;
+ } else {
+ markerCounter[markerId]++;
+ use = marker.getElementsByTagName("use")[0];
+ }
+ $(use, attr);
+ var delta = dx * (type != "diamond" && type != "oval");
+ if (isEnd) {
+ from = o._.arrows.startdx * stroke || 0;
+ to = R.getTotalLength(attrs.path) - delta * stroke;
+ } else {
+ from = delta * stroke;
+ to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);
+ }
+ attr = {};
+ attr["marker-" + se] = "url(#" + markerId + ")";
+ if (to || from) {
+ attr.d = Raphael.getSubpath(attrs.path, from, to);
+ }
+ $(node, attr);
+ o._.arrows[se + "Path"] = pathId;
+ o._.arrows[se + "Marker"] = markerId;
+ o._.arrows[se + "dx"] = delta;
+ o._.arrows[se + "Type"] = type;
+ o._.arrows[se + "String"] = value;
+ } else {
+ if (isEnd) {
+ from = o._.arrows.startdx * stroke || 0;
+ to = R.getTotalLength(attrs.path) - from;
+ } else {
+ from = 0;
+ to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);
+ }
+ o._.arrows[se + "Path"] && $(node, {d: Raphael.getSubpath(attrs.path, from, to)});
+ delete o._.arrows[se + "Path"];
+ delete o._.arrows[se + "Marker"];
+ delete o._.arrows[se + "dx"];
+ delete o._.arrows[se + "Type"];
+ delete o._.arrows[se + "String"];
+ }
+ for (attr in markerCounter) if (markerCounter[has](attr) && !markerCounter[attr]) {
+ var item = R._g.doc.getElementById(attr);
+ item && item.parentNode.removeChild(item);
+ }
+ }
+ },
+ dasharray = {
+ "": [0],
+ "none": [0],
+ "-": [3, 1],
+ ".": [1, 1],
+ "-.": [3, 1, 1, 1],
+ "-..": [3, 1, 1, 1, 1, 1],
+ ". ": [1, 3],
+ "- ": [4, 3],
+ "--": [8, 3],
+ "- .": [4, 3, 1, 3],
+ "--.": [8, 3, 1, 3],
+ "--..": [8, 3, 1, 3, 1, 3]
+ },
+ addDashes = function (o, value, params) {
+ value = dasharray[Str(value).toLowerCase()];
+ if (value) {
+ var width = o.attrs["stroke-width"] || "1",
+ butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,
+ dashes = [],
+ i = value.length;
+ while (i--) {
+ dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt;
+ }
+ $(o.node, {"stroke-dasharray": dashes.join(",")});
+ }
+ },
+ setFillAndStroke = function (o, params) {
+ var node = o.node,
+ attrs = o.attrs,
+ vis = node.style.visibility;
+ node.style.visibility = "hidden";
+ for (var att in params) {
+ if (params[has](att)) {
+ if (!R._availableAttrs[has](att)) {
+ continue;
+ }
+ var value = params[att];
+ attrs[att] = value;
+ switch (att) {
+ case "blur":
+ o.blur(value);
+ break;
+ case "href":
+ case "title":
+ case "target":
+ var pn = node.parentNode;
+ if (pn.tagName.toLowerCase() != "a") {
+ var hl = $("a");
+ pn.insertBefore(hl, node);
+ hl.appendChild(node);
+ pn = hl;
+ }
+ if (att == "target") {
+ pn.setAttributeNS(xlink, "show", value == "blank" ? "new" : value);
+ } else {
+ pn.setAttributeNS(xlink, att, value);
+ }
+ break;
+ case "cursor":
+ node.style.cursor = value;
+ break;
+ case "transform":
+ o.transform(value);
+ break;
+ case "arrow-start":
+ addArrow(o, value);
+ break;
+ case "arrow-end":
+ addArrow(o, value, 1);
+ break;
+ case "clip-rect":
+ var rect = Str(value).split(separator);
+ if (rect.length == 4) {
+ o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode);
+ var el = $("clipPath"),
+ rc = $("rect");
+ el.id = R.createUUID();
+ $(rc, {
+ x: rect[0],
+ y: rect[1],
+ width: rect[2],
+ height: rect[3]
+ });
+ el.appendChild(rc);
+ o.paper.defs.appendChild(el);
+ $(node, {"clip-path": "url(#" + el.id + ")"});
+ o.clip = rc;
+ }
+ if (!value) {
+ var path = node.getAttribute("clip-path");
+ if (path) {
+ var clip = R._g.doc.getElementById(path.replace(/(^url\(#|\)$)/g, E));
+ clip && clip.parentNode.removeChild(clip);
+ $(node, {"clip-path": E});
+ delete o.clip;
+ }
+ }
+ break;
+ case "path":
+ if (o.type == "path") {
+ $(node, {d: value ? attrs.path = R._pathToAbsolute(value) : "M0,0"});
+ o._.dirty = 1;
+ if (o._.arrows) {
+ "startString" in o._.arrows && addArrow(o, o._.arrows.startString);
+ "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);
+ }
+ }
+ break;
+ case "width":
+ node.setAttribute(att, value);
+ o._.dirty = 1;
+ if (attrs.fx) {
+ att = "x";
+ value = attrs.x;
+ } else {
+ break;
+ }
+ case "x":
+ if (attrs.fx) {
+ value = -attrs.x - (attrs.width || 0);
+ }
+ case "rx":
+ if (att == "rx" && o.type == "rect") {
+ break;
+ }
+ case "cx":
+ node.setAttribute(att, value);
+ o.pattern && updatePosition(o);
+ o._.dirty = 1;
+ break;
+ case "height":
+ node.setAttribute(att, value);
+ o._.dirty = 1;
+ if (attrs.fy) {
+ att = "y";
+ value = attrs.y;
+ } else {
+ break;
+ }
+ case "y":
+ if (attrs.fy) {
+ value = -attrs.y - (attrs.height || 0);
+ }
+ case "ry":
+ if (att == "ry" && o.type == "rect") {
+ break;
+ }
+ case "cy":
+ node.setAttribute(att, value);
+ o.pattern && updatePosition(o);
+ o._.dirty = 1;
+ break;
+ case "r":
+ if (o.type == "rect") {
+ $(node, {rx: value, ry: value});
+ } else {
+ node.setAttribute(att, value);
+ }
+ o._.dirty = 1;
+ break;
+ case "src":
+ if (o.type == "image") {
+ node.setAttributeNS(xlink, "href", value);
+ }
+ break;
+ case "stroke-width":
+ if (o._.sx != 1 || o._.sy != 1) {
+ value /= mmax(abs(o._.sx), abs(o._.sy)) || 1;
+ }
+ if (o.paper._vbSize) {
+ value *= o.paper._vbSize;
+ }
+ node.setAttribute(att, value);
+ if (attrs["stroke-dasharray"]) {
+ addDashes(o, attrs["stroke-dasharray"], params);
+ }
+ if (o._.arrows) {
+ "startString" in o._.arrows && addArrow(o, o._.arrows.startString);
+ "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);
+ }
+ break;
+ case "stroke-dasharray":
+ addDashes(o, value, params);
+ break;
+ case "fill":
+ var isURL = Str(value).match(R._ISURL);
+ if (isURL) {
+ el = $("pattern");
+ var ig = $("image");
+ el.id = R.createUUID();
+ $(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1});
+ $(ig, {x: 0, y: 0, "xlink:href": isURL[1]});
+ el.appendChild(ig);
+
+ (function (el) {
+ R._preload(isURL[1], function () {
+ var w = this.offsetWidth,
+ h = this.offsetHeight;
+ $(el, {width: w, height: h});
+ $(ig, {width: w, height: h});
+ o.paper.safari();
+ });
+ })(el);
+ o.paper.defs.appendChild(el);
+ $(node, {fill: "url(#" + el.id + ")"});
+ o.pattern = el;
+ o.pattern && updatePosition(o);
+ break;
+ }
+ var clr = R.getRGB(value);
+ if (!clr.error) {
+ delete params.gradient;
+ delete attrs.gradient;
+ !R.is(attrs.opacity, "undefined") &&
+ R.is(params.opacity, "undefined") &&
+ $(node, {opacity: attrs.opacity});
+ !R.is(attrs["fill-opacity"], "undefined") &&
+ R.is(params["fill-opacity"], "undefined") &&
+ $(node, {"fill-opacity": attrs["fill-opacity"]});
+ } else if ((o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value)) {
+ if ("opacity" in attrs || "fill-opacity" in attrs) {
+ var gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E));
+ if (gradient) {
+ var stops = gradient.getElementsByTagName("stop");
+ $(stops[stops.length - 1], {"stop-opacity": ("opacity" in attrs ? attrs.opacity : 1) * ("fill-opacity" in attrs ? attrs["fill-opacity"] : 1)});
+ }
+ }
+ attrs.gradient = value;
+ attrs.fill = "none";
+ break;
+ }
+ clr[has]("opacity") && $(node, {"fill-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});
+ case "stroke":
+ clr = R.getRGB(value);
+ node.setAttribute(att, clr.hex);
+ att == "stroke" && clr[has]("opacity") && $(node, {"stroke-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});
+ if (att == "stroke" && o._.arrows) {
+ "startString" in o._.arrows && addArrow(o, o._.arrows.startString);
+ "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);
+ }
+ break;
+ case "gradient":
+ (o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value);
+ break;
+ case "opacity":
+ if (attrs.gradient && !attrs[has]("stroke-opacity")) {
+ $(node, {"stroke-opacity": value > 1 ? value / 100 : value});
+ }
+ // fall
+ case "fill-opacity":
+ if (attrs.gradient) {
+ gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E));
+ if (gradient) {
+ stops = gradient.getElementsByTagName("stop");
+ $(stops[stops.length - 1], {"stop-opacity": value});
+ }
+ break;
+ }
+ default:
+ att == "font-size" && (value = toInt(value, 10) + "px");
+ var cssrule = att.replace(/(\-.)/g, function (w) {
+ return w.substring(1).toUpperCase();
+ });
+ node.style[cssrule] = value;
+ o._.dirty = 1;
+ node.setAttribute(att, value);
+ break;
+ }
+ }
+ }
+
+ tuneText(o, params);
+ node.style.visibility = vis;
+ },
+ leading = 1.2,
+ tuneText = function (el, params) {
+ if (el.type != "text" || !(params[has]("text") || params[has]("font") || params[has]("font-size") || params[has]("x") || params[has]("y"))) {
+ return;
+ }
+ var a = el.attrs,
+ node = el.node,
+ fontSize = node.firstChild ? toInt(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size"), 10) : 10;
+
+ if (params[has]("text")) {
+ a.text = params.text;
+ while (node.firstChild) {
+ node.removeChild(node.firstChild);
+ }
+ var texts = Str(params.text).split("\n"),
+ tspans = [],
+ tspan;
+ for (var i = 0, ii = texts.length; i < ii; i++) {
+ tspan = $("tspan");
+ i && $(tspan, {dy: fontSize * leading, x: a.x});
+ tspan.appendChild(R._g.doc.createTextNode(texts[i]));
+ node.appendChild(tspan);
+ tspans[i] = tspan;
+ }
+ } else {
+ tspans = node.getElementsByTagName("tspan");
+ for (i = 0, ii = tspans.length; i < ii; i++) if (i) {
+ $(tspans[i], {dy: fontSize * leading, x: a.x});
+ } else {
+ $(tspans[0], {dy: 0});
+ }
+ }
+ $(node, {x: a.x, y: a.y});
+ el._.dirty = 1;
+ var bb = el._getBBox(),
+ dif = a.y - (bb.y + bb.height / 2);
+ dif && R.is(dif, "finite") && $(tspans[0], {dy: dif});
+ },
+ Element = function (node, svg) {
+ var X = 0,
+ Y = 0;
+ /*\
+ * Element.node
+ [ property (object) ]
+ **
+ * Gives you a reference to the DOM object, so you can assign event handlers or just mess around.
+ **
+ * Note: Don’t mess with it.
+ > Usage
+ | // draw a circle at coordinate 10,10 with radius of 10
+ | var c = paper.circle(10, 10, 10);
+ | c.node.onclick = function () {
+ | c.attr("fill", "red");
+ | };
+ \*/
+ this[0] = this.node = node;
+ /*\
+ * Element.raphael
+ [ property (object) ]
+ **
+ * Internal reference to @Raphael object. In case it is not available.
+ > Usage
+ | Raphael.el.red = function () {
+ | var hsb = this.paper.raphael.rgb2hsb(this.attr("fill"));
+ | hsb.h = 1;
+ | this.attr({fill: this.paper.raphael.hsb2rgb(hsb).hex});
+ | }
+ \*/
+ node.raphael = true;
+ /*\
+ * Element.id
+ [ property (number) ]
+ **
+ * Unique id of the element. Especially usesful when you want to listen to events of the element,
+ * because all events are fired in format `<module>.<action>.<id>`. Also useful for @Paper.getById method.
+ \*/
+ this.id = R._oid++;
+ node.raphaelid = this.id;
+ this.matrix = R.matrix();
+ this.realPath = null;
+ /*\
+ * Element.paper
+ [ property (object) ]
+ **
+ * Internal reference to “paper” where object drawn. Mainly for use in plugins and element extensions.
+ > Usage
+ | Raphael.el.cross = function () {
+ | this.attr({fill: "red"});
+ | this.paper.path("M10,10L50,50M50,10L10,50")
+ | .attr({stroke: "red"});
+ | }
+ \*/
+ this.paper = svg;
+ this.attrs = this.attrs || {};
+ this._ = {
+ transform: [],
+ sx: 1,
+ sy: 1,
+ deg: 0,
+ dx: 0,
+ dy: 0,
+ dirty: 1
+ };
+ !svg.bottom && (svg.bottom = this);
+ /*\
+ * Element.prev
+ [ property (object) ]
+ **
+ * Reference to the previous element in the hierarchy.
+ \*/
+ this.prev = svg.top;
+ svg.top && (svg.top.next = this);
+ svg.top = this;
+ /*\
+ * Element.next
+ [ property (object) ]
+ **
+ * Reference to the next element in the hierarchy.
+ \*/
+ this.next = null;
+ },
+ elproto = R.el;
+
+ Element.prototype = elproto;
+ elproto.constructor = Element;
+
+ R._engine.path = function (pathString, SVG) {
+ var el = $("path");
+ SVG.canvas && SVG.canvas.appendChild(el);
+ var p = new Element(el, SVG);
+ p.type = "path";
+ setFillAndStroke(p, {
+ fill: "none",
+ stroke: "#000",
+ path: pathString
+ });
+ return p;
+ };
+ /*\
+ * Element.rotate
+ [ method ]
+ **
+ * Deprecated! Use @Element.transform instead.
+ * Adds rotation by given angle around given point to the list of
+ * transformations of the element.
+ > Parameters
+ - deg (number) angle in degrees
+ - cx (number) #optional x coordinate of the centre of rotation
+ - cy (number) #optional y coordinate of the centre of rotation
+ * If cx & cy aren’t specified centre of the shape is used as a point of rotation.
+ = (object) @Element
+ \*/
+ elproto.rotate = function (deg, cx, cy) {
+ if (this.removed) {
+ return this;
+ }
+ deg = Str(deg).split(separator);
+ if (deg.length - 1) {
+ cx = toFloat(deg[1]);
+ cy = toFloat(deg[2]);
+ }
+ deg = toFloat(deg[0]);
+ (cy == null) && (cx = cy);
+ if (cx == null || cy == null) {
+ var bbox = this.getBBox(1);
+ cx = bbox.x + bbox.width / 2;
+ cy = bbox.y + bbox.height / 2;
+ }
+ this.transform(this._.transform.concat([["r", deg, cx, cy]]));
+ return this;
+ };
+ /*\
+ * Element.scale
+ [ method ]
+ **
+ * Deprecated! Use @Element.transform instead.
+ * Adds scale by given amount relative to given point to the list of
+ * transformations of the element.
+ > Parameters
+ - sx (number) horisontal scale amount
+ - sy (number) vertical scale amount
+ - cx (number) #optional x coordinate of the centre of scale
+ - cy (number) #optional y coordinate of the centre of scale
+ * If cx & cy aren’t specified centre of the shape is used instead.
+ = (object) @Element
+ \*/
+ elproto.scale = function (sx, sy, cx, cy) {
+ if (this.removed) {
+ return this;
+ }
+ sx = Str(sx).split(separator);
+ if (sx.length - 1) {
+ sy = toFloat(sx[1]);
+ cx = toFloat(sx[2]);
+ cy = toFloat(sx[3]);
+ }
+ sx = toFloat(sx[0]);
+ (sy == null) && (sy = sx);
+ (cy == null) && (cx = cy);
+ if (cx == null || cy == null) {
+ var bbox = this.getBBox(1);
+ }
+ cx = cx == null ? bbox.x + bbox.width / 2 : cx;
+ cy = cy == null ? bbox.y + bbox.height / 2 : cy;
+ this.transform(this._.transform.concat([["s", sx, sy, cx, cy]]));
+ return this;
+ };
+ /*\
+ * Element.translate
+ [ method ]
+ **
+ * Deprecated! Use @Element.transform instead.
+ * Adds translation by given amount to the list of transformations of the element.
+ > Parameters
+ - dx (number) horisontal shift
+ - dy (number) vertical shift
+ = (object) @Element
+ \*/
+ elproto.translate = function (dx, dy) {
+ if (this.removed) {
+ return this;
+ }
+ dx = Str(dx).split(separator);
+ if (dx.length - 1) {
+ dy = toFloat(dx[1]);
+ }
+ dx = toFloat(dx[0]) || 0;
+ dy = +dy || 0;
+ this.transform(this._.transform.concat([["t", dx, dy]]));
+ return this;
+ };
+ /*\
+ * Element.transform
+ [ method ]
+ **
+ * Adds transformation to the element which is separate to other attributes,
+ * i.e. translation doesn’t change `x` or `y` of the rectange. The format
+ * of transformation string is similar to the path string syntax:
+ | "t100,100r30,100,100s2,2,100,100r45s1.5"
+ * Each letter is a command. There are four commands: `t` is for translate, `r` is for rotate, `s` is for
+ * scale and `m` is for matrix.
+ *
+ * There are also alternative “absolute” translation, rotation and scale: `T`, `R` and `S`. They will not take previous transformation into account. For example, `...T100,0` will always move element 100 px horisontally, while `...t100,0` could move it vertically if there is `r90` before. Just compare results of `r90t100,0` and `r90T100,0`.
+ *
+ * So, the example line above could be read like “translate by 100, 100; rotate 30° around 100, 100; scale twice around 100, 100;
+ * rotate 45° around centre; scale 1.5 times relative to centre”. As you can see rotate and scale commands have origin
+ * coordinates as optional parameters, the default is the centre point of the element.
+ * Matrix accepts six parameters.
+ > Usage
+ | var el = paper.rect(10, 20, 300, 200);
+ | // translate 100, 100, rotate 45°, translate -100, 0
+ | el.transform("t100,100r45t-100,0");
+ | // if you want you can append or prepend transformations
+ | el.transform("...t50,50");
+ | el.transform("s2...");
+ | // or even wrap
+ | el.transform("t50,50...t-50-50");
+ | // to reset transformation call method with empty string
+ | el.transform("");
+ | // to get current value call it without parameters
+ | console.log(el.transform());
+ > Parameters
+ - tstr (string) #optional transformation string
+ * If tstr isn’t specified
+ = (string) current transformation string
+ * else
+ = (object) @Element
+ \*/
+ elproto.transform = function (tstr) {
+ var _ = this._;
+ if (tstr == null) {
+ return _.transform;
+ }
+ R._extractTransform(this, tstr);
+
+ this.clip && $(this.clip, {transform: this.matrix.invert()});
+ this.pattern && updatePosition(this);
+ this.node && $(this.node, {transform: this.matrix});
+
+ if (_.sx != 1 || _.sy != 1) {
+ var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1;
+ this.attr({"stroke-width": sw});
+ }
+
+ return this;
+ };
+ /*\
+ * Element.hide
+ [ method ]
+ **
+ * Makes element invisible. See @Element.show.
+ = (object) @Element
+ \*/
+ elproto.hide = function () {
+ !this.removed && this.paper.safari(this.node.style.display = "none");
+ return this;
+ };
+ /*\
+ * Element.show
+ [ method ]
+ **
+ * Makes element visible. See @Element.hide.
+ = (object) @Element
+ \*/
+ elproto.show = function () {
+ !this.removed && this.paper.safari(this.node.style.display = "");
+ return this;
+ };
+ /*\
+ * Element.remove
+ [ method ]
+ **
+ * Removes element form the paper.
+ \*/
+ elproto.remove = function () {
+ if (this.removed || !this.node.parentNode) {
+ return;
+ }
+ var paper = this.paper;
+ paper.__set__ && paper.__set__.exclude(this);
+ eve.unbind("raphael.*.*." + this.id);
+ if (this.gradient) {
+ paper.defs.removeChild(this.gradient);
+ }
+ R._tear(this, paper);
+ if (this.node.parentNode.tagName.toLowerCase() == "a") {
+ this.node.parentNode.parentNode.removeChild(this.node.parentNode);
+ } else {
+ this.node.parentNode.removeChild(this.node);
+ }
+ for (var i in this) {
+ this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
+ }
+ this.removed = true;
+ };
+ elproto._getBBox = function () {
+ if (this.node.style.display == "none") {
+ this.show();
+ var hide = true;
+ }
+ var bbox = {};
+ try {
+ bbox = this.node.getBBox();
+ } catch(e) {
+ // Firefox 3.0.x plays badly here
+ } finally {
+ bbox = bbox || {};
+ }
+ hide && this.hide();
+ return bbox;
+ };
+ /*\
+ * Element.attr
+ [ method ]
+ **
+ * Sets the attributes of the element.
+ > Parameters
+ - attrName (string) attribute’s name
+ - value (string) value
+ * or
+ - params (object) object of name/value pairs
+ * or
+ - attrName (string) attribute’s name
+ * or
+ - attrNames (array) in this case method returns array of current values for given attribute names
+ = (object) @Element if attrsName & value or params are passed in.
+ = (...) value of the attribute if only attrsName is passed in.
+ = (array) array of values of the attribute if attrsNames is passed in.
+ = (object) object of attributes if nothing is passed in.
+ > Possible parameters
+ # <p>Please refer to the <a href="http://www.w3.org/TR/SVG/" title="The W3C Recommendation for the SVG language describes these properties in detail.">SVG specification</a> for an explanation of these parameters.</p>
+ o arrow-end (string) arrowhead on the end of the path. The format for string is `<type>[-<width>[-<length>]]`. Possible types: `classic`, `block`, `open`, `oval`, `diamond`, `none`, width: `wide`, `narrow`, `midium`, length: `long`, `short`, `midium`.
+ o clip-rect (string) comma or space separated values: x, y, width and height
+ o cursor (string) CSS type of the cursor
+ o cx (number) the x-axis coordinate of the center of the circle, or ellipse
+ o cy (number) the y-axis coordinate of the center of the circle, or ellipse
+ o fill (string) colour, gradient or image
+ o fill-opacity (number)
+ o font (string)
+ o font-family (string)
+ o font-size (number) font size in pixels
+ o font-weight (string)
+ o height (number)
+ o href (string) URL, if specified element behaves as hyperlink
+ o opacity (number)
+ o path (string) SVG path string format
+ o r (number) radius of the circle, ellipse or rounded corner on the rect
+ o rx (number) horisontal radius of the ellipse
+ o ry (number) vertical radius of the ellipse
+ o src (string) image URL, only works for @Element.image element
+ o stroke (string) stroke colour
+ o stroke-dasharray (string) [“”, “`-`”, “`.`”, “`-.`”, “`-..`”, “`. `”, “`- `”, “`--`”, “`- .`”, “`--.`”, “`--..`”]
+ o stroke-linecap (string) [“`butt`”, “`square`”, “`round`”]
+ o stroke-linejoin (string) [“`bevel`”, “`round`”, “`miter`”]
+ o stroke-miterlimit (number)
+ o stroke-opacity (number)
+ o stroke-width (number) stroke width in pixels, default is '1'
+ o target (string) used with href
+ o text (string) contents of the text element. Use `\n` for multiline text
+ o text-anchor (string) [“`start`”, “`middle`”, “`end`”], default is “`middle`”
+ o title (string) will create tooltip with a given text
+ o transform (string) see @Element.transform
+ o width (number)
+ o x (number)
+ o y (number)
+ > Gradients
+ * Linear gradient format: “`‹angle›-‹colour›[-‹colour›[:‹offset›]]*-‹colour›`”, example: “`90-#fff-#000`” – 90°
+ * gradient from white to black or “`0-#fff-#f00:20-#000`” – 0° gradient from white via red (at 20%) to black.
+ *
+ * radial gradient: “`r[(‹fx›, ‹fy›)]‹colour›[-‹colour›[:‹offset›]]*-‹colour›`”, example: “`r#fff-#000`” –
+ * gradient from white to black or “`r(0.25, 0.75)#fff-#000`” – gradient from white to black with focus point
+ * at 0.25, 0.75. Focus point coordinates are in 0..1 range. Radial gradients can only be applied to circles and ellipses.
+ > Path String
+ # <p>Please refer to <a href="http://www.w3.org/TR/SVG/paths.html#PathData" title="Details of a path’s data attribute’s format are described in the SVG specification.">SVG documentation regarding path string</a>. Raphaël fully supports it.</p>
+ > Colour Parsing
+ # <ul>
+ # <li>Colour name (“<code>red</code>”, “<code>green</code>”, “<code>cornflowerblue</code>”, etc)</li>
+ # <li>#••• — shortened HTML colour: (“<code>#000</code>”, “<code>#fc0</code>”, etc)</li>
+ # <li>#•••••• — full length HTML colour: (“<code>#000000</code>”, “<code>#bd2300</code>”)</li>
+ # <li>rgb(•••, •••, •••) — red, green and blue channels’ values: (“<code>rgb(200,&nbsp;100,&nbsp;0)</code>”)</li>
+ # <li>rgb(•••%, •••%, •••%) — same as above, but in %: (“<code>rgb(100%,&nbsp;175%,&nbsp;0%)</code>”)</li>
+ # <li>rgba(•••, •••, •••, •••) — red, green and blue channels’ values: (“<code>rgba(200,&nbsp;100,&nbsp;0, .5)</code>”)</li>
+ # <li>rgba(•••%, •••%, •••%, •••%) — same as above, but in %: (“<code>rgba(100%,&nbsp;175%,&nbsp;0%, 50%)</code>”)</li>
+ # <li>hsb(•••, •••, •••) — hue, saturation and brightness values: (“<code>hsb(0.5,&nbsp;0.25,&nbsp;1)</code>”)</li>
+ # <li>hsb(•••%, •••%, •••%) — same as above, but in %</li>
+ # <li>hsba(•••, •••, •••, •••) — same as above, but with opacity</li>
+ # <li>hsl(•••, •••, •••) — almost the same as hsb, see <a href="http://en.wikipedia.org/wiki/HSL_and_HSV" title="HSL and HSV - Wikipedia, the free encyclopedia">Wikipedia page</a></li>
+ # <li>hsl(•••%, •••%, •••%) — same as above, but in %</li>
+ # <li>hsla(•••, •••, •••, •••) — same as above, but with opacity</li>
+ # <li>Optionally for hsb and hsl you could specify hue as a degree: “<code>hsl(240deg,&nbsp;1,&nbsp;.5)</code>” or, if you want to go fancy, “<code>hsl(240°,&nbsp;1,&nbsp;.5)</code>”</li>
+ # </ul>
+ \*/
+ elproto.attr = function (name, value) {
+ if (this.removed) {
+ return this;
+ }
+ if (name == null) {
+ var res = {};
+ for (var a in this.attrs) if (this.attrs[has](a)) {
+ res[a] = this.attrs[a];
+ }
+ res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient;
+ res.transform = this._.transform;
+ return res;
+ }
+ if (value == null && R.is(name, "string")) {
+ if (name == "fill" && this.attrs.fill == "none" && this.attrs.gradient) {
+ return this.attrs.gradient;
+ }
+ if (name == "transform") {
+ return this._.transform;
+ }
+ var names = name.split(separator),
+ out = {};
+ for (var i = 0, ii = names.length; i < ii; i++) {
+ name = names[i];
+ if (name in this.attrs) {
+ out[name] = this.attrs[name];
+ } else if (R.is(this.paper.customAttributes[name], "function")) {
+ out[name] = this.paper.customAttributes[name].def;
+ } else {
+ out[name] = R._availableAttrs[name];
+ }
+ }
+ return ii - 1 ? out : out[names[0]];
+ }
+ if (value == null && R.is(name, "array")) {
+ out = {};
+ for (i = 0, ii = name.length; i < ii; i++) {
+ out[name[i]] = this.attr(name[i]);
+ }
+ return out;
+ }
+ if (value != null) {
+ var params = {};
+ params[name] = value;
+ } else if (name != null && R.is(name, "object")) {
+ params = name;
+ }
+ for (var key in params) {
+ eve("raphael.attr." + key + "." + this.id, this, params[key]);
+ }
+ for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {
+ var par = this.paper.customAttributes[key].apply(this, [].concat(params[key]));
+ this.attrs[key] = params[key];
+ for (var subkey in par) if (par[has](subkey)) {
+ params[subkey] = par[subkey];
+ }
+ }
+ setFillAndStroke(this, params);
+ return this;
+ };
+ /*\
+ * Element.toFront
+ [ method ]
+ **
+ * Moves the element so it is the closest to the viewer’s eyes, on top of other elements.
+ = (object) @Element
+ \*/
+ elproto.toFront = function () {
+ if (this.removed) {
+ return this;
+ }
+ if (this.node.parentNode.tagName.toLowerCase() == "a") {
+ this.node.parentNode.parentNode.appendChild(this.node.parentNode);
+ } else {
+ this.node.parentNode.appendChild(this.node);
+ }
+ var svg = this.paper;
+ svg.top != this && R._tofront(this, svg);
+ return this;
+ };
+ /*\
+ * Element.toBack
+ [ method ]
+ **
+ * Moves the element so it is the furthest from the viewer’s eyes, behind other elements.
+ = (object) @Element
+ \*/
+ elproto.toBack = function () {
+ if (this.removed) {
+ return this;
+ }
+ var parent = this.node.parentNode;
+ if (parent.tagName.toLowerCase() == "a") {
+ parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild);
+ } else if (parent.firstChild != this.node) {
+