From 4fc10cbae9e66ec7e21b3e36deb102224709f364 Mon Sep 17 00:00:00 2001 From: PoziWorld Date: Mon, 22 Sep 2014 15:23:06 -0700 Subject: Grammatical error: a SVG => an SVG --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8066600..a332cc5 100755 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ See [svgjs.com](http://svgjs.com) for an introduction, [documentation](http://do ## Usage -### Create a SVG document +### Create an SVG document -Use the `SVG()` function to create a SVG document within a given html element: +Use the `SVG()` function to create an SVG document within a given html element: ```javascript var draw = SVG('drawing').size(300, 300) @@ -2824,7 +2824,7 @@ The dynamic representation: ] ``` -Precompiling it as a `SVG.PointArray`: +Precompiling it as an `SVG.PointArray`: ```javascript new SVG.PointArray([ @@ -2858,7 +2858,7 @@ The dynamic representation: ] ``` -Precompiling it as a `SVG.PathArray`: +Precompiling it as an `SVG.PathArray`: ```javascript new SVG.PathArray([ @@ -3108,7 +3108,7 @@ SVG.extend(SVG.Ellipse, SVG.Path, SVG.Polygon, { Here are a few nice plugins that are available for svg.js: ### absorb -[svg.absorb.js](https://github.com/wout/svg.absorb.js) absorb raw SVG data into a svg.js instance. +[svg.absorb.js](https://github.com/wout/svg.absorb.js) absorb raw SVG data into an svg.js instance. ### draggable [svg.draggable.js](https://github.com/wout/svg.draggable.js) to make elements draggable. -- cgit v1.2.3 From c3eb2591d2d5e3523c8e04ce263fcf55b31c861c Mon Sep 17 00:00:00 2001 From: sebastian krämer Date: Mon, 13 Oct 2014 10:27:06 +0200 Subject: add missing add in function params --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8066600..99832ab 100755 --- a/README.md +++ b/README.md @@ -2395,7 +2395,7 @@ path.marker('end', 20, 20, function(add) { The `marker()` method can be used in three ways. Firstly, a marker can be created on any container element (e.g. svg, nested, group, ...). This is useful if you plan to reuse the marker many times so it will create a marker in the defs but not show it yet: ```javascript -var marker = draw.marker(10, 10, function() { +var marker = draw.marker(10, 10, function(add) { add.rect(10, 10) }) ``` @@ -2403,7 +2403,7 @@ var marker = draw.marker(10, 10, function() { Secondly a marker can be created and applied directly on its target element: ```javascript -path.marker('start', 10, 10, function() { +path.marker('start', 10, 10, function(add) { add.circle(10).fill('#f06') }) ``` -- cgit v1.2.3 From c4ca1932dc593abe919219c0eb91c8bfea5646af Mon Sep 17 00:00:00 2001 From: Mason Stewart Date: Sun, 9 Nov 2014 11:09:40 -0500 Subject: Added missing `.bbox()` calls to merge example Hey there. I may be misunderstanding, so feel free to dismiss this, but the `merge` method example for `BBox` wasn't working. I looked at the source for a few minutes, and realized that the first two lines in the example were missing a call to `bbox`, since `merge` belongs to `BBox` instances, not `Rect` instances. Thanks for making such a great lib. Really enjoying it so far :sparkles: --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8066600..9f016be 100755 --- a/README.md +++ b/README.md @@ -1450,8 +1450,8 @@ As opposed to the native `getBBox()` method any translations used with the `tran The `SVG.BBox` has one other nifty little feature, enter the `merge()` method. With `merge()` two `SVG.BBox` instances can be merged into one new instance, basically being the bounding box of the two original bounding boxes: ```javascript -var box1 = draw.rect(100,100).move(50,50) -var box2 = draw.rect(100,100).move(200,200) +var box1 = draw.rect(100,100).move(50,50).bbox() +var box2 = draw.rect(100,100).move(200,200).bbox() var box3 = box1.merge(box2) ``` -- cgit v1.2.3 From cb0b0149a3c2fe84781de1689be6df9d21cf841a Mon Sep 17 00:00:00 2001 From: Gianluca Casati Date: Wed, 12 Nov 2014 18:40:56 +0100 Subject: Fixed npm warning about "repositories" property After adding *svg.js* as a dependency ``` $ npm install svg.js --save svg.js@1.0.1 node_modules/svg.js ``` when I update deps I get a warning ``` $ npm install npm WARN package.json svg.js@1.0.1 'repositories' (plural) Not supported. npm WARN package.json Please pick one as the 'repository' field svg.js@1.0.1 node_modules/svg.js ``` --- package.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 6d586f1..35f22e0 100755 --- a/package.json +++ b/package.json @@ -27,11 +27,9 @@ , "url": "http://www.opensource.org/licenses/mit-license.php" } ] -, "repositories": [ - { - "type": "git" - , "url": "https://github.com/wout/svg.js.git" - } - ] +, "repository": { + "type": "git" + , "url": "https://github.com/wout/svg.js.git" + } , "github": "https://github.com/wout/svg.js" } -- cgit v1.2.3 From d1c7202aad3ad422a6c0d7f0cac00ce4a1cd9bf5 Mon Sep 17 00:00:00 2001 From: Andres Kalle Date: Fri, 26 Dec 2014 01:03:52 +0200 Subject: Gave example variables less confusing names --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8066600..7a8be57 100755 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ _Javascript inheritance stack: `SVG.Ellipse` < `SVG.Shape` < `SVG.Element`_ Ellipses can also be redefined by their radii: ```javascript -rect.radius(75, 50) +ellipse.radius(75, 50) ``` __`returns`: `itself`__ @@ -243,7 +243,7 @@ _Note that this generates an `` element instead of a ``. This c Circles can also be redefined by their radius: ```javascript -rect.radius(75) +circle.radius(75) ``` __`returns`: `itself`__ -- cgit v1.2.3 From 58ddd89d079ab7d2ab4cd62c1c7c0cc720677063 Mon Sep 17 00:00:00 2001 From: Andres Kalle Date: Fri, 26 Dec 2014 02:07:56 +0200 Subject: Fixed function usage in example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8066600..ba3db32 100755 --- a/README.md +++ b/README.md @@ -377,7 +377,7 @@ _Javascript inheritance stack: `SVG.Image` < `SVG.Shape` < `SVG.Element`_ Loading another image can be done with the `load()` method: ```javascript -draw.image('/path/to/another/image.jpg') +image.load('/path/to/another/image.jpg') ``` __`returns`: `itself`__ -- cgit v1.2.3 From 382786ef574c5e320c10ba12c7424fde816917ef Mon Sep 17 00:00:00 2001 From: Andres Kalle Date: Fri, 26 Dec 2014 20:05:01 +0200 Subject: Various typo and error fixes --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8066600..eef0897 100755 --- a/README.md +++ b/README.md @@ -1249,7 +1249,7 @@ Set the size of an element by a given `width` and `height`: rect.size(200, 300) ``` -Proporional resizing is also possible by leaving out `height`: +Proportional resizing is also possible by leaving out `height`: ```javascript rect.size(200) @@ -1490,7 +1490,7 @@ var length = path.length() __`returns`: `number`__ ### pointAt() -Get get point on a path at given length: +Get point on a path at given length: ```javascript var point = path.pointAt(105) //-> returns { x : 96.88497924804688, y : 58.062747955322266 } @@ -1524,7 +1524,7 @@ If you include the sugar.js module, `fill()`, `stroke()`, `rotate()`, `skew()`, rect.animate().rotate(45).skew(25, 0) ``` -You can also animate non-numeric unit values unsing the `attr()` method: +You can also animate non-numeric unit values using the `attr()` method: ```javascript rect.attr('x', '10%').animate().attr('x', '50%') ``` @@ -2587,7 +2587,7 @@ Removing it is quite as easy: rect.click(null) ``` -All available evenets are: `click`, `dblclick`, `mousedown`, `mouseup`, `mouseover`, `mouseout`, `mousemove`, `touchstart`, `touchmove`, `touchleave`, `touchend` and `touchcancel`. +All available events are: `click`, `dblclick`, `mousedown`, `mouseup`, `mouseover`, `mouseout`, `mousemove`, `touchstart`, `touchmove`, `touchleave`, `touchend` and `touchcancel`. __`returns`: `itself`__ @@ -3046,19 +3046,19 @@ var rounded = draw.rounded(200, 100) That's it, the invention is now ready to be used! #### Accepted values -The `SVG.invent()` function always expectes an object. The object can have the following configuration values: +The `SVG.invent()` function always expects an object. The object can have the following configuration values: - `create`: can be either a string with the node name (e.g. `rect`, `ellipse`, ...) or a custom initializer function; `[required]` - `inherit`: the desired svg.js class to inherit from (e.g. `SVG.Shape`, `SVG.Element`, `SVG.Container`, `SVG.Rect`, ...); `[optional but recommended]` - `extend`: an object with the methods that should be applied to the element's prototype; `[optional]` -- `construct`: an objects with the methods to create the element on the parent element; `[optional]` +- `construct`: an object with the methods to create the element on the parent element; `[optional]` - `parent`: an svg.js parent class on which the methods in the passed `construct` object should be available; `[optional]` Svg.js uses the `SVG.invent()` function to create all internal elements, so have a look at the source to see how this function is used in various ways. ### SVG.extend() -Svg.js has a modular structure. It is very easy to add you own methods at different levels. Let's say we want to add a method to all shape types then we would add our method to SVG.Shape: +Svg.js has a modular structure. It is very easy to add your own methods at different levels. Let's say we want to add a method to all shape types then we would add our method to SVG.Shape: ```javascript SVG.extend(SVG.Shape, { -- cgit v1.2.3 From aebdf519cd91d1dc36bed1e847eab15d12d41ad3 Mon Sep 17 00:00:00 2001 From: Ionică Bizău Date: Sun, 28 Dec 2014 11:32:21 +0200 Subject: Added connectable plugin. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8066600..3a3269e 100755 --- a/README.md +++ b/README.md @@ -3113,6 +3113,9 @@ Here are a few nice plugins that are available for svg.js: ### draggable [svg.draggable.js](https://github.com/wout/svg.draggable.js) to make elements draggable. +### connectable +[svg.connectable.js](https://github.com/jillix/svg.connectable.js) to connect elements. + ### easing [svg.easing.js](https://github.com/wout/svg.easing.js) for more easing methods on animations. -- cgit v1.2.3 From 79b0bf36d753ff99adac3d0926b31be8e5ed11c2 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sat, 17 Jan 2015 23:38:54 -0800 Subject: Remove nested AMD/exports loader Fixes Mismatched anonymous define() module: error in requirejs --- Rakefile | 2 +- dist/svg.js | 7 +------ dist/svg.min.js | 5 ++--- src/loader.js | 6 ------ 4 files changed, 4 insertions(+), 16 deletions(-) delete mode 100755 src/loader.js diff --git a/Rakefile b/Rakefile index a312d9d..519c3b2 100755 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ SVGJS_VERSION = '1.0.1' # all available modules in the correct loading order -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 ] +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 helpers ] # how many bytes in a "kilobyte" KILO = 1024 diff --git a/dist/svg.js b/dist/svg.js index 5e77b72..7780cda 100755 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js 1.0.1-3-g6b0c1d2 - 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 */ +/* svg.js 1.0.1-4-g7984a87 - 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 helpers - svgjs.com/license */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(factory); @@ -3752,11 +3752,6 @@ }) - if (typeof define === 'function' && define.amd) - define(function() { return SVG }) - else if (typeof exports !== 'undefined') - exports.SVG = SVG - function camelCase(s) { return s.toLowerCase().replace(/-(.)/g, function(m, g) { return g.toUpperCase() diff --git a/dist/svg.min.js b/dist/svg.min.js index c41ce86..1c8c2a9 100755 --- a/dist/svg.min.js +++ b/dist/svg.min.js @@ -1,3 +1,2 @@ -/* svg.js 1.0.1-3-g6b0c1d2 - 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=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=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;ni/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;in.x&&t>n.y&&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=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")=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-1&&this.members.splice(t,1),this},each:function(e){for(var t=0,n=this.members.length;t=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=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 +!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),l.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]+$/},l.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}}},l.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?l.regex.isRgb.test(t)?(e=l.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):l.regex.isHex.test(t)&&(e=l.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},l.extend(l.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(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 l.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,x=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(u=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(l.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=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):requestAnimFrame(u.render)}else requestAnimFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.events={},l.listeners={},l.registerEvent=function(e){l.events[e]||(l.events[e]=new t(e))},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(t,e){return l.events[t].detail=e,this.node.dispatchEvent(l.events[t]),delete l.events[t].detail,this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return"radial"==this.type?this.attr({fx:new l.Number(t),fy:new l.Number(e)}):this.attr({x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return"radial"==this.type?this.attr({cx:new l.Number(t),cy:new l.Number(e)}):this.attr({x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e); +return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.registerEvent("rebuild"),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),l}); \ No newline at end of file diff --git a/src/loader.js b/src/loader.js deleted file mode 100755 index 80644d8..0000000 --- a/src/loader.js +++ /dev/null @@ -1,6 +0,0 @@ - -// Use AMD or CommonJS if either is present -if (typeof define === 'function' && define.amd) - define(function() { return SVG }) -else if (typeof exports !== 'undefined') - exports.SVG = SVG \ No newline at end of file -- cgit v1.2.3 From 4b2e055187f2f33d14f9e7573ce34b9333b553a3 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sun, 22 Feb 2015 14:27:45 +0100 Subject: Fixed Custom Events with data #317 Keeps the `registerEvent`-function only for consistency --- README.md | 10 ++-------- dist/svg.js | 22 +++++----------------- dist/svg.min.js | 4 ++-- spec/spec/event.js | 18 ++++++++++++++---- src/event.js | 17 ++++------------- src/text.js | 3 --- 6 files changed, 27 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 9557c35..698a0ab 100755 --- a/README.md +++ b/README.md @@ -2625,15 +2625,9 @@ SVG.off(window, 'click', click) ``` ### Custom events -You can even create your own events. +You can even use your own events. -The only thing you need to do is register your own event: - -```javascript -SVG.registerEvent('my:event') -``` - -Next you can add an event listener for your newly created event: +Just add an event listener for your event: ```javascript rect.on('my:event', function() { alert('ta-da!') diff --git a/dist/svg.js b/dist/svg.js index 7780cda..8da0454 100755 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js 1.0.1-4-g7984a87 - 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 helpers - svgjs.com/license */ +/* svg.js 1.0.1-20-g6bb7b47 - 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 helpers - svgjs.com/license */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(factory); @@ -2058,15 +2058,11 @@ }) - // Initialize events and listeners stack - SVG.events = {} + // Initialize listeners stack SVG.listeners = {} - // Event constructor - SVG.registerEvent = function(event) { - if (!SVG.events[event]) - SVG.events[event] = new CustomEvent(event) - } + // Only kept for consistency of API + SVG.registerEvent = function(){}; // Add event binder in the SVG namespace SVG.on = function(node, event, listener) { @@ -2131,14 +2127,9 @@ } // Fire given 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 + this.node.dispatchEvent(new CustomEvent(event, {detail:data})) return this } @@ -3230,9 +3221,6 @@ return this.node.getComputedTextLength() } }) - - // Register rebuild event - SVG.registerEvent('rebuild') SVG.TextPath = SVG.invent({ diff --git a/dist/svg.min.js b/dist/svg.min.js index 1c8c2a9..3395bde 100755 --- a/dist/svg.min.js +++ b/dist/svg.min.js @@ -1,2 +1,2 @@ -!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),l.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]+$/},l.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}}},l.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?l.regex.isRgb.test(t)?(e=l.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):l.regex.isHex.test(t)&&(e=l.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},l.extend(l.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(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 l.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,x=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(u=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(l.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=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):requestAnimFrame(u.render)}else requestAnimFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.events={},l.listeners={},l.registerEvent=function(e){l.events[e]||(l.events[e]=new t(e))},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(t,e){return l.events[t].detail=e,this.node.dispatchEvent(l.events[t]),delete l.events[t].detail,this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return"radial"==this.type?this.attr({fx:new l.Number(t),fy:new l.Number(e)}):this.attr({x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return"radial"==this.type?this.attr({cx:new l.Number(t),cy:new l.Number(e)}):this.attr({x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e); -return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.registerEvent("rebuild"),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),l}); \ No newline at end of file +!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),l.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]+$/},l.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}}},l.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?l.regex.isRgb.test(t)?(e=l.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):l.regex.isHex.test(t)&&(e=l.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},l.extend(l.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(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 l.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,x=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(u=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(l.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=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):requestAnimFrame(u.render)}else requestAnimFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners={},l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)}) +}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),l}); \ No newline at end of file diff --git a/spec/spec/event.js b/spec/spec/event.js index 45db382..403c795 100644 --- a/spec/spec/event.js +++ b/spec/spec/event.js @@ -1,9 +1,11 @@ describe('Event', function() { var rect, context , toast = null - , action = function() { + , fruitsInDetail, + action = function(e) { toast = 'ready' context = this + fruitsInDetail = e.detail } beforeEach(function() { @@ -287,7 +289,8 @@ describe('Event', function() { }) } - +/* This function is no longer needed and only exists for compatibility issues */ +/* describe('registerEvent()', function() { it('creates a new custom event and stores it in the events object', function() { expect(SVG.events['my:event']).toBeUndefined() @@ -295,7 +298,7 @@ describe('Event', function() { expect(SVG.events['my:event'] instanceof CustomEvent).toBeTruthy() }) }) - +*/ describe('on()', function() { beforeEach(function() { @@ -369,12 +372,19 @@ describe('Event', function() { expect(toast).toBeNull() rect.fire('my:event') expect(toast).toBe('ready') + expect(fruitsInDetail).toBe(null) }) it('returns the called element', function() { expect(rect.fire('my:event')).toBe(rect) }) - + it('fires event with additional data', function() { + expect(fruitsInDetail).toBeNull() + rect.fire('my:event', {apple:1}) + expect(fruitsInDetail).not.toBe(null) + expect(fruitsInDetail.apple).toBe(1) + }) }) + }) diff --git a/src/event.js b/src/event.js index 63764ed..d7a83b2 100755 --- a/src/event.js +++ b/src/event.js @@ -27,15 +27,11 @@ }) -// Initialize events and listeners stack -SVG.events = {} +// Initialize listeners stack SVG.listeners = {} -// Event constructor -SVG.registerEvent = function(event) { - if (!SVG.events[event]) - SVG.events[event] = new CustomEvent(event) -} +// Only kept for consistency of API +SVG.registerEvent = function(){}; // Add event binder in the SVG namespace SVG.on = function(node, event, listener) { @@ -100,14 +96,9 @@ SVG.extend(SVG.Element, { } // Fire given 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 + this.node.dispatchEvent(new CustomEvent(event, {detail:data})) return this } diff --git a/src/text.js b/src/text.js index 1b6bd94..38d4ecc 100755 --- a/src/text.js +++ b/src/text.js @@ -222,6 +222,3 @@ SVG.extend(SVG.Text, SVG.TSpan, { return this.node.getComputedTextLength() } }) - -// Register rebuild event -SVG.registerEvent('rebuild') -- cgit v1.2.3 From 7e47015224e778aa1bac45346665f1854b1ce4dc Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sun, 22 Feb 2015 14:40:39 +0100 Subject: Added example in Readme about passing additional data to events --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 698a0ab..9354932 100755 --- a/README.md +++ b/README.md @@ -2642,6 +2642,18 @@ function whenSomethingHappens() { } ``` +You can also pass some data to the event: + +```javascript +function whenSomethingHappens() { + rect.fire('my:event', {some:'data'}) +} + +rect.on('my:event', function(e) { + alert(e.detail.some) // outputs 'data' +}) +``` + _Important: always make sure you namespace your event to avoid conflicts. Preferably use something very specific. So `wicked:event` for example would be better than something generic like `svg:event`._ ## Numbers -- cgit v1.2.3 From 095b474e110f7ed7f5920ca297607b58ed351128 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sun, 22 Feb 2015 14:58:20 +0100 Subject: Fixed Event-Spec for Chrome --- spec/spec/event.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/spec/event.js b/spec/spec/event.js index 403c795..9f1f0e1 100644 --- a/spec/spec/event.js +++ b/spec/spec/event.js @@ -1,11 +1,11 @@ describe('Event', function() { var rect, context , toast = null - , fruitsInDetail, + , fruitsInDetail = null, action = function(e) { toast = 'ready' context = this - fruitsInDetail = e.detail + fruitsInDetail = e.detail || null } beforeEach(function() { -- cgit v1.2.3 From e5b321e1c49928d5e7fceeeedec7fde91aa5e0f0 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sun, 22 Feb 2015 16:25:37 +0100 Subject: Fixes #326 drawing.remove() now calls destroy() to remove the doc from the DOM --- dist/svg.js | 12 ++++++++++-- dist/svg.min.js | 4 ++-- spec/spec/doc.js | 22 ++++++++++++++++++++++ src/doc.js | 8 ++++++++ src/element.js | 2 +- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/dist/svg.js b/dist/svg.js index 8da0454..12ffe73 100755 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js 1.0.1-20-g6bb7b47 - 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 helpers - svgjs.com/license */ +/* svg.js 1.0.1-23-g095b474 - 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 helpers - svgjs.com/license */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(factory); @@ -1114,7 +1114,7 @@ // Remove element , remove: function() { if (this.parent) - this.parent.removeElement(this) + this.doc() === this ? this.destroy() : this.parent.removeElement(this) return this } @@ -2602,6 +2602,14 @@ return this } + + // Removes the doc from the DOM + , destroy: function() { + this.parent.removeChild(this.node); + this.parent = null; + + return this; + } } }) diff --git a/dist/svg.min.js b/dist/svg.min.js index 3395bde..7829ec6 100755 --- a/dist/svg.min.js +++ b/dist/svg.min.js @@ -1,2 +1,2 @@ -!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),l.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]+$/},l.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}}},l.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?l.regex.isRgb.test(t)?(e=l.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):l.regex.isHex.test(t)&&(e=l.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},l.extend(l.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(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 l.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,x=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(u=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(l.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=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):requestAnimFrame(u.render)}else requestAnimFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners={},l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)}) -}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),l}); \ No newline at end of file +!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),l.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]+$/},l.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}}},l.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?l.regex.isRgb.test(t)?(e=l.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):l.regex.isHex.test(t)&&(e=l.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},l.extend(l.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(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 l.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,x=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(u=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(l.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=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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.doc()===this?this.destroy():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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):requestAnimFrame(u.render)}else requestAnimFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners={},l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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},destroy:function(){return this.parent.removeChild(this.node),this.parent=null,this}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e); +return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),l}); \ No newline at end of file diff --git a/spec/spec/doc.js b/spec/spec/doc.js index 4312678..eabdd02 100755 --- a/spec/spec/doc.js +++ b/spec/spec/doc.js @@ -7,6 +7,10 @@ describe('Doc', function() { it('has a defs element', function() { expect(draw._defs instanceof SVG.Defs).toBe(true) }) + + it('has itself as doc', function() { + expect(draw.doc()).toBe(draw); + }) describe('defs()', function() { it('returns defs element', function(){ @@ -17,4 +21,22 @@ describe('Doc', function() { }) }) + describe('remove() / destroy()', function() { + it('removes the doc from the dom (remove)', function() { + draw.remove() + expect(draw.parent).toBeNull() + expect(document.getElementsByTagName('body')[0].querySelectorAll('svg').length).toBe(1) + draw = SVG(drawing).size(100,100); + expect(document.getElementsByTagName('body')[0].querySelectorAll('svg').length).toBe(2) + }) + + it('removes the doc from the dom (remove)', function() { + draw.destroy() + expect(draw.parent).toBeNull() + expect(document.getElementsByTagName('body')[0].querySelectorAll('svg').length).toBe(1) + draw = SVG(drawing).size(100,100); + expect(document.getElementsByTagName('body')[0].querySelectorAll('svg').length).toBe(2) + }) + }) + }) \ No newline at end of file diff --git a/src/doc.js b/src/doc.js index a10bffe..a2c756b 100755 --- a/src/doc.js +++ b/src/doc.js @@ -78,6 +78,14 @@ SVG.Doc = SVG.invent({ return this } + + // Removes the doc from the DOM + , destroy: function() { + this.parent.removeChild(this.node); + this.parent = null; + + return this; + } } }) diff --git a/src/element.js b/src/element.js index 8c4166d..438f5a9 100755 --- a/src/element.js +++ b/src/element.js @@ -101,7 +101,7 @@ SVG.Element = SVG.invent({ // Remove element , remove: function() { if (this.parent) - this.parent.removeElement(this) + this.doc() === this ? this.destroy() : this.parent.removeElement(this) return this } -- cgit v1.2.3 From a4ad42e9fb0a9fd63a6e609083729f3060634462 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Mon, 23 Feb 2015 11:47:09 +0100 Subject: Rework of `drawing.remove()` --- dist/svg.js | 12 +++++++----- dist/svg.min.js | 2 +- spec/spec/doc.js | 12 ++---------- src/doc.js | 8 +++++--- src/element.js | 2 +- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/dist/svg.js b/dist/svg.js index 12ffe73..0c02421 100755 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js 1.0.1-23-g095b474 - 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 helpers - svgjs.com/license */ +/* svg.js 1.0.1-26-g2ecbacb - 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 helpers - svgjs.com/license */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(factory); @@ -1114,7 +1114,7 @@ // Remove element , remove: function() { if (this.parent) - this.doc() === this ? this.destroy() : this.parent.removeElement(this) + this.parent.removeElement(this) return this } @@ -2604,9 +2604,11 @@ } // Removes the doc from the DOM - , destroy: function() { - this.parent.removeChild(this.node); - this.parent = null; + , remove: function() { + if(this.parent) { + this.parent.removeChild(this.node); + this.parent = null; + } return this; } diff --git a/dist/svg.min.js b/dist/svg.min.js index 7829ec6..3c8d1e7 100755 --- a/dist/svg.min.js +++ b/dist/svg.min.js @@ -1,2 +1,2 @@ -!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),l.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]+$/},l.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}}},l.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?l.regex.isRgb.test(t)?(e=l.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):l.regex.isHex.test(t)&&(e=l.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},l.extend(l.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(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 l.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,x=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(u=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(l.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=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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.doc()===this?this.destroy():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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):requestAnimFrame(u.render)}else requestAnimFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners={},l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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},destroy:function(){return this.parent.removeChild(this.node),this.parent=null,this}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e); +!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),l.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]+$/},l.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}}},l.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?l.regex.isRgb.test(t)?(e=l.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):l.regex.isHex.test(t)&&(e=l.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},l.extend(l.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(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 l.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,x=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(u=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(l.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=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):requestAnimFrame(u.render)}else requestAnimFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners={},l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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},remove:function(){return this.parent&&(this.parent.removeChild(this.node),this.parent=null),this}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e); return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),l}); \ No newline at end of file diff --git a/spec/spec/doc.js b/spec/spec/doc.js index eabdd02..beedff7 100755 --- a/spec/spec/doc.js +++ b/spec/spec/doc.js @@ -21,22 +21,14 @@ describe('Doc', function() { }) }) - describe('remove() / destroy()', function() { - it('removes the doc from the dom (remove)', function() { + describe('remove()', function() { + it('removes the doc from the dom', function() { draw.remove() expect(draw.parent).toBeNull() expect(document.getElementsByTagName('body')[0].querySelectorAll('svg').length).toBe(1) draw = SVG(drawing).size(100,100); expect(document.getElementsByTagName('body')[0].querySelectorAll('svg').length).toBe(2) }) - - it('removes the doc from the dom (remove)', function() { - draw.destroy() - expect(draw.parent).toBeNull() - expect(document.getElementsByTagName('body')[0].querySelectorAll('svg').length).toBe(1) - draw = SVG(drawing).size(100,100); - expect(document.getElementsByTagName('body')[0].querySelectorAll('svg').length).toBe(2) - }) }) }) \ No newline at end of file diff --git a/src/doc.js b/src/doc.js index a2c756b..820a8cd 100755 --- a/src/doc.js +++ b/src/doc.js @@ -80,9 +80,11 @@ SVG.Doc = SVG.invent({ } // Removes the doc from the DOM - , destroy: function() { - this.parent.removeChild(this.node); - this.parent = null; + , remove: function() { + if(this.parent) { + this.parent.removeChild(this.node); + this.parent = null; + } return this; } diff --git a/src/element.js b/src/element.js index 438f5a9..8c4166d 100755 --- a/src/element.js +++ b/src/element.js @@ -101,7 +101,7 @@ SVG.Element = SVG.invent({ // Remove element , remove: function() { if (this.parent) - this.doc() === this ? this.destroy() : this.parent.removeElement(this) + this.parent.removeElement(this) return this } -- cgit v1.2.3 From 2f887f54a69032f5494273b4e1d9889311965da2 Mon Sep 17 00:00:00 2001 From: Balint Morvai Date: Mon, 23 Feb 2015 17:51:32 +0100 Subject: Added comic.js to plugins section in README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 704d187..92ba3de 100755 --- a/README.md +++ b/README.md @@ -3149,6 +3149,9 @@ Here are a few nice plugins that are available for svg.js: ### topath [svg.topath.js](https://github.com/wout/svg.topath.js) to convert any other shape to a path. +### comic +[comic.js](https://github.com/balint42/comic.js) to cartoonize any given svg. + ## Contributing All contributions are very welcome but please make sure you: -- cgit v1.2.3 From 2fc54cb89bef303efa9be3dfcd26ff10921deb04 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sat, 28 Feb 2015 20:56:40 +0100 Subject: Added `cancelAnimationFrame`-Polyfill, fixes #316 --- dist/svg.js | 45 +++++++++++++++++++++++++++++++++------------ dist/svg.min.js | 4 ++-- src/fx.js | 5 +++-- src/helpers.js | 9 --------- src/polyfill.js | 30 +++++++++++++++++++++++++++++- 5 files changed, 67 insertions(+), 26 deletions(-) diff --git a/dist/svg.js b/dist/svg.js index 0c02421..ca49e9e 100755 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js 1.0.1-26-g2ecbacb - 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 helpers - svgjs.com/license */ +/* svg.js 1.0.1-29-g02e88d9 - 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 helpers - svgjs.com/license */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(factory); @@ -133,6 +133,34 @@ window.CustomEvent = CustomEvent } + + // requestAnimationFrame / cancelAnimationFrame Polyfill with fallback based on Paul Irish + (function(w) { + var lastTime = 0 + var vendors = ['moz', 'webkit'] + + for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { + w.requestAnimationFrame = w[vendors[x] + 'RequestAnimationFrame'] + w.cancelAnimationFrame = w[vendors[x] + 'CancelAnimationFrame'] || + w[vendors[x] + 'CancelRequestAnimationFrame'] + } + + w.requestAnimationFrame = w.requestAnimationFrame || + function(callback) { + var currTime = new Date().getTime() + var timeToCall = Math.max(0, 16 - (currTime - lastTime)) + + var id = w.setTimeout(function() { + callback(currTime + timeToCall) + }, timeToCall) + + lastTime = currTime + timeToCall + return id + } + + w.cancelAnimationFrame = w.cancelAnimationFrame || w.clearTimeout; + + }(window)) SVG.regex = { /* parse unit value */ @@ -1741,10 +1769,10 @@ } } else { - requestAnimFrame(fx.render) + fx.animationFrame = requestAnimationFrame(fx.render) } } else { - requestAnimFrame(fx.render) + fx.animationFrame = requestAnimationFrame(fx.render) } } @@ -1932,6 +1960,7 @@ } else { /* stop current animation */ clearTimeout(this.timeout) + cancelAnimationFrame(this.animationFrame); /* reset storage for properties that need animation */ this.attrs = {} @@ -3871,15 +3900,7 @@ if (m) return m[1] } - - // Shim layer with setTimeout fallback by Paul Irish - window.requestAnimFrame = (function(){ - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.msRequestAnimationFrame || - function (c) { window.setTimeout(c, 1000 / 60) } - })() + return SVG })); diff --git a/dist/svg.min.js b/dist/svg.min.js index 3c8d1e7..1b7318e 100755 --- a/dist/svg.min.js +++ b/dist/svg.min.js @@ -1,2 +1,2 @@ -!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),l.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]+$/},l.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}}},l.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?l.regex.isRgb.test(t)?(e=l.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):l.regex.isHex.test(t)&&(e=l.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},l.extend(l.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(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 l.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,x=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(u=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(l.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=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):requestAnimFrame(u.render)}else requestAnimFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners={},l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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},remove:function(){return this.parent&&(this.parent.removeChild(this.node),this.parent=null),this}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e); -return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),l}); \ No newline at end of file +!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),function(t){for(var e=0,i=["moz","webkit"],n=0;nt?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,m=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(m=f.y)):("x1"in f&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=m+f.y1),"y2"in f&&(u=m+f.y2),"x"in f&&(p+=f.x),"y"in f&&(m+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,m),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,m),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(m),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,m,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,m,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,m,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,m),e):"a"==c?d.replaceItem(l.parser.path.createSVGPathSegArcAbs(p,m,f.r1,f.r2,f.angle,f.largeArcFlag,f.sweepFlag),e):("z"==c||"Z"==c)&&(p=n,m=r)),("M"==c||"m"==c)&&(n=p,r=m);for(t=[],d=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):u.animationFrame=requestAnimationFrame(u.render)}else u.animationFrame=requestAnimationFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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),cancelAnimationFrame(this.animationFrame),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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners={},l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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},remove:function(){return this.parent&&(this.parent.removeChild(this.node),this.parent=null),this}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),l}); \ No newline at end of file diff --git a/src/fx.js b/src/fx.js index 2b983c3..b723235 100755 --- a/src/fx.js +++ b/src/fx.js @@ -186,10 +186,10 @@ SVG.FX = SVG.invent({ } } else { - requestAnimFrame(fx.render) + fx.animationFrame = requestAnimationFrame(fx.render) } } else { - requestAnimFrame(fx.render) + fx.animationFrame = requestAnimationFrame(fx.render) } } @@ -377,6 +377,7 @@ SVG.FX = SVG.invent({ } else { /* stop current animation */ clearTimeout(this.timeout) + cancelAnimationFrame(this.animationFrame); /* reset storage for properties that need animation */ this.attrs = {} diff --git a/src/helpers.js b/src/helpers.js index c63c215..f3f8f26 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -120,12 +120,3 @@ function idFromReference(url) { if (m) return m[1] } - -// Shim layer with setTimeout fallback by Paul Irish -window.requestAnimFrame = (function(){ - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.msRequestAnimationFrame || - function (c) { window.setTimeout(c, 1000 / 60) } -})() \ No newline at end of file diff --git a/src/polyfill.js b/src/polyfill.js index 3a3c25c..a913337 100644 --- a/src/polyfill.js +++ b/src/polyfill.js @@ -11,4 +11,32 @@ if (typeof CustomEvent !== 'function') { CustomEvent.prototype = window.Event.prototype window.CustomEvent = CustomEvent -} \ No newline at end of file +} + +// requestAnimationFrame / cancelAnimationFrame Polyfill with fallback based on Paul Irish +(function(w) { + var lastTime = 0 + var vendors = ['moz', 'webkit'] + + for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { + w.requestAnimationFrame = w[vendors[x] + 'RequestAnimationFrame'] + w.cancelAnimationFrame = w[vendors[x] + 'CancelAnimationFrame'] || + w[vendors[x] + 'CancelRequestAnimationFrame'] + } + + w.requestAnimationFrame = w.requestAnimationFrame || + function(callback) { + var currTime = new Date().getTime() + var timeToCall = Math.max(0, 16 - (currTime - lastTime)) + + var id = w.setTimeout(function() { + callback(currTime + timeToCall) + }, timeToCall) + + lastTime = currTime + timeToCall + return id + } + + w.cancelAnimationFrame = w.cancelAnimationFrame || w.clearTimeout; + +}(window)) \ No newline at end of file -- cgit v1.2.3 From 2eff42ea62f1ff8301000b49eae54cc8c370ee66 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sun, 1 Mar 2015 00:09:17 +0100 Subject: Fixes #323 --- dist/svg.js | 40 ++++++++++++++++++++++------------------ dist/svg.min.js | 2 +- spec/spec/event.js | 42 +++++++++++++++++++++++++++++++++++++----- src/event.js | 38 +++++++++++++++++++++----------------- 4 files changed, 81 insertions(+), 41 deletions(-) diff --git a/dist/svg.js b/dist/svg.js index ca49e9e..7fa09c0 100755 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js 1.0.1-29-g02e88d9 - 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 helpers - svgjs.com/license */ +/* svg.js 1.0.1-30-g2fc54cb - 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 helpers - svgjs.com/license */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(factory); @@ -2088,22 +2088,24 @@ }) // Initialize listeners stack - SVG.listeners = {} + SVG.listeners = [] + SVG.handlerMap = [] // Only kept for consistency of API SVG.registerEvent = function(){}; // Add event binder in the SVG namespace SVG.on = function(node, event, listener) { - // create listener - var l = listener.bind(node.instance || node) - - // ensure reference objects - SVG.listeners[node] = SVG.listeners[node] || {} - SVG.listeners[node][event] = SVG.listeners[node][event] || {} + // create listener, get object-index + var l = listener.bind(node.instance || node) + , index = (SVG.handlerMap.indexOf(node) + 1 || SVG.handlerMap.push(node)) - 1 + + // ensure valid object + SVG.listeners[index] = SVG.listeners[index] || {} + SVG.listeners[index][event] = SVG.listeners[index][event] || {} // reference listener - SVG.listeners[node][event][listener] = l + SVG.listeners[index][event][listener] = l // add listener node.addEventListener(event, l, false) @@ -2111,31 +2113,33 @@ // Add event unbinder in the SVG namespace SVG.off = function(node, event, listener) { + var index = SVG.handlerMap.indexOf(node) + if (listener) { // remove listener reference - if (SVG.listeners[node] && SVG.listeners[node][event]) { + if (index != -1 && SVG.listeners[index][event]) { // remove listener - node.removeEventListener(event, SVG.listeners[node][event][listener], false) + node.removeEventListener(event, SVG.listeners[index][event][listener], false) - delete SVG.listeners[node][event][listener] + delete SVG.listeners[index][event][listener] } } else if (event) { // remove all listeners for the event - if (SVG.listeners[node][event]) { - for (listener in SVG.listeners[node][event]) + if (SVG.listeners[index][event]) { + for (listener in SVG.listeners[index][event]) SVG.off(node, event, listener) - delete SVG.listeners[node][event] + delete SVG.listeners[index][event] } } else { // remove all listeners on a given node - if (SVG.listeners[node]) { - for (event in SVG.listeners[node]) + if (index != -1) { + for (event in SVG.listeners[index]) SVG.off(node, event) - delete SVG.listeners[node] + delete SVG.listeners[index] } } } diff --git a/dist/svg.min.js b/dist/svg.min.js index 1b7318e..d30757e 100755 --- a/dist/svg.min.js +++ b/dist/svg.min.js @@ -1,2 +1,2 @@ -!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),function(t){for(var e=0,i=["moz","webkit"],n=0;nt?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,m=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(m=f.y)):("x1"in f&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=m+f.y1),"y2"in f&&(u=m+f.y2),"x"in f&&(p+=f.x),"y"in f&&(m+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,m),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,m),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(m),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,m,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,m,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,m,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,m),e):"a"==c?d.replaceItem(l.parser.path.createSVGPathSegArcAbs(p,m,f.r1,f.r2,f.angle,f.largeArcFlag,f.sweepFlag),e):("z"==c||"Z"==c)&&(p=n,m=r)),("M"==c||"m"==c)&&(n=p,r=m);for(t=[],d=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):u.animationFrame=requestAnimationFrame(u.render)}else u.animationFrame=requestAnimationFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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),cancelAnimationFrame(this.animationFrame),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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners={},l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t);l.listeners[t]=l.listeners[t]||{},l.listeners[t][e]=l.listeners[t][e]||{},l.listeners[t][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){if(i)l.listeners[t]&&l.listeners[t][e]&&(t.removeEventListener(e,l.listeners[t][e][i],!1),delete l.listeners[t][e][i]);else if(e){if(l.listeners[t][e]){for(i in l.listeners[t][e])l.off(t,e,i);delete l.listeners[t][e]}}else if(l.listeners[t]){for(e in l.listeners[t])l.off(t,e);delete l.listeners[t]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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},remove:function(){return this.parent&&(this.parent.removeChild(this.node),this.parent=null),this}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.Shape,extend:{x:function(t){return null==t?this.cx()-this.attr("rx"):this.cx(t+this.attr("rx")) +!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),function(t){for(var e=0,i=["moz","webkit"],n=0;nt?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,m=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(m=f.y)):("x1"in f&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=m+f.y1),"y2"in f&&(u=m+f.y2),"x"in f&&(p+=f.x),"y"in f&&(m+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,m),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,m),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(m),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,m,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,m,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,m,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,m),e):"a"==c?d.replaceItem(l.parser.path.createSVGPathSegArcAbs(p,m,f.r1,f.r2,f.angle,f.largeArcFlag,f.sweepFlag),e):("z"==c||"Z"==c)&&(p=n,m=r)),("M"==c||"m"==c)&&(n=p,r=m);for(t=[],d=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):u.animationFrame=requestAnimationFrame(u.render)}else u.animationFrame=requestAnimationFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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),cancelAnimationFrame(this.animationFrame),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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners=[],l.handlerMap=[],l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t),r=(l.handlerMap.indexOf(t)+1||l.handlerMap.push(t))-1;l.listeners[r]=l.listeners[r]||{},l.listeners[r][e]=l.listeners[r][e]||{},l.listeners[r][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){var n=l.handlerMap.indexOf(t);if(i)-1!=n&&l.listeners[n][e]&&(t.removeEventListener(e,l.listeners[n][e][i],!1),delete l.listeners[n][e][i]);else if(e){if(l.listeners[n][e]){for(i in l.listeners[n][e])l.off(t,e,i);delete l.listeners[n][e]}}else if(-1!=n){for(e in l.listeners[n])l.off(t,e);delete l.listeners[n]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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},remove:function(){return this.parent&&(this.parent.removeChild(this.node),this.parent=null),this}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),l}); \ No newline at end of file diff --git a/spec/spec/event.js b/spec/spec/event.js index 9f1f0e1..8801130 100644 --- a/spec/spec/event.js +++ b/spec/spec/event.js @@ -309,13 +309,28 @@ describe('Event', function() { dispatchEvent(rect.on('my:event', action), 'my:event') expect(toast).toBe('ready') }) + it('attaches multiple handlers on different element', function() { + var listenerCnt = SVG.listeners.length + + var rect2 = draw.rect(100,100); + var rect3 = draw.rect(100,100); + + rect.on('my:event', action) + rect2.on('my:event', action) + rect3.on('my:event', function(){ butter = 'melting' }) + rect3.on('my:event', action) + + expect(Object.keys(SVG.listeners[SVG.handlerMap.indexOf(rect.node)]['my:event']).length).toBe(1) // 1 listener on rect + expect(Object.keys(SVG.listeners[SVG.handlerMap.indexOf(rect3.node)]['my:event']).length).toBe(2) // 2 listener on rect3 + expect(SVG.listeners.length).toBe(listenerCnt + 3) // added 3 listener + }) 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() + expect(SVG.listeners[SVG.handlerMap.indexOf(rect.node)]['my:event'][action]).not.toBeUndefined() }) it('returns the called element', function() { expect(rect.on('my:event', action)).toBe(rect) @@ -330,21 +345,38 @@ describe('Event', function() { SVG.registerEvent('my:event') }) - it('detaches a specific event listener', function() { + it('detaches a specific event listener, all other still working', function() { + rect2 = draw.rect(100,100); + rect3 = draw.rect(100,100); + rect.on('my:event', action) + rect2.on('my:event', action) + rect3.on('my:event', function(){ butter = 'melting' }) + rect.off('my:event', action) + + expect(Object.keys(SVG.listeners[SVG.handlerMap.indexOf(rect.node)]['my:event']).length).toBe(0) + dispatchEvent(rect, 'my:event') expect(toast).toBeNull() - expect(SVG.listeners[rect.node]['my:event'][action]).toBeUndefined() + + dispatchEvent(rect2, 'my:event') + expect(toast).toBe('ready') + + dispatchEvent(rect3, 'my:event') + expect(butter).toBe('melting') + + expect(SVG.listeners[SVG.handlerMap.indexOf(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() + expect(SVG.listeners[SVG.handlerMap.indexOf(rect.node)]['my:event']).toBeUndefined() }) it('detaches all listeners without an argument', function() { rect.on('my:event', action) @@ -354,7 +386,7 @@ describe('Event', function() { dispatchEvent(rect, 'click') expect(toast).toBeNull() expect(butter).toBeNull() - expect(SVG.listeners[rect.node]).toBeUndefined() + expect(SVG.listeners[SVG.handlerMap.indexOf(rect.node)]).toBeUndefined() }) it('returns the called element', function() { expect(rect.off('my:event', action)).toBe(rect) diff --git a/src/event.js b/src/event.js index d7a83b2..10585bb 100755 --- a/src/event.js +++ b/src/event.js @@ -28,22 +28,24 @@ }) // Initialize listeners stack -SVG.listeners = {} +SVG.listeners = [] +SVG.handlerMap = [] // Only kept for consistency of API SVG.registerEvent = function(){}; // Add event binder in the SVG namespace SVG.on = function(node, event, listener) { - // create listener - var l = listener.bind(node.instance || node) - - // ensure reference objects - SVG.listeners[node] = SVG.listeners[node] || {} - SVG.listeners[node][event] = SVG.listeners[node][event] || {} + // create listener, get object-index + var l = listener.bind(node.instance || node) + , index = (SVG.handlerMap.indexOf(node) + 1 || SVG.handlerMap.push(node)) - 1 + + // ensure valid object + SVG.listeners[index] = SVG.listeners[index] || {} + SVG.listeners[index][event] = SVG.listeners[index][event] || {} // reference listener - SVG.listeners[node][event][listener] = l + SVG.listeners[index][event][listener] = l // add listener node.addEventListener(event, l, false) @@ -51,31 +53,33 @@ SVG.on = function(node, event, listener) { // Add event unbinder in the SVG namespace SVG.off = function(node, event, listener) { + var index = SVG.handlerMap.indexOf(node) + if (listener) { // remove listener reference - if (SVG.listeners[node] && SVG.listeners[node][event]) { + if (index != -1 && SVG.listeners[index][event]) { // remove listener - node.removeEventListener(event, SVG.listeners[node][event][listener], false) + node.removeEventListener(event, SVG.listeners[index][event][listener], false) - delete SVG.listeners[node][event][listener] + delete SVG.listeners[index][event][listener] } } else if (event) { // remove all listeners for the event - if (SVG.listeners[node][event]) { - for (listener in SVG.listeners[node][event]) + if (SVG.listeners[index][event]) { + for (listener in SVG.listeners[index][event]) SVG.off(node, event, listener) - delete SVG.listeners[node][event] + delete SVG.listeners[index][event] } } else { // remove all listeners on a given node - if (SVG.listeners[node]) { - for (event in SVG.listeners[node]) + if (index != -1) { + for (event in SVG.listeners[index]) SVG.off(node, event) - delete SVG.listeners[node] + delete SVG.listeners[index] } } } -- cgit v1.2.3 From cc9a4a372893d948900ce3fe83dd1324b153757d Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Tue, 3 Mar 2015 00:15:45 +0100 Subject: Fixes #258, added few fx-specs --- dist/svg.js | 13 +++++++-- dist/svg.min.js | 4 +-- spec/index.html | 1 + spec/spec/fx.js | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fx.js | 7 +++++ 5 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 spec/spec/fx.js diff --git a/dist/svg.js b/dist/svg.js index 7fa09c0..39155dd 100755 --- a/dist/svg.js +++ b/dist/svg.js @@ -1718,7 +1718,7 @@ /* animate transformations */ for (i = tkeys.length - 1; i >= 0; i--) element.transform(tkeys[i], at(fx.trans[tkeys[i]], pos)) - + /* animate styles */ for (i = skeys.length - 1; i >= 0; i--) element.style(skeys[i], at(fx.styles[skeys[i]], pos)) @@ -1816,15 +1816,24 @@ /* dlete matrixstring from object */ delete o.matrix + /* add rotation-center to transformations */ + this.target.trans.cx = o.cx || null + this.target.trans.cy = o.cy || null + + delete o.cx + delete o.cy + /* store matrix values */ for (v in o) this.trans[v] = { from: this.target.trans[v], to: o[v] } + + } else { /* apply transformations as object if key value arguments are given*/ var transform = {} transform[o] = v - + this.transform(transform) } diff --git a/dist/svg.min.js b/dist/svg.min.js index d30757e..18e25e9 100755 --- a/dist/svg.min.js +++ b/dist/svg.min.js @@ -1,2 +1,2 @@ -!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),function(t){for(var e=0,i=["moz","webkit"],n=0;nt?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,m=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(m=f.y)):("x1"in f&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=m+f.y1),"y2"in f&&(u=m+f.y2),"x"in f&&(p+=f.x),"y"in f&&(m+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,m),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,m),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(m),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,m,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,m,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,m,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,m),e):"a"==c?d.replaceItem(l.parser.path.createSVGPathSegArcAbs(p,m,f.r1,f.r2,f.angle,f.largeArcFlag,f.sweepFlag),e):("z"==c||"Z"==c)&&(p=n,m=r)),("M"==c||"m"==c)&&(n=p,r=m);for(t=[],d=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):u.animationFrame=requestAnimationFrame(u.render)}else u.animationFrame=requestAnimationFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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),cancelAnimationFrame(this.animationFrame),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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners=[],l.handlerMap=[],l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t),r=(l.handlerMap.indexOf(t)+1||l.handlerMap.push(t))-1;l.listeners[r]=l.listeners[r]||{},l.listeners[r][e]=l.listeners[r][e]||{},l.listeners[r][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){var n=l.handlerMap.indexOf(t);if(i)-1!=n&&l.listeners[n][e]&&(t.removeEventListener(e,l.listeners[n][e][i],!1),delete l.listeners[n][e][i]);else if(e){if(l.listeners[n][e]){for(i in l.listeners[n][e])l.off(t,e,i);delete l.listeners[n][e]}}else if(-1!=n){for(e in l.listeners[n])l.off(t,e);delete l.listeners[n]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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},remove:function(){return this.parent&&(this.parent.removeChild(this.node),this.parent=null),this}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),l}); \ No newline at end of file +!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(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 n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(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 s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(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 o(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 a(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 u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.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];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),function(t){for(var e=0,i=["moz","webkit"],n=0;nt?0:t>1?1:t,new l.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}}),l.Color.test=function(t){return t+="",l.regex.isHex.test(t)||l.regex.isRgb.test(t)},l.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},l.Color.isColor=function(t){return l.Color.isRgb(t)||l.Color.test(t)},l.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},l.extend(l.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.lengtht;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 l.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}}),l.PointArray=function(){this.constructor.apply(this,arguments)},l.PointArray.prototype=new l.Array,l.extend(l.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 l.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 l.parser.poly.setAttribute("points",this.toString()),l.parser.poly.getBBox()}}),l.PathArray=function(t,e){this.constructor.call(this,t,e)},l.PathArray.prototype=new l.Array,l.extend(l.PathArray,{toString:function(){return h(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 l.PathArray)return t.valueOf();var e,i,n,r,s,o,a,u,c,f,d,p=0,m=0;for(l.parser.path.setAttribute("d","string"==typeof t?t:h(t)),d=l.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&&(m=f.y)):("x1"in f&&(s=p+f.x1),"x2"in f&&(a=p+f.x2),"y1"in f&&(o=m+f.y1),"y2"in f&&(u=m+f.y2),"x"in f&&(p+=f.x),"y"in f&&(m+=f.y),"m"==c?d.replaceItem(l.parser.path.createSVGPathSegMovetoAbs(p,m),e):"l"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoAbs(p,m),e):"h"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(l.parser.path.createSVGPathSegLinetoVerticalAbs(m),e):"c"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicAbs(p,m,s,o,a,u),e):"s"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,m,a,u),e):"q"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,m,s,o),e):"t"==c?d.replaceItem(l.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,m),e):"a"==c?d.replaceItem(l.parser.path.createSVGPathSegArcAbs(p,m,f.r1,f.r2,f.angle,f.largeArcFlag,f.sweepFlag),e):("z"==c||"Z"==c)&&(p=n,m=r)),("M"==c||"m"==c)&&(n=p,r=m);for(t=[],d=l.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 l.parser.path.setAttribute("d",this.toString()),l.parser.path.getBBox()}}),l.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(l.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 l.Number&&(this.value=t.value,this.unit=t.unit)},l.extend(l.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 l.Number(t),this},minus:function(t){return this.plus(-new l.Number(t))},times:function(t){return this.value=this*new l.Number(t),this},divide:function(t){return this.value=this/new l.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new l.Number(t),this},at:function(t){return this.destination?new l.Number(this.destination).minus(this).times(t).plus(this):this}}),l.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,c=t;for(n=new l.Number(t.width()),r=new l.Number(t.height());"%"==n.unit;)s*=n.value,n=new l.Number(u instanceof l.Doc?u.parent.offsetWidth:u.parent.width()),u=u.parent;for(;"%"==r.unit;)h*=r.value,r=new l.Number(c instanceof l.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)},l.extend(l.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),l.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}o(this)},l.extend(l.BBox,{merge:function(t){var e=new l.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,o(e),e}}),l.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+="number"==typeof window.scrollX?window.scrollX:window.pageXOffset,this.y+="number"==typeof window.scrollY?window.scrollY:window.pageYOffset,o(this)},l.extend(l.RBox,{merge:function(t){var e=new l.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,o(e),e}}),l.Element=l.invent({create:function(t){this._stroke=l.defaults.attrs.stroke,this.trans=l.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new l.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new l.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=r(this.bbox(),t,e);return this.width(new l.Number(i.width)).height(new l.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||l.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]=l.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.attributes[t],null==e?l.defaults.attrs[t]:l.regex.isNumber.test(e.nodeValue)?parseFloat(e.nodeValue):e.nodeValue;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)&&(l.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof l.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new l.Number(e):l.Color.isColor(e)?e=new l.Color(e):Array.isArray(e)&&(e=new l.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=a(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!=l.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 l.Number(t.x/t.scaleX)+" "+new l.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(t,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(i in t)this.style(i,t[i]);else{if(!l.regex.isCss.test(t))return this.node.style[e(t)];t=t.split(";");for(var n=0;ni.x&&e>i.y&&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 l.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof l.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()}}}),l.Container=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Parent,extend:{viewbox:function(t){return 0==arguments.length?new l.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),l.FX=l.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,h,o,a=this.target,u=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new l.Number(t).valueOf(),e=e||"<>",u.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in u.attrs)n.push(o);if(a.morphArray&&(u._plot||n.indexOf("points")>-1)){var l,c=new a.morphArray(u._plot||u.attrs.points||a.array);u._size&&c.size(u._size.width.to,u._size.height.to),l=c.bbox(),u._x?c.move(u._x.to,l.y):u._cx&&c.move(u._cx.to-l.width/2,l.y),l=c.bbox(),u._y?c.move(l.x,u._y.to):u._cy&&c.move(l.x,u._cy.to-l.height/2),delete u._x,delete u._y,delete u._cx,delete u._cy,delete u._size,u._plot=a.array.morph(c)}}if(null==r){r=[];for(o in u.trans)r.push(o)}if(null==h){h=[];for(o in u.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,u._plot?a.plot(u._plot.at(t)):(u._x?a.x(u._x.at(t)):u._cx&&a.cx(u._cx.at(t)),u._y?a.y(u._y.at(t)):u._cy&&a.cy(u._cy.at(t)),u._size&&a.size(u._size.width.at(t),u._size.height.at(t))),u._viewbox&&a.viewbox(u._viewbox.x.at(t),u._viewbox.y.at(t),u._viewbox.width.at(t),u._viewbox.height.at(t)),u._leading&&a.leading(u._leading.at(t)),i=n.length-1;i>=0;i--)a.attr(n[i],s(u.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)a.transform(r[i],s(u.trans[r[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],s(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return s({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();u.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},u.render=function(){if(u.situation.play===!0){var n=(new Date).getTime(),r=n>u.situation.finish?1:(n-u.situation.start)/t;u.to(r),n>u.situation.finish?(u._plot&&a.plot(new l.PointArray(u._plot.destination).settle()),u._loop===!0||"number"==typeof u._loop&&u._loop>1?("number"==typeof u._loop&&--u._loop,u.animate(t,e,i)):u._after?u._after.apply(a,[u]):u.stop()):u.animationFrame=requestAnimationFrame(u.render)}else u.animationFrame=requestAnimationFrame(u.render)},u.render()},new l.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]=l.Color.isColor(n)?new l.Color(n).morph(e):l.regex.unit.test(n)?new l.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=a(t),delete t.matrix,this.target.trans.cx=t.cx||null,this.target.trans.cy=t.cy||null,delete t.cx,delete t.cy;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 l.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new l.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new l.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new l.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 l.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new l.Number(i.width).morph(t),height:new l.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 l.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof l.Container){var r=this.target.viewbox();this._viewbox={x:new l.Number(r.x).morph(t),y:new l.Number(r.y).morph(e),width:new l.Number(r.width).morph(i),height:new l.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof l.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 l.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),cancelAnimationFrame(this.animationFrame),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:l.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new l.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}}}),l.extend(l.Element,l.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","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){l.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),l.listeners=[],l.handlerMap=[],l.registerEvent=function(){},l.on=function(t,e,i){var n=i.bind(t.instance||t),r=(l.handlerMap.indexOf(t)+1||l.handlerMap.push(t))-1;l.listeners[r]=l.listeners[r]||{},l.listeners[r][e]=l.listeners[r][e]||{},l.listeners[r][e][i]=n,t.addEventListener(e,n,!1)},l.off=function(t,e,i){var n=l.handlerMap.indexOf(t);if(i)-1!=n&&l.listeners[n][e]&&(t.removeEventListener(e,l.listeners[n][e][i],!1),delete l.listeners[n][e][i]);else if(e){if(l.listeners[n][e]){for(i in l.listeners[n][e])l.off(t,e,i);delete l.listeners[n][e]}}else if(-1!=n){for(e in l.listeners[n])l.off(t,e);delete l.listeners[n]}},l.extend(l.Element,{on:function(t,e){return l.on(this.node,t,e),this},off:function(t,e){return l.off(this.node,t,e),this},fire:function(e,i){return this.node.dispatchEvent(new t(e,{detail:i})),this}}),l.Defs=l.invent({create:"defs",inherit:l.Container}),l.G=l.invent({create:"g",inherit:l.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 l.G)}}}),l.extend(l.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}}),l.Mask=l.invent({create:function(){this.constructor.call(this,l.create("mask")),this.targets=[]},inherit:l.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 l.Mask)}}}),l.extend(l.Element,{maskWith:function(t){return this.masker=t instanceof l.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)}}),l.Clip=l.invent({create:function(){this.constructor.call(this,l.create("clipPath")),this.targets=[]},inherit:l.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 l.Clip)}}}),l.extend(l.Element,{clipWith:function(t){return this.clipper=t instanceof l.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)}}),l.Gradient=l.invent({create:function(t){this.constructor.call(this,l.create(t+"Gradient")),this.type=t},inherit:l.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new l.Number(t),fy:new l.Number(e)}:{x1:new l.Number(t),y1:new l.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new l.Number(t),cy:new l.Number(e)}:{x2:new l.Number(t),y2:new l.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new l.Number(t)}):this},at:function(t,e,i){return this.put(new l.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)}}}),l.extend(l.Defs,{gradient:function(t,e){return this.put(new l.Gradient(t)).update(e)}}),l.Stop=l.invent({create:"stop",inherit:l.Element,extend:{update:function(t){return("number"==typeof t||t instanceof l.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 l.Number(t.offset)),this}}}),l.Pattern=l.invent({create:"pattern",inherit:l.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)}}}),l.extend(l.Defs,{pattern:function(t,e,i){return this.put(new l.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),l.Doc=l.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:l.create("svg")),this.attr({xmlns:l.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",l.xlink,l.xmlns),this._defs=new l.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:l.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),l.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},remove:function(){return this.parent&&(this.parent.removeChild(this.node),this.parent=null),this}}}),l.Shape=l.invent({create:function(t){this.constructor.call(this,t)},inherit:l.Element}),l.Symbol=l.invent({create:"symbol",inherit:l.Container,construct:{symbol:function(){return this.defs().put(new l.Symbol)}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e)) +}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.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 l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.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")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 l.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 l.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 l.Text).text(t)},plain:function(t){return this.put(new l.Text).plain(t)}}}),l.TSpan=l.invent({create:"tspan",inherit:l.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(l.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),l.extend(l.Text,l.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 l.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof l.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 l.Text&&(delete this.lines,this.lines=new l.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),l.TextPath=l.invent({create:"textPath",inherit:l.Element,parent:l.Text,construct:{path:function(t){for(this.textPath=new l.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,l.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),l.Nested=l.invent({create:function(){this.constructor.call(this,l.create("svg")),this.style("overflow","visible")},inherit:l.Container,construct:{nested:function(){return this.put(new l.Nested)}}}),l.A=l.invent({create:"a",inherit:l.Container,extend:{to:function(t){return this.attr("href",t,l.xlink)},show:function(t){return this.attr("show",t,l.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new l.A).to(t)}}}),l.extend(l.Element,{linkTo:function(t){var e=new l.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}}),l.Marker=l.invent({create:"marker",inherit:l.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)}}}),l.extend(l.Defs,{marker:function(t,e,i){return this.put(new l.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),l.extend(l.Line,l.Polyline,l.Polygon,l.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof l.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var c={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};return["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||l.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=c[t].length-1;e>=0;e--)null!=i[c[t][e]]&&this.attr(c.prefix(t,c[t][e]),i[c[t][e]]);return this},l.extend(l.Element,l.FX,i)}),l.extend(l.Element,l.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)}}),l.extend(l.Rect,l.Ellipse,l.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),l.extend(l.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),l.extend(l.Parent,l.Text,l.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}}),l.Set=l.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 l.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 l.Set}}}),l.SetFX=l.invent({create:function(t){this.set=t}}),l.Set.inherit=function(){var t,e=[];for(var t in l.Shape.prototype)"function"==typeof l.Shape.prototype[t]&&"function"!=typeof l.Set.prototype[t]&&e.push(t);e.forEach(function(t){l.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 l.SetFX(this)):this}}),e=[];for(var t in l.FX.prototype)"function"==typeof l.FX.prototype[t]&&"function"!=typeof l.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){l.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}})},l.extend(l.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}}),l.extend(l.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={})}}),l}); \ No newline at end of file diff --git a/spec/index.html b/spec/index.html index 8896dd0..a40e8d2 100755 --- a/spec/index.html +++ b/spec/index.html @@ -61,6 +61,7 @@ +