Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eugene Shen
todomvc
Commits
ad8a026c
Commit
ad8a026c
authored
Feb 19, 2013
by
Pascal Hartig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ember: jshint style
parent
55065f19
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
31 deletions
+53
-31
architecture-examples/emberjs/js/app.js
architecture-examples/emberjs/js/app.js
+1
-0
architecture-examples/emberjs/js/controllers/todo_controller.js
...ecture-examples/emberjs/js/controllers/todo_controller.js
+5
-2
architecture-examples/emberjs/js/controllers/todos_controller.js
...cture-examples/emberjs/js/controllers/todos_controller.js
+17
-14
architecture-examples/emberjs/js/models/store.js
architecture-examples/emberjs/js/models/store.js
+3
-0
architecture-examples/emberjs/js/models/todo.js
architecture-examples/emberjs/js/models/todo.js
+5
-2
architecture-examples/emberjs/js/router.js
architecture-examples/emberjs/js/router.js
+11
-8
architecture-examples/emberjs/js/views/edit_todo_view.js
architecture-examples/emberjs/js/views/edit_todo_view.js
+7
-4
architecture-examples/emberjs/js/views/todo_view.js
architecture-examples/emberjs/js/views/todo_view.js
+4
-1
No files found.
architecture-examples/emberjs/js/app.js
View file @
ad8a026c
/*global Ember*/
window
.
Todos
=
Ember
.
Application
.
create
();
window
.
Todos
=
Ember
.
Application
.
create
();
architecture-examples/emberjs/js/controllers/todo_controller.js
View file @
ad8a026c
/*global Todos Ember*/
'
use strict
'
;
Todos
.
TodoController
=
Ember
.
ObjectController
.
extend
({
Todos
.
TodoController
=
Ember
.
ObjectController
.
extend
({
isEditing
:
false
,
isEditing
:
false
,
editTodo
:
function
()
{
editTodo
:
function
()
{
this
.
set
(
'
isEditing
'
,
true
);
this
.
set
(
'
isEditing
'
,
true
);
},
},
removeTodo
:
function
()
{
removeTodo
:
function
()
{
var
todo
=
this
.
get
(
'
model
'
);
var
todo
=
this
.
get
(
'
model
'
);
todo
.
deleteRecord
();
todo
.
deleteRecord
();
...
...
architecture-examples/emberjs/js/controllers/todos_controller.js
View file @
ad8a026c
/*global Todos Ember*/
'
use strict
'
;
Todos
.
TodosController
=
Ember
.
ArrayController
.
extend
({
Todos
.
TodosController
=
Ember
.
ArrayController
.
extend
({
createTodo
:
function
()
{
createTodo
:
function
()
{
// Get the todo title set by the "New Todo" text field
// Get the todo title set by the "New Todo" text field
var
title
=
this
.
get
(
'
newTitle
'
);
var
title
=
this
.
get
(
'
newTitle
'
);
if
(
!
title
.
trim
())
{
return
;
}
if
(
!
title
.
trim
())
{
return
;
}
...
@@ -17,38 +20,38 @@ Todos.TodosController = Ember.ArrayController.extend({
...
@@ -17,38 +20,38 @@ Todos.TodosController = Ember.ArrayController.extend({
this
.
get
(
'
store
'
).
commit
();
this
.
get
(
'
store
'
).
commit
();
},
},
clearCompleted
:
function
()
{
clearCompleted
:
function
()
{
var
completed
=
this
.
filterProperty
(
'
isCompleted
'
,
true
);
var
completed
=
this
.
filterProperty
(
'
isCompleted
'
,
true
);
completed
.
invoke
(
'
deleteRecord
'
);
completed
.
invoke
(
'
deleteRecord
'
);
this
.
get
(
'
store
'
).
commit
();
this
.
get
(
'
store
'
).
commit
();
},
},
remaining
:
function
()
{
remaining
:
function
()
{
return
this
.
filterProperty
(
'
isCompleted
'
,
false
).
get
(
'
length
'
);
return
this
.
filterProperty
(
'
isCompleted
'
,
false
).
get
(
'
length
'
);
}.
property
(
'
@each.isCompleted
'
),
}.
property
(
'
@each.isCompleted
'
),
remainingFormatted
:
function
()
{
remainingFormatted
:
function
()
{
var
remaining
=
this
.
get
(
'
remaining
'
);
var
remaining
=
this
.
get
(
'
remaining
'
);
var
plural
=
remaining
===
1
?
'
item
'
:
'
items
'
;
var
plural
=
remaining
===
1
?
'
item
'
:
'
items
'
;
return
'
<strong>%@</strong> %@ left
'
.
fmt
(
remaining
,
plural
);
return
'
<strong>%@</strong> %@ left
'
.
fmt
(
remaining
,
plural
);
}.
property
(
'
remaining
'
),
}.
property
(
'
remaining
'
),
completed
:
function
()
{
completed
:
function
()
{
return
this
.
filterProperty
(
'
isCompleted
'
,
true
).
get
(
'
length
'
);
return
this
.
filterProperty
(
'
isCompleted
'
,
true
).
get
(
'
length
'
);
}.
property
(
'
@each.isCompleted
'
),
}.
property
(
'
@each.isCompleted
'
),
hasCompleted
:
function
()
{
hasCompleted
:
function
()
{
return
this
.
get
(
'
completed
'
)
>
0
;
return
this
.
get
(
'
completed
'
)
>
0
;
}.
property
(
'
completed
'
),
}.
property
(
'
completed
'
),
allAreDone
:
function
(
key
,
value
)
{
allAreDone
:
function
(
key
,
value
)
{
if
(
value
!==
undefined
)
{
if
(
value
!==
undefined
)
{
this
.
setEach
(
'
isCompleted
'
,
value
);
this
.
setEach
(
'
isCompleted
'
,
value
);
return
value
;
return
value
;
}
else
{
}
else
{
return
!!
this
.
get
(
'
length
'
)
&&
return
!!
this
.
get
(
'
length
'
)
&&
this
.
everyProperty
(
'
isCompleted
'
,
true
);
this
.
everyProperty
(
'
isCompleted
'
,
true
);
}
}
}.
property
(
'
@each.isCompleted
'
)
}.
property
(
'
@each.isCompleted
'
)
});
});
architecture-examples/emberjs/js/models/store.js
View file @
ad8a026c
/*global Todos DS*/
'
use strict
'
;
Todos
.
Store
=
DS
.
Store
.
extend
({
Todos
.
Store
=
DS
.
Store
.
extend
({
revision
:
11
,
revision
:
11
,
adapter
:
'
Todos.LSAdapter
'
adapter
:
'
Todos.LSAdapter
'
...
...
architecture-examples/emberjs/js/models/todo.js
View file @
ad8a026c
/*global Todos DS Ember*/
'
use strict
'
;
Todos
.
Todo
=
DS
.
Model
.
extend
({
Todos
.
Todo
=
DS
.
Model
.
extend
({
title
:
DS
.
attr
(
'
string
'
),
title
:
DS
.
attr
(
'
string
'
),
isCompleted
:
DS
.
attr
(
'
boolean
'
),
isCompleted
:
DS
.
attr
(
'
boolean
'
),
todoDidChange
:
function
()
{
todoDidChange
:
function
()
{
Ember
.
run
.
once
(
this
,
function
()
{
Ember
.
run
.
once
(
this
,
function
()
{
this
.
get
(
'
store
'
).
commit
();
this
.
get
(
'
store
'
).
commit
();
});
});
}.
observes
(
'
isCompleted
'
,
'
title
'
)
}.
observes
(
'
isCompleted
'
,
'
title
'
)
...
...
architecture-examples/emberjs/js/router.js
View file @
ad8a026c
Todos
.
Router
.
map
(
function
()
{
/*global Todos Ember*/
this
.
resource
(
'
todos
'
,
{
path
:
'
/
'
},
function
()
{
'
use strict
'
;
Todos
.
Router
.
map
(
function
()
{
this
.
resource
(
'
todos
'
,
{
path
:
'
/
'
},
function
()
{
this
.
route
(
'
active
'
);
this
.
route
(
'
active
'
);
this
.
route
(
'
completed
'
);
this
.
route
(
'
completed
'
);
});
});
});
});
Todos
.
TodosRoute
=
Ember
.
Route
.
extend
({
Todos
.
TodosRoute
=
Ember
.
Route
.
extend
({
model
:
function
()
{
model
:
function
()
{
return
Todos
.
Todo
.
find
();
return
Todos
.
Todo
.
find
();
}
}
});
});
Todos
.
TodosIndexRoute
=
Ember
.
Route
.
extend
({
Todos
.
TodosIndexRoute
=
Ember
.
Route
.
extend
({
setupController
:
function
()
{
setupController
:
function
()
{
var
todos
=
Todos
.
Todo
.
find
();
var
todos
=
Todos
.
Todo
.
find
();
this
.
controllerFor
(
'
todos
'
).
set
(
'
filteredTodos
'
,
todos
);
this
.
controllerFor
(
'
todos
'
).
set
(
'
filteredTodos
'
,
todos
);
}
}
});
});
Todos
.
TodosActiveRoute
=
Ember
.
Route
.
extend
({
Todos
.
TodosActiveRoute
=
Ember
.
Route
.
extend
({
setupController
:
function
()
{
setupController
:
function
()
{
var
todos
=
Todos
.
Todo
.
filter
(
function
(
todo
)
{
var
todos
=
Todos
.
Todo
.
filter
(
function
(
todo
)
{
if
(
!
todo
.
get
(
'
isCompleted
'
))
{
return
true
;
}
if
(
!
todo
.
get
(
'
isCompleted
'
))
{
return
true
;
}
});
});
...
@@ -29,8 +32,8 @@ Todos.TodosActiveRoute = Ember.Route.extend({
...
@@ -29,8 +32,8 @@ Todos.TodosActiveRoute = Ember.Route.extend({
});
});
Todos
.
TodosCompletedRoute
=
Ember
.
Route
.
extend
({
Todos
.
TodosCompletedRoute
=
Ember
.
Route
.
extend
({
setupController
:
function
()
{
setupController
:
function
()
{
var
todos
=
Todos
.
Todo
.
filter
(
function
(
todo
)
{
var
todos
=
Todos
.
Todo
.
filter
(
function
(
todo
)
{
if
(
todo
.
get
(
'
isCompleted
'
))
{
return
true
;
}
if
(
todo
.
get
(
'
isCompleted
'
))
{
return
true
;
}
});
});
...
...
architecture-examples/emberjs/js/views/edit_todo_view.js
View file @
ad8a026c
/*global Todos Ember*/
'
use strict
'
;
Todos
.
EditTodoView
=
Ember
.
TextField
.
extend
({
Todos
.
EditTodoView
=
Ember
.
TextField
.
extend
({
classNames
:
[
'
edit
'
],
classNames
:
[
'
edit
'
],
valueBinding
:
'
todo.title
'
,
valueBinding
:
'
todo.title
'
,
change
:
function
()
{
change
:
function
()
{
var
value
=
this
.
get
(
'
value
'
);
var
value
=
this
.
get
(
'
value
'
);
if
(
Ember
.
isEmpty
(
value
))
{
if
(
Ember
.
isEmpty
(
value
))
{
...
@@ -11,15 +14,15 @@ Todos.EditTodoView = Ember.TextField.extend({
...
@@ -11,15 +14,15 @@ Todos.EditTodoView = Ember.TextField.extend({
}
}
},
},
focusOut
:
function
()
{
focusOut
:
function
()
{
this
.
set
(
'
controller.isEditing
'
,
false
);
this
.
set
(
'
controller.isEditing
'
,
false
);
},
},
insertNewline
:
function
()
{
insertNewline
:
function
()
{
this
.
set
(
'
controller.isEditing
'
,
false
);
this
.
set
(
'
controller.isEditing
'
,
false
);
},
},
didInsertElement
:
function
()
{
didInsertElement
:
function
()
{
this
.
$
().
focus
();
this
.
$
().
focus
();
}
}
});
});
architecture-examples/emberjs/js/views/todo_view.js
View file @
ad8a026c
/*global Todos Ember*/
'
use strict
'
;
Todos
.
TodoView
=
Ember
.
View
.
extend
({
Todos
.
TodoView
=
Ember
.
View
.
extend
({
tagName
:
'
li
'
,
tagName
:
'
li
'
,
classNameBindings
:
[
'
todo.isCompleted:completed
'
,
'
isEditing:editing
'
],
classNameBindings
:
[
'
todo.isCompleted:completed
'
,
'
isEditing:editing
'
],
doubleClick
:
function
(
event
)
{
doubleClick
:
function
(
)
{
this
.
set
(
'
isEditing
'
,
true
);
this
.
set
(
'
isEditing
'
,
true
);
}
}
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment