--- a/static/js/backbone.shard.js Sat Feb 09 18:06:31 2013 +0900
+++ b/static/js/backbone.shard.js Thu Mar 21 16:04:47 2013 +0900
- * (c) 2012 Anton Shestakov.
+ * (c) 2013 Anton Shestakov.
* This extension to Backbone may be freely distributed
return _.map(this.models, function(model) { return model.get(attr); });
- return _(this.models).chain();
// Underscore methods that we want to implement on the Shard.
-var methods = ['forEach', 'each', 'map', 'reduce', 'reduceRight', 'find',
- 'detect', 'filter', 'select', 'reject', 'every', 'all', 'some', 'any',
- 'include', 'contains', 'invoke', 'max', 'min', 'sortBy', 'sortedIndex',
- 'toArray', 'size', 'first', 'initial', 'rest', 'last', 'without', 'indexOf',
- 'shuffle', 'lastIndexOf', 'isEmpty', 'groupBy'];
+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',
// Mix in each Underscore method as a proxy to `Shard#models`.
_.each(methods, function(method) {
Backbone.Shard.prototype[method] = function() {
- return _[method].apply(_, [this.models].concat(_.toArray(arguments)));
+ var args = Array.prototype.slice.call(arguments);
+ args.unshift(this.models);
+ return _[method].apply(_, args);
+// Underscore methods that take a property name as an argument.
+var attributeMethods = ['groupBy', 'countBy', 'sortBy'];
+// Use attributes instead of properties.
+_.each(attributeMethods, function(method) {
+ Backbone.Shard.prototype[method] = function(value, context) {
+ var iterator = _.isFunction(value) ? value : function(model) {
+ return model.get(value);
+ return _[method](this.models, iterator, context);
--- a/static/js/ui.js Sat Feb 09 18:06:31 2013 +0900
+++ b/static/js/ui.js Thu Mar 21 16:04:47 2013 +0900
- fruitbar.projects.update(data['projects']);
- fruitbar.tasks.update(data['tasks']);
+ fruitbar.projects.set(data['projects']);
+ fruitbar.tasks.set(data['tasks']);
--- a/templates/index.html Sat Feb 09 18:06:31 2013 +0900
+++ b/templates/index.html Thu Mar 21 16:04:47 2013 +0900
<link type="text/css" href="{{ url_for('static', filename='css/custom.css') }}" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
- <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.3/underscore-min.js"></script>
- <script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.9/backbone-min.js"></script>
+ <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
+ <script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
<script src="{{ url_for('static', filename='js/backbone.shard.js') }}"></script>
<script src="{{ url_for('static', filename='js/framework/models.js') }}"></script>