From a0de111dead16ec1ae7e334eec5fa8e97be8617f Mon Sep 17 00:00:00 2001 From: maxpozdeev Date: Tue, 22 Aug 2023 18:08:40 +0300 Subject: [PATCH] * save the state of show notes on click with Cmd/Ctrl --- src/content/mytinytodo.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/content/mytinytodo.js b/src/content/mytinytodo.js index c849b4d..d17d38c 100644 --- a/src/content/mytinytodo.js +++ b/src/content/mytinytodo.js @@ -1,6 +1,6 @@ /* This file is a part of myTinyTodo. - (C) Copyright 2009-2010,2020-2022 Max Pozdeev + (C) Copyright 2009-2010,2020-2023 Max Pozdeev Licensed under the GNU GPL version 2 or any later. See file COPYRIGHT for details. */ @@ -313,14 +313,14 @@ var mytinytodo = window.mytinytodo = _mtt = { loadTags(curList.id, function(){$('#tagcloudload').hide();}); }); - $('#mtt-notes-show').click(function(){ - toggleAllNotes(1); + $('#mtt-notes-show').click(function(e){ + toggleAllNotes(1, e); this.blur(); return false; }); - $('#mtt-notes-hide').click(function(){ - toggleAllNotes(0); + $('#mtt-notes-hide').click(function(e){ + toggleAllNotes(0, e); this.blur(); return false; }); @@ -1542,16 +1542,18 @@ function setTaskview(v) }; -function toggleAllNotes(show) +function toggleAllNotes(show, event) { - for(var id in taskList) + for (let id in taskList) { - if(taskList[id].note == '') continue; - if(show) $('#taskrow_'+id).addClass('task-expanded'); + if (taskList[id].note == '') continue; + if (show) $('#taskrow_'+id).addClass('task-expanded'); else $('#taskrow_'+id).removeClass('task-expanded'); } curList.showNotes = show; - if(_mtt.options.saveShowNotes) _mtt.db.request('setShowNotesInList', {list:curList.id, shownotes:show}, function(json){}); + if (_mtt.options.saveShowNotes || (event && (event.metaKey || event.ctrlKey)) ) { + _mtt.db.request('setShowNotesInList', {list:curList.id, shownotes:show}, function(json){}); + } };