Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moved over backbone.binding

  • Loading branch information...
commit e731c9783cc9cf5c4b244af020ff34c95576a502 1 parent 860359d
@hunterloftis authored
View
10 Makefile
@@ -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
20 backbone.binding.coffee
@@ -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
26 backbone.binding.js
@@ -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
73 lib/backbone.binding.js
@@ -1,26 +1,47 @@
-(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);
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+
+ (function(Backbone) {
+ Backbone.Binding = (function() {
+
+ function Binding(description) {
+ this.stop = __bind(this.stop, this);
+
+ this.start = __bind(this.start, this);
+
+ this.onViewChange = __bind(this.onViewChange, this);
+
+ this.onCollectionChange = __bind(this.onCollectionChange, this);
+
+ this.onModelChange = __bind(this.onModelChange, this);
+
+ this.initialize = __bind(this.initialize, this);
+ _.extend(this, description);
+ this.initialize.apply(this, description.args);
+ }
+
+ Binding.prototype.initialize = function() {};
+
+ Binding.prototype.onModelChange = function() {};
+
+ Binding.prototype.onCollectionChange = function() {};
+
+ Binding.prototype.onViewChange = function() {};
+
+ Binding.prototype.start = function() {
+ this.viewModel.on('change:' + this.attribute, this.onModelChange);
+ return this.onModelChange();
+ };
+
+ Binding.prototype.stop = function() {
+ return this.viewModel.off('change:' + this.attribute, this.onModelChange);
+ };
+
+ return Binding;
+
+ })();
+ return Backbone.Binding.extend = Backbone.Model.extend;
+ })(Backbone);
+
+}).call(this);
Please sign in to comment.
Something went wrong with that request. Please try again.