Commit 7405c80f authored by Aaron Boushley's avatar Aaron Boushley

Upgraded libs. Resolving other issues.

Bolding items left.
Trim todo input and prevent whitespace only todos.
Change content to title in model.
Double click on item div instead of just title.
Removed unused jslitmus.js.
parent de0428e0
......@@ -36,7 +36,7 @@
<script src="js/libs/json2.js"></script>
<script src="js/libs/jquery-1.7.1.min.js"></script>
<script src="js/libs/underscore-1.1.6.js"></script>
<script src="js/libs/underscore.js"></script>
<script src="js/libs/backbone.js"></script>
<script src="js/libs/backbone-localstorage.js"></script>
<script src="js/app.js"></script>
......@@ -46,17 +46,17 @@
<script type="text/template" id="item-template">
<div class="view">
<input class="toggle" type="checkbox" <%= done ? 'checked="checked"' : '' %> />
<label><%= content %></label>
<label><%= title %></label>
<a class="destroy"></a>
</div>
<input class="edit" type="text" value="<%= content %>" />
<input class="edit" type="text" value="<%= title %>" />
</script>
<script type="text/template" id="stats-template">
<% if (done) { %>
<a id="clear-completed">Clear <%= done %> completed <%= done == 1 ? 'item' : 'items' %></a>
<% } %>
<div class="todo-count"><%= remaining %> <%= remaining == 1 ? 'item' : 'items' %> left.</div>
<div class="todo-count"><b><%= remaining %></b> <%= remaining == 1 ? 'item' : 'items' %> left</div>
</script>
</body>
......
......@@ -9,19 +9,19 @@ $(function(){
// Todo Model
// ----------
// Our basic **Todo** model has `content`, `order`, and `done` attributes.
// Our basic **Todo** model has `title`, `order`, and `done` attributes.
var Todo = Backbone.Model.extend({
// Default attributes for the todo.
defaults: {
content: "empty todo...",
title: "empty todo...",
done: false
},
// Ensure that each todo created has `content`.
// Ensure that each todo created has `title`.
initialize: function() {
if (!this.get("content")) {
this.set({"content": this.defaults.content});
if (!this.get("title")) {
this.set({"title": this.defaults.title});
}
},
......@@ -92,7 +92,7 @@ $(function(){
// The DOM events specific to an item.
events: {
"click .toggle" : "toggleDone",
"dblclick label" : "edit",
"dblclick .view" : "edit",
"click a.destroy" : "clear",
"keypress .edit" : "updateOnEnter",
"blur .edit" : "close"
......@@ -106,7 +106,7 @@ $(function(){
this.model.bind('destroy', this.remove, this);
},
// Re-render the contents of the todo item.
// Re-render the titles of the todo item.
render: function() {
var $el = $(this.el);
$el.html(this.template(this.model.toJSON()));
......@@ -129,7 +129,7 @@ $(function(){
// Close the `"editing"` mode, saving changes to the todo.
close: function() {
this.model.save({content: this.input.val()});
this.model.save({title: this.input.val()});
$(this.el).removeClass("editing");
},
......@@ -220,9 +220,9 @@ $(function(){
// Generate the attributes for a new Todo item.
newAttributes: function() {
return {
content: this.input.val(),
order: Todos.nextOrder(),
done: false
title: this.input.val().trim(),
order: Todos.nextOrder(),
done: false
};
},
......@@ -230,6 +230,8 @@ $(function(){
// persisting it to *localStorage*.
createOnEnter: function(e) {
if (e.keyCode != 13) return;
if (!this.input.val().trim()) return;
Todos.create(this.newAttributes());
this.input.val('');
},
......
This diff is collapsed.
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