1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-08-20 12:51:43 +02:00

mobile improvements

This commit is contained in:
Morris Brodersen
2020-10-21 20:18:12 +02:00
parent 0174686516
commit 7f1038bef3
5 changed files with 122 additions and 81 deletions

View File

@@ -10,12 +10,10 @@ VT.TodoItemInput = function (el) {
var inputEl = el.querySelector('.input');
var saveEl = el.querySelector('.save');
VT.AppLateBlur(inputEl);
el.querySelectorAll('.app-icon').forEach(VT.AppIcon);
saveEl.addEventListener('click', save);
inputEl.addEventListener('keypress', handleKeypress);
function handleKeypress(e) {
inputEl.addEventListener('keypress', function (e) {
switch (e.keyCode) {
case 13: // enter
save();
@@ -24,7 +22,14 @@ VT.TodoItemInput = function (el) {
clear();
break;
}
}
});
inputEl.addEventListener('lateBlur', save);
saveEl.addEventListener('click', function () {
save();
inputEl.focus();
});
function save() {
var label = inputEl.value.trim();
@@ -39,7 +44,6 @@ VT.TodoItemInput = function (el) {
);
inputEl.value = '';
inputEl.focus();
}
function clear() {