From 57b8666bd24a1a22c11af9932e9361ab125b6904 Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Tue, 20 Oct 2020 21:33:36 +0300 Subject: [PATCH] * move 'All tasks' tab to the left (to be the first tab) --- src/ajax.php | 16 +++++++++- src/content/themes/default/index.php | 8 +++-- src/content/themes/default/print.css | 1 - src/content/themes/default/style.css | 8 ++--- src/includes/mytinytodo.js | 46 +++++++++++++++++----------- 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/ajax.php b/src/ajax.php index a1b86fd..b2defba 100644 --- a/src/ajax.php +++ b/src/ajax.php @@ -18,7 +18,8 @@ if(isset($_GET['loadLists'])) if (!is_logged()) $sqlWhere = 'WHERE published=1'; else $sqlWhere = ''; $t = array(); - $t['total'] = 0; + $t['list'][] = prepareAllTasksList(); + $t['total'] = 1; $q = $db->dq("SELECT * FROM {$db->prefix}lists $sqlWhere ORDER BY ow ASC, id ASC"); while($r = $q->fetch_assoc($q)) { @@ -875,6 +876,19 @@ function prepareList($row) ); } +function prepareAllTasksList() +{ + return array( + 'id' => -1, + 'name' => htmlarray(__('alltasks')), + 'sort' => 3, + 'published' => 0, + 'showCompl' => 1, + 'showNotes' => 0, + 'hidden' => 1, + ); +} + function getUserListsSimple() { $db = DBConnection::instance(); diff --git a/src/content/themes/default/index.php b/src/content/themes/default/index.php index 3c34159..3f66251 100644 --- a/src/content/themes/default/index.php +++ b/src/content/themes/default/index.php @@ -73,12 +73,14 @@ $().ready(function(){
+
    -
    -
    -
    +
    diff --git a/src/content/themes/default/print.css b/src/content/themes/default/print.css index a373781..6e917aa 100644 --- a/src/content/themes/default/print.css +++ b/src/content/themes/default/print.css @@ -14,7 +14,6 @@ h3 { border-bottom:2px solid #777777; } .mtt-tab a span { text-align:left; padding:0; max-width:none; font-size:1.3rem; color:#000; } .mtt-tabs-add-button { display:none; } -#list_all { display:none; } #tabs_buttons { display:none; } #taskview { padding-left:0; font-weight:normal; } #taskview .arrdown { display:none; } diff --git a/src/content/themes/default/style.css b/src/content/themes/default/style.css index 2af8d7d..48a1282 100644 --- a/src/content/themes/default/style.css +++ b/src/content/themes/default/style.css @@ -54,8 +54,7 @@ a { color:#0000ff; cursor:pointer; text-decoration:underline; } .tabs-n-button { flex-grow:1; display:flex; align-items:flex-start; } .tab-height-wrapper { box-sizing:border-box; height:2.2rem; display:flex; align-items:center; } .mtt-tabs { list-style:none; padding:0; margin:0; display:flex; justify-content:flex-start; flex-wrap:wrap; } -.mtt-tabs li { margin:1px 3px 0 0; } -.mtt-tab { background-color:#fbfbfb; border:1px solid #ededed; border-bottom:none; border-top-right-radius:8px; transition:background-color 0.1s ease-in; } +.mtt-tab { margin:1px 3px 0 0; background-color:#fbfbfb; border:1px solid #ededed; border-bottom:none; border-top-right-radius:8px; transition:background-color 0.1s ease-in; } .mtt-tab a { margin:0; text-decoration:none; white-space:nowrap; color:#333333; display:inline-block; outline:none; box-sizing:border-box; height:2.2rem; padding:1px 0.3rem 0 0.3rem; display:flex; align-items:center; @@ -68,10 +67,7 @@ a { color:#0000ff; cursor:pointer; text-decoration:underline; } .mtt-tab:hover { background-color:#ddd; } .mtt-tab.mtt-tabs-selected:hover { background-color:#ededed; } .mtt-tabs-hidden { display:none; } -.mtt-tabs .mtt-list-sort-placeholder { background-color:#ddd; border:1px solid #aaa; } - -.mtt-tabs-alltasks { margin:1px 3px 0 3px; } -.mtt-tabs-alltasks.mtt-tab { border-top-right-radius:0px; border-top-left-radius:8px; } +.mtt-tab-sort-placeholder { background-color:#ddd; border-color:#aaa; } #tabs_buttons { padding-left:2px; padding-right:2px; diff --git a/src/includes/mytinytodo.js b/src/includes/mytinytodo.js index 06b40cc..e6524d5 100644 --- a/src/includes/mytinytodo.js +++ b/src/includes/mytinytodo.js @@ -477,20 +477,22 @@ var mytinytodo = window.mytinytodo = _mtt = { } $("#tasklist").sortable({ - items: '> :not(.task-completed)', - cancel: 'span,input,a,textarea', - delay: 150, - start: tasklistSortStart, - update: tasklistSortUpdated, - placeholder: 'mtt-task-placeholder', - cursor: 'grabbing' + items: '> :not(.task-completed)', + cancel: 'span,input,a,textarea', + delay: 150, + start: tasklistSortStart, + update: tasklistSortUpdated, + placeholder: 'mtt-task-placeholder', + cursor: 'grabbing' }); $("#lists ul").sortable({ - delay:150, - update:listOrderChanged, - placeholder: 'mtt-list-sort-placeholder', + delay: 150, + update: listOrderChanged, + items: '> :not(.mtt-tabs-alltasks)', + forcePlaceholderSize : true, + placeholder: 'mtt-tab mtt-tab-sort-placeholder', cursor: 'grabbing' }); @@ -673,11 +675,18 @@ var mytinytodo = window.mytinytodo = _mtt = { // or open first if all list are hidden if(!openListId) openListId = res.list[0].id; - $.each(res.list, function(i,item){ - tabLists.add(item); - ti += '
  • '+ - ''+item.name+''+ - '
  • '; + $.each(res.list, function(i,item) { + if ( item.id == -1) { + ti += '
  • '+ + ''+item.name+''+ + '
  • '; + } + else { + tabLists.add(item); + ti += '
  • '+ + ''+item.name+''+ + '
  • '; + } }); } @@ -1292,12 +1301,13 @@ function toggleAllNotes(show) function tabSelect(elementOrId) { var id; - if(typeof elementOrId == 'number') id = elementOrId; + if (typeof elementOrId == 'number') id = elementOrId; else if(typeof elementOrId == 'string') id = parseInt(elementOrId); else { id = $(elementOrId).attr('id'); - if(!id) return; - id = parseInt(id.split('_', 2)[1]); + if (!id ) return; + id = id.split('_', 2)[1]; + if (id === 'all') id = -1; } if ( !tabLists.exists(id) ) { // TODO: handle unknown list