diff --git a/www/todo/main.js b/www/todo/main.js index 3a7921f47..be4ae48b8 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,39 +62,47 @@ define([ }); }; - var display = APP.display = function () { - var $list = $iframe.find('#tasksList'); - - $list.empty(); + var addTaskUI = function (el, animate) { + var $taskDiv = $('
', { + 'class': 'cp-task' + }).appendTo($list); + $taskDiv.data('id', el); - APP.lm.proxy.order.forEach(function(el) { - var $taskDiv = $('
', { - 'class': 'cp-task' - }).appendTo($list); + var $box = makeCheckbox(el, function (state) { + display(); + }) + .appendTo($taskDiv); - var $box = makeCheckbox(el, function (state) { - display(); - }) - .appendTo($taskDiv); + var entry = APP.lm.proxy.data[el]; - var entry = APP.lm.proxy.data[el]; + if (entry.state) { + $taskDiv.addClass('cp-task-complete'); + } - if (entry.state) { - $taskDiv.addClass('cp-task-complete'); - } + $('', { 'class': 'cp-task-text' }) + .text(entry.task) + .appendTo($taskDiv); + /*$('', { 'class': 'cp-task-date' }) + .text(new Date(entry.ctime).toLocaleString()) + .appendTo($taskDiv);*/ + $('