[Isocial-svn] SF.net SVN: isocial: [59] app
Status: Pre-Alpha
Brought to you by:
aguidrevitch
From: <di...@us...> - 2008-03-10 16:47:38
|
Revision: 59 http://isocial.svn.sourceforge.net/isocial/?rev=59&view=rev Author: dim0s77 Date: 2008-03-10 09:47:44 -0700 (Mon, 10 Mar 2008) Log Message: ----------- added deleting of single thread Modified Paths: -------------- app/controllers/message_controller.php app/views/message/_rows.tpl app/views/message/inbox.tpl app/views/message/outbox.tpl Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-10 13:36:49 UTC (rev 58) +++ app/controllers/message_controller.php 2008-03-10 16:47:44 UTC (rev 59) @@ -21,12 +21,11 @@ $box_messages = array(); if(!empty($messages)) { foreach ($messages as $message_loop_key => $message) { - if (!isset($inbox_messages[$message->thread_id])) { + if (!isset($box_messages[$message->thread_id])) { $box_messages[$message->thread_id] = $message; } } } - $user_id = $box_message == 'inbox_message' ? 'sender_id' : 'recipient_id'; $this->message_threads = count($box_messages); return $box_messages; } @@ -159,7 +158,7 @@ $this->_delete_thread(); return $this->render(array('partial' => 'rows', 'locals' => array('messages' => $this->_getBoxMessages('outbox_message'), - 'target' => 'sender'))); + 'target' => 'recipient'))); } function _delete_thread () { Modified: app/views/message/_rows.tpl =================================================================== --- app/views/message/_rows.tpl 2008-03-10 13:36:49 UTC (rev 58) +++ app/views/message/_rows.tpl 2008-03-10 16:47:44 UTC (rev 59) @@ -33,7 +33,7 @@ </div> </td> <td class="delete_msg"> - <a href="#" onclick=""> </a> + <a href="#" onclick="delete_single_thread(this)" name="{message.id}"> </a> </td> </tr> {else} @@ -45,4 +45,3 @@ </table> <div class="inbox_footer"><div class="mailbox_size">{message_threads} _{Message Threads}</div></div> - Modified: app/views/message/inbox.tpl =================================================================== --- app/views/message/inbox.tpl 2008-03-10 13:36:49 UTC (rev 58) +++ app/views/message/inbox.tpl 2008-03-10 16:47:44 UTC (rev 59) @@ -17,7 +17,7 @@ <li><a class="disabled">_{Mark as}:</a></li> <li><a href="#" onclick="mark_as_unread(this)" id="unread_link" class="disabled">_{Unread},</a></li> <li><a href="#" onclick="mark_as_read(this)" id="read_link" class="disabled">_{Read};</a></li> - <li><a href="#" onclick="delete_thread(this)" id="delete_link" class="disabled">_{Delete}</a></li> + <li><a href="#" onclick="delete_threads(this)" id="delete_link" class="disabled">_{Delete}</a></li> </ul> </div> </div> @@ -31,9 +31,15 @@ </form> <script> +var checkids = new Array(); function oncheck (element, is_read) { + checked = $$('input[type=checkbox]:checked'); checkread = $$('input[type=checkbox].checkread:checked'); checkunread = $$('input[type=checkbox].checkunread:checked'); + checkids.clear(); + for (var index = 0; index < checked.length; index++) { + checkids.push(checked[index].id); + } checkread.length ? $("unread_link").removeClassName('disabled') : $("unread_link").addClassName('disabled'); checkunread.length ? $("read_link").removeClassName('disabled') : $("read_link").addClassName('disabled'); @@ -79,14 +85,35 @@ return false; } -function delete_thread (element) { +function delete_threads (element) { new Ajax.Updater('messages', '/message/delete_inbox_thread', - { method:'post', asynchronous:true, parameters:$('messages_form').serialize()}); + { method:'post', + asynchronous:true, + parameters:$('messages_form').serialize() + }); disable_action_links(); return false; } +function delete_single_thread (element) { + new Ajax.Updater('messages', + '/message/delete_inbox_thread', + { method:'post', + asynchronous:true, + parameters: 'check_messages[]=' + element.name, + onComplete: function () { + disable_action_links(); + tocheck = new Array(); + $$('input[type=checkbox]').each( function (el) { + if (checkids.indexOf(el.value) != -1) { tocheck.push(el); } + }); + tocheck.invoke('click'); + } + }); + return false; +} + function disable_action_links () { $("read_link").addClassName('disabled'); $("unread_link").addClassName('disabled'); Modified: app/views/message/outbox.tpl =================================================================== --- app/views/message/outbox.tpl 2008-03-10 13:36:49 UTC (rev 58) +++ app/views/message/outbox.tpl 2008-03-10 16:47:44 UTC (rev 59) @@ -12,12 +12,12 @@ </div> <div class="menu_block"> <ul id="inbox_action" class="buttons"> - <li><a href="#" onclick="delete_thread(this)" id="delete_link" class="disabled">_{Delete}</a></li> + <li><a href="#" onclick="delete_threads(this)" id="delete_link" class="disabled">_{Delete}</a></li> </ul> </div> </div> -<form id="messages_form" action="/message/inbox" method="post" onsubmit="return false;"> +<form id="messages_form" action="/message/outbox" method="post" onsubmit="return false;"> <div id="messages"> <?= $controller->render(array('partial' => 'rows', 'locals' => array('messages' => $outbox_messages, @@ -26,8 +26,13 @@ </form> <script> +var checkids = new Array(); function oncheck (element, is_read) { - checked = $$('input[type=checkbox]:checked'); + checkids = $$('input[type=checkbox]:checked').toArray(); + checkids.clear(); + for (var index = 0; index < checked.length; index++) { + checkids.push(checked[index].id); + } checked.length ? $("delete_link").removeClassName('disabled') : $("delete_link").addClassName('disabled'); }; @@ -46,13 +51,34 @@ } }; -function delete_thread (element) { +function delete_threads (element) { new Ajax.Updater('messages', '/message/delete_outbox_thread', - { method:'post', asynchronous:true, parameters:$('messages_form').serialize()}); + { method:'post', + asynchronous:true, + parameters:$('messages_form').serialize() + }); $("delete_link").addClassName('disabled'); return false; } +function delete_single_thread (element) { + new Ajax.Updater('messages', + '/message/delete_outbox_thread', + { method:'post', + asynchronous:true, + parameters: 'check_messages[]=' + element.name, + onComplete: function () { + $("delete_link").addClassName('disabled'); + tocheck = new Array(); + $$('input[type=checkbox]').each( function (el) { + if (checkids.indexOf(el.value) != -1) { tocheck.push(el); } + }); + tocheck.invoke('click'); + } + }); + return false; +} + </script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |