Skip to content

Commit

Permalink
Merge pull request tastejs#509 from petermichaux/gh-pages
Browse files Browse the repository at this point in the history
whitespace fix and allow escape key to cancel edit mode of a todo
  • Loading branch information
passy committed Mar 28, 2013
2 parents 6f41dab + 89c59e1 commit adeabde
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion architecture-examples/maria/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<footer id="info">
<p>Double-click to edit a todo</p>
<p>Created by <a href="http://github.com/petermichaux">Peter Michaux</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>

</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ maria.Controller.subclass(checkit, 'TodoController', {
this.getView().showEdit();
},
onKeyupEdit: function(evt) {
if (checkit.isEnterKeyCode(evt.keyCode)) {
var keyCode = evt.keyCode;
if (checkit.isEnterKeyCode(keyCode)) {
this.onBlurEdit();
}
else if (checkit.isEscapeKeyCode(keyCode)) {
var view = this.getView();
view.resetEdit();
view.showDisplay();
}
},
onBlurEdit: function() {
var model = this.getModel();
Expand Down
4 changes: 4 additions & 0 deletions architecture-examples/maria/src/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ checkit.escapeHTML = function(str) {
checkit.isEnterKeyCode = function(keyCode) {
return keyCode === 13;
};

checkit.isEscapeKeyCode = function(keyCode) {
return keyCode === 27;
};
6 changes: 5 additions & 1 deletion architecture-examples/maria/src/js/views/TodoView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ maria.ElementView.subclass(checkit, 'TodoView', {
update: function() {
this.buildData();
},
showEdit: function() {
resetEdit: function() {
var input = this.find('.edit');
input.value = this.getModel().getTitle();
},
showEdit: function() {
this.resetEdit();
var input = this.find('.edit');
aristocrat.addClass(this.find('li'), 'editing');
input.focus();
},
Expand Down

0 comments on commit adeabde

Please sign in to comment.