Commit 10c3e3b7 by Dmitry Baranovskiy

* Global variables leakage fix

  *  fix for elements with links
  * Gradient clean up
  * Added  attribute
  * Fixed hsb methods
  * Fixed image flickering
  * Improved  method on
  * Fixed drag'n'drop
  * New method [Paper.add](http://raphaeljs.com/reference.html#Paper.add)
  * Fix for
parent 3c49587c
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`
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
This source diff could not be displayed because it is too large. You can view the blob instead.
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ "Raphaël 2.0" - JavaScript Vector Library │ \\ // │ "Raphaël 2.0.1" - JavaScript Vector Library │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\ // │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
- height (number) - height (number)
- callback (function) #optional callback function which is going to be executed in the context of newly created paper - callback (function) #optional callback function which is going to be executed in the context of newly created paper
* or * or
- all (array) (first 3 or 4 elements in the array are equal to [containerID, width, height] or [x, y, width, height]. The rest are element descriptions in format {type: type, <attributes>}) - all (array) (first 3 or 4 elements in the array are equal to [containerID, width, height] or [x, y, width, height]. The rest are element descriptions in format {type: type, <attributes>}). See @Paper.add.
- callback (function) #optional callback function which is going to be executed in the context of newly created paper - callback (function) #optional callback function which is going to be executed in the context of newly created paper
* or * or
- onReadyCallback (function) function that is going to be called on DOM ready event. You can also subscribe to this event via Eve’s “DOMLoad” event. In this case method returns `undefined`. - onReadyCallback (function) function that is going to be called on DOM ready event. You can also subscribe to this event via Eve’s “DOMLoad” event. In this case method returns `undefined`.
...@@ -60,17 +60,7 @@ ...@@ -60,17 +60,7 @@
if (R.is(first, "function")) { if (R.is(first, "function")) {
return loaded ? first() : eve.on("DOMload", first); return loaded ? first() : eve.on("DOMload", first);
} else if (R.is(first, array)) { } else if (R.is(first, array)) {
var a = first, return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first);
cnv = R._engine.create[apply](R, a.splice(0, 3 + R.is(a[0], nu))),
res = cnv.set(),
i = 0,
ii = a.length,
j;
for (; i < ii; i++) {
j = a[i] || {};
elements[has](j.type) && res.push(cnv[j.type]().attr(j));
}
return res;
} else { } else {
var args = Array.prototype.slice.call(arguments, 0); var args = Array.prototype.slice.call(arguments, 0);
if (R.is(args[args.length - 1], "function")) { if (R.is(args[args.length - 1], "function")) {
...@@ -83,7 +73,7 @@ ...@@ -83,7 +73,7 @@
} }
} }
} }
R.version = "2.0.0"; R.version = "2.0.1";
R.eve = eve; R.eve = eve;
var loaded, var loaded,
separator = /[, ]+/, separator = /[, ]+/,
...@@ -191,6 +181,7 @@ ...@@ -191,6 +181,7 @@
gradient: 0, gradient: 0,
height: 0, height: 0,
href: "http://raphaeljs.com/", href: "http://raphaeljs.com/",
"letter-spacing": 0,
opacity: 1, opacity: 1,
path: "M0,0", path: "M0,0",
r: 0, r: 0,
...@@ -293,7 +284,7 @@ ...@@ -293,7 +284,7 @@
if (!matrix) { if (!matrix) {
return path; return path;
} }
var x, y, i, j, pathi; var x, y, i, j, ii, jj, pathi;
path = path2curve(path); path = path2curve(path);
for (i = 0, ii = path.length; i < ii; i++) { for (i = 0, ii = path.length; i < ii; i++) {
pathi = path[i]; pathi = path[i];
...@@ -501,8 +492,8 @@ ...@@ -501,8 +492,8 @@
eve("setWindow", R, g.win, newwin); eve("setWindow", R, g.win, newwin);
g.win = newwin; g.win = newwin;
g.doc = g.win.document; g.doc = g.win.document;
if (initWin) { if (R._engine.initWin) {
initWin(g.win); R._engine.initWin(g.win);
} }
}; };
var toHex = function (color) { var toHex = function (color) {
...@@ -632,7 +623,7 @@ ...@@ -632,7 +623,7 @@
clr.v = rgb.b; clr.v = rgb.b;
} else { } else {
clr = {hex: "none"}; clr = {hex: "none"};
crl.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1; clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;
} }
} }
clr.toString = rgbtoString; clr.toString = rgbtoString;
...@@ -815,7 +806,7 @@ ...@@ -815,7 +806,7 @@
var preload = R._preload = function (src, f) { var preload = R._preload = function (src, f) {
var img = g.doc.createElement("img"); var img = g.doc.createElement("img");
img.style.cssText = "position:absolute;left:-9999em;top-9999em"; img.style.cssText = "position:absolute;left:-9999em;top:-9999em";
img.onload = function () { img.onload = function () {
f.call(this); f.call(this);
this.onload = null; this.onload = null;
...@@ -1174,6 +1165,11 @@ ...@@ -1174,6 +1165,11 @@
alpha: alpha alpha: alpha
}; };
}; };
R._removedFactory = function (methodname) {
return function () {
throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object");
};
};
var pathDimensions = cacher(function (path) { var pathDimensions = cacher(function (path) {
if (!path) { if (!path) {
return {x: 0, y: 0, width: 0, height: 0}; return {x: 0, y: 0, width: 0, height: 0};
...@@ -1719,11 +1715,6 @@ ...@@ -1719,11 +1715,6 @@
el2.prev = el; el2.prev = el;
el.next = el2; el.next = el2;
}, },
removed = function (methodname) {
return function () {
throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object");
};
},
extractTransform = R._extractTransform = function (el, tstr) { extractTransform = R._extractTransform = function (el, tstr) {
if (tstr == null) { if (tstr == null) {
return el._.transform; return el._.transform;
...@@ -2175,7 +2166,12 @@ ...@@ -2175,7 +2166,12 @@
matrixproto.toTransformString = function (shorter) { matrixproto.toTransformString = function (shorter) {
var s = shorter || this[split](); var s = shorter || this[split]();
if (s.isSimple) { if (s.isSimple) {
return "t" + [s.dx, s.dy] + "s" + [s.scalex, s.scaley, 0, 0] + "r" + [s.rotate, 0, 0]; s.scalex = +s.scalex.toFixed(4);
s.scaley = +s.scaley.toFixed(4);
s.rotate = +s.rotate.toFixed(4);
return (s.dx && s.dy ? "t" + [s.dx, s.dy] : E) +
(s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) +
(s.rotate ? "r" + [s.rotate, 0, 0] : E);
} else { } else {
return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)]; return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
} }
...@@ -2647,6 +2643,7 @@ ...@@ -2647,6 +2643,7 @@
elproto.unhover = function (f_in, f_out) { elproto.unhover = function (f_in, f_out) {
return this.unmouseover(f_in).unmouseout(f_out); return this.unmouseover(f_in).unmouseout(f_out);
}; };
var draggable = [];
/*\ /*\
* Element.drag * Element.drag
[ method ] [ method ]
...@@ -2693,6 +2690,7 @@ ...@@ -2693,6 +2690,7 @@
eve("drag.start." + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e); eve("drag.start." + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e);
} }
this._drag = {}; this._drag = {};
draggable.push({el: this, start: start});
this.mousedown(start); this.mousedown(start);
return this; return this;
}; };
...@@ -2714,13 +2712,13 @@ ...@@ -2714,13 +2712,13 @@
* Removes all drag event handlers from given element. * Removes all drag event handlers from given element.
\*/ \*/
elproto.undrag = function () { elproto.undrag = function () {
var i = drag.length; var i = draggable.length;
while (i--) if (drag[i].el == this) { while (i--) if (draggable[i].el == this) {
R.unmousedown(drag[i].start); this.unmousedown(draggable[i].start);
drag.splice(i++, 1); draggable.splice(i, 1);
eve.unbind("drag.*." + this.id); eve.unbind("drag.*." + this.id);
} }
!drag.length && R.unmousemove(dragMove).unmouseup(dragUp); !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp);
}; };
/*\ /*\
* Paper.circle * Paper.circle
...@@ -3615,7 +3613,7 @@ ...@@ -3615,7 +3613,7 @@
= (object) original element = (object) original element
\*/ \*/
elproto.animateWith = function (element, anim, params, ms, easing, callback) { elproto.animateWith = function (element, anim, params, ms, easing, callback) {
var a = params ? R.animation(params, ms, easing, callback) : anim; var a = params ? R.animation(params, ms, easing, callback) : anim,
status = element.status(anim); status = element.status(anim);
return this.animate(a).status(a, status * anim.ms / a.ms); return this.animate(a).status(a, status * anim.ms / a.ms);
}; };
...@@ -3776,7 +3774,7 @@ ...@@ -3776,7 +3774,7 @@
return; return;
} }
if (!isInAnim) { if (!isInAnim) {
for (attr in params) if (params[has](attr)) { for (var attr in params) if (params[has](attr)) {
if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) { if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) {
from[attr] = element.attr(attr); from[attr] = element.attr(attr);
(from[attr] == null) && (from[attr] = availableAttrs[attr]); (from[attr] == null) && (from[attr] = availableAttrs[attr]);
...@@ -4508,6 +4506,48 @@ ...@@ -4508,6 +4506,48 @@
}; };
/*\ /*\
* Paper.add
[ method ]
**
* Imports elements in JSON array in format `{type: type, <attributes>}`
**
> Parameters
**
- json (array)
= (object) resulting set of imported elements
> Usage
| paper.import([
| {
| type: "circle",
| cx: 10,
| cy: 10,
| r: 5
| },
| {
| type: "rect",
| x: 10,
| y: 10,
| width: 10,
| height: 10,
| fill: "#fc0"
| }
| ]);
\*/
paperproto.add = function (json) {
if (R.is(json, "array")) {
var res = this.set(),
i = 0,
ii = json.length,
j;
for (; i < ii; i++) {
j = json[i] || {};
elements[has](j.type) && res.push(this[j.type]().attr(j));
}
}
return res;
};
/*\
* Raphael.format * Raphael.format
[ method ] [ method ]
** **
......
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ Raphaël 2.0 - JavaScript Vector Library │ \\ // │ Raphaël 2.0.1 - JavaScript Vector Library │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\ // │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
// └─────────────────────────────────────────────────────────────────────┘ \\ // └─────────────────────────────────────────────────────────────────────┘ \\
// ┌──────────────────────────────────────────────────────────────────────────────────────┐ \\ // ┌──────────────────────────────────────────────────────────────────────────────────────┐ \\
// │ Eve 0.3.2 - JavaScript Events Library │ \\ // │ Eve 0.4.0 - JavaScript Events Library │ \\
// ├──────────────────────────────────────────────────────────────────────────────────────┤ \\ // ├──────────────────────────────────────────────────────────────────────────────────────┤ \\
// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\ // │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\
// │ Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. │ \\ // │ Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. │ \\
// └──────────────────────────────────────────────────────────────────────────────────────┘ \\ // └──────────────────────────────────────────────────────────────────────────────────────┘ \\
(function (glob) { (function (glob) {
var version = "0.3.2", var version = "0.4.0",
has = "hasOwnProperty", has = "hasOwnProperty",
separator = /[\.\/]/, separator = /[\.\/]/,
wildcard = "*", wildcard = "*",
...@@ -157,9 +157,10 @@ ...@@ -157,9 +157,10 @@
e, e,
key, key,
splice, splice,
i, ii, j, jj,
cur = [events]; cur = [events];
for (var i = 0, ii = names.length; i < ii; i++) { for (i = 0, ii = names.length; i < ii; i++) {
for (var j = 0; j < cur.length; j += splice.length - 2) { for (j = 0; j < cur.length; j += splice.length - 2) {
splice = [j, 1]; splice = [j, 1];
e = cur[j].n; e = cur[j].n;
if (names[i] != wildcard) { if (names[i] != wildcard) {
...@@ -204,6 +205,14 @@ ...@@ -204,6 +205,14 @@
} }
}; };
eve.once = function (name, f) {
var f2 = function () {
f.apply(this, arguments);
eve.unbind(name, f2);
};
return eve.on(name, f2);
};
eve.version = version; eve.version = version;
eve.toString = function () { eve.toString = function () {
return "You are running Eve " + version; return "You are running Eve " + version;
...@@ -212,7 +221,7 @@ ...@@ -212,7 +221,7 @@
})(this); })(this);
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ "Raphaël 2.0" - JavaScript Vector Library │ \\ // │ "Raphaël 2.0.1" - JavaScript Vector Library │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\ // │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
...@@ -224,17 +233,7 @@ ...@@ -224,17 +233,7 @@
if (R.is(first, "function")) { if (R.is(first, "function")) {
return loaded ? first() : eve.on("DOMload", first); return loaded ? first() : eve.on("DOMload", first);
} else if (R.is(first, array)) { } else if (R.is(first, array)) {
var a = first, return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first);
cnv = R._engine.create[apply](R, a.splice(0, 3 + R.is(a[0], nu))),
res = cnv.set(),
i = 0,
ii = a.length,
j;
for (; i < ii; i++) {
j = a[i] || {};
elements[has](j.type) && res.push(cnv[j.type]().attr(j));
}
return res;
} else { } else {
var args = Array.prototype.slice.call(arguments, 0); var args = Array.prototype.slice.call(arguments, 0);
if (R.is(args[args.length - 1], "function")) { if (R.is(args[args.length - 1], "function")) {
...@@ -247,7 +246,7 @@ ...@@ -247,7 +246,7 @@
} }
} }
} }
R.version = "2.0.0"; R.version = "2.0.1";
R.eve = eve; R.eve = eve;
var loaded, var loaded,
separator = /[, ]+/, separator = /[, ]+/,
...@@ -325,6 +324,7 @@ ...@@ -325,6 +324,7 @@
gradient: 0, gradient: 0,
height: 0, height: 0,
href: "http://raphaeljs.com/", href: "http://raphaeljs.com/",
"letter-spacing": 0,
opacity: 1, opacity: 1,
path: "M0,0", path: "M0,0",
r: 0, r: 0,
...@@ -427,7 +427,7 @@ ...@@ -427,7 +427,7 @@
if (!matrix) { if (!matrix) {
return path; return path;
} }
var x, y, i, j, pathi; var x, y, i, j, ii, jj, pathi;
path = path2curve(path); path = path2curve(path);
for (i = 0, ii = path.length; i < ii; i++) { for (i = 0, ii = path.length; i < ii; i++) {
pathi = path[i]; pathi = path[i];
...@@ -536,8 +536,8 @@ ...@@ -536,8 +536,8 @@
eve("setWindow", R, g.win, newwin); eve("setWindow", R, g.win, newwin);
g.win = newwin; g.win = newwin;
g.doc = g.win.document; g.doc = g.win.document;
if (initWin) { if (R._engine.initWin) {
initWin(g.win); R._engine.initWin(g.win);
} }
}; };
var toHex = function (color) { var toHex = function (color) {
...@@ -648,7 +648,7 @@ ...@@ -648,7 +648,7 @@
clr.v = rgb.b; clr.v = rgb.b;
} else { } else {
clr = {hex: "none"}; clr = {hex: "none"};
crl.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1; clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;
} }
} }
clr.toString = rgbtoString; clr.toString = rgbtoString;
...@@ -769,7 +769,7 @@ ...@@ -769,7 +769,7 @@
var preload = R._preload = function (src, f) { var preload = R._preload = function (src, f) {
var img = g.doc.createElement("img"); var img = g.doc.createElement("img");
img.style.cssText = "position:absolute;left:-9999em;top-9999em"; img.style.cssText = "position:absolute;left:-9999em;top:-9999em";
img.onload = function () { img.onload = function () {
f.call(this); f.call(this);
this.onload = null; this.onload = null;
...@@ -1000,6 +1000,11 @@ ...@@ -1000,6 +1000,11 @@
alpha: alpha alpha: alpha
}; };
}; };
R._removedFactory = function (methodname) {
return function () {
throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object");
};
};
var pathDimensions = cacher(function (path) { var pathDimensions = cacher(function (path) {
if (!path) { if (!path) {
return {x: 0, y: 0, width: 0, height: 0}; return {x: 0, y: 0, width: 0, height: 0};
...@@ -1545,11 +1550,6 @@ ...@@ -1545,11 +1550,6 @@
el2.prev = el; el2.prev = el;
el.next = el2; el.next = el2;
}, },
removed = function (methodname) {
return function () {
throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object");
};
},
extractTransform = R._extractTransform = function (el, tstr) { extractTransform = R._extractTransform = function (el, tstr) {
if (tstr == null) { if (tstr == null) {
return el._.transform; return el._.transform;
...@@ -1876,7 +1876,12 @@ ...@@ -1876,7 +1876,12 @@
matrixproto.toTransformString = function (shorter) { matrixproto.toTransformString = function (shorter) {
var s = shorter || this[split](); var s = shorter || this[split]();
if (s.isSimple) { if (s.isSimple) {
return "t" + [s.dx, s.dy] + "s" + [s.scalex, s.scaley, 0, 0] + "r" + [s.rotate, 0, 0]; s.scalex = +s.scalex.toFixed(4);
s.scaley = +s.scaley.toFixed(4);
s.rotate = +s.rotate.toFixed(4);
return (s.dx && s.dy ? "t" + [s.dx, s.dy] : E) +
(s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) +
(s.rotate ? "r" + [s.rotate, 0, 0] : E);
} else { } else {
return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)]; return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
} }
...@@ -2101,6 +2106,7 @@ ...@@ -2101,6 +2106,7 @@
elproto.unhover = function (f_in, f_out) { elproto.unhover = function (f_in, f_out) {
return this.unmouseover(f_in).unmouseout(f_out); return this.unmouseover(f_in).unmouseout(f_out);
}; };
var draggable = [];
elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) { elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) {
function start(e) { function start(e) {
...@@ -2118,6 +2124,7 @@ ...@@ -2118,6 +2124,7 @@
eve("drag.start." + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e); eve("drag.start." + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e);
} }
this._drag = {}; this._drag = {};
draggable.push({el: this, start: start});
this.mousedown(start); this.mousedown(start);
return this; return this;
}; };
...@@ -2127,13 +2134,13 @@ ...@@ -2127,13 +2134,13 @@
}; };
elproto.undrag = function () { elproto.undrag = function () {
var i = drag.length; var i = draggable.length;
while (i--) if (drag[i].el == this) { while (i--) if (draggable[i].el == this) {
R.unmousedown(drag[i].start); this.unmousedown(draggable[i].start);
drag.splice(i++, 1); draggable.splice(i, 1);
eve.unbind("drag.*." + this.id); eve.unbind("drag.*." + this.id);
} }
!drag.length && R.unmousemove(dragMove).unmouseup(dragUp); !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp);
}; };
paperproto.circle = function (x, y, r) { paperproto.circle = function (x, y, r) {
...@@ -2645,7 +2652,7 @@ ...@@ -2645,7 +2652,7 @@
}; };
elproto.animateWith = function (element, anim, params, ms, easing, callback) { elproto.animateWith = function (element, anim, params, ms, easing, callback) {
var a = params ? R.animation(params, ms, easing, callback) : anim; var a = params ? R.animation(params, ms, easing, callback) : anim,
status = element.status(anim); status = element.status(anim);
return this.animate(a).status(a, status * anim.ms / a.ms); return this.animate(a).status(a, status * anim.ms / a.ms);
}; };
...@@ -2781,7 +2788,7 @@ ...@@ -2781,7 +2788,7 @@
return; return;
} }
if (!isInAnim) { if (!isInAnim) {
for (attr in params) if (params[has](attr)) { for (var attr in params) if (params[has](attr)) {
if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) { if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) {
from[attr] = element.attr(attr); from[attr] = element.attr(attr);
(from[attr] == null) && (from[attr] = availableAttrs[attr]); (from[attr] == null) && (from[attr] = availableAttrs[attr]);
...@@ -3312,6 +3319,21 @@ ...@@ -3312,6 +3319,21 @@
}; };
paperproto.add = function (json) {
if (R.is(json, "array")) {
var res = this.set(),
i = 0,
ii = json.length,
j;
for (; i < ii; i++) {
j = json[i] || {};
elements[has](j.type) && res.push(this[j.type]().attr(j));
}
}
return res;
};
R.format = function (token, params) { R.format = function (token, params) {
var args = R.is(params, array) ? [0][concat](params) : arguments; var args = R.is(params, array) ? [0][concat](params) : arguments;
token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) { token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) {
...@@ -3373,7 +3395,7 @@ ...@@ -3373,7 +3395,7 @@
})(); })();
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ Raphaël 2 - JavaScript Vector Library │ \\ // │ Raphaël - JavaScript Vector Library │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
// │ SVG Module │ \\ // │ SVG Module │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
...@@ -3424,16 +3446,6 @@ window.Raphael.svg && function (R) { ...@@ -3424,16 +3446,6 @@ window.Raphael.svg && function (R) {
} }
return el; return el;
}, },
gradients = {},
rgGrad = /^url\(#(.*)\)$/,
removeGradientFill = function (node, paper) {
var oid = node.getAttribute("fill");
oid = oid && oid.match(rgGrad);
if (oid && !--gradients[oid[1]]) {
delete gradients[oid[1]];
paper.defs.removeChild(R._g.doc.getElementById(oid[1]));
}
},
addGradientFill = function (element, gradient) { addGradientFill = function (element, gradient) {
var type = "linear", var type = "linear",
id = element.id + gradient, id = element.id + gradient,
...@@ -3480,30 +3492,33 @@ window.Raphael.svg && function (R) { ...@@ -3480,30 +3492,33 @@ window.Raphael.svg && function (R) {
if (!dots) { if (!dots) {
return null; return null;
} }
if (element.gradient) { id = id.replace(/[\(\)\s,\xb0#]/g, "_");
if (element.gradient && id != element.gradient.id) {
SVG.defs.removeChild(element.gradient); SVG.defs.removeChild(element.gradient);
delete element.gradient; delete element.gradient;
} }
id = id.replace(/[\(\)\s,\xb0#]/g, "-"); if (!element.gradient) {
el = $(type + "Gradient", {id: id}); el = $(type + "Gradient", {id: id});
element.gradient = el; element.gradient = el;
$(el, type == "radial" ? { $(el, type == "radial" ? {
fx: fx, fx: fx,
fy: fy fy: fy
} : { } : {
x1: vector[0], x1: vector[0],
y1: vector[1], y1: vector[1],
x2: vector[2], x2: vector[2],
y2: vector[3], y2: vector[3],
gradientTransform: element.matrix.invert() gradientTransform: element.matrix.invert()
}); });
SVG.defs.appendChild(el); SVG.defs.appendChild(el);
for (var i = 0, ii = dots.length; i < ii; i++) { for (var i = 0, ii = dots.length; i < ii; i++) {
el.appendChild($("stop", { el.appendChild($("stop", {
offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%", offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%",
"stop-color": dots[i].color || "#fff" "stop-color": dots[i].color || "#fff"
})); }));
}
} }
} }
$(o, { $(o, {
...@@ -3749,10 +3764,13 @@ window.Raphael.svg && function (R) { ...@@ -3749,10 +3764,13 @@ window.Raphael.svg && function (R) {
o.clip = rc; o.clip = rc;
} }
if (!value) { if (!value) {
var clip = R._g.doc.getElementById(node.getAttribute("clip-path").replace(/(^url\(#|\)$)/g, E)); var path = node.getAttribute("clip-path");
clip && clip.parentNode.removeChild(clip); if (path) {
$(node, {"clip-path": E}); var clip = R._g.doc.getElementById(path.replace(/(^url\(#|\)$)/g, E));
delete o.clip; clip && clip.parentNode.removeChild(clip);
$(node, {"clip-path": E});
delete o.clip;
}
} }
break; break;
case "path": case "path":
...@@ -4109,12 +4127,16 @@ window.Raphael.svg && function (R) { ...@@ -4109,12 +4127,16 @@ window.Raphael.svg && function (R) {
if (this.removed) { if (this.removed) {
return; return;
} }
this.paper.__set__ && this.paper.__set__.exclude(this); var paper = this.paper;
paper.__set__ && paper.__set__.exclude(this);
eve.unbind("*.*." + this.id); eve.unbind("*.*." + this.id);
R._tear(this, this.paper); if (this.gradient) {
paper.defs.removeChild(this.gradient);
}
R._tear(this, paper);
this.node.parentNode.removeChild(this.node); this.node.parentNode.removeChild(this.node);
for (var i in this) { for (var i in this) {
delete this[i]; this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
} }
this.removed = true; this.removed = true;
}; };
...@@ -4200,7 +4222,11 @@ window.Raphael.svg && function (R) { ...@@ -4200,7 +4222,11 @@ window.Raphael.svg && function (R) {
if (this.removed) { if (this.removed) {
return this; return this;
} }
this.node.parentNode.appendChild(this.node); 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; var svg = this.paper;
svg.top != this && R._tofront(this, svg); svg.top != this && R._tofront(this, svg);
return this; return this;
...@@ -4210,11 +4236,14 @@ window.Raphael.svg && function (R) { ...@@ -4210,11 +4236,14 @@ window.Raphael.svg && function (R) {
if (this.removed) { if (this.removed) {
return this; return this;
} }
if (this.node.parentNode.firstChild != this.node) { var parent = this.node.parentNode;
this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild); if (parent.tagName.toLowerCase() == "a") {
R._toback(this, this.paper); parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild);
var svg = this.paper; } else if (parent.firstChild != this.node) {
parent.insertBefore(this.node, this.node.parentNode.firstChild);
} }
R._toback(this, this.paper);
var svg = this.paper;
return this; return this;
}; };
...@@ -4440,7 +4469,7 @@ window.Raphael.svg && function (R) { ...@@ -4440,7 +4469,7 @@ window.Raphael.svg && function (R) {
eve("remove", this); eve("remove", this);
this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
for (var i in this) { for (var i in this) {
this[i] = removed(i); this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
} }
}; };
var setproto = R.st; var setproto = R.st;
...@@ -4457,7 +4486,7 @@ window.Raphael.svg && function (R) { ...@@ -4457,7 +4486,7 @@ window.Raphael.svg && function (R) {
}(window.Raphael); }(window.Raphael);
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ Raphaël 2 - JavaScript Vector Library │ \\ // │ Raphaël - JavaScript Vector Library │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
// │ VML Module │ \\ // │ VML Module │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
...@@ -4574,7 +4603,7 @@ window.Raphael.vml && function (R) { ...@@ -4574,7 +4603,7 @@ window.Raphael.vml && function (R) {
R.toString = function () { R.toString = function () {
return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version; return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version;
}; };
addArrow = function (o, value, isEnd) { var addArrow = function (o, value, isEnd) {
var values = Str(value).toLowerCase().split("-"), var values = Str(value).toLowerCase().split("-"),
se = isEnd ? "end" : "start", se = isEnd ? "end" : "start",
i = values.length, i = values.length,
...@@ -4601,7 +4630,7 @@ window.Raphael.vml && function (R) { ...@@ -4601,7 +4630,7 @@ window.Raphael.vml && function (R) {
stroke[se + "arrow"] = type; stroke[se + "arrow"] = type;
stroke[se + "arrowlength"] = w; stroke[se + "arrowlength"] = w;
stroke[se + "arrowwidth"] = h; stroke[se + "arrowwidth"] = h;
}; },
setFillAndStroke = function (o, params) { setFillAndStroke = function (o, params) {
// o.paper.canvas.style.display = "none"; // o.paper.canvas.style.display = "none";
o.attrs = o.attrs || {}; o.attrs = o.attrs || {};
...@@ -4662,7 +4691,7 @@ window.Raphael.vml && function (R) { ...@@ -4662,7 +4691,7 @@ window.Raphael.vml && function (R) {
} }
} }
if (!params["clip-rect"]) { if (!params["clip-rect"]) {
node.clipRect && (node.clipRect.style.clip = E); node.clipRect && (node.clipRect.style.clip = "auto");
} }
} }
if (o.textpath) { if (o.textpath) {
...@@ -4789,7 +4818,7 @@ window.Raphael.vml && function (R) { ...@@ -4789,7 +4818,7 @@ window.Raphael.vml && function (R) {
a["font-family"] && (s.fontFamily = a["font-family"]); a["font-family"] && (s.fontFamily = a["font-family"]);
a["font-weight"] && (s.fontWeight = a["font-weight"]); a["font-weight"] && (s.fontWeight = a["font-weight"]);
a["font-style"] && (s.fontStyle = a["font-style"]); a["font-style"] && (s.fontStyle = a["font-style"]);
fontSize = toFloat(fontSize ? fontSize[0] : a["font-size"]); fontSize = toFloat(a["font-size"] || fontSize && fontSize[0]) || 10;
s.fontSize = fontSize * m + "px"; s.fontSize = fontSize * m + "px";
res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/</g, "&#60;").replace(/&/g, "&#38;").replace(/\n/g, "<br>")); res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/</g, "&#60;").replace(/&/g, "&#38;").replace(/\n/g, "<br>"));
var brect = span.getBoundingClientRect(); var brect = span.getBoundingClientRect();
...@@ -4824,7 +4853,7 @@ window.Raphael.vml && function (R) { ...@@ -4824,7 +4853,7 @@ window.Raphael.vml && function (R) {
res.textpath.style["v-text-kern"] = true; res.textpath.style["v-text-kern"] = true;
} }
// res.paper.canvas.style.display = E; // res.paper.canvas.style.display = E;
}; },
addGradientFill = function (o, gradient, fill) { addGradientFill = function (o, gradient, fill) {
o.attrs = o.attrs || {}; o.attrs = o.attrs || {};
var attrs = o.attrs, var attrs = o.attrs,
...@@ -4882,7 +4911,7 @@ window.Raphael.vml && function (R) { ...@@ -4882,7 +4911,7 @@ window.Raphael.vml && function (R) {
o.appendChild(fill); o.appendChild(fill);
} }
return 1; return 1;
}; },
Element = function (node, vml) { Element = function (node, vml) {
this[0] = this.node = node; this[0] = this.node = node;
node.raphael = true; node.raphael = true;
...@@ -5032,16 +5061,12 @@ window.Raphael.vml && function (R) { ...@@ -5032,16 +5061,12 @@ window.Raphael.vml && function (R) {
if (this.removed) { if (this.removed) {
return {}; return {};
} }
if (this.type == "text") { return {
return { x: this.X + (this.bbx || 0) - this.W / 2,
x: this.X + (this.bbx || 0) - this.W / 2, y: this.Y - this.H,
y: this.Y - this.H, width: this.W,
width: this.W, height: this.H
height: this.H };
};
} else {
return pathDimensions(this.attrs.path);
}
}; };
elproto.remove = function () { elproto.remove = function () {
if (this.removed) { if (this.removed) {
...@@ -5053,7 +5078,7 @@ window.Raphael.vml && function (R) { ...@@ -5053,7 +5078,7 @@ window.Raphael.vml && function (R) {
this.node.parentNode.removeChild(this.node); this.node.parentNode.removeChild(this.node);
this.shape && this.shape.parentNode.removeChild(this.shape); this.shape && this.shape.parentNode.removeChild(this.shape);
for (var i in this) { for (var i in this) {
delete this[i]; this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
} }
this.removed = true; this.removed = true;
}; };
...@@ -5314,7 +5339,7 @@ window.Raphael.vml && function (R) { ...@@ -5314,7 +5339,7 @@ window.Raphael.vml && function (R) {
cs.height = height; cs.height = height;
cs.clip = "rect(0 " + width + " " + height + " 0)"; cs.clip = "rect(0 " + width + " " + height + " 0)";
if (this._viewBox) { if (this._viewBox) {
setViewBox.apply(this, this._viewBox); R._engine.setViewBox.apply(this, this._viewBox);
} }
return this; return this;
}; };
...@@ -5345,8 +5370,8 @@ window.Raphael.vml && function (R) { ...@@ -5345,8 +5370,8 @@ window.Raphael.vml && function (R) {
}); });
return this; return this;
}; };
var createNode, var createNode;
initWin = function (win) { R._engine.initWin = function (win) {
var doc = win.document; var doc = win.document;
doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"); doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");
try { try {
...@@ -5360,7 +5385,7 @@ window.Raphael.vml && function (R) { ...@@ -5360,7 +5385,7 @@ window.Raphael.vml && function (R) {
}; };
} }
}; };
initWin(R._g.win); R._engine.initWin(R._g.win);
R._engine.create = function () { R._engine.create = function () {
var con = R._getContainer.apply(0, arguments), var con = R._getContainer.apply(0, arguments),
container = con.container, container = con.container,
...@@ -5417,7 +5442,7 @@ window.Raphael.vml && function (R) { ...@@ -5417,7 +5442,7 @@ window.Raphael.vml && function (R) {
R.eve("remove", this); R.eve("remove", this);
this.canvas.parentNode.removeChild(this.canvas); this.canvas.parentNode.removeChild(this.canvas);
for (var i in this) { for (var i in this) {
this[i] = removed(i); this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
} }
return true; return true;
}; };
......
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ Raphaël 2 - JavaScript Vector Library │ \\ // │ Raphaël - JavaScript Vector Library │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
// │ SVG Module │ \\ // │ SVG Module │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
...@@ -50,16 +50,6 @@ window.Raphael.svg && function (R) { ...@@ -50,16 +50,6 @@ window.Raphael.svg && function (R) {
} }
return el; return el;
}, },
gradients = {},
rgGrad = /^url\(#(.*)\)$/,
removeGradientFill = function (node, paper) {
var oid = node.getAttribute("fill");
oid = oid && oid.match(rgGrad);
if (oid && !--gradients[oid[1]]) {
delete gradients[oid[1]];
paper.defs.removeChild(R._g.doc.getElementById(oid[1]));
}
},
addGradientFill = function (element, gradient) { addGradientFill = function (element, gradient) {
var type = "linear", var type = "linear",
id = element.id + gradient, id = element.id + gradient,
...@@ -106,30 +96,33 @@ window.Raphael.svg && function (R) { ...@@ -106,30 +96,33 @@ window.Raphael.svg && function (R) {
if (!dots) { if (!dots) {
return null; return null;
} }
if (element.gradient) { id = id.replace(/[\(\)\s,\xb0#]/g, "_");
if (element.gradient && id != element.gradient.id) {
SVG.defs.removeChild(element.gradient); SVG.defs.removeChild(element.gradient);
delete element.gradient; delete element.gradient;
} }
id = id.replace(/[\(\)\s,\xb0#]/g, "-"); if (!element.gradient) {
el = $(type + "Gradient", {id: id}); el = $(type + "Gradient", {id: id});
element.gradient = el; element.gradient = el;
$(el, type == "radial" ? { $(el, type == "radial" ? {
fx: fx, fx: fx,
fy: fy fy: fy
} : { } : {
x1: vector[0], x1: vector[0],
y1: vector[1], y1: vector[1],
x2: vector[2], x2: vector[2],
y2: vector[3], y2: vector[3],
gradientTransform: element.matrix.invert() gradientTransform: element.matrix.invert()
}); });
SVG.defs.appendChild(el); SVG.defs.appendChild(el);
for (var i = 0, ii = dots.length; i < ii; i++) { for (var i = 0, ii = dots.length; i < ii; i++) {
el.appendChild($("stop", { el.appendChild($("stop", {
offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%", offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%",
"stop-color": dots[i].color || "#fff" "stop-color": dots[i].color || "#fff"
})); }));
}
} }
} }
$(o, { $(o, {
...@@ -375,10 +368,13 @@ window.Raphael.svg && function (R) { ...@@ -375,10 +368,13 @@ window.Raphael.svg && function (R) {
o.clip = rc; o.clip = rc;
} }
if (!value) { if (!value) {
var clip = R._g.doc.getElementById(node.getAttribute("clip-path").replace(/(^url\(#|\)$)/g, E)); var path = node.getAttribute("clip-path");
clip && clip.parentNode.removeChild(clip); if (path) {
$(node, {"clip-path": E}); var clip = R._g.doc.getElementById(path.replace(/(^url\(#|\)$)/g, E));
delete o.clip; clip && clip.parentNode.removeChild(clip);
$(node, {"clip-path": E});
delete o.clip;
}
} }
break; break;
case "path": case "path":
...@@ -873,12 +869,16 @@ window.Raphael.svg && function (R) { ...@@ -873,12 +869,16 @@ window.Raphael.svg && function (R) {
if (this.removed) { if (this.removed) {
return; return;
} }
this.paper.__set__ && this.paper.__set__.exclude(this); var paper = this.paper;
paper.__set__ && paper.__set__.exclude(this);
eve.unbind("*.*." + this.id); eve.unbind("*.*." + this.id);
R._tear(this, this.paper); if (this.gradient) {
paper.defs.removeChild(this.gradient);
}
R._tear(this, paper);
this.node.parentNode.removeChild(this.node); this.node.parentNode.removeChild(this.node);
for (var i in this) { for (var i in this) {
delete this[i]; this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
} }
this.removed = true; this.removed = true;
}; };
...@@ -921,8 +921,8 @@ window.Raphael.svg && function (R) { ...@@ -921,8 +921,8 @@ window.Raphael.svg && function (R) {
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 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 clip-rect (string) comma or space separated values: x, y, width and height
o cursor (string) CSS type of the cursor o cursor (string) CSS type of the cursor
o cx (number) o cx (number) the x-axis coordinate of the center of the circle, or ellipse
o cy (number) o cy (number) the y-axis coordinate of the center of the circle, or ellipse
o fill (string) colour, gradient or image o fill (string) colour, gradient or image
o fill-opacity (number) o fill-opacity (number)
o font (string) o font (string)
...@@ -933,9 +933,9 @@ window.Raphael.svg && function (R) { ...@@ -933,9 +933,9 @@ window.Raphael.svg && function (R) {
o href (string) URL, if specified element behaves as hyperlink o href (string) URL, if specified element behaves as hyperlink
o opacity (number) o opacity (number)
o path (string) SVG path string format o path (string) SVG path string format
o r (number) o r (number) radius of the circle, ellipse or rounded corner on the rect
o rx (number) o rx (number) horisontal radius of the ellipse
o ry (number) o ry (number) vertical radius of the ellipse
o src (string) image URL, only works for @Element.image element o src (string) image URL, only works for @Element.image element
o stroke (string) stroke colour o stroke (string) stroke colour
o stroke-dasharray (string) [“”, “`-`”, “`.`”, “`-.`”, “`-..`”, “`. `”, “`- `”, “`--`”, “`- .`”, “`--.`”, “`--..`”] o stroke-dasharray (string) [“”, “`-`”, “`.`”, “`-.`”, “`-..`”, “`. `”, “`- `”, “`--`”, “`- .`”, “`--.`”, “`--..`”]
...@@ -1050,7 +1050,11 @@ window.Raphael.svg && function (R) { ...@@ -1050,7 +1050,11 @@ window.Raphael.svg && function (R) {
if (this.removed) { if (this.removed) {
return this; return this;
} }
this.node.parentNode.appendChild(this.node); 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; var svg = this.paper;
svg.top != this && R._tofront(this, svg); svg.top != this && R._tofront(this, svg);
return this; return this;
...@@ -1066,11 +1070,14 @@ window.Raphael.svg && function (R) { ...@@ -1066,11 +1070,14 @@ window.Raphael.svg && function (R) {
if (this.removed) { if (this.removed) {
return this; return this;
} }
if (this.node.parentNode.firstChild != this.node) { var parent = this.node.parentNode;
this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild); if (parent.tagName.toLowerCase() == "a") {
R._toback(this, this.paper); parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild);
var svg = this.paper; } else if (parent.firstChild != this.node) {
parent.insertBefore(this.node, this.node.parentNode.firstChild);
} }
R._toback(this, this.paper);
var svg = this.paper;
return this; return this;
}; };
/*\ /*\
...@@ -1327,7 +1334,7 @@ window.Raphael.svg && function (R) { ...@@ -1327,7 +1334,7 @@ window.Raphael.svg && function (R) {
eve("remove", this); eve("remove", this);
this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
for (var i in this) { for (var i in this) {
this[i] = removed(i); this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
} }
}; };
var setproto = R.st; var setproto = R.st;
......
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ Raphaël 2 - JavaScript Vector Library │ \\ // │ Raphaël - JavaScript Vector Library │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
// │ VML Module │ \\ // │ VML Module │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
...@@ -116,7 +116,7 @@ window.Raphael.vml && function (R) { ...@@ -116,7 +116,7 @@ window.Raphael.vml && function (R) {
R.toString = function () { R.toString = function () {
return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version; return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version;
}; };
addArrow = function (o, value, isEnd) { var addArrow = function (o, value, isEnd) {
var values = Str(value).toLowerCase().split("-"), var values = Str(value).toLowerCase().split("-"),
se = isEnd ? "end" : "start", se = isEnd ? "end" : "start",
i = values.length, i = values.length,
...@@ -143,7 +143,7 @@ window.Raphael.vml && function (R) { ...@@ -143,7 +143,7 @@ window.Raphael.vml && function (R) {
stroke[se + "arrow"] = type; stroke[se + "arrow"] = type;
stroke[se + "arrowlength"] = w; stroke[se + "arrowlength"] = w;
stroke[se + "arrowwidth"] = h; stroke[se + "arrowwidth"] = h;
}; },
setFillAndStroke = function (o, params) { setFillAndStroke = function (o, params) {
// o.paper.canvas.style.display = "none"; // o.paper.canvas.style.display = "none";
o.attrs = o.attrs || {}; o.attrs = o.attrs || {};
...@@ -204,7 +204,7 @@ window.Raphael.vml && function (R) { ...@@ -204,7 +204,7 @@ window.Raphael.vml && function (R) {
} }
} }
if (!params["clip-rect"]) { if (!params["clip-rect"]) {
node.clipRect && (node.clipRect.style.clip = E); node.clipRect && (node.clipRect.style.clip = "auto");
} }
} }
if (o.textpath) { if (o.textpath) {
...@@ -331,7 +331,7 @@ window.Raphael.vml && function (R) { ...@@ -331,7 +331,7 @@ window.Raphael.vml && function (R) {
a["font-family"] && (s.fontFamily = a["font-family"]); a["font-family"] && (s.fontFamily = a["font-family"]);
a["font-weight"] && (s.fontWeight = a["font-weight"]); a["font-weight"] && (s.fontWeight = a["font-weight"]);
a["font-style"] && (s.fontStyle = a["font-style"]); a["font-style"] && (s.fontStyle = a["font-style"]);
fontSize = toFloat(fontSize ? fontSize[0] : a["font-size"]); fontSize = toFloat(a["font-size"] || fontSize && fontSize[0]) || 10;
s.fontSize = fontSize * m + "px"; s.fontSize = fontSize * m + "px";
res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/</g, "&#60;").replace(/&/g, "&#38;").replace(/\n/g, "<br>")); res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/</g, "&#60;").replace(/&/g, "&#38;").replace(/\n/g, "<br>"));
var brect = span.getBoundingClientRect(); var brect = span.getBoundingClientRect();
...@@ -366,7 +366,7 @@ window.Raphael.vml && function (R) { ...@@ -366,7 +366,7 @@ window.Raphael.vml && function (R) {
res.textpath.style["v-text-kern"] = true; res.textpath.style["v-text-kern"] = true;
} }
// res.paper.canvas.style.display = E; // res.paper.canvas.style.display = E;
}; },
addGradientFill = function (o, gradient, fill) { addGradientFill = function (o, gradient, fill) {
o.attrs = o.attrs || {}; o.attrs = o.attrs || {};
var attrs = o.attrs, var attrs = o.attrs,
...@@ -424,7 +424,7 @@ window.Raphael.vml && function (R) { ...@@ -424,7 +424,7 @@ window.Raphael.vml && function (R) {
o.appendChild(fill); o.appendChild(fill);
} }
return 1; return 1;
}; },
Element = function (node, vml) { Element = function (node, vml) {
this[0] = this.node = node; this[0] = this.node = node;
node.raphael = true; node.raphael = true;
...@@ -574,16 +574,12 @@ window.Raphael.vml && function (R) { ...@@ -574,16 +574,12 @@ window.Raphael.vml && function (R) {
if (this.removed) { if (this.removed) {
return {}; return {};
} }
if (this.type == "text") { return {
return { x: this.X + (this.bbx || 0) - this.W / 2,
x: this.X + (this.bbx || 0) - this.W / 2, y: this.Y - this.H,
y: this.Y - this.H, width: this.W,
width: this.W, height: this.H
height: this.H };
};
} else {
return pathDimensions(this.attrs.path);
}
}; };
elproto.remove = function () { elproto.remove = function () {
if (this.removed) { if (this.removed) {
...@@ -595,7 +591,7 @@ window.Raphael.vml && function (R) { ...@@ -595,7 +591,7 @@ window.Raphael.vml && function (R) {
this.node.parentNode.removeChild(this.node); this.node.parentNode.removeChild(this.node);
this.shape && this.shape.parentNode.removeChild(this.shape); this.shape && this.shape.parentNode.removeChild(this.shape);
for (var i in this) { for (var i in this) {
delete this[i]; this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
} }
this.removed = true; this.removed = true;
}; };
...@@ -856,7 +852,7 @@ window.Raphael.vml && function (R) { ...@@ -856,7 +852,7 @@ window.Raphael.vml && function (R) {
cs.height = height; cs.height = height;
cs.clip = "rect(0 " + width + " " + height + " 0)"; cs.clip = "rect(0 " + width + " " + height + " 0)";
if (this._viewBox) { if (this._viewBox) {
setViewBox.apply(this, this._viewBox); R._engine.setViewBox.apply(this, this._viewBox);
} }
return this; return this;
}; };
...@@ -887,8 +883,8 @@ window.Raphael.vml && function (R) { ...@@ -887,8 +883,8 @@ window.Raphael.vml && function (R) {
}); });
return this; return this;
}; };
var createNode, var createNode;
initWin = function (win) { R._engine.initWin = function (win) {
var doc = win.document; var doc = win.document;
doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"); doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");
try { try {
...@@ -902,7 +898,7 @@ window.Raphael.vml && function (R) { ...@@ -902,7 +898,7 @@ window.Raphael.vml && function (R) {
}; };
} }
}; };
initWin(R._g.win); R._engine.initWin(R._g.win);
R._engine.create = function () { R._engine.create = function () {
var con = R._getContainer.apply(0, arguments), var con = R._getContainer.apply(0, arguments),
container = con.container, container = con.container,
...@@ -959,7 +955,7 @@ window.Raphael.vml && function (R) { ...@@ -959,7 +955,7 @@ window.Raphael.vml && function (R) {
R.eve("remove", this); R.eve("remove", this);
this.canvas.parentNode.removeChild(this.canvas); this.canvas.parentNode.removeChild(this.canvas);
for (var i in this) { for (var i in this) {
this[i] = removed(i); this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
} }
return true; return true;
}; };
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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