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 // Asynchronously loads the pin keyboard. | 11 /** |
| 12 function showPinKeyboardAsync() { | 12 * Asynchronously loads the pin keyboard. |
| 13 * @param {Object) userPod Pod to hide/unhide elements. | |
| 14 * @param {boolean} visible Whether to make the pin visible. | |
| 15 */ | |
| 16 function showPinKeyboardAsync(userPod, visible) { | |
|
jdufault
2016/06/17 18:54:22
Please rename this function now that it can also h
sammiequon
2016/06/22 23:26:16
Done.
| |
| 13 'use strict'; | 17 'use strict'; |
| 14 | 18 |
| 19 var setPinVisibility = function(userPod, visible) { | |
|
jdufault
2016/06/17 18:54:22
If the |userPod| and |visible| params are removed
| |
| 20 var elements = [userPod.authElement, userPod.imageElement, | |
| 21 userPod.signInElement, userPod, userPod.pinContainer]; | |
|
jdufault
2016/06/17 18:54:22
Make userPod first element in the array?
sammiequon
2016/06/22 23:26:16
Done.
| |
| 22 | |
| 23 for (var idx = 0; idx < elements.length; idx++) { | |
| 24 var currentElement = elements[idx]; | |
| 25 if (visible) { | |
| 26 currentElement.classList.add('pin-enabled'); | |
| 27 currentElement.classList.remove('pin-disabled'); | |
| 28 } | |
| 29 else { | |
|
jdufault
2016/06/17 18:54:22
nit: } else {
sammiequon
2016/06/22 23:26:17
Done.
| |
| 30 currentElement.classList.remove('pin-enabled'); | |
| 31 currentElement.classList.add('pin-disabled'); | |
| 32 } | |
| 33 } | |
| 34 }; | |
| 35 | |
| 15 // This function could get called multiple times. Do nothing if we have | 36 // This function could get called multiple times. Do nothing if we have |
| 16 // already loaded. This check needs to happen before the registerAssets call, | 37 // already loaded. This check needs to happen before the registerAssets call, |
| 17 // because that will clobber the loaded state. | 38 // because that will clobber the loaded state. |
| 18 if (cr.ui.login.ResourceLoader.alreadyLoadedAssets('custom-elements')) | 39 if (cr.ui.login.ResourceLoader.alreadyLoadedAssets('custom-elements')) { |
| 40 setPinVisibility(userPod, visible); | |
| 19 return; | 41 return; |
| 42 } | |
| 20 | 43 |
| 21 // Register loader for custom elements. | 44 // Register loader for custom elements. |
| 22 cr.ui.login.ResourceLoader.registerAssets({ | 45 cr.ui.login.ResourceLoader.registerAssets({ |
| 23 id: 'custom-elements', | 46 id: 'custom-elements', |
| 24 html: [{ url: 'chrome://oobe/custom_elements.html' }] | 47 html: [{ url: 'chrome://oobe/custom_elements.html' }] |
| 25 }); | 48 }); |
| 26 | 49 |
| 27 // Called after polymer has been loaded. Fades the pin element in. | 50 // Called after polymer has been loaded. Fades the pin element in. |
| 28 var onPinLoaded = function(pinContainer) { | 51 var onPinLoaded = function(pinContainer) { |
| 29 pinContainer.style.opacity = 1; | 52 setPinVisibility(userPod, true); |
|
jdufault
2016/06/17 18:54:22
true should be |visible|, if you call showPinKeybo
| |
| 30 }; | 53 }; |
| 31 | 54 |
| 32 // We only load the PIN element when it is actually shown so that lock screen | 55 // We only load the PIN element when it is actually shown so that lock screen |
| 33 // load times remain low when the user is not using a PIN. | 56 // load times remain low when the user is not using a PIN. |
| 34 // | 57 // |
| 35 // Loading the PIN element blocks the DOM, which will interrupt any running | 58 // Loading the PIN element blocks the DOM, which will interrupt any running |
| 36 // animations. We load the PIN after an idle notification to allow the pod | 59 // animations. We load the PIN after an idle notification to allow the pod |
| 37 // fly-in animation to complete without interruption. | 60 // fly-in animation to complete without interruption. |
| 38 cr.ui.login.ResourceLoader.loadAssetsOnIdle('custom-elements', function() { | 61 cr.ui.login.ResourceLoader.loadAssetsOnIdle('custom-elements', function() { |
| 39 cr.ui.login.ResourceLoader.waitUntilLayoutComplete('pin-container', | 62 cr.ui.login.ResourceLoader.waitUntilLayoutComplete('pin-container', |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 * Reloads content of the page. | 98 * Reloads content of the page. |
| 76 * @param {!Object} data New dictionary with i18n values. | 99 * @param {!Object} data New dictionary with i18n values. |
| 77 */ | 100 */ |
| 78 reloadContent: function(data) { | 101 reloadContent: function(data) { |
| 79 loadTimeData.overrideValues(data); | 102 loadTimeData.overrideValues(data); |
| 80 i18nTemplate.process(document, loadTimeData); | 103 i18nTemplate.process(document, loadTimeData); |
| 81 Oobe.getInstance().updateLocalizedContent_(); | 104 Oobe.getInstance().updateLocalizedContent_(); |
| 82 }, | 105 }, |
| 83 }; | 106 }; |
| 84 }); | 107 }); |
| OLD | NEW |