backbone_extensions 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,30 +1,30 @@
|
|
1
1
|
(function(_, Backbone) {
|
2
2
|
'use strict';
|
3
3
|
function bindModelEvents(tuple) {
|
4
|
-
var self = this, subject = tuple[0], isJquery = !!_(subject).result('jquery'),
|
4
|
+
var self = this, subject = tuple[0], eventNames = tuple[1], isJquery = !!_(subject).result('jquery'),
|
5
|
+
modelEvents = self._modelCallbacks, context = tuple[2];
|
5
6
|
modelEvents.push(tuple);
|
6
7
|
|
7
8
|
_(subject && eventNames).each(function(callback, event) {
|
8
9
|
_(event.split(' ')).each(function(e) {
|
9
10
|
_([callback]).chain().flatten().each(function(c) {
|
10
|
-
|
11
|
+
var fn = _(c).isFunction() ? c : self[c];
|
11
12
|
if (isJquery) {
|
12
|
-
|
13
|
+
if (context) {
|
14
|
+
subject.on(e, context, fn);
|
15
|
+
} else {
|
16
|
+
subject.on(e, fn);
|
17
|
+
}
|
13
18
|
} else {
|
14
|
-
subject.on(e,
|
19
|
+
subject.on(e, fn, context);
|
15
20
|
}
|
16
|
-
} else {
|
17
|
-
if (!isJquery) {
|
18
|
-
subject.on(e, self[c], self);
|
19
|
-
}
|
20
|
-
}
|
21
21
|
});
|
22
22
|
});
|
23
23
|
});
|
24
24
|
}
|
25
25
|
|
26
26
|
function unbindModelEvents() {
|
27
|
-
var self = this, modelEvents = self.
|
27
|
+
var self = this, modelEvents = self._modelCallbacks;
|
28
28
|
_(modelEvents).each(function(tuple) {
|
29
29
|
var subject = tuple[0], events = tuple[1];
|
30
30
|
|
@@ -54,7 +54,7 @@
|
|
54
54
|
included: function(source) {
|
55
55
|
_(source.prototype).extend({
|
56
56
|
initialize: _(source.prototype.initialize).wrap(function(oldInitialize, attrsOrModels, options) {
|
57
|
-
this.
|
57
|
+
this._modelCallbacks = [];
|
58
58
|
oldInitialize.call(this, attrsOrModels, options);
|
59
59
|
}),
|
60
60
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backbone_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -126,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
segments:
|
128
128
|
- 0
|
129
|
-
hash:
|
129
|
+
hash: 3574570062899009095
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
none: false
|
132
132
|
requirements:
|
@@ -135,10 +135,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
segments:
|
137
137
|
- 0
|
138
|
-
hash:
|
138
|
+
hash: 3574570062899009095
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 1.8.
|
141
|
+
rubygems_version: 1.8.21
|
142
142
|
signing_key:
|
143
143
|
specification_version: 3
|
144
144
|
summary: Extensions to backbone javascript library as a rails engine
|