@@ -17,8 +17,8 @@ goog.require('todomvc.todocontrol');
17
17
* @extends {mvc.Control }
18
18
*/
19
19
todomvc . listcontrol = function ( list ) {
20
- goog . base ( this , list ) ;
21
- this . filter_ = todomvc . listcontrol . Filter . ALL ;
20
+ goog . base ( this , list ) ;
21
+ this . filter_ = todomvc . listcontrol . Filter . ALL ;
22
22
} ;
23
23
goog . inherits ( todomvc . listcontrol , mvc . Control ) ;
24
24
@@ -27,9 +27,9 @@ goog.inherits(todomvc.listcontrol, mvc.Control);
27
27
* @enum {Function}
28
28
*/
29
29
todomvc . listcontrol . Filter = {
30
- ALL : function ( ) { return true } ,
31
- ACTIVE : function ( model ) { return ! model . get ( 'completed' ) } ,
32
- COMPLETED : function ( model ) { return model . get ( 'completed' ) }
30
+ ALL : function ( ) { return true } ,
31
+ ACTIVE : function ( model ) { return ! model . get ( 'completed' ) } ,
32
+ COMPLETED : function ( model ) { return model . get ( 'completed' ) }
33
33
} ;
34
34
35
35
@@ -39,77 +39,77 @@ todomvc.listcontrol.Filter = {
39
39
* @inheritDoc
40
40
*/
41
41
todomvc . listcontrol . prototype . enterDocument = function ( ) {
42
- goog . base ( this , 'enterDocument' ) ;
42
+ goog . base ( this , 'enterDocument' ) ;
43
43
44
- var list = /** @type {Object } */ ( this . getModel ( ) ) ;
44
+ var list = /** @type {Object } */ ( this . getModel ( ) ) ;
45
45
46
- // create new model from text box
47
- var input = this . getEls ( 'input' ) [ 0 ] ;
48
- this . on ( goog . events . EventType . KEYUP , function ( e ) {
46
+ // create new model from text box
47
+ var input = this . getEls ( 'input' ) [ 0 ] ;
48
+ this . on ( goog . events . EventType . KEYUP , function ( e ) {
49
49
50
- // on return get trimmed text
51
- if ( e . keyCode !== goog . events . KeyCodes . ENTER ) return ;
50
+ // on return get trimmed text
51
+ if ( e . keyCode !== goog . events . KeyCodes . ENTER ) return ;
52
52
53
- var text = goog . string . trim ( input . value ) ;
54
- if ( text === '' ) return ;
53
+ var text = goog . string . trim ( input . value ) ;
54
+ if ( text === '' ) return ;
55
55
56
- //create new model
57
- list . newModel ( { 'title' : text } ) ;
56
+ //create new model
57
+ list . newModel ( { 'title' : text } ) ;
58
58
59
- input . value = '' ;
59
+ input . value = '' ;
60
60
61
- } , 'todo-entry' ) ;
61
+ } , 'todo-entry' ) ;
62
62
63
- // clear completed
64
- this . click ( function ( e ) {
65
- goog . array . forEach ( list . get ( 'completed' ) , function ( model ) {
66
- model . dispose ( ) ;
67
- } ) ;
68
- } , 'clear-completed' ) ;
63
+ // clear completed
64
+ this . click ( function ( e ) {
65
+ goog . array . forEach ( list . get ( 'completed' ) , function ( model ) {
66
+ model . dispose ( ) ;
67
+ } ) ;
68
+ } , 'clear-completed' ) ;
69
69
70
- // toggle completed
71
- this . click ( function ( e ) {
72
- var checked = e . target . checked ;
73
- goog . array . forEach ( list . getModels ( ) , function ( model ) {
74
- model . set ( 'completed' , checked ) ;
75
- } ) ;
76
- } , 'toggle-all' ) ;
70
+ // toggle completed
71
+ this . click ( function ( e ) {
72
+ var checked = e . target . checked ;
73
+ goog . array . forEach ( list . getModels ( ) , function ( model ) {
74
+ model . set ( 'completed' , checked ) ;
75
+ } ) ;
76
+ } , 'toggle-all' ) ;
77
77
78
- // refresh the view on changes that effect the models order
79
- this . anyModelChange ( function ( ) {
80
- this . refresh ( ) ;
81
- list . save ( ) ;
82
- } , this ) ;
78
+ // refresh the view on changes that effect the models order
79
+ this . anyModelChange ( function ( ) {
80
+ this . refresh ( ) ;
81
+ list . save ( ) ;
82
+ } , this ) ;
83
83
84
84
85
- // hide/show footer and main body
86
- this . modelChange ( function ( ) {
87
- this . showMainFooter ( ! ! list . getLength ( ) ) ;
88
- } , this ) ;
89
- this . showMainFooter ( ! ! list . getLength ( ) ) ;
85
+ // hide/show footer and main body
86
+ this . modelChange ( function ( ) {
87
+ this . showMainFooter ( ! ! list . getLength ( ) ) ;
88
+ } , this ) ;
89
+ this . showMainFooter ( ! ! list . getLength ( ) ) ;
90
90
91
- // update counts
92
- this . bind ( 'completed' , function ( completedModels ) {
91
+ // update counts
92
+ this . bind ( 'completed' , function ( completedModels ) {
93
93
94
- // update "left" count
95
- soy . renderElement ( goog . dom . getElement ( 'todo-count' ) ,
96
- todomvc . templates . itemsLeft , {
97
- left : list . getLength ( ) - completedModels . length
98
- } ) ;
94
+ // update "left" count
95
+ soy . renderElement ( goog . dom . getElement ( 'todo-count' ) ,
96
+ todomvc . templates . itemsLeft , {
97
+ left : list . getLength ( ) - completedModels . length
98
+ } ) ;
99
99
100
- // update clear button
101
- var clearButton = goog . dom . getElement ( 'clear-completed' ) ;
102
- goog . dom . setTextContent ( clearButton ,
103
- 'Clear completed (' + completedModels . length + ')' ) ;
104
- goog . style . showElement ( clearButton , completedModels . length ) ;
100
+ // update clear button
101
+ var clearButton = goog . dom . getElement ( 'clear-completed' ) ;
102
+ goog . dom . setTextContent ( clearButton ,
103
+ 'Clear completed (' + completedModels . length + ')' ) ;
104
+ goog . style . showElement ( clearButton , completedModels . length ) ;
105
105
106
- // update checkbox
107
- var checkBox = this . getEls ( '.toggle-all' ) [ 0 ] ;
108
- checkBox . checked = completedModels . length === list . getLength ( ) ;
109
- } ) ;
106
+ // update checkbox
107
+ var checkBox = this . getEls ( '.toggle-all' ) [ 0 ] ;
108
+ checkBox . checked = completedModels . length === list . getLength ( ) ;
109
+ } ) ;
110
110
111
- // get the saved todos
112
- list . fetch ( ) ;
111
+ // get the saved todos
112
+ list . fetch ( ) ;
113
113
} ;
114
114
115
115
@@ -119,11 +119,11 @@ todomvc.listcontrol.prototype.enterDocument = function() {
119
119
* @param {boolean= } opt_hide whether to hide the footer.
120
120
*/
121
121
todomvc . listcontrol . prototype . showMainFooter = function ( opt_hide ) {
122
- var main = goog . dom . getElement ( 'main' ) ;
123
- var footer = goog . dom . getElementsByTagNameAndClass ( 'footer' ) [ 0 ] ;
122
+ var main = goog . dom . getElement ( 'main' ) ;
123
+ var footer = goog . dom . getElementsByTagNameAndClass ( 'footer' ) [ 0 ] ;
124
124
125
- goog . style . showElement ( main , opt_hide ) ;
126
- goog . style . showElement ( footer , opt_hide ) ;
125
+ goog . style . showElement ( main , opt_hide ) ;
126
+ goog . style . showElement ( footer , opt_hide ) ;
127
127
} ;
128
128
129
129
@@ -133,8 +133,8 @@ todomvc.listcontrol.prototype.showMainFooter = function(opt_hide) {
133
133
* @param {Function } filter to decide models returned.
134
134
*/
135
135
todomvc . listcontrol . prototype . setFilter = function ( filter ) {
136
- this . filter_ = filter ;
137
- this . refresh ( ) ;
136
+ this . filter_ = filter ;
137
+ this . refresh ( ) ;
138
138
} ;
139
139
140
140
@@ -143,17 +143,17 @@ todomvc.listcontrol.prototype.setFilter = function(filter) {
143
143
*/
144
144
todomvc . listcontrol . prototype . refresh = function ( ) {
145
145
146
- // dispose and remove all the children.
147
- this . forEachChild ( function ( child ) { child . dispose ( ) ; } ) ;
148
- this . removeChildren ( true ) ;
149
-
150
- // create new controls for the models
151
- goog . array . forEach ( this . getModel ( ) . getModels ( this . filter_ ) ,
152
- function ( model ) {
153
- var newModelControl = new todomvc . todocontrol ( model ) ;
154
- this . addChild ( newModelControl ) ;
155
- newModelControl . render ( goog . dom . getElement ( 'todo-list' ) ) ;
156
- } , this ) ;
146
+ // dispose and remove all the children.
147
+ this . forEachChild ( function ( child ) { child . dispose ( ) ; } ) ;
148
+ this . removeChildren ( true ) ;
149
+
150
+ // create new controls for the models
151
+ goog . array . forEach ( this . getModel ( ) . getModels ( this . filter_ ) ,
152
+ function ( model ) {
153
+ var newModelControl = new todomvc . todocontrol ( model ) ;
154
+ this . addChild ( newModelControl ) ;
155
+ newModelControl . render ( goog . dom . getElement ( 'todo-list' ) ) ;
156
+ } , this ) ;
157
157
} ;
158
158
159
159
0 commit comments