summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/element.js8
-rw-r--r--src/hyperlink.js16
2 files changed, 24 insertions, 0 deletions
diff --git a/src/element.js b/src/element.js
index dafb9b9..ad0fc4a 100755
--- a/src/element.js
+++ b/src/element.js
@@ -114,6 +114,14 @@ SVG.extend(SVG.Element, {
return element
}
+ // Add element to given container and return self
+, addTo: function(parent) {
+ return parent.put(this)
+ }
+ // Add element to given container and return container
+, putIn: function(parent) {
+ return parent.add(this)
+ }
// Get parent document
, doc: function(type) {
return this._parent(type || SVG.Doc)
diff --git a/src/hyperlink.js b/src/hyperlink.js
index 9feea30..7b9d986 100644
--- a/src/hyperlink.js
+++ b/src/hyperlink.js
@@ -29,4 +29,20 @@ SVG.extend(SVG.Container, {
return this.put(new SVG.A).to(url)
}
+})
+
+//
+SVG.extend(SVG.Element, {
+ // Create a hyperlink element
+ linkTo: function(url) {
+ var link = new SVG.A
+
+ if (typeof url == 'function')
+ url.call(link, link)
+ else
+ link.to(url)
+
+ return this.parent.put(link).put(this)
+ }
+
}) \ No newline at end of file