Commit 5b1af514 authored by Sindre Sorhus's avatar Sindre Sorhus

Merge pull request #923 from dprotti/agility789

Agility - cancel editing on escape keypress
parents 4f9ba99c 308e8478
......@@ -2,6 +2,7 @@
'use strict';
var ENTER_KEY = 13;
var ESCAPE_KEY = 27;
// 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
......@@ -49,7 +50,10 @@
'keyup input': function () {
if (event.which === ENTER_KEY) {
this.updateTitle();
} else if (event.which === ESCAPE_KEY) {
this.revertTitleEdit();
}
}
},
updateTitle: function () {
......@@ -64,6 +68,11 @@
} else {
this.destroy();
}
},
revertTitleEdit: function() {
this.view.$().removeClass('editing');
// restore title
this.view.$(".edit").val(this.model.get('title'));
}
}).persist($$.adapter.localStorage, {
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