Download:
child 96:5e7f52c8da36
parent 94:6a0b2fa39927
95:ba60cdc7a535
Anton Shestakov <av6@dwimlabs.net>, Thu, 30 Jun 2016 21:47:54 +0800
static: update bundled backbone.shard.js

1 файлов изменено, 17 вставок(+), 15 удалений(-) [+]
static/js/backbone.shard.js file | annotate | diff | comparison | revisions
--- a/static/js/backbone.shard.js Mon Jun 27 18:13:01 2016 +0800
+++ b/static/js/backbone.shard.js Thu Jun 30 21:47:54 2016 +0800
@@ -1,19 +1,19 @@
/*
* backbone.shard.js.
- *
- * (c) 2013 Anton Shestakov.
- *
+ *
+ * (c) 2013, 2016 Anton Shestakov.
+ *
* This extension to Backbone may be freely distributed
* under the MIT license:
- * http://opensource.org/licenses/mit-license.php
+ * https://opensource.org/licenses/MIT
*/
Backbone.Shard = function(options) {
this._collection = options.collection;
this._filter = options.filter;
-
+
this.models = this._collection.filter(this._filter);
-
+
this._collection
.on('all', function(event, model) {
if (event == 'change') {
@@ -48,25 +48,27 @@
this.models = this._collection.filter(this._filter);
this.trigger('reset');
}, this);
-
+
this.initialize.apply(this, arguments);
};
_.extend(Backbone.Shard.prototype, Backbone.Events, {
initialize: function() {},
-
+
pluck: function(attr) {
return _.map(this.models, function(model) { return model.get(attr); });
}
});
// Underscore methods that we want to implement on the Shard.
-var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
- 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
- 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
- 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
- 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf',
- 'isEmpty', 'chain'];
+var methods = [
+ 'all', 'any', 'chain', 'collect', 'contains', 'detect', 'difference',
+ 'drop', 'each', 'every', 'filter', 'find', 'findIndex', 'findLastIndex',
+ 'first', 'foldl', 'foldr', 'forEach', 'head', 'include', 'includes',
+ 'indexOf', 'initial', 'inject', 'invoke', 'isEmpty', 'last', 'lastIndexOf',
+ 'map', 'max', 'min', 'reduce', 'reduceRight', 'reject', 'rest', 'sample',
+ 'select', 'shuffle', 'size', 'some', 'tail', 'take', 'toArray', 'without'
+];
// Mix in each Underscore method as a proxy to `Shard#models`.
_.each(methods, function(method) {
@@ -78,7 +80,7 @@
});
// Underscore methods that take a property name as an argument.
-var attributeMethods = ['groupBy', 'countBy', 'sortBy'];
+var attributeMethods = ['countBy', 'groupBy', 'indexBy', 'sortBy'];
// Use attributes instead of properties.
_.each(attributeMethods, function(method) {