Commit 594c7679 authored by Duilio Protti's avatar Duilio Protti

ariatemplates - cancel editing on escape keypress

parent 1d9089af
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
<input class="edit" value="${iter.item.title|escapeForHTML}" <input class="edit" value="${iter.item.title|escapeForHTML}"
{id "editbox"/} {id "editbox"/}
{on blur {fn: "stopEdit", scope: this, args: iter}/} {on blur {fn: "stopEdit", scope: this, args: iter}/}
{on keydown {fn: "confirmEdit", scope: this, args: iter}/}> {on keydown {fn: "confirmOrRevertEdit", scope: this, args: iter}/}>
{else/} {else/}
<div class="view"> <div class="view">
{@html:CheckBox { {@html:CheckBox {
......
...@@ -83,8 +83,9 @@ Aria.tplScriptDefinition({ ...@@ -83,8 +83,9 @@ Aria.tplScriptDefinition({
this.$focus('editbox'); this.$focus('editbox');
}, },
confirmEdit: function (evt, e) { confirmOrRevertEdit: function (evt, e) {
if (evt.keyCode === evt.KC_ENTER) { this.stopEdit(evt, e); } if (evt.keyCode === evt.KC_ENTER) { this.stopEdit(evt, e); }
if (evt.keyCode === evt.KC_ESCAPE) { this.revertEdit(evt, e); }
}, },
stopEdit: function (evt, e) { stopEdit: function (evt, e) {
...@@ -106,6 +107,15 @@ Aria.tplScriptDefinition({ ...@@ -106,6 +107,15 @@ Aria.tplScriptDefinition({
} }
}, },
revertEdit: function (evt, e) {
var el;
this.data.editedTask = null;
el = this.$getElementById(e.sectionId);
if (el) { el.classList.remove('editing'); }
this.$refresh({outputSection: e.sectionId});
this.$json.setValue(e.item, 'title', e.item.title);
},
todolistUpdateHandler: function () { todolistUpdateHandler: function () {
var size; var size;
if (this.pauselistener) { return; } if (this.pauselistener) { return; }
......
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