From 0612a50ab4324eb086d1e2d1a3f1936957f299b8 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 26 Jul 2017 11:40:24 +0200 Subject: [PATCH] Add fadein/fadeout when adding or removing a task --- www/todo/main.js | 77 ++++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/www/todo/main.js b/www/todo/main.js index 0b54a96e8..20cece307 100644 --- a/www/todo/main.js +++ b/www/todo/main.js @@ -20,6 +20,7 @@ define([ var $iframe = $('#pad-iframe').contents(); var $body = $iframe.find('body'); var ifrw = $('#pad-iframe')[0].contentWindow; + var $list = $iframe.find('#tasksList'); var onReady = function () { @@ -28,7 +29,13 @@ define([ var deleteTask = function(id) { todo.remove(id); - APP.display(); + var $els = $list.find('.cp-task').filter(function (i, el) { + return $(el).data('id') === id; + }); + $els.fadeOut(null, function () { + $els.remove(); + }); + //APP.display(); }; // TODO make this actually work, and scroll to bottom... @@ -55,38 +62,48 @@ define([ }); }; - var display = APP.display = function () { - var $list = $iframe.find('#tasksList'); + var addTaskUI = function (el, animate) { + var $taskDiv = $('
', { + 'class': 'cp-task' + }).appendTo($list); + $taskDiv.data('id', el); - $list.empty(); + var $box = makeCheckbox(el, function (state) { + display(); + }) + .appendTo($taskDiv); - APP.lm.proxy.order.forEach(function(el) { - var $taskDiv = $('
', { - 'class': 'cp-task' - }).appendTo($list); + var entry = APP.lm.proxy.data[el]; - var $box = makeCheckbox(el, function (state) { - display(); - }) - .appendTo($taskDiv); + if (entry.state) { + $taskDiv.addClass('cp-task-complete'); + } - var entry = APP.lm.proxy.data[el]; + $('', { 'class': 'cp-task-text' }) + .text(entry.task) + .appendTo($taskDiv); + $('', { 'class': 'cp-task-date' }) + .text(new Date(entry.ctime).toLocaleString()) + .appendTo($taskDiv); + $('