[Svn] r3411 - trunk/roundcubemail/program/js

trac at roundcube.net trac at roundcube.net
Wed Mar 24 10:47:45 CET 2010


Author: thomasb
Date: 2010-03-24 04:47:45 -0500 (Wed, 24 Mar 2010)
New Revision: 3411

Modified:
   trunk/roundcubemail/program/js/app.js
   trunk/roundcubemail/program/js/list.js
Log:
Only select childs when a message row is collapsed but also do it when deleting a thread

Modified: trunk/roundcubemail/program/js/app.js
===================================================================
--- trunk/roundcubemail/program/js/app.js	2010-03-24 09:28:59 UTC (rev 3410)
+++ trunk/roundcubemail/program/js/app.js	2010-03-24 09:47:45 UTC (rev 3411)
@@ -2203,32 +2203,38 @@
 
   // delete selected messages from the current mailbox
   this.delete_messages = function()
-    {
-    var selection = this.message_list ? this.message_list.get_selection() : new Array();
+  {
+    var selection = this.message_list ? $.merge([], this.message_list.get_selection()) : new Array();
 
     // exit if no mailbox specified or if selection is empty
     if (!this.env.uid && !selection.length)
       return;
-
+      
+    // also select childs of collapsed rows
+    for (var uid, i=0; i < selection.length; i++) {
+      uid = selection[i];
+      if (this.message_list.rows[uid].has_children && !this.message_list.rows[uid].expanded)
+        this.message_list.select_childs(uid);
+    }
+    
     // if config is set to flag for deletion
     if (this.env.flag_for_deletion) {
       this.mark_message('delete');
       return false;
-      }
+    }
     // if there isn't a defined trash mailbox or we are in it
     else if (!this.env.trash_mailbox || this.env.mailbox == this.env.trash_mailbox) 
       this.permanently_remove_messages();
     // if there is a trash mailbox defined and we're not currently in it
     else {
       // if shift was pressed delete it immediately
-      if (this.message_list && this.message_list.shiftkey)
-        {
+      if (this.message_list && this.message_list.shiftkey) {
         if (confirm(this.get_label('deletemessagesconfirm')))
           this.permanently_remove_messages();
-        }
+      }
       else
         this.move_messages(this.env.trash_mailbox);
-      }
+    }
 
     return true;
   };
@@ -2260,7 +2266,7 @@
       for (var n=0; n<selection.length; n++) {
         id = selection[n];
         a_uids[a_uids.length] = id;
-	count += this.update_thread(id);
+        count += this.update_thread(id);
         this.message_list.remove_row(id, (this.env.display_next && n == selection.length-1));
       }
       // make sure there are no selected rows

Modified: trunk/roundcubemail/program/js/list.js
===================================================================
--- trunk/roundcubemail/program/js/list.js	2010-03-24 09:28:59 UTC (rev 3410)
+++ trunk/roundcubemail/program/js/list.js	2010-03-24 09:47:45 UTC (rev 3411)
@@ -658,7 +658,30 @@
     this.select_row(first_row, false, false);  
 },
 
+/**
+ * Add all childs of the given row to selection
+ */
+select_childs: function(uid)
+{
+  if (!this.rows[uid] || !this.rows[uid].has_children)
+    return;
+  
+  var depth = this.rows[uid].depth;
+  var row = this.rows[uid].obj.nextSibling;
+  while (row) {
+    if (row.nodeType == 1) {
+      if ((r = this.rows[row.uid])) {
+        if (!r.depth || r.depth <= depth)
+          break;
+        if (!this.in_selection(r.uid))
+          this.select_row(r.uid, CONTROL_KEY);
+      }
+    }
+    row = row.nextSibling;
+  }
+},
 
+
 /**
  * Perform selection when shift key is pressed
  */
@@ -1013,21 +1036,8 @@
     var depth, row, uid, r;
     for (var n=0; n < selection.length; n++) {
       uid = selection[n];
-      if (this.rows[uid].has_children /*&& !this.rows[uid].expanded*/) {
-        depth = this.rows[uid].depth;
-        row = this.rows[uid].obj.nextSibling;
-        while (row) {
-          if (row.nodeType == 1) {
-            if ((r = this.rows[row.uid])) {
-              if (!r.depth || r.depth <= depth)
-                break;
-              if (!this.in_selection(r.uid))
-                this.select_row(r.uid, CONTROL_KEY);
-            }
-          }
-          row = row.nextSibling;
-        }
-      }
+      if (this.rows[uid].has_children && !this.rows[uid].expanded)
+        this.select_childs(uid);
     }
 
     // get subjects of selected messages

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list