Commit 27abf868 authored by Sindre Sorhus's avatar Sindre Sorhus

Ember app - code style

parent d73610a5
<!doctype html>
<html lang="en">
<head>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>ember.js • TodoMVC</title>
<link rel="stylesheet" href="components/todomvc-common/base.css">
</head>
<body>
</head>
<body>
<script type="text/x-handlebars" data-template-name="todos">
<section id="todoapp">
<header id="header">
......@@ -14,7 +14,6 @@
{{view Ember.TextField id="new-todo" placeholder="What needs to be done?"
valueBinding="newTitle" action="createTodo"}}
</header>
{{#if length}}
<section id="main">
<ul id="todo-list">
......@@ -32,7 +31,6 @@
</ul>
{{view Ember.Checkbox id="toggle-all" checkedBinding="allAreDone"}}
</section>
<footer id="footer">
<span id="todo-count">{{{remainingFormatted}}}</span>
<ul id="filters">
......@@ -46,7 +44,6 @@
{{#linkTo todos.completed activeClass="selected"}}Completed{{/linkTo}}
</li>
</ul>
{{#if hasCompleted}}
<button id="clear-completed" {{action "clearCompleted"}} {{bindAttr class="buttonClass:hidden"}}>
Clear completed ({{completed}})
......@@ -55,7 +52,6 @@
</footer>
{{/if}}
</section>
<footer id="info">
<p>Double-click to edit a todo</p>
<p>
......@@ -66,8 +62,6 @@
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>
</script>
<!-- /* Handlebars templates end */ -->
<script src="components/todomvc-common/base.js"></script>
<script src="components/jquery/jquery.js"></script>
<script src="components/handlebars/handlebars.js"></script>
......@@ -83,5 +77,5 @@
<script src="js/controllers/todo_controller.js"></script>
<script src="js/views/todo_view.js"></script>
<script src="js/views/edit_todo_view.js"></script>
</body>
</body>
</html>
/*global Ember*/
/*global Ember */
window.Todos = Ember.Application.create();
/*global Todos Ember*/
/*global Todos Ember */
'use strict';
Todos.TodoController = Ember.ObjectController.extend({
......
/*global Todos Ember*/
/*global Todos Ember */
'use strict';
Todos.TodosController = Ember.ArrayController.extend({
createTodo: function () {
// Get the todo title set by the "New Todo" text field
var title = this.get('newTitle');
if (!title.trim()) { return; }
if (!title.trim()) {
return;
}
// Create the new Todo model
Todos.Todo.createRecord({
......
/*global Todos DS*/
/*global Todos DS */
'use strict';
Todos.Store = DS.Store.extend({
......
/*global Todos DS Ember*/
/*global Todos DS Ember */
'use strict';
Todos.Todo = DS.Model.extend({
......
/*global Todos Ember*/
/*global Todos Ember */
'use strict';
Todos.Router.map(function () {
......@@ -24,7 +24,9 @@ Todos.TodosIndexRoute = Ember.Route.extend({
Todos.TodosActiveRoute = Ember.Route.extend({
setupController: function () {
var todos = Todos.Todo.filter(function (todo) {
if (!todo.get('isCompleted')) { return true; }
if (!todo.get('isCompleted')) {
return true;
}
});
this.controllerFor('todos').set('filteredTodos', todos);
......@@ -34,7 +36,9 @@ Todos.TodosActiveRoute = Ember.Route.extend({
Todos.TodosCompletedRoute = Ember.Route.extend({
setupController: function () {
var todos = Todos.Todo.filter(function (todo) {
if (todo.get('isCompleted')) { return true; }
if (todo.get('isCompleted')) {
return true;
}
});
this.controllerFor('todos').set('filteredTodos', todos);
......
/*global Todos Ember*/
/*global Todos Ember */
'use strict';
Todos.EditTodoView = Ember.TextField.extend({
......
/*global Todos Ember*/
/*global Todos Ember */
'use strict';
Todos.TodoView = Ember.View.extend({
tagName: 'li',
classNameBindings: ['todo.isCompleted:completed', 'isEditing:editing'],
classNameBindings: [
'todo.isCompleted:completed',
'isEditing:editing'
],
doubleClick: function () {
this.set('isEditing', true);
}
......
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