js_stack 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- //= require js_stack/plugins/backbone/virtualcollection/0.6.1
1
+ //= require js_stack/plugins/backbone/virtualcollection/0.6.3
@@ -1,11 +1,16 @@
1
+ (function(root, factory) {
2
+ if (typeof define === 'function' && define.amd) {
3
+ define(['backbone', 'underscore'], factory);
4
+ } else if (typeof exports === 'object') {
5
+ module.exports = factory(require('backbone'), require('underscore'));
6
+ } else {
7
+ root.VirtualCollection = factory(root.Backbone, root._);
8
+ }
9
+ }(this, function(Backbone, _) {
1
10
 
2
- // Available under the MIT License (MIT)
3
-
4
- var VirtualCollection,
5
- Backbone = require('backbone'),
6
- _ = require('underscore');
11
+ // Available under the MIT License (MIT);
7
12
 
8
- VirtualCollection = Backbone.Collection.extend({
13
+ var VirtualCollection = Backbone.VirtualCollection = Backbone.Collection.extend({
9
14
 
10
15
  constructor: function (collection, options) {
11
16
  options = options || {};
@@ -23,6 +28,7 @@ VirtualCollection = Backbone.Collection.extend({
23
28
  this.listenTo(this.collection, 'change', this._onChange);
24
29
  this.listenTo(this.collection, 'reset', this._onReset);
25
30
  this.listenTo(this.collection, 'sort', this._onSort);
31
+ this._proxyParentEvents(['sync', 'request', 'error']);
26
32
 
27
33
  this.initialize.apply(this, arguments);
28
34
  },
@@ -41,9 +47,7 @@ VirtualCollection = Backbone.Collection.extend({
41
47
  },
42
48
 
43
49
  _rebuildIndex: function () {
44
- for(idx in this.models) {
45
- this.models[idx].off('all', this._onAllEvent, this);
46
- }
50
+ _.invoke(this.models, 'off', 'all', this._onAllEvent, this);
47
51
  this._reset();
48
52
  this.collection.each(function (model, i) {
49
53
  if (this.accepts(model, i)) {
@@ -70,6 +74,12 @@ VirtualCollection = Backbone.Collection.extend({
70
74
  this.orderViaParent(options);
71
75
  },
72
76
 
77
+ _proxyParentEvents: function (events) {
78
+ _.each(events, function (eventName) {
79
+ this.listenTo(this.collection, eventName, _.partial(this.trigger, eventName));
80
+ }, this);
81
+ },
82
+
73
83
  _onAdd: function (model, collection, options) {
74
84
  var already_here = this.get(model);
75
85
  if (!already_here && this.accepts(model, options.index)) {
@@ -176,7 +186,7 @@ VirtualCollection = Backbone.Collection.extend({
176
186
  return options;
177
187
  } else if (options.constructor === Object) {
178
188
  return function (model) {
179
- return !Boolean(_(Object.keys(options)).detect(function (key) {
189
+ return !Boolean(_(_.keys(options)).detect(function (key) {
180
190
  return model.get(key) !== options[key];
181
191
  }));
182
192
  };
@@ -207,4 +217,5 @@ function sortedIndexTwo (array, obj, iterator, context) {
207
217
 
208
218
  _.extend(VirtualCollection.prototype, Backbone.Events);
209
219
 
210
- module.exports = VirtualCollection;
220
+ return VirtualCollection;
221
+ }));
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js_stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Pewiński
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-16 00:00:00.000000000 Z
12
+ date: 2015-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml_coffee_assets
@@ -116,6 +116,7 @@ files:
116
116
  - vendor/assets/javascripts/js_stack/base/marionette/2.1.0.js
117
117
  - vendor/assets/javascripts/js_stack/base/marionette/2.2.2.js
118
118
  - vendor/assets/javascripts/js_stack/base/marionette/2.3.2.js
119
+ - vendor/assets/javascripts/js_stack/base/marionette/2.4.1.js
119
120
  - vendor/assets/javascripts/js_stack/base/underscore.js
120
121
  - vendor/assets/javascripts/js_stack/base/underscore/1.5.2.js
121
122
  - vendor/assets/javascripts/js_stack/base/underscore/1.6.0.js
@@ -145,7 +146,7 @@ files:
145
146
  - vendor/assets/javascripts/js_stack/plugins/backbone/validation/0.9.2.js
146
147
  - vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.4.15.js
147
148
  - vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.5.3.js
148
- - vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.6.1.js
149
+ - vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.6.3.js
149
150
  - vendor/assets/javascripts/js_stack/plugins/cocktail.js
150
151
  - vendor/assets/javascripts/js_stack/plugins/cocktail/0.5.10.js
151
152
  - vendor/assets/javascripts/js_stack/plugins/moment.js