Explorar o código

make todomvc example work with new exp splitter

Evan You %!s(int64=12) %!d(string=hai) anos
pai
achega
5f9b61b0dc
Modificáronse 2 ficheiros con 12 adicións e 8 borrados
  1. 3 3
      examples/todomvc/index.html
  2. 9 5
      examples/todomvc/js/app.js

+ 3 - 3
examples/todomvc/index.html

@@ -28,8 +28,8 @@
                     <li
                         class="todo"
                         sd-repeat="todo:todos"
-                        sd-if="todoFilter(todo)"
-                        sd-class="completed:todo.completed, editing:todo == editedTodo"
+                        sd-if="todoFilter(todo.completed)"
+                        sd-class="completed:todo.completed & editing:todo == editedTodo"
                     >
                         <div class="view">
                             <input
@@ -44,7 +44,7 @@
                         <input
                             class="edit"
                             type="text"
-                            sd-on="blur:doneEdit, keyup:doneEdit | key enter, keyup:cancelEdit | key esc"
+                            sd-on="blur:doneEdit & keyup:doneEdit | key enter & keyup:cancelEdit | key esc"
                             sd-model="todo.title"
                             sd-todo-focus="todo == editedTodo"
                         >

+ 9 - 5
examples/todomvc/js/app.js

@@ -1,7 +1,7 @@
 var filters = {
-    all: function (todo) { return todo.completed || true },
-    active: function (todo) { return !todo.completed },
-    completed: function (todo) { return todo.completed }
+    all: function () { return true },
+    active: function (completed) { return !completed },
+    completed: function (completed) { return completed }
 }
 
 Seed.directive('todo-focus', function (value) {
@@ -16,8 +16,10 @@ var app = new Seed({
     el: '#todoapp',
 
     init: function () {
-        this.remaining = this.todos.filter(filters.active).length
         this.updateFilter()
+        this.remaining = this.todos.filter(function (todo) {
+            return !todo.completed
+        }).length
     },
 
     scope: {
@@ -70,7 +72,9 @@ var app = new Seed({
         },
 
         removeCompleted: function () {
-            this.todos.mutateFilter(filters.active)
+            this.todos.mutateFilter(function (todo) {
+                return !todo.completed
+            })
             todoStorage.save()
         },