summaryrefslogtreecommitdiffstats
path: root/src/textpath.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-02-03 15:14:47 +0100
committerwout <wout@impinc.co.uk>2014-02-03 15:14:47 +0100
commite2304534e0cfb6f6f4ab8c37ea5275ae26cd455a (patch)
tree2386e9f361d9c5fa1308387aeeaf33f00241b3c5 /src/textpath.js
parent7a29817ffd764cf7ab6906250b57f234801c94e0 (diff)
downloadsvg.js-e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a.tar.gz
svg.js-e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a.zip
Implemented SVG.invent function and bumped to v1.0rc3
Diffstat (limited to 'src/textpath.js')
-rwxr-xr-xsrc/textpath.js77
1 files changed, 40 insertions, 37 deletions
diff --git a/src/textpath.js b/src/textpath.js
index 04d7bde..9f7b088 100755
--- a/src/textpath.js
+++ b/src/textpath.js
@@ -1,39 +1,42 @@
-SVG.TextPath = function() {
- this.constructor.call(this, SVG.create('textPath'))
-}
-
-// Inherit from SVG.Element
-SVG.TextPath.prototype = new SVG.Element
-
-//
-SVG.extend(SVG.Text, {
- // Create path for text to run on
- path: function(d) {
- /* create textPath element */
- this.textPath = new SVG.TextPath
-
- /* move lines to textpath */
- while(this.node.hasChildNodes())
- this.textPath.node.appendChild(this.node.firstChild)
-
- /* add textPath element as child node */
- this.node.appendChild(this.textPath.node)
-
- /* create path in defs */
- this.track = this.doc().defs().path(d, true)
-
- /* create circular reference */
- this.textPath.parent = this
-
- /* link textPath to path and add content */
- this.textPath.attr('href', '#' + this.track, SVG.xlink)
-
- return this
+SVG.TextPath = SVG.invent({
+ // Initialize node
+ create: 'textPath'
+
+ // Inherit from
+, inherit: SVG.Element
+
+ // Define parent class
+, parent: SVG.Text
+
+ // Add parent method
+, construct: {
+ // Create path for text to run on
+ path: function(d) {
+ /* create textPath element */
+ this.textPath = new SVG.TextPath
+
+ /* move lines to textpath */
+ while(this.node.hasChildNodes())
+ this.textPath.node.appendChild(this.node.firstChild)
+
+ /* add textPath element as child node */
+ this.node.appendChild(this.textPath.node)
+
+ /* create path in defs */
+ this.track = this.doc().defs().path(d, true)
+
+ /* create circular reference */
+ this.textPath.parent = this
+
+ /* link textPath to path and add content */
+ this.textPath.attr('href', '#' + this.track, SVG.xlink)
+
+ return this
+ }
+ // Plot path if any
+ , plot: function(d) {
+ if (this.track) this.track.plot(d)
+ return this
+ }
}
- // Plot path if any
-, plot: function(d) {
- if (this.track) this.track.plot(d)
- return this
- }
-
}) \ No newline at end of file