Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: ui/login/account_picker/md_user_pod_row.js

Issue 2926003002: Refresh UI of public session pods for new login screen (Closed)
Patch Set: Address comments and make minor changes on positioning Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 User pod row implementation. 6 * @fileoverview User pod row implementation.
7 */ 7 */
8 8
9 cr.define('login', function() { 9 cr.define('login', function() {
10 /** 10 /**
11 * Variables used for pod placement processing. Width and height should be 11 * Variables used for pod placement processing. Width and height should be
12 * synced with computed CSS sizes of pods. 12 * synced with computed CSS sizes of pods.
13 */ 13 */
14 var CROS_POD_WIDTH = 306; 14 var CROS_POD_WIDTH = 306;
15 var CROS_SMALL_POD_WIDTH = 304; 15 var CROS_SMALL_POD_WIDTH = 304;
16 var CROS_EXTRA_SMALL_POD_WIDTH = 282; 16 var CROS_EXTRA_SMALL_POD_WIDTH = 282;
17 var DESKTOP_POD_WIDTH = 180; 17 var DESKTOP_POD_WIDTH = 180;
18 var MD_DESKTOP_POD_WIDTH = 160; 18 var MD_DESKTOP_POD_WIDTH = 160;
19 var PUBLIC_EXPANDED_BASIC_WIDTH = 500; 19 var PUBLIC_EXPANDED_WIDTH = 622;
20 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610;
21 var CROS_POD_HEIGHT = 346; 20 var CROS_POD_HEIGHT = 346;
22 var CROS_SMALL_POD_HEIGHT = 74; 21 var CROS_SMALL_POD_HEIGHT = 74;
23 var CROS_EXTRA_SMALL_POD_HEIGHT = 60; 22 var CROS_EXTRA_SMALL_POD_HEIGHT = 60;
24 var DESKTOP_POD_HEIGHT = 226; 23 var DESKTOP_POD_HEIGHT = 226;
25 var MD_DESKTOP_POD_HEIGHT = 200; 24 var MD_DESKTOP_POD_HEIGHT = 200;
25 var PUBLIC_EXPANDED_HEIGHT = 324;
26 var POD_ROW_PADDING = 10; 26 var POD_ROW_PADDING = 10;
27 var DESKTOP_ROW_PADDING = 32; 27 var DESKTOP_ROW_PADDING = 32;
28 var CUSTOM_ICON_CONTAINER_SIZE = 40; 28 var CUSTOM_ICON_CONTAINER_SIZE = 40;
29 var CROS_PIN_POD_HEIGHT = 417; 29 var CROS_PIN_POD_HEIGHT = 417;
30 var SCROLL_MASK_HEIGHT = 112; 30 var SCROLL_MASK_HEIGHT = 112;
31 var BANNER_MESSAGE_WIDTH = 520; 31 var BANNER_MESSAGE_WIDTH = 520;
32 var CROS_POD_HEIGHT_WITH_PIN = 618; 32 var CROS_POD_HEIGHT_WITH_PIN = 618;
33 var PUBLIC_SESSION_ICON_WIDTH = 12;
33 34
34 /** 35 /**
35 * The maximum number of users that each pod placement method can handle. 36 * The maximum number of users that each pod placement method can handle.
36 */ 37 */
37 var POD_ROW_LIMIT = 2; 38 var POD_ROW_LIMIT = 2;
38 var LANDSCAPE_MODE_LIMIT = 6; 39 var LANDSCAPE_MODE_LIMIT = 6;
39 var PORTRAIT_MODE_LIMIT = 9; 40 var PORTRAIT_MODE_LIMIT = 9;
40 41
41 /** 42 /**
42 * Minimal padding between user pod and virtual keyboard. 43 * Minimal padding between user pod and virtual keyboard.
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 1146
1146 /** 1147 /**
1147 * Gets the fingerprint icon area. 1148 * Gets the fingerprint icon area.
1148 * @type {!HTMLDivElement} 1149 * @type {!HTMLDivElement}
1149 */ 1150 */
1150 get fingerprintIconElement() { 1151 get fingerprintIconElement() {
1151 return this.querySelector('.fingerprint-icon-container'); 1152 return this.querySelector('.fingerprint-icon-container');
1152 }, 1153 },
1153 1154
1154 /** 1155 /**
1156 * Returns true if it's a public session pod.
1157 * @type {boolean}
1158 */
1159 get isPublicSessionPod() {
1160 return this.classList.contains('public-account');
1161 },
1162
1163 /**
1155 * Sets the pod style. 1164 * Sets the pod style.
1156 * @param {UserPod.Style} style Style set to the pod. 1165 * @param {UserPod.Style} style Style set to the pod.
1157 */ 1166 */
1158 setPodStyle: function(style) { 1167 setPodStyle: function(style) {
1159 switch (style) { 1168 switch (style) {
1160 case UserPod.Style.LARGE: 1169 case UserPod.Style.LARGE:
1161 this.querySelector('.large-pod').hidden = false; 1170 this.querySelector('.large-pod').hidden = false;
1162 this.querySelector('.small-pod').hidden = true; 1171 this.querySelector('.small-pod').hidden = true;
1163 break; 1172 break;
1164 case UserPod.Style.SMALL: 1173 case UserPod.Style.SMALL:
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 }, 2089 },
2081 2090
2082 /** 2091 /**
2083 * Handles click event on a user pod. 2092 * Handles click event on a user pod.
2084 * @param {Event} e Click event. 2093 * @param {Event} e Click event.
2085 */ 2094 */
2086 handleClickOnPod_: function(e) { 2095 handleClickOnPod_: function(e) {
2087 if (this.parentNode.disabled) 2096 if (this.parentNode.disabled)
2088 return; 2097 return;
2089 2098
2099 // Click events on public session pods should only be handled by their
2100 // overriding handler.
2101 if (this.isPublicSessionPod)
2102 return;
2103
2090 if (this.getPodStyle() != UserPod.Style.LARGE) { 2104 if (this.getPodStyle() != UserPod.Style.LARGE) {
2091 $('pod-row').switchMainPod(this); 2105 $('pod-row').switchMainPod(this);
2092 return; 2106 return;
2093 } 2107 }
2094 Oobe.clearErrors(); 2108 Oobe.clearErrors();
2095 2109
2096 if (!this.isActionBoxMenuActive) { 2110 if (!this.isActionBoxMenuActive) {
2097 if (this.isAuthTypeOnlineSignIn) { 2111 if (this.isAuthTypeOnlineSignIn) {
2098 this.showSigninUI(); 2112 this.showSigninUI();
2099 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) { 2113 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 node.appendChild(el); 2180 node.appendChild(el);
2167 } 2181 }
2168 2182
2169 return node; 2183 return node;
2170 }); 2184 });
2171 2185
2172 PublicAccountUserPod.prototype = { 2186 PublicAccountUserPod.prototype = {
2173 __proto__: UserPod.prototype, 2187 __proto__: UserPod.prototype,
2174 2188
2175 /** 2189 /**
2190 * Keeps track of the pod's original position before it's expanded.
2191 * @type {Object}
2192 * @private
2193 */
2194 lastPosition_: {left: 'unset', top: 'unset'},
jdufault 2017/06/08 00:49:37 Just set/get the variable directly without a wrapp
Wenzhao (Colin) Zang 2017/06/08 01:14:50 Done.
2195 get lastPosition() {
2196 return this.lastPosition_;
2197 },
2198 set lastPosition(value) {
2199 this.lastPosition_ = value;
2200 },
2201
2202 /**
2176 * "Enter" button in expanded side pane. 2203 * "Enter" button in expanded side pane.
2177 * @type {!HTMLButtonElement} 2204 * @type {!HTMLButtonElement}
2178 */ 2205 */
2179 get enterButtonElement() { 2206 get enterButtonElement() {
2180 return this.querySelector('.enter-button'); 2207 return this.querySelector('.enter-button');
2181 }, 2208 },
2182 2209
2183 /** 2210 /**
2184 * Boolean flag of whether the pod is showing the side pane. The flag 2211 * Boolean flag of whether the pod is showing the side pane. The flag
2185 * controls whether 'expanded' class is added to the pod's class list and 2212 * controls whether 'expanded' class is added to the pod's class list and
2186 * resets tab order because main input element changes when the 'expanded' 2213 * resets tab order because main input element changes when the 'expanded'
2187 * state changes. 2214 * state changes.
2188 * @type {boolean} 2215 * @type {boolean}
2189 */ 2216 */
2190 get expanded() { 2217 get expanded() {
2191 return this.classList.contains('expanded'); 2218 return this.classList.contains('expanded');
2192 }, 2219 },
2193 2220
2194 set expanded(expanded) { 2221 set expanded(expanded) {
2222 if (this.getPodStyle() != UserPod.Style.LARGE) {
2223 console.error(
2224 'Attempt to expand a public session pod when it is not large.');
2225 return;
2226 }
2195 if (this.expanded == expanded) 2227 if (this.expanded == expanded)
2196 return; 2228 return;
2197 2229
2198 this.resetTabOrder(); 2230 this.resetTabOrder();
2199 this.classList.toggle('expanded', expanded); 2231 this.classList.toggle('expanded', expanded);
2200 if (expanded) { 2232 if (expanded) {
2201 // Show the advanced expanded pod directly if there are at least two 2233 // Show the advanced expanded pod directly if there are at least two
2202 // recommended locales. This will be the case in multilingual 2234 // recommended locales. This will be the case in multilingual
2203 // environments where users are likely to want to choose among locales. 2235 // environments where users are likely to want to choose among locales.
2204 if (this.querySelector('.language-select').multipleRecommendedLocales) 2236 if (this.querySelector('.language-select').multipleRecommendedLocales)
2205 this.classList.add('advanced'); 2237 this.classList.add('advanced');
2206 this.usualLeft = this.left; 2238 } else {
2207 this.makeSpaceForExpandedPod_(); 2239 this.classList.remove('advanced');
2208 } else if (typeof(this.usualLeft) != 'undefined') {
2209 this.left = this.usualLeft;
2210 } 2240 }
2211 2241 this.parentNode.handlePublicPodExpansion(this, expanded);
2212 var self = this;
2213 this.classList.add('animating');
2214 this.addEventListener('transitionend', function f(e) {
2215 self.removeEventListener('transitionend', f);
2216 self.classList.remove('animating');
2217
2218 // Accessibility focus indicator does not move with the focused
2219 // element. Sends a 'focus' event on the currently focused element
2220 // so that accessibility focus indicator updates its location.
2221 if (document.activeElement)
2222 document.activeElement.dispatchEvent(new Event('focus'));
2223 });
2224 // Guard timer set to animation duration + 20ms.
2225 ensureTransitionEndEvent(this, 200);
2226 }, 2242 },
2227 2243
2228 get advanced() { 2244 get advanced() {
2229 return this.classList.contains('advanced'); 2245 return this.classList.contains('advanced');
2230 }, 2246 },
2231 2247
2232 /** @override */ 2248 /** @override */
2233 get mainInput() { 2249 get mainInput() {
2234 if (this.expanded) 2250 if (this.expanded)
2235 return this.enterButtonElement; 2251 return this.enterButtonElement;
(...skipping 16 matching lines...) Expand all
2252 // newly focused "Enter" button. 2268 // newly focused "Enter" button.
2253 e.preventDefault(); 2269 e.preventDefault();
2254 } 2270 }
2255 }).bind(this)); 2271 }).bind(this));
2256 2272
2257 var learnMore = this.querySelector('.learn-more'); 2273 var learnMore = this.querySelector('.learn-more');
2258 learnMore.addEventListener('mousedown', stopEventPropagation); 2274 learnMore.addEventListener('mousedown', stopEventPropagation);
2259 learnMore.addEventListener('click', this.handleLearnMoreEvent); 2275 learnMore.addEventListener('click', this.handleLearnMoreEvent);
2260 learnMore.addEventListener('keydown', this.handleLearnMoreEvent); 2276 learnMore.addEventListener('keydown', this.handleLearnMoreEvent);
2261 2277
2262 learnMore = this.querySelector('.expanded-pane-learn-more');
2263 learnMore.addEventListener('click', this.handleLearnMoreEvent);
2264 learnMore.addEventListener('keydown', this.handleLearnMoreEvent);
2265
2266 var languageSelect = this.querySelector('.language-select'); 2278 var languageSelect = this.querySelector('.language-select');
2267 languageSelect.tabIndex = UserPodTabOrder.POD_INPUT; 2279 languageSelect.tabIndex = UserPodTabOrder.POD_INPUT;
2268 languageSelect.manuallyChanged = false; 2280 languageSelect.manuallyChanged = false;
2269 languageSelect.addEventListener( 2281 languageSelect.addEventListener(
2270 'change', 2282 'change',
2271 function() { 2283 function() {
2272 languageSelect.manuallyChanged = true; 2284 languageSelect.manuallyChanged = true;
2273 this.getPublicSessionKeyboardLayouts_(); 2285 this.getPublicSessionKeyboardLayouts_();
2274 }.bind(this)); 2286 }.bind(this));
2275 2287
2276 var keyboardSelect = this.querySelector('.keyboard-select'); 2288 var keyboardSelect = this.querySelector('.keyboard-select');
2277 keyboardSelect.tabIndex = UserPodTabOrder.POD_INPUT; 2289 keyboardSelect.tabIndex = UserPodTabOrder.POD_INPUT;
2278 keyboardSelect.loadedLocale = null; 2290 keyboardSelect.loadedLocale = null;
2279 2291
2280 var languageAndInput = this.querySelector('.language-and-input'); 2292 var languageAndInputLink = this.querySelector('.language-and-input');
2281 languageAndInput.tabIndex = UserPodTabOrder.POD_INPUT; 2293 languageAndInputLink.tabIndex = UserPodTabOrder.POD_INPUT;
2282 languageAndInput.addEventListener('click', 2294 languageAndInputLink.addEventListener(
2283 this.transitionToAdvanced_.bind(this)); 2295 'click', this.transitionToAdvanced_.bind(this));
2296
2297 var languageAndInputIcon =
2298 this.querySelector('.language-and-input-dropdown');
2299 languageAndInputIcon.addEventListener(
2300 'click', this.transitionToAdvanced_.bind(this));
2284 2301
2285 var monitoringLearnMore = this.querySelector('.monitoring-learn-more'); 2302 var monitoringLearnMore = this.querySelector('.monitoring-learn-more');
2286 monitoringLearnMore.tabIndex = UserPodTabOrder.POD_INPUT; 2303 monitoringLearnMore.tabIndex = UserPodTabOrder.POD_INPUT;
2287 monitoringLearnMore.addEventListener( 2304 monitoringLearnMore.addEventListener(
2288 'click', this.onMonitoringLearnMoreClicked_.bind(this)); 2305 'click', this.onMonitoringLearnMoreClicked_.bind(this));
2289 2306
2290 this.enterButtonElement.addEventListener('click', (function(e) { 2307 this.enterButtonElement.addEventListener('click', (function(e) {
2291 this.enterButtonElement.disabled = true; 2308 this.enterButtonElement.disabled = true;
2292 var locale = this.querySelector('.language-select').value; 2309 var locale = this.querySelector('.language-select').value;
2293 var keyboardSelect = this.querySelector('.keyboard-select'); 2310 var keyboardSelect = this.querySelector('.keyboard-select');
(...skipping 22 matching lines...) Expand all
2316 var languageSelect = this.querySelector('.language-select'); 2333 var languageSelect = this.querySelector('.language-select');
2317 languageSelect.setAttribute('id', id); 2334 languageSelect.setAttribute('id', id);
2318 this.populateLanguageSelect(this.user.initialLocales, 2335 this.populateLanguageSelect(this.user.initialLocales,
2319 this.user.initialLocale, 2336 this.user.initialLocale,
2320 this.user.initialMultipleRecommendedLocales); 2337 this.user.initialMultipleRecommendedLocales);
2321 }, 2338 },
2322 2339
2323 /** @override **/ 2340 /** @override **/
2324 update: function() { 2341 update: function() {
2325 UserPod.prototype.update.call(this); 2342 UserPod.prototype.update.call(this);
2326 this.querySelector('.expanded-pane-name').textContent =
2327 this.user_.displayName;
2328 this.querySelector('.info').textContent = 2343 this.querySelector('.info').textContent =
2329 loadTimeData.getStringF('publicAccountInfoFormat', 2344 loadTimeData.getStringF('publicAccountInfoFormat',
2330 this.user_.enterpriseDomain); 2345 this.user_.enterpriseDomain);
2331 }, 2346 },
2332 2347
2333 /** @override */ 2348 /** @override */
2334 focusInput: function() { 2349 focusInput: function() {
2335 // Move tabIndex from the whole pod to the main input. 2350 // Move tabIndex from the whole pod to the main input.
2336 this.tabIndex = -1; 2351 this.tabIndex = -1;
2337 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; 2352 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 break; 2417 break;
2403 default: 2418 default:
2404 return; 2419 return;
2405 } 2420 }
2406 break; 2421 break;
2407 } 2422 }
2408 chrome.send('launchHelpApp', [HELP_TOPIC_PUBLIC_SESSION]); 2423 chrome.send('launchHelpApp', [HELP_TOPIC_PUBLIC_SESSION]);
2409 stopEventPropagation(event); 2424 stopEventPropagation(event);
2410 }, 2425 },
2411 2426
2412 makeSpaceForExpandedPod_: function() {
2413 var width = this.classList.contains('advanced') ?
2414 PUBLIC_EXPANDED_ADVANCED_WIDTH : PUBLIC_EXPANDED_BASIC_WIDTH;
2415 var isDesktopUserManager = Oobe.getInstance().displayType ==
2416 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
2417 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING :
2418 POD_ROW_PADDING;
2419 if (this.left + width > $('pod-row').offsetWidth - rowPadding)
2420 this.left = $('pod-row').offsetWidth - rowPadding - width;
2421 },
2422
2423 /** 2427 /**
2424 * Transition the expanded pod from the basic to the advanced view. 2428 * Transition the expanded pod from the basic to the advanced view.
2425 */ 2429 */
2426 transitionToAdvanced_: function() { 2430 transitionToAdvanced_: function() {
2427 var pod = this; 2431 this.classList.add('advanced');
2428 var languageAndInputSection = 2432 // TODO(wzang): Add transition animation when its spec becomes available.
2429 this.querySelector('.language-and-input-section');
2430 this.classList.add('transitioning-to-advanced');
2431 setTimeout(function() {
2432 pod.classList.add('advanced');
2433 pod.makeSpaceForExpandedPod_();
2434 languageAndInputSection.addEventListener('transitionend',
2435 function observer() {
2436 languageAndInputSection.removeEventListener('transitionend',
2437 observer);
2438 pod.classList.remove('transitioning-to-advanced');
2439 pod.querySelector('.language-select').focus();
2440 });
2441 // Guard timer set to animation duration + 20ms.
2442 ensureTransitionEndEvent(languageAndInputSection, 380);
2443 }, 0);
2444 }, 2433 },
2445 2434
2446 /** 2435 /**
2447 * Show a dialog when user clicks on learn more (monitoring) button. 2436 * Show a dialog when user clicks on learn more (monitoring) button.
2448 */ 2437 */
2449 onMonitoringLearnMoreClicked_: function() { 2438 onMonitoringLearnMoreClicked_: function() {
2450 if (!this.dialogContainer_) { 2439 if (!this.dialogContainer_) {
2451 this.dialogContainer_ = document.createElement('div'); 2440 this.dialogContainer_ = document.createElement('div');
2452 this.dialogContainer_.classList.add('monitoring-dialog-container'); 2441 this.dialogContainer_.classList.add('monitoring-dialog-container');
2453 var topContainer = document.querySelector('#scroll-container'); 2442 var topContainer = document.querySelector('#scroll-container');
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 getPublicSessionKeyboardLayouts_: function() { 2478 getPublicSessionKeyboardLayouts_: function() {
2490 var selectedLocale = this.querySelector('.language-select').value; 2479 var selectedLocale = this.querySelector('.language-select').value;
2491 if (selectedLocale == 2480 if (selectedLocale ==
2492 this.querySelector('.keyboard-select').loadedLocale) { 2481 this.querySelector('.keyboard-select').loadedLocale) {
2493 // If the list of keyboard layouts was loaded for the currently selected 2482 // If the list of keyboard layouts was loaded for the currently selected
2494 // locale, it is already up to date. 2483 // locale, it is already up to date.
2495 return; 2484 return;
2496 } 2485 }
2497 chrome.send('getPublicSessionKeyboardLayouts', 2486 chrome.send('getPublicSessionKeyboardLayouts',
2498 [this.user.username, selectedLocale]); 2487 [this.user.username, selectedLocale]);
2499 }, 2488 },
2500 2489
2501 /** 2490 /**
2502 * Populates the keyboard layout "select" element with a list of layouts. 2491 * Populates the keyboard layout "select" element with a list of layouts.
2503 * @param {string} locale The locale to which this list of keyboard layouts 2492 * @param {string} locale The locale to which this list of keyboard layouts
2504 * applies 2493 * applies
2505 * @param {!Object} list List of available keyboard layouts 2494 * @param {!Object} list List of available keyboard layouts
2506 */ 2495 */
2507 populateKeyboardSelect: function(locale, list) { 2496 populateKeyboardSelect: function(locale, list) {
2508 if (locale != this.querySelector('.language-select').value) { 2497 if (locale != this.querySelector('.language-select').value) {
2509 // The selected locale has changed and the list of keyboard layouts is 2498 // The selected locale has changed and the list of keyboard layouts is
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
3408 }, 3397 },
3409 3398
3410 /** 3399 /**
3411 * Sets the state of touch view mode. 3400 * Sets the state of touch view mode.
3412 * @param {boolean} isTouchViewEnabled true if the mode is on. 3401 * @param {boolean} isTouchViewEnabled true if the mode is on.
3413 */ 3402 */
3414 setTouchViewState: function(isTouchViewEnabled) { 3403 setTouchViewState: function(isTouchViewEnabled) {
3415 this.touchViewEnabled_ = isTouchViewEnabled; 3404 this.touchViewEnabled_ = isTouchViewEnabled;
3416 this.pods.forEach(function(pod, index) { 3405 this.pods.forEach(function(pod, index) {
3417 pod.actionBoxAreaElement.classList.toggle('forced', isTouchViewEnabled); 3406 pod.actionBoxAreaElement.classList.toggle('forced', isTouchViewEnabled);
3407 if (pod.isPublicSessionPod)
3408 pod.querySelector('.button-container')
3409 .classList.toggle('forced', isTouchViewEnabled);
3418 }); 3410 });
3419 }, 3411 },
3420 3412
3421 /** 3413 /**
3422 * Updates the display name shown on a public session pod. 3414 * Updates the display name shown on a public session pod.
3423 * @param {string} userID The user ID of the public session 3415 * @param {string} userID The user ID of the public session
3424 * @param {string} displayName The new display name 3416 * @param {string} displayName The new display name
3425 */ 3417 */
3426 setPublicSessionDisplayName: function(userID, displayName) { 3418 setPublicSessionDisplayName: function(userID, displayName) {
3427 var pod = this.getPodWithUsername_(userID); 3419 var pod = this.getPodWithUsername_(userID);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3569 clientArea.style.position = 'relative'; 3561 clientArea.style.position = 'relative';
3570 } 3562 }
3571 }, 3563 },
3572 3564
3573 /** 3565 /**
3574 * Called when there is one user pod. 3566 * Called when there is one user pod.
3575 * @private 3567 * @private
3576 */ 3568 */
3577 placeSinglePod_: function() { 3569 placeSinglePod_: function() {
3578 this.mainPod_.setPodStyle(UserPod.Style.LARGE); 3570 this.mainPod_.setPodStyle(UserPod.Style.LARGE);
3579 this.mainPod_.left = (this.screenSize.width - CROS_POD_WIDTH) / 2; 3571 this.centerPod_(this.mainPod_, CROS_POD_WIDTH, CROS_POD_HEIGHT);
3580 this.mainPod_.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2;
3581 }, 3572 },
3582 3573
3583 /** 3574 /**
3584 * Called when there are two users pods. 3575 * Called when the number of pods is within the POD_ROW_LIMIT.
3585 * @private 3576 * @private
3586 */ 3577 */
3587 placePodsOnPodRow_: function() { 3578 placePodsOnPodRow_: function() {
3588 // Both pods have large size and are placed adjacently. 3579 // Both pods have large size and are placed adjacently.
3589 var secondPod = 3580 var secondPod =
3590 this.pods[0] == this.mainPod_ ? this.pods[1] : this.pods[0]; 3581 this.pods[0] == this.mainPod_ ? this.pods[1] : this.pods[0];
3591 this.mainPod_.setPodStyle(UserPod.Style.LARGE); 3582 this.mainPod_.setPodStyle(UserPod.Style.LARGE);
3592 secondPod.setPodStyle(UserPod.Style.LARGE); 3583 secondPod.setPodStyle(UserPod.Style.LARGE);
3593 3584
3594 var DOUBLE_PODS_PADDING = this.isPortraitMode_() ? 32 : 118; 3585 var DOUBLE_PODS_PADDING = this.isPortraitMode_() ? 32 : 118;
3595 var leftPadding = 3586 var leftPadding =
3596 (this.screenSize.width - (CROS_POD_WIDTH * 2 + DOUBLE_PODS_PADDING)) / 3587 (this.screenSize.width - (CROS_POD_WIDTH * 2 + DOUBLE_PODS_PADDING)) /
3597 2; 3588 2;
3598 // Start actual positioning. 3589 // Start actual positioning.
3599 this.mainPod_.left = leftPadding; 3590 this.mainPod_.left = leftPadding;
3600 this.mainPod_.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2; 3591 this.mainPod_.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2;
3601 secondPod.left = leftPadding + CROS_POD_WIDTH + DOUBLE_PODS_PADDING; 3592 secondPod.left = leftPadding + CROS_POD_WIDTH + DOUBLE_PODS_PADDING;
3602 secondPod.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2; 3593 secondPod.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2;
3603 }, 3594 },
3604 3595
3605 /** 3596 /**
3606 * Called when there are more than two user pods. 3597 * Called when the number of pods exceeds the POD_ROW_LIMIT.
3607 * @private 3598 * @private
3608 */ 3599 */
3609 placePodsOnContainer_: function() { 3600 placePodsOnContainer_: function() {
3610 this.smallPodsContainer.hidden = false; 3601 this.smallPodsContainer.hidden = false;
3611 var pods = this.pods; 3602 var pods = this.pods;
3612 if ((pods.length > LANDSCAPE_MODE_LIMIT && !this.isPortraitMode_()) || 3603 if ((pods.length > LANDSCAPE_MODE_LIMIT && !this.isPortraitMode_()) ||
3613 (pods.length > PORTRAIT_MODE_LIMIT && this.isPortraitMode_())) { 3604 (pods.length > PORTRAIT_MODE_LIMIT && this.isPortraitMode_())) {
3614 // If the pod count exceeds limits, they should be in extra small size 3605 // If the pod count exceeds limits, they should be in extra small size
3615 // and the container will become scrollable. 3606 // and the container will become scrollable.
3616 this.placePodsOnScrollableContainer_(); 3607 this.placePodsOnScrollableContainer_();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3678 if (pod == this.mainPod_) { 3669 if (pod == this.mainPod_) {
3679 continue; 3670 continue;
3680 } 3671 }
3681 pod.left = 0; 3672 pod.left = 0;
3682 pod.top = smallPodsTopPadding; 3673 pod.top = smallPodsTopPadding;
3683 smallPodsTopPadding += CROS_SMALL_POD_HEIGHT + actualSmallPodPadding; 3674 smallPodsTopPadding += CROS_SMALL_POD_HEIGHT + actualSmallPodPadding;
3684 } 3675 }
3685 }, 3676 },
3686 3677
3687 /** 3678 /**
3688 * Called when there are more than 6 user pods in landscape mode, or more 3679 * Called when the LANDSCAPE_MODE_LIMIT or PORTRAIT_MODE_LIMIT is exceeded
3689 * than 10 user pods in portrait mode. 3680 * and the scrollable container is shown.
3690 * @private 3681 * @private
3691 */ 3682 */
3692 placePodsOnScrollableContainer_: function() { 3683 placePodsOnScrollableContainer_: function() {
3693 this.smallPodsContainer.hidden = false; 3684 this.smallPodsContainer.hidden = false;
3694 // Add a dark overlay. 3685 // Add a dark overlay.
3695 this.smallPodsContainer.classList.add('scroll'); 3686 this.smallPodsContainer.classList.add('scroll');
3696 var pods = this.pods; 3687 var pods = this.pods;
3697 this.mainPod_.setPodStyle(UserPod.Style.LARGE); 3688 this.mainPod_.setPodStyle(UserPod.Style.LARGE);
3698 for (var pod of pods) { 3689 for (var pod of pods) {
3699 if (pod != this.mainPod_) { 3690 if (pod != this.mainPod_) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3784 document.querySelector('.small-pod-container-mask').hidden = true; 3775 document.querySelector('.small-pod-container-mask').hidden = true;
3785 document.querySelector('.small-pod-container-mask.rotate').hidden = true; 3776 document.querySelector('.small-pod-container-mask.rotate').hidden = true;
3786 this.smallPodsContainer.classList.remove('scroll'); 3777 this.smallPodsContainer.classList.remove('scroll');
3787 var pods = this.pods; 3778 var pods = this.pods;
3788 for (var pod of pods) { 3779 for (var pod of pods) {
3789 // There is a chance that one of the pods has a bottom padding, so 3780 // There is a chance that one of the pods has a bottom padding, so
3790 // reset all of them to be safe. This is because if the pod was at 3781 // reset all of them to be safe. This is because if the pod was at
3791 // the last position in the scrollable container, a bottom padding 3782 // the last position in the scrollable container, a bottom padding
3792 // was added to ensure a symmetric layout. 3783 // was added to ensure a symmetric layout.
3793 pod.style.paddingBottom = cr.ui.toCssPx(0); 3784 pod.style.paddingBottom = cr.ui.toCssPx(0);
3794 // Remove the switch animation that might be added earlier.
3795 pod.imageElement.classList.remove('switch-image-animation');
3796 pod.smallPodImageElement.classList.remove('switch-image-animation');
3797 } 3785 }
3786 this.clearPodsAnimation_();
3798 this.hideEmptyArea_(); 3787 this.hideEmptyArea_();
3799 // Clear error bubbles whenever pod placement is happening, i.e., after 3788 // Clear error bubbles whenever pod placement is happening, i.e., after
3800 // orientation change, showing or hiding virtual keyboard, and user 3789 // orientation change, showing or hiding virtual keyboard, and user
3801 // removal. 3790 // removal.
3802 Oobe.clearErrors(); 3791 Oobe.clearErrors();
3803 }, 3792 },
3804 3793
3805 /** 3794 /**
3806 * Checks if the screen is in portrait mode. 3795 * Checks if the screen is in portrait mode.
3807 * @return {boolean} True if in portrait mode. 3796 * @return {boolean} True if in portrait mode.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3855 // Make sure that user name on each large pod is centered and extra 3844 // Make sure that user name on each large pod is centered and extra
3856 // long names don't exceed maximum pod width. 3845 // long names don't exceed maximum pod width.
3857 var nameArea = pod.querySelector('.name-container'); 3846 var nameArea = pod.querySelector('.name-container');
3858 var leftMargin = (CROS_POD_WIDTH - pod.nameElement.offsetWidth) / 2; 3847 var leftMargin = (CROS_POD_WIDTH - pod.nameElement.offsetWidth) / 2;
3859 if (leftMargin > 0) 3848 if (leftMargin > 0)
3860 nameArea.style.left = cr.ui.toCssPx(leftMargin); 3849 nameArea.style.left = cr.ui.toCssPx(leftMargin);
3861 else { 3850 else {
3862 pod.nameElement.style.width = cr.ui.toCssPx(CROS_POD_WIDTH); 3851 pod.nameElement.style.width = cr.ui.toCssPx(CROS_POD_WIDTH);
3863 nameArea.style.left = cr.ui.toCssPx(0); 3852 nameArea.style.left = cr.ui.toCssPx(0);
3864 } 3853 }
3854 // Update info container area for public session pods.
3855 if (pod.isPublicSessionPod) {
3856 var infoElement = pod.querySelector('.info');
3857 var infoIcon = pod.querySelector('.learn-more');
3858 var totalWidth = PUBLIC_SESSION_ICON_WIDTH + infoElement.offsetWidth;
3859 var infoLeftMargin = (CROS_POD_WIDTH - totalWidth) / 2;
3860 if (infoLeftMargin > 0) {
3861 infoIcon.style.left = cr.ui.toCssPx(infoLeftMargin);
3862 infoElement.style.left =
3863 cr.ui.toCssPx(infoLeftMargin + PUBLIC_SESSION_ICON_WIDTH);
3864 } else {
3865 infoIcon.style.left = cr.ui.toCssPx(0);
3866 infoElement.style.left = cr.ui.toCssPx(PUBLIC_SESSION_ICON_WIDTH);
3867 infoElement.style.width = cr.ui.toCssPx(
3868 CROS_POD_WIDTH - PUBLIC_SESSION_ICON_WIDTH -
3869 infoElement.style.paddingLeft);
3870 }
3871 // If the public session pod is already expanded, make sure it's
3872 // still centered.
3873 if (pod.expanded)
3874 this.centerPod_(pod, PUBLIC_EXPANDED_WIDTH, PUBLIC_EXPANDED_HEIGHT);
3875 }
3865 // Update action box menu position to ensure it doesn't overlap with 3876 // Update action box menu position to ensure it doesn't overlap with
3866 // elements outside the pod. 3877 // elements outside the pod.
3867 var actionBoxMenu = pod.querySelector('.action-box-menu'); 3878 var actionBoxMenu = pod.querySelector('.action-box-menu');
3868 var actionBoxButton = pod.querySelector('.action-box-button'); 3879 var actionBoxButton = pod.querySelector('.action-box-button');
3869 actionBoxMenu.style.top = 3880 var MENU_TOP_PADDING = 5;
3870 cr.ui.toCssPx(actionBoxButton.offsetHeight);
3871 if (this.isPortraitMode_() && pods.length > 1) { 3881 if (this.isPortraitMode_() && pods.length > 1) {
3872 // Confine the menu inside the pod when it may overlap with outside 3882 // Confine the menu inside the pod when it may overlap with outside
3873 // elements. 3883 // elements.
3874 actionBoxMenu.style.left = 'auto'; 3884 actionBoxMenu.style.left = 'auto';
3875 actionBoxMenu.style.right = cr.ui.toCssPx(0); 3885 actionBoxMenu.style.right = cr.ui.toCssPx(0);
3886 actionBoxMenu.style.top =
3887 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING);
3888 } else if (!this.isPortraitMode_() && this.isScreenShrinked_()) {
3889 // Prevent the virtual keyboard from blocking the remove user button.
3890 actionBoxMenu.style.left = cr.ui.toCssPx(
3891 pod.nameElement.offsetWidth + actionBoxButton.offsetWidth);
3892 actionBoxMenu.style.right = 'auto';
3893 actionBoxMenu.style.top = cr.ui.toCssPx(0);
3876 } else { 3894 } else {
3877 actionBoxMenu.style.left = cr.ui.toCssPx( 3895 actionBoxMenu.style.left = cr.ui.toCssPx(
3878 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft); 3896 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3879 actionBoxMenu.style.right = 'auto'; 3897 actionBoxMenu.style.right = 'auto';
3898 actionBoxMenu.style.top =
3899 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING);
3880 } 3900 }
3881 // Add ripple animation. 3901 // Add ripple animation.
3882 var actionBoxRippleEffect = 3902 var actionBoxRippleEffect =
3883 pod.querySelector('.action-box-button.ripple-circle'); 3903 pod.querySelector('.action-box-button.ripple-circle');
3884 actionBoxRippleEffect.style.left = actionBoxMenu.style.left; 3904 actionBoxRippleEffect.style.left = cr.ui.toCssPx(
3905 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3885 actionBoxRippleEffect.style.top = 3906 actionBoxRippleEffect.style.top =
3886 cr.ui.toCssPx(actionBoxButton.style.marginTop); 3907 cr.ui.toCssPx(actionBoxButton.style.marginTop);
3887 // Adjust the vertical position of the pod if pin keyboard is shown. 3908 // Adjust the vertical position of the pod if pin keyboard is shown.
3888 if (pod.isPinShown() && !this.isScreenShrinked_()) 3909 if (pod.isPinShown() && !this.isScreenShrinked_())
3889 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2; 3910 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2;
3890 } 3911 }
3891 // Update the position of the sign-in banner if it's shown. 3912 // Update the position of the sign-in banner if it's shown.
3892 if ($('signin-banner').textContent.length != 0) { 3913 if ($('signin-banner').textContent.length != 0) {
3893 var bannerContainer = $('signin-banner-container1'); 3914 var bannerContainer = $('signin-banner-container1');
3894 var BANNER_TOP_PADDING = this.isScreenShrinked_() ? 0 : 38; 3915 bannerContainer.style.top = cr.ui.toCssPx(this.mainPod_.top / 2);
3895 bannerContainer.style.top = cr.ui.toCssPx(
3896 this.mainPod_.top + CROS_POD_HEIGHT + BANNER_TOP_PADDING);
3897 if (this.pods.length <= POD_ROW_LIMIT) { 3916 if (this.pods.length <= POD_ROW_LIMIT) {
3898 bannerContainer.style.left = 3917 bannerContainer.style.left =
3899 cr.ui.toCssPx((this.screenSize.width - BANNER_MESSAGE_WIDTH) / 2); 3918 cr.ui.toCssPx((this.screenSize.width - BANNER_MESSAGE_WIDTH) / 2);
3900 } 3919 }
3901 else { 3920 else {
3902 var leftPadding = 3921 var leftPadding =
3903 this.mainPod_.left - (BANNER_MESSAGE_WIDTH - CROS_POD_WIDTH) / 2; 3922 this.mainPod_.left - (BANNER_MESSAGE_WIDTH - CROS_POD_WIDTH) / 2;
3904 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0)); 3923 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0));
3905 } 3924 }
3906 } 3925 }
3907 }, 3926 },
3908 3927
3909 /** 3928 /**
3929 * Handles required UI changes when a public session pod toggles the
3930 * expanded state.
3931 * @param {UserPod} pod Public session pod.
3932 * @param {boolean} expanded Whether the pod is expanded or not.
3933 */
3934 handlePublicPodExpansion: function(pod, expanded) {
3935 // Hide all other elements in the account picker if the pod is expanded.
3936 this.parentNode.classList.toggle('public-account-expanded', expanded);
3937 if (expanded) {
3938 this.centerPod_(pod, PUBLIC_EXPANDED_WIDTH, PUBLIC_EXPANDED_HEIGHT);
3939 } else {
3940 // Return the pod to its last position.
3941 pod.left = pod.lastPosition.left;
3942 pod.top = pod.lastPosition.top;
3943 // Pod placement has already finished by this point, but we still need
3944 // to make sure that the styles of all the elements in the pod row are
3945 // updated before being shown.
3946 this.handleAfterPodPlacement_();
3947 this.clearPodsAnimation_();
3948 }
3949 },
3950
3951 /**
3952 * Called when a pod needs to be centered.
3953 * @param {UserPod} pod Pod to be centered.
3954 * @param {number} podWidth The pod width.
3955 * @param {number} podHeight The pod height.
3956 * @private
3957 */
3958 centerPod_: function(pod, podWidth, podHeight) {
3959 // The original position of a public session pod is recorded in case of
3960 // future need.
3961 if (pod.isPublicSessionPod)
3962 pod.lastPosition = {left: pod.left, top: pod.top};
3963 // Avoid using offsetWidth and offsetHeight in case the pod is not fully
3964 // loaded yet.
3965 pod.left = (this.screenSize.width - podWidth) / 2;
3966 pod.top = (this.screenSize.height - podHeight) / 2;
3967 },
3968
3969 /**
3970 * Clears animation classes that may be added earlier to ensure a clean
3971 * state.
3972 * @private
3973 */
3974 clearPodsAnimation_: function() {
3975 var pods = this.pods;
3976 for (var pod of pods) {
3977 pod.imageElement.classList.remove('switch-image-animation');
3978 pod.smallPodImageElement.classList.remove('switch-image-animation');
3979 }
3980 },
3981
3982 /**
3910 * Called when a small or extra small pod is clicked to trigger the switch 3983 * Called when a small or extra small pod is clicked to trigger the switch
3911 * with the main pod. 3984 * with the main pod.
3985 * @param {UserPod} pod Pod to be switched with the main pod.
3912 */ 3986 */
3913 switchMainPod: function(pod) { 3987 switchMainPod: function(pod) {
3914 if (this.disabled) { 3988 if (this.disabled) {
3915 console.error('Cannot change main pod while sign-in UI is disabled.'); 3989 console.error('Cannot switch main pod while sign-in UI is disabled.');
3916 return; 3990 return;
3917 } 3991 }
3918 if (!this.mainPod_) { 3992 if (!this.mainPod_) {
3919 console.error('Attempt to switch a non-existing main pod.'); 3993 console.error('Attempt to switch a non-existing main pod.');
3920 return; 3994 return;
3921 } 3995 }
3922 // Find the index of the small pod. 3996 // Find the index of the small pod.
3923 var insert = 0; 3997 var insert = 0;
3924 var children = pod.parentNode.children; 3998 var children = pod.parentNode.children;
3925 while (insert < children.length && children[insert] != pod) 3999 while (insert < children.length && children[insert] != pod)
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
4260 if (this.alwaysFocusSinglePod && !pod) { 4334 if (this.alwaysFocusSinglePod && !pod) {
4261 if ($('login-header-bar').contains(e.target)) 4335 if ($('login-header-bar').contains(e.target))
4262 return; 4336 return;
4263 // If the click is outside the single pod, still focus on that pod 4337 // If the click is outside the single pod, still focus on that pod
4264 // but do not focus on input box any more. This makes virtual keyboard 4338 // but do not focus on input box any more. This makes virtual keyboard
4265 // (if present) disappear. 4339 // (if present) disappear.
4266 this.focusPod( 4340 this.focusPod(
4267 this.focusedPod_, true /* force */, true /* opt_skipInputFocus */); 4341 this.focusedPod_, true /* force */, true /* opt_skipInputFocus */);
4268 this.focusedPod_.userTypeBubbleElement.classList.remove('bubble-shown'); 4342 this.focusedPod_.userTypeBubbleElement.classList.remove('bubble-shown');
4269 this.focusedPod_.isActionBoxMenuHovered = false; 4343 this.focusedPod_.isActionBoxMenuHovered = false;
4344 // If the click is outside the public session pod, still focus on it
4345 // but do not expand it any more.
4346 if (this.focusedPod_.isPublicSessionPod)
4347 this.focusedPod_.expanded = false;
4270 } 4348 }
4271 }, 4349 },
4272 4350
4273 /** 4351 /**
4274 * Handler of mouse move event. 4352 * Handler of mouse move event.
4275 * @param {Event} e Click Event object. 4353 * @param {Event} e Click Event object.
4276 * @private 4354 * @private
4277 */ 4355 */
4278 handleMouseMove_: function(e) { 4356 handleMouseMove_: function(e) {
4279 if (this.disabled) 4357 if (this.disabled)
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4388 if (!editing) { 4466 if (!editing) {
4389 if (this.focusedPod_ && this.focusedPod_.nextElementSibling) 4467 if (this.focusedPod_ && this.focusedPod_.nextElementSibling)
4390 this.focusPod(this.focusedPod_.nextElementSibling); 4468 this.focusPod(this.focusedPod_.nextElementSibling);
4391 else 4469 else
4392 this.focusPod(this.firstElementChild); 4470 this.focusPod(this.firstElementChild);
4393 4471
4394 e.stopPropagation(); 4472 e.stopPropagation();
4395 } 4473 }
4396 break; 4474 break;
4397 case 'Enter': 4475 case 'Enter':
4398 if (this.focusedPod_) { 4476 // Click events on public session pods should only be handled by
4477 // their own handler.
4478 if (this.focusedPod_ && !this.focusedPod_.isPublicSessionPod) {
4399 var targetTag = e.target.tagName; 4479 var targetTag = e.target.tagName;
4400 if (e.target == this.focusedPod_.passwordElement || 4480 if (e.target == this.focusedPod_.passwordElement ||
4401 (this.focusedPod_.pinKeyboard && 4481 (this.focusedPod_.pinKeyboard &&
4402 e.target == this.focusedPod_.pinKeyboard.inputElement) || 4482 e.target == this.focusedPod_.pinKeyboard.inputElement) ||
4403 (targetTag != 'INPUT' && 4483 (targetTag != 'INPUT' &&
4404 targetTag != 'BUTTON' && 4484 targetTag != 'BUTTON' &&
4405 targetTag != 'A')) { 4485 targetTag != 'A')) {
4406 this.setActivatedPod(this.focusedPod_, e); 4486 this.setActivatedPod(this.focusedPod_, e);
4407 e.stopPropagation(); 4487 e.stopPropagation();
4408 } 4488 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
4500 if (pod && pod.multiProfilesPolicyApplied) { 4580 if (pod && pod.multiProfilesPolicyApplied) {
4501 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 4581 pod.userTypeBubbleElement.classList.remove('bubble-shown');
4502 } 4582 }
4503 } 4583 }
4504 }; 4584 };
4505 4585
4506 return { 4586 return {
4507 PodRow: PodRow 4587 PodRow: PodRow
4508 }; 4588 };
4509 }); 4589 });
OLDNEW
« no previous file with comments | « ui/login/account_picker/md_user_pod_row.css ('k') | ui/login/account_picker/md_user_pod_template.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698