diff options
author | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2011-08-08 09:14:49 +0800 |
---|---|---|
committer | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2011-08-08 09:14:49 +0800 |
commit | c6837f3edb97b06d1aff8e4300d58653b9484713 (patch) | |
tree | 8b13122d65125f2c1e9b17a86df9caf6b3c661b0 | |
parent | 7424ac01d5010aaa101c2b5841daf840b4d0e20c (diff) | |
download | gsoc2013-empathy-c6837f3edb97b06d1aff8e4300d58653b9484713.tar gsoc2013-empathy-c6837f3edb97b06d1aff8e4300d58653b9484713.tar.gz gsoc2013-empathy-c6837f3edb97b06d1aff8e4300d58653b9484713.tar.bz2 gsoc2013-empathy-c6837f3edb97b06d1aff8e4300d58653b9484713.tar.lz gsoc2013-empathy-c6837f3edb97b06d1aff8e4300d58653b9484713.tar.xz gsoc2013-empathy-c6837f3edb97b06d1aff8e4300d58653b9484713.tar.zst gsoc2013-empathy-c6837f3edb97b06d1aff8e4300d58653b9484713.zip |
Factor out toggleExpander()
-rw-r--r-- | 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 f2e0cdfe1..839ddee53 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'); |