diff options
author | wout <wout@impinc.co.uk> | 2014-06-25 15:05:03 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-06-25 15:05:03 +0200 |
commit | e567c774c17e6649041d4972defd1232ab602012 (patch) | |
tree | 05140fe4715a652c99f15672e1d56c0fc8426824 /src/doc.js | |
parent | ec21f496bddc588e2113fd5418d713ce8ae78f39 (diff) | |
download | svg.js-e567c774c17e6649041d4972defd1232ab602012.tar.gz svg.js-e567c774c17e6649041d4972defd1232ab602012.zip |
Added SVG.Circle, removed structural internal references
Diffstat (limited to 'src/doc.js')
-rwxr-xr-x | src/doc.js | 43 |
1 files changed, 24 insertions, 19 deletions
@@ -1,25 +1,24 @@ SVG.Doc = SVG.invent({ // Initialize node create: function(element) { - /* ensure the presence of a dom element */ - element = typeof element == 'string' ? - document.getElementById(element) : - element - - /* If the target is an svg element, use that element as the main wrapper. - This allows svg.js to work with svg documents as well. */ - if (element.nodeName == 'svg') { - this.constructor.call(this, element) - } else { - this.constructor.call(this, SVG.create('svg')) - element.appendChild(this.node) + if (element) { + /* ensure the presence of a dom element */ + element = typeof element == 'string' ? + document.getElementById(element) : + element + + /* If the target is an svg element, use that element as the main wrapper. + This allows svg.js to work with svg documents as well. */ + if (element.nodeName == 'svg') { + this.constructor.call(this, element) + } else { + this.constructor.call(this, SVG.create('svg')) + element.appendChild(this.node) + } + + /* set svg element attributes and ensure defs node */ + this.namespace().size('100%', '100%').defs() } - - /* set svg element attributes and ensure defs node */ - this - .attr({ xmlns: SVG.ns, version: '1.1', width: '100%', height: '100%' }) - .attr('xmlns:xlink', SVG.xlink, SVG.xmlns) - .defs() } // Inherit from @@ -27,8 +26,14 @@ SVG.Doc = SVG.invent({ // Add class methods , extend: { + // Add namespaces + namespace: function() { + return this + .attr({ xmlns: SVG.ns, version: '1.1' }) + .attr('xmlns:xlink', SVG.xlink, SVG.xmlns) + } // Creates and returns defs element - defs: function() { + , defs: function() { if (!this._defs) { var defs |