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 3// found in the LICENSE file. 4 5cr.define('chrome.sync.events_tab', function() { 6 'use strict'; 7 8 function toggleDisplay(event) { 9 var originatingButton = event.target; 10 if (originatingButton.className != 'toggle-button') { 11 return; 12 } 13 var detailsNode = originatingButton.parentNode.getElementsByClassName( 14 'details')[0]; 15 var detailsColumn = detailsNode.parentNode; 16 var detailsRow = detailsColumn.parentNode; 17 18 if (!detailsRow.classList.contains('expanded')) { 19 detailsRow.classList.toggle('expanded'); 20 detailsColumn.setAttribute('colspan', 4); 21 detailsNode.removeAttribute('hidden'); 22 } else { 23 detailsNode.setAttribute('hidden', ''); 24 detailsColumn.removeAttribute('colspan'); 25 detailsRow.classList.toggle('expanded'); 26 } 27 }; 28 29 function displaySyncEvents() { 30 var entries = chrome.sync.log.entries; 31 var eventTemplateContext = { 32 eventList: entries, 33 }; 34 var context = new JsEvalContext(eventTemplateContext); 35 jstProcess(context, $('sync-events')); 36 }; 37 38 function onLoad() { 39 $('sync-events').addEventListener('click', toggleDisplay); 40 chrome.sync.log.addEventListener('append', function(event) { 41 displaySyncEvents(); 42 }); 43 } 44 45 return { 46 onLoad: onLoad 47 }; 48}); 49 50document.addEventListener( 51 'DOMContentLoaded', chrome.sync.events_tab.onLoad, false); 52