From 614c93cb19a20762d83d896a7866dbfa6673e49d Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Mon, 4 Oct 2010 23:14:28 +0400 Subject: [PATCH] + Added ability (disabled) to autosave "Show notes" toggle status --- src/ajax.php | 10 ++++++++++ src/mytinytodo.js | 4 +++- src/mytinytodo_ajax_storage.js | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ajax.php b/src/ajax.php index 86d72a9..5fdb631 100644 --- a/src/ajax.php +++ b/src/ajax.php @@ -517,6 +517,16 @@ elseif(isset($_GET['clearCompletedInList'])) echo json_encode($t); exit; } +elseif(isset($_GET['setShowNotesInList'])) +{ + check_write_access(); + $listId = (int)_post('list'); + $flag = (int)_post('shownotes'); + $bitwise = ($flag == 0) ? 'taskview & ~2' : 'taskview | 2'; + $db->dq("UPDATE {$db->prefix}lists SET taskview=$bitwise WHERE id=$listId"); + echo json_encode(array('total'=>1)); + exit; +} ################################################################################################### diff --git a/src/mytinytodo.js b/src/mytinytodo.js index 9ce1eb1..5efc021 100644 --- a/src/mytinytodo.js +++ b/src/mytinytodo.js @@ -47,7 +47,8 @@ var mytinytodo = window.mytinytodo = _mtt = { openList: 0, singletab: false, autotag: false, - tagPreview: true + tagPreview: true, + saveShowNotes: false }, timers: { @@ -985,6 +986,7 @@ function toggleAllNotes(show) else $('#taskrow_'+id).removeClass('task-expanded'); } curList.showNotes = show; + if(_mtt.options.saveShowNotes) _mtt.db.request('setShowNotesInList', {list:curList.id, shownotes:show}, function(json){}); }; diff --git a/src/mytinytodo_ajax_storage.js b/src/mytinytodo_ajax_storage.js index 67d77c9..a1c33c1 100644 --- a/src/mytinytodo_ajax_storage.js +++ b/src/mytinytodo_ajax_storage.js @@ -152,6 +152,11 @@ mytinytodoStorageAjax.prototype = { $.post(this.mtt.mttUrl+'ajax.php?publishList', { list:params.list, publish:params.publish }, callback, 'json'); }, + + setShowNotesInList: function(params, callback) + { + $.post(this.mtt.mttUrl+'ajax.php?setShowNotesInList', { list:params.list, shownotes:params.shownotes }, callback, 'json'); + }, changeListOrder: function(params, callback) {