js_stack 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +3 -3
- data/lib/js_stack/version.rb +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/backbone/associations/{0.6.1.js → 0.6.2.js} +232 -126
- data/vendor/assets/javascripts/js_stack/plugins/backbone/paginator/{2.0.0.js → 2.0.1.js} +13 -2
- data/vendor/assets/javascripts/js_stack/plugins/backbone.associations.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/backbone.paginator.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/cocktail/{0.5.3.js → 0.5.8.js} +14 -12
- data/vendor/assets/javascripts/js_stack/plugins/cocktail.js +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcee6f489f0b24c8b69b1eac5dec1b29be4f7484
|
4
|
+
data.tar.gz: ce93f0127c785c3d511fb012099e4c75ff122637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a4cf05e07abc47e36a01c25aa2d15d1ea533ad84d37a1d129f1ee983f805874df33f72dce9f749c250624431cef5b90848d54072ef6f378b8d6245b58ab5d6d
|
7
|
+
data.tar.gz: 1a1b808931ae8919670a58b211f92ce94dc427f3ddd6d870a73f8392be6dc2f7ec399d4bff46ae5f61b7268831c00c748c7998c5d50ee5ab288553d8e1dd2dfa
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -62,16 +62,16 @@ Examples:
|
|
62
62
|
|
63
63
|
| Library | Versions | Changelog | Homepage | Default |
|
64
64
|
| :-----: | :------: | :-------: | :------: | :-----: |
|
65
|
-
| backbone associations | **0.6.
|
65
|
+
| backbone associations | **0.6.2**, 0.5.5 | [changelog](https://github.com/dhruvaray/backbone-associations/blob/master/CHANGELOG.md) | [homepage](http://dhruvaray.github.io/backbone-associations/) | Yes
|
66
66
|
| backbone deepmodel | **0.10.4** | [changelog](https://github.com/powmedia/backbone-deep-model#changelog) | [homepage](https://github.com/powmedia/backbone-deep-model) | Yes
|
67
67
|
| backbone mutators | **0.4.2** | [changelog](https://github.com/asciidisco/Backbone.Mutators#changelog) | [homepage](https://github.com/asciidisco/Backbone.Mutators) | No
|
68
68
|
| backbone pageable | **1.4.8**, 1.3.2 | [changelog](https://github.com/backbone-paginator/backbone-pageable#change-log) | [homepage](https://github.com/wyuenho/backbone-pageable) | Yes
|
69
|
-
| backbone paginator | **2.0.
|
69
|
+
| backbone paginator | **2.0.1** | [changelog](https://github.com/backbone-paginator/backbone.paginator/wiki/Changelog) | [homepage](https://github.com/backbone-paginator/backbone.paginator) | No
|
70
70
|
| backbone routefilter | **0.2.1** | [changelog](https://github.com/boazsender/backbone.routefilter#release-history) | [homepage](https://github.com/boazsender/backbone.routefilter) | No
|
71
71
|
| backbone stickit | **0.8.0**, 0.7.0, 0.6.3 | [changelog](http://nytimes.github.io/backbone.stickit/#change-log) | [homepage](http://nytimes.github.io/backbone.stickit/) | Yes
|
72
72
|
| backbone validation | **0.9.1**, 0.8.1 | [changelog](https://github.com/thedersen/backbone.validation#release-notes) | [homepage](https://github.com/thedersen/backbone.validation) | Yes
|
73
73
|
| backbone virtualcollection | **0.4.15** | [changelog](https://github.com/p3drosola/Backbone.VirtualCollection#changelog) | [homepage](https://github.com/p3drosola/Backbone.VirtualCollection) | Yes
|
74
|
-
| cocktail | **0.5.
|
74
|
+
| cocktail | **0.5.8** | none | [homepage](https://github.com/onsi/cocktail) | No
|
75
75
|
| momentjs | **2.7.0** | [changelog](https://github.com/moment/moment/#changelog) | [homepage](https://github.com/derekprior/momentjs-rails) | No
|
76
76
|
| underscore inflections | **0.2.1** | none | [homepage](https://github.com/geetarista/underscore.inflections) | No
|
77
77
|
| underscore string | **2.3.2** | [changelog](https://github.com/epeli/underscore.string#changelog) | [homepage](http://epeli.github.io/underscore.string/) | No
|
data/lib/js_stack/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
//
|
2
|
-
// Backbone-associations.js 0.6.
|
2
|
+
// Backbone-associations.js 0.6.2
|
3
3
|
//
|
4
|
-
// (c)
|
4
|
+
// (c) 2014 Dhruva Ray, Jaynti Kanani, Persistent Systems Ltd.
|
5
5
|
// Backbone-associations may be freely distributed under the MIT license.
|
6
6
|
// For all details and documentation:
|
7
7
|
// https://github.com/dhruvaray/backbone-associations/
|
@@ -51,7 +51,7 @@
|
|
51
51
|
BackboneEvent = Backbone.Events;
|
52
52
|
|
53
53
|
Backbone.Associations = {
|
54
|
-
VERSION: "0.6.
|
54
|
+
VERSION: "0.6.2"
|
55
55
|
};
|
56
56
|
|
57
57
|
// Alternative scopes other than root
|
@@ -108,6 +108,13 @@
|
|
108
108
|
// and prevent redundant event to be triggered in case of cyclic model graphs.
|
109
109
|
_proxyCalls:undefined,
|
110
110
|
|
111
|
+
// Override constructor to set parents
|
112
|
+
constructor: function (attributes, options) {
|
113
|
+
// Set parent's opportunistically.
|
114
|
+
options && options.__parents__ && (this.parents = [options.__parents__]);
|
115
|
+
BackboneModel.apply(this, arguments);
|
116
|
+
},
|
117
|
+
|
111
118
|
on: function (name, callback, context) {
|
112
119
|
|
113
120
|
var result = BackboneEvent.on.apply(this, arguments);
|
@@ -169,8 +176,10 @@
|
|
169
176
|
|
170
177
|
// Get the value of an attribute.
|
171
178
|
get:function (attr) {
|
172
|
-
var
|
173
|
-
|
179
|
+
var cache = this.__attributes__,
|
180
|
+
val = ModelProto.get.call(this, attr),
|
181
|
+
obj = cache ? (isValuePresent(val) ? val : cache[attr]) : val;
|
182
|
+
return isValuePresent(obj) ? obj : this._getAttr.apply(this, arguments);
|
174
183
|
},
|
175
184
|
|
176
185
|
// Set a hash of model attributes on the Backbone Model.
|
@@ -196,6 +205,10 @@
|
|
196
205
|
_set:function (attributes, options) {
|
197
206
|
var attr, modelMap, modelId, obj, result = this;
|
198
207
|
if (!attributes) return this;
|
208
|
+
|
209
|
+
// temp cache of attributes
|
210
|
+
this.__attributes__ = attributes;
|
211
|
+
|
199
212
|
for (attr in attributes) {
|
200
213
|
//Create a map for each unique object whose attributes we want to set
|
201
214
|
modelMap || (modelMap = {});
|
@@ -203,8 +216,9 @@
|
|
203
216
|
var pathTokens = getPathArray(attr), initials = _.initial(pathTokens),
|
204
217
|
last = pathTokens[pathTokens.length - 1],
|
205
218
|
parentModel = this.get(initials);
|
206
|
-
if (parentModel instanceof
|
207
|
-
obj = modelMap[parentModel.cid] ||
|
219
|
+
if (parentModel instanceof BackboneModel) {
|
220
|
+
obj = modelMap[parentModel.cid] ||
|
221
|
+
(modelMap[parentModel.cid] = {'model': parentModel, 'data': {}});
|
208
222
|
obj.data[last] = attributes[attr];
|
209
223
|
}
|
210
224
|
} else {
|
@@ -222,6 +236,9 @@
|
|
222
236
|
} else {
|
223
237
|
result = this._setAttr.call(this, attributes, options);
|
224
238
|
}
|
239
|
+
|
240
|
+
delete this.__attributes__;
|
241
|
+
|
225
242
|
return result;
|
226
243
|
|
227
244
|
},
|
@@ -242,108 +259,90 @@
|
|
242
259
|
// if `relations` are available.
|
243
260
|
_.each(this.relations, function (relation) {
|
244
261
|
var relationKey = relation.key,
|
245
|
-
relatedModel = relation.relatedModel,
|
246
|
-
collectionType = relation.collectionType,
|
247
262
|
activationContext = relation.scope || root,
|
248
|
-
|
263
|
+
relatedModel = this._transformRelatedModel(relation, attributes),
|
264
|
+
collectionType = this._transformCollectionType(relation, relatedModel, attributes),
|
265
|
+
map = _.isString(relation.map) ? map2Scope(relation.map, activationContext) : relation.map,
|
249
266
|
currVal = this.attributes[relationKey],
|
250
267
|
idKey = currVal && currVal.idAttribute,
|
251
268
|
val, relationOptions, data, relationValue, newCtx = false;
|
252
269
|
|
253
|
-
// Call function if relatedModel is implemented as a function
|
254
|
-
if (relatedModel && !(relatedModel.prototype instanceof BackboneModel))
|
255
|
-
relatedModel = _.isFunction(relatedModel) ?
|
256
|
-
relatedModel.call(this, relation, attributes) :
|
257
|
-
relatedModel;
|
258
|
-
|
259
|
-
// Get class if relation and map is stored as a string.
|
260
|
-
if (relatedModel && _.isString(relatedModel)) {
|
261
|
-
relatedModel = (relatedModel === Backbone.Self) ?
|
262
|
-
this.constructor :
|
263
|
-
map2Scope(relatedModel, activationContext);
|
264
|
-
}
|
265
|
-
|
266
|
-
map && _.isString(map) && (map = map2Scope(map, activationContext));
|
267
270
|
// Merge in `options` specific to this relation.
|
268
271
|
relationOptions = relation.options ? _.extend({}, relation.options, options) : options;
|
269
272
|
|
270
273
|
if (attributes[relationKey]) {
|
274
|
+
|
271
275
|
// Get value of attribute with relation key in `val`.
|
272
276
|
val = _.result(attributes, relationKey);
|
277
|
+
|
273
278
|
// Map `val` if a transformation function is provided.
|
274
279
|
val = map ? map.call(this, val, collectionType ? collectionType : relatedModel) : val;
|
280
|
+
if (!isValuePresent(val)) {
|
281
|
+
data = val;
|
282
|
+
} else {
|
283
|
+
// If `relation.type` is `Backbone.Many`,
|
284
|
+
// Create `Backbone.Collection` with passed data and perform Backbone `set`.
|
285
|
+
if (relation.type === Backbone.Many) {
|
275
286
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
if (collectionType && _.isFunction(collectionType) &&
|
281
|
-
(collectionType.prototype instanceof BackboneModel))
|
282
|
-
throw new Error('type is of Backbone.Model. Specify derivatives of Backbone.Collection');
|
283
|
-
|
284
|
-
// Call function if collectionType is implemented as a function
|
285
|
-
if (collectionType && !(collectionType.prototype instanceof BackboneCollection))
|
286
|
-
collectionType = _.isFunction(collectionType) ?
|
287
|
-
collectionType.call(this, relation, attributes) : collectionType;
|
288
|
-
|
289
|
-
collectionType && _.isString(collectionType) &&
|
290
|
-
(collectionType = map2Scope(collectionType, activationContext));
|
291
|
-
|
292
|
-
if ((!relatedModel) && (!collectionType))
|
293
|
-
throw new Error('specify either a relatedModel or collectionType');
|
294
|
-
|
295
|
-
// `collectionType` of defined `relation` should be instance of `Backbone.Collection`.
|
296
|
-
if (collectionType && !collectionType.prototype instanceof BackboneCollection) {
|
297
|
-
throw new Error('collectionType must inherit from Backbone.Collection');
|
298
|
-
}
|
299
|
-
|
300
|
-
if (currVal) {
|
301
|
-
// Setting this flag will prevent events from firing immediately. That way clients
|
302
|
-
// will not get events until the entire object graph is updated.
|
303
|
-
currVal._deferEvents = true;
|
304
|
-
|
305
|
-
// Use Backbone.Collection's `reset` or smart `set` method
|
306
|
-
currVal[relationOptions.reset ? 'reset' : 'set'](
|
307
|
-
val instanceof BackboneCollection ? val.models : val, relationOptions);
|
287
|
+
if (currVal) {
|
288
|
+
// Setting this flag will prevent events from firing immediately. That way clients
|
289
|
+
// will not get events until the entire object graph is updated.
|
290
|
+
currVal._deferEvents = true;
|
308
291
|
|
309
|
-
|
292
|
+
// Use Backbone.Collection's `reset` or smart `set` method
|
293
|
+
currVal[relationOptions.reset ? 'reset' : 'set'](
|
294
|
+
val instanceof BackboneCollection ? val.models : val, relationOptions);
|
310
295
|
|
311
|
-
|
312
|
-
newCtx = true;
|
296
|
+
data = currVal;
|
313
297
|
|
314
|
-
if (val instanceof BackboneCollection) {
|
315
|
-
data = val;
|
316
298
|
} else {
|
317
|
-
|
318
|
-
|
319
|
-
|
299
|
+
newCtx = true;
|
300
|
+
|
301
|
+
if (val instanceof BackboneCollection) {
|
302
|
+
data = val;
|
303
|
+
} else {
|
304
|
+
data = this._createCollection(
|
305
|
+
collectionType || BackboneCollection,
|
306
|
+
relation.collectionOptions || (relatedModel ? {model: relatedModel} : {})
|
307
|
+
);
|
308
|
+
data[relationOptions.reset ? 'reset' : 'set'](val, relationOptions);
|
309
|
+
}
|
320
310
|
}
|
321
|
-
}
|
322
311
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
312
|
+
} else if (relation.type === Backbone.One) {
|
313
|
+
|
314
|
+
var hasOwnProperty = (val instanceof BackboneModel) ?
|
315
|
+
val.attributes.hasOwnProperty(idKey) :
|
316
|
+
val.hasOwnProperty(idKey);
|
317
|
+
var newIdKey = (val instanceof BackboneModel) ?
|
318
|
+
val.attributes[idKey] :
|
319
|
+
val[idKey];
|
320
|
+
|
321
|
+
//Is the passed in data for the same key?
|
322
|
+
if (currVal && hasOwnProperty &&
|
323
|
+
currVal.attributes[idKey] === newIdKey) {
|
324
|
+
// Setting this flag will prevent events from firing immediately. That way clients
|
325
|
+
// will not get events until the entire object graph is updated.
|
326
|
+
currVal._deferEvents = true;
|
327
|
+
// Perform the traditional `set` operation
|
328
|
+
currVal._set(val instanceof BackboneModel ? val.attributes : val, relationOptions);
|
329
|
+
data = currVal;
|
330
|
+
} else {
|
331
|
+
newCtx = true;
|
327
332
|
|
328
|
-
|
329
|
-
|
333
|
+
if (val instanceof BackboneModel) {
|
334
|
+
data = val;
|
335
|
+
} else {
|
336
|
+
relationOptions.__parents__ = this;
|
337
|
+
data = new relatedModel(val, relationOptions);
|
338
|
+
delete relationOptions.__parents__;
|
339
|
+
}
|
330
340
|
|
331
|
-
|
332
|
-
//Is the passed in data for the same key?
|
333
|
-
if (currVal && data.attributes[idKey] &&
|
334
|
-
currVal.attributes[idKey] === data.attributes[idKey]) {
|
335
|
-
// Setting this flag will prevent events from firing immediately. That way clients
|
336
|
-
// will not get events until the entire object graph is updated.
|
337
|
-
currVal._deferEvents = true;
|
338
|
-
// Perform the traditional `set` operation
|
339
|
-
currVal._set(val instanceof AssociatedModel ? val.attributes : val, relationOptions);
|
340
|
-
data = currVal;
|
341
|
+
}
|
341
342
|
} else {
|
342
|
-
|
343
|
+
throw new Error('type attribute must be specified and ' +
|
344
|
+
'have the values Backbone.One or Backbone.Many');
|
343
345
|
}
|
344
|
-
|
345
|
-
} else {
|
346
|
-
throw new Error('type attribute must be specified and have the values Backbone.One or Backbone.Many');
|
347
346
|
}
|
348
347
|
|
349
348
|
|
@@ -353,28 +352,19 @@
|
|
353
352
|
// Add proxy events to respective parents.
|
354
353
|
// Only add callback if not defined or new Ctx has been identified.
|
355
354
|
if (newCtx || (relationValue && !relationValue._proxyCallback)) {
|
356
|
-
relationValue._proxyCallback
|
357
|
-
|
358
|
-
|
359
|
-
|
355
|
+
if(!relationValue._proxyCallback) {
|
356
|
+
relationValue._proxyCallback = function () {
|
357
|
+
return Backbone.Associations.EVENTS_BUBBLE &&
|
358
|
+
this._bubbleEvent.call(this, relationKey, relationValue, arguments);
|
359
|
+
};
|
360
|
+
}
|
360
361
|
relationValue.on("all", relationValue._proxyCallback, this);
|
361
362
|
}
|
362
363
|
|
363
364
|
}
|
364
365
|
//Distinguish between the value of undefined versus a set no-op
|
365
|
-
if (attributes.hasOwnProperty(relationKey))
|
366
|
-
|
367
|
-
var updated = attributes[relationKey];
|
368
|
-
var original = this.attributes[relationKey];
|
369
|
-
if (updated) {
|
370
|
-
updated.parents = updated.parents || [];
|
371
|
-
(_.indexOf(updated.parents, this) == -1) && updated.parents.push(this);
|
372
|
-
} else if (original && original.parents.length > 0) { // New value is undefined
|
373
|
-
original.parents = _.difference(original.parents, [this]);
|
374
|
-
// Don't bubble to this parent anymore
|
375
|
-
original._proxyCallback && original.off("all", original._proxyCallback, this);
|
376
|
-
}
|
377
|
-
}
|
366
|
+
if (attributes.hasOwnProperty(relationKey))
|
367
|
+
this._setupParents(attributes[relationKey], this.attributes[relationKey]);
|
378
368
|
}, this);
|
379
369
|
}
|
380
370
|
// Return results for `BackboneModel.set`.
|
@@ -484,18 +474,27 @@
|
|
484
474
|
});
|
485
475
|
},
|
486
476
|
|
487
|
-
//
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
477
|
+
//Maintain reverse pointers - a.k.a parents
|
478
|
+
_setupParents: function (updated, original) {
|
479
|
+
// Set new parent for updated
|
480
|
+
if (updated) {
|
481
|
+
updated.parents = updated.parents || [];
|
482
|
+
(_.indexOf(updated.parents, this) == -1) && updated.parents.push(this);
|
483
|
+
}
|
484
|
+
// Remove `this` from the earlier set value's parents (if the new value is different).
|
485
|
+
if (original && original.parents.length > 0 && original != updated) {
|
486
|
+
original.parents = _.difference(original.parents, [this]);
|
487
|
+
// Don't bubble to this parent anymore
|
488
|
+
original._proxyCallback && original.off("all", original._proxyCallback, this);
|
497
489
|
}
|
498
|
-
|
490
|
+
},
|
491
|
+
|
492
|
+
// Returns new `collection` (or derivatives) of type `options.model`.
|
493
|
+
_createCollection: function (type, options) {
|
494
|
+
options = _.defaults(options, {model: type.model});
|
495
|
+
var c = new type([], _.isFunction(options) ? options.call(this) : options);
|
496
|
+
c.parents = [this];
|
497
|
+
return c;
|
499
498
|
},
|
500
499
|
|
501
500
|
// Process all pending events after the entire object graph has been updated
|
@@ -515,13 +514,78 @@
|
|
515
514
|
// Traverse down the object graph and call process pending events on sub-trees
|
516
515
|
_.each(this.relations, function (relation) {
|
517
516
|
var val = this.attributes[relation.key];
|
518
|
-
val && val._processPendingEvents();
|
517
|
+
val && val._processPendingEvents && val._processPendingEvents();
|
519
518
|
}, this);
|
520
519
|
|
521
520
|
delete this._processedEvents;
|
522
521
|
}
|
523
522
|
},
|
524
523
|
|
524
|
+
// Process the raw `relatedModel` value set in a relation
|
525
|
+
_transformRelatedModel: function (relation, attributes) {
|
526
|
+
|
527
|
+
var relatedModel = relation.relatedModel;
|
528
|
+
var activationContext = relation.scope || root;
|
529
|
+
|
530
|
+
// Call function if relatedModel is implemented as a function
|
531
|
+
if (relatedModel && !(relatedModel.prototype instanceof BackboneModel))
|
532
|
+
relatedModel = _.isFunction(relatedModel) ?
|
533
|
+
relatedModel.call(this, relation, attributes) :
|
534
|
+
relatedModel;
|
535
|
+
|
536
|
+
// Get class if relation and map is stored as a string.
|
537
|
+
if (relatedModel && _.isString(relatedModel)) {
|
538
|
+
relatedModel = (relatedModel === Backbone.Self) ?
|
539
|
+
this.constructor :
|
540
|
+
map2Scope(relatedModel, activationContext);
|
541
|
+
}
|
542
|
+
|
543
|
+
// Error checking
|
544
|
+
if (relation.type === Backbone.One) {
|
545
|
+
|
546
|
+
if (!relatedModel)
|
547
|
+
throw new Error('specify a relatedModel for Backbone.One type');
|
548
|
+
|
549
|
+
if (!(relatedModel.prototype instanceof Backbone.Model))
|
550
|
+
throw new Error('specify an AssociatedModel or Backbone.Model for Backbone.One type');
|
551
|
+
}
|
552
|
+
|
553
|
+
return relatedModel;
|
554
|
+
},
|
555
|
+
|
556
|
+
// Process the raw `collectionType` value set in a relation
|
557
|
+
_transformCollectionType: function (relation, relatedModel, attributes) {
|
558
|
+
|
559
|
+
var collectionType = relation.collectionType;
|
560
|
+
var activationContext = relation.scope || root;
|
561
|
+
|
562
|
+
if (collectionType && _.isFunction(collectionType) &&
|
563
|
+
(collectionType.prototype instanceof BackboneModel))
|
564
|
+
throw new Error('type is of Backbone.Model. Specify derivatives of Backbone.Collection');
|
565
|
+
|
566
|
+
// Call function if collectionType is implemented as a function
|
567
|
+
if (collectionType && !(collectionType.prototype instanceof BackboneCollection))
|
568
|
+
collectionType = _.isFunction(collectionType) ?
|
569
|
+
collectionType.call(this, relation, attributes) : collectionType;
|
570
|
+
|
571
|
+
collectionType && _.isString(collectionType) &&
|
572
|
+
(collectionType = map2Scope(collectionType, activationContext));
|
573
|
+
|
574
|
+
// `collectionType` of defined `relation` should be instance of `Backbone.Collection`.
|
575
|
+
if (collectionType && !collectionType.prototype instanceof BackboneCollection) {
|
576
|
+
throw new Error('collectionType must inherit from Backbone.Collection');
|
577
|
+
}
|
578
|
+
|
579
|
+
// Error checking
|
580
|
+
if (relation.type === Backbone.Many) {
|
581
|
+
if ((!relatedModel) && (!collectionType))
|
582
|
+
throw new Error('specify either a relatedModel or collectionType');
|
583
|
+
}
|
584
|
+
|
585
|
+
return collectionType;
|
586
|
+
|
587
|
+
},
|
588
|
+
|
525
589
|
// Override trigger to defer events in the object graph.
|
526
590
|
trigger:function (name) {
|
527
591
|
// Defer event processing
|
@@ -555,7 +619,8 @@
|
|
555
619
|
remoteKey = relation.remoteKey,
|
556
620
|
attr = this.attributes[key],
|
557
621
|
serialize = !relation.isTransient,
|
558
|
-
serialize_keys = relation.serialize || []
|
622
|
+
serialize_keys = relation.serialize || [],
|
623
|
+
_options = _.clone(options);
|
559
624
|
|
560
625
|
// Remove default Backbone serialization for associations.
|
561
626
|
delete json[key];
|
@@ -566,12 +631,12 @@
|
|
566
631
|
|
567
632
|
// Pass the keys to serialize as options to the toJSON method.
|
568
633
|
if (serialize_keys.length) {
|
569
|
-
|
570
|
-
(
|
571
|
-
(
|
634
|
+
_options ?
|
635
|
+
(_options.serialize_keys = serialize_keys) :
|
636
|
+
(_options = {serialize_keys: serialize_keys})
|
572
637
|
}
|
573
638
|
|
574
|
-
aJson = attr && attr.toJSON ? attr.toJSON(
|
639
|
+
aJson = attr && attr.toJSON ? attr.toJSON(_options) : attr;
|
575
640
|
json[remoteKey || key] = _.isArray(aJson) ? _.compact(aJson) : aJson;
|
576
641
|
}
|
577
642
|
|
@@ -591,18 +656,51 @@
|
|
591
656
|
// Call this if you want to set an `AssociatedModel` to a falsy value like undefined/null directly.
|
592
657
|
// Not calling this will leak memory and have wrong parents.
|
593
658
|
// See test case "parent relations"
|
594
|
-
cleanup:function () {
|
659
|
+
cleanup:function (options) {
|
660
|
+
options = options || {};
|
661
|
+
|
595
662
|
_.each(this.relations, function (relation) {
|
596
663
|
var val = this.attributes[relation.key];
|
597
|
-
|
664
|
+
if(val) {
|
665
|
+
val._proxyCallback && val.off("all", val._proxyCallback, this);
|
666
|
+
val.parents = _.difference(val.parents, [this]);
|
667
|
+
}
|
598
668
|
}, this);
|
599
|
-
|
669
|
+
|
670
|
+
(!options.listen) && this.off();
|
671
|
+
},
|
672
|
+
|
673
|
+
// Override destroy to perform house-keeping on `parents` collection
|
674
|
+
destroy: function(options) {
|
675
|
+
options = options ? _.clone(options) : {};
|
676
|
+
options = _.defaults(options, {remove_references: true, listen: true});
|
677
|
+
var model = this;
|
678
|
+
|
679
|
+
if(options.remove_references && options.wait) {
|
680
|
+
// Proxy success implementation
|
681
|
+
var success = options.success;
|
682
|
+
|
683
|
+
// Substitute with an implementation which will remove references to `model`
|
684
|
+
options.success = function (resp) {
|
685
|
+
if (success) success(model, resp, options);
|
686
|
+
model.cleanup(options);
|
687
|
+
}
|
688
|
+
}
|
689
|
+
// Call the base implementation
|
690
|
+
var xhr = ModelProto.destroy.apply(this, [options]);
|
691
|
+
|
692
|
+
if(options.remove_references && !options.wait) {
|
693
|
+
model.cleanup(options);
|
694
|
+
}
|
695
|
+
|
696
|
+
return xhr;
|
600
697
|
},
|
601
698
|
|
602
699
|
// Navigate the path to the leaf object in the path to query for the attribute value
|
603
700
|
_getAttr:function (path) {
|
604
701
|
|
605
702
|
var result = this,
|
703
|
+
cache = this.__attributes__,
|
606
704
|
//Tokenize the path
|
607
705
|
attrs = getPathArray(path),
|
608
706
|
key,
|
@@ -614,7 +712,10 @@
|
|
614
712
|
//Navigate the path to get to the result
|
615
713
|
result = result instanceof BackboneCollection
|
616
714
|
? (isNaN(key) ? undefined : result.at(key))
|
617
|
-
:
|
715
|
+
: (cache ?
|
716
|
+
(isValuePresent(result.attributes[key]) ? result.attributes[key] : cache[key]) :
|
717
|
+
result.attributes[key]
|
718
|
+
);
|
618
719
|
}
|
619
720
|
return result;
|
620
721
|
}
|
@@ -631,7 +732,7 @@
|
|
631
732
|
|
632
733
|
if (!path) return path;
|
633
734
|
|
634
|
-
//event_type:<path>
|
735
|
+
// event_type:<path>
|
635
736
|
var tokens = path.split(":");
|
636
737
|
|
637
738
|
if (tokens.length > 1) {
|
@@ -649,7 +750,7 @@
|
|
649
750
|
var target,
|
650
751
|
scopes = [context];
|
651
752
|
|
652
|
-
//Check global scopes after passed-in context
|
753
|
+
// Check global scopes after passed-in context
|
653
754
|
scopes.push.apply(scopes, Backbone.Associations.scopes);
|
654
755
|
|
655
756
|
for (var ctx, i = 0, l = scopes.length; i < l; ++i) {
|
@@ -664,7 +765,7 @@
|
|
664
765
|
};
|
665
766
|
|
666
767
|
|
667
|
-
//Infer the relation from the collection's parents and find the appropriate map for the passed in `models`
|
768
|
+
// Infer the relation from the collection's parents and find the appropriate map for the passed in `models`
|
668
769
|
var map2models = function (parents, target, models) {
|
669
770
|
var relation, surrogate;
|
670
771
|
//Iterate over collection's parents
|
@@ -686,6 +787,11 @@
|
|
686
787
|
return models;
|
687
788
|
};
|
688
789
|
|
790
|
+
// Utility method to check for null or undefined value
|
791
|
+
var isValuePresent = function (value) {
|
792
|
+
return (!_.isUndefined(value)) && (!_.isNull(value));
|
793
|
+
};
|
794
|
+
|
689
795
|
var proxies = {};
|
690
796
|
// Proxy Backbone collection methods
|
691
797
|
_.each(['set', 'remove', 'reset'], function (method) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
backbone.paginator 2.0.
|
2
|
+
backbone.paginator 2.0.1
|
3
3
|
http://github.com/backbone-paginator/backbone.paginator
|
4
4
|
|
5
5
|
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors
|
@@ -470,6 +470,10 @@
|
|
470
470
|
pageCol.push(nextModel, {onRemove: true});
|
471
471
|
});
|
472
472
|
}
|
473
|
+
else if (!pageCol.length && state.totalRecords) {
|
474
|
+
pageCol.reset(fullCol.models.slice(pageStart - pageSize, pageEnd - pageSize),
|
475
|
+
_extend({}, options, {parse: false}));
|
476
|
+
}
|
473
477
|
fullCol.remove(model);
|
474
478
|
}
|
475
479
|
else if (removedIndex >= pageStart && removedIndex < pageEnd) {
|
@@ -479,6 +483,10 @@
|
|
479
483
|
});
|
480
484
|
}
|
481
485
|
pageCol.remove(model);
|
486
|
+
if (!pageCol.length && state.totalRecords) {
|
487
|
+
pageCol.reset(fullCol.models.slice(pageStart - pageSize, pageEnd - pageSize),
|
488
|
+
_extend({}, options, {parse: false}));
|
489
|
+
}
|
482
490
|
}
|
483
491
|
}
|
484
492
|
else delete options.onAdd;
|
@@ -1148,7 +1156,10 @@
|
|
1148
1156
|
|
1149
1157
|
// fix up sorting parameters
|
1150
1158
|
if (state.sortKey && state.order) {
|
1151
|
-
|
1159
|
+
var o = _isFunction(queryParams.order) ?
|
1160
|
+
queryParams.order.call(thisCopy) :
|
1161
|
+
queryParams.order;
|
1162
|
+
data[o] = this.queryParams.directions[state.order + ""];
|
1152
1163
|
}
|
1153
1164
|
else if (!state.sortKey) delete data[queryParams.order];
|
1154
1165
|
|
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/plugins/backbone/associations/0.6.
|
1
|
+
//= require js_stack/plugins/backbone/associations/0.6.2
|
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/plugins/backbone/paginator/2.0.
|
1
|
+
//= require js_stack/plugins/backbone/paginator/2.0.1
|
@@ -1,19 +1,18 @@
|
|
1
|
-
// Cocktail.js 0.5.
|
1
|
+
// Cocktail.js 0.5.8
|
2
2
|
// (c) 2012 Onsi Fakhouri
|
3
3
|
// Cocktail.js may be freely distributed under the MIT license.
|
4
4
|
// http://github.com/onsi/cocktail
|
5
|
-
(function() {
|
6
|
-
|
7
|
-
|
8
|
-
if (typeof exports !== 'undefined') {
|
9
|
-
Cocktail = exports;
|
5
|
+
(function(factory) {
|
6
|
+
if (typeof require === 'function' && typeof module !== 'undefined' && module.exports) {
|
7
|
+
module.exports = factory(require('underscore'));
|
10
8
|
} else if (typeof define === 'function') {
|
11
|
-
define(
|
12
|
-
return Cocktail;
|
13
|
-
});
|
9
|
+
define(['underscore'], factory);
|
14
10
|
} else {
|
15
|
-
this.Cocktail =
|
11
|
+
this.Cocktail = factory(_);
|
16
12
|
}
|
13
|
+
}(function (_) {
|
14
|
+
|
15
|
+
var Cocktail = {};
|
17
16
|
|
18
17
|
Cocktail.mixins = {};
|
19
18
|
|
@@ -35,7 +34,8 @@
|
|
35
34
|
if (obj[key] === value) return;
|
36
35
|
|
37
36
|
if (obj[key]) {
|
38
|
-
|
37
|
+
// Avoid accessing built-in properties like constructor (#39)
|
38
|
+
collisions[key] = collisions.hasOwnProperty(key) ? collisions[key] : [obj[key]];
|
39
39
|
collisions[key].push(value);
|
40
40
|
}
|
41
41
|
obj[key] = value;
|
@@ -98,4 +98,6 @@
|
|
98
98
|
klass.extend = originalExtend;
|
99
99
|
});
|
100
100
|
};
|
101
|
-
|
101
|
+
|
102
|
+
return Cocktail;
|
103
|
+
}));
|
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/plugins/cocktail/0.5.
|
1
|
+
//= require js_stack/plugins/cocktail/0.5.8
|
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: 0.6.
|
4
|
+
version: 0.6.7
|
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: 2014-
|
12
|
+
date: 2014-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml_coffee_assets
|
@@ -128,12 +128,12 @@ files:
|
|
128
128
|
- vendor/assets/javascripts/js_stack/plugins/backbone.validation.js
|
129
129
|
- vendor/assets/javascripts/js_stack/plugins/backbone.virtualcollection.js
|
130
130
|
- vendor/assets/javascripts/js_stack/plugins/backbone/associations/0.5.5.js
|
131
|
-
- vendor/assets/javascripts/js_stack/plugins/backbone/associations/0.6.
|
131
|
+
- vendor/assets/javascripts/js_stack/plugins/backbone/associations/0.6.2.js
|
132
132
|
- vendor/assets/javascripts/js_stack/plugins/backbone/deepmodel/0.10.4.js
|
133
133
|
- vendor/assets/javascripts/js_stack/plugins/backbone/mutators/0.4.2.js
|
134
134
|
- vendor/assets/javascripts/js_stack/plugins/backbone/pageable/1.3.2.js
|
135
135
|
- vendor/assets/javascripts/js_stack/plugins/backbone/pageable/1.4.8.js
|
136
|
-
- vendor/assets/javascripts/js_stack/plugins/backbone/paginator/2.0.
|
136
|
+
- vendor/assets/javascripts/js_stack/plugins/backbone/paginator/2.0.1.js
|
137
137
|
- vendor/assets/javascripts/js_stack/plugins/backbone/routefilter/0.2.1.js
|
138
138
|
- vendor/assets/javascripts/js_stack/plugins/backbone/stickit/0.6.3.js
|
139
139
|
- vendor/assets/javascripts/js_stack/plugins/backbone/stickit/0.7.0.js
|
@@ -142,7 +142,7 @@ files:
|
|
142
142
|
- vendor/assets/javascripts/js_stack/plugins/backbone/validation/0.9.1.js
|
143
143
|
- vendor/assets/javascripts/js_stack/plugins/backbone/virtualcollection/0.4.15.js
|
144
144
|
- vendor/assets/javascripts/js_stack/plugins/cocktail.js
|
145
|
-
- vendor/assets/javascripts/js_stack/plugins/cocktail/0.5.
|
145
|
+
- vendor/assets/javascripts/js_stack/plugins/cocktail/0.5.8.js
|
146
146
|
- vendor/assets/javascripts/js_stack/plugins/moment.js
|
147
147
|
- vendor/assets/javascripts/js_stack/plugins/underscore.inflections.js
|
148
148
|
- vendor/assets/javascripts/js_stack/plugins/underscore.string.js
|