From 84a3312f0b16fdf02061d8bbdc62228290b0beeb Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Wed, 24 Mar 2010 05:47:45 -0400
Subject: [PATCH] Only select childs when a message row is collapsed but also do it when deleting a thread

---
 program/js/list.js |   40 +++++++++++++++++++++++++---------------
 1 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/program/js/list.js b/program/js/list.js
index c5267ee..614d9c3 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -658,6 +658,29 @@
     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

--
Gitblit v1.9.1