aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2012-12-17 19:39:52 +0100
committerwout <wout@impinc.co.uk>2012-12-17 19:39:52 +0100
commit8dfec33b4fa79b89d89a07e3ae92c5d5c5f8ce73 (patch)
tree7caa493057b543ac40008770fdb4df566995c4e7 /src
parent6a013f19d6fa84e538d31bca5f1466c5f3479630 (diff)
downloadsvg.js-8dfec33b4fa79b89d89a07e3ae92c5d5c5f8ce73.tar.gz
svg.js-8dfec33b4fa79b89d89a07e3ae92c5d5c5f8ce73.zip
Code slimming
Diffstat (limited to 'src')
-rw-r--r--src/clip.js (renamed from src/clip_path.js)6
-rw-r--r--src/container.js2
-rw-r--r--src/defs.js2
-rw-r--r--src/doc.js (renamed from src/document.js)6
-rw-r--r--src/element.js18
-rw-r--r--src/g.js (renamed from src/group.js)8
-rw-r--r--src/object.js31
-rw-r--r--src/shape.js24
-rw-r--r--src/svg.js2
9 files changed, 28 insertions, 71 deletions
diff --git a/src/clip_path.js b/src/clip.js
index 57bff82..80d78d0 100644
--- a/src/clip_path.js
+++ b/src/clip.js
@@ -1,14 +1,14 @@
// initialize id sequence
var clipID = 0;
-SVG.ClipPath = function ClipPath() {
+SVG.Clip = function Clip() {
this.constructor.call(this, SVG.create('clipPath'));
this.id = '_' + (clipID++);
this.attr('id', this.id);
};
// inherit from SVG.Element
-SVG.ClipPath.prototype = new SVG.Element();
+SVG.Clip.prototype = new SVG.Element();
// include the container object
-SVG.Utils.merge(SVG.ClipPath, SVG.Container); \ No newline at end of file
+SVG.Utils.merge(SVG.Clip, SVG.Container); \ No newline at end of file
diff --git a/src/container.js b/src/container.js
index cc2fd4f..9d8b5af 100644
--- a/src/container.js
+++ b/src/container.js
@@ -75,7 +75,7 @@ SVG.Container = {
},
group: function() {
- var e = new SVG.Group();
+ var e = new SVG.G();
this.add(e);
return e;
diff --git a/src/defs.js b/src/defs.js
index 4c252a5..4ba7c8c 100644
--- a/src/defs.js
+++ b/src/defs.js
@@ -14,7 +14,7 @@ SVG.Utils.merge(SVG.Defs, {
// define clippath
clipPath: function() {
- var e = new SVG.ClipPath();
+ var e = new SVG.Clip();
this.add(e);
return e;
diff --git a/src/document.js b/src/doc.js
index 32780c1..41b157f 100644
--- a/src/document.js
+++ b/src/doc.js
@@ -1,5 +1,5 @@
-SVG.Document = function Document(e) {
+SVG.Doc = function Doc(e) {
this.constructor.call(this, SVG.create('svg'));
this.attr('xmlns', SVG.ns);
@@ -13,7 +13,7 @@ SVG.Document = function Document(e) {
};
// inherit from SVG.Element
-SVG.Document.prototype = new SVG.Element();
+SVG.Doc.prototype = new SVG.Element();
// include the container object
-SVG.Utils.merge(SVG.Document, SVG.Container); \ No newline at end of file
+SVG.Utils.merge(SVG.Doc, SVG.Container); \ No newline at end of file
diff --git a/src/element.js b/src/element.js
index 7926e1f..9536a79 100644
--- a/src/element.js
+++ b/src/element.js
@@ -42,32 +42,20 @@ SVG.Utils.merge(SVG.Element, {
},
// remove element
- destroy: function() {
+ remove: function() {
return this.parent != null ? this.parent.remove(this) : void 0;
},
// get parent document
parentDoc: function() {
- return this._parent(SVG.Document);
+ return this._parent(SVG.Doc);
},
// get parent svg wrapper
parentSVG: function() {
return this.parentDoc();
},
-
- //_D // set svg element attribute
- //_D setAttribute: function(a, v, ns) {
- //_D this.attrs[a] = v;
- //_D
- //_D if (ns != null)
- //_D this.node.setAttributeNS(ns, a, v);
- //_D else
- //_D this.node.setAttribute(a, v);
- //_D
- //_D return this;
- //_D },
-
+
// set svg element attribute
attr: function(v) {
var a = arguments;
diff --git a/src/group.js b/src/g.js
index 2236c09..cd6de15 100644
--- a/src/group.js
+++ b/src/g.js
@@ -1,16 +1,16 @@
-SVG.Group = function Group() {
+SVG.G = function G() {
this.constructor.call(this, SVG.create('g'));
};
// inherit from SVG.Element
-SVG.Group.prototype = new SVG.Element();
+SVG.G.prototype = new SVG.Element();
// include the container object
-SVG.Utils.merge(SVG.Group, SVG.Container);
+SVG.Utils.merge(SVG.G, SVG.Container);
// Add group-specific functions
-SVG.Utils.merge(SVG.Group, {
+SVG.Utils.merge(SVG.G, {
// group rotation
rotate: function(d) {
diff --git a/src/object.js b/src/object.js
deleted file mode 100644
index 1ec7ecc..0000000
--- a/src/object.js
+++ /dev/null
@@ -1,31 +0,0 @@
-
-//SVG.Object = function Object() {};
-//
-//Object.prototype.include = function(module) {
-//
-// for (var key in module)
-// this.prototype[key] = module[key];
-//
-// if (module.included != null)
-// module.included.apply(this);
-//
-// return this;
-//};
-
-//SVG.Object = function Object() {};
-//
-//SVG.Object.moduleKeywords = ['included', 'extended'];
-//
-//SVG.Object.include = function(module) {
-// var key, value, _ref;
-// for (key in module) {
-// value = module[key];
-// if (Array.prototype.indexOf.call(this.moduleKeywords, key) < 0) {
-// this.prototype[key] = value;
-// }
-// }
-// if ((_ref = module.included) != null) {
-// _ref.apply(this);
-// }
-// return this;
-//}; \ No newline at end of file
diff --git a/src/shape.js b/src/shape.js
index a57b9f2..1a32a00 100644
--- a/src/shape.js
+++ b/src/shape.js
@@ -10,26 +10,26 @@ SVG.Shape.prototype = new SVG.Element();
SVG.Utils.merge(SVG.Shape, {
// set fill color and opacity
- fill: function(fill) {
- if (fill.color != null)
- this.attr('fill', fill.color);
+ fill: function(f) {
+ if (f.color != null)
+ this.attr('fill', f.color);
- if (fill.opacity != null)
- this.attr('fill-opacity', fill.opacity);
+ if (f.opacity != null)
+ this.attr('fill-opacity', f.opacity);
return this;
},
// set stroke color and opacity
- stroke: function(stroke) {
- if (stroke.color != null)
- this.attr('stroke', stroke.color);
+ stroke: function(s) {
+ if (s.color)
+ this.attr('stroke', s.color);
- if (stroke.width != null)
- this.attr('stroke-width', stroke.width);
+ if (s.width != null)
+ this.attr('stroke-width', s.width);
- if (stroke.opacity != null)
- this.attr('stroke-opacity', stroke.opacity);
+ if (s.opacity != null)
+ this.attr('stroke-opacity', s.opacity);
if (this.attrs['fill-opacity'] == null)
this.fill({ opacity: 0 });
diff --git a/src/svg.js b/src/svg.js
index b042f12..331d756 100644
--- a/src/svg.js
+++ b/src/svg.js
@@ -9,5 +9,5 @@ this.SVG = {
};
this.svg = function(e) {
- return new SVG.Document(e);
+ return new SVG.Doc(e);
}; \ No newline at end of file