Commit c8b4bd92 authored by Aaron Boushley's avatar Aaron Boushley

Change the hiding of the clear completed button to use more proper views and binding.

parent 9a4f81c7
...@@ -396,9 +396,6 @@ body { ...@@ -396,9 +396,6 @@ 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 {
......
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
<!-- Insert this after the CreateTodoView and before the collection. --> <!-- Insert this after the CreateTodoView and before the collection. -->
{{#view Todos.StatsView id="todo-stats" content=this}} {{#view Todos.StatsView id="todo-stats" content=this}}
{{#view Ember.Button target="Todos.todosController" action="clearCompletedTodos" classNameBindings="Todos.todosController.completeClass" content=this}} {{#view Todos.ClearCompletedButtonView target="Todos.todosController" action="clearCompletedTodos" classNameBindings="completedButtonClass"}}
Clear {{content.completedString}} Clear {{completedString}}
{{/view}} {{/view}}
{{remainingString}} left {{remainingString}} left
{{/view}} {{/view}}
......
...@@ -65,12 +65,6 @@ Todos.StatsView = Ember.View.extend({ ...@@ -65,12 +65,6 @@ Todos.StatsView = Ember.View.extend({
var remaining = this.get('remaining'); var remaining = this.get('remaining');
return remaining + (remaining === 1 ? " item" : " items"); return remaining + (remaining === 1 ? " item" : " items");
}.property('remaining'), }.property('remaining'),
completedBinding: 'Todos.todosController.completed',
completedString: function() {
var completed = this.get('completed');
return completed + " completed" + (completed === 1 ? " item" : " items");
}.property('completed')
}); });
Todos.CreateTodoView = Ember.TextField.extend({ Todos.CreateTodoView = Ember.TextField.extend({
...@@ -84,6 +78,21 @@ Todos.CreateTodoView = Ember.TextField.extend({ ...@@ -84,6 +78,21 @@ Todos.CreateTodoView = Ember.TextField.extend({
} }
}); });
Todos.ClearCompletedButtonView = Ember.Button.extend({
completedBinding: 'Todos.todosController.completed',
completedString: function() {
var completed = this.get('completed');
return completed + " completed" + (completed === 1 ? " item" : " items");
}.property('completed'),
completedButtonClass: function () {
if (this.get('completed') < 1)
return 'hidden';
else
return '';
}.property('completed')
});
Todos.TodoStore = (function () { Todos.TodoStore = (function () {
// Generate four random hex digits. // Generate four random hex digits.
var S4 = function () { var S4 = function () {
......
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