summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/chromeos/login/demo_user_login.js
blob: 1fefc2368571603fc87fbd431e9ffb2f7a8e38c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @fileoverview Demo login UI.
 */

/**
 * Handles a user clicking anywhere on the screen. This will log the demo user
 * in. Yes, this actually _is the intention.
 * @param {Event} e The click event that triggered this function.
 */
onClick = function(e) {
  document.removeEventListener('click', onClick);
  e.stopPropagation();
  showLoginSpinner();
  chrome.send('launchDemoUser');
};

/**
 * Initializes the click handler.
 */
initialize = function() {
  $('page').style.opacity = 1;
  document.addEventListener('click', onClick);
  // Report back sign in UI being painted.
  window.webkitRequestAnimationFrame(function() {
    chrome.send('loginVisible', ['demo']);
  });
};

/**
 * Show the login spinner.
 */
showLoginSpinner = function() {
  // We're already logging in - don't login on click.
  document.removeEventListener('click', onClick);

  // Hide the "Click to start" and show the spinner.
  $('demo-login-text').hidden = true;
  $('login-spinner').hidden = false;
};

disableTextSelectAndDrag();
document.addEventListener('DOMContentLoaded', initialize);