Commit 85c49e18 authored by Addy Osmani's avatar Addy Osmani

Merge pull request #46 from boushley/emberjs

Ember.js Clear Completed Tasks Update
parents 495a9aac 9a4f81c7
...@@ -249,7 +249,7 @@ body { ...@@ -249,7 +249,7 @@ body {
margin: 0 10px 0 7px; margin: 0 10px 0 7px;
float: left; float: left;
} }
#todo-list .done .todo-content { #todo-list .is-done label {
text-decoration: line-through; text-decoration: line-through;
color: #777777; color: #777777;
} }
...@@ -396,6 +396,10 @@ body { ...@@ -396,6 +396,10 @@ body {
border:0px; border:0px;
} }
#todoapp #todo-stats button.none-completed {
display: none;
}
/* line 136 */ /* line 136 */
#todoapp #todo-stats button:hover, #todoapp #todo-stats button:focus { #todoapp #todo-stats button:hover, #todoapp #todo-stats button:focus {
background: rgba(0, 0, 0, 0.15); background: rgba(0, 0, 0, 0.15);
......
...@@ -45,14 +45,13 @@ ...@@ -45,14 +45,13 @@
{{#view id="todos"}} {{#view id="todos"}}
{{#collection id="todo-list" contentBinding="Todos.todosController" tagName="ul" itemClassBinding="content.isDone"}} {{#collection id="todo-list" contentBinding="Todos.todosController" tagName="ul" itemClassBinding="content.isDone"}}
{{view Ember.Checkbox titleBinding="content.title" {{view Ember.Checkbox titleBinding="content.title" valueBinding="content.isDone"}}
valueBinding="content.isDone"}}
{{/collection}} {{/collection}}
{{/view}} {{/view}}
<!-- Insert this after the CreateTodoView and before the collection. --> <!-- Insert this after the CreateTodoView and before the collection. -->
{{#view Todos.StatsView id="todo-stats"}} {{#view Todos.StatsView id="todo-stats" content=this}}
{{#view Ember.Button target="Todos.todosController" action="clearCompletedTodos" content=this}} {{#view Ember.Button target="Todos.todosController" action="clearCompletedTodos" classNameBindings="Todos.todosController.completeClass" content=this}}
Clear {{content.completedString}} Clear {{content.completedString}}
{{/view}} {{/view}}
{{remainingString}} left {{remainingString}} left
......
...@@ -52,6 +52,10 @@ Todos.todosController = Ember.ArrayProxy.create({ ...@@ -52,6 +52,10 @@ Todos.todosController = Ember.ArrayProxy.create({
} else { } else {
return !!this.get('length') && this.everyProperty('isDone', true); return !!this.get('length') && this.everyProperty('isDone', true);
} }
}.property('@each.isDone'),
completeClass: function () {
return this.get('completed') < 1 ? 'none-completed' : 'some-completed';
}.property('@each.isDone') }.property('@each.isDone')
}); });
...@@ -155,7 +159,5 @@ Todos.TodoStore = (function () { ...@@ -155,7 +159,5 @@ Todos.TodoStore = (function () {
items = [todo]; items = [todo];
} }
Todos.todosController.arrayContentWillChange(0, 0, items.length);
Todos.todosController.set('[]', items); Todos.todosController.set('[]', items);
Todos.todosController.arrayContentDidChange(0, 0, items.length);
})(); })();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment