From 304d37a334a1dff4cdce31d42fecc362594744d8 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 26 Jul 2017 10:06:24 +0200 Subject: [PATCH] use styled checkboxes --- www/todo/main.js | 30 ++++++++++++++++++------------ www/todo/todo.less | 11 +++++++++++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/www/todo/main.js b/www/todo/main.js index dde911b3d..1371cb0fb 100644 --- a/www/todo/main.js +++ b/www/todo/main.js @@ -41,6 +41,20 @@ define([ }; scrollTo = scrollTo; + var makeCheckbox = function (id, cb) { + var entry = APP.lm.proxy.data[id]; + var checked = entry.state === 1? 'fa-check-square-o': 'fa-square-o'; + + return $('', { + 'class': 'cp-task-checkbox fa ' + checked, + }).on('click', function () { + entry.state = (entry.state + 1) % 2; + if (typeof(cb) === 'function') { + cb(entry.state); + } + }); + }; + var display = APP.display = function () { var $list = $iframe.find('#tasksList'); @@ -51,19 +65,11 @@ define([ 'class': 'cp-task' }).appendTo($list); + makeCheckbox(el, function (state) { + display(); + }).appendTo($taskDiv); + var entry = APP.lm.proxy.data[el]; - - var $check = $('', { - type: 'checkbox', - }) - .on('change', function (e) { - var checked = $check[0].checked; - entry.state = checked? 1: 0; - entry.mtime = +new Date(); - }) - .appendTo($taskDiv); - $check[0].checked = entry.state? true: false; - $('', { 'class': 'cp-task-text' }) .text(entry.task) .appendTo($taskDiv); diff --git a/www/todo/todo.less b/www/todo/todo.less index 648ffe9e1..939b11b70 100644 --- a/www/todo/todo.less +++ b/www/todo/todo.less @@ -47,6 +47,13 @@ body { .cp-create-form { margin: @spacing; + min-width: 40%; + display: flex; + + #newTodoName { + flex: 1; + margin-right: 15px; + } } .cp-task { @@ -66,4 +73,8 @@ body { .cp-task-remove { margin: @spacing; } + .cp-task-checkbox { + font-size: 45px; + width: 45px; + } }