From ff77ed7e46fd4a9054179c13dba12eefec8d582d Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Sat, 2 Feb 2013 22:25:14 -0700 Subject: [PATCH] Consistent style --- html/repulsion.html | 2 +- js/lib/canvas.js | 8 +++----- js/lib/canvas_helpers.js | 6 +++--- js/lib/canvas_object.js | 4 ++-- js/lib/collision.mixin.js | 3 ++- js/lib/drawable.js | 4 ++-- js/lib/drawable_collection.js | 4 ++-- js/lib/gravity.mixin.js | 5 +++-- js/lib/request_anim_shims.js | 2 ++ js/lib/util.js | 4 ++-- js/lib/valentine_ext.js | 2 ++ js/lib/vec2.js | 4 +++- 12 files changed, 27 insertions(+), 21 deletions(-) diff --git a/html/repulsion.html b/html/repulsion.html index 149cd95..7914967 100644 --- a/html/repulsion.html +++ b/html/repulsion.html @@ -18,10 +18,10 @@ - + diff --git a/js/lib/canvas.js b/js/lib/canvas.js index 9822b17..4a137ed 100644 --- a/js/lib/canvas.js +++ b/js/lib/canvas.js @@ -1,8 +1,8 @@ 'use strict'; -var Canvas = P(function(proto, uber, klass, uberklass) { - $.v.extend(proto, { +window.Canvas = P(function(proto, uber, klass, uberklass) { + return { init: function(id, options) { this.$wrapperElement = $(id) this.options = options || {} @@ -271,8 +271,6 @@ var Canvas = P(function(proto, uber, klass, uberklass) { _clearDebug: function() { this.$debugDiv.html("") } - }) - - $.v.extend(proto, CanvasHelpers) + } }) diff --git a/js/lib/canvas_helpers.js b/js/lib/canvas_helpers.js index 19c7db8..ed58070 100644 --- a/js/lib/canvas_helpers.js +++ b/js/lib/canvas_helpers.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; -var CanvasHelpers = { +$.v.extend(Canvas.prototype, { line: function(x1, y1, x2, y2, options) { var options options = $.v.extend({}, options, { @@ -131,5 +131,5 @@ var CanvasHelpers = { options.origin = [0, 0] return options } -} +}) diff --git a/js/lib/canvas_object.js b/js/lib/canvas_object.js index a913e04..738f404 100644 --- a/js/lib/canvas_object.js +++ b/js/lib/canvas_object.js @@ -1,7 +1,7 @@ 'use strict'; -var CanvasObject = P(Drawable, function(proto, uber) { +window.CanvasObject = P(Drawable, function(proto, uber) { return { init: function(parent, opts) { uber.init.call(this, parent) @@ -35,7 +35,7 @@ var CanvasObject = P(Drawable, function(proto, uber) { setPos: function(interpFactor) { // this.pos + this.vel represents the target position // however, we have to take the interpolation factor into play - // on every update, this.pos + // on every update, this.pos this.pos[0] += this.vel[0] * interpFactor this.pos[1] += this.vel[1] * interpFactor }, diff --git a/js/lib/collision.mixin.js b/js/lib/collision.mixin.js index f051377..00bda55 100644 --- a/js/lib/collision.mixin.js +++ b/js/lib/collision.mixin.js @@ -1,7 +1,7 @@ 'use strict'; -var collision = { +window.collision = { applyTo: function(canvas, obj) { var bb, newpos, ob, dxa, dxb, dya, dyb, velslope, newvel @@ -56,3 +56,4 @@ var collision = { } } } + diff --git a/js/lib/drawable.js b/js/lib/drawable.js index 581912b..0fa2224 100644 --- a/js/lib/drawable.js +++ b/js/lib/drawable.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; -var Drawable = P(function () { +window.Drawable = P(function () { return { init: function(parent) { this.setParent(parent) diff --git a/js/lib/drawable_collection.js b/js/lib/drawable_collection.js index 0f6a066..78d1d58 100644 --- a/js/lib/drawable_collection.js +++ b/js/lib/drawable_collection.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; -var DrawableCollection = P(Drawable, function (proto, uber) { +window.DrawableCollection = P(Drawable, function (proto, uber) { return { init: function (parent) { uber.init.call(this, parent) diff --git a/js/lib/gravity.mixin.js b/js/lib/gravity.mixin.js index 67cc595..50931d7 100644 --- a/js/lib/gravity.mixin.js +++ b/js/lib/gravity.mixin.js @@ -1,7 +1,8 @@ -'use strict' +'use strict'; -var Gravity = { +// FIXME +window.Gravity = { mixin: function(args) { args.canvasClass.prototype.objectGravity = function(obj) { var newvel, balls, newpos diff --git a/js/lib/request_anim_shims.js b/js/lib/request_anim_shims.js index 77663ae..67be4e3 100644 --- a/js/lib/request_anim_shims.js +++ b/js/lib/request_anim_shims.js @@ -1,4 +1,6 @@ +'use strict'; + (function() { var fallbackCancelRequestAnimationFrame, fallbackRequestAnimationFrame, diff --git a/js/lib/util.js b/js/lib/util.js index 8c0d10b..b3dc8f9 100644 --- a/js/lib/util.js +++ b/js/lib/util.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; -var util = (function () { +window.util = (function () { var util = {}, rand = {}, arr = {}, diff --git a/js/lib/valentine_ext.js b/js/lib/valentine_ext.js index 8638909..450a9b3 100644 --- a/js/lib/valentine_ext.js +++ b/js/lib/valentine_ext.js @@ -1,4 +1,6 @@ +'use strict'; + // Zip together multiple lists into a single array -- elements that share // an index go together. // Taken from Underscore diff --git a/js/lib/vec2.js b/js/lib/vec2.js index d6392ad..15036b4 100644 --- a/js/lib/vec2.js +++ b/js/lib/vec2.js @@ -1,8 +1,10 @@ +'use strict'; + // The idea for the third argument to the operations comes from: // http://media.tojicode.com/sfjs-vectors/#31 -var Vec2 = function (x, y) { +window.Vec2 = function (x, y) { // TODO: Use a Int16Array? return [x, y] }