| OLD | NEW |
| (Empty) |
| 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 | |
| 5 cr.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 if (screen === 'confirmation-screen') { | |
| 36 // Focus on the submit button when showing the confirmation-screen. | |
| 37 $('close').focus(); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 function showInitialScreen() { | |
| 42 showScreen('login-screen'); | |
| 43 document.addEventListener('keydown', onKeydown); | |
| 44 $('gaialogin').contentWindow.addEventListener('keydown', onKeydown); | |
| 45 } | |
| 46 | |
| 47 function onKeydown(e) { | |
| 48 // Handle ESC key. | |
| 49 if (e.keyIdentifier === 'U+001B') { | |
| 50 e.stopPropagation(); | |
| 51 chrome.send("DialogClose", [""]); | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 function onLoad() { | |
| 56 chrome.send('enrollmentScreenReady', []); | |
| 57 } | |
| 58 | |
| 59 return { | |
| 60 showScreen: showScreen, | |
| 61 showInitialScreen: showInitialScreen, | |
| 62 onLoad: onLoad | |
| 63 }; | |
| 64 }); | |
| 65 | |
| 66 document.addEventListener('DOMContentLoaded', | |
| 67 enterpriseEnrollment.onLoad); | |
| OLD | NEW |