Permalink
Browse files

moved over backbone.binding

  • Loading branch information...
1 parent 860359d commit e731c9783cc9cf5c4b244af020ff34c95576a502 @hunterloftis committed May 17, 2012
Showing with 72 additions and 57 deletions.
  1. +5 −5 Makefile
  2. +20 −0 backbone.binding.coffee
  3. +0 −26 backbone.binding.js
  4. +47 −26 lib/backbone.binding.js
View
@@ -16,15 +16,15 @@ dist: js
http://closure-compiler.appspot.com/compile \
> $(OUT)
-clean:
- rm -rf dist/*
- rm -rf lib/*
-
test: js
open test/test.html
-js:
+js: clean
coffee --output lib --compile .
cp *.js lib
+clean:
+ rm -rf dist/*
+ rm -rf lib/*
+
.PHONY: dist clean test js
View
@@ -0,0 +1,20 @@
+do (Backbone) ->
+
+ class Backbone.Binding
+ constructor: (description) ->
+ _.extend(this, description)
+ @initialize(description.args...)
+
+ initialize: =>
+ onModelChange: =>
+ onCollectionChange: =>
+ onViewChange: =>
+
+ start: =>
+ @viewModel.on('change:' + @attribute, @onModelChange)
+ @onModelChange()
+
+ stop: =>
+ @viewModel.off('change:' + @attribute, @onModelChange)
+
+ Backbone.Binding.extend = Backbone.Model.extend
View
@@ -1,26 +0,0 @@
-(function(Backbone) {
-
- // Generic Binding (all bindings inherit from this)
- // description is an object with: node, viewModel, args, type
- Backbone.Binding = function(description) {
- _.bindAll(this);
- _.extend(this, description);
- this.initialize.apply(this, description.args);
- };
-
- _.extend(Backbone.Binding.prototype, {
- initialize: function() {},
- start: function() {
- this.viewModel.on('change:' + this.attribute, this.onModelChange);
- this.onModelChange();
- },
- onModelChange: function() {},
- onViewChange: function() {},
- stop: function() {
- this.viewModel.off('change:' + this.attribute, this.onModelChange);
- }
- });
-
- Backbone.Binding.extend = Backbone.Model.extend;
-
-})(Backbone);
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit e731c97

Please sign in to comment.