diff --git a/examples/Animated/AnimatedStar.html b/examples/Animated/AnimatedStar.html
index 9cd5ba4a..b42a79fd 100644
--- a/examples/Animated/AnimatedStar.html
+++ b/examples/Animated/AnimatedStar.html
@@ -44,7 +44,7 @@
}
// Reposition the paths whenever the window is resized:
- Event.add(window, {
+ DomEvent.add(window, {
resize: function(event) {
document.activeLayer.position = document.bounds.center;
}
diff --git a/examples/Animated/Flock.html b/examples/Animated/Flock.html
index 4d92d863..ee167a1e 100644
--- a/examples/Animated/Flock.html
+++ b/examples/Animated/Flock.html
@@ -11,7 +11,7 @@
// http://processing.org/learning/topics/flocking.html
// Reposition the heart path whenever the window is resized:
- Event.add(window, {
+ DomEvent.add(window, {
resize: function(event) {
size = document.size;
heartPath.position = document.bounds.center;
diff --git a/examples/Animated/RadialRainbows.html b/examples/Animated/RadialRainbows.html
index 32ac3066..03618d92 100644
--- a/examples/Animated/RadialRainbows.html
+++ b/examples/Animated/RadialRainbows.html
@@ -64,7 +64,7 @@
gradientColor.hilite = mouseDown ? point : point + vector;
}
- Event.add(window, {
+ DomEvent.add(window, {
resize: function(event) {
point = new Point(document.size) / 2;
path.bounds = document.bounds;
diff --git a/examples/Animated/Smoothing.html b/examples/Animated/Smoothing.html
index 7b161332..4c60f7fc 100644
--- a/examples/Animated/Smoothing.html
+++ b/examples/Animated/Smoothing.html
@@ -59,7 +59,7 @@
}
// Reposition the path whenever the window is resized:
- Event.add(window, {
+ DomEvent.add(window, {
resize: function(event) {
initializePath();
onFrame();
diff --git a/src/browser/Element.js b/src/browser/DomElement.js
similarity index 86%
rename from src/browser/Element.js
rename to src/browser/DomElement.js
index c47c8479..f5c73431 100644
--- a/src/browser/Element.js
+++ b/src/browser/DomElement.js
@@ -14,7 +14,7 @@
* All rights reserved.
*/
-var Element = new function() {
+var DomElement = new function() {
function cumulate(el, name, parent) {
var left = name + 'Left',
top = name + 'Top',
@@ -41,8 +41,8 @@ var Element = new function() {
},
getBounds: function(el, scroll) {
- return new Rectangle(Element.getOffset(el, scroll),
- Element.getSize(el));
+ return new Rectangle(DomElement.getOffset(el, scroll),
+ DomElement.getSize(el));
},
getWindowSize: function() {
@@ -58,8 +58,8 @@ var Element = new function() {
isVisible: function(el) {
// See if the scrolled bounds intersect with the windows rectangle
// which always starts at 0, 0
- return new Rectangle([0, 0], Element.getWindowSize())
- .intersects(Element.getBounds(el, true));
+ return new Rectangle([0, 0], DomElement.getWindowSize())
+ .intersects(DomElement.getBounds(el, true));
}
};
};
diff --git a/src/browser/Event.js b/src/browser/DomEvent.js
similarity index 93%
rename from src/browser/Event.js
rename to src/browser/DomEvent.js
index f0b4c9f1..1c411688 100644
--- a/src/browser/Event.js
+++ b/src/browser/DomEvent.js
@@ -14,7 +14,7 @@
* All rights reserved.
*/
-var Event = {
+var DomEvent = {
add: function(el, events) {
for (var type in events) {
var func = events[type];
@@ -60,12 +60,12 @@ var Event = {
getOffset: function(event) {
// Remove target offsets from page coordinates
- return Event.getPoint(event).subtract(
- Element.getOffset(Event.getElement(event), true));
+ return DomEvent.getPoint(event).subtract(
+ DomElement.getOffset(DomEvent.getElement(event), true));
}
};
-Event.requestAnimationFrame = new function() {
+DomEvent.requestAnimationFrame = new function() {
var part = 'equestAnimationFrame',
request = window['r' + part] || window['webkitR' + part]
|| window['mozR' + part] || window['oR' + part]
@@ -100,7 +100,7 @@ Event.requestAnimationFrame = new function() {
var entry = callbacks[i],
func = entry[0],
element = entry[1];
- if (!element || Element.isVisible(element)) {
+ if (!element || DomElement.isVisible(element)) {
// Handle callback and remove it from callbacks list.
callbacks.splice(i, 1);
func(+new Date);
@@ -110,7 +110,7 @@ Event.requestAnimationFrame = new function() {
}
if (!paper.debug) {
- Event.add(window, {
+ DomEvent.add(window, {
focus: function() {
focused = true;
// Switch to falst checkCallback calls while window is focused.
diff --git a/src/document/Document.js b/src/document/Document.js
index 851ef3fe..65fa81f4 100644
--- a/src/document/Document.js
+++ b/src/document/Document.js
@@ -30,15 +30,15 @@ var Document = this.Document = Base.extend({
// margin: 0;
// overflow: hidden;
// }
- this._size = Element.getWindowSize()
- .subtract(Element.getOffset(this.canvas));
+ this._size = DomElement.getWindowSize()
+ .subtract(DomElement.getOffset(this.canvas));
this.canvas.width = this._size.width;
this.canvas.height = this._size.height;
var that = this;
- Event.add(window, {
+ DomEvent.add(window, {
resize: function(event) {
- that.setSize(Element.getWindowSize()
- .subtract(Element.getOffset(that.canvas)));
+ that.setSize(DomElement.getWindowSize()
+ .subtract(DomElement.getOffset(that.canvas)));
that.redraw();
}
});
@@ -72,7 +72,7 @@ var Document = this.Document = Base.extend({
// Align top-left to the canvas
var element = this.stats.domElement,
style = element.style,
- offset = Element.getOffset(this.canvas);
+ offset = DomElement.getOffset(this.canvas);
style.position = 'absolute';
style.left = offset.x + 'px';
style.top = offset.y + 'px';
diff --git a/src/load.js b/src/load.js
index 3b9b1aaa..bcc2ad15 100644
--- a/src/load.js
+++ b/src/load.js
@@ -66,8 +66,8 @@ var sources = [
'src/tool/ToolHandler.js',
'src/tool/Tool.js',
- 'src/browser/Element.js',
- 'src/browser/Event.js',
+ 'src/browser/DomElement.js',
+ 'src/browser/DomEvent.js',
'src/util/CanvasProvider.js',
'src/util/Numerical.js',
diff --git a/src/paper.js b/src/paper.js
index 7c0900a3..79205e61 100644
--- a/src/paper.js
+++ b/src/paper.js
@@ -163,8 +163,8 @@ Base.inject({
//#include "tool/Tool.js"
//#ifdef BROWSER
-//#include "browser/Element.js"
-//#include "browser/Event.js"
+//#include "browser/DomElement.js"
+//#include "browser/DomEvent.js"
//#endif // BROWSER
//#include "util/CanvasProvider.js"
diff --git a/src/tool/Tool.js b/src/tool/Tool.js
index aa4b4534..8d789df0 100644
--- a/src/tool/Tool.js
+++ b/src/tool/Tool.js
@@ -16,9 +16,8 @@
var Tool = this.Tool = ToolHandler.extend(new function() {
function viewToArtwork(event, document) {
- var point = Event.getOffset(event);
// TODO: always the active view?
- return document.activeView.viewToArtwork(point);
+ return document.activeView.viewToArtwork(DomEvent.getOffset(event));
};
return {
@@ -91,9 +90,9 @@ var Tool = this.Tool = ToolHandler.extend(new function() {
// Remove old events first.
if (this._document)
- Event.remove(this._document.canvas, this.events);
+ DomEvent.remove(this._document.canvas, this.events);
this._document = doc;
- Event.add(doc.canvas, this.events);
+ DomEvent.add(doc.canvas, this.events);
},
getDocument: function() {
diff --git a/src/tool/ToolEvent.js b/src/tool/ToolEvent.js
index ee81bac2..5a0df5d1 100644
--- a/src/tool/ToolEvent.js
+++ b/src/tool/ToolEvent.js
@@ -35,9 +35,9 @@ var ToolEvent = this.ToolEvent = Base.extend({
beans: true,
initialize: function(tool, type, event) {
- this.event = event;
this.tool = tool;
this.type = type;
+ this.event = event;
},
toString: function() {
diff --git a/src/util/PaperScript.js b/src/util/PaperScript.js
index ddb82002..4c7aefdc 100644
--- a/src/util/PaperScript.js
+++ b/src/util/PaperScript.js
@@ -152,12 +152,12 @@ var PaperScript = this.PaperScript = new function() {
if (onFrame) {
function frame() {
// Request next frame already
- Event.requestAnimationFrame(frame, doc && doc.canvas);
+ DomEvent.requestAnimationFrame(frame, doc && doc.canvas);
onFrame();
// Automatically redraw document each frame.
doc && doc.redraw();
}
- Event.requestAnimationFrame(frame, doc && doc.canvas);
+ DomEvent.requestAnimationFrame(frame, doc && doc.canvas);
}
} catch (e) {
}
@@ -209,7 +209,7 @@ var PaperScript = this.PaperScript = new function() {
}
}
- Event.add(window, { load: load });
+ DomEvent.add(window, { load: load });
return {
compile: compile,