OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function() { | 5 (function() { |
6 'use strict'; | 6 'use strict'; |
7 var toggleDisplay = function(event) { | 7 var toggleDisplay = function(event) { |
8 var originatingButton = event.target; | 8 var originatingButton = event.target; |
9 if (originatingButton.className != 'toggleButton') { | |
10 return; | |
11 } | |
9 var detailsNode = originatingButton.parentNode.getElementsByClassName( | 12 var detailsNode = originatingButton.parentNode.getElementsByClassName( |
10 'details')[0]; | 13 'details')[0]; |
14 var detailsColumn = detailsNode.parentNode; | |
15 var detailsRow = detailsColumn.parentNode; | |
11 | 16 |
12 if (detailsNode.getAttribute('hidden') != null) { | 17 if (detailsNode.getAttribute('hidden') != null) { |
rlarocque
2014/08/07 22:49:12
hasAttribute()?
Nicolas Zea
2014/08/21 22:29:57
Done.
| |
18 for (var node in detailsRow.childNodes) { | |
rlarocque
2014/08/07 22:49:12
Rather than iterate and change the DOM structure l
Nicolas Zea
2014/08/21 22:29:57
Done.
| |
19 if (detailsRow.childNodes[node].nodeType == 1) { | |
rlarocque
2014/08/07 22:49:12
== Node.ELEMENT_NODE?
Better yet, why not just it
Nicolas Zea
2014/08/21 22:29:57
I'd still have to check the nodeType though right?
| |
20 detailsRow.childNodes[node].setAttribute('hidden', 'hidden'); | |
rlarocque
2014/08/07 22:49:12
set value to ''? A hidden=hidden attribute seems
Nicolas Zea
2014/08/21 22:29:57
Done.
| |
21 } | |
22 } | |
23 detailsColumn.removeAttribute('hidden'); | |
24 detailsColumn.setAttribute('colspan', 4); | |
13 detailsNode.removeAttribute('hidden'); | 25 detailsNode.removeAttribute('hidden'); |
14 } else { | 26 } else { |
15 detailsNode.setAttribute('hidden', 'hidden'); | 27 detailsNode.setAttribute('hidden', 'hidden'); |
28 detailsColumn.removeAttribute('colspan'); | |
29 for (var node in detailsRow.childNodes) { | |
30 if (detailsRow.childNodes[node].nodeType == 1) { | |
31 detailsRow.childNodes[node].removeAttribute('hidden'); | |
32 } | |
33 } | |
16 } | 34 } |
17 } | 35 }; |
18 | 36 |
19 var syncEvents = $('sync-events'); | 37 var syncEvents = $('sync-events'); |
20 | 38 |
21 var entries = chrome.sync.log.entries; | 39 var entries = chrome.sync.log.entries; |
22 var displaySyncEvents = function() { | 40 var displaySyncEvents = function() { |
23 var eventTemplateContext = { | 41 var eventTemplateContext = { |
24 eventList: entries, | 42 eventList: entries, |
25 }; | 43 }; |
26 var context = new JsEvalContext(eventTemplateContext); | 44 var context = new JsEvalContext(eventTemplateContext); |
27 jstProcess(context, syncEvents); | 45 jstProcess(context, syncEvents); |
28 } | 46 }; |
29 | 47 |
30 syncEvents.addEventListener('click', toggleDisplay); | 48 syncEvents.addEventListener('click', toggleDisplay); |
31 chrome.sync.log.addEventListener('append', function(event) { | 49 chrome.sync.log.addEventListener('append', function(event) { |
32 displaySyncEvents(); | 50 displaySyncEvents(); |
33 }); | 51 }); |
34 })(); | 52 })(); |
OLD | NEW |