OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 var chrome = chrome || {}; | 5 var chrome = chrome || {}; |
6 | 6 |
7 /** | 7 /** |
8 * Organizes all signin event listeners and asynchronous requests. | 8 * Organizes all signin event listeners and asynchronous requests. |
9 * This object has no public constructor. | 9 * This object has no public constructor. |
10 * @type {Object} | 10 * @type {Object} |
11 */ | 11 */ |
12 chrome.signin = chrome.signin || {}; | 12 chrome.signin = chrome.signin || {}; |
13 | 13 |
14 (function() { | 14 (function() { |
15 | 15 |
16 // TODO(vishwath): This function is identical to the one in sync_internals.js | 16 // TODO(vishwath): This function is identical to the one in sync_internals.js |
17 // Merge both if possible. | 17 // Merge both if possible. |
18 // Accepts a DOM node and sets its highlighted attribute oldVal != newVal | 18 // Accepts a DOM node and sets its highlighted attribute oldVal != newVal |
19 function highlightIfChanged(node, oldVal, newVal) { | 19 function highlightIfChanged(node, oldVal, newVal) { |
20 var oldStr = oldVal.toString(); | 20 var oldStr = oldVal.toString(); |
21 var newStr = newVal.toString(); | 21 var newStr = newVal.toString(); |
22 if (oldStr != '' && oldStr != newStr) { | 22 if (oldStr != '' && oldStr != newStr) { |
23 // Note the addListener function does not end up creating duplicate | 23 // Note the addListener function does not end up creating duplicate |
24 // listeners. There can be only one listener per event at a time. | 24 // listeners. There can be only one listener per event at a time. |
25 // Reference: https://developer.mozilla.org/en/DOM/element.addEventListener | 25 // Reference: https://developer.mozilla.org/en/DOM/element.addEventListener |
26 node.addEventListener('webkitAnimationEnd', | 26 node.addEventListener('webkitAnimationEnd', |
27 function() { this.removeAttribute('highlighted'); }, | 27 function() { this.removeAttribute('highlighted'); }, |
28 false); | 28 false); |
29 node.setAttribute('highlighted'); | 29 node.setAttribute('highlighted', ''); |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 // Wraps highlightIfChanged for multiple conditions. | 33 // Wraps highlightIfChanged for multiple conditions. |
34 function highlightIfAnyChanged(node, oldToNewValList) { | 34 function highlightIfAnyChanged(node, oldToNewValList) { |
35 for (var i = 0; i < oldToNewValList.length; i++) | 35 for (var i = 0; i < oldToNewValList.length; i++) |
36 highlightIfChanged(node, oldToNewValList[i][0], oldToNewValList[i][1]); | 36 highlightIfChanged(node, oldToNewValList[i][0], oldToNewValList[i][1]); |
37 } | 37 } |
38 | 38 |
39 function setClassFromValue(value) { | 39 function setClassFromValue(value) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 function onLoad() { | 176 function onLoad() { |
177 chrome.signin.getSigninInfo(refreshSigninInfo); | 177 chrome.signin.getSigninInfo(refreshSigninInfo); |
178 | 178 |
179 chrome.signin.onSigninInfoChanged.addListener(function(info) { | 179 chrome.signin.onSigninInfoChanged.addListener(function(info) { |
180 refreshSigninInfo(info); | 180 refreshSigninInfo(info); |
181 }); | 181 }); |
182 } | 182 } |
183 | 183 |
184 document.addEventListener('DOMContentLoaded', onLoad, false); | 184 document.addEventListener('DOMContentLoaded', onLoad, false); |
185 })(); | 185 })(); |
OLD | NEW |