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 /** | 5 /** |
6 * @fileoverview Demo login UI. | 6 * @fileoverview Demo login UI. |
7 */ | 7 */ |
8 | 8 |
9 /** | 9 /** |
10 * Handles a user clicking anywhere on the screen. This will log the demo user | 10 * Handles a user clicking anywhere on the screen. This will log the demo user |
11 * in. Yes, this actually _is the intention. | 11 * in. Yes, this actually _is the intention. |
12 * @param {Event} e The click event that triggered this function. | 12 * @param {Event} e The click event that triggered this function. |
13 */ | 13 */ |
14 onClick = function(e) { | 14 onClick = function(e) { |
15 document.removeEventListener('click', onClick); | 15 document.removeEventListener('click', onClick); |
16 e.stopPropagation(); | 16 e.stopPropagation(); |
| 17 showLoginSpinner(); |
17 chrome.send('launchDemoUser'); | 18 chrome.send('launchDemoUser'); |
18 }; | 19 }; |
19 | 20 |
20 /** | 21 /** |
21 * Initializes the click handler. | 22 * Initializes the click handler. |
22 */ | 23 */ |
23 initialize = function() { | 24 initialize = function() { |
24 $('page').style.opacity = 1; | 25 $('page').style.opacity = 1; |
25 document.addEventListener('click', onClick); | 26 document.addEventListener('click', onClick); |
26 chrome.send('demoWebuiReady'); | 27 chrome.send('demoWebuiReady'); |
27 // Report back sign in UI being painted. | 28 // Report back sign in UI being painted. |
28 window.webkitRequestAnimationFrame(function() { | 29 window.webkitRequestAnimationFrame(function() { |
29 chrome.send('loginVisible', ['demo']); | 30 chrome.send('loginVisible', ['demo']); |
30 }); | 31 }); |
31 }; | 32 }; |
32 | 33 |
| 34 /** |
| 35 * Show the login spinner. |
| 36 */ |
| 37 showLoginSpinner = function() { |
| 38 // We're already logging in - don't login on click. |
| 39 document.removeEventListener('click', onClick); |
| 40 |
| 41 // Hide the "Click to start" assets. |
| 42 $('logo').hidden = true; |
| 43 $('demo-login-text').hidden = true; |
| 44 |
| 45 // Show the "Logging in" assets. |
| 46 $('logo-login').hidden = false; |
| 47 $('login-spinner').hidden = false; |
| 48 }; |
| 49 |
33 disableTextSelectAndDrag(); | 50 disableTextSelectAndDrag(); |
34 document.addEventListener('DOMContentLoaded', initialize); | 51 document.addEventListener('DOMContentLoaded', initialize); |
OLD | NEW |