[empathy: 10/28] Factor out toggleExpander()



commit c6837f3edb97b06d1aff8e4300d58653b9484713
Author: Danielle Madeley <danielle madeley collabora co uk>
Date:   Mon Aug 8 11:14:49 2011 +1000

    Factor out toggleExpander()

 data/empathy-log-window.html |   43 ++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 18 deletions(-)
---
diff --git a/data/empathy-log-window.html b/data/empathy-log-window.html
index f2e0cdf..839ddee 100644
--- a/data/empathy-log-window.html
+++ b/data/empathy-log-window.html
@@ -57,6 +57,29 @@ function getToggle(node)
   return filterNodes(node, 'SPAN')[0];
 }
 
+function toggleExpander(node, open)
+{
+  var toggle = getToggle(node);
+  var display;
+  var nodes;
+
+  if (open)
+    {
+      toggle.setAttribute('class', 'open');
+      display = 'block';
+    }
+  else
+    {
+      toggle.setAttribute('class', 'closed');
+      display = 'none';
+    }
+
+  nodes = getNodes(node);
+
+  for (var i = 0; i < nodes.length; i++)
+    nodes[i].style.display = display;
+}
+
 function insertRow (path, text)
 {
   var treeview = document.getElementById('treeview');
@@ -91,26 +114,10 @@ function insertRow (path, text)
 
   toggle.onclick = function (e)
     {
-      var display;
-      var nodes;
-
       if (toggle.getAttribute('class') == 'closed')
-        {
-          toggle.setAttribute('class', 'open');
-          display = 'block';
-        }
+        toggleExpander(newnode, true);
       else
-        {
-          toggle.setAttribute('class', 'closed');
-          display = 'none';
-        }
-
-      // console.log("clicked: " + display);
-
-      nodes = getNodes(newnode);
-
-      for (var i = 0; i < nodes.length; i++)
-        nodes[i].style.display = display;
+        toggleExpander(newnode, false);
     };
   
   var contents = document.createElement('p');



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]