Commit 308e8478 authored by Duilio Protti's avatar Duilio Protti

Agility - cancel editing on escape keypress

parent 4f9ba99c
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
'use strict'; 'use strict';
var ENTER_KEY = 13; var ENTER_KEY = 13;
var ESCAPE_KEY = 27;
// hack of taking out html elements from DOM so that agility's view can use it // hack of taking out html elements from DOM so that agility's view can use it
// we need 'outerhtml' also, as agilityjs will append DOM, so removing it // we need 'outerhtml' also, as agilityjs will append DOM, so removing it
...@@ -49,7 +50,10 @@ ...@@ -49,7 +50,10 @@
'keyup input': function () { 'keyup input': function () {
if (event.which === ENTER_KEY) { if (event.which === ENTER_KEY) {
this.updateTitle(); this.updateTitle();
} else if (event.which === ESCAPE_KEY) {
this.revertTitleEdit();
} }
} }
}, },
updateTitle: function () { updateTitle: function () {
...@@ -64,6 +68,11 @@ ...@@ -64,6 +68,11 @@
} else { } else {
this.destroy(); this.destroy();
} }
},
revertTitleEdit: function() {
this.view.$().removeClass('editing');
// restore title
this.view.$(".edit").val(this.model.get('title'));
} }
}).persist($$.adapter.localStorage, { }).persist($$.adapter.localStorage, {
collection: 'todos-agilityjs' collection: 'todos-agilityjs'
......
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