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 | 20 |
| 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]; | |
|
jdufault
2016/06/14 22:50:32
Can you make showPinContainer take a UserPod insta
| |
| 28 | |
| 29 // The top of pod is not set in a css class since some other js will | |
| 30 // overwritte its values. | |
|
jdufault
2016/06/14 22:50:33
nit: overwrite
sammiequon
2016/06/15 21:56:58
Done.
| |
| 31 if (visible) | |
| 32 pod.style.top = '-200px'; | |
| 33 else | |
| 34 pod.style.top = '0'; | |
| 35 | |
| 36 for (var idx = 0; idx < elems.length; idx++) { | |
| 37 if (visible) { | |
| 38 elems[idx].classList.add('pin-enabled'); | |
|
jdufault
2016/06/14 22:50:33
Since you're typing elems[idx] 4 times, I think it
sammiequon
2016/06/15 21:56:58
Done.
| |
| 39 elems[idx].classList.remove('pin-disabled'); | |
| 40 } | |
| 41 else { | |
| 42 elems[idx].classList.add('pin-disabled'); | |
| 43 elems[idx].classList.remove('pin-enabled'); | |
| 44 } | |
| 45 } | |
| 46 }; | |
| 47 | |
| 21 // Called after polymer has been loaded. Fades the pin element in. | 48 // Called after polymer has been loaded. Fades the pin element in. |
| 22 var onPinLoaded = function(pinContainer) { | 49 var onPinLoaded = function(pinContainer) { |
| 23 pinContainer.style.opacity = 1; | 50 showPinContainer(true); |
| 24 }; | 51 }; |
| 25 | 52 |
| 26 // We only load the PIN element when it is actually shown so that lock screen | 53 // 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. | 54 // load times remain low when the user is not using a PIN. |
| 28 // | 55 // |
| 29 // Loading the PIN element blocks the DOM, which will interrupt any running | 56 // 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 | 57 // animations. We load the PIN after an idle notification to allow the pod |
| 31 // fly-in animation to complete without interruption. | 58 // fly-in animation to complete without interruption. |
| 32 if (loadTimeData.getBoolean('showPin')) { | 59 if (loadTimeData.getBoolean('showPin')) { |
| 33 cr.ui.login.ResourceLoader.loadAssetsOnIdle('custom-elements', function() { | 60 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. | 98 * Reloads content of the page. |
| 72 * @param {!Object} data New dictionary with i18n values. | 99 * @param {!Object} data New dictionary with i18n values. |
| 73 */ | 100 */ |
| 74 reloadContent: function(data) { | 101 reloadContent: function(data) { |
| 75 loadTimeData.overrideValues(data); | 102 loadTimeData.overrideValues(data); |
| 76 i18nTemplate.process(document, loadTimeData); | 103 i18nTemplate.process(document, loadTimeData); |
| 77 Oobe.getInstance().updateLocalizedContent_(); | 104 Oobe.getInstance().updateLocalizedContent_(); |
| 78 }, | 105 }, |
| 79 }; | 106 }; |
| 80 }); | 107 }); |
| OLD | NEW |