enrollment.js revision ddb351dbec246cf1fab5ec20d2d5520909041de1
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('enterpriseEnrollment', function() {
6
7  function showScreen(screen) {
8    var screens = ['login-screen', 'confirmation-screen'];
9    for (var i = 0; i < screens.length; i++) {
10      $(screens[i]).hidden = screens[i] != screen;
11
12      // Hiding an iframe unfortunately doesn't remove it or its contents from
13      // tabbing order. To hack around this:
14      // - Hide the content document (if it exists), so nested elements won't
15      //   receive focus and relinquish focus if they already have it.
16      // - Set tabIndex = -1 on the iframe, so it doesn't get focused itself.
17      //
18      // See https://bugs.webkit.org/show_bug.cgi?id=55861
19      iframes = $(screens[i]).getElementsByTagName('iframe');
20      for (var j = 0; j < iframes.length; j++) {
21        var display = '';
22        if (screens[i] != screen) {
23          display = 'none';
24          iframes[j].tabIndex = -1;
25        } else {
26          display = 'block';
27          iframes[j].removeAttribute('tabIndex');
28        }
29        if (iframes[j].contentDocument && iframes[j].contentDocument.body) {
30          iframes[j].contentDocument.body.style.display = display;
31        }
32      }
33    }
34  }
35
36  function showInitialScreen() {
37    var args = JSON.parse(chrome.dialogArguments);
38    showScreen(args.initialScreen);
39  }
40
41  return {
42    showScreen: showScreen,
43    showInitialScreen: showInitialScreen
44  };
45});
46
47document.addEventListener('DOMContentLoaded',
48                          enterpriseEnrollment.showInitialScreen);
49