Commit 7f9bd8d4 authored by Stephen McKamey's avatar Stephen McKamey

Applying jscs lint suggestions.

parent 3f420ea0
...@@ -19,5 +19,5 @@ ...@@ -19,5 +19,5 @@
<!-- Hidden if no completed items are left ↓ --> <!-- Hidden if no completed items are left ↓ -->
<button class="clear-completed" <button class="clear-completed"
if="<%= data.completed %>" if="<%= data.completed %>"
onclick="<%= todos.actions.clear_click %>">Clear completed</button> onclick="<%= todos.actions.clearOnClick %>">Clear completed</button>
</footer> </footer>
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
<li class="<%= data.completed ? 'completed' : '' %>"> <li class="<%= data.completed ? 'completed' : '' %>">
<div class="view"> <div class="view">
<input class="toggle" type="checkbox" checked="<%= data.completed %>" <input class="toggle" type="checkbox" checked="<%= data.completed %>"
onchange="<%= todos.actions.completed_change(data.id) %>"> onchange="<%= todos.actions.completedOnChange(data.id) %>">
<label ondblclick="<%= todos.actions.content_dblclick %>"><%= data.title %></label> <label ondblclick="<%= todos.actions.editOnDblclick %>"><%= data.title %></label>
<button class="destroy" onclick="<%= todos.actions.remove_click(data.id) %>"></button> <button class="destroy" onclick="<%= todos.actions.removeOnClick(data.id) %>"></button>
</div> </div>
<input class="edit" type="text" value="<%= data.title %>" <input class="edit" type="text" value="<%= data.title %>"
onblur="<%= todos.actions.edit_blur(data.id) %>" onblur="<%= todos.actions.editOnBlur(data.id) %>"
onkeydown="<%= todos.actions.edit_keypress(data.id) %>"> onkeydown="<%= todos.actions.editOnKeydown(data.id) %>">
</li> </li>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<%-- This section should be hidden by default and shown when there are todos. --%> <%-- This section should be hidden by default and shown when there are todos. --%>
<section class="main" if="<%= data.tasks && data.tasks.length %>"> <section class="main" if="<%= data.tasks && data.tasks.length %>">
<input class="toggle-all" type="checkbox" checked="<%= !data.stats.active %>" <input class="toggle-all" type="checkbox" checked="<%= !data.stats.active %>"
onchange="<%= todos.actions.toggle_change %>"> onchange="<%= todos.actions.toggleOnChange %>">
<label for="toggle-all">Mark all as complete</label> <label for="toggle-all">Mark all as complete</label>
<ul class="todo-list"> <ul class="todo-list">
<for each="<%= data.tasks %>"> <for each="<%= data.tasks %>">
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<header class="header"> <header class="header">
<h1>todos</h1> <h1>todos</h1>
<input class="new-todo" placeholder="What needs to be done?" autofocus <input class="new-todo" placeholder="What needs to be done?" autofocus
onblur="<%= todos.actions.add_blur %>" onkeydown="<%= todos.actions.add_keypress %>"> onblur="<%= todos.actions.add_blur %>" onkeydown="<%= todos.actions.addOnKeydown %>">
</header> </header>
<call view="Tasks" data="data" /> <call view="Tasks" data="data" />
<call view="Stats" data="data.stats" /> <call view="Stats" data="data.stats" />
......
...@@ -71,7 +71,7 @@ var todos = todos || {}; ...@@ -71,7 +71,7 @@ var todos = todos || {};
// event handlers // event handlers
todos.actions = { todos.actions = {
add_keypress: function (e) { addOnKeydown: function (e) {
if (e.keyCode === ENTER_KEY) { if (e.keyCode === ENTER_KEY) {
add(this); add(this);
} else if (e.keyCode === ESC_KEY) { } else if (e.keyCode === ESC_KEY) {
...@@ -79,14 +79,14 @@ var todos = todos || {}; ...@@ -79,14 +79,14 @@ var todos = todos || {};
} }
}, },
edit_blur: function (id) { editOnBlur: function (id) {
// create a closure around the ID // create a closure around the ID
return function () { return function () {
edit(this, id); edit(this, id);
}; };
}, },
edit_keypress: function (id) { editOnKeydown: function (id) {
// create a closure around the ID // create a closure around the ID
return function (e) { return function (e) {
if (e.keyCode === ENTER_KEY) { if (e.keyCode === ENTER_KEY) {
...@@ -99,7 +99,7 @@ var todos = todos || {}; ...@@ -99,7 +99,7 @@ var todos = todos || {};
}; };
}, },
remove_click: function (id) { removeOnClick: function (id) {
// create a closure around the ID // create a closure around the ID
return function () { return function () {
todos.model.remove(id); todos.model.remove(id);
...@@ -107,37 +107,35 @@ var todos = todos || {}; ...@@ -107,37 +107,35 @@ var todos = todos || {};
}; };
}, },
clear_click: function () { clearOnClick: function () {
todos.model.expunge(); todos.model.expunge();
refreshView(); refreshView();
}, },
content_dblclick: function () { editOnDblclick: function () {
var li = this; var self = this;
while (li.tagName !== 'LI') { while (self.tagName !== 'LI') {
li = li.parentNode; self = self.parentNode;
} }
li.className = 'editing'; self.className = 'editing';
var input = find('input[type=text]', li); var input = find('input[type=text]', self);
if (input) { if (input) {
input.focus(); input.focus();
} }
}, },
completed_change: function (id) { completedOnChange: function (id) {
// create a closure around the ID // create a closure around the ID
return function () { return function () {
var checkbox = this; todos.model.toggle(id, this.checked);
todos.model.toggle(id, checkbox.checked);
refreshView(); refreshView();
}; };
}, },
toggle_change: function () { toggleOnChange: function () {
var checkbox = this; todos.model.toggleAll(this.checked);
todos.model.toggleAll(checkbox.checked);
refreshView(); refreshView();
} }
}; };
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<p>Ported to <a href="http://duelengine.org">DUEL</a> by <a href="http://mck.me">Stephen McKamey</a></p> <p>Ported to <a href="http://duelengine.org">DUEL</a> by <a href="http://mck.me">Stephen McKamey</a></p>
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p> <p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer> </footer>
<script src="./cdn/0246d47e943708b571e47bd968ef697d343ae178.js"></script> <script src="./cdn/41614acbac7a243d667ca7ec317c4d0c81ca1d7d.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
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