Commit e280987d authored by Sindre Sorhus's avatar Sindre Sorhus

Batman app: Cleanup

parent e1843aab
# Batman TodoMVC
# Batman • [TodoMVC](http://todomvc.com)
A todo app built using [Batman](http://batmanjs.org), inspired by [TodoMVC](https://github.com/addyosmani/todomvc).
A todo app built using [Batman](http://batmanjs.org)
## Running it
Spin up an HTTP server and visit http://localhost/labs/architecture-examples/batman/index.html
## Run
Spin up an HTTP server and visit http://localhost/labs/architecture-examples/batman/
## Persistence
A quick note: This app uses `Batman.LocalStorage` to persist the Todo records across page reloads. Batman's `localStorage` engine sticks each record under it's own key in `localStorage`, which is a departure from the TodoMVC application specification, which asks that all the records are stored under one key as a big blob. Batman stores records this way so that the whole set doesn't need to be parsed just to find one record or check if that record exists.
## Building it
This app is written in CoffeeScript, so to make changes, please edit `js/app.coffee` and rebuild the JavaScript with the `coffee` compiler.
## Build
This app is written in CoffeeScript, so to make changes, please edit `js/app.coffee` and rebuild the JavaScript with the `coffee` compiler.
\ No newline at end of file
......@@ -23,27 +23,23 @@
<li data-foreach-todo="currentTodos"
data-addclass-completed="todo.completed"
data-addclass-editing="todo.editing" >
<div class="view" data-hideif="todo.editing" data-event-doubleclick="toggleEditing">
<input class="toggle" type="checkbox" data-bind="todo.completed" data-event-change="todoDoneChanged">
<label data-bind="todo.title"></label>
<button class="destroy" data-event-click="destroyTodo"></button>
</div>
<input class="edit" type="text"
data-bind="todo.title"
data-bind-id="'todo-input-' | append todo.id"
data-event-blur="toggleEditing"
data-event-keypress="disableEditingUponSubmit" >
data-event-keypress="disableEditingUponSubmit">
</li>
</ul>
</section>
<footer id="footer" data-showif="Todo.all.length">
<span id="todo-count">
<strong data-bind="Todo.active.length"></strong>
<span data-bind="'item' | pluralize Todo.active.length, false"></span>
left
<span data-bind="'item' | pluralize Todo.active.length, false"></span> left
</span>
<ul id="filters">
<li>
......@@ -56,7 +52,9 @@
<a data-addclass-selected="currentRoute.action | equals 'completed'" data-route="'/completed'">Completed</a>
</li>
</ul>
<button id="clear-completed" data-event-click="clearCompleted" data-showif="Todo.completed.length">Clear completed (<span data-bind="Todo.completed.length"></span>)</button>
<button id="clear-completed" data-event-click="clearCompleted" data-showif="Todo.completed.length">
Clear completed (<span data-bind="Todo.completed.length"></span>)
</button>
</footer>
</section>
<footer id="info">
......@@ -68,7 +66,7 @@
</div>
<script src="../../../assets/base.js"></script>
<script src="js/es5-shim.js"></script>
<script src="js/batman.js"></script>
<script src="js/lib/batman.js"></script>
<script src="js/app.js"></script>
</body>
</html>
\ No newline at end of file
class Alfred extends Batman.App
@root 'todos#all'
@route "/completed", "todos#completed"
@route "/active", "todos#active"
@route '/completed', 'todos#completed'
@route '/active', 'todos#active'
class Alfred.TodosController extends Batman.Controller
constructor: ->
......@@ -50,7 +50,6 @@ class Alfred.TodosController extends Batman.Controller
editing = todo.set('editing', !todo.get('editing'))
if editing
input = document.getElementById("todo-input-#{todo.get('id')}")
input.focus()
input.select()
else
if todo.get('title')?.length > 0
......
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