PageRenderTime 58ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/labs/dependency-examples/backbone_marionette_require/js/collections/TodoList.js

https://github.com/1manStartup/todomvc
JavaScript | 21 lines | 17 code | 4 blank | 0 comment | 0 complexity | 3f52662b4b1b2feab351c14f7745e658 MD5 | raw file
  1. define(['backbone','models/Todo','lib/backbone-localStorage'],function(Backbone,Todo) {
  2. 'use strict';
  3. function isCompleted(todo) { return todo.get('completed'); }
  4. return Backbone.Collection.extend({
  5. model: Todo,
  6. localStorage: new Backbone.LocalStorage('todos-backbone'),
  7. getCompleted: function() {
  8. return this.filter(isCompleted);
  9. },
  10. getActive: function() {
  11. return this.reject(isCompleted);
  12. },
  13. comparator: function( todo ) {
  14. return todo.get('created');
  15. }
  16. });
  17. });