]> source.dussan.org Git - svg.js.git/commitdiff
Bumped to version 1.0.0-rc.7
authorwout <wout@impinc.co.uk>
Wed, 11 Jun 2014 13:27:07 +0000 (15:27 +0200)
committerwout <wout@impinc.co.uk>
Wed, 11 Jun 2014 13:27:07 +0000 (15:27 +0200)
Look at change log for full overview of changes.

20 files changed:
CHANGELOG.md
README.md
Rakefile
bower.json
component.json
dist/svg.js
dist/svg.min.js
package.json
spec/index.html
spec/spec/element.js
spec/spec/pattern.js
spec/spec/regex.js [new file with mode: 0644]
spec/spec/svg.js
spec/spec/text.js
src/element.js
src/event.js
src/pointarray.js
src/regex.js
src/svg.js
src/text.js

index 3bb4bed51fc49861396bf3f689c490ecbcf0c9c1..c8f202fea14d5adc38369b4a0104dc2f7d8c3fbd 100755 (executable)
@@ -1,3 +1,15 @@
+# 1.0.0-rc.7 (11/06/2014)
+
+- calling `after()` when calling `stop(true)` (fulfill flag) [thanks @vird]
+- added `classes()`, `hasClass()`, `addClass()`, `removeClass()` and `toggleClass()` [thanks @pklingem]
+- fixed a bug where `Element#style()` would not save empty values in IE11 [thanks @Shtong]
+- fixed `SVG is not defined error` [thanks @anvaka]
+- fixed a bug in `move()`on text elements with a string based value
+- binding events listeners to svg.js instance
+- text element fires `rebuild` event whenever the `rebuild()` method is called
+- fix for `text()` method on text element when acting as getter [thanks @Lochemage]
+- fix in `style()` method with a css string [thanks @TobiasHeckel]
+
 # 1.0.0-rc.6 (03/03/2014)
 
 - fine-tuned text element positioning
@@ -35,7 +47,7 @@
 - fix in `animate('=').to()`
 - added `pointAt()` method to `SVG.Path`, wrapping the native `getPointAtLength()`
 - moved `length()` method to sugar module
-- fix for arcs in patharray `toString()` method
+- fix for arcs in patharray `toString()` method [thanks @dotnetCarpenter]
 
 # v1.0rc3 (03/02/2014)
 
index 10bc38c659d456292659d24e0b90439883cca855..1173910c0327716c92bd3390c907bcf7b807275d 100755 (executable)
--- a/README.md
+++ b/README.md
@@ -520,6 +520,16 @@ tspan.animate('2s').fill('#f06')
 
 __`returns`: `itself`__
 
+### rebuild()
+This is an internal callback that probably never needs to be called manually. Basically it rebuilds the text element whenerver `font-size` and `x` attributes or the `leading()` of the text element are modified. This method also acts a setter to enable or disable rebuilding:
+
+```javascript
+text.rebuild(false) //-> disables rebuilding
+text.rebuild(true)  //-> enables rebuilding and instantaneously rebuilds the text element
+```
+
+__`returns`: `itself`__
+
 ### clear()
 Clear all the contents of the called text element:
 
@@ -532,6 +542,14 @@ __`returns`: `itself`__
 ### lines
 All added tspans are stored in the `lines` reference, which is an instance of `SVG.Set`.
 
+### events
+The text element has one event. It is fired every time the `rebuild()` method is called:
+
+```javascript
+text.on('rebuild', function() {
+  // whatever you need to do after rebuilding
+})
+```
 
 ## TSpan
 The tspan elements are only available inside text elements or inside other tspan elements. In svg.js they have a class of their own:
@@ -1012,6 +1030,50 @@ rect.style('cursor', null)
 
 `setter`__`returns`: `itself`__
 
+### classes()
+Fetches an array of css classes on the node:
+
+```javascript
+rect.classes()
+```
+
+`getter`__`returns`: `array`__
+
+### hasClass()
+Test the presence of a given css class:
+
+```javascript
+rect.hasClass('purple-rain')
+```
+
+`getter`__`returns`: `boolean`__
+
+### addClass()
+Adds a given css class:
+
+```javascript
+rect.addClass('pink-flower')
+```
+
+`setter`__`returns`: `itself`__
+
+### removeClass()
+Removes a given css class:
+
+```javascript
+rect.removeClass('pink-flower')
+```
+
+`setter`__`returns`: `itself`__
+
+### toggleClass()
+Toggles a given css class:
+
+```javascript
+rect.toggleClass('pink-flower')
+```
+
+`setter`__`returns`: `itself`__
 
 ### move()
 Move the element to a given `x` and `y` position by its upper left corner:
@@ -1293,7 +1355,7 @@ __`returns`: `element`__
 
 ## Geometry
 
-### viewBox()
+### viewbox()
 
 The `viewBox` attribute of an `<svg>` element can be managed with the `viewbox()` method. When supplied with four arguments it will act as a setter:
 
@@ -2362,12 +2424,11 @@ All available evenets are: `click`, `dblclick`, `mousedown`, `mouseup`, `mouseov
 __`returns`: `itself`__
 
 ### Event listeners
-
 You can also bind event listeners to elements:
 
 ```javascript
 var click = function() {
-  rect.fill({ color: '#f06' })
+  this.fill({ color: '#f06' })
 }
 
 rect.on('click', click)
@@ -2375,8 +2436,6 @@ rect.on('click', click)
 
 __`returns`: `itself`__
 
-Note that the context of event listeners is not the same as events, which are applied directly to the element. Therefore `this` will not refer to the element when using event listeners.
-
 Unbinding events is just as easy:
 
 ```javascript
@@ -2397,6 +2456,32 @@ Obviously unbinding is practically the same:
 SVG.off(window, 'click', click)
 ```
 
+### Custom events
+You can even create 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:
+```javascript
+rect.on('my:event', function() {
+  alert('ta-da!')
+})
+```
+
+Now you are ready to fire the event whenever you need:
+
+```javascript
+function whenSomethingHappens() {
+  rect.fire('my:event') 
+}
+```
+
+_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
 
 Numbers in svg.js have a dedicated number class to be able to process string values. Creating a new number is simple:
@@ -2888,6 +2973,21 @@ Here are a few nice plugins that are available for svg.js:
 [svg.topath.js](https://github.com/wout/svg.topath.js) to convert any other shape to a path.
 
 
+## Contributing
+All contributions are very welcome but please make sure you:
+
+- maintain the coding style
+  - _indentation_ of 2 spaces
+  - no tailing _semicolons_
+  - use one line _comments_ to describe any additions
+  - look around and you'll know what to do
+- write at least on spec example per implementation or modification
+
+Before tunning the specs you will need to build the library.
+
+Be aware that pull requests without specs will be declined.
+
+
 ## Building
 Starting out with the default distribution of svg.js is good. Although you might want to remove some modules to keep the size at minimum.
 
index 8ff1eac164f7cb74a3cfe829ef198ab0221a5b6d..9a3857091cb552371ab64b98bc25456fccd76862 100755 (executable)
--- a/Rakefile
+++ b/Rakefile
@@ -1,4 +1,4 @@
-SVGJS_VERSION = '1.0.0-rc.6'
+SVGJS_VERSION = '1.0.0-rc.7'
 
 # all available modules in the correct loading order
 MODULES = %w[ svg inventor regex default color array pointarray patharray number viewbox bbox rbox element parent container fx relative event defs group arrange mask clip gradient pattern doc shape use rect ellipse line poly path image text textpath nested hyperlink sugar set data memory loader helpers ]
index 62ff0d8b0b1deedac085317876e11c702ec94e82..a28bcc758681fe6f020954279c9c42f2647d28ca 100755 (executable)
@@ -1,6 +1,6 @@
 {
   "name": "svg.js",
-  "version": "1.0.0-rc.6",
+  "version": "1.0.0-rc.7",
   "homepage": "http://svgjs.com/",
   "authors": [
     "Wout Fierens <wout@impinc.co.uk>"
index 82a55dfbfbac8a87506b51116a7dfd758df52aed..1b7059a7e29df3d57f915c20e86ca2f95fd32428 100755 (executable)
@@ -2,7 +2,7 @@
   "name": "svg.js",
   "repo": "wout/svg.js",
   "description": "A lightweight library for manipulating and animating SVG",
-  "version": "1.0.0-rc.6",
+  "version": "1.0.0-rc.7",
   "keywords": ["svg"],
   "author": "Wout Fierens <wout@impinc.co.uk>",
   "main": "dist/svg.js",
index c8eed90855e4c97d9e45810b4a3d92d1d76d790d..ac8c78b86ff564afb4afe45b5d36fd39ac2fae69 100755 (executable)
@@ -1,7 +1,7 @@
-/* svg.js 1.0.0-rc.6-8-g63d8846 - svg inventor regex default color array pointarray patharray number viewbox bbox rbox element parent container fx relative event defs group arrange mask clip gradient pattern doc shape use rect ellipse line poly path image text textpath nested hyperlink sugar set data memory loader helpers - svgjs.com/license */
+/* svg.js 1.0.0-rc.7-3-g791f436 - svg inventor regex default color array pointarray patharray number viewbox bbox rbox element parent container fx relative event defs group arrange mask clip gradient pattern doc shape use rect ellipse line poly path image text textpath nested hyperlink sugar set data memory loader helpers - svgjs.com/license */
 ;(function() {
 
-  this.SVG = function(element) {
+  var SVG = this.SVG = function(element) {
     if (SVG.supported) {
       element = new SVG.Doc(element)
   
@@ -66,7 +66,7 @@
   SVG.prepare = function(element) {
     /* select document body and create invisible svg element */
     var body = document.getElementsByTagName('body')[0]
-      , draw = (body ? new SVG.Doc(body) : element.nested()).size(2, 2)
+      , draw = (body ? new SVG.Doc(body) : element.nested()).size(2, 0)
       , path = SVG.create('path')
   
     /* insert parsers */
@@ -89,6 +89,7 @@
   
   if (!SVG.supported) return false
 
+
   SVG.invent = function(config) {
        /* create element initializer */
        var initializer = typeof config.create == 'function' ?
     /* test for image url */
   , isImage:      /\.(jpg|jpeg|png|gif)(\?[^=]+.*)?/i
     
+    /* test for namespaced event */
+  , isEvent:      /^[\w]+:[\w]+$/
+  
   }
 
   SVG.defaults = {
       /* recalculate position of all points according to new size */
       for (i = this.value.length - 1; i >= 0; i--) {
         this.value[i][0] = ((this.value[i][0] - box.x) * width)  / box.width  + box.x
-        this.value[i][1] = ((this.value[i][1] - box.y) * height) / box.height + box.x
+        this.value[i][1] = ((this.value[i][1] - box.y) * height) / box.height + box.y
       }
   
       return this
             s = s.split(';')
   
             /* apply every definition individually */
-            for (v = 0; v < s.length; v++) {
-              v = s[v].split(':')
+            for (var i = 0; i < s.length; i++) {
+              v = s[i].split(':')
               this.style(v[0].replace(/\s+/g, ''), v[1])
             }
           } else {
     , stop: function(fulfill) {
         /* fulfill animation */
         if (fulfill === true) {
+  
           this.animate(0)
   
+          if (this._after)
+            this._after.apply(this.target, [this])
+  
         } else {
           /* stop current animation */
           clearTimeout(this.timeout)
     }
   })
 
+
   SVG.extend(SVG.Element, SVG.FX, {
     // Relative move over x axis
     dx: function(x) {
     
   })
   
+  // Initialize events stack
+  SVG.events = {}
+  
+  // Event constructor
+  SVG.registerEvent = function(event) {
+    if (!SVG.events[event])
+      SVG.events[event] = new Event(event)
+  }
+  
   // Add event binder in the SVG namespace
   SVG.on = function(node, event, listener) {
-    if (node.addEventListener)
-      node.addEventListener(event, listener, false)
-    else
-      node.attachEvent('on' + event, listener)
+    node.addEventListener(event, listener.bind(node.instance || node), false)
   }
   
   // Add event unbinder in the SVG namespace
   SVG.off = function(node, event, listener) {
-    if (node.removeEventListener)
-      node.removeEventListener(event, listener, false)
-    else
-      node.detachEvent('on' + event, listener)
+    node.removeEventListener(event, listener.bind(node.instance || node), false)
   }
   
   //
   , off: function(event, listener) {
       SVG.off(this.node, event, listener)
       
+      return this
+    }
+    // Fire given event
+  , fire: function(event) {
+      this.node.dispatchEvent(SVG.events[event])
+  
       return this
     }
   })
       }
       // Move over y-axis
     , y: function(y) {
-        var o = this.attr('y') - this.bbox().y
+        var oy = this.attr('y')
+          , o  = typeof oy === 'number' ? oy - this.bbox().y : 0
   
         /* act as getter */
         if (y == null)
-          return this.attr('y') - o
+          return typeof oy === 'number' ? oy - o : oy
   
-        return this.attr('y', y + o)
+        return this.attr('y', typeof y === 'number' ? y + o : y)
       }
       // Move center over x-axis
     , cx: function(x) {
       // Set the text content
     , text: function(text) {
         /* act as getter */
-        if (!text) return this.content
+        if (typeof text === 'undefined') return this.content
         
         /* remove existing content */
         this.clear().build(true)
   
         } else {
           /* store text and make sure text is not blank */
-          text = (this.content = (SVG.regex.isBlank.test(text) ? 'text' : text)).split('\n')
+          text = (this.content = text).split('\n')
           
           /* build new lines */
           for (var i = 0, il = text.length; i < il; i++)
       }
       // Rebuild appearance type
     , rebuild: function(rebuild) {
-        var self = this
-  
         /* store new rebuild flag if given */
         if (typeof rebuild == 'boolean')
           this._rebuild = rebuild
   
         /* define position of all lines */
         if (this._rebuild) {
+          var self = this
+          
           this.lines.each(function() {
             if (this.newLined) {
               if (!this.textPath)
               this.attr('dy', self._leading * new SVG.Number(self.attr('font-size'))) 
             }
           })
+  
+          this.fire('rebuild')
         }
   
         return this
     }
   })
   
+  // Register rebuild event
+  SVG.registerEvent('rebuild')
 
 
   SVG.TextPath = SVG.invent({
index e742a1e0dba1af42e12fe6100e0e86c234cb8409..02df0976f1b5f80a69a43ac4e28e632b31fd8d82 100755 (executable)
@@ -1,2 +1,2 @@
-(function(){function t(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function e(t){return 4==t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}function i(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function n(t,e,i){return(null==e||null==i)&&(null==i?i=t.height/t.width*e:null==e&&(e=t.width/t.height*i)),{width:e,height:i}}function r(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof SVG.Color||t instanceof SVG.Number?t.at(e):1>e?t.from:t.to}function s(t){for(var e=0,i=t.length,n="";i>e;e++)n+=t[e][0],null!=t[e][1]&&(n+=t[e][1],null!=t[e][2]&&(n+=" ",n+=t[e][2],null!=t[e][3]&&(n+=" ",n+=t[e][3],n+=" ",n+=t[e][4],null!=t[e][5]&&(n+=" ",n+=t[e][5],n+=" ",n+=t[e][6],null!=t[e][7]&&(n+=" ",n+=t[e][7])))));return n+" "}function h(t){t.x2=t.x+t.width,t.y2=t.y+t.height,t.cx=t.x+t.width/2,t.cy=t.y+t.height/2}function o(t){if(t.matrix){var e=t.matrix.replace(/\s/g,"").split(",");6==e.length&&(t.a=parseFloat(e[0]),t.b=parseFloat(e[1]),t.c=parseFloat(e[2]),t.d=parseFloat(e[3]),t.e=parseFloat(e[4]),t.f=parseFloat(e[5]))}return t}if(this.SVG=function(t){return SVG.supported?(t=new SVG.Doc(t),SVG.parser||SVG.prepare(t),t):void 0},SVG.ns="http://www.w3.org/2000/svg",SVG.xmlns="http://www.w3.org/2000/xmlns/",SVG.xlink="http://www.w3.org/1999/xlink",SVG.did=1e3,SVG.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+SVG.did++},SVG.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},SVG.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];SVG.Set&&SVG.Set.inherit&&SVG.Set.inherit()},SVG.get=function(t){var e=document.getElementById(t);return e?e.instance:void 0},SVG.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new SVG.Doc(e):t.nested()).size(2,2),n=SVG.create("path");i.node.appendChild(n),SVG.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},SVG.supported=function(){return!!document.createElementNS&&!!document.createElementNS(SVG.ns,"svg").createSVGRect}(),!SVG.supported)return!1;SVG.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,SVG.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&SVG.extend(e,t.extend),t.construct&&SVG.extend(t.parent||SVG.Container,t.construct),e},SVG.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+)\)/,isHex:/^#[a-f0-9]{3,6}$/i,isRgb:/^rgb\(/,isCss:/[^:]+:[^;]+;?/,isBlank:/^(\s+)?$/,isNumber:/^-?[\d\.]+$/,isPercent:/^-?[\d\.]+%$/,isImage:/\.(jpg|jpeg|png|gif)(\?[^=]+.*)?/i},SVG.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}}},SVG.Color=function(t){var i;this.r=0,this.g=0,this.b=0,"string"==typeof t?SVG.regex.isRgb.test(t)?(i=SVG.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(i[1]),this.g=parseInt(i[2]),this.b=parseInt(i[3])):SVG.regex.isHex.test(t)&&(i=SVG.regex.hex.exec(e(t)),this.r=parseInt(i[1],16),this.g=parseInt(i[2],16),this.b=parseInt(i[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},SVG.extend(SVG.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+i(this.r)+i(this.g)+i(this.b)},toRgb:function(){return"rgb("+[this.r,this.g,this.b].join()+")"},brightness:function(){return this.r/255*.3+this.g/255*.59+this.b/255*.11},morph:function(t){return this.destination=new SVG.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new SVG.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}}),SVG.Color.test=function(t){return t+="",SVG.regex.isHex.test(t)||SVG.regex.isRgb.test(t)},SVG.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},SVG.Color.isColor=function(t){return SVG.Color.isRgb(t)||SVG.Color.test(t)},SVG.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},SVG.extend(SVG.Array,{morph:function(t){if(this.destination=this.parse(t),this.value.length!=this.destination.length){for(var e=this.value[this.value.length-1],i=this.destination[this.destination.length-1];this.value.length>this.destination.length;)this.destination.push(i);for(;this.value.length<this.destination.length;)this.value.push(e)}return this},settle:function(){for(var t=0,e=this.value.length,i=[];e>t;t++)-1==i.indexOf(this.value[t])&&i.push(this.value[t]);return this.value=i},at:function(t){if(!this.destination)return this;for(var e=0,i=this.value.length,n=[];i>e;e++)n.push(this.value[e]+(this.destination[e]-this.value[e])*t);return new SVG.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}}),SVG.PointArray=function(){this.constructor.apply(this,arguments)},SVG.PointArray.prototype=new SVG.Array,SVG.extend(SVG.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 SVG.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.x;return this},bbox:function(){return SVG.parser.poly.setAttribute("points",this.toString()),SVG.parser.poly.getBBox()}}),SVG.PathArray=function(t,e){this.constructor.call(this,t,e)},SVG.PathArray.prototype=new SVG.Array,SVG.extend(SVG.PathArray,{toString:function(){return s(this.value)},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n,r=this.value.length-1;r>=0;r--)n=this.value[r][0],"M"==n||"L"==n||"T"==n?(this.value[r][1]+=t,this.value[r][2]+=e):"H"==n?this.value[r][1]+=t:"V"==n?this.value[r][1]+=e:"C"==n||"S"==n||"Q"==n?(this.value[r][1]+=t,this.value[r][2]+=e,this.value[r][3]+=t,this.value[r][4]+=e,"C"==n&&(this.value[r][5]+=t,this.value[r][6]+=e)):"A"==n&&(this.value[r][6]+=t,this.value[r][7]+=e);return this},size:function(t,e){var i,n,r=this.bbox();for(i=this.value.length-1;i>=0;i--)n=this.value[i][0],"M"==n||"L"==n||"T"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y):"H"==n?this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x:"V"==n?this.value[i][1]=(this.value[i][1]-r.y)*e/r.height+r.y:"C"==n||"S"==n||"Q"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y,this.value[i][3]=(this.value[i][3]-r.x)*t/r.width+r.x,this.value[i][4]=(this.value[i][4]-r.y)*e/r.height+r.y,"C"==n&&(this.value[i][5]=(this.value[i][5]-r.x)*t/r.width+r.x,this.value[i][6]=(this.value[i][6]-r.y)*e/r.height+r.y)):"A"==n&&(this.value[i][1]=this.value[i][1]*t/r.width,this.value[i][2]=this.value[i][2]*e/r.height,this.value[i][6]=(this.value[i][6]-r.x)*t/r.width+r.x,this.value[i][7]=(this.value[i][7]-r.y)*e/r.height+r.y);return this},parse:function(t){if(t instanceof SVG.PathArray)return t.valueOf();var e,i,n,r,h,o,a,u,l,c,f,d=0,p=0;for(SVG.parser.path.setAttribute("d","string"==typeof t?t:s(t)),f=SVG.parser.path.pathSegList,e=0,i=f.numberOfItems;i>e;++e)c=f.getItem(e),l=c.pathSegTypeAsLetter,"M"==l||"L"==l||"H"==l||"V"==l||"C"==l||"S"==l||"Q"==l||"T"==l||"A"==l?("x"in c&&(d=c.x),"y"in c&&(p=c.y)):("x1"in c&&(h=d+c.x1),"x2"in c&&(a=d+c.x2),"y1"in c&&(o=p+c.y1),"y2"in c&&(u=p+c.y2),"x"in c&&(d+=c.x),"y"in c&&(p+=c.y),"m"==l?f.replaceItem(SVG.parser.path.createSVGPathSegMovetoAbs(d,p),e):"l"==l?f.replaceItem(SVG.parser.path.createSVGPathSegLinetoAbs(d,p),e):"h"==l?f.replaceItem(SVG.parser.path.createSVGPathSegLinetoHorizontalAbs(d),e):"v"==l?f.replaceItem(SVG.parser.path.createSVGPathSegLinetoVerticalAbs(p),e):"c"==l?f.replaceItem(SVG.parser.path.createSVGPathSegCurvetoCubicAbs(d,p,h,o,a,u),e):"s"==l?f.replaceItem(SVG.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(d,p,a,u),e):"q"==l?f.replaceItem(SVG.parser.path.createSVGPathSegCurvetoQuadraticAbs(d,p,h,o),e):"t"==l?f.replaceItem(SVG.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(d,p),e):"a"==l?f.replaceItem(SVG.parser.path.createSVGPathSegArcAbs(d,p,c.r1,c.r2,c.angle,c.largeArcFlag,c.sweepFlag),e):("z"==l||"Z"==l)&&(d=n,p=r)),("M"==l||"m"==l)&&(n=d,r=p);for(t=[],f=SVG.parser.path.pathSegList,e=0,i=f.numberOfItems;i>e;++e)c=f.getItem(e),l=c.pathSegTypeAsLetter,d=[l],"M"==l||"L"==l||"T"==l?d.push(c.x,c.y):"H"==l?d.push(c.x):"V"==l?d.push(c.y):"C"==l?d.push(c.x1,c.y1,c.x2,c.y2,c.x,c.y):"S"==l?d.push(c.x2,c.y2,c.x,c.y):"Q"==l?d.push(c.x1,c.y1,c.x,c.y):"A"==l&&d.push(c.r1,c.r2,c.angle,0|c.largeArcFlag,0|c.sweepFlag,c.x,c.y),t.push(d);return t},bbox:function(){return SVG.parser.path.setAttribute("d",this.toString()),SVG.parser.path.getBBox()}}),SVG.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(SVG.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 SVG.Number&&(this.value=t.value,this.unit=t.unit)},SVG.extend(SVG.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 SVG.Number(t),this},minus:function(t){return this.plus(-new SVG.Number(t))},times:function(t){return this.value=this*new SVG.Number(t),this},divide:function(t){return this.value=this/new SVG.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new SVG.Number(t),this},at:function(t){return this.destination?new SVG.Number(this.destination).minus(this).times(t).plus(this):this}}),SVG.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g);for(n=new SVG.Number(t.width()),r=new SVG.Number(t.height());"%"==n.unit;)s*=n.value,n=new SVG.Number(t instanceof SVG.Doc?t.parent.offsetWidth:t.width());for(;"%"==r.unit;)h*=r.value,r=new SVG.Number(t instanceof SVG.Doc?t.parent.offsetHeight:t.height());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)},SVG.extend(SVG.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),SVG.BBox=function(t){var e;if(this.x=0,this.y=0,this.width=0,this.height=0,t){try{e=t.node.getBBox()}catch(i){e={x:t.node.clientLeft,y:t.node.clientTop,width:t.node.clientWidth,height:t.node.clientHeight}}this.x=e.x+t.trans.x,this.y=e.y+t.trans.y,this.width=e.width*t.trans.scaleX,this.height=e.height*t.trans.scaleY}h(this)},SVG.extend(SVG.BBox,{merge:function(t){var e=new SVG.BBox;return e.x=Math.min(this.x,t.x),e.y=Math.min(this.y,t.y),e.width=Math.max(this.x+this.width,t.x+t.width)-e.x,e.height=Math.max(this.y+this.height,t.y+t.height)-e.y,h(e),e}}),SVG.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,h(this)},SVG.extend(SVG.RBox,{merge:function(t){var e=new SVG.RBox;return e.x=Math.min(this.x,t.x),e.y=Math.min(this.y,t.y),e.width=Math.max(this.x+this.width,t.x+t.width)-e.x,e.height=Math.max(this.y+this.height,t.y+t.height)-e.y,h(e),e}}),SVG.Element=SVG.invent({create:function(t){this._stroke=SVG.defaults.attrs.stroke,this.trans=SVG.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new SVG.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new SVG.Number(t),t.value/=this.trans.scaleY),this.attr("y",t)},cx:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)},cy:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},width:function(t){return this.attr("width",t)},height:function(t){return this.attr("height",t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr({width:new SVG.Number(i.width),height:new SVG.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||SVG.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]=SVG.regex.isNumber.test(e[i].nodeValue)?parseFloat(e[i].nodeValue):e[i].nodeValue;return t}if("object"==typeof t)for(e in t)this.attr(e,t[e]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return e=this.node.getAttribute(t),null==e?SVG.defaults.attrs[t]:SVG.regex.isNumber.test(e)?parseFloat(e):e;if("style"==t)return this.style(e);"stroke-width"==t?this.attr("stroke",parseFloat(e)>0?this._stroke:null):"stroke"==t&&(this._stroke=e),("fill"==t||"stroke"==t)&&(SVG.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof SVG.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new SVG.Number(e):SVG.Color.isColor(e)?e=new SVG.Color(e):Array.isArray(e)&&(e=new SVG.Array(e)),"leading"==t?this.leading&&this.leading(e):"string"==typeof i?this.node.setAttributeNS(i,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!=t&&"x"!=t||this.rebuild(t,e)}return this},transform:function(t,e){if(0==arguments.length)return this.trans;if("string"==typeof t){if(arguments.length<2)return this.trans[t];var i={};return i[t]=e,this.transform(i)}var i=[];t=o(t);for(e in t)null!=t[e]&&(this.trans[e]=t[e]);return this.trans.matrix=this.trans.a+" "+this.trans.b+" "+this.trans.c+" "+this.trans.d+" "+this.trans.e+" "+this.trans.f,t=this.trans,t.matrix!=SVG.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 SVG.Number(t.x/t.scaleX)+" "+new SVG.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(e,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof e)for(i in e)this.style(i,e[i]);else{if(!SVG.regex.isCss.test(e))return this.node.style[t(e)];for(e=e.split(";"),i=0;i<e.length;i++)i=e[i].split(":"),this.style(i[0].replace(/\s+/g,""),i[1])}else this.node.style[t(e)]=null===i||SVG.regex.isBlank.test(i)?"":i;return this},bbox:function(){return new SVG.BBox(this)},rbox:function(){return new SVG.RBox(this)},inside:function(t,e){var i=this.bbox();return t>i.x&&e>i.y&&t<i.x+i.width&&e<i.y+i.height},show:function(){return this.style("display","")},hide:function(){return this.style("display","none")},visible:function(){return"none"!=this.style("display")},toString:function(){return this.attr("id")},classes:function(){var t=this.node.getAttribute("class");return null===t?[]:t.trim().split(/\s+/)},hasClass:function(t){return-1!=this.classes().indexOf(t)},addClass:function(t){var e;return this.hasClass(t)||(e=this.classes(),e.push(t),this.node.setAttribute("class",e.join(" "))),this},removeClass:function(t){var e;return this.hasClass(t)&&(e=this.classes().filter(function(e){return e!=t}),this.node.setAttribute("class",e.join(" "))),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t),this},_parent:function(t){for(var e=this;null!=e&&!(e instanceof t);)e=e.parent;return e}}}),SVG.Parent=SVG.invent({create:function(t){this.constructor.call(this,t)},inherit:SVG.Element,extend:{children:function(){return this._children||(this._children=[])},add:function(t,e){return this.has(t)||(e=null==e?this.children().length:e,t.parent&&t.parent.children().splice(t.parent.index(t),1),this.children().splice(e,0,t),this.node.insertBefore(t.node,this.node.childNodes[e]||null),t.parent=this),this._defs&&(this.node.removeChild(this._defs.node),this.node.appendChild(this._defs.node)),this},put:function(t,e){return this.add(t,e),t},has:function(t){return this.index(t)>=0},index:function(t){return this.children().indexOf(t)},get:function(t){return this.children()[t]},first:function(){return this.children()[0]},last:function(){return this.children()[this.children().length-1]},each:function(t,e){var i,n,r=this.children();for(i=0,n=r.length;n>i;i++)r[i]instanceof SVG.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof SVG.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()}}}),SVG.Container=SVG.invent({create:function(t){this.constructor.call(this,t)},inherit:SVG.Parent,extend:{viewbox:function(t){return 0==arguments.length?new SVG.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),SVG.FX=SVG.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,s,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 SVG.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==s){s=[];for(o in u.trans)s.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],r(u.attrs[n[i]],t));for(i=s.length-1;i>=0;i--)a.transform(s[i],r(u.trans[s[i]],t));for(i=h.length-1;i>=0;i--)a.style(h[i],r(u.styles[h[i]],t));u._during&&u._during.call(a,t,function(e,i){return r({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();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 SVG.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 SVG.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]=SVG.Color.isColor(n)?new SVG.Color(n).morph(e):SVG.regex.unit.test(n)?new SVG.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=o(t),delete t.matrix;for(e in t)this.trans[e]={from:this.target.trans[e],to:t[e]}}else{var i={};i[t]=e,this.transform(i)}return this},style:function(t,e){if("object"==typeof t)for(var i in t)this.style(i,t[i]);else this.styles[t]={from:this.target.style(t),to:e};return this},x:function(t){return this._x=new SVG.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new SVG.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new SVG.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new SVG.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 SVG.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new SVG.Number(i.width).morph(t),height:new SVG.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 SVG.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof SVG.Container){var r=this.target.viewbox();this._viewbox={x:new SVG.Number(r.x).morph(t),y:new SVG.Number(r.y).morph(e),width:new SVG.Number(r.width).morph(i),height:new SVG.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof SVG.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 SVG.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):(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:SVG.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new SVG.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}}}),SVG.extend(SVG.Element,SVG.FX,{dx:function(t){return this.x((this.target||this).x()+t)},dy:function(t){return this.y((this.target||this).y()+t)},dmove:function(t,e){return this.dx(t).dy(e)}}),["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){SVG.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),SVG.on=function(t,e,i){t.addEventListener?t.addEventListener(e,i,!1):t.attachEvent("on"+e,i)},SVG.off=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent("on"+e,i)},SVG.extend(SVG.Element,{on:function(t,e){return SVG.on(this.node,t,e),this},off:function(t,e){return SVG.off(this.node,t,e),this}}),SVG.Defs=SVG.invent({create:"defs",inherit:SVG.Container}),SVG.G=SVG.invent({create:"g",inherit:SVG.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 SVG.G)}}}),SVG.extend(SVG.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}}),SVG.Mask=SVG.invent({create:function(){this.constructor.call(this,SVG.create("mask")),this.targets=[]},inherit:SVG.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 SVG.Mask)}}}),SVG.extend(SVG.Element,{maskWith:function(t){return this.masker=t instanceof SVG.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)}}),SVG.Clip=SVG.invent({create:function(){this.constructor.call(this,SVG.create("clipPath")),this.targets=[]},inherit:SVG.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 SVG.Clip)}}}),SVG.extend(SVG.Element,{clipWith:function(t){return this.clipper=t instanceof SVG.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)}}),SVG.Gradient=SVG.invent({create:function(t){this.constructor.call(this,SVG.create(t+"Gradient")),this.type=t},inherit:SVG.Container,extend:{from:function(t,e){return this.attr("radial"==this.type?{fx:new SVG.Number(t),fy:new SVG.Number(e)}:{x1:new SVG.Number(t),y1:new SVG.Number(e)})},to:function(t,e){return this.attr("radial"==this.type?{cx:new SVG.Number(t),cy:new SVG.Number(e)}:{x2:new SVG.Number(t),y2:new SVG.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new SVG.Number(t)}):this},at:function(t,e,i){return this.put(new SVG.Stop).update(t,e,i)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},fill:function(){return"url(#"+this.attr("id")+")"},toString:function(){return this.fill()}},construct:{gradient:function(t,e){return this.defs().gradient(t,e)}}}),SVG.extend(SVG.Defs,{gradient:function(t,e){return this.put(new SVG.Gradient(t)).update(e)}}),SVG.Stop=SVG.invent({create:"stop",inherit:SVG.Element,extend:{update:function(t){return("number"==typeof t||t instanceof SVG.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 SVG.Number(t.offset)),this}}}),SVG.Pattern=SVG.invent({create:"pattern",inherit:SVG.Container,extend:{fill:function(){return"url(#"+this.attr("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)}}}),SVG.extend(SVG.Defs,{pattern:function(t,e,i){return this.put(new SVG.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),SVG.Doc=SVG.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:SVG.create("svg")),this.attr({xmlns:SVG.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",SVG.xlink,SVG.xmlns),this._defs=new SVG.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:SVG.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),SVG.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}}}),SVG.Shape=SVG.invent({create:function(t){this.constructor.call(this,t)},inherit:SVG.Element}),SVG.Use=SVG.invent({create:"use",inherit:SVG.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,SVG.xlink)}},construct:{use:function(t){return this.put(new SVG.Use).element(t)}}}),SVG.Rect=SVG.invent({create:"rect",inherit:SVG.Shape,construct:{rect:function(t,e){return this.put((new SVG.Rect).size(t,e))}}}),SVG.Ellipse=SVG.invent({create:"ellipse",inherit:SVG.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 SVG.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new SVG.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new SVG.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new SVG.Number(t).divide(2))},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr({rx:new SVG.Number(i.width).divide(2),ry:new SVG.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new SVG.Ellipse).size(t,e).move(0,0)}}}),SVG.Line=SVG.invent({create:"line",inherit:SVG.Shape,extend:{x:function(t){var e=this.bbox();return null==t?e.x:this.attr({x1:this.attr("x1")-e.x+t,x2:this.attr("x2")-e.x+t})},y:function(t){var e=this.bbox();return null==t?e.y:this.attr({y1:this.attr("y1")-e.y+t,y2:this.attr("y2")-e.y+t})},cx:function(t){var e=this.bbox().width/2;return null==t?this.x()+e:this.x(t-e)},cy:function(t){var e=this.bbox().height/2;return null==t?this.y()+e:this.y(t-e)},width:function(t){var e=this.bbox();return null==t?e.width:this.attr(this.attr("x1")<this.attr("x2")?"x2":"x1",e.x+t)},height:function(t){var e=this.bbox();return null==t?e.height:this.attr(this.attr("y1")<this.attr("y2")?"y2":"y1",e.y+t)},size:function(t,e){var i=n(this.bbox(),t,e);
-return this.width(i.width).height(i.height)},plot:function(t,e,i,n){return this.attr({x1:t,y1:e,x2:i,y2:n})}},construct:{line:function(t,e,i,n){return this.put((new SVG.Line).plot(t,e,i,n))}}}),SVG.Polyline=SVG.invent({create:"polyline",inherit:SVG.Shape,construct:{polyline:function(t){return this.put(new SVG.Polyline).plot(t)}}}),SVG.Polygon=SVG.invent({create:"polygon",inherit:SVG.Shape,construct:{polygon:function(t){return this.put(new SVG.Polygon).plot(t)}}}),SVG.extend(SVG.Polyline,SVG.Polygon,{morphArray:SVG.PointArray,plot:function(t){return this.attr("points",this.array=new SVG.PointArray(t,[[0,0]]))},move:function(t,e){return this.attr("points",this.array.move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},width:function(t){var e=this.bbox();return null==t?e.width:this.size(t,e.height)},height:function(t){var e=this.bbox();return null==t?e.height:this.size(e.width,t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr("points",this.array.size(i.width,i.height))}}),SVG.Path=SVG.invent({create:"path",inherit:SVG.Shape,extend:{plot:function(t){return this.attr("d",this.array=new SVG.PathArray(t,[["M",0,0]]))},move:function(t,e){return this.attr("d",this.array.move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr("d",this.array.size(i.width,i.height))},width:function(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)},height:function(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}},construct:{path:function(t){return this.put(new SVG.Path).plot(t)}}}),SVG.Image=SVG.invent({create:"image",inherit:SVG.Shape,extend:{load:function(t){if(!t)return this;var e=this,i=document.createElement("img");return i.onload=function(){var n=e.doc(SVG.Pattern);0==e.width()&&0==e.height()&&e.size(i.width,i.height),n&&0==n.width()&&0==n.height()&&n.size(e.width(),e.height()),"function"==typeof e._loaded&&e._loaded.call(e,{width:i.width,height:i.height,ratio:i.width/i.height,url:t})},this.attr("href",i.src=this.src=t,SVG.xlink)},loaded:function(t){return this._loaded=t,this}},construct:{image:function(t,e,i){return this.put(new SVG.Image).load(t).size(e||0,i||e||0)}}}),SVG.Text=SVG.invent({create:function(){this.constructor.call(this,SVG.create("text")),this._leading=new SVG.Number(1.3),this._rebuild=!0,this._build=!1,this.attr("font-family",SVG.defaults.attrs["font-family"])},inherit:SVG.Shape,extend:{x:function(t){return null==t?this.attr("x"):(this.textPath||this.lines.each(function(){this.newLined&&this.x(t)}),this.attr("x",t))},y:function(t){var e=this.attr("y")-this.bbox().y;return null==t?this.attr("y")-e:this.attr("y",t+e)},cx:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)},cy:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)},text:function(t){if(!t)return this.content;if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else{t=(this.content=SVG.regex.isBlank.test(t)?"text":t).split("\n");for(var e=0,i=t.length;i>e;e++)this.tspan(t[e]).newLine()}return this.build(!1).rebuild()},size:function(t){return this.attr("font-size",t).rebuild()},leading:function(t){return null==t?this._leading:(this._leading=new SVG.Number(t),this.rebuild())},rebuild:function(t){var e=this;return"boolean"==typeof t&&(this._rebuild=t),this._rebuild&&this.lines.each(function(){this.newLined&&(this.textPath||this.attr("x",e.attr("x")),this.attr("dy",e._leading*new SVG.Number(e.attr("font-size"))))}),this},build:function(t){return this._build=!!t,this}},construct:{text:function(t){return this.put(new SVG.Text).text(t)},plain:function(t){return this.put(new SVG.Text).plain(t)}}}),SVG.TSpan=SVG.invent({create:"tspan",inherit:SVG.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(SVG.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),SVG.extend(SVG.Text,SVG.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 SVG.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof SVG.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 SVG.Text&&(delete this.lines,this.lines=new SVG.Set,this.content=""),this}}),SVG.TextPath=SVG.invent({create:"textPath",inherit:SVG.Element,parent:SVG.Text,construct:{path:function(t){for(this.textPath=new SVG.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,SVG.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),SVG.Nested=SVG.invent({create:function(){this.constructor.call(this,SVG.create("svg")),this.style("overflow","visible")},inherit:SVG.Container,construct:{nested:function(){return this.put(new SVG.Nested)}}}),SVG.A=SVG.invent({create:"a",inherit:SVG.Container,extend:{to:function(t){return this.attr("href",t,SVG.xlink)},show:function(t){return this.attr("show",t,SVG.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new SVG.A).to(t)}}}),SVG.extend(SVG.Element,{linkTo:function(t){var e=new SVG.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}});var a={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||SVG.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=a[t].length-1;e>=0;e--)null!=i[a[t][e]]&&this.attr(a.prefix(t,a[t][e]),i[a[t][e]]);return this},SVG.extend(SVG.Element,SVG.FX,i)}),SVG.extend(SVG.Element,SVG.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)}}),SVG.extend(SVG.Rect,SVG.Ellipse,SVG.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),SVG.extend(SVG.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),SVG.extend(SVG.Parent,SVG.Text,SVG.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}}),SVG.Set=SVG.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]},valueOf:function(){return this.members},bbox:function(){var t=new SVG.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 SVG.Set}}}),SVG.SetFX=SVG.invent({create:function(t){this.set=t}}),SVG.Set.inherit=function(){var t,e=[];for(var t in SVG.Shape.prototype)"function"==typeof SVG.Shape.prototype[t]&&"function"!=typeof SVG.Set.prototype[t]&&e.push(t);e.forEach(function(t){SVG.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 SVG.SetFX(this)):this}}),e=[];for(var t in SVG.FX.prototype)"function"==typeof SVG.FX.prototype[t]&&"function"!=typeof SVG.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){SVG.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}})},SVG.extend(SVG.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}}),SVG.extend(SVG.Element,{remember:function(t,e){if("object"==typeof arguments[0])for(var e in t)this.remember(e,t[e]);else{if(1==arguments.length)return this.memory()[t];this.memory()[t]=e}return this},forget:function(){if(0==arguments.length)this._memory={};else for(var t=arguments.length-1;t>=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory||(this._memory={})}}),"function"==typeof define&&define.amd?define(function(){return SVG}):"undefined"!=typeof exports&&(exports.SVG=SVG),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}()}).call(this);
\ No newline at end of file
+(function(){function t(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function e(t){return 4==t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}function i(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function n(t,e,i){return(null==e||null==i)&&(null==i?i=t.height/t.width*e:null==e&&(e=t.width/t.height*i)),{width:e,height:i}}function r(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof a.Color||t instanceof a.Number?t.at(e):1>e?t.from:t.to}function s(t){for(var e=0,i=t.length,n="";i>e;e++)n+=t[e][0],null!=t[e][1]&&(n+=t[e][1],null!=t[e][2]&&(n+=" ",n+=t[e][2],null!=t[e][3]&&(n+=" ",n+=t[e][3],n+=" ",n+=t[e][4],null!=t[e][5]&&(n+=" ",n+=t[e][5],n+=" ",n+=t[e][6],null!=t[e][7]&&(n+=" ",n+=t[e][7])))));return n+" "}function h(t){t.x2=t.x+t.width,t.y2=t.y+t.height,t.cx=t.x+t.width/2,t.cy=t.y+t.height/2}function o(t){if(t.matrix){var e=t.matrix.replace(/\s/g,"").split(",");6==e.length&&(t.a=parseFloat(e[0]),t.b=parseFloat(e[1]),t.c=parseFloat(e[2]),t.d=parseFloat(e[3]),t.e=parseFloat(e[4]),t.f=parseFloat(e[5]))}return t}var a=this.SVG=function(t){return a.supported?(t=new a.Doc(t),a.parser||a.prepare(t),t):void 0};if(a.ns="http://www.w3.org/2000/svg",a.xmlns="http://www.w3.org/2000/xmlns/",a.xlink="http://www.w3.org/1999/xlink",a.did=1e3,a.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+a.did++},a.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},a.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];a.Set&&a.Set.inherit&&a.Set.inherit()},a.get=function(t){var e=document.getElementById(t);return e?e.instance:void 0},a.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new a.Doc(e):t.nested()).size(2,0),n=a.create("path");i.node.appendChild(n),a.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},a.supported=function(){return!!document.createElementNS&&!!document.createElementNS(a.ns,"svg").createSVGRect}(),!a.supported)return!1;a.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,a.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&a.extend(e,t.extend),t.construct&&a.extend(t.parent||a.Container,t.construct),e},a.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+)\)/,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]+$/},a.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}}},a.Color=function(t){var i;this.r=0,this.g=0,this.b=0,"string"==typeof t?a.regex.isRgb.test(t)?(i=a.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(i[1]),this.g=parseInt(i[2]),this.b=parseInt(i[3])):a.regex.isHex.test(t)&&(i=a.regex.hex.exec(e(t)),this.r=parseInt(i[1],16),this.g=parseInt(i[2],16),this.b=parseInt(i[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},a.extend(a.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+i(this.r)+i(this.g)+i(this.b)},toRgb:function(){return"rgb("+[this.r,this.g,this.b].join()+")"},brightness:function(){return this.r/255*.3+this.g/255*.59+this.b/255*.11},morph:function(t){return this.destination=new a.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new a.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}}),a.Color.test=function(t){return t+="",a.regex.isHex.test(t)||a.regex.isRgb.test(t)},a.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},a.Color.isColor=function(t){return a.Color.isRgb(t)||a.Color.test(t)},a.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},a.extend(a.Array,{morph:function(t){if(this.destination=this.parse(t),this.value.length!=this.destination.length){for(var e=this.value[this.value.length-1],i=this.destination[this.destination.length-1];this.value.length>this.destination.length;)this.destination.push(i);for(;this.value.length<this.destination.length;)this.value.push(e)}return this},settle:function(){for(var t=0,e=this.value.length,i=[];e>t;t++)-1==i.indexOf(this.value[t])&&i.push(this.value[t]);return this.value=i},at:function(t){if(!this.destination)return this;for(var e=0,i=this.value.length,n=[];i>e;e++)n.push(this.value[e]+(this.destination[e]-this.value[e])*t);return new a.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}}),a.PointArray=function(){this.constructor.apply(this,arguments)},a.PointArray.prototype=new a.Array,a.extend(a.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 a.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 a.parser.poly.setAttribute("points",this.toString()),a.parser.poly.getBBox()}}),a.PathArray=function(t,e){this.constructor.call(this,t,e)},a.PathArray.prototype=new a.Array,a.extend(a.PathArray,{toString:function(){return s(this.value)},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n,r=this.value.length-1;r>=0;r--)n=this.value[r][0],"M"==n||"L"==n||"T"==n?(this.value[r][1]+=t,this.value[r][2]+=e):"H"==n?this.value[r][1]+=t:"V"==n?this.value[r][1]+=e:"C"==n||"S"==n||"Q"==n?(this.value[r][1]+=t,this.value[r][2]+=e,this.value[r][3]+=t,this.value[r][4]+=e,"C"==n&&(this.value[r][5]+=t,this.value[r][6]+=e)):"A"==n&&(this.value[r][6]+=t,this.value[r][7]+=e);return this},size:function(t,e){var i,n,r=this.bbox();for(i=this.value.length-1;i>=0;i--)n=this.value[i][0],"M"==n||"L"==n||"T"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y):"H"==n?this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x:"V"==n?this.value[i][1]=(this.value[i][1]-r.y)*e/r.height+r.y:"C"==n||"S"==n||"Q"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y,this.value[i][3]=(this.value[i][3]-r.x)*t/r.width+r.x,this.value[i][4]=(this.value[i][4]-r.y)*e/r.height+r.y,"C"==n&&(this.value[i][5]=(this.value[i][5]-r.x)*t/r.width+r.x,this.value[i][6]=(this.value[i][6]-r.y)*e/r.height+r.y)):"A"==n&&(this.value[i][1]=this.value[i][1]*t/r.width,this.value[i][2]=this.value[i][2]*e/r.height,this.value[i][6]=(this.value[i][6]-r.x)*t/r.width+r.x,this.value[i][7]=(this.value[i][7]-r.y)*e/r.height+r.y);return this},parse:function(t){if(t instanceof a.PathArray)return t.valueOf();var e,i,n,r,h,o,u,l,c,f,d,p=0,x=0;for(a.parser.path.setAttribute("d","string"==typeof t?t:s(t)),d=a.parser.path.pathSegList,e=0,i=d.numberOfItems;i>e;++e)f=d.getItem(e),c=f.pathSegTypeAsLetter,"M"==c||"L"==c||"H"==c||"V"==c||"C"==c||"S"==c||"Q"==c||"T"==c||"A"==c?("x"in f&&(p=f.x),"y"in f&&(x=f.y)):("x1"in f&&(h=p+f.x1),"x2"in f&&(u=p+f.x2),"y1"in f&&(o=x+f.y1),"y2"in f&&(l=x+f.y2),"x"in f&&(p+=f.x),"y"in f&&(x+=f.y),"m"==c?d.replaceItem(a.parser.path.createSVGPathSegMovetoAbs(p,x),e):"l"==c?d.replaceItem(a.parser.path.createSVGPathSegLinetoAbs(p,x),e):"h"==c?d.replaceItem(a.parser.path.createSVGPathSegLinetoHorizontalAbs(p),e):"v"==c?d.replaceItem(a.parser.path.createSVGPathSegLinetoVerticalAbs(x),e):"c"==c?d.replaceItem(a.parser.path.createSVGPathSegCurvetoCubicAbs(p,x,h,o,u,l),e):"s"==c?d.replaceItem(a.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(p,x,u,l),e):"q"==c?d.replaceItem(a.parser.path.createSVGPathSegCurvetoQuadraticAbs(p,x,h,o),e):"t"==c?d.replaceItem(a.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(p,x),e):"a"==c?d.replaceItem(a.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=a.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 a.parser.path.setAttribute("d",this.toString()),a.parser.path.getBBox()}}),a.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(a.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 a.Number&&(this.value=t.value,this.unit=t.unit)},a.extend(a.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 a.Number(t),this},minus:function(t){return this.plus(-new a.Number(t))},times:function(t){return this.value=this*new a.Number(t),this},divide:function(t){return this.value=this/new a.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new a.Number(t),this},at:function(t){return this.destination?new a.Number(this.destination).minus(this).times(t).plus(this):this}}),a.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),u=(t.attr("viewBox")||"").match(/-?[\d\.]+/g);for(n=new a.Number(t.width()),r=new a.Number(t.height());"%"==n.unit;)s*=n.value,n=new a.Number(t instanceof a.Doc?t.parent.offsetWidth:t.width());for(;"%"==r.unit;)h*=r.value,r=new a.Number(t instanceof a.Doc?t.parent.offsetHeight:t.height());this.x=o.x,this.y=o.y,this.width=n*s,this.height=r*h,this.zoom=1,u&&(e=parseFloat(u[0]),i=parseFloat(u[1]),n=parseFloat(u[2]),r=parseFloat(u[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)},a.extend(a.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),a.BBox=function(t){var e;if(this.x=0,this.y=0,this.width=0,this.height=0,t){try{e=t.node.getBBox()}catch(i){e={x:t.node.clientLeft,y:t.node.clientTop,width:t.node.clientWidth,height:t.node.clientHeight}}this.x=e.x+t.trans.x,this.y=e.y+t.trans.y,this.width=e.width*t.trans.scaleX,this.height=e.height*t.trans.scaleY}h(this)},a.extend(a.BBox,{merge:function(t){var e=new a.BBox;return e.x=Math.min(this.x,t.x),e.y=Math.min(this.y,t.y),e.width=Math.max(this.x+this.width,t.x+t.width)-e.x,e.height=Math.max(this.y+this.height,t.y+t.height)-e.y,h(e),e}}),a.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,h(this)},a.extend(a.RBox,{merge:function(t){var e=new a.RBox;return e.x=Math.min(this.x,t.x),e.y=Math.min(this.y,t.y),e.width=Math.max(this.x+this.width,t.x+t.width)-e.x,e.height=Math.max(this.y+this.height,t.y+t.height)-e.y,h(e),e}}),a.Element=a.invent({create:function(t){this._stroke=a.defaults.attrs.stroke,this.trans=a.defaults.trans(),(this.node=t)&&(this.type=t.nodeName,this.node.instance=this)},extend:{x:function(t){return null!=t&&(t=new a.Number(t),t.value/=this.trans.scaleX),this.attr("x",t)},y:function(t){return null!=t&&(t=new a.Number(t),t.value/=this.trans.scaleY),this.attr("y",t)},cx:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)},cy:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},width:function(t){return this.attr("width",t)},height:function(t){return this.attr("height",t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr({width:new a.Number(i.width),height:new a.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||a.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]=a.regex.isNumber.test(e[i].nodeValue)?parseFloat(e[i].nodeValue):e[i].nodeValue;return t}if("object"==typeof t)for(e in t)this.attr(e,t[e]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return e=this.node.getAttribute(t),null==e?a.defaults.attrs[t]:a.regex.isNumber.test(e)?parseFloat(e):e;if("style"==t)return this.style(e);"stroke-width"==t?this.attr("stroke",parseFloat(e)>0?this._stroke:null):"stroke"==t&&(this._stroke=e),("fill"==t||"stroke"==t)&&(a.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof a.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new a.Number(e):a.Color.isColor(e)?e=new a.Color(e):Array.isArray(e)&&(e=new a.Array(e)),"leading"==t?this.leading&&this.leading(e):"string"==typeof i?this.node.setAttributeNS(i,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!=t&&"x"!=t||this.rebuild(t,e)}return this},transform:function(t,e){if(0==arguments.length)return this.trans;if("string"==typeof t){if(arguments.length<2)return this.trans[t];var i={};return i[t]=e,this.transform(i)}var i=[];t=o(t);for(e in t)null!=t[e]&&(this.trans[e]=t[e]);return this.trans.matrix=this.trans.a+" "+this.trans.b+" "+this.trans.c+" "+this.trans.d+" "+this.trans.e+" "+this.trans.f,t=this.trans,t.matrix!=a.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 a.Number(t.x/t.scaleX)+" "+new a.Number(t.y/t.scaleY)+")"),0==i.length?this.node.removeAttribute("transform"):this.node.setAttribute("transform",i.join(" ")),this},style:function(e,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof e)for(i in e)this.style(i,e[i]);else{if(!a.regex.isCss.test(e))return this.node.style[t(e)];e=e.split(";");for(var n=0;n<e.length;n++)i=e[n].split(":"),this.style(i[0].replace(/\s+/g,""),i[1])}else this.node.style[t(e)]=null===i||a.regex.isBlank.test(i)?"":i;return this},bbox:function(){return new a.BBox(this)},rbox:function(){return new a.RBox(this)},inside:function(t,e){var i=this.bbox();return t>i.x&&e>i.y&&t<i.x+i.width&&e<i.y+i.height},show:function(){return this.style("display","")},hide:function(){return this.style("display","none")},visible:function(){return"none"!=this.style("display")},toString:function(){return this.attr("id")},classes:function(){var t=this.node.getAttribute("class");return null===t?[]:t.trim().split(/\s+/)},hasClass:function(t){return-1!=this.classes().indexOf(t)},addClass:function(t){var e;return this.hasClass(t)||(e=this.classes(),e.push(t),this.node.setAttribute("class",e.join(" "))),this},removeClass:function(t){var e;return this.hasClass(t)&&(e=this.classes().filter(function(e){return e!=t}),this.node.setAttribute("class",e.join(" "))),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t),this},_parent:function(t){for(var e=this;null!=e&&!(e instanceof t);)e=e.parent;return e}}}),a.Parent=a.invent({create:function(t){this.constructor.call(this,t)},inherit:a.Element,extend:{children:function(){return this._children||(this._children=[])},add:function(t,e){return this.has(t)||(e=null==e?this.children().length:e,t.parent&&t.parent.children().splice(t.parent.index(t),1),this.children().splice(e,0,t),this.node.insertBefore(t.node,this.node.childNodes[e]||null),t.parent=this),this._defs&&(this.node.removeChild(this._defs.node),this.node.appendChild(this._defs.node)),this},put:function(t,e){return this.add(t,e),t},has:function(t){return this.index(t)>=0},index:function(t){return this.children().indexOf(t)},get:function(t){return this.children()[t]},first:function(){return this.children()[0]},last:function(){return this.children()[this.children().length-1]},each:function(t,e){var i,n,r=this.children();for(i=0,n=r.length;n>i;i++)r[i]instanceof a.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof a.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()}}}),a.Container=a.invent({create:function(t){this.constructor.call(this,t)},inherit:a.Parent,extend:{viewbox:function(t){return 0==arguments.length?new a.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),a.FX=a.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,s,h,o,u=this.target,l=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new a.Number(t).valueOf(),e=e||"<>",l.to=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(o in l.attrs)n.push(o);if(u.morphArray&&(l._plot||n.indexOf("points")>-1)){var a,c=new u.morphArray(l._plot||l.attrs.points||u.array);l._size&&c.size(l._size.width.to,l._size.height.to),a=c.bbox(),l._x?c.move(l._x.to,a.y):l._cx&&c.move(l._cx.to-a.width/2,a.y),a=c.bbox(),l._y?c.move(a.x,l._y.to):l._cy&&c.move(a.x,l._cy.to-a.height/2),delete l._x,delete l._y,delete l._cx,delete l._cy,delete l._size,l._plot=u.array.morph(c)}}if(null==s){s=[];for(o in l.trans)s.push(o)}if(null==h){h=[];for(o in l.styles)h.push(o)}for(t="<>"==e?-Math.cos(t*Math.PI)/2+.5:">"==e?Math.sin(t*Math.PI/2):"<"==e?-Math.cos(t*Math.PI/2)+1:"-"==e?t:"function"==typeof e?e(t):t,l._plot?u.plot(l._plot.at(t)):(l._x?u.x(l._x.at(t)):l._cx&&u.cx(l._cx.at(t)),l._y?u.y(l._y.at(t)):l._cy&&u.cy(l._cy.at(t)),l._size&&u.size(l._size.width.at(t),l._size.height.at(t))),l._viewbox&&u.viewbox(l._viewbox.x.at(t),l._viewbox.y.at(t),l._viewbox.width.at(t),l._viewbox.height.at(t)),l._leading&&u.leading(l._leading.at(t)),i=n.length-1;i>=0;i--)u.attr(n[i],r(l.attrs[n[i]],t));for(i=s.length-1;i>=0;i--)u.transform(s[i],r(l.trans[s[i]],t));for(i=h.length-1;i>=0;i--)u.style(h[i],r(l.styles[h[i]],t));l._during&&l._during.call(u,t,function(e,i){return r({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();l.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},l.render=function(){if(l.situation.play===!0){var n=(new Date).getTime(),r=n>l.situation.finish?1:(n-l.situation.start)/t;l.to(r),n>l.situation.finish?(l._plot&&u.plot(new a.PointArray(l._plot.destination).settle()),l._loop===!0||"number"==typeof l._loop&&l._loop>1?("number"==typeof l._loop&&--l._loop,l.animate(t,e,i)):l._after?l._after.apply(u,[l]):l.stop()):requestAnimFrame(l.render)}else requestAnimFrame(l.render)},l.render()},new a.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]=a.Color.isColor(n)?new a.Color(n).morph(e):a.regex.unit.test(n)?new a.Number(n).morph(e):{from:n,to:e}}return this},transform:function(t,e){if(1==arguments.length){t=o(t),delete t.matrix;for(e in t)this.trans[e]={from:this.target.trans[e],to:t[e]}}else{var i={};i[t]=e,this.transform(i)}return this},style:function(t,e){if("object"==typeof t)for(var i in t)this.style(i,t[i]);else this.styles[t]={from:this.target.style(t),to:e};return this},x:function(t){return this._x=new a.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new a.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new a.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new a.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 a.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new a.Number(i.width).morph(t),height:new a.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 a.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof a.Container){var r=this.target.viewbox();this._viewbox={x:new a.Number(r.x).morph(t),y:new a.Number(r.y).morph(e),width:new a.Number(r.width).morph(i),height:new a.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof a.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 a.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:a.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new a.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}}}),a.extend(a.Element,a.FX,{dx:function(t){return this.x((this.target||this).x()+t)},dy:function(t){return this.y((this.target||this).y()+t)},dmove:function(t,e){return this.dx(t).dy(e)}}),["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){a.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),a.events={},a.registerEvent=function(t){a.events[t]||(a.events[t]=new Event(t))},a.on=function(t,e,i){t.addEventListener(e,i.bind(t.instance||t),!1)},a.off=function(t,e,i){t.removeEventListener(e,i.bind(t.instance||t),!1)},a.extend(a.Element,{on:function(t,e){return a.on(this.node,t,e),this},off:function(t,e){return a.off(this.node,t,e),this},fire:function(t){return this.node.dispatchEvent(a.events[t]),this}}),a.Defs=a.invent({create:"defs",inherit:a.Container}),a.G=a.invent({create:"g",inherit:a.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 a.G)}}}),a.extend(a.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}}),a.Mask=a.invent({create:function(){this.constructor.call(this,a.create("mask")),this.targets=[]},inherit:a.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 a.Mask)}}}),a.extend(a.Element,{maskWith:function(t){return this.masker=t instanceof a.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)}}),a.Clip=a.invent({create:function(){this.constructor.call(this,a.create("clipPath")),this.targets=[]},inherit:a.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 a.Clip)}}}),a.extend(a.Element,{clipWith:function(t){return this.clipper=t instanceof a.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)}}),a.Gradient=a.invent({create:function(t){this.constructor.call(this,a.create(t+"Gradient")),this.type=t},inherit:a.Container,extend:{from:function(t,e){return"radial"==this.type?this.attr({fx:new a.Number(t),fy:new a.Number(e)}):this.attr({x1:new a.Number(t),y1:new a.Number(e)})},to:function(t,e){return"radial"==this.type?this.attr({cx:new a.Number(t),cy:new a.Number(e)}):this.attr({x2:new a.Number(t),y2:new a.Number(e)})},radius:function(t){return"radial"==this.type?this.attr({r:new a.Number(t)}):this},at:function(t,e,i){return this.put(new a.Stop).update(t,e,i)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},fill:function(){return"url(#"+this.attr("id")+")"},toString:function(){return this.fill()}},construct:{gradient:function(t,e){return this.defs().gradient(t,e)}}}),a.extend(a.Defs,{gradient:function(t,e){return this.put(new a.Gradient(t)).update(e)}}),a.Stop=a.invent({create:"stop",inherit:a.Element,extend:{update:function(t){return("number"==typeof t||t instanceof a.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 a.Number(t.offset)),this}}}),a.Pattern=a.invent({create:"pattern",inherit:a.Container,extend:{fill:function(){return"url(#"+this.attr("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)}}}),a.extend(a.Defs,{pattern:function(t,e,i){return this.put(new a.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),a.Doc=a.invent({create:function(t){this.parent="string"==typeof t?document.getElementById(t):t,this.constructor.call(this,"svg"==this.parent.nodeName?this.parent:a.create("svg")),this.attr({xmlns:a.ns,version:"1.1",width:"100%",height:"100%"}).attr("xmlns:xlink",a.xlink,a.xmlns),this._defs=new a.Defs,this._defs.parent=this,this.node.appendChild(this._defs.node),this.doSpof=!1,this.parent!=this.node&&this.stage()},inherit:a.Container,extend:{stage:function(){var t=this;return this.parent.appendChild(this.node),t.spof(),a.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}}}),a.Shape=a.invent({create:function(t){this.constructor.call(this,t)},inherit:a.Element}),a.Use=a.invent({create:"use",inherit:a.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,a.xlink)}},construct:{use:function(t){return this.put(new a.Use).element(t)}}}),a.Rect=a.invent({create:"rect",inherit:a.Shape,construct:{rect:function(t,e){return this.put((new a.Rect).size(t,e))}}}),a.Ellipse=a.invent({create:"ellipse",inherit:a.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 a.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new a.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new a.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new a.Number(t).divide(2))},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr({rx:new a.Number(i.width).divide(2),ry:new a.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new a.Ellipse).size(t,e).move(0,0)}}}),a.Line=a.invent({create:"line",inherit:a.Shape,extend:{x:function(t){var e=this.bbox();return null==t?e.x:this.attr({x1:this.attr("x1")-e.x+t,x2:this.attr("x2")-e.x+t})},y:function(t){var e=this.bbox();return null==t?e.y:this.attr({y1:this.attr("y1")-e.y+t,y2:this.attr("y2")-e.y+t})},cx:function(t){var e=this.bbox().width/2;return null==t?this.x()+e:this.x(t-e)},cy:function(t){var e=this.bbox().height/2;return null==t?this.y()+e:this.y(t-e)},width:function(t){var e=this.bbox();return null==t?e.width:this.attr(this.attr("x1")<this.attr("x2")?"x2":"x1",e.x+t)},height:function(t){var e=this.bbox();return null==t?e.height:this.attr(this.attr("y1")<this.attr("y2")?"y2":"y1",e.y+t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.width(i.width).height(i.height)},plot:function(t,e,i,n){return this.attr({x1:t,y1:e,x2:i,y2:n})}},construct:{line:function(t,e,i,n){return this.put((new a.Line).plot(t,e,i,n))}}}),a.Polyline=a.invent({create:"polyline",inherit:a.Shape,construct:{polyline:function(t){return this.put(new a.Polyline).plot(t)
+}}}),a.Polygon=a.invent({create:"polygon",inherit:a.Shape,construct:{polygon:function(t){return this.put(new a.Polygon).plot(t)}}}),a.extend(a.Polyline,a.Polygon,{morphArray:a.PointArray,plot:function(t){return this.attr("points",this.array=new a.PointArray(t,[[0,0]]))},move:function(t,e){return this.attr("points",this.array.move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},width:function(t){var e=this.bbox();return null==t?e.width:this.size(t,e.height)},height:function(t){var e=this.bbox();return null==t?e.height:this.size(e.width,t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr("points",this.array.size(i.width,i.height))}}),a.Path=a.invent({create:"path",inherit:a.Shape,extend:{plot:function(t){return this.attr("d",this.array=new a.PathArray(t,[["M",0,0]]))},move:function(t,e){return this.attr("d",this.array.move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},size:function(t,e){var i=n(this.bbox(),t,e);return this.attr("d",this.array.size(i.width,i.height))},width:function(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)},height:function(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}},construct:{path:function(t){return this.put(new a.Path).plot(t)}}}),a.Image=a.invent({create:"image",inherit:a.Shape,extend:{load:function(t){if(!t)return this;var e=this,i=document.createElement("img");return i.onload=function(){var n=e.doc(a.Pattern);0==e.width()&&0==e.height()&&e.size(i.width,i.height),n&&0==n.width()&&0==n.height()&&n.size(e.width(),e.height()),"function"==typeof e._loaded&&e._loaded.call(e,{width:i.width,height:i.height,ratio:i.width/i.height,url:t})},this.attr("href",i.src=this.src=t,a.xlink)},loaded:function(t){return this._loaded=t,this}},construct:{image:function(t,e,i){return this.put(new a.Image).load(t).size(e||0,i||e||0)}}}),a.Text=a.invent({create:function(){this.constructor.call(this,a.create("text")),this._leading=new a.Number(1.3),this._rebuild=!0,this._build=!1,this.attr("font-family",a.defaults.attrs["font-family"])},inherit:a.Shape,extend:{x:function(t){return null==t?this.attr("x"):(this.textPath||this.lines.each(function(){this.newLined&&this.x(t)}),this.attr("x",t))},y:function(t){var e=this.attr("y"),i="number"==typeof e?e-this.bbox().y:0;return null==t?"number"==typeof e?e-i:e:this.attr("y","number"==typeof t?t+i:t)},cx:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)},cy:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)},text:function(t){if("undefined"==typeof t)return this.content;if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else{t=(this.content=t).split("\n");for(var e=0,i=t.length;i>e;e++)this.tspan(t[e]).newLine()}return this.build(!1).rebuild()},size:function(t){return this.attr("font-size",t).rebuild()},leading:function(t){return null==t?this._leading:(this._leading=new a.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 a.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 a.Text).text(t)},plain:function(t){return this.put(new a.Text).plain(t)}}}),a.TSpan=a.invent({create:"tspan",inherit:a.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(a.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),a.extend(a.Text,a.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 a.TSpan;return this._build===!1&&this.clear(),e.appendChild(i.node),i.parent=this,this instanceof a.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 a.Text&&(delete this.lines,this.lines=new a.Set,this.content=""),this}}),a.registerEvent("rebuild"),a.TextPath=a.invent({create:"textPath",inherit:a.Element,parent:a.Text,construct:{path:function(t){for(this.textPath=new a.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,a.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),a.Nested=a.invent({create:function(){this.constructor.call(this,a.create("svg")),this.style("overflow","visible")},inherit:a.Container,construct:{nested:function(){return this.put(new a.Nested)}}}),a.A=a.invent({create:"a",inherit:a.Container,extend:{to:function(t){return this.attr("href",t,a.xlink)},show:function(t){return this.attr("show",t,a.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new a.A).to(t)}}}),a.extend(a.Element,{linkTo:function(t){var e=new a.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent.put(e).put(this)}});var u={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||a.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=u[t].length-1;e>=0;e--)null!=i[u[t][e]]&&this.attr(u.prefix(t,u[t][e]),i[u[t][e]]);return this},a.extend(a.Element,a.FX,i)}),a.extend(a.Element,a.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)}}),a.extend(a.Rect,a.Ellipse,a.FX,{radius:function(t,e){return this.attr({rx:t,ry:e||t})}}),a.extend(a.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),a.extend(a.Parent,a.Text,a.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}}),a.Set=a.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]},valueOf:function(){return this.members},bbox:function(){var t=new a.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 a.Set}}}),a.SetFX=a.invent({create:function(t){this.set=t}}),a.Set.inherit=function(){var t,e=[];for(var t in a.Shape.prototype)"function"==typeof a.Shape.prototype[t]&&"function"!=typeof a.Set.prototype[t]&&e.push(t);e.forEach(function(t){a.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 a.SetFX(this)):this}}),e=[];for(var t in a.FX.prototype)"function"==typeof a.FX.prototype[t]&&"function"!=typeof a.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){a.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}})},a.extend(a.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}}),a.extend(a.Element,{remember:function(t,e){if("object"==typeof arguments[0])for(var e in t)this.remember(e,t[e]);else{if(1==arguments.length)return this.memory()[t];this.memory()[t]=e}return this},forget:function(){if(0==arguments.length)this._memory={};else for(var t=arguments.length-1;t>=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory||(this._memory={})}}),"function"==typeof define&&define.amd?define(function(){return a}):"undefined"!=typeof exports&&(exports.SVG=a),window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}()}).call(this);
\ No newline at end of file
index 510c985ed3c795f6d2649ccda102c021dd7d2efa..837e67efdc01415a9c53ed2728229d627a5b1436 100755 (executable)
@@ -6,7 +6,7 @@
 , "keywords":     ["svg", "vector", "graphics", "animation"]
 , "author":       "Wout Fierens <wout@impinc.co.uk>"
 , "main":         "dist/svg.js"
-, "version":      "1.0.0-rc.6"
+, "version":      "1.0.0-rc.7"
 , "jam": {
     "include": [
       "dist/svg.js"
index 2044a3e4c80ef694719b5aeb0556efd32f92a8b1..78d95d8c88c2ddc2fc729b51fd55e138c4317638 100755 (executable)
@@ -29,6 +29,7 @@
 
 <!-- include spec files here... -->
 <script type="text/javascript" src="spec/svg.js"></script>
+<script type="text/javascript" src="spec/regex.js"></script>
 <script type="text/javascript" src="spec/container.js"></script>
 <script type="text/javascript" src="spec/element.js"></script>
 <script type="text/javascript" src="spec/memory.js"></script>
index 064c1e8c9ebb0fc98562733e6a26e51e6ebdea36..a0c7a2a7e7c832b848ecae40cc23bda6ea130bb4 100755 (executable)
@@ -89,13 +89,13 @@ describe('Element', function() {
   describe('style()', function() {
     it('should set the style with key and value arguments', function() {
       var rect = draw.rect(100,100).style('cursor', 'crosshair')
-      expect(stripped(rect.node.getAttribute('style'))).toBe('cursor:crosshair;')
+      expect(stripped(rect.node.style.cssText)).toBe('cursor:crosshair;')
     })
     it('should set multiple styles with an object as the first argument', function() {
       var rect = draw.rect(100,100).style({ cursor: 'help', display: 'block' })
-      expect(stripped(rect.node.getAttribute('style'))).toMatch(/cursor:help;/)
-      expect(stripped(rect.node.getAttribute('style'))).toMatch(/display:block;/)
-      expect(stripped(rect.node.getAttribute('style')).length).toBe(('display:block;cursor:help;').length)
+      expect(stripped(rect.node.style.cssText)).toMatch(/cursor:help;/)
+      expect(stripped(rect.node.style.cssText)).toMatch(/display:block;/)
+      expect(stripped(rect.node.style.cssText).length).toBe(('display:block;cursor:help;').length)
     })
     it('should get a style with a string key as the fists argument', function() {
       var rect = draw.rect(100,100).style({ cursor: 'progress', display: 'block' })
index b251801caea42e2c54f396099eb3a59c6422b373..4abdadcbd64c24957faa5a0d1b1d822324a6cfd5 100755 (executable)
@@ -37,6 +37,10 @@ describe('Pattern', function() {
       rect.attr('fill', pattern)
       expect(rect.attr('fill')).toBe('url(#' + pattern.attr('id') + ')')
     })
+    it('is called when instance is passed in a fill() method', function() {
+      rect.fill(pattern)
+      expect(rect.attr('fill')).toBe('url(#' + pattern.attr('id') + ')')
+    })
   })
 
   describe('update()', function() {
diff --git a/spec/spec/regex.js b/spec/spec/regex.js
new file mode 100644 (file)
index 0000000..f64991a
--- /dev/null
@@ -0,0 +1,27 @@
+describe('Regex', function() {
+
+  describe('unit', function() {
+    it('is true with a positive unit value', function() {
+      expect(SVG.regex.unit.test('10%')).toBeTruthy()
+    })
+    it('is true with a negative unit value', function() {
+      expect(SVG.regex.unit.test('-11%')).toBeTruthy()
+    })
+    it('is false with a positive unit value', function() {
+      expect(SVG.regex.unit.test('NotAUnit')).toBeFalsy()
+    })
+  })
+
+  describe('isEvent', function() {
+    it('is true with a namespaced and lowercase name', function() {
+      expect(SVG.regex.isEvent.test('my:event')).toBeTruthy()
+    })
+    it('is true with a namespaced and camelCase name', function() {
+      expect(SVG.regex.isEvent.test('mt:fabulousEvent')).toBeTruthy()
+    })
+    it('is false without a namespace', function() {
+      expect(SVG.regex.isEvent.test('idontlinkenamespaces')).toBeFalsy()
+    })
+  })
+
+})
\ No newline at end of file
index 75f8a6d16e3fb73543f8ac419f907f337a1c6156..843bb89706230fa8b0175dcd08461f3636ca758f 100755 (executable)
@@ -1,23 +1,23 @@
 describe('SVG', function() {
   
   describe('()', function() {
-    var canvas, wrapper
+    var drawing, wrapper
     
     beforeEach(function() {
       wrapper = document.createElement('div')
       document.getElementsByTagName('body')[0].appendChild(wrapper)
-      canvas = SVG(wrapper)
+      drawing = SVG(wrapper)
     })
     
     afterEach(function() {
       wrapper.parentNode.removeChild(wrapper)
     })
     
-    it('creates a new svg canvas', function() {
-      expect(canvas.type).toBe('svg')
+    it('creates a new svg drawing', function() {
+      expect(drawing.type).toBe('svg')
     })
     it('creates an instance of SVG.Doc', function() {
-      expect(canvas instanceof SVG.Doc).toBe(true)
+      expect(drawing instanceof SVG.Doc).toBe(true)
     })
   })
   
index 6c4d9c6db159c37bd85805bb9b131320353e8b9e..2e373a47c898700f8bda7e08fb0cb366e4e0fa93 100755 (executable)
@@ -33,15 +33,17 @@ describe('Text', function() {
     it('returns the value of y without an argument', function() {
       expect(text.y(0).y()).toBe(0)
     })
+    it('returns the value of y when y is a percentual value', function() {
+      expect(text.y('45%').y()).toBe('45%')
+    })
     it('sets the value of y with the first argument', function() {
       text.y(345)
       var box = text.bbox()
       expect(box.y).toBe(345)
     })
-    it('sets the value of y based on the anchor with the first argument', function() {
-      text.y(345, true)
-      var box = text.bbox()
-      expect(box.y).toBe(345)
+    it('sets the value of y with a percent value', function() {
+      text.y('40%')
+      expect(text.node.getAttribute('y')).toBe('40%')
     })
   })
   
@@ -112,6 +114,11 @@ describe('Text', function() {
       expect(text.node.childNodes[0].nodeType).toBe(1)
       expect(text.node.childNodes[0].childNodes[0].nodeValue).toBe('It is a bear!')
     })
+    it('adds content in a nested tspan even with an empty string', function() {
+      text.text('')
+      expect(text.node.childNodes[0].nodeType).toBe(1)
+      expect(text.node.childNodes[0].childNodes[0].nodeValue).toBe('')
+    })
     it('creates multiple lines with a newline separated string', function() {
       text.text('It is\nJUST\na bear!')
       expect(text.node.childNodes.length).toBe(3)
index 9c52dd074a40649b50467ad0e12a395f9e774d21..e63b57e7c98eeb15bd0e3160a76f50fafddbc63b 100755 (executable)
@@ -293,8 +293,8 @@ SVG.Element = SVG.invent({
           s = s.split(';')
 
           /* apply every definition individually */
-          for (v = 0; v < s.length; v++) {
-            v = s[v].split(':')
+          for (var i = 0; i < s.length; i++) {
+            v = s[i].split(':')
             this.style(v[0].replace(/\s+/g, ''), v[1])
           }
         } else {
index 73e3ba5e5f50d45af689a92a9192ab420d6cb544..885eab8e2450101d684e127ce967ce0164f42e17 100755 (executable)
@@ -1,8 +1,4 @@
-// ### Manage events on elements
-
-//     rect.click(function() {
-//       this.fill({ color: '#f06' })
-//     })
+// Add events to elements
 ;[  'click'
   , 'dblclick'
   , 'mousedown'
   
 })
 
+// Initialize events stack
+SVG.events = {}
+
+// Event constructor
+SVG.registerEvent = function(event) {
+  if (!SVG.events[event])
+    SVG.events[event] = new Event(event)
+}
+
 // Add event binder in the SVG namespace
 SVG.on = function(node, event, listener) {
-  if (node.addEventListener)
-    node.addEventListener(event, listener, false)
-  else
-    node.attachEvent('on' + event, listener)
+  node.addEventListener(event, listener.bind(node.instance || node), false)
 }
 
 // Add event unbinder in the SVG namespace
 SVG.off = function(node, event, listener) {
-  if (node.removeEventListener)
-    node.removeEventListener(event, listener, false)
-  else
-    node.detachEvent('on' + event, listener)
+  node.removeEventListener(event, listener.bind(node.instance || node), false)
 }
 
 //
@@ -59,6 +58,12 @@ SVG.extend(SVG.Element, {
 , off: function(event, listener) {
     SVG.off(this.node, event, listener)
     
+    return this
+  }
+  // Fire given event
+, fire: function(event) {
+    this.node.dispatchEvent(SVG.events[event])
+
     return this
   }
 })
\ No newline at end of file
index 16f32839b5bdd87cdeda7d3ee643b0c64b59cc8c..e246adf4f3fc8fb66c66a2d46014ef5a8de1e24c 100755 (executable)
@@ -69,7 +69,7 @@ SVG.extend(SVG.PointArray, {
     /* recalculate position of all points according to new size */
     for (i = this.value.length - 1; i >= 0; i--) {
       this.value[i][0] = ((this.value[i][0] - box.x) * width)  / box.width  + box.x
-      this.value[i][1] = ((this.value[i][1] - box.y) * height) / box.height + box.x
+      this.value[i][1] = ((this.value[i][1] - box.y) * height) / box.height + box.y
     }
 
     return this
index c78d9f3e095d03fde3d21d2aec9df0727f7d8715..433952b499063a4584b1afd29de3bda4f3040f30 100755 (executable)
@@ -30,4 +30,7 @@ SVG.regex = {
   /* test for image url */
 , isImage:      /\.(jpg|jpeg|png|gif)(\?[^=]+.*)?/i
   
+  /* test for namespaced event */
+, isEvent:      /^[\w]+:[\w]+$/
+
 }
\ No newline at end of file
index 07afa7af00cb78512cd88c2b229aa424927764c4..e0e5b44adec6a1feb6de56e3fe46037a0b92e347 100755 (executable)
@@ -1,6 +1,6 @@
 
 // The main wrapping element
-this.SVG = function(element) {
+var SVG = this.SVG = function(element) {
   if (SVG.supported) {
     element = new SVG.Doc(element)
 
@@ -65,7 +65,7 @@ SVG.get = function(id) {
 SVG.prepare = function(element) {
   /* select document body and create invisible svg element */
   var body = document.getElementsByTagName('body')[0]
-    , draw = (body ? new SVG.Doc(body) : element.nested()).size(2, 2)
+    , draw = (body ? new SVG.Doc(body) : element.nested()).size(2, 0)
     , path = SVG.create('path')
 
   /* insert parsers */
@@ -86,4 +86,4 @@ SVG.supported = (function() {
          !! document.createElementNS(SVG.ns,'svg').createSVGRect
 })()
 
-if (!SVG.supported) return false
\ No newline at end of file
+if (!SVG.supported) return false
index 170b9de66a2cd1fa77b1f2e35dc3a3676a78bf0d..1d053620e3b3f0d226179e33697f3f236240ebb0 100755 (executable)
@@ -31,13 +31,14 @@ SVG.Text = SVG.invent({
     }
     // Move over y-axis
   , y: function(y) {
-      var o = this.attr('y') - this.bbox().y
+      var oy = this.attr('y')
+        , o  = typeof oy === 'number' ? oy - this.bbox().y : 0
 
       /* act as getter */
       if (y == null)
-        return this.attr('y') - o
+        return typeof oy === 'number' ? oy - o : oy
 
-      return this.attr('y', y + o)
+      return this.attr('y', typeof y === 'number' ? y + o : y)
     }
     // Move center over x-axis
   , cx: function(x) {
@@ -50,7 +51,7 @@ SVG.Text = SVG.invent({
     // Set the text content
   , text: function(text) {
       /* act as getter */
-      if (!text) return this.content
+      if (typeof text === 'undefined') return this.content
       
       /* remove existing content */
       this.clear().build(true)
@@ -61,7 +62,7 @@ SVG.Text = SVG.invent({
 
       } else {
         /* store text and make sure text is not blank */
-        text = (this.content = (SVG.regex.isBlank.test(text) ? 'text' : text)).split('\n')
+        text = (this.content = text).split('\n')
         
         /* build new lines */
         for (var i = 0, il = text.length; i < il; i++)
@@ -88,14 +89,14 @@ SVG.Text = SVG.invent({
     }
     // Rebuild appearance type
   , rebuild: function(rebuild) {
-      var self = this
-
       /* store new rebuild flag if given */
       if (typeof rebuild == 'boolean')
         this._rebuild = rebuild
 
       /* define position of all lines */
       if (this._rebuild) {
+        var self = this
+        
         this.lines.each(function() {
           if (this.newLined) {
             if (!this.textPath)
@@ -103,6 +104,8 @@ SVG.Text = SVG.invent({
             this.attr('dy', self._leading * new SVG.Number(self.attr('font-size'))) 
           }
         })
+
+        this.fire('rebuild')
       }
 
       return this
@@ -216,3 +219,5 @@ SVG.extend(SVG.Text, SVG.TSpan, {
   }
 })
 
+// Register rebuild event
+SVG.registerEvent('rebuild')