diff --git a/langs/ru.php b/langs/ru.php
index 6fb0ead..5ed6dfc 100644
--- a/langs/ru.php
+++ b/langs/ru.php
@@ -2,12 +2,12 @@
/*
myTinyTodo language pack
- Language: Russian
- Language Original: Русский
+ Language: Русский
+ Translated: Russian
Author: Max Pozdeev
Author Url: http://www.mytinytodo.net
AppVersion: v1.3.2
- Date: 2009-12-19
+ Date: 2009-12-26
*/
class Lang extends DefaultLang
@@ -75,6 +75,7 @@ class Lang extends DefaultLang
'action_note' => "Заметка",
'action_delete' => "Удалить",
'action_priority' => "Приоритет",
+ 'action_move' => "Переместить в",
'notes' => "Заметки:",
'notes_show' => "Показать",
'notes_hide' => "Скрыть",
diff --git a/src/ajax.js b/src/ajax.js
index 15d46dd..5e73f96 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -936,6 +936,7 @@ function loadLists(onInit, updAccess)
$('#lists>ul').html(ti);
$('#lists').show();
if(!flag.needAuth || flag.isLogged || curList) $('#page_tasks').show();
+ doAction('listsLoaded');
});
$('#page_tasks').hide();
if(updAccess) updateAccessStatus();
@@ -954,7 +955,10 @@ function addList()
var i = tabLists.length;
item.i = i;
tabLists[i] = item;
- if(i > 0) $('#lists>ul>li.mtt-tabs-button').before('
'+item.name+'') ;
+ if(i > 0) {
+ $('#lists>ul>li.mtt-tabs-button').before(''+item.name+'') ;
+ doAction('listAdded', {i:i, list:item});
+ }
else loadLists();
}, 'json');
}
@@ -974,6 +978,7 @@ function renameCurList()
tabLists[curList.i] = item;
curList = item;
$('#lists>ul>.mtt-tabs-selected>a').attr('title', item.name).html(item.name);
+ doAction('listRenamed', {i:curList.i, list:item});
}, 'json');
}
@@ -1142,6 +1147,7 @@ function taskContextClick(el)
case 'cmenu_note': toggleTaskNote(taskId); break;
case 'cmenu_delete': deleteTask(taskId); break;
case 'cmenu_prio': setTaskPrio(taskId, parseInt(value)); break;
+ case 'cmenu_move': moveTaskToList(taskId, value); break;
}
}
@@ -1151,6 +1157,7 @@ function mttMenu(container, options)
this.container = $('#'+container);
this.menuOpen = false;
this.options = options || {};
+ this.submenu = [];
//create submenus
this.container.find('li.mtt-menu-has-submenu').each(function()
@@ -1160,7 +1167,7 @@ function mttMenu(container, options)
submenu.parent = menu;
if(menu.root) submenu.root = menu.root; //!! be careful with circular references
else submenu.root = menu;
- menu.submenu = submenu;
+ menu.submenu.push(submenu);
var showTimer, hideTimer;
$(this).hover(
@@ -1183,21 +1190,19 @@ function mttMenu(container, options)
submenu.root.onclick(this);
return false;
})
- .each(function()
- {
- $(this).hover(
- function(){
- clearTimeout(hideTimer);
- },
- function(){
- hideTimer = setTimeout(function(){
- submenu.hide();
- }, 400);
- }
- );
- });
+ .hover(
+ function(){
+ clearTimeout(hideTimer);
+ },
+ function(){
+ hideTimer = setTimeout(function(){
+ submenu.hide();
+ }, 400);
+ }
+ );
});
+ //if(!this.root)
this.container.find('li').click(function(){
menu.onclick(this);
return false;
@@ -1212,7 +1217,7 @@ function mttMenu(container, options)
this.hide = function()
{
- if(this.submenu) this.submenu.hide();
+ for(var i in this.submenu) this.submenu[i].hide();
this.container.hide();
this.menuOpen = false;
}
@@ -1256,4 +1261,53 @@ function mttMenu(container, options)
this.container.css({ position: 'absolute', top: offset.top+dy, left: offset.left+this.$caller.outerWidth() /*, 'min-width': this.$caller.outerWidth()*/ }).show();
this.menuOpen = true;
}
+
+ this.destroy = function()
+ {
+ for(var i in this.submenu) {
+ this.submenu[i].destroy();
+ delete this.submenu[i];
+ }
+ this.container.find('li').unbind(); //'click mouseenter mouseleave'
+ }
+
+}
+
+function doAction(action, opts)
+{
+ switch(action) {
+ case 'listsLoaded':
+ if(cmenu) cmenu.destroy();
+ cmenu = null;
+ var s = '';
+ for(var i in tabLists) {
+ s += '';
+ }
+ $('#listsmenucontainer ul').html(s);
+ break;
+ case 'listAdded':
+ if(cmenu) cmenu.destroy();
+ cmenu = null;
+ $('#listsmenucontainer ul').append('');
+ break;
+ case 'listRenamed':
+ $('#cmenu_move\\:'+opts.list.id).text(opts.list.name);
+ break;
+ }
+}
+
+function moveTaskToList(taskId, listId)
+{
+ if(curList.id == listId) return;
+ setAjaxErrorTrigger();
+ $.post('ajax.php?moveTask&rnd='+Math.random(), { id:taskId, from:curList.id, to:listId }, function(json){
+ resetAjaxErrorTrigger();
+ if(!parseInt(json.total)) return;
+ delete taskList[taskId];
+ taskOrder.splice($.inArray(taskId,taskOrder), 1);
+ $('#taskrow_'+taskId).fadeOut('normal', function(){ $(this).remove() });
+ $('#total').html( parseInt($('#total').text())-1 );
+ }, 'json');
+ $("#edittags").flushCache();
+ flag.tagsChanged = true;
}
diff --git a/src/ajax.php b/src/ajax.php
index 9994133..d393c5e 100644
--- a/src/ajax.php
+++ b/src/ajax.php
@@ -159,21 +159,10 @@ elseif(isset($_GET['fullNewTask']))
}
elseif(isset($_GET['deleteTask']))
{
- check_write_access();
$id = (int)$_GET['deleteTask'];
- $tags = get_task_tags($id);
- $db->ex("BEGIN");
- if($tags) {
- $s = implode(',', $tags);
- $db->ex("DELETE FROM {$db->prefix}tag2task WHERE task_id=$id");
- $db->ex("UPDATE {$db->prefix}tags SET tags_count=tags_count-1 WHERE id IN ($s)");
- $db->ex("DELETE FROM {$db->prefix}tags WHERE tags_count < 1"); # slow on large amount of tags
- }
- $db->dq("DELETE FROM {$db->prefix}todolist WHERE id=$id");
- $affected = $db->affected();
- $db->ex("COMMIT");
+ $deleted = deleteTask($id);
$t = array();
- $t['total'] = $affected;
+ $t['total'] = $deleted;
$t['list'][] = array('id'=>$id);
echo json_encode($t);
exit;
@@ -425,6 +414,16 @@ elseif(isset($_GET['publishList']))
echo json_encode(array('total'=>1));
exit;
}
+elseif(isset($_GET['moveTask']))
+{
+ check_write_access();
+ $id = (int)_post('id');
+// $fromId = (int)_post('from');
+ $toId = (int)_post('to');
+ $r = moveTask($id, $toId);
+ echo json_encode(array('total'=>$r?1:0));
+ exit;
+}
###################################################################################################
@@ -671,4 +670,47 @@ function myExceptionHandler($e)
exit;
}
+function deleteTask($id)
+{
+ check_write_access();
+ global $db;
+ $tags = get_task_tags($id);
+ $db->ex("BEGIN");
+ if($tags) {
+ $s = implode(',', $tags);
+ $db->ex("DELETE FROM {$db->prefix}tag2task WHERE task_id=$id");
+ $db->ex("UPDATE {$db->prefix}tags SET tags_count=tags_count-1 WHERE id IN ($s)");
+ $db->ex("DELETE FROM {$db->prefix}tags WHERE tags_count < 1"); # slow on large amount of tags
+ }
+ $db->dq("DELETE FROM {$db->prefix}todolist WHERE id=$id");
+ $affected = $db->affected();
+ $db->ex("COMMIT");
+ return $affected;
+}
+
+function moveTask($id, $listId)
+{
+ check_write_access();
+ global $db;
+ $r = $db->sqa("SELECT * FROM {$db->prefix}todolist WHERE id=?", array($id));
+ if(!$r || $listId == $r['list_id']) return false;
+ if(!$db->sq("SELECT COUNT(*) FROM {$db->prefix}lists WHERE id=?", $listId))
+ return false;
+
+ $ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM {$db->prefix}todolist WHERE list_id=? AND compl=?", array($listId, $r['compl']?1:0));
+ $tags = get_task_tags($id);
+ $db->ex("BEGIN");
+ if($tags)
+ {
+ $s = implode(',', $tags);
+ $db->ex("DELETE FROM {$db->prefix}tag2task WHERE task_id=?", $id);
+ $db->ex("UPDATE {$db->prefix}tags SET tags_count=tags_count-1 WHERE id IN ($s)");
+ $db->ex("DELETE FROM {$db->prefix}tags WHERE tags_count < 1"); #slow
+ update_task_tags($id, prepare_tags($r['tags'], $listId));
+ }
+ $db->dq("UPDATE {$db->prefix}todolist SET list_id=?, ow=? WHERE id=?", array($listId, $ow, $id));
+ $db->ex("COMMIT");
+ return true;
+}
+
?>
\ No newline at end of file
diff --git a/src/index.php b/src/index.php
index 481625e..592381f 100644
--- a/src/index.php
+++ b/src/index.php
@@ -218,9 +218,7 @@ $().ajaxStop( function(r,s) {$("#loading").fadeOut();} );
-
+
diff --git a/src/lang/class.default.php b/src/lang/class.default.php
index 8617b64..6535c51 100644
--- a/src/lang/class.default.php
+++ b/src/lang/class.default.php
@@ -70,6 +70,7 @@ class DefaultLang
'action_note' => "Edit Note",
'action_delete' => "Delete",
'action_priority' => "Priority",
+ 'action_move' => "Move to",
'notes' => "Notes:",
'notes_show' => "Show",
'notes_hide' => "Hide",
diff --git a/src/lang/en.php b/src/lang/en.php
index 7157afb..fa56584 100644
--- a/src/lang/en.php
+++ b/src/lang/en.php
@@ -3,11 +3,11 @@
/*
myTinyTodo language pack
Language: English
- Language Original: English
+ Translated: English
Author: Max Pozdeev
Author Url: http://www.mytinytodo.net
AppVersion: v1.3.2
- Date: 2009-12-19
+ Date: 2009-12-26
*/
class Lang extends DefaultLang
@@ -75,6 +75,7 @@ class Lang extends DefaultLang
'action_note' => "Edit Note",
'action_delete' => "Delete",
'action_priority' => "Priority",
+ 'action_move' => "Move to",
'notes' => "Notes:",
'notes_show' => "Show",
'notes_hide' => "Hide",