Commit 89c59e10 authored by Peter Michaux's avatar Peter Michaux

allow escape key to end edit mode of a todo

parent 7bd29bc5
......@@ -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();
......
......@@ -16,3 +16,7 @@ checkit.escapeHTML = function(str) {
checkit.isEnterKeyCode = function(keyCode) {
return keyCode === 13;
};
checkit.isEscapeKeyCode = function(keyCode) {
return keyCode === 27;
};
......@@ -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();
},
......
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