summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xCHANGELOG.md9
-rwxr-xr-xREADME.md22
-rwxr-xr-xRakefile18
-rwxr-xr-xbower.json2
-rwxr-xr-xcomponent.json2
-rwxr-xr-xdist/svg.js96
-rwxr-xr-xdist/svg.min.js5
-rwxr-xr-xpackage.json2
-rwxr-xr-xspec/index.html3
-rwxr-xr-xspec/spec/element.js14
-rw-r--r--spec/spec/event.js385
-rwxr-xr-xspec/spec/helper.js23
-rw-r--r--spec/spec/selector.js2
-rwxr-xr-xspec/spec/svg.js2
-rwxr-xr-xsrc/element.js8
-rwxr-xr-xsrc/event.js55
-rw-r--r--src/polyfill.js14
-rwxr-xr-xsrc/rbox.js4
18 files changed, 599 insertions, 67 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dba814e..2667d2d 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,7 @@
-# 1.0.0-rc.10 (?/?/2014)
+# 1.0.0 (?/09/2014)
-- remove internal references everywhere -> __TODO!__
-- rework transformation to be chainable and more true to native SVG -> __TODO!__
-- implement an SVG adoption system to be able to manipulate existing SVG's not created with svg.js -> __TODO!__
-- fixed a bug in clipping and masking where empty nodes persists after removal -> __TODO!__
-- added support to clone manually built text elements -> __TODO!__
+- fixed event module
+- removed `mouseenter` and `mouseleave` events because they are not supported by IE
# 1.0.0-rc.9 (17/06/2014)
diff --git a/README.md b/README.md
index d44bce4..8066600 100755
--- a/README.md
+++ b/README.md
@@ -8,8 +8,6 @@ Svg.js is licensed under the terms of the MIT License.
See [svgjs.com](http://svgjs.com) for an introduction, [documentation](http://documentup.com/wout/svg.js) and [some action](http://svgjs.com/test).
-[![Wout on Gittip](http://files.wout.co.uk/github/gittip.png)](https://www.gittip.com/wout/)
-
## Usage
### Create a SVG document
@@ -77,7 +75,7 @@ var draw = SVG('drawing').fixSubPixelOffset()
## Parent elements
### Main svg document
-The main svg.js initializer function creates a root svg node in the given element and retuns an instance of `SVG.Doc`:
+The main svg.js initializer function creates a root svg node in the given element and returns an instance of `SVG.Doc`:
```javascript
var draw = SVG('drawing')
@@ -893,7 +891,7 @@ group.has(rect) //-> returns false
__`returns`: `boolean`__
### index()
-Returns the index of given element and retuns -1 when it is not a child:
+Returns the index of given element and returns -1 when it is not a child:
```javascript
var rect = draw.rect(100, 50)
@@ -1579,7 +1577,7 @@ Pausing an animations is fairly straightforward:
```javascript
rect.animate().move(200, 200)
-rect.mouseenter(function() { this.pause() })
+rect.mouseover(function() { this.pause() })
```
__`returns`: `itself`__
@@ -1590,8 +1588,8 @@ Will start playing a paused animation:
```javascript
rect.animate().move(200, 200)
-rect.mouseenter(function() { this.pause() })
-rect.mouseleave(function() { this.play() })
+rect.mouseover(function() { this.pause() })
+rect.mouseout(function() { this.play() })
```
__`returns`: `itself`__
@@ -1686,7 +1684,7 @@ Note that the `after()` method will never be called if the animation is looping
__`returns`: `SVG.FX`__
### to()
-Say you want to control the position of an animation with an external event, then the `to()` method will proove very useful:
+Say you want to control the position of an animation with an external event, then the `to()` method will prove to be very useful:
```javascript
var animate = draw.rect(100, 100).move(50, 50).animate('=').move(200, 200)
@@ -2589,7 +2587,7 @@ Removing it is quite as easy:
rect.click(null)
```
-All available evenets are: `click`, `dblclick`, `mousedown`, `mouseup`, `mouseover`, `mouseout`, `mousemove`, `mouseenter`, `mouseleave`, `touchstart`, `touchmove`, `touchleave`, `touchend` and `touchcancel`.
+All available evenets are: `click`, `dblclick`, `mousedown`, `mouseup`, `mouseover`, `mouseout`, `mousemove`, `touchstart`, `touchmove`, `touchleave`, `touchend` and `touchcancel`.
__`returns`: `itself`__
@@ -2954,10 +2952,10 @@ Note that this method is currently not available on `SVG.PathArray` but will be
__`returns`: `itself`__
### move()
-Moves geometry of the array with the given `x` and `y` values:
+Moves geometry to a given `x` and `y` position by its upper left corner:
```javascript
-var array = new SVG.PointArray([[0, 0], [100, 100]])
+var array = new SVG.PointArray([[10, 10], [100, 100]])
array.move(33,75)
array.toString() //-> returns '33,75 133,175'
```
@@ -3005,7 +3003,7 @@ __`returns`: `object`__
## Extending functionality
### SVG.invent()
-Creating your own custom elements with svg.js is piece of cake thanks to the `SVG.invent` function. For the sake of this example, lets "invent" a shape. We want a `rect` with rounded corners that are always proportional to the height of the element. The new shape lives in the `SVG` namespace and is called `Rounded`. Here is how we achieve that.
+Creating your own custom elements with svg.js is a piece of cake thanks to the `SVG.invent` function. For the sake of this example, let's "invent" a shape. We want a `rect` with rounded corners that are always proportional to the height of the element. The new shape lives in the `SVG` namespace and is called `Rounded`. Here is how we achieve that.
```javascript
SVG.Rounded = SVG.invent({
diff --git a/Rakefile b/Rakefile
index 03d37f8..3dcefb4 100755
--- a/Rakefile
+++ b/Rakefile
@@ -1,7 +1,7 @@
-SVGJS_VERSION = '1.0.0-rc.9'
+SVGJS_VERSION = '1.0.0'
# all available modules in the correct loading order
-MODULES = %w[ svg selector inventor regex default color array pointarray patharray number viewbox bbox rbox element parent container fx relative event defs group arrange mask clip gradient pattern doc shape symbol use rect ellipse line poly path image text textpath nested hyperlink marker sugar set data memory loader helpers ]
+MODULES = %w[ svg selector inventor polyfill regex default color array pointarray patharray number viewbox bbox rbox element parent container fx relative event defs group arrange mask clip gradient pattern doc shape symbol use rect ellipse line poly path image text textpath nested hyperlink marker sugar set data memory loader helpers ]
# how many bytes in a "kilobyte"
KILO = 1024
@@ -54,11 +54,19 @@ BuildTask.define_task 'dist/svg.js' => MODULES.map {|m| "src/#{ m }.js" } do |ta
File.open(task.name, 'w') do |file|
file.puts "/* svg.js %s - %s - svgjs.com/license */" % [version_string, task.modules.join(' ')]
-
- file.puts ';(function() {'
+ file.puts ";(function(root, factory) {"
+ file.puts " if (typeof define === 'function' && define.amd) {"
+ file.puts " define(factory);"
+ file.puts " } else if (typeof exports === 'object') {"
+ file.puts " module.exports = factory();"
+ file.puts " } else {"
+ file.puts " root.SVG = factory();"
+ file.puts " }"
+ file.puts "}(this, function() {"
file.puts "\n"
file.puts svgjs
- file.puts '}).call(this);'
+ file.puts " return SVG"
+ file.puts "}));"
end
end
diff --git a/bower.json b/bower.json
index 7ddcee4..c6527ed 100755
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "svg.js",
- "version":"1.0.0-rc.9",
+ "version":"1.0.0",
"homepage": "http://svgjs.com/",
"authors": [
"Wout Fierens <wout@impinc.co.uk>"
diff --git a/component.json b/component.json
index ebdd7c1..9bc4468 100755
--- a/component.json
+++ b/component.json
@@ -2,7 +2,7 @@
"name": "svg.js",
"repo": "wout/svg.js",
"description": "A lightweight library for manipulating and animating SVG",
- "version": "1.0.0-rc.9",
+ "version": "1.0.0",
"keywords": ["svg"],
"author": "Wout Fierens <wout@impinc.co.uk>",
"main": "dist/svg.js",
diff --git a/dist/svg.js b/dist/svg.js
index 49f2b02..7176d27 100755
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -1,5 +1,13 @@
-/* svg.js 1.0.0-rc.10-4-gf47dddc - svg selector inventor regex default color array pointarray patharray number viewbox bbox rbox element parent container fx relative event defs group arrange mask clip gradient pattern doc shape symbol use rect ellipse line poly path image text textpath nested hyperlink marker sugar set data memory loader helpers - svgjs.com/license */
-;(function() {
+/* svg.js 1.0.1 - svg selector inventor polyfill regex default color array pointarray patharray number viewbox bbox rbox element parent container fx relative event defs group arrange mask clip gradient pattern doc shape symbol use rect ellipse line poly path image text textpath nested hyperlink marker sugar set data memory loader helpers - svgjs.com/license */
+;(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(factory);
+ } else if (typeof exports === 'object') {
+ module.exports = factory();
+ } else {
+ root.SVG = factory();
+ }
+}(this, function() {
var SVG = this.SVG = function(element) {
if (SVG.supported) {
@@ -112,6 +120,20 @@
return initializer
}
+ if (typeof CustomEvent !== 'function') {
+ // Code from: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
+ function CustomEvent (event, options) {
+ options = options || { bubbles: false, cancelable: false, detail: undefined }
+ var e = document.createEvent('CustomEvent')
+ e.initCustomEvent(event, options.bubbles, options.cancelable, options.detail)
+ return e
+ }
+
+ CustomEvent.prototype = window.Event.prototype
+
+ window.CustomEvent = CustomEvent
+ }
+
SVG.regex = {
/* parse unit value */
unit: /^(-?[\d\.]+)([a-z%]{0,2})$/
@@ -961,8 +983,8 @@
this.height = box.height /= zoom
/* offset by window scroll position, because getBoundingClientRect changes when window is scrolled */
- this.x += window.scrollX;
- this.y += window.scrollY;
+ this.x += typeof window.scrollX === 'number' ? window.scrollX : window.pageXOffset
+ this.y += typeof window.scrollY === 'number' ? window.scrollY : window.pageYOffset
/* add center, right and bottom */
boxProperties(this)
@@ -1135,11 +1157,11 @@
} else if (v == null) {
/* act as a getter if the first and only argument is not an object */
- v = this.node.getAttribute(a)
+ v = this.node.attributes[a]
return v == null ?
SVG.defaults.attrs[a] :
- SVG.regex.isNumber.test(v) ?
- parseFloat(v) : v
+ SVG.regex.isNumber.test(v.nodeValue) ?
+ parseFloat(v.nodeValue) : v.nodeValue
} else if (a == 'style') {
/* redirect to the style method */
@@ -1380,7 +1402,7 @@
}
// Get referenced element form attribute value
, reference: function(attr) {
- return SVG.get(this.attr(attr))
+ return SVG.get(this.attr()[attr])
}
// Private: find svg parent by instance
, _parent: function(parent) {
@@ -2015,8 +2037,8 @@
, 'mouseover'
, 'mouseout'
, 'mousemove'
- , 'mouseenter'
- , 'mouseleave'
+ // , 'mouseenter' -> not supported by IE
+ // , 'mouseleave' -> not supported by IE
, 'touchstart'
, 'touchmove'
, 'touchleave'
@@ -2043,20 +2065,54 @@
// Event constructor
SVG.registerEvent = function(event) {
if (!SVG.events[event])
- SVG.events[event] = new Event(event)
+ SVG.events[event] = new CustomEvent(event)
}
// Add event binder in the SVG namespace
SVG.on = function(node, event, listener) {
+ // create listener
var l = listener.bind(node.instance || node)
- SVG.listeners[listener] = l
+
+ // ensure reference objects
+ SVG.listeners[node] = SVG.listeners[node] || {}
+ SVG.listeners[node][event] = SVG.listeners[node][event] || {}
+
+ // reference listener
+ SVG.listeners[node][event][listener] = l
+
+ // add listener
node.addEventListener(event, l, false)
}
// Add event unbinder in the SVG namespace
SVG.off = function(node, event, listener) {
- node.removeEventListener(event, SVG.listeners[listener], false)
- delete SVG.listeners[listener]
+ if (listener) {
+ // remove listener reference
+ if (SVG.listeners[node] && SVG.listeners[node][event]) {
+ // remove listener
+ node.removeEventListener(event, SVG.listeners[node][event][listener], false)
+
+ delete SVG.listeners[node][event][listener]
+ }
+
+ } else if (event) {
+ // remove all listeners for the event
+ if (SVG.listeners[node][event]) {
+ for (listener in SVG.listeners[node][event])
+ SVG.off(node, event, listener)
+
+ delete SVG.listeners[node][event]
+ }
+
+ } else {
+ // remove all listeners on a given node
+ if (SVG.listeners[node]) {
+ for (event in SVG.listeners[node])
+ SVG.off(node, event)
+
+ delete SVG.listeners[node]
+ }
+ }
}
//
@@ -2074,9 +2130,16 @@
return this
}
// Fire given event
- , fire: function(event) {
+ , fire: function(event, data) {
+ // Add detail data to event
+ SVG.events[event].detail = data
+
+ // Dispatch event
this.node.dispatchEvent(SVG.events[event])
+ // Remove detail
+ delete SVG.events[event].detail
+
return this
}
})
@@ -3825,4 +3888,5 @@
function (c) { window.setTimeout(c, 1000 / 60) }
})()
-}).call(this);
+ return SVG
+}));
diff --git a/dist/svg.min.js b/dist/svg.min.js
index 24a923b..4992e32 100755
--- a/dist/svg.min.js
+++ b/dist/svg.min.js
@@ -1,2 +1,3 @@
-(function(){function t(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function e(t){return 4==t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}function i(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function n(t,e,i){return(null==e||null==i)&&(null==i?i=t.height/t.width*e:null==e&&(e=t.width/t.height*i)),{width:e,height:i}}function r(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof u.Color||t instanceof u.Number?t.at(e):1>e?t.from:t.to}function s(t){for(var e=0,i=t.length,n="";i>e;e++)n+=t[e][0],null!=t[e][1]&&(n+=t[e][1],null!=t[e][2]&&(n+=" ",n+=t[e][2],null!=t[e][3]&&(n+=" ",n+=t[e][3],n+=" ",n+=t[e][4],null!=t[e][5]&&(n+=" ",n+=t[e][5],n+=" ",n+=t[e][6],null!=t[e][7]&&(n+=" ",n+=t[e][7])))));return n+" "}function h(t){t.x2=t.x+t.width,t.y2=t.y+t.height,t.cx=t.x+t.width/2,t.cy=t.y+t.height/2}function o(t){if(t.matrix){var e=t.matrix.replace(/\s/g,"").split(",");6==e.length&&(t.a=parseFloat(e[0]),t.b=parseFloat(e[1]),t.c=parseFloat(e[2]),t.d=parseFloat(e[3]),t.e=parseFloat(e[4]),t.f=parseFloat(e[5]))}return t}function a(t){var e=t.toString().match(u.regex.reference);return e?e[1]:void 0}var u=this.SVG=function(t){return u.supported?(t=new u.Doc(t),u.parser||u.prepare(t),t):void 0};if(u.ns="http://www.w3.org/2000/svg",u.xmlns="http://www.w3.org/2000/xmlns/",u.xlink="http://www.w3.org/1999/xlink",u.did=1e3,u.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+u.did++},u.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},u.extend=function(){var t,e,i,n;for(t=[].slice.call(arguments),e=t.pop(),n=t.length-1;n>=0;n--)if(t[n])for(i in e)t[n].prototype[i]=e[i];u.Set&&u.Set.inherit&&u.Set.inherit()},u.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new u.Doc(e):t.nested()).size(2,0),n=u.create("path");i.node.appendChild(n),u.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},u.supported=function(){return!!document.createElementNS&&!!document.createElementNS(u.ns,"svg").createSVGRect}(),!u.supported)return!1;u.get=function(t){var e=document.getElementById(a(t)||t);return e?e.instance:void 0},u.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,u.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&u.extend(e,t.extend),t.construct&&u.extend(t.parent||u.Container,t.construct),e},u.regex={unit:/^(-?[\d\.]+)([a-z%]{0,2})$/,hex:/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,rgb:/rgb\((\d+),(\d+),(\d+)\)/,reference:/#([a-z0-9\-_]+)/i,isHex:/^#[a-f0-9]{3,6}$/i,isRgb:/^rgb\(/,isCss:/[^:]+:[^;]+;?/,isBlank:/^(\s+)?$/,isNumber:/^-?[\d\.]+$/,isPercent:/^-?[\d\.]+%$/,isImage:/\.(jpg|jpeg|png|gif)(\?[^=]+.*)?/i,isEvent:/^[\w]+:[\w]+$/},u.defaults={matrix:"1 0 0 1 0 0",attrs:{"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","font-size":16,"font-family":"Helvetica, Arial, sans-serif","text-anchor":"start"},trans:function(){return{x:0,y:0,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0,matrix:this.matrix,a:1,b:0,c:0,d:1,e:0,f:0}}},u.Color=function(t){var i;this.r=0,this.g=0,this.b=0,"string"==typeof t?u.regex.isRgb.test(t)?(i=u.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(i[1]),this.g=parseInt(i[2]),this.b=parseInt(i[3])):u.regex.isHex.test(t)&&(i=u.regex.hex.exec(e(t)),this.r=parseInt(i[1],16),this.g=parseInt(i[2],16),this.b=parseInt(i[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},u.extend(u.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+i(this.r)+i(this.g)+i(this.b)},toRgb:function(){return"rgb("+[this.r,this.g,this.b].join()+")"},brightness:function(){return this.r/255*.3+this.g/255*.59+this.b/255*.11},morph:function(t){return this.destination=new u.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new u.Color({r:~~(this.r+(this.destination.r-this.r)*t),g:~~(this.g+(this.destination.g-this.g)*t),b:~~(this.b+(this.destination.b-this.b)*t)})):this}}),u.Color.test=function(t){return t+="",u.regex.isHex.test(t)||u.regex.isRgb.test(t)},u.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},u.Color.isColor=function(t){return u.Color.isRgb(t)||u.Color.test(t)},u.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},u.extend(u.Array,{morph:function(t){if(this.destination=this.parse(t),this.value.length!=this.destination.length){for(var e=this.value[this.value.length-1],i=this.destination[this.destination.length-1];this.value.length>this.destination.length;)this.destination.push(i);for(;this.value.length<this.destination.length;)this.value.push(e)}return this},settle:function(){for(var t=0,e=this.value.length,i=[];e>t;t++)-1==i.indexOf(this.value[t])&&i.push(this.value[t]);return this.value=i},at:function(t){if(!this.destination)return this;for(var e=0,i=this.value.length,n=[];i>e;e++)n.push(this.value[e]+(this.destination[e]-this.value[e])*t);return new u.Array(n)},toString:function(){return this.value.join(" ")},valueOf:function(){return this.value},parse:function(t){return t=t.valueOf(),Array.isArray(t)?t:this.split(t)},split:function(t){return t.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"").split(" ")},reverse:function(){return this.value.reverse(),this}}),u.PointArray=function(){this.constructor.apply(this,arguments)},u.PointArray.prototype=new u.Array,u.extend(u.PointArray,{toString:function(){for(var t=0,e=this.value.length,i=[];e>t;t++)i.push(this.value[t].join(","));return i.join(" ")},at:function(t){if(!this.destination)return this;for(var e=0,i=this.value.length,n=[];i>e;e++)n.push([this.value[e][0]+(this.destination[e][0]-this.value[e][0])*t,this.value[e][1]+(this.destination[e][1]-this.value[e][1])*t]);return new u.PointArray(n)},parse:function(t){if(t=t.valueOf(),Array.isArray(t))return t;t=this.split(t);for(var e,i=0,n=t.length,r=[];n>i;i++)e=t[i].split(","),r.push([parseFloat(e[0]),parseFloat(e[1])]);return r},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n=this.value.length-1;n>=0;n--)this.value[n]=[this.value[n][0]+t,this.value[n][1]+e];return this},size:function(t,e){var i,n=this.bbox();for(i=this.value.length-1;i>=0;i--)this.value[i][0]=(this.value[i][0]-n.x)*t/n.width+n.x,this.value[i][1]=(this.value[i][1]-n.y)*e/n.height+n.y;return this},bbox:function(){return u.parser.poly.setAttribute("points",this.toString()),u.parser.poly.getBBox()}}),u.PathArray=function(t,e){this.constructor.call(this,t,e)},u.PathArray.prototype=new u.Array,u.extend(u.PathArray,{toString:function(){return s(this.value)},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n,r=this.value.length-1;r>=0;r--)n=this.value[r][0],"M"==n||"L"==n||"T"==n?(this.value[r][1]+=t,this.value[r][2]+=e):"H"==n?this.value[r][1]+=t:"V"==n?this.value[r][1]+=e:"C"==n||"S"==n||"Q"==n?(this.value[r][1]+=t,this.value[r][2]+=e,this.value[r][3]+=t,this.value[r][4]+=e,"C"==n&&(this.value[r][5]+=t,this.value[r][6]+=e)):"A"==n&&(this.value[r][6]+=t,this.value[r][7]+=e);return this},size:function(t,e){var i,n,r=this.bbox();for(i=this.value.length-1;i>=0;i--)n=this.value[i][0],"M"==n||"L"==n||"T"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y):"H"==n?this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x:"V"==n?this.value[i][1]=(this.value[i][1]-r.y)*e/r.height+r.y:"C"==n||"S"==n||"Q"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y,this.value[i][3]=(this.value[i][3]-r.x)*t/r.width+r.x,this.value[i][4]=(this.value[i][4]-r.y)*e/r.height+r.y,"C"==n&&(this.value[i][5]=(this.value[i][5]-r.x)*t/r.width+r.x,this.value[i][6]=(this.value[i][6]-r.y)*e/r.height+r.y)):"A"==n&&(this.value[i][1]=this.value[i][1]*t/r.width,this.value[i][2]=this.value[i][2]*e/r.height,this.value[i][6]=(this.value[i][6]-r.x)*t/r.width+r.x,this.value[i][7]=(this.value[i][7]-r.y)*e/r.height+r.y);return this},parse:function(t){if(t instanceof u.PathArray)return t.valueOf();var e,i,n,r,h,o,a,l,c,f,d,p=0,x=0;for(u.parser.path.setAttribute("d","string"==typeof t?t:s(t)),d=u.parser.path.pathSegList,e=0,i=d.numberOfItems;i>e;++e)f=d.getItem(e),c=f.pathSegTypeAsLetter,"M"==c||"L"==c||"H"==c||"V"==c||"C"==c||"S"==c||"Q"==c||"T"==c||"A"==c?("x"in f&&(p=f.x),"y"in f&&(x=f.y)):("x1"in f&&(h=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(l=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(u.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(u.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(u.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(u.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(u.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,h,o,a,l),e):"s"==c?d.replaceItem(u.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,a,l),e):"q"==c?d.replaceItem(u.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,h,o),e):"t"==c?d.replaceItem(u.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(u.parser.path.createSVGPathSegArcAbs(p,x,f.r1,f.r2,f.angle,f.largeArcFlag,f.sweepFlag),e):("z"==c||"Z"==c)&&(p=n,x=r)),("M"==c||"m"==c)&&(n=p,r=x);for(t=[],d=u.parser.path.pathSegList,e=0,i=d.numberOfItems;i>e;++e)f=d.getItem(e),c=f.pathSegTypeAsLetter,p=[c],"M"==c||"L"==c||"T"==c?p.push(f.x,f.y):"H"==c?p.push(f.x):"V"==c?p.push(f.y):"C"==c?p.push(f.x1,f.y1,f.x2,f.y2,f.x,f.y):"S"==c?p.push(f.x2,f.y2,f.x,f.y):"Q"==c?p.push(f.x1,f.y1,f.x,f.y):"A"==c&&p.push(f.r1,f.r2,f.angle,0|f.largeArcFlag,0|f.sweepFlag,f.x,f.y),t.push(p);return t},bbox:function(){return u.parser.path.setAttribute("d",this.toString()),u.parser.path.getBBox()}}),u.Number=function(t){if(this.value=0,this.unit="","number"==typeof t)this.value=isNaN(t)?0:isFinite(t)?t:0>t?-3.4e38:3.4e38;else if("string"==typeof t){var e=t.match(u.regex.unit);e&&(this.value=parseFloat(e[1]),"%"==e[2]?this.value/=100:"s"==e[2]&&(this.value*=1e3),this.unit=e[2])}else t instanceof u.Number&&(this.value=t.value,this.unit=t.unit)},u.extend(u.Number,{toString:function(){return("%"==this.unit?~~(1e8*this.value)/1e6:"s"==this.unit?this.value/1e3:this.value)+this.unit},valueOf:function(){return this.value},plus:function(t){return this.value=this+new u.Number(t),this},minus:function(t){return this.plus(-new u.Number(t))},times:function(t){return this.value=this*new u.Number(t),this},divide:function(t){return this.value=this/new u.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new u.Number(t),this},at:function(t){return this.destination?new u.Number(this.destination).minus(this).times(t).plus(this):this}}),u.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),l=t,c=t;for(n=new u.Number(t.width()),r=new u.Number(t.height());"%"==n.unit;)s*=n.value,n=new u.Number(l instanceof u.Doc?l.parent.offsetWidth:l.parent.width()),l=l.parent;for(;"%"==r.unit;)h*=r.value,r=new u.Number(c instanceof u.Doc?c.parent.offsetHeight:c.parent.height()),c=c.parent;this.x=o.x,this.y=o.y,this.width=n*s,this.height=r*h,this.zoom=1,a&&(e=parseFloat(a[0]),i=parseFloat(a[1]),n=parseFloat(a[2]),r=parseFloat(a[3]),this.zoom=this.width/this.height>n/r?this.height/r:this.width/n,this.x=e,this.y=i,this.width=n,this.height=r)},u.extend(u.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),u.BBox=function(t){var e;if(this.x=0,this.y=0,this.width=0,this.height=0,t){try{e=t.node.getBBox()}catch(i){e={x:t.node.clientLeft,y:t.node.clientTop,width:t.node.clientWidth,height:t.node.clientHeight}}this.x=e.x+t.trans.x,this.y=e.y+t.trans.y,this.width=e.width*t.trans.scaleX,this.height=e.height*t.trans.scaleY}h(this)},u.extend(u.BBox,{merge:function(t){var e=new u.BBox;return e.x=Math.min(this.x,t.x),e.y=Math.min(this.y,t.y),e.width=Math.max(this.x+this.width,t.x+t.width)-e.x,e.height=Math.max(this.y+this.height,t.y+t.height)-e.y,h(e),e}}),u.RBox=function(t){var e,i,n={};if(this.x=0,this.y=0,this.width=0,this.height=0,t){for(e=t.doc().parent,i=t.doc().viewbox().zoom,n=t.node.getBoundingClientRect(),this.x=n.left,this.y=n.top,this.x-=e.offsetLeft,this.y-=e.offsetTop;e=e.offsetParent;)this.x-=e.offsetLeft,this.y-=e.offsetTop;for(e=t;e=e.parent;)"svg"==e.type&&e.viewbox&&(i*=e.viewbox().zoom,this.x-=e.x()||0,this.y-=e.y()||0)}this.x/=i,this.y/=i,this.width=n.width/=i,this.height=n.height/=i,this.x+=window.scrollX,this.y+=window.scrollY,h(this)},u.extend(u.RBox,{merge:function(t){var e=new u.RBox;return e.x=Math.min(this.x,t.x),e.y=Math.min(this.y,t.y),e.width=Math.max(this.x+this.width,t.x+t.width)-e.x,e.height=Math.max(this.y+this.height,t.y+t.height)-e.y,h(e),e}}),u.Element=u.invent({create:function(t){this._stroke=u.defaults.attrs.stroke,this.trans=u.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new u.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new u.Number(t),t.value/=this.trans.scaleY),this.attr("y",t)},cx:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)},cy:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},width:function(t){return this.attr("width",t)},height:function(t){return this.attr("height",t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.width(new u.Number(i.width)).height(new u.Number(i.height))},clone:function(){var t,e,i=this.type;return t="rect"==i||"ellipse"==i?this.parent[i](0,0):"line"==i?this.parent[i](0,0,0,0):"image"==i?this.parent[i](this.src):"text"==i?this.parent[i](this.content):"path"==i?this.parent[i](this.attr("d")):"polyline"==i||"polygon"==i?this.parent[i](this.attr("points")):"g"==i?this.parent.group():this.parent[i](),e=this.attr(),delete e.id,t.attr(e),t.trans=this.trans,t.transform({})},remove:function(){return this.parent&&this.parent.removeElement(this),this},replace:function(t){return this.after(t).remove(),t},addTo:function(t){return t.put(this)},putIn:function(t){return t.add(this)},doc:function(t){return this._parent(t||u.Doc)},attr:function(t,e,i){if(null==t){for(t={},e=this.node.attributes,i=e.length-1;i>=0;i--)t[e[i].nodeName]=u.regex.isNumber.test(e[i].nodeValue)?parseFloat(e[i].nodeValue):e[i].nodeValue;return t}if("object"==typeof t)for(e in t)this.attr(e,t[e]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return e=this.node.getAttribute(t),null==e?u.defaults.attrs[t]:u.regex.isNumber.test(e)?parseFloat(e):e;if("style"==t)return this.style(e);"stroke-width"==t?this.attr("stroke",parseFloat(e)>0?this._stroke:null):"stroke"==t&&(this._stroke=e),("fill"==t||"stroke"==t)&&(u.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof u.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new u.Number(e):u.Color.isColor(e)?e=new u.Color(e):Array.isArray(e)&&(e=new u.Array(e)),"leading"==t?this.leading&&this.leading(e):"string"==typeof i?this.node.setAttributeNS(i,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!=t&&"x"!=t||this.rebuild(t,e)}return this},transform:function(t,e){if(0==arguments.length)return this.trans;if("string"==typeof t){if(arguments.length<2)return this.trans[t];var i={};return i[t]=e,this.transform(i)}var i=[];t=o(t);for(e in t)null!=t[e]&&(this.trans[e]=t[e]);return this.trans.matrix=this.trans.a+" "+this.trans.b+" "+this.trans.c+" "+this.trans.d+" "+this.trans.e+" "+this.trans.f,t=this.trans,t.matrix!=u.defaults.matrix&&i.push("matrix("+t.matrix+")"),0!=t.rotation&&i.push("rotate("+t.rotation+" "+(null==t.cx?this.bbox().cx:t.cx)+" "+(null==t.cy?this.bbox().cy:t.cy)+")"),(1!=t.scaleX||1!=t.scaleY)&&i.push("scale("+t.scaleX+" "+t.scaleY+")"),0!=t.skewX&&i.push("skewX("+t.skewX+")"),0!=t.skewY&&i.push("skewY("+t.skewY+")"),(0!=t.x||0!=t.y)&&i.push("translate("+new u.Number(t.x/t.scaleX)+" "+new u.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(e,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof e)for(i in e)this.style(i,e[i]);else{if(!u.regex.isCss.test(e))return this.node.style[t(e)];e=e.split(";");for(var n=0;n<e.length;n++)i=e[n].split(":"),this.style(i[0].replace(/\s+/g,""),i[1])}else this.node.style[t(e)]=null===i||u.regex.isBlank.test(i)?"":i;return this},id:function(t){return this.attr("id",t)},bbox:function(){return new u.BBox(this)},rbox:function(){return new u.RBox(this)},inside:function(t,e){var i=this.bbox();return t>i.x&&e>i.y&&t<i.x+i.width&&e<i.y+i.height},show:function(){return this.style("display","")},hide:function(){return this.style("display","none")},visible:function(){return"none"!=this.style("display")},toString:function(){return this.attr("id")},classes:function(){var t=this.node.getAttribute("class");return null===t?[]:t.trim().split(/\s+/)},hasClass:function(t){return-1!=this.classes().indexOf(t)},addClass:function(t){var e;return this.hasClass(t)||(e=this.classes(),e.push(t),this.node.setAttribute("class",e.join(" "))),this},removeClass:function(t){var e;return this.hasClass(t)&&(e=this.classes().filter(function(e){return e!=t}),this.node.setAttribute("class",e.join(" "))),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t),this},reference:function(t){return u.get(this.attr(t))},_parent:function(t){for(var e=this;null!=e&&!(e instanceof t);)e=e.parent;return e}}}),u.Parent=u.invent({create:function(t){this.constructor.call(this,t)},inherit:u.Element,extend:{children:function(){return this._children||(this._children=[])},add:function(t,e){return this.has(t)||(e=null==e?this.children().length:e,t.parent&&t.parent.children().splice(t.parent.index(t),1),this.children().splice(e,0,t),this.node.insertBefore(t.node,this.node.childNodes[e]||null),t.parent=this),this._defs&&(this.node.removeChild(this._defs.node),this.node.appendChild(this._defs.node)),this},put:function(t,e){return this.add(t,e),t},has:function(t){return this.index(t)>=0},index:function(t){return this.children().indexOf(t)},get:function(t){return this.children()[t]},first:function(){return this.children()[0]},last:function(){return this.children()[this.children().length-1]},each:function(t,e){var i,n,r=this.children();for(i=0,n=r.length;n>i;i++)r[i]instanceof u.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof u.Container&&r[i].each(t,e);return this},removeElement:function(t){return this.children().splice(this.index(t),1),this.node.removeChild(t.node),t.parent=null,this},clear:function(){for(var t=this.children().length-1;t>=0;t--)this.removeElement(this.children()[t]);return this._defs&&this._defs.clear(),this},defs:function(){return this.doc().defs()}}}),u.Container=u.invent({create:function(t){this.constructor.call(this,t)},inherit:u.Parent,extend:{viewbox:function(t){return 0==arguments.length?new u.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),u.FX=u.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,s,h,o,a=this.target,l=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new u.Number(t).valueOf(),e=e||"<>",l.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in l.attrs)n.push(o);if(a.morphArray&&(l._plot||n.indexOf("points")>-1)){var u,c=new a.morphArray(l._plot||l.attrs.points||a.array);l._size&&c.size(l._size.width.to,l._size.height.to),u=c.bbox(),l._x?c.move(l._x.to,u.y):l._cx&&c.move(l._cx.to-u.width/2,u.y),u=c.bbox(),l._y?c.move(u.x,l._y.to):l._cy&&c.move(u.x,l._cy.to-u.height/2),delete l._x,delete l._y,delete l._cx,delete l._cy,delete l._size,l._plot=a.array.morph(c)}}if(null==s){s=[];for(o in l.trans)s.push(o)}if(null==h){h=[];for(o in l.styles)h.push(o)}for(t="<>"==e?-Math.cos(t*Math.PI)/2+.5:">"==e?Math.sin(t*Math.PI/2):"<"==e?-Math.cos(t*Math.PI/2)+1:"-"==e?t:"function"==typeof e?e(t):t,l._plot?a.plot(l._plot.at(t)):(l._x?a.x(l._x.at(t)):l._cx&&a.cx(l._cx.at(t)),l._y?a.y(l._y.at(t)):l._cy&&a.cy(l._cy.at(t)),l._size&&a.size(l._size.width.at(t),l._size.height.at(t))),l._viewbox&&a.viewbox(l._viewbox.x.at(t),l._viewbox.y.at(t),l._viewbox.width.at(t),l._viewbox.height.at(t)),l._leading&&a.leading(l._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],r(l.attrs[n[i]],t));for(i=s.length-1;i>=0;i--)a.transform(s[i],r(l.trans[s[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],r(l.styles[h[i]],t));l._during&&l._during.call(a,t,function(e,i){return r({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();l.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},l.render=function(){if(l.situation.play===!0){var n=(new Date).getTime(),r=n>l.situation.finish?1:(n-l.situation.start)/t;l.to(r),n>l.situation.finish?(l._plot&&a.plot(new u.PointArray(l._plot.destination).settle()),l._loop===!0||"number"==typeof l._loop&&l._loop>1?("number"==typeof l._loop&&--l._loop,l.animate(t,e,i)):l._after?l._after.apply(a,[l]):l.stop()):requestAnimFrame(l.render)}else requestAnimFrame(l.render)},l.render()},new u.Number(i).valueOf())),this},bbox:function(){return this.target.bbox()},attr:function(t,e){if("object"==typeof t)for(var i in t)this.attr(i,t[i]);else{var n=this.target.attr(t);this.attrs[t]=u.Color.isColor(n)?new u.Color(n).morph(e):u.regex.unit.test(n)?new u.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=o(t),delete t.matrix;for(e in t)this.trans[e]={from:this.target.trans[e],to:t[e]}}else{var i={};i[t]=e,this.transform(i)}return this},style:function(t,e){if("object"==typeof t)for(var i in t)this.style(i,t[i]);else this.styles[t]={from:this.target.style(t),to:e};return this},x:function(t){return this._x=new u.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new u.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new u.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new u.Number(this.target.cy()).morph(t),this},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},size:function(t,e){if(this.target instanceof u.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new u.Number(i.width).morph(t),height:new u.Number(i.height).morph(e)}}return this},plot:function(t){return this._plot=t,this},leading:function(t){return this.target._leading&&(this._leading=new u.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof u.Container){var r=this.target.viewbox();this._viewbox={x:new u.Number(r.x).morph(t),y:new u.Number(r.y).morph(e),width:new u.Number(r.width).morph(i),height:new u.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof u.Stop&&(null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new u.Number(t.offset))),this},during:function(t){return this._during=t,this},after:function(t){return this._after=t,this},loop:function(t){return this._loop=t||!0,this},stop:function(t){return t===!0?(this.animate(0),this._after&&this._after.apply(this.target,[this])):(clearTimeout(this.timeout),this.attrs={},this.trans={},this.styles={},this.situation={},delete this._x,delete this._y,delete this._cx,delete this._cy,delete this._size,delete this._plot,delete this._loop,delete this._after,delete this._during,delete this._leading,delete this._viewbox),this},pause:function(){return this.situation.play===!0&&(this.situation.play=!1,this.situation.pause=(new Date).getTime()),this},play:function(){if(this.situation.play===!1){var t=(new Date).getTime()-this.situation.pause;this.situation.finish+=t,this.situation.start+=t,this.situation.play=!0}return this}},parent:u.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new u.FX(this))).stop().animate(t,e,i)},stop:function(t){return this.fx&&this.fx.stop(t),this},pause:function(){return this.fx&&this.fx.pause(),this},play:function(){return this.fx&&this.fx.play(),this}}}),u.extend(u.Element,u.FX,{dx:function(t){return this.x((this.target||this).x()+t)},dy:function(t){return this.y((this.target||this).y()+t)},dmove:function(t,e){return this.dx(t).dy(e)}}),["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){u.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),u.events={},u.listeners={},u.registerEvent=function(t){u.events[t]||(u.events[t]=new Event(t))},u.on=function(t,e,i){var n=i.bind(t.instance||t);u.listeners[i]=n,t.addEventListener(e,n,!1)},u.off=function(t,e,i){t.removeEventListener(e,u.listeners[i],!1),delete u.listeners[i]},u.extend(u.Element,{on:function(t,e){return u.on(this.node,t,e),this},off:function(t,e){return u.off(this.node,t,e),this},fire:function(t){return this.node.dispatchEvent(u.events[t]),this}}),u.Defs=u.invent({create:"defs",inherit:u.Container}),u.G=u.invent({create:"g",inherit:u.Container,extend:{x:function(t){return null==t?this.trans.x:this.transform("x",t)},y:function(t){return null==t?this.trans.y:this.transform("y",t)},cx:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)},cy:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)}},construct:{group:function(){return this.put(new u.G)}}}),u.extend(u.Element,{siblings:function(){return this.parent.children()},position:function(){return this.parent.index(this)},next:function(){return this.siblings()[this.position()+1]},previous:function(){return this.siblings()[this.position()-1]},forward:function(){var t=this.position();return this.parent.removeElement(this).put(this,t+1)},backward:function(){var t=this.position();return t>0&&this.parent.removeElement(this).add(this,t-1),this},front:function(){return this.parent.removeElement(this).put(this)},back:function(){return this.position()>0&&this.parent.removeElement(this).add(this,0),this},before:function(t){t.remove();var e=this.position();return this.parent.add(t,e),this},after:function(t){t.remove();var e=this.position();return this.parent.add(t,e+1),this}}),u.Mask=u.invent({create:function(){this.constructor.call(this,u.create("mask")),this.targets=[]},inherit:u.Container,extend:{remove:function(){for(var t=this.targets.length-1;t>=0;t--)this.targets[t]&&this.targets[t].unmask();return delete this.targets,this.parent.removeElement(this),this}},construct:{mask:function(){return this.defs().put(new u.Mask)}}}),u.extend(u.Element,{maskWith:function(t){return this.masker=t instanceof u.Mask?t:this.parent.mask().add(t),this.masker.targets.push(this),this.attr("mask",'url("#'+this.masker.attr("id")+'")')},unmask:function(){return delete this.masker,this.attr("mask",null)}}),u.Clip=u.invent({create:function(){this.constructor.call(this,u.create("clipPath")),this.targets=[]},inherit:u.Container,extend:{remove:function(){for(var t=this.targets.length-1;t>=0;t--)this.targets[t]&&this.targets[t].unclip();return delete this.targets,this.parent.removeElement(this),this}},construct:{clip:function(){return this.defs().put(new u.Clip)}}}),u.extend(u.Element,{clipWith:function(t){return this.clipper=t instanceof u.Clip?t:this.parent.clip().add(t),this.clipper.targets.push(this),this.attr("clip-path",'url("#'+this.clipper.attr("id")+'")')},unclip:function(){return delete this.clipper,this.attr("clip-path",null)}}),u.Gradient=u.invent({create:function(t){this.constructor.call(this,u.create(t+"Gradient")),this.type=t},inherit:u.Container,extend:{from:function(t,e){return"radial"==this.type?this.attr({fx:new u.Number(t),fy:new u.Number(e)}):this.attr({x1:new u.Number(t),y1:new u.Number(e)})},to:function(t,e){return"radial"==this.type?this.attr({cx:new u.Number(t),cy:new u.Number(e)}):this.attr({x2:new u.Number(t),y2:new u.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new u.Number(t)}):this},at:function(t,e,i){return this.put(new u.Stop).update(t,e,i)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},fill:function(){return"url(#"+this.id()+")"},toString:function(){return this.fill()}},construct:{gradient:function(t,e){return this.defs().gradient(t,e)}}}),u.extend(u.Defs,{gradient:function(t,e){return this.put(new u.Gradient(t)).update(e)}}),u.Stop=u.invent({create:"stop",inherit:u.Element,extend:{update:function(t){return("number"==typeof t||t instanceof u.Number)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new u.Number(t.offset)),this}}}),u.Pattern=u.invent({create:"pattern",inherit:u.Container,extend:{fill:function(){return"url(#"+this.id()+")"},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},toString:function(){return this.fill()}},construct:{pattern:function(t,e,i){return this.defs().pattern(t,e,i)}}}),u.extend(u.Defs,{pattern:function(t,e,i){return this.put(new u.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),u.Doc=u.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:u.create("svg")),this.attr({xmlns:u.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",u.xlink,u.xmlns),this._defs=new u.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:u.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),u.on(window,"resize",function(){t.spof()}),this},defs:function(){return this._defs},spof:function(){if(this.doSpof){var t=this.node.getScreenCTM();t&&this.style("left",-t.e%1+"px").style("top",-t.f%1+"px")}return this},fixSubPixelOffset:function(){return this.doSpof=!0,this}}}),u.Shape=u.invent({create:function(t){this.constructor.call(this,t)},inherit:u.Element}),u.Symbol=u.invent({create:"symbol",inherit:u.Container,construct:{symbol:function(){return this.defs().put(new u.Symbol)}}}),u.Use=u.invent({create:"use",inherit:u.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,u.xlink)}},construct:{use:function(t){return this.put(new u.Use).element(t)}}}),u.Rect=u.invent({create:"rect",inherit:u.Shape,construct:{rect:function(t,e){return this.put((new u.Rect).size(t,e))}}}),u.Ellipse=u.invent({create:"ellipse",inherit:u.Shape,extend:{x:function(t){return null==t?this.cx()-this.attr("rx"):this.cx(t+this.attr("rx"))},y:function(t){return null==t?this.cy()-this.attr("ry"):this.cy(t+this.attr("ry"))},cx:function(t){return null==t?this.attr("cx"):this.attr("cx",new u.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new u.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new u.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new u.Number(t).divide(2))},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr({rx:new u.Number(i.width).divide(2),ry:new u.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new u.Ellipse).size(t,e).move(0,0)}}}),u.Line=u.invent({create:"line",inherit:u.Shape,extend:{x:function(t){var e=this.bbox();return null==t?e.x:this.attr({x1:this.attr("x1")-e.x+t,x2:this.attr("x2")-e.x+t})},y:function(t){var e=this.bbox();return null==t?e.y:this.attr({y1:this.attr("y1")-e.y+t,y2:this.attr("y2")-e.y+t})},cx:function(t){var e=this.bbox().width/2;return null==t?this.x()+e:this.x(t-e)},cy:function(t){var e=this.bbox().height/2;return null==t?this.y()+e:this.y(t-e)},width:function(t){var e=this.bbox();return null==t?e.width:this.attr(this.attr("x1")<this.attr("x2")?"x2":"x1",e.x+t)},height:function(t){var e=this.bbox();
-return null==t?e.height:this.attr(this.attr("y1")<this.attr("y2")?"y2":"y1",e.y+t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.width(i.width).height(i.height)},plot:function(t,e,i,n){return this.attr({x1:t,y1:e,x2:i,y2:n})}},construct:{line:function(t,e,i,n){return this.put((new u.Line).plot(t,e,i,n))}}}),u.Polyline=u.invent({create:"polyline",inherit:u.Shape,construct:{polyline:function(t){return this.put(new u.Polyline).plot(t)}}}),u.Polygon=u.invent({create:"polygon",inherit:u.Shape,construct:{polygon:function(t){return this.put(new u.Polygon).plot(t)}}}),u.extend(u.Polyline,u.Polygon,{morphArray:u.PointArray,plot:function(t){return this.attr("points",this.array=new u.PointArray(t,[[0,0]]))},move:function(t,e){return this.attr("points",this.array.move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},width:function(t){var e=this.bbox();return null==t?e.width:this.size(t,e.height)},height:function(t){var e=this.bbox();return null==t?e.height:this.size(e.width,t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr("points",this.array.size(i.width,i.height))}}),u.Path=u.invent({create:"path",inherit:u.Shape,extend:{plot:function(t){return this.attr("d",this.array=new u.PathArray(t,[["M",0,0]]))},move:function(t,e){return this.attr("d",this.array.move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr("d",this.array.size(i.width,i.height))},width:function(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)},height:function(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}},construct:{path:function(t){return this.put(new u.Path).plot(t)}}}),u.Image=u.invent({create:"image",inherit:u.Shape,extend:{load:function(t){if(!t)return this;var e=this,i=document.createElement("img");return i.onload=function(){var n=e.doc(u.Pattern);0==e.width()&&0==e.height()&&e.size(i.width,i.height),n&&0==n.width()&&0==n.height()&&n.size(e.width(),e.height()),"function"==typeof e._loaded&&e._loaded.call(e,{width:i.width,height:i.height,ratio:i.width/i.height,url:t})},this.attr("href",i.src=this.src=t,u.xlink)},loaded:function(t){return this._loaded=t,this}},construct:{image:function(t,e,i){return this.put(new u.Image).load(t).size(e||0,i||e||0)}}}),u.Text=u.invent({create:function(){this.constructor.call(this,u.create("text")),this._leading=new u.Number(1.3),this._rebuild=!0,this._build=!1,this.attr("font-family",u.defaults.attrs["font-family"])},inherit:u.Shape,extend:{x:function(t){return null==t?this.attr("x"):(this.textPath||this.lines.each(function(){this.newLined&&this.x(t)}),this.attr("x",t))},y:function(t){var e=this.attr("y"),i="number"==typeof e?e-this.bbox().y:0;return null==t?"number"==typeof e?e-i:e:this.attr("y","number"==typeof t?t+i:t)},cx:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)},cy:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)},text:function(t){if("undefined"==typeof t)return this.content;if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else{t=(this.content=t).split("\n");for(var e=0,i=t.length;i>e;e++)this.tspan(t[e]).newLine()}return this.build(!1).rebuild()},size:function(t){return this.attr("font-size",t).rebuild()},leading:function(t){return null==t?this._leading:(this._leading=new u.Number(t),this.rebuild())},rebuild:function(t){if("boolean"==typeof t&&(this._rebuild=t),this._rebuild){var e=this;this.lines.each(function(){this.newLined&&(this.textPath||this.attr("x",e.attr("x")),this.attr("dy",e._leading*new u.Number(e.attr("font-size"))))}),this.fire("rebuild")}return this},build:function(t){return this._build=!!t,this}},construct:{text:function(t){return this.put(new u.Text).text(t)},plain:function(t){return this.put(new u.Text).plain(t)}}}),u.TSpan=u.invent({create:"tspan",inherit:u.Shape,extend:{text:function(t){return"function"==typeof t?t.call(this,this):this.plain(t),this},dx:function(t){return this.attr("dx",t)},dy:function(t){return this.attr("dy",t)},newLine:function(){var t=this.doc(u.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),u.extend(u.Text,u.TSpan,{plain:function(t){return this._build===!1&&this.clear(),this.node.appendChild(document.createTextNode(this.content=t)),this},tspan:function(t){var e=(this.textPath||this).node,i=new u.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof u.Text&&this.lines.add(i),i.text(t)},clear:function(){for(var t=(this.textPath||this).node;t.hasChildNodes();)t.removeChild(t.lastChild);return this instanceof u.Text&&(delete this.lines,this.lines=new u.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),u.registerEvent("rebuild"),u.TextPath=u.invent({create:"textPath",inherit:u.Element,parent:u.Text,construct:{path:function(t){for(this.textPath=new u.TextPath;this.node.hasChildNodes();)this.textPath.node.appendChild(this.node.firstChild);return this.node.appendChild(this.textPath.node),this.track=this.doc().defs().path(t),this.textPath.parent=this,this.textPath.attr("href","#"+this.track,u.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),u.Nested=u.invent({create:function(){this.constructor.call(this,u.create("svg")),this.style("overflow","visible")},inherit:u.Container,construct:{nested:function(){return this.put(new u.Nested)}}}),u.A=u.invent({create:"a",inherit:u.Container,extend:{to:function(t){return this.attr("href",t,u.xlink)},show:function(t){return this.attr("show",t,u.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new u.A).to(t)}}}),u.extend(u.Element,{linkTo:function(t){var e=new u.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),u.Marker=u.invent({create:"marker",inherit:u.Container,extend:{width:function(t){return this.attr("markerWidth",t)},height:function(t){return this.attr("markerHeight",t)},ref:function(t,e){return this.attr("refX",t).attr("refY",e)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},toString:function(){return"url(#"+this.id()+")"}},construct:{marker:function(t,e,i){return this.defs().marker(t,e,i)}}}),u.extend(u.Defs,{marker:function(t,e,i){return this.put(new u.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),u.extend(u.Line,u.Polyline,u.Polygon,u.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof u.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var l={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||u.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=l[t].length-1;e>=0;e--)null!=i[l[t][e]]&&this.attr(l.prefix(t,l[t][e]),i[l[t][e]]);return this},u.extend(u.Element,u.FX,i)}),u.extend(u.Element,u.FX,{rotate:function(t,e,i){return this.transform({rotation:t||0,cx:e,cy:i})},skew:function(t,e){return this.transform({skewX:t||0,skewY:e||0})},scale:function(t,e){return this.transform({scaleX:t,scaleY:null==e?t:e})},translate:function(t,e){return this.transform({x:t,y:e})},matrix:function(t){return this.transform({matrix:t})},opacity:function(t){return this.attr("opacity",t)}}),u.extend(u.Rect,u.Ellipse,u.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),u.extend(u.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),u.extend(u.Parent,u.Text,u.FX,{font:function(t){for(var e in t)"leading"==e?this.leading(t[e]):"anchor"==e?this.attr("text-anchor",t[e]):"size"==e||"family"==e||"weight"==e||"stretch"==e||"variant"==e||"style"==e?this.attr("font-"+e,t[e]):this.attr(e,t[e]);return this}}),u.Set=u.invent({create:function(){this.clear()},extend:{add:function(){var t,e,i=[].slice.call(arguments);for(t=0,e=i.length;e>t;t++)this.members.push(i[t]);return this},remove:function(t){var e=this.index(t);return e>-1&&this.members.splice(e,1),this},each:function(t){for(var e=0,i=this.members.length;i>e;e++)t.apply(this.members[e],[e,this.members]);return this},clear:function(){return this.members=[],this},has:function(t){return this.index(t)>=0},index:function(t){return this.members.indexOf(t)},get:function(t){return this.members[t]},first:function(){return this.get(0)},last:function(){return this.get(this.members.length-1)},valueOf:function(){return this.members},bbox:function(){var t=new u.BBox;if(0==this.members.length)return t;var e=this.members[0].rbox();return t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height,this.each(function(){t=t.merge(this.rbox())}),t}},construct:{set:function(){return new u.Set}}}),u.SetFX=u.invent({create:function(t){this.set=t}}),u.Set.inherit=function(){var t,e=[];for(var t in u.Shape.prototype)"function"==typeof u.Shape.prototype[t]&&"function"!=typeof u.Set.prototype[t]&&e.push(t);e.forEach(function(t){u.Set.prototype[t]=function(){for(var e=0,i=this.members.length;i>e;e++)this.members[e]&&"function"==typeof this.members[e][t]&&this.members[e][t].apply(this.members[e],arguments);return"animate"==t?this.fx||(this.fx=new u.SetFX(this)):this}}),e=[];for(var t in u.FX.prototype)"function"==typeof u.FX.prototype[t]&&"function"!=typeof u.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){u.SetFX.prototype[t]=function(){for(var e=0,i=this.set.members.length;i>e;e++)this.set.members[e].fx[t].apply(this.set.members[e].fx,arguments);return this}})},u.extend(u.Element,{data:function(t,e,i){if("object"==typeof t)for(e in t)this.data(e,t[e]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+t))}catch(n){return this.attr("data-"+t)}else this.attr("data-"+t,null===e?null:i===!0||"string"==typeof e||"number"==typeof e?e:JSON.stringify(e));return this}}),u.extend(u.Element,{remember:function(t,e){if("object"==typeof arguments[0])for(var e in t)this.remember(e,t[e]);else{if(1==arguments.length)return this.memory()[t];this.memory()[t]=e}return this},forget:function(){if(0==arguments.length)this._memory={};else for(var t=arguments.length-1;t>=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory||(this._memory={})}}),"function"==typeof define&&define.amd?define(function(){return u}):"undefined"!=typeof exports&&(exports.SVG=u),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}()}).call(this); \ No newline at end of file
+/* svg.js 1.0.1 - svg selector inventor polyfill regex default color array pointarray patharray number viewbox bbox rbox element parent container fx relative event defs group arrange mask clip gradient pattern doc shape symbol use rect ellipse line poly path image text textpath nested hyperlink marker sugar set data memory loader helpers - svgjs.com/license */
+(function(e,t){typeof define=="function"&&define.amd?define(t):typeof exports=="object"?module.exports=t():e.SVG=t()})(this,function(){function r(e){return e.toLowerCase().replace(/-(.)/g,function(e,t){return t.toUpperCase()})}function i(e){return e.length==4?["#",e.substring(1,2),e.substring(1,2),e.substring(2,3),e.substring(2,3),e.substring(3,4),e.substring(3,4)].join(""):e}function s(e){var t=e.toString(16);return t.length==1?"0"+t:t}function o(e,t,n){if(t==null||n==null)n==null?n=e.height/e.width*t:t==null&&(t=e.width/e.height*n);return{width:t,height:n}}function u(t,n){return typeof t.from=="number"?t.from+(t.to-t.from)*n:t instanceof e.Color||t instanceof e.Number?t.at(n):n<1?t.from:t.to}function a(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t][0],e[t][1]!=null&&(r+=e[t][1],e[t][2]!=null&&(r+=" ",r+=e[t][2],e[t][3]!=null&&(r+=" ",r+=e[t][3],r+=" ",r+=e[t][4],e[t][5]!=null&&(r+=" ",r+=e[t][5],r+=" ",r+=e[t][6],e[t][7]!=null&&(r+=" ",r+=e[t][7])))));return r+" "}function f(e){e.x2=e.x+e.width,e.y2=e.y+e.height,e.cx=e.x+e.width/2,e.cy=e.y+e.height/2}function l(e){if(e.matrix){var t=e.matrix.replace(/\s/g,"").split(",");t.length==6&&(e.a=parseFloat(t[0]),e.b=parseFloat(t[1]),e.c=parseFloat(t[2]),e.d=parseFloat(t[3]),e.e=parseFloat(t[4]),e.f=parseFloat(t[5]))}return e}function c(t){var n=t.toString().match(e.regex.reference);if(n)return n[1]}var e=this.SVG=function(t){if(e.supported)return t=new e.Doc(t),e.parser||e.prepare(t),t};e.ns="http://www.w3.org/2000/svg",e.xmlns="http://www.w3.org/2000/xmlns/",e.xlink="http://www.w3.org/1999/xlink",e.did=1e3,e.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+e.did++},e.create=function(e){var t=document.createElementNS(this.ns,e);return t.setAttribute("id",this.eid(e)),t},e.extend=function(){var t,n,r,i;t=[].slice.call(arguments),n=t.pop();for(i=t.length-1;i>=0;i--)if(t[i])for(r in n)t[i].prototype[r]=n[r];e.Set&&e.Set.inherit&&e.Set.inherit()},e.prepare=function(t){var n=document.getElementsByTagName("body")[0],r=(n?new e.Doc(n):t.nested()).size(2,0),i=e.create("path");r.node.appendChild(i),e.parser={body:n||t.parent,draw:r.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:r.polyline().node,path:i}},e.supported=function(){return!!document.createElementNS&&!!document.createElementNS(e.ns,"svg").createSVGRect}();if(!e.supported)return!1;e.get=function(e){var t=document.getElementById(c(e)||e);if(t)return t.instance},e.invent=function(t){var n=typeof t.create=="function"?t.create:function(){this.constructor.call(this,e.create(t.create))};return t.inherit&&(n.prototype=new t.inherit),t.extend&&e.extend(n,t.extend),t.construct&&e.extend(t.parent||e.Container,t.construct),n};if(typeof t!="function"){function t(e,t){t=t||{bubbles:!1,cancelable:!1,detail:undefined};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}t.prototype=window.Event.prototype,window.CustomEvent=t}e.regex={unit:/^(-?[\d\.]+)([a-z%]{0,2})$/,hex:/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,rgb:/rgb\((\d+),(\d+),(\d+)\)/,reference:/#([a-z0-9\-_]+)/i,isHex:/^#[a-f0-9]{3,6}$/i,isRgb:/^rgb\(/,isCss:/[^:]+:[^;]+;?/,isBlank:/^(\s+)?$/,isNumber:/^-?[\d\.]+$/,isPercent:/^-?[\d\.]+%$/,isImage:/\.(jpg|jpeg|png|gif)(\?[^=]+.*)?/i,isEvent:/^[\w]+:[\w]+$/},e.defaults={matrix:"1 0 0 1 0 0",attrs:{"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","font-size":16,"font-family":"Helvetica, Arial, sans-serif","text-anchor":"start"},trans:function(){return{x:0,y:0,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0,matrix:this.matrix,a:1,b:0,c:0,d:1,e:0,f:0}}},e.Color=function(t){var n;this.r=0,this.g=0,this.b=0,typeof t=="string"?e.regex.isRgb.test(t)?(n=e.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(n[1]),this.g=parseInt(n[2]),this.b=parseInt(n[3])):e.regex.isHex.test(t)&&(n=e.regex.hex.exec(i(t)),this.r=parseInt(n[1],16),this.g=parseInt(n[2],16),this.b=parseInt(n[3],16)):typeof t=="object"&&(this.r=t.r,this.g=t.g,this.b=t.b)},e.extend(e.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+s(this.r)+s(this.g)+s(this.b)},toRgb:function(){return"rgb("+[this.r,this.g,this.b].join()+")"},brightness:function(){return this.r/255*.3+this.g/255*.59+this.b/255*.11},morph:function(t){return this.destination=new e.Color(t),this},at:function(t){return this.destination?(t=t<0?0:t>1?1:t,new e.Color({r:~~(this.r+(this.destination.r-this.r)*t),g:~~(this.g+(this.destination.g-this.g)*t),b:~~(this.b+(this.destination.b-this.b)*t)})):this}}),e.Color.test=function(t){return t+="",e.regex.isHex.test(t)||e.regex.isRgb.test(t)},e.Color.isRgb=function(e){return e&&typeof e.r=="number"&&typeof e.g=="number"&&typeof e.b=="number"},e.Color.isColor=function(t){return e.Color.isRgb(t)||e.Color.test(t)},e.Array=function(e,t){e=(e||[]).valueOf(),e.length==0&&t&&(e=t.valueOf()),this.value=this.parse(e)},e.extend(e.Array,{morph:function(e){this.destination=this.parse(e);if(this.value.length!=this.destination.length){var t=this.value[this.value.length-1],n=this.destination[this.destination.length-1];while(this.value.length>this.destination.length)this.destination.push(n);while(this.value.length<this.destination.length)this.value.push(t)}return this},settle:function(){for(var e=0,t=this.value.length,n=[];e<t;e++)n.indexOf(this.value[e])==-1&&n.push(this.value[e]);return this.value=n},at:function(t){if(!this.destination)return this;for(var n=0,r=this.value.length,i=[];n<r;n++)i.push(this.value[n]+(this.destination[n]-this.value[n])*t);return new e.Array(i)},toString:function(){return this.value.join(" ")},valueOf:function(){return this.value},parse:function(e){return e=e.valueOf(),Array.isArray(e)?e:this.split(e)},split:function(e){return e.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"").split(" ")},reverse:function(){return this.value.reverse(),this}}),e.PointArray=function(){this.constructor.apply(this,arguments)},e.PointArray.prototype=new e.Array,e.extend(e.PointArray,{toString:function(){for(var e=0,t=this.value.length,n=[];e<t;e++)n.push(this.value[e].join(","));return n.join(" ")},at:function(t){if(!this.destination)return this;for(var n=0,r=this.value.length,i=[];n<r;n++)i.push([this.value[n][0]+(this.destination[n][0]-this.value[n][0])*t,this.value[n][1]+(this.destination[n][1]-this.value[n][1])*t]);return new e.PointArray(i)},parse:function(e){e=e.valueOf();if(Array.isArray(e))return e;e=this.split(e);for(var t=0,n=e.length,r,i=[];t<n;t++)r=e[t].split(","),i.push([parseFloat(r[0]),parseFloat(r[1])]);return i},move:function(e,t){var n=this.bbox();e-=n.x,t-=n.y;if(!isNaN(e)&&!isNaN(t))for(var r=this.value.length-1;r>=0;r--)this.value[r]=[this.value[r][0]+e,this.value[r][1]+t];return this},size:function(e,t){var n,r=this.bbox();for(n=this.value.length-1;n>=0;n--)this.value[n][0]=(this.value[n][0]-r.x)*e/r.width+r.x,this.value[n][1]=(this.value[n][1]-r.y)*t/r.height+r.y;return this},bbox:function(){return e.parser.poly.setAttribute("points",this.toString()),e.parser.poly.getBBox()}}),e.PathArray=function(e,t){this.constructor.call(this,e,t)},e.PathArray.prototype=new e.Array,e.extend(e.PathArray,{toString:function(){return a(this.value)},move:function(e,t){var n=this.bbox();e-=n.x,t-=n.y;if(!isNaN(e)&&!isNaN(t))for(var r,i=this.value.length-1;i>=0;i--)r=this.value[i][0],r=="M"||r=="L"||r=="T"?(this.value[i][1]+=e,this.value[i][2]+=t):r=="H"?this.value[i][1]+=e:r=="V"?this.value[i][1]+=t:r=="C"||r=="S"||r=="Q"?(this.value[i][1]+=e,this.value[i][2]+=t,this.value[i][3]+=e,this.value[i][4]+=t,r=="C"&&(this.value[i][5]+=e,this.value[i][6]+=t)):r=="A"&&(this.value[i][6]+=e,this.value[i][7]+=t);return this},size:function(e,t){var n,r,i=this.bbox();for(n=this.value.length-1;n>=0;n--)r=this.value[n][0],r=="M"||r=="L"||r=="T"?(this.value[n][1]=(this.value[n][1]-i.x)*e/i.width+i.x,this.value[n][2]=(this.value[n][2]-i.y)*t/i.height+i.y):r=="H"?this.value[n][1]=(this.value[n][1]-i.x)*e/i.width+i.x:r=="V"?this.value[n][1]=(this.value[n][1]-i.y)*t/i.height+i.y:r=="C"||r=="S"||r=="Q"?(this.value[n][1]=(this.value[n][1]-i.x)*e/i.width+i.x,this.value[n][2]=(this.value[n][2]-i.y)*t/i.height+i.y,this.value[n][3]=(this.value[n][3]-i.x)*e/i.width+i.x,this.value[n][4]=(this.value[n][4]-i.y)*t/i.height+i.y,r=="C"&&(this.value[n][5]=(this.value[n][5]-i.x)*e/i.width+i.x,this.value[n][6]=(this.value[n][6]-i.y)*t/i.height+i.y)):r=="A"&&(this.value[n][1]=this.value[n][1]*e/i.width,this.value[n][2]=this.value[n][2]*t/i.height,this.value[n][6]=(this.value[n][6]-i.x)*e/i.width+i.x,this.value[n][7]=(this.value[n][7]-i.y)*t/i.height+i.y);return this},parse:function(t){if(t instanceof e.PathArray)return t.valueOf();var n,r,i,s,o,u,f,l,c,h,p,d=0,v=0;e.parser.path.setAttribute("d",typeof t=="string"?t:a(t)),p=e.parser.path.pathSegList;for(n=0,r=p.numberOfItems;n<r;++n){h=p.getItem(n),c=h.pathSegTypeAsLetter;if(c=="M"||c=="L"||c=="H"||c=="V"||c=="C"||c=="S"||c=="Q"||c=="T"||c=="A")"x"in h&&(d=h.x),"y"in h&&(v=h.y);else{"x1"in h&&(o=d+h.x1),"x2"in h&&(f=d+h.x2),"y1"in h&&(u=v+h.y1),"y2"in h&&(l=v+h.y2),"x"in h&&(d+=h.x),"y"in h&&(v+=h.y);if(c=="m")p.replaceItem(e.parser.path.createSVGPathSegMovetoAbs(d,v),n);else if(c=="l")p.replaceItem(e.parser.path.createSVGPathSegLinetoAbs(d,v),n);else if(c=="h")p.replaceItem(e.parser.path.createSVGPathSegLinetoHorizontalAbs(d),n);else if(c=="v")p.replaceItem(e.parser.path.createSVGPathSegLinetoVerticalAbs(v),n);else if(c=="c")p.replaceItem(e.parser.path.createSVGPathSegCurvetoCubicAbs(d,v,o,u,f,l),n);else if(c=="s")p.replaceItem(e.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(d,v,f,l),n);else if(c=="q")p.replaceItem(e.parser.path.createSVGPathSegCurvetoQuadraticAbs(d,v,o,u),n);else if(c=="t")p.replaceItem(e.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(d,v),n);else if(c=="a")p.replaceItem(e.parser.path.createSVGPathSegArcAbs(d,v,h.r1,h.r2,h.angle,h.largeArcFlag,h.sweepFlag),n);else if(c=="z"||c=="Z")d=i,v=s}if(c=="M"||c=="m")i=d,s=v}t=[],p=e.parser.path.pathSegList;for(n=0,r=p.numberOfItems;n<r;++n)h=p.getItem(n),c=h.pathSegTypeAsLetter,d=[c],c=="M"||c=="L"||c=="T"?d.push(h.x,h.y):c=="H"?d.push(h.x):c=="V"?d.push(h.y):c=="C"?d.push(h.x1,h.y1,h.x2,h.y2,h.x,h.y):c=="S"?d.push(h.x2,h.y2,h.x,h.y):c=="Q"?d.push(h.x1,h.y1,h.x,h.y):c=="A"&&d.push(h.r1,h.r2,h.angle,h.largeArcFlag|0,h.sweepFlag|0,h.x,h.y),t.push(d);return t},bbox:function(){return e.parser.path.setAttribute("d",this.toString()),e.parser.path.getBBox()}}),e.Number=function(t){this.value=0,this.unit="";if(typeof t=="number")this.value=isNaN(t)?0:isFinite(t)?t:t<0?-3.4e38:3.4e38;else if(typeof t=="string"){var n=t.match(e.regex.unit);n&&(this.value=parseFloat(n[1]),n[2]=="%"?this.value/=100:n[2]=="s"&&(this.value*=1e3),this.unit=n[2])}else t instanceof e.Number&&(this.value=t.value,this.unit=t.unit)},e.extend(e.Number,{toString:function(){return(this.unit=="%"?~~(this.value*1e8)/1e6:this.unit=="s"?this.value/1e3:this.value)+this.unit},valueOf:function(){return this.value},plus:function(t){return this.value=this+new e.Number(t),this},minus:function(t){return this.plus(-(new e.Number(t)))},times:function(t){return this.value=this*new e.Number(t),this},divide:function(t){return this.value=this/new e.Number(t),this},to:function(e){return typeof e=="string"&&(this.unit=e),this},morph:function(t){return this.destination=new e.Number(t),this},at:function(t){return this.destination?(new e.Number(this.destination)).minus(this).times(t).plus(this):this}}),e.ViewBox=function(t){var n,r,i,s,o=1,u=1,a=t.bbox(),f=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),l=t,c=t;i=new e.Number(t.width()),s=new e.Number(t.height());while(i.unit=="%")o*=i.value,i=new e.Number(l instanceof e.Doc?l.parent.offsetWidth:l.parent.width()),l=l.parent;while(s.unit=="%")u*=s.value,s=new e.Number(c instanceof e.Doc?c.parent.offsetHeight:c.parent.height()),c=c.parent;this.x=a.x,this.y=a.y,this.width=i*o,this.height=s*u,this.zoom=1,f&&(n=parseFloat(f[0]),r=parseFloat(f[1]),i=parseFloat(f[2]),s=parseFloat(f[3]),this.zoom=this.width/this.height>i/s?this.height/s:this.width/i,this.x=n,this.y=r,this.width=i,this.height=s)},e.extend(e.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),e.BBox=function(e){var t;this.x=0,this.y=0,this.width=0,this.height=0;if(e){try{t=e.node.getBBox()}catch(n){t={x:e.node.clientLeft,y:e.node.clientTop,width:e.node.clientWidth,height:e.node.clientHeight}}this.x=t.x+e.trans.x,this.y=t.y+e.trans.y,this.width=t.width*e.trans.scaleX,this.height=t.height*e.trans.scaleY}f(this)},e.extend(e.BBox,{merge:function(t){var n=new e.BBox;return n.x=Math.min(this.x,t.x),n.y=Math.min(this.y,t.y),n.width=Math.max(this.x+this.width,t.x+t.width)-n.x,n.height=Math.max(this.y+this.height,t.y+t.height)-n.y,f(n),n}}),e.RBox=function(e){var t,n,r={};this.x=0,this.y=0,this.width=0,this.height=0;if(e){t=e.doc().parent,n=e.doc().viewbox().zoom,r=e.node.getBoundingClientRect(),this.x=r.left,this.y=r.top,this.x-=t.offsetLeft,this.y-=t.offsetTop;while(t=t.offsetParent)this.x-=t.offsetLeft,this.y-=t.offsetTop;t=e;while(t=t.parent)t.type=="svg"&&t.viewbox&&(n*=t.viewbox().zoom,this.x-=t.x()||0,this.y-=t.y()||0)}this.x/=n,this.y/=n,this.width=r.width/=n,this.height=r.height/=n,this.x+=typeof window.scrollX=="number"?window.scrollX:window.pageXOffset,this.y+=typeof window.scrollY=="number"?window.scrollY:window.pageYOffset,f(this)},e.extend(e.RBox,{merge:function(t){var n=new e.RBox;return n.x=Math.min(this.x,t.x),n.y=Math.min(this.y,t.y),n.width=Math.max(this.x+this.width,t.x+t.width)-n.x,n.height=Math.max(this.y+this.height,t.y+t.height)-n.y,f(n),n}}),e.Element=e.invent({create:function(t){this._stroke=e.defaults.attrs.stroke,this.trans=e.defaults.trans();if(this.node=t)this.type=t.nodeName,this.node.instance=this},extend:{x:function(t){return t!=null&&(t=new e.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return t!=null&&(t=new e.Number(t),t.value/=this.trans.scaleY),this.attr("y",t)},cx:function(e){return e==null?this.x()+this.width()/2:this.x(e-this.width()/2)},cy:function(e){return e==null?this.y()+this.height()/2:this.y(e-this.height()/2)},move:function(e,t){return this.x(e).y(t)},center:function(e,t){return this.cx(e).cy(t)},width:function(e){return this.attr("width",e)},height:function(e){return this.attr("height",e)},size:function(t,n){var r=o(this.bbox(),t,n);return this.width(new e.Number(r.width)).height(new e.Number(r.height))},clone:function(){var e,t,n=this.type;return e=n=="rect"||n=="ellipse"?this.parent[n](0,0):n=="line"?this.parent[n](0,0,0,0):n=="image"?this.parent[n](this.src):n=="text"?this.parent[n](this.content):n=="path"?this.parent[n](this.attr("d")):n=="polyline"||n=="polygon"?this.parent[n](this.attr("points")):n=="g"?this.parent.group():this.parent[n](),t=this.attr(),delete t.id,e.attr(t),e.trans=this.trans,e.transform({})},remove:function(){return this.parent&&this.parent.removeElement(this),this},replace:function(e){return this.after(e).remove(),e},addTo:function(e){return e.put(this)},putIn:function(e){return e.add(this)},doc:function(t){return this._parent(t||e.Doc)},attr:function(t,n,r){if(t==null){t={},n=this.node.attributes;for(r=n.length-1;r>=0;r--)t[n[r].nodeName]=e.regex.isNumber.test(n[r].nodeValue)?parseFloat(n[r].nodeValue):n[r].nodeValue;return t}if(typeof t=="object")for(n in t)this.attr(n,t[n]);else if(n===null)this.node.removeAttribute(t);else{if(n==null)return n=this.node.attributes[t],n==null?e.defaults.attrs[t]:e.regex.isNumber.test(n.nodeValue)?parseFloat(n.nodeValue):n.nodeValue;if(t=="style")return this.style(n);t=="stroke-width"?this.attr("stroke",parseFloat(n)>0?this._stroke:null):t=="stroke"&&(this._stroke=n);if(t=="fill"||t=="stroke")e.regex.isImage.test(n)&&(n=this.doc().defs().image(n,0,0)),n instanceof e.Image&&(n=this.doc().defs().pattern(0,0,function(){this.add(n)}));typeof n=="number"?n=new e.Number(n):e.Color.isColor(n)?n=new e.Color(n):Array.isArray(n)&&(n=new e.Array(n)),t=="leading"?this.leading&&this.leading(n):typeof r=="string"?this.node.setAttributeNS(r,t,n.toString()):this.node.setAttribute(t,n.toString()),this.rebuild&&(t=="font-size"||t=="x")&&this.rebuild(t,n)}return this},transform:function(t,n){if(arguments.length==0)return this.trans;if(typeof t=="string"){if(arguments.length<2)return this.trans[t];var r={};return r[t]=n,this.transform(r)}var r=[];t=l(t);for(n in t)t[n]!=null&&(this.trans[n]=t[n]);return this.trans.matrix=this.trans.a+" "+this.trans.b+" "+this.trans.c+" "+this.trans.d+" "+this.trans.e+" "+this.trans.f,t=this.trans,t.matrix!=e.defaults.matrix&&r.push("matrix("+t.matrix+")"),t.rotation!=0&&r.push("rotate("+t.rotation+" "+(t.cx==null?this.bbox().cx:t.cx)+" "+(t.cy==null?this.bbox().cy:t.cy)+")"),(t.scaleX!=1||t.scaleY!=1)&&r.push("scale("+t.scaleX+" "+t.scaleY+")"),t.skewX!=0&&r.push("skewX("+t.skewX+")"),t.skewY!=0&&r.push("skewY("+t.skewY+")"),(t.x!=0||t.y!=0)&&r.push("translate("+new e.Number(t.x/t.scaleX)+" "+new e.Number(t.y/t.scaleY)+")"),r.length==0?this.node.removeAttribute("transform"):this.node.setAttribute("transform",r.join(" ")),this},style:function(t,n){if(arguments.length==0)return this.node.style.cssText||"";if(arguments.length<2)if(typeof t=="object")for(n in t)this.style(n,t[n]);else{if(!e.regex.isCss.test(t))return this.node.style[r(t)];t=t.split(";");for(var i=0;i<t.length;i++)n=t[i].split(":"),this.style(n[0].replace(/\s+/g,""),n[1])}else this.node.style[r(t)]=n===null||e.regex.isBlank.test(n)?"":n;return this},id:function(e){return this.attr("id",e)},bbox:function(){return new e.BBox(this)},rbox:function(){return new e.RBox(this)},inside:function(e,t){var n=this.bbox();return e>n.x&&t>n.y&&e<n.x+n.width&&t<n.y+n.height},show:function(){return this.style("display","")},hide:function(){return this.style("display","none")},visible:function(){return this.style("display")!="none"},toString:function(){return this.attr("id")},classes:function(){var e=this.node.getAttribute("class");return e===null?[]:e.trim().split(/\s+/)},hasClass:function(e){return this.classes().indexOf(e)!=-1},addClass:function(e){var t;return this.hasClass(e)||(t=this.classes(),t.push(e),this.node.setAttribute("class",t.join(" "))),this},removeClass:function(e){var t;return this.hasClass(e)&&(t=this.classes().filter(function(t){return t!=e}),this.node.setAttribute("class",t.join(" "))),this},toggleClass:function(e){return this.hasClass(e)?this.removeClass(e):this.addClass(e),this},reference:function(t){return e.get(this.attr()[t])},_parent:function(e){var t=this;while(t!=null&&!(t instanceof e))t=t.parent;return t}}}),e.Parent=e.invent({create:function(e){this.constructor.call(this,e)},inherit:e.Element,extend:{children:function(){return this._children||(this._children=[])},add:function(e,t){return this.has(e)||(t=t==null?this.children().length:t,e.parent&&e.parent.children().splice(e.parent.index(e),1),this.children().splice(t,0,e),this.node.insertBefore(e.node,this.node.childNodes[t]||null),e.parent=this),this._defs&&(this.node.removeChild(this._defs.node),this.node.appendChild(this._defs.node)),this},put:function(e,t){return this.add(e,t),e},has:function(e){return this.index(e)>=0},index:function(e){return this.children().indexOf(e)},get:function(e){return this.children()[e]},first:function(){return this.children()[0]},last:function(){return this.children()[this.children().length-1]},each:function(t,n){var r,i,s=this.children();for(r=0,i=s.length;r<i;r++)s[r]instanceof e.Element&&t.apply(s[r],[r,s]),n&&s[r]instanceof e.Container&&s[r].each(t,n);return this},removeElement:function(e){return this.children().splice(this.index(e),1),this.node.removeChild(e.node),e.parent=null,this},clear:function(){for(var e=this.children().length-1;e>=0;e--)this.removeElement(this.children()[e]);return this._defs&&this._defs.clear(),this},defs:function(){return this.doc().defs()}}}),e.Container=e.invent({create:function(e){this.constructor.call(this,e)},inherit:e.Parent,extend:{viewbox:function(t){return arguments.length==0?new e.ViewBox(this):(t=arguments.length==1?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),e.FX=e.invent({create:function(e){this.target=e},extend:{animate:function(t,n,r){var i,s,o,a,f=this.target,l=this;return typeof t=="object"&&(r=t.delay,n=t.ease,t=t.duration),t=t=="="?t:t==null?1e3:(new e.Number(t)).valueOf(),n=n||"<>",l.to=function(e){var t;e=e<0?0:e>1?1:e;if(i==null){i=[];for(a in l.attrs)i.push(a);if(f.morphArray&&(l._plot||i.indexOf("points")>-1)){var r,c=new f.morphArray(l._plot||l.attrs.points||f.array);l._size&&c.size(l._size.width.to,l._size.height.to),r=c.bbox(),l._x?c.move(l._x.to,r.y):l._cx&&c.move(l._cx.to-r.width/2,r.y),r=c.bbox(),l._y?c.move(r.x,l._y.to):l._cy&&c.move(r.x,l._cy.to-r.height/2),delete l._x,delete l._y,delete l._cx,delete l._cy,delete l._size,l._plot=f.array.morph(c)}}if(s==null){s=[];for(a in l.trans)s.push(a)}if(o==null){o=[];for(a in l.styles)o.push(a)}e=n=="<>"?-Math.cos(e*Math.PI)/2+.5:n==">"?Math.sin(e*Math.PI/2):n=="<"?-Math.cos(e*Math.PI/2)+1:n=="-"?e:typeof n=="function"?n(e):e,l._plot?f.plot(l._plot.at(e)):(l._x?f.x(l._x.at(e)):l._cx&&f.cx(l._cx.at(e)),l._y?f.y(l._y.at(e)):l._cy&&f.cy(l._cy.at(e)),l._size&&f.size(l._size.width.at(e),l._size.height.at(e))),l._viewbox&&f.viewbox(l._viewbox.x.at(e),l._viewbox.y.at(e),l._viewbox.width.at(e),l._viewbox.height.at(e)),l._leading&&f.leading(l._leading.at(e));for(t=i.length-1;t>=0;t--)f.attr(i[t],u(l.attrs[i[t]],e));for(t=s.length-1;t>=0;t--)f.transform(s[t],u(l.trans[s[t]],e));for(t=o.length-1;t>=0;t--)f.style(o[t],u(l.styles[o[t]],e));l._during&&l._during.call(f,e,function(t,n){return u({from:t,to:n},e)})},typeof t=="number"&&(this.timeout=setTimeout(function(){var i=(new Date).getTime();l.situation={interval:1e3/60,start:i,play:!0,finish:i+t,duration:t},l.render=function(){if(l.situation.play===!0){var i=(new Date).getTime(),s=i>l.situation.finish?1:(i-l.situation.start)/t;l.to(s),i>l.situation.finish?(l._plot&&f.plot((new e.PointArray(l._plot.destination)).settle()),l._loop===!0||typeof l._loop=="number"&&l._loop>1?(typeof l._loop=="number"&&--l._loop,l.animate(t,n,r)):l._after?l._after.apply(f,[l]):l.stop()):requestAnimFrame(l.render)}else requestAnimFrame(l.render)},l.render()},(new e.Number(r)).valueOf())),this},bbox:function(){return this.target.bbox()},attr:function(t,n){if(typeof t=="object")for(var r in t)this.attr(r,t[r]);else{var i=this.target.attr(t);this.attrs[t]=e.Color.isColor(i)?(new e.Color(i)).morph(n):e.regex.unit.test(i)?(new e.Number(i)).morph(n):{from:i,to:n}}return this},transform:function(e,t){if(arguments.length==1){e=l(e),delete e.matrix;for(t in e)this.trans[t]={from:this.target.trans[t],to:e[t]}}else{var n={};n[e]=t,this.transform(n)}return this},style:function(e,t){if(typeof e=="object")for(var n in e)this.style(n,e[n]);else this.styles[e]={from:this.target.style(e),to:t};return this},x:function(t){return this._x=(new e.Number(this.target.x())).morph(t),this},y:function(t){return this._y=(new e.Number(this.target.y())).morph(t),this},cx:function(t){return this._cx=(new e.Number(this.target.cx())).morph(t),this},cy:function(t){return this._cy=(new e.Number(this.target.cy())).morph(t),this},move:function(e,t){return this.x(e).y(t)},center:function(e,t){return this.cx(e).cy(t)},size:function(t,n){if(this.target instanceof e.Text)this.attr("font-size",t);else{var r=this.target.bbox();this._size={width:(new e.Number(r.width)).morph(t),height:(new e.Number(r.height)).morph(n)}}return this},plot:function(e){return this._plot=e,this},leading:function(t){return this.target._leading&&(this._leading=(new e.Number(this.target._leading)).morph(t)),this},viewbox:function(t,n,r,i){if(this.target instanceof e.Container){var s=this.target.viewbox();this._viewbox={x:(new e.Number(s.x)).morph(t),y:(new e.Number(s.y)).morph(n),width:(new e.Number(s.width)).morph(r),height:(new e.Number(s.height)).morph(i)}}return this},update:function(t){return this.target instanceof e.Stop&&(t.opacity!=null&&this.attr("stop-opacity",t.opacity),t.color!=null&&this.attr("stop-color",t.color),t.offset!=null&&this.attr("offset",new e.Number(t.offset))),this},during:function(e){return this._during=e,this},after:function(e){return this._after=e,this},loop:function(e){return this._loop=e||!0,this},stop:function(e){return e===!0?(this.animate(0),this._after&&this._after.apply(this.target,[this])):(clearTimeout(this.timeout),this.attrs={},this.trans={},this.styles={},this.situation={},delete this._x,delete this._y,delete this._cx,delete this._cy,delete this._size,delete this._plot,delete this._loop,delete this._after,delete this._during,delete this._leading,delete this._viewbox),this},pause:function(){return this.situation.play===!0&&(this.situation.play=!1,this.situation.pause=(new Date).getTime()),this},play:function(){if(this.situation.play===!1){var e=(new Date).getTime()-this.situation.pause;this.situation.finish+=e,this.situation.start+=e,this.situation.play=!0}return this}},parent:e.Element,construct:{animate:function(t,n,r){return(this.fx||(this.fx=new e.FX(this))).stop().animate(t,n,r)},stop:function(e){return this.fx&&this.fx.stop(e),this},pause:function(){return this.fx&&this.fx.pause(),this},play:function(){return this.fx&&this.fx.play(),this}}}),e.extend(e.Element,e.FX,{dx:function(e){return this.x((this.target||this).x()+e)},dy:function(e){return this.y((this.target||this).y()+e)},dmove:function(e,t){return this.dx(e).dy(t)}}),["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){e.Element.prototype[t]=function(e){var n=this;return this.node["on"+t]=typeof e=="function"?function(){return e.apply(n,arguments)}:null,this}}),e.events={},e.listeners={},e.registerEvent=function(n){e.events[n]||(e.events[n]=new t(n))},e.on=function(t,n,r){var i=r.bind(t.instance||t);e.listeners[t]=e.listeners[t]||{},e.listeners[t][n]=e.listeners[t][n]||{},e.listeners[t][n][r]=i,t.addEventListener(n,i,!1)},e.off=function(t,n,r){if(r)e.listeners[t]&&e.listeners[t][n]&&(t.removeEventListener(n,e.listeners[t][n][r],!1),delete e.listeners[t][n][r]);else if(n){if(e.listeners[t][n]){for(r in e.listeners[t][n])e.off(t,n,r);delete e.listeners[t][n]}}else if(e.listeners[t]){for(n in e.listeners[t])e.off(t,n);delete e.listeners[t]}},e.extend(e.Element,{on:function(t,n){return e.on(this.node,t,n),this},off:function(t,n){return e.off(this.node,t,n),this},fire:function(t,n){return e.events[t].detail=n,this.node.dispatchEvent(e.events[t]),delete e.events[t].detail,this}}),e.Defs=e.invent({create:"defs",inherit:e.Container}),e.G=e.invent({create:"g",inherit:e.Container,extend:{x:function(e){return e==null?this.trans.x:this.transform("x",e)},y:function(e){return e==null?this.trans.y:this.transform("y",e)},cx:function(e){return e==null?this.bbox().cx:this.x(e-this.bbox().width/2)},cy:function(e){return e==null?this.bbox().cy:this.y(e-this.bbox().height/2)}},construct:{group:function(){return this.put(new e.G)}}}),e.extend(e.Element,{siblings:function(){return this.parent.children()},position:function(){return this.parent.index(this)},next:function(){return this.siblings()[this.position()+1]},previous:function(){return this.siblings()[this.position()-1]},forward:function(){var e=this.position();return this.parent.removeElement(this).put(this,e+1)},backward:function(){var e=this.position();return e>0&&this.parent.removeElement(this).add(this,e-1),this},front:function(){return this.parent.removeElement(this).put(this)},back:function(){return this.position()>0&&this.parent.removeElement(this).add(this,0),this},before:function(e){e.remove();var t=this.position();return this.parent.add(e,t),this},after:function(e){e.remove();var t=this.position();return this.parent.add(e,t+1),this}}),e.Mask=e.invent({create:function(){this.constructor.call(this,e.create("mask")),this.targets=[]},inherit:e.Container,extend:{remove:function(){for(var e=this.targets.length-1;e>=0;e--)this.targets[e]&&this.targets[e].unmask();return delete this.targets,this.parent.removeElement(this),this}},construct:{mask:function(){return this.defs().put(new e.Mask)}}}),e.extend(e.Element,{maskWith:function(t){return this.masker=t instanceof e.Mask?t:this.parent.mask().add(t),this.masker.targets.push(this),this.attr("mask",'url("#'+this.masker.attr("id")+'")')},unmask:function(){return delete this.masker,this.attr("mask",null)}}),e.Clip=e.invent({create:function(){this.constructor.call(this,e.create("clipPath")),this.targets=[]},inherit:e.Container,extend:{remove:function(){for(var e=this.targets.length-1;e>=0;e--)this.targets[e]&&this.targets[e].unclip();return delete this.targets,this.parent.removeElement(this),this}},construct:{clip:function(){return this.defs().put(new e.Clip)}}}),e.extend(e.Element,{clipWith:function(t){return this.clipper=t instanceof e.Clip?t:this.parent.clip().add(t),this.clipper.targets.push(this),this.attr("clip-path",'url("#'+this.clipper.attr("id")+'")')},unclip:function(){return delete this.clipper,this.attr("clip-path",null)}}),e.Gradient=e.invent({create:function(t){this.constructor.call(this,e.create(t+"Gradient")),this.type=t},inherit:e.Container,extend:{from:function(t,n){return this.type=="radial"?this.attr({fx:new e.Number(t),fy:new e.Number(n)}):this.attr({x1:new e.Number(t),y1:new e.Number(n)})},to:function(t,n){return this.type=="radial"?this.attr({cx:new e.Number(t),cy:new e.Number(n)}):this.attr({x2:new e.Number(t),y2:new e.Number(n)})},radius:function(t){return this.type=="radial"?this.attr({r:new e.Number(t)}):this},at:function(t,n,r){return this.put(new e.Stop).update(t,n,r)},update:function(e){return this.clear(),typeof e=="function"&&e.call(this,this),this},fill:function(){return"url(#"+this.id()+")"},toString:function(){return this.fill()}},construct:{gradient:function(e,t){return this.defs().gradient(e,t)}}}),e.extend(e.Defs,{gradient:function(t,n){return this.put(new e.Gradient(t)).update(n)}}),e.Stop=e.invent({create:"stop",inherit:e.Element,extend:{update:function(t){if(typeof t=="number"||t instanceof e.Number)t={offset:arguments[0],color:arguments[1],opacity:arguments[2]};return t.opacity!=null&&this.attr("stop-opacity",t.opacity),t.color!=null&&this.attr("stop-color",t.color),t.offset!=null&&this.attr("offset",new e.Number(t.offset)),this}}}),e.Pattern=e.invent({create:"pattern",inherit:e.Container,extend:{fill:function(){return"url(#"+this.id()+")"},update:function(e){return this.clear(),typeof e=="function"&&e.call(this,this),this},toString:function(){return this.fill()}},construct:{pattern:function(e,t,n){return this.defs().pattern(e,t,n)}}}),e.extend(e.Defs,{pattern:function(t,n,r){return this.put(new e.Pattern).update(r).attr({x:0,y:0,width:t,height:n,patternUnits:"userSpaceOnUse"})}}),e.Doc=e.invent({create:function(t){this.parent=typeof t=="string"?document.getElementById(t):t,this.constructor.call(this,this.parent.nodeName=="svg"?this.parent:e.create("svg")),this.attr({xmlns:e.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",e.xlink,e.xmlns),this._defs=new e.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:e.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),e.on(window,"resize",function(){t.spof()}),this},defs:function(){return this._defs},spof:function(){if(this.doSpof){var e=this.node.getScreenCTM();e&&this.style("left",-e.e%1+"px").style("top",-e.f%1+"px")}return this},fixSubPixelOffset:function(){return this.doSpof=!0,this}}}),e.Shape=e.invent({create:function(e){this.constructor.call(this,e)},inherit:e.Element}),e.Symbol=e.invent({create:"symbol",inherit:e.Container,construct:{symbol:function(){return this.defs().put(new e.Symbol)}}}),e.Use=e.invent({create:"use",inherit:e.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,e.xlink)}},construct:{use:function(t){return this.put(new e.Use).element(t)}}}),e.Rect=e.invent({create:"rect",inherit:e.Shape,construct:{rect:function(t,n){return this.put((new e.Rect).size(t,n))}}}),e.Ellipse=e.invent({create:"ellipse",inherit:e.Shape,extend:{x:function(e){return e==null?this.cx()-this.attr("rx"):this.cx(e+this.attr("rx"))},y:function(e){return e==null?this
+.cy()-this.attr("ry"):this.cy(e+this.attr("ry"))},cx:function(t){return t==null?this.attr("cx"):this.attr("cx",(new e.Number(t)).divide(this.trans.scaleX))},cy:function(t){return t==null?this.attr("cy"):this.attr("cy",(new e.Number(t)).divide(this.trans.scaleY))},width:function(t){return t==null?this.attr("rx")*2:this.attr("rx",(new e.Number(t)).divide(2))},height:function(t){return t==null?this.attr("ry")*2:this.attr("ry",(new e.Number(t)).divide(2))},size:function(t,n){var r=o(this.bbox(),t,n);return this.attr({rx:(new e.Number(r.width)).divide(2),ry:(new e.Number(r.height)).divide(2)})}},construct:{circle:function(e){return this.ellipse(e,e)},ellipse:function(t,n){return this.put(new e.Ellipse).size(t,n).move(0,0)}}}),e.Line=e.invent({create:"line",inherit:e.Shape,extend:{x:function(e){var t=this.bbox();return e==null?t.x:this.attr({x1:this.attr("x1")-t.x+e,x2:this.attr("x2")-t.x+e})},y:function(e){var t=this.bbox();return e==null?t.y:this.attr({y1:this.attr("y1")-t.y+e,y2:this.attr("y2")-t.y+e})},cx:function(e){var t=this.bbox().width/2;return e==null?this.x()+t:this.x(e-t)},cy:function(e){var t=this.bbox().height/2;return e==null?this.y()+t:this.y(e-t)},width:function(e){var t=this.bbox();return e==null?t.width:this.attr(this.attr("x1")<this.attr("x2")?"x2":"x1",t.x+e)},height:function(e){var t=this.bbox();return e==null?t.height:this.attr(this.attr("y1")<this.attr("y2")?"y2":"y1",t.y+e)},size:function(e,t){var n=o(this.bbox(),e,t);return this.width(n.width).height(n.height)},plot:function(e,t,n,r){return this.attr({x1:e,y1:t,x2:n,y2:r})}},construct:{line:function(t,n,r,i){return this.put((new e.Line).plot(t,n,r,i))}}}),e.Polyline=e.invent({create:"polyline",inherit:e.Shape,construct:{polyline:function(t){return this.put(new e.Polyline).plot(t)}}}),e.Polygon=e.invent({create:"polygon",inherit:e.Shape,construct:{polygon:function(t){return this.put(new e.Polygon).plot(t)}}}),e.extend(e.Polyline,e.Polygon,{morphArray:e.PointArray,plot:function(t){return this.attr("points",this.array=new e.PointArray(t,[[0,0]]))},move:function(e,t){return this.attr("points",this.array.move(e,t))},x:function(e){return e==null?this.bbox().x:this.move(e,this.bbox().y)},y:function(e){return e==null?this.bbox().y:this.move(this.bbox().x,e)},width:function(e){var t=this.bbox();return e==null?t.width:this.size(e,t.height)},height:function(e){var t=this.bbox();return e==null?t.height:this.size(t.width,e)},size:function(e,t){var n=o(this.bbox(),e,t);return this.attr("points",this.array.size(n.width,n.height))}}),e.Path=e.invent({create:"path",inherit:e.Shape,extend:{plot:function(t){return this.attr("d",this.array=new e.PathArray(t,[["M",0,0]]))},move:function(e,t){return this.attr("d",this.array.move(e,t))},x:function(e){return e==null?this.bbox().x:this.move(e,this.bbox().y)},y:function(e){return e==null?this.bbox().y:this.move(this.bbox().x,e)},size:function(e,t){var n=o(this.bbox(),e,t);return this.attr("d",this.array.size(n.width,n.height))},width:function(e){return e==null?this.bbox().width:this.size(e,this.bbox().height)},height:function(e){return e==null?this.bbox().height:this.size(this.bbox().width,e)}},construct:{path:function(t){return this.put(new e.Path).plot(t)}}}),e.Image=e.invent({create:"image",inherit:e.Shape,extend:{load:function(t){if(!t)return this;var n=this,r=document.createElement("img");return r.onload=function(){var i=n.doc(e.Pattern);n.width()==0&&n.height()==0&&n.size(r.width,r.height),i&&i.width()==0&&i.height()==0&&i.size(n.width(),n.height()),typeof n._loaded=="function"&&n._loaded.call(n,{width:r.width,height:r.height,ratio:r.width/r.height,url:t})},this.attr("href",r.src=this.src=t,e.xlink)},loaded:function(e){return this._loaded=e,this}},construct:{image:function(t,n,r){return this.put(new e.Image).load(t).size(n||0,r||n||0)}}}),e.Text=e.invent({create:function(){this.constructor.call(this,e.create("text")),this._leading=new e.Number(1.3),this._rebuild=!0,this._build=!1,this.attr("font-family",e.defaults.attrs["font-family"])},inherit:e.Shape,extend:{x:function(e){return e==null?this.attr("x"):(this.textPath||this.lines.each(function(){this.newLined&&this.x(e)}),this.attr("x",e))},y:function(e){var t=this.attr("y"),n=typeof t=="number"?t-this.bbox().y:0;return e==null?typeof t=="number"?t-n:t:this.attr("y",typeof e=="number"?e+n:e)},cx:function(e){return e==null?this.bbox().cx:this.x(e-this.bbox().width/2)},cy:function(e){return e==null?this.bbox().cy:this.y(e-this.bbox().height/2)},text:function(e){if(typeof e=="undefined")return this.content;this.clear().build(!0);if(typeof e=="function")e.call(this,this);else{e=(this.content=e).split("\n");for(var t=0,n=e.length;t<n;t++)this.tspan(e[t]).newLine()}return this.build(!1).rebuild()},size:function(e){return this.attr("font-size",e).rebuild()},leading:function(t){return t==null?this._leading:(this._leading=new e.Number(t),this.rebuild())},rebuild:function(t){typeof t=="boolean"&&(this._rebuild=t);if(this._rebuild){var n=this;this.lines.each(function(){this.newLined&&(this.textPath||this.attr("x",n.attr("x")),this.attr("dy",n._leading*new e.Number(n.attr("font-size"))))}),this.fire("rebuild")}return this},build:function(e){return this._build=!!e,this}},construct:{text:function(t){return this.put(new e.Text).text(t)},plain:function(t){return this.put(new e.Text).plain(t)}}}),e.TSpan=e.invent({create:"tspan",inherit:e.Shape,extend:{text:function(e){return typeof e=="function"?e.call(this,this):this.plain(e),this},dx:function(e){return this.attr("dx",e)},dy:function(e){return this.attr("dy",e)},newLine:function(){var t=this.doc(e.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),e.extend(e.Text,e.TSpan,{plain:function(e){return this._build===!1&&this.clear(),this.node.appendChild(document.createTextNode(this.content=e)),this},tspan:function(t){var n=(this.textPath||this).node,r=new e.TSpan;return this._build===!1&&this.clear(),n.appendChild(r.node),r.parent=this,this instanceof e.Text&&this.lines.add(r),r.text(t)},clear:function(){var t=(this.textPath||this).node;while(t.hasChildNodes())t.removeChild(t.lastChild);return this instanceof e.Text&&(delete this.lines,this.lines=new e.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),e.registerEvent("rebuild"),e.TextPath=e.invent({create:"textPath",inherit:e.Element,parent:e.Text,construct:{path:function(t){this.textPath=new e.TextPath;while(this.node.hasChildNodes())this.textPath.node.appendChild(this.node.firstChild);return this.node.appendChild(this.textPath.node),this.track=this.doc().defs().path(t),this.textPath.parent=this,this.textPath.attr("href","#"+this.track,e.xlink),this},plot:function(e){return this.track&&this.track.plot(e),this}}}),e.Nested=e.invent({create:function(){this.constructor.call(this,e.create("svg")),this.style("overflow","visible")},inherit:e.Container,construct:{nested:function(){return this.put(new e.Nested)}}}),e.A=e.invent({create:"a",inherit:e.Container,extend:{to:function(t){return this.attr("href",t,e.xlink)},show:function(t){return this.attr("show",t,e.xlink)},target:function(e){return this.attr("target",e)}},construct:{link:function(t){return this.put(new e.A).to(t)}}}),e.extend(e.Element,{linkTo:function(t){var n=new e.A;return typeof t=="function"?t.call(n,n):n.to(t),this.parent.put(n).put(this)}}),e.Marker=e.invent({create:"marker",inherit:e.Container,extend:{width:function(e){return this.attr("markerWidth",e)},height:function(e){return this.attr("markerHeight",e)},ref:function(e,t){return this.attr("refX",e).attr("refY",t)},update:function(e){return this.clear(),typeof e=="function"&&e.call(this,this),this},toString:function(){return"url(#"+this.id()+")"}},construct:{marker:function(e,t,n){return this.defs().marker(e,t,n)}}}),e.extend(e.Defs,{marker:function(t,n,r){return this.put(new e.Marker).size(t,n).ref(t/2,n/2).viewbox(0,0,t,n).attr("orient","auto").update(r)}}),e.extend(e.Line,e.Polyline,e.Polygon,e.Path,{marker:function(t,n,r,i){var s=["marker"];return t!="all"&&s.push(t),s=s.join("-"),t=arguments[1]instanceof e.Marker?arguments[1]:this.doc().marker(n,r,i),this.attr(s,t)}});var n={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(e,t){return t=="color"?e:e+"-"+t}};return["fill","stroke"].forEach(function(t){var r,i={};i[t]=function(i){if(typeof i=="string"||e.Color.isRgb(i)||i&&typeof i.fill=="function")this.attr(t,i);else for(r=n[t].length-1;r>=0;r--)i[n[t][r]]!=null&&this.attr(n.prefix(t,n[t][r]),i[n[t][r]]);return this},e.extend(e.Element,e.FX,i)}),e.extend(e.Element,e.FX,{rotate:function(e,t,n){return this.transform({rotation:e||0,cx:t,cy:n})},skew:function(e,t){return this.transform({skewX:e||0,skewY:t||0})},scale:function(e,t){return this.transform({scaleX:e,scaleY:t==null?e:t})},translate:function(e,t){return this.transform({x:e,y:t})},matrix:function(e){return this.transform({matrix:e})},opacity:function(e){return this.attr("opacity",e)}}),e.extend(e.Rect,e.Ellipse,e.FX,{radius:function(e,t){return this.attr({rx:e,ry:t||e})}}),e.extend(e.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(e){return this.node.getPointAtLength(e)}}),e.extend(e.Parent,e.Text,e.FX,{font:function(e){for(var t in e)t=="leading"?this.leading(e[t]):t=="anchor"?this.attr("text-anchor",e[t]):t=="size"||t=="family"||t=="weight"||t=="stretch"||t=="variant"||t=="style"?this.attr("font-"+t,e[t]):this.attr(t,e[t]);return this}}),e.Set=e.invent({create:function(){this.clear()},extend:{add:function(){var e,t,n=[].slice.call(arguments);for(e=0,t=n.length;e<t;e++)this.members.push(n[e]);return this},remove:function(e){var t=this.index(e);return t>-1&&this.members.splice(t,1),this},each:function(e){for(var t=0,n=this.members.length;t<n;t++)e.apply(this.members[t],[t,this.members]);return this},clear:function(){return this.members=[],this},has:function(e){return this.index(e)>=0},index:function(e){return this.members.indexOf(e)},get:function(e){return this.members[e]},first:function(){return this.get(0)},last:function(){return this.get(this.members.length-1)},valueOf:function(){return this.members},bbox:function(){var t=new e.BBox;if(this.members.length==0)return t;var n=this.members[0].rbox();return t.x=n.x,t.y=n.y,t.width=n.width,t.height=n.height,this.each(function(){t=t.merge(this.rbox())}),t}},construct:{set:function(){return new e.Set}}}),e.SetFX=e.invent({create:function(e){this.set=e}}),e.Set.inherit=function(){var t,n=[];for(var t in e.Shape.prototype)typeof e.Shape.prototype[t]=="function"&&typeof e.Set.prototype[t]!="function"&&n.push(t);n.forEach(function(t){e.Set.prototype[t]=function(){for(var n=0,r=this.members.length;n<r;n++)this.members[n]&&typeof this.members[n][t]=="function"&&this.members[n][t].apply(this.members[n],arguments);return t=="animate"?this.fx||(this.fx=new e.SetFX(this)):this}}),n=[];for(var t in e.FX.prototype)typeof e.FX.prototype[t]=="function"&&typeof e.SetFX.prototype[t]!="function"&&n.push(t);n.forEach(function(t){e.SetFX.prototype[t]=function(){for(var e=0,n=this.set.members.length;e<n;e++)this.set.members[e].fx[t].apply(this.set.members[e].fx,arguments);return this}})},e.extend(e.Element,{data:function(e,t,n){if(typeof e=="object")for(t in e)this.data(t,e[t]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+e))}catch(r){return this.attr("data-"+e)}else this.attr("data-"+e,t===null?null:n===!0||typeof t=="string"||typeof t=="number"?t:JSON.stringify(t));return this}}),e.extend(e.Element,{remember:function(e,t){if(typeof arguments[0]=="object")for(var t in e)this.remember(t,e[t]);else{if(arguments.length==1)return this.memory()[e];this.memory()[e]=t}return this},forget:function(){if(arguments.length==0)this._memory={};else for(var e=arguments.length-1;e>=0;e--)delete this.memory()[arguments[e]];return this},memory:function(){return this._memory||(this._memory={})}}),typeof define=="function"&&define.amd?define(function(){return e}):typeof exports!="undefined"&&(exports.SVG=e),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}}(),e}); \ No newline at end of file
diff --git a/package.json b/package.json
index a704576..78bc1b4 100755
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
, "keywords": ["svg", "vector", "graphics", "animation"]
, "author": "Wout Fierens <wout@impinc.co.uk>"
, "main": "dist/svg.js"
-, "version": "1.0.0-rc.9"
+, "version": "1.0.0"
, "jam": {
"include": [
"dist/svg.js"
diff --git a/spec/index.html b/spec/index.html
index 2dd41b2..8896dd0 100755
--- a/spec/index.html
+++ b/spec/index.html
@@ -3,7 +3,7 @@
<html>
<head>
<title>Jasmine Spec Runner</title>
-
+
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.1/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
@@ -35,6 +35,7 @@
<script type="text/javascript" src="spec/element.js"></script>
<script type="text/javascript" src="spec/memory.js"></script>
<script type="text/javascript" src="spec/arrange.js"></script>
+<script type="text/javascript" src="spec/event.js"></script>
<script type="text/javascript" src="spec/bbox.js"></script>
<script type="text/javascript" src="spec/rect.js"></script>
<script type="text/javascript" src="spec/ellipse.js"></script>
diff --git a/spec/spec/element.js b/spec/spec/element.js
index 5bda0d2..cc4912b 100755
--- a/spec/spec/element.js
+++ b/spec/spec/element.js
@@ -249,12 +249,12 @@ describe('Element', function() {
it('returns the correct rectangular box', function() {
var rect = draw.size(200,150).viewbox(0,0,200,150).rect(105,210).move(2,12)
var box = rect.rbox()
- expect(approximately(box.x)).toBe(approximately(2))
- expect(approximately(box.y)).toBe(approximately(12))
- expect(approximately(box.cx)).toBe(approximately(54.5))
- expect(approximately(box.cy)).toBe(approximately(117))
- expect(approximately(box.width)).toBe(approximately(105))
- expect(approximately(box.height)).toBe(approximately(210))
+ expect(box.x).toBe(2)
+ expect(box.y).toBe(12)
+ expect(box.cx).toBe(54.5)
+ expect(box.cy).toBe(117)
+ expect(box.width).toBeCloseTo(105)
+ expect(box.height).toBeCloseTo(210)
})
it('returns the correct rectangular box within a viewbox', function() {
var rect = draw.size(200,150).viewbox(0,0,100,75).rect(105,210).move(2,12)
@@ -418,7 +418,7 @@ describe('Element', function() {
, use = draw.use(rect)
, mark = draw.marker(10, 10)
, path = draw.path(svgPath).marker('end', mark)
-
+
expect(use.reference('href')).toBe(rect)
expect(path.reference('marker-end')).toBe(mark)
})
diff --git a/spec/spec/event.js b/spec/spec/event.js
new file mode 100644
index 0000000..45db382
--- /dev/null
+++ b/spec/spec/event.js
@@ -0,0 +1,385 @@
+describe('Event', function() {
+ var rect, context
+ , toast = null
+ , action = function() {
+ toast = 'ready'
+ context = this
+ }
+
+ beforeEach(function() {
+ rect = draw.rect(100, 100)
+ })
+
+ afterEach(function() {
+ toast = context = null
+ })
+
+ if (!window.isTouchDevice) {
+
+ describe('click()', function() {
+ it('attaches an onclick event to the node of the element', function() {
+ expect(typeof rect.node.onclick).not.toBe('function')
+ rect.click(action)
+ expect(typeof rect.node.onclick).toBe('function')
+ })
+ it('fires the event on click', function() {
+ dispatchEvent(rect.click(action), 'click')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.click(action), 'click')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.click(action)).toBe(rect)
+ })
+ })
+
+ describe('dblclick()', function() {
+ it('attaches an ondblclick event to the node of the element', function() {
+ expect(typeof rect.node.ondblclick).not.toBe('function')
+ rect.dblclick(action)
+ expect(typeof rect.node.ondblclick).toBe('function')
+ })
+ it('fires the event on dblclick', function() {
+ dispatchEvent(rect.dblclick(action), 'dblclick')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.dblclick(action), 'dblclick')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.dblclick(action)).toBe(rect)
+ })
+ })
+
+ describe('mousedown()', function() {
+ it('attaches an onmousedown event to the node of the element', function() {
+ expect(typeof rect.node.onmousedown).not.toBe('function')
+ rect.mousedown(action)
+ expect(typeof rect.node.onmousedown).toBe('function')
+ })
+ it('fires the event on mousedown', function() {
+ dispatchEvent(rect.mousedown(action), 'mousedown')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.mousedown(action), 'mousedown')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.mousedown(action)).toBe(rect)
+ })
+ })
+
+ describe('mouseup()', function() {
+ it('attaches an onmouseup event to the node of the element', function() {
+ expect(typeof rect.node.onmouseup).not.toBe('function')
+ rect.mouseup(action)
+ expect(typeof rect.node.onmouseup).toBe('function')
+ })
+ it('fires the event on mouseup', function() {
+ dispatchEvent(rect.mouseup(action), 'mouseup')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.mouseup(action), 'mouseup')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.mouseup(action)).toBe(rect)
+ })
+ })
+
+ describe('mouseover()', function() {
+ it('attaches an onmouseover event to the node of the element', function() {
+ expect(typeof rect.node.onmouseover).not.toBe('function')
+ rect.mouseover(action)
+ expect(typeof rect.node.onmouseover).toBe('function')
+ })
+ it('fires the event on mouseover', function() {
+ dispatchEvent(rect.mouseover(action), 'mouseover')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.mouseover(action), 'mouseover')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.mouseover(action)).toBe(rect)
+ })
+ })
+
+ describe('mouseout()', function() {
+ it('attaches an onmouseout event to the node of the element', function() {
+ expect(typeof rect.node.onmouseout).not.toBe('function')
+ rect.mouseout(action)
+ expect(typeof rect.node.onmouseout).toBe('function')
+ })
+ it('fires the event on mouseout', function() {
+ dispatchEvent(rect.mouseout(action), 'mouseout')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.mouseout(action), 'mouseout')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.mouseout(action)).toBe(rect)
+ })
+ })
+
+ describe('mousemove()', function() {
+ it('attaches an onmousemove event to the node of the element', function() {
+ expect(typeof rect.node.onmousemove).not.toBe('function')
+ rect.mousemove(action)
+ expect(typeof rect.node.onmousemove).toBe('function')
+ })
+ it('fires the event on mousemove', function() {
+ dispatchEvent(rect.mousemove(action), 'mousemove')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.mousemove(action), 'mousemove')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.mousemove(action)).toBe(rect)
+ })
+ })
+
+ // NOT SUPPORTED BY IE
+ // describe('mouseenter()', function() {
+ // it('attaches an onmouseenter event to the node of the element', function() {
+ // expect(typeof rect.node.onmouseenter).not.toBe('function')
+ // rect.mouseenter(action)
+ // expect(typeof rect.node.onmouseenter).toBe('function')
+ // })
+ // it('fires the event on mouseenter', function() {
+ // dispatchEvent(rect.mouseenter(action), 'mouseenter')
+ // expect(toast).toBe('ready')
+ // })
+ // it('applies the element as context', function() {
+ // dispatchEvent(rect.mouseenter(action), 'mouseenter')
+ // expect(context).toBe(rect)
+ // })
+ // it('returns the called element', function() {
+ // expect(rect.mouseenter(action)).toBe(rect)
+ // })
+ // })
+
+ // NOT SUPPORTED BY IE
+ // describe('mouseleave()', function() {
+ // it('attaches an onmouseleave event to the node of the element', function() {
+ // expect(typeof rect.node.onmouseleave).not.toBe('function')
+ // rect.mouseleave(action)
+ // expect(typeof rect.node.onmouseleave).toBe('function')
+ // })
+ // it('fires the event on mouseleave', function() {
+ // dispatchEvent(rect.mouseleave(action), 'mouseleave')
+ // expect(toast).toBe('ready')
+ // })
+ // it('applies the element as context', function() {
+ // dispatchEvent(rect.mouseleave(action), 'mouseleave')
+ // expect(context).toBe(rect)
+ // })
+ // it('returns the called element', function() {
+ // expect(rect.mouseleave(action)).toBe(rect)
+ // })
+ // })
+
+ } else {
+
+ describe('touchstart()', function() {
+ it('attaches an ontouchstart event to the node of the element', function() {
+ expect(typeof rect.node.ontouchstart).not.toBe('function')
+ rect.touchstart(action)
+ expect(typeof rect.node.ontouchstart).toBe('function')
+ })
+ it('fires the event on touchstart', function() {
+ dispatchEvent(rect.touchstart(action), 'touchstart')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.touchstart(action), 'touchstart')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.touchstart(action)).toBe(rect)
+ })
+ })
+
+ describe('touchmove()', function() {
+ it('attaches an ontouchmove event to the node of the element', function() {
+ expect(typeof rect.node.ontouchmove).not.toBe('function')
+ rect.touchmove(action)
+ expect(typeof rect.node.ontouchmove).toBe('function')
+ })
+ it('fires the event on touchmove', function() {
+ dispatchEvent(rect.touchmove(action), 'touchmove')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.touchmove(action), 'touchmove')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.touchmove(action)).toBe(rect)
+ })
+ })
+
+ describe('touchleave()', function() {
+ it('attaches an ontouchleave event to the node of the element', function() {
+ expect(typeof rect.node.ontouchleave).not.toBe('function')
+ rect.touchleave(action)
+ expect(typeof rect.node.ontouchleave).toBe('function')
+ })
+ it('fires the event on touchleave', function() {
+ dispatchEvent(rect.touchleave(action), 'touchleave')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.touchleave(action), 'touchleave')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.touchleave(action)).toBe(rect)
+ })
+ })
+
+ describe('touchend()', function() {
+ it('attaches an ontouchend event to the node of the element', function() {
+ expect(typeof rect.node.ontouchend).not.toBe('function')
+ rect.touchend(action)
+ expect(typeof rect.node.ontouchend).toBe('function')
+ })
+ it('fires the event on touchend', function() {
+ dispatchEvent(rect.touchend(action), 'touchend')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.touchend(action), 'touchend')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.touchend(action)).toBe(rect)
+ })
+ })
+
+ describe('touchcancel()', function() {
+ it('attaches an ontouchcancel event to the node of the element', function() {
+ expect(typeof rect.node.ontouchcancel).not.toBe('function')
+ rect.touchcancel(action)
+ expect(typeof rect.node.ontouchcancel).toBe('function')
+ })
+ it('fires the event on touchcancel', function() {
+ dispatchEvent(rect.touchcancel(action), 'touchcancel')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.touchcancel(action), 'touchcancel')
+ expect(context).toBe(rect)
+ })
+ it('returns the called element', function() {
+ expect(rect.touchcancel(action)).toBe(rect)
+ })
+ })
+
+ }
+
+ describe('registerEvent()', function() {
+ it('creates a new custom event and stores it in the events object', function() {
+ expect(SVG.events['my:event']).toBeUndefined()
+ SVG.registerEvent('my:event')
+ expect(SVG.events['my:event'] instanceof CustomEvent).toBeTruthy()
+ })
+ })
+
+ describe('on()', function() {
+
+ beforeEach(function() {
+ SVG.registerEvent('my:event')
+ })
+
+ it('attaches and event to the element', function() {
+ dispatchEvent(rect.on('my:event', action), 'my:event')
+ expect(toast).toBe('ready')
+ })
+ it('applies the element as context', function() {
+ dispatchEvent(rect.on('my:event', action), 'my:event')
+ expect(context).toBe(rect)
+ })
+ it('stores the listener for future reference', function() {
+ rect.on('my:event', action)
+ expect(SVG.listeners[rect.node]['my:event'][action]).not.toBeUndefined()
+ })
+ it('returns the called element', function() {
+ expect(rect.on('my:event', action)).toBe(rect)
+ })
+ })
+
+ describe('off()', function() {
+ var butter = null
+
+ beforeEach(function() {
+ butter = null
+ SVG.registerEvent('my:event')
+ })
+
+ it('detaches a specific event listener', function() {
+ rect.on('my:event', action)
+ rect.off('my:event', action)
+ dispatchEvent(rect, 'my:event')
+ expect(toast).toBeNull()
+ expect(SVG.listeners[rect.node]['my:event'][action]).toBeUndefined()
+ })
+ it('detaches all listeners for an event without a listener given', function() {
+ rect.on('my:event', action)
+ rect.on('my:event', function() { butter = 'melting' })
+ rect.off('my:event')
+ dispatchEvent(rect, 'my:event')
+ expect(toast).toBeNull()
+ expect(butter).toBeNull()
+ expect(SVG.listeners[rect.node]['my:event']).toBeUndefined()
+ })
+ it('detaches all listeners without an argument', function() {
+ rect.on('my:event', action)
+ rect.on('click', function() { butter = 'melting' })
+ rect.off()
+ dispatchEvent(rect, 'my:event')
+ dispatchEvent(rect, 'click')
+ expect(toast).toBeNull()
+ expect(butter).toBeNull()
+ expect(SVG.listeners[rect.node]).toBeUndefined()
+ })
+ it('returns the called element', function() {
+ expect(rect.off('my:event', action)).toBe(rect)
+ })
+ })
+
+ describe('fire()', function() {
+
+ beforeEach(function() {
+ SVG.registerEvent('my:event')
+ rect.on('my:event', action)
+ })
+
+ it('fires an event for the element', function() {
+ expect(toast).toBeNull()
+ rect.fire('my:event')
+ expect(toast).toBe('ready')
+ })
+ it('returns the called element', function() {
+ expect(rect.fire('my:event')).toBe(rect)
+ })
+
+ })
+
+})
+
+
+
+
+
+
diff --git a/spec/spec/helper.js b/spec/spec/helper.js
index e3cba61..8b46076 100755
--- a/spec/spec/helper.js
+++ b/spec/spec/helper.js
@@ -13,6 +13,9 @@ imageUrl = ''
/* lorem ipsum text */
loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sodales\n imperdiet auctor. Nunc ultrices lectus at erat dictum pharetra\n elementum ante posuere. Duis turpis risus, blandit nec elementum et,\n posuere eget lacus. Aliquam et risus magna, eu aliquet nibh. Fusce\n consequat mi quis purus varius sagittis euismod urna interdum.\n Curabitur aliquet orci quis felis semper vulputate. Vestibulum ac nisi\n magna, id dictum diam. Proin sed metus vel magna blandit\n sodales. Pellentesque at neque ultricies nunc euismod rutrum ut in\n lorem. Mauris euismod tellus in tellus tempus interdum. Phasellus\n mattis sapien et leo feugiat dictum. Vestibulum at volutpat velit.'
+/* test for touch device */
+window.isTouchDevice = 'ontouchstart' in document.documentElement
+
/* approximately helper */
function approximately(number, precision) {
precision = precision == null ? 1.5 : precision
@@ -23,4 +26,24 @@ function approximately(number, precision) {
/* strip spaces from result */
function stripped(string) {
return string.replace(/\s+/g, '')
+}
+
+/* dispatch an event */
+function dispatchEvent(element, name) {
+ var e
+
+ if (document.createEvent) {
+ e = document.createEvent('HTMLEvents')
+ e.initEvent(name, true, true)
+ } else {
+ e = document.createEventObject()
+ e.eventType = name
+ }
+
+ e.eventName = name
+
+ if (document.createEvent)
+ element.node.dispatchEvent(e)
+ else
+ element.node.fireEvent('on' + name, e)
} \ No newline at end of file
diff --git a/spec/spec/selector.js b/spec/spec/selector.js
index 4727bfd..eb3d6bf 100644
--- a/spec/spec/selector.js
+++ b/spec/spec/selector.js
@@ -19,7 +19,7 @@ describe('Selector', function() {
, mark = draw.marker(10, 10)
, path = draw.path(svgPath).marker('end', mark)
- expect(SVG.get(use.attr('href'))).toBe(rect)
+ expect(SVG.get(use.attr().href)).toBe(rect)
expect(SVG.get(path.attr('marker-end'))).toBe(mark)
})
})
diff --git a/spec/spec/svg.js b/spec/spec/svg.js
index cc9f7be..5f3f1d1 100755
--- a/spec/spec/svg.js
+++ b/spec/spec/svg.js
@@ -48,7 +48,7 @@ describe('SVG', function() {
return this.opacity(0.2)
}
})
-
+ expect(draw.rect(100,100).soft() instanceof SVG.Rect).toBeTruthy()
expect(typeof SVG.Rect.prototype.soft).toBe('function')
expect(draw.rect(100,100).soft().attr('opacity')).toBe(0.2)
})
diff --git a/src/element.js b/src/element.js
index b12947b..8c4166d 100755
--- a/src/element.js
+++ b/src/element.js
@@ -144,11 +144,11 @@ SVG.Element = SVG.invent({
} else if (v == null) {
/* act as a getter if the first and only argument is not an object */
- v = this.node.getAttribute(a)
+ v = this.node.attributes[a]
return v == null ?
SVG.defaults.attrs[a] :
- SVG.regex.isNumber.test(v) ?
- parseFloat(v) : v
+ SVG.regex.isNumber.test(v.nodeValue) ?
+ parseFloat(v.nodeValue) : v.nodeValue
} else if (a == 'style') {
/* redirect to the style method */
@@ -389,7 +389,7 @@ SVG.Element = SVG.invent({
}
// Get referenced element form attribute value
, reference: function(attr) {
- return SVG.get(this.attr(attr))
+ return SVG.get(this.attr()[attr])
}
// Private: find svg parent by instance
, _parent: function(parent) {
diff --git a/src/event.js b/src/event.js
index 8430fa0..63764ed 100755
--- a/src/event.js
+++ b/src/event.js
@@ -6,8 +6,8 @@
, 'mouseover'
, 'mouseout'
, 'mousemove'
- , 'mouseenter'
- , 'mouseleave'
+ // , 'mouseenter' -> not supported by IE
+ // , 'mouseleave' -> not supported by IE
, 'touchstart'
, 'touchmove'
, 'touchleave'
@@ -34,20 +34,54 @@ SVG.listeners = {}
// Event constructor
SVG.registerEvent = function(event) {
if (!SVG.events[event])
- SVG.events[event] = new Event(event)
+ SVG.events[event] = new CustomEvent(event)
}
// Add event binder in the SVG namespace
SVG.on = function(node, event, listener) {
+ // create listener
var l = listener.bind(node.instance || node)
- SVG.listeners[listener] = l
+
+ // ensure reference objects
+ SVG.listeners[node] = SVG.listeners[node] || {}
+ SVG.listeners[node][event] = SVG.listeners[node][event] || {}
+
+ // reference listener
+ SVG.listeners[node][event][listener] = l
+
+ // add listener
node.addEventListener(event, l, false)
}
// Add event unbinder in the SVG namespace
SVG.off = function(node, event, listener) {
- node.removeEventListener(event, SVG.listeners[listener], false)
- delete SVG.listeners[listener]
+ if (listener) {
+ // remove listener reference
+ if (SVG.listeners[node] && SVG.listeners[node][event]) {
+ // remove listener
+ node.removeEventListener(event, SVG.listeners[node][event][listener], false)
+
+ delete SVG.listeners[node][event][listener]
+ }
+
+ } else if (event) {
+ // remove all listeners for the event
+ if (SVG.listeners[node][event]) {
+ for (listener in SVG.listeners[node][event])
+ SVG.off(node, event, listener)
+
+ delete SVG.listeners[node][event]
+ }
+
+ } else {
+ // remove all listeners on a given node
+ if (SVG.listeners[node]) {
+ for (event in SVG.listeners[node])
+ SVG.off(node, event)
+
+ delete SVG.listeners[node]
+ }
+ }
}
//
@@ -65,9 +99,16 @@ SVG.extend(SVG.Element, {
return this
}
// Fire given event
-, fire: function(event) {
+, fire: function(event, data) {
+ // Add detail data to event
+ SVG.events[event].detail = data
+
+ // Dispatch event
this.node.dispatchEvent(SVG.events[event])
+ // Remove detail
+ delete SVG.events[event].detail
+
return this
}
}) \ No newline at end of file
diff --git a/src/polyfill.js b/src/polyfill.js
new file mode 100644
index 0000000..3a3c25c
--- /dev/null
+++ b/src/polyfill.js
@@ -0,0 +1,14 @@
+// Add CustomEvent to IE9 and IE10
+if (typeof CustomEvent !== 'function') {
+ // Code from: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
+ function CustomEvent (event, options) {
+ options = options || { bubbles: false, cancelable: false, detail: undefined }
+ var e = document.createEvent('CustomEvent')
+ e.initCustomEvent(event, options.bubbles, options.cancelable, options.detail)
+ return e
+ }
+
+ CustomEvent.prototype = window.Event.prototype
+
+ window.CustomEvent = CustomEvent
+} \ No newline at end of file
diff --git a/src/rbox.js b/src/rbox.js
index 54e08cb..2fc093b 100755
--- a/src/rbox.js
+++ b/src/rbox.js
@@ -47,8 +47,8 @@ SVG.RBox = function(element) {
this.height = box.height /= zoom
/* offset by window scroll position, because getBoundingClientRect changes when window is scrolled */
- this.x += window.scrollX;
- this.y += window.scrollY;
+ this.x += typeof window.scrollX === 'number' ? window.scrollX : window.pageXOffset
+ this.y += typeof window.scrollY === 'number' ? window.scrollY : window.pageYOffset
/* add center, right and bottom */
boxProperties(this)