Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 Login UI based on a stripped down OOBE controller. | 6 * @fileoverview Login UI based on a stripped down OOBE controller. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 <include src="login_shared.js"> | 9 <include src="login_shared.js"> |
| 10 | 10 |
| 11 // Lazy load polymer. | 11 // Lazy load polymer. |
| 12 (function() { | 12 (function() { |
| 13 'use strict'; | 13 'use strict'; |
| 14 | 14 |
| 15 // Register loader for custom elements. | 15 // Register loader for custom elements. |
| 16 cr.ui.login.ResourceLoader.registerAssets({ | 16 cr.ui.login.ResourceLoader.registerAssets({ |
| 17 id: 'custom-elements', | 17 id: 'custom-elements', |
| 18 html: [{ url: 'chrome://oobe/custom_elements.html' }] | 18 html: [{ url: 'chrome://oobe/custom_elements.html' }] |
| 19 }); | 19 }); |
| 20 // TODO(sammiequon): Remove this method once showPinContainerUser works. | |
|
jdufault
2016/06/15 22:20:39
nit: indent
nit: newline before the comment
nit: P
sammiequon
2016/06/17 01:00:43
Done.
| |
| 21 var showPinContainer = function(visible) { | |
| 22 var authContainer = document.getElementsByClassName('auth-container')[0]; | |
| 23 var pinContainer = $('pin-container'); | |
| 24 var signIn = document.getElementsByClassName('signed-in-indicator')[0]; | |
| 25 var pod = document.getElementsByClassName('pod')[0]; | |
| 26 var userImage = document.getElementsByClassName('user-image')[0]; | |
| 27 var elems = [authContainer, pinContainer, signIn, pod, userImage]; | |
| 28 | |
| 29 for (var idx = 0; idx < elems.length; idx++) { | |
| 30 var currElem = elems[idx]; | |
|
jdufault
2016/06/15 22:20:38
Typically we don't abbreviate, so either currentEl
sammiequon
2016/06/17 01:00:43
Done.
| |
| 31 if (visible) { | |
| 32 currElem.classList.add('pin-enabled'); | |
| 33 currElem.classList.remove('pin-disabled'); | |
| 34 } | |
| 35 else { | |
| 36 currElem.classList.add('pin-disabled'); | |
|
jdufault
2016/06/15 22:20:39
flip-flop the order here so pin-enabled is always
sammiequon
2016/06/17 01:00:43
Done.
| |
| 37 currElem.classList.remove('pin-enabled'); | |
| 38 } | |
| 39 } | |
| 40 }; | |
| 41 | |
| 42 var showPinContainer = function(visible, userPod) { | |
|
jdufault
2016/06/15 22:20:38
Only one of these definitions should be committed.
| |
| 43 var authContainer = userPod.authElement; | |
| 44 var pinContainer = userPod.pinKeyboard; | |
| 45 var signIn = userPod.signInElement; | |
| 46 var pod = userPod; | |
| 47 var userImage = userPod.imageElement; | |
|
jdufault
2016/06/15 22:20:39
I don't think the local variables give us much in
sammiequon
2016/06/17 01:00:43
Done.
| |
| 48 var elems = [authContainer, pinContainer, signIn, pod, userImage]; | |
| 49 | |
| 50 for (var idx = 0; idx < elems.length; idx++) { | |
| 51 var currElem = elems[idx]; | |
| 52 if (visible) { | |
| 53 currElem.classList.add('pin-enabled'); | |
| 54 currElem.classList.remove('pin-disabled'); | |
| 55 } | |
| 56 else { | |
| 57 currElem.classList.add('pin-disabled'); | |
| 58 currElem.classList.remove('pin-enabled'); | |
| 59 } | |
| 60 } | |
| 61 }; | |
| 20 | 62 |
| 21 // Called after polymer has been loaded. Fades the pin element in. | 63 // Called after polymer has been loaded. Fades the pin element in. |
| 22 var onPinLoaded = function(pinContainer) { | 64 var onPinLoaded = function(pinContainer) { |
| 23 pinContainer.style.opacity = 1; | 65 showPinContainer(true); |
| 24 }; | 66 }; |
| 25 | 67 |
| 26 // We only load the PIN element when it is actually shown so that lock screen | 68 // We only load the PIN element when it is actually shown so that lock screen |
| 27 // load times remain low when the user is not using a PIN. | 69 // load times remain low when the user is not using a PIN. |
| 28 // | 70 // |
| 29 // Loading the PIN element blocks the DOM, which will interrupt any running | 71 // Loading the PIN element blocks the DOM, which will interrupt any running |
| 30 // animations. We load the PIN after an idle notification to allow the pod | 72 // animations. We load the PIN after an idle notification to allow the pod |
| 31 // fly-in animation to complete without interruption. | 73 // fly-in animation to complete without interruption. |
| 32 if (loadTimeData.getBoolean('showPin')) { | 74 if (loadTimeData.getBoolean('showPin')) { |
| 33 cr.ui.login.ResourceLoader.loadAssetsOnIdle('custom-elements', function() { | 75 cr.ui.login.ResourceLoader.loadAssetsOnIdle('custom-elements', function() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 * Reloads content of the page. | 113 * Reloads content of the page. |
| 72 * @param {!Object} data New dictionary with i18n values. | 114 * @param {!Object} data New dictionary with i18n values. |
| 73 */ | 115 */ |
| 74 reloadContent: function(data) { | 116 reloadContent: function(data) { |
| 75 loadTimeData.overrideValues(data); | 117 loadTimeData.overrideValues(data); |
| 76 i18nTemplate.process(document, loadTimeData); | 118 i18nTemplate.process(document, loadTimeData); |
| 77 Oobe.getInstance().updateLocalizedContent_(); | 119 Oobe.getInstance().updateLocalizedContent_(); |
| 78 }, | 120 }, |
| 79 }; | 121 }; |
| 80 }); | 122 }); |
| OLD | NEW |