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

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: Removed getter and setter of lastPosition 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 */
2193 lastPosition: {left: 'unset', top: 'unset'},
2194
2195 /**
2176 * "Enter" button in expanded side pane. 2196 * "Enter" button in expanded side pane.
2177 * @type {!HTMLButtonElement} 2197 * @type {!HTMLButtonElement}
2178 */ 2198 */
2179 get enterButtonElement() { 2199 get enterButtonElement() {
2180 return this.querySelector('.enter-button'); 2200 return this.querySelector('.enter-button');
2181 }, 2201 },
2182 2202
2183 /** 2203 /**
2184 * Boolean flag of whether the pod is showing the side pane. The flag 2204 * 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 2205 * 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' 2206 * resets tab order because main input element changes when the 'expanded'
2187 * state changes. 2207 * state changes.
2188 * @type {boolean} 2208 * @type {boolean}
2189 */ 2209 */
2190 get expanded() { 2210 get expanded() {
2191 return this.classList.contains('expanded'); 2211 return this.classList.contains('expanded');
2192 }, 2212 },
2193 2213
2194 set expanded(expanded) { 2214 set expanded(expanded) {
2215 if (this.getPodStyle() != UserPod.Style.LARGE) {
2216 console.error(
2217 'Attempt to expand a public session pod when it is not large.');
2218 return;
2219 }
2195 if (this.expanded == expanded) 2220 if (this.expanded == expanded)
2196 return; 2221 return;
2197 2222
2198 this.resetTabOrder(); 2223 this.resetTabOrder();
2199 this.classList.toggle('expanded', expanded); 2224 this.classList.toggle('expanded', expanded);
2200 if (expanded) { 2225 if (expanded) {
2201 // Show the advanced expanded pod directly if there are at least two 2226 // Show the advanced expanded pod directly if there are at least two
2202 // recommended locales. This will be the case in multilingual 2227 // recommended locales. This will be the case in multilingual
2203 // environments where users are likely to want to choose among locales. 2228 // environments where users are likely to want to choose among locales.
2204 if (this.querySelector('.language-select').multipleRecommendedLocales) 2229 if (this.querySelector('.language-select').multipleRecommendedLocales)
2205 this.classList.add('advanced'); 2230 this.classList.add('advanced');
2206 this.usualLeft = this.left; 2231 } else {
2207 this.makeSpaceForExpandedPod_(); 2232 this.classList.remove('advanced');
2208 } else if (typeof(this.usualLeft) != 'undefined') {
2209 this.left = this.usualLeft;
2210 } 2233 }
2211 2234 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 }, 2235 },
2227 2236
2228 get advanced() { 2237 get advanced() {
2229 return this.classList.contains('advanced'); 2238 return this.classList.contains('advanced');
2230 }, 2239 },
2231 2240
2232 /** @override */ 2241 /** @override */
2233 get mainInput() { 2242 get mainInput() {
2234 if (this.expanded) 2243 if (this.expanded)
2235 return this.enterButtonElement; 2244 return this.enterButtonElement;
(...skipping 16 matching lines...) Expand all
2252 // newly focused "Enter" button. 2261 // newly focused "Enter" button.
2253 e.preventDefault(); 2262 e.preventDefault();
2254 } 2263 }
2255 }).bind(this)); 2264 }).bind(this));
2256 2265
2257 var learnMore = this.querySelector('.learn-more'); 2266 var learnMore = this.querySelector('.learn-more');
2258 learnMore.addEventListener('mousedown', stopEventPropagation); 2267 learnMore.addEventListener('mousedown', stopEventPropagation);
2259 learnMore.addEventListener('click', this.handleLearnMoreEvent); 2268 learnMore.addEventListener('click', this.handleLearnMoreEvent);
2260 learnMore.addEventListener('keydown', this.handleLearnMoreEvent); 2269 learnMore.addEventListener('keydown', this.handleLearnMoreEvent);
2261 2270
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'); 2271 var languageSelect = this.querySelector('.language-select');
2267 languageSelect.tabIndex = UserPodTabOrder.POD_INPUT; 2272 languageSelect.tabIndex = UserPodTabOrder.POD_INPUT;
2268 languageSelect.manuallyChanged = false; 2273 languageSelect.manuallyChanged = false;
2269 languageSelect.addEventListener( 2274 languageSelect.addEventListener(
2270 'change', 2275 'change',
2271 function() { 2276 function() {
2272 languageSelect.manuallyChanged = true; 2277 languageSelect.manuallyChanged = true;
2273 this.getPublicSessionKeyboardLayouts_(); 2278 this.getPublicSessionKeyboardLayouts_();
2274 }.bind(this)); 2279 }.bind(this));
2275 2280
2276 var keyboardSelect = this.querySelector('.keyboard-select'); 2281 var keyboardSelect = this.querySelector('.keyboard-select');
2277 keyboardSelect.tabIndex = UserPodTabOrder.POD_INPUT; 2282 keyboardSelect.tabIndex = UserPodTabOrder.POD_INPUT;
2278 keyboardSelect.loadedLocale = null; 2283 keyboardSelect.loadedLocale = null;
2279 2284
2280 var languageAndInput = this.querySelector('.language-and-input'); 2285 var languageAndInputLink = this.querySelector('.language-and-input');
2281 languageAndInput.tabIndex = UserPodTabOrder.POD_INPUT; 2286 languageAndInputLink.tabIndex = UserPodTabOrder.POD_INPUT;
2282 languageAndInput.addEventListener('click', 2287 languageAndInputLink.addEventListener(
2283 this.transitionToAdvanced_.bind(this)); 2288 'click', this.transitionToAdvanced_.bind(this));
2289
2290 var languageAndInputIcon =
2291 this.querySelector('.language-and-input-dropdown');
2292 languageAndInputIcon.addEventListener(
2293 'click', this.transitionToAdvanced_.bind(this));
2284 2294
2285 var monitoringLearnMore = this.querySelector('.monitoring-learn-more'); 2295 var monitoringLearnMore = this.querySelector('.monitoring-learn-more');
2286 monitoringLearnMore.tabIndex = UserPodTabOrder.POD_INPUT; 2296 monitoringLearnMore.tabIndex = UserPodTabOrder.POD_INPUT;
2287 monitoringLearnMore.addEventListener( 2297 monitoringLearnMore.addEventListener(
2288 'click', this.onMonitoringLearnMoreClicked_.bind(this)); 2298 'click', this.onMonitoringLearnMoreClicked_.bind(this));
2289 2299
2290 this.enterButtonElement.addEventListener('click', (function(e) { 2300 this.enterButtonElement.addEventListener('click', (function(e) {
2291 this.enterButtonElement.disabled = true; 2301 this.enterButtonElement.disabled = true;
2292 var locale = this.querySelector('.language-select').value; 2302 var locale = this.querySelector('.language-select').value;
2293 var keyboardSelect = this.querySelector('.keyboard-select'); 2303 var keyboardSelect = this.querySelector('.keyboard-select');
(...skipping 22 matching lines...) Expand all
2316 var languageSelect = this.querySelector('.language-select'); 2326 var languageSelect = this.querySelector('.language-select');
2317 languageSelect.setAttribute('id', id); 2327 languageSelect.setAttribute('id', id);
2318 this.populateLanguageSelect(this.user.initialLocales, 2328 this.populateLanguageSelect(this.user.initialLocales,
2319 this.user.initialLocale, 2329 this.user.initialLocale,
2320 this.user.initialMultipleRecommendedLocales); 2330 this.user.initialMultipleRecommendedLocales);
2321 }, 2331 },
2322 2332
2323 /** @override **/ 2333 /** @override **/
2324 update: function() { 2334 update: function() {
2325 UserPod.prototype.update.call(this); 2335 UserPod.prototype.update.call(this);
2326 this.querySelector('.expanded-pane-name').textContent =
2327 this.user_.displayName;
2328 this.querySelector('.info').textContent = 2336 this.querySelector('.info').textContent =
2329 loadTimeData.getStringF('publicAccountInfoFormat', 2337 loadTimeData.getStringF('publicAccountInfoFormat',
2330 this.user_.enterpriseDomain); 2338 this.user_.enterpriseDomain);
2331 }, 2339 },
2332 2340
2333 /** @override */ 2341 /** @override */
2334 focusInput: function() { 2342 focusInput: function() {
2335 // Move tabIndex from the whole pod to the main input. 2343 // Move tabIndex from the whole pod to the main input.
2336 this.tabIndex = -1; 2344 this.tabIndex = -1;
2337 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; 2345 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 break; 2410 break;
2403 default: 2411 default:
2404 return; 2412 return;
2405 } 2413 }
2406 break; 2414 break;
2407 } 2415 }
2408 chrome.send('launchHelpApp', [HELP_TOPIC_PUBLIC_SESSION]); 2416 chrome.send('launchHelpApp', [HELP_TOPIC_PUBLIC_SESSION]);
2409 stopEventPropagation(event); 2417 stopEventPropagation(event);
2410 }, 2418 },
2411 2419
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 /** 2420 /**
2424 * Transition the expanded pod from the basic to the advanced view. 2421 * Transition the expanded pod from the basic to the advanced view.
2425 */ 2422 */
2426 transitionToAdvanced_: function() { 2423 transitionToAdvanced_: function() {
2427 var pod = this; 2424 this.classList.add('advanced');
2428 var languageAndInputSection = 2425 // 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 }, 2426 },
2445 2427
2446 /** 2428 /**
2447 * Show a dialog when user clicks on learn more (monitoring) button. 2429 * Show a dialog when user clicks on learn more (monitoring) button.
2448 */ 2430 */
2449 onMonitoringLearnMoreClicked_: function() { 2431 onMonitoringLearnMoreClicked_: function() {
2450 if (!this.dialogContainer_) { 2432 if (!this.dialogContainer_) {
2451 this.dialogContainer_ = document.createElement('div'); 2433 this.dialogContainer_ = document.createElement('div');
2452 this.dialogContainer_.classList.add('monitoring-dialog-container'); 2434 this.dialogContainer_.classList.add('monitoring-dialog-container');
2453 var topContainer = document.querySelector('#scroll-container'); 2435 var topContainer = document.querySelector('#scroll-container');
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 getPublicSessionKeyboardLayouts_: function() { 2471 getPublicSessionKeyboardLayouts_: function() {
2490 var selectedLocale = this.querySelector('.language-select').value; 2472 var selectedLocale = this.querySelector('.language-select').value;
2491 if (selectedLocale == 2473 if (selectedLocale ==
2492 this.querySelector('.keyboard-select').loadedLocale) { 2474 this.querySelector('.keyboard-select').loadedLocale) {
2493 // If the list of keyboard layouts was loaded for the currently selected 2475 // If the list of keyboard layouts was loaded for the currently selected
2494 // locale, it is already up to date. 2476 // locale, it is already up to date.
2495 return; 2477 return;
2496 } 2478 }
2497 chrome.send('getPublicSessionKeyboardLayouts', 2479 chrome.send('getPublicSessionKeyboardLayouts',
2498 [this.user.username, selectedLocale]); 2480 [this.user.username, selectedLocale]);
2499 }, 2481 },
2500 2482
2501 /** 2483 /**
2502 * Populates the keyboard layout "select" element with a list of layouts. 2484 * Populates the keyboard layout "select" element with a list of layouts.
2503 * @param {string} locale The locale to which this list of keyboard layouts 2485 * @param {string} locale The locale to which this list of keyboard layouts
2504 * applies 2486 * applies
2505 * @param {!Object} list List of available keyboard layouts 2487 * @param {!Object} list List of available keyboard layouts
2506 */ 2488 */
2507 populateKeyboardSelect: function(locale, list) { 2489 populateKeyboardSelect: function(locale, list) {
2508 if (locale != this.querySelector('.language-select').value) { 2490 if (locale != this.querySelector('.language-select').value) {
2509 // The selected locale has changed and the list of keyboard layouts is 2491 // 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 }, 3390 },
3409 3391
3410 /** 3392 /**
3411 * Sets the state of touch view mode. 3393 * Sets the state of touch view mode.
3412 * @param {boolean} isTouchViewEnabled true if the mode is on. 3394 * @param {boolean} isTouchViewEnabled true if the mode is on.
3413 */ 3395 */
3414 setTouchViewState: function(isTouchViewEnabled) { 3396 setTouchViewState: function(isTouchViewEnabled) {
3415 this.touchViewEnabled_ = isTouchViewEnabled; 3397 this.touchViewEnabled_ = isTouchViewEnabled;
3416 this.pods.forEach(function(pod, index) { 3398 this.pods.forEach(function(pod, index) {
3417 pod.actionBoxAreaElement.classList.toggle('forced', isTouchViewEnabled); 3399 pod.actionBoxAreaElement.classList.toggle('forced', isTouchViewEnabled);
3400 if (pod.isPublicSessionPod)
3401 pod.querySelector('.button-container')
3402 .classList.toggle('forced', isTouchViewEnabled);
3418 }); 3403 });
3419 }, 3404 },
3420 3405
3421 /** 3406 /**
3422 * Updates the display name shown on a public session pod. 3407 * Updates the display name shown on a public session pod.
3423 * @param {string} userID The user ID of the public session 3408 * @param {string} userID The user ID of the public session
3424 * @param {string} displayName The new display name 3409 * @param {string} displayName The new display name
3425 */ 3410 */
3426 setPublicSessionDisplayName: function(userID, displayName) { 3411 setPublicSessionDisplayName: function(userID, displayName) {
3427 var pod = this.getPodWithUsername_(userID); 3412 var pod = this.getPodWithUsername_(userID);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3569 clientArea.style.position = 'relative'; 3554 clientArea.style.position = 'relative';
3570 } 3555 }
3571 }, 3556 },
3572 3557
3573 /** 3558 /**
3574 * Called when there is one user pod. 3559 * Called when there is one user pod.
3575 * @private 3560 * @private
3576 */ 3561 */
3577 placeSinglePod_: function() { 3562 placeSinglePod_: function() {
3578 this.mainPod_.setPodStyle(UserPod.Style.LARGE); 3563 this.mainPod_.setPodStyle(UserPod.Style.LARGE);
3579 this.mainPod_.left = (this.screenSize.width - CROS_POD_WIDTH) / 2; 3564 this.centerPod_(this.mainPod_, CROS_POD_WIDTH, CROS_POD_HEIGHT);
3580 this.mainPod_.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2;
3581 }, 3565 },
3582 3566
3583 /** 3567 /**
3584 * Called when there are two users pods. 3568 * Called when the number of pods is within the POD_ROW_LIMIT.
3585 * @private 3569 * @private
3586 */ 3570 */
3587 placePodsOnPodRow_: function() { 3571 placePodsOnPodRow_: function() {
3588 // Both pods have large size and are placed adjacently. 3572 // Both pods have large size and are placed adjacently.
3589 var secondPod = 3573 var secondPod =
3590 this.pods[0] == this.mainPod_ ? this.pods[1] : this.pods[0]; 3574 this.pods[0] == this.mainPod_ ? this.pods[1] : this.pods[0];
3591 this.mainPod_.setPodStyle(UserPod.Style.LARGE); 3575 this.mainPod_.setPodStyle(UserPod.Style.LARGE);
3592 secondPod.setPodStyle(UserPod.Style.LARGE); 3576 secondPod.setPodStyle(UserPod.Style.LARGE);
3593 3577
3594 var DOUBLE_PODS_PADDING = this.isPortraitMode_() ? 32 : 118; 3578 var DOUBLE_PODS_PADDING = this.isPortraitMode_() ? 32 : 118;
3595 var leftPadding = 3579 var leftPadding =
3596 (this.screenSize.width - (CROS_POD_WIDTH * 2 + DOUBLE_PODS_PADDING)) / 3580 (this.screenSize.width - (CROS_POD_WIDTH * 2 + DOUBLE_PODS_PADDING)) /
3597 2; 3581 2;
3598 // Start actual positioning. 3582 // Start actual positioning.
3599 this.mainPod_.left = leftPadding; 3583 this.mainPod_.left = leftPadding;
3600 this.mainPod_.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2; 3584 this.mainPod_.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2;
3601 secondPod.left = leftPadding + CROS_POD_WIDTH + DOUBLE_PODS_PADDING; 3585 secondPod.left = leftPadding + CROS_POD_WIDTH + DOUBLE_PODS_PADDING;
3602 secondPod.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2; 3586 secondPod.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2;
3603 }, 3587 },
3604 3588
3605 /** 3589 /**
3606 * Called when there are more than two user pods. 3590 * Called when the number of pods exceeds the POD_ROW_LIMIT.
3607 * @private 3591 * @private
3608 */ 3592 */
3609 placePodsOnContainer_: function() { 3593 placePodsOnContainer_: function() {
3610 this.smallPodsContainer.hidden = false; 3594 this.smallPodsContainer.hidden = false;
3611 var pods = this.pods; 3595 var pods = this.pods;
3612 if ((pods.length > LANDSCAPE_MODE_LIMIT && !this.isPortraitMode_()) || 3596 if ((pods.length > LANDSCAPE_MODE_LIMIT && !this.isPortraitMode_()) ||
3613 (pods.length > PORTRAIT_MODE_LIMIT && this.isPortraitMode_())) { 3597 (pods.length > PORTRAIT_MODE_LIMIT && this.isPortraitMode_())) {
3614 // If the pod count exceeds limits, they should be in extra small size 3598 // If the pod count exceeds limits, they should be in extra small size
3615 // and the container will become scrollable. 3599 // and the container will become scrollable.
3616 this.placePodsOnScrollableContainer_(); 3600 this.placePodsOnScrollableContainer_();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3678 if (pod == this.mainPod_) { 3662 if (pod == this.mainPod_) {
3679 continue; 3663 continue;
3680 } 3664 }
3681 pod.left = 0; 3665 pod.left = 0;
3682 pod.top = smallPodsTopPadding; 3666 pod.top = smallPodsTopPadding;
3683 smallPodsTopPadding += CROS_SMALL_POD_HEIGHT + actualSmallPodPadding; 3667 smallPodsTopPadding += CROS_SMALL_POD_HEIGHT + actualSmallPodPadding;
3684 } 3668 }
3685 }, 3669 },
3686 3670
3687 /** 3671 /**
3688 * Called when there are more than 6 user pods in landscape mode, or more 3672 * Called when the LANDSCAPE_MODE_LIMIT or PORTRAIT_MODE_LIMIT is exceeded
3689 * than 10 user pods in portrait mode. 3673 * and the scrollable container is shown.
3690 * @private 3674 * @private
3691 */ 3675 */
3692 placePodsOnScrollableContainer_: function() { 3676 placePodsOnScrollableContainer_: function() {
3693 this.smallPodsContainer.hidden = false; 3677 this.smallPodsContainer.hidden = false;
3694 // Add a dark overlay. 3678 // Add a dark overlay.
3695 this.smallPodsContainer.classList.add('scroll'); 3679 this.smallPodsContainer.classList.add('scroll');
3696 var pods = this.pods; 3680 var pods = this.pods;
3697 this.mainPod_.setPodStyle(UserPod.Style.LARGE); 3681 this.mainPod_.setPodStyle(UserPod.Style.LARGE);
3698 for (var pod of pods) { 3682 for (var pod of pods) {
3699 if (pod != this.mainPod_) { 3683 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; 3768 document.querySelector('.small-pod-container-mask').hidden = true;
3785 document.querySelector('.small-pod-container-mask.rotate').hidden = true; 3769 document.querySelector('.small-pod-container-mask.rotate').hidden = true;
3786 this.smallPodsContainer.classList.remove('scroll'); 3770 this.smallPodsContainer.classList.remove('scroll');
3787 var pods = this.pods; 3771 var pods = this.pods;
3788 for (var pod of pods) { 3772 for (var pod of pods) {
3789 // There is a chance that one of the pods has a bottom padding, so 3773 // 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 3774 // 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 3775 // the last position in the scrollable container, a bottom padding
3792 // was added to ensure a symmetric layout. 3776 // was added to ensure a symmetric layout.
3793 pod.style.paddingBottom = cr.ui.toCssPx(0); 3777 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 } 3778 }
3779 this.clearPodsAnimation_();
3798 this.hideEmptyArea_(); 3780 this.hideEmptyArea_();
3799 // Clear error bubbles whenever pod placement is happening, i.e., after 3781 // Clear error bubbles whenever pod placement is happening, i.e., after
3800 // orientation change, showing or hiding virtual keyboard, and user 3782 // orientation change, showing or hiding virtual keyboard, and user
3801 // removal. 3783 // removal.
3802 Oobe.clearErrors(); 3784 Oobe.clearErrors();
3803 }, 3785 },
3804 3786
3805 /** 3787 /**
3806 * Checks if the screen is in portrait mode. 3788 * Checks if the screen is in portrait mode.
3807 * @return {boolean} True if in portrait mode. 3789 * @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 3837 // Make sure that user name on each large pod is centered and extra
3856 // long names don't exceed maximum pod width. 3838 // long names don't exceed maximum pod width.
3857 var nameArea = pod.querySelector('.name-container'); 3839 var nameArea = pod.querySelector('.name-container');
3858 var leftMargin = (CROS_POD_WIDTH - pod.nameElement.offsetWidth) / 2; 3840 var leftMargin = (CROS_POD_WIDTH - pod.nameElement.offsetWidth) / 2;
3859 if (leftMargin > 0) 3841 if (leftMargin > 0)
3860 nameArea.style.left = cr.ui.toCssPx(leftMargin); 3842 nameArea.style.left = cr.ui.toCssPx(leftMargin);
3861 else { 3843 else {
3862 pod.nameElement.style.width = cr.ui.toCssPx(CROS_POD_WIDTH); 3844 pod.nameElement.style.width = cr.ui.toCssPx(CROS_POD_WIDTH);
3863 nameArea.style.left = cr.ui.toCssPx(0); 3845 nameArea.style.left = cr.ui.toCssPx(0);
3864 } 3846 }
3847 // Update info container area for public session pods.
3848 if (pod.isPublicSessionPod) {
3849 var infoElement = pod.querySelector('.info');
3850 var infoIcon = pod.querySelector('.learn-more');
3851 var totalWidth = PUBLIC_SESSION_ICON_WIDTH + infoElement.offsetWidth;
3852 var infoLeftMargin = (CROS_POD_WIDTH - totalWidth) / 2;
3853 if (infoLeftMargin > 0) {
3854 infoIcon.style.left = cr.ui.toCssPx(infoLeftMargin);
3855 infoElement.style.left =
3856 cr.ui.toCssPx(infoLeftMargin + PUBLIC_SESSION_ICON_WIDTH);
3857 } else {
3858 infoIcon.style.left = cr.ui.toCssPx(0);
3859 infoElement.style.left = cr.ui.toCssPx(PUBLIC_SESSION_ICON_WIDTH);
3860 infoElement.style.width = cr.ui.toCssPx(
3861 CROS_POD_WIDTH - PUBLIC_SESSION_ICON_WIDTH -
3862 infoElement.style.paddingLeft);
3863 }
3864 // If the public session pod is already expanded, make sure it's
3865 // still centered.
3866 if (pod.expanded)
3867 this.centerPod_(pod, PUBLIC_EXPANDED_WIDTH, PUBLIC_EXPANDED_HEIGHT);
3868 }
3865 // Update action box menu position to ensure it doesn't overlap with 3869 // Update action box menu position to ensure it doesn't overlap with
3866 // elements outside the pod. 3870 // elements outside the pod.
3867 var actionBoxMenu = pod.querySelector('.action-box-menu'); 3871 var actionBoxMenu = pod.querySelector('.action-box-menu');
3868 var actionBoxButton = pod.querySelector('.action-box-button'); 3872 var actionBoxButton = pod.querySelector('.action-box-button');
3869 actionBoxMenu.style.top = 3873 var MENU_TOP_PADDING = 7;
3870 cr.ui.toCssPx(actionBoxButton.offsetHeight);
3871 if (this.isPortraitMode_() && pods.length > 1) { 3874 if (this.isPortraitMode_() && pods.length > 1) {
3872 // Confine the menu inside the pod when it may overlap with outside 3875 // Confine the menu inside the pod when it may overlap with outside
3873 // elements. 3876 // elements.
3874 actionBoxMenu.style.left = 'auto'; 3877 actionBoxMenu.style.left = 'auto';
3875 actionBoxMenu.style.right = cr.ui.toCssPx(0); 3878 actionBoxMenu.style.right = cr.ui.toCssPx(0);
3879 actionBoxMenu.style.top =
3880 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING);
3881 } else if (!this.isPortraitMode_() && this.isScreenShrinked_()) {
3882 // Prevent the virtual keyboard from blocking the remove user button.
3883 actionBoxMenu.style.left = cr.ui.toCssPx(
3884 pod.nameElement.offsetWidth + actionBoxButton.offsetWidth);
3885 actionBoxMenu.style.right = 'auto';
3886 actionBoxMenu.style.top = cr.ui.toCssPx(0);
3876 } else { 3887 } else {
3877 actionBoxMenu.style.left = cr.ui.toCssPx( 3888 actionBoxMenu.style.left = cr.ui.toCssPx(
3878 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft); 3889 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3879 actionBoxMenu.style.right = 'auto'; 3890 actionBoxMenu.style.right = 'auto';
3891 actionBoxMenu.style.top =
3892 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING);
3880 } 3893 }
3881 // Add ripple animation. 3894 // Add ripple animation.
3882 var actionBoxRippleEffect = 3895 var actionBoxRippleEffect =
3883 pod.querySelector('.action-box-button.ripple-circle'); 3896 pod.querySelector('.action-box-button.ripple-circle');
3884 actionBoxRippleEffect.style.left = actionBoxMenu.style.left; 3897 actionBoxRippleEffect.style.left = cr.ui.toCssPx(
3898 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3885 actionBoxRippleEffect.style.top = 3899 actionBoxRippleEffect.style.top =
3886 cr.ui.toCssPx(actionBoxButton.style.marginTop); 3900 cr.ui.toCssPx(actionBoxButton.style.marginTop);
3887 // Adjust the vertical position of the pod if pin keyboard is shown. 3901 // Adjust the vertical position of the pod if pin keyboard is shown.
3888 if (pod.isPinShown() && !this.isScreenShrinked_()) 3902 if (pod.isPinShown() && !this.isScreenShrinked_())
3889 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2; 3903 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2;
3890 } 3904 }
3891 // Update the position of the sign-in banner if it's shown. 3905 // Update the position of the sign-in banner if it's shown.
3892 if ($('signin-banner').textContent.length != 0) { 3906 if ($('signin-banner').textContent.length != 0) {
3893 var bannerContainer = $('signin-banner-container1'); 3907 var bannerContainer = $('signin-banner-container1');
3894 var BANNER_TOP_PADDING = this.isScreenShrinked_() ? 0 : 38; 3908 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) { 3909 if (this.pods.length <= POD_ROW_LIMIT) {
3898 bannerContainer.style.left = 3910 bannerContainer.style.left =
3899 cr.ui.toCssPx((this.screenSize.width - BANNER_MESSAGE_WIDTH) / 2); 3911 cr.ui.toCssPx((this.screenSize.width - BANNER_MESSAGE_WIDTH) / 2);
3900 } 3912 }
3901 else { 3913 else {
3902 var leftPadding = 3914 var leftPadding =
3903 this.mainPod_.left - (BANNER_MESSAGE_WIDTH - CROS_POD_WIDTH) / 2; 3915 this.mainPod_.left - (BANNER_MESSAGE_WIDTH - CROS_POD_WIDTH) / 2;
3904 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0)); 3916 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0));
3905 } 3917 }
3906 } 3918 }
3907 }, 3919 },
3908 3920
3909 /** 3921 /**
3922 * Handles required UI changes when a public session pod toggles the
3923 * expanded state.
3924 * @param {UserPod} pod Public session pod.
3925 * @param {boolean} expanded Whether the pod is expanded or not.
3926 */
3927 handlePublicPodExpansion: function(pod, expanded) {
3928 // Hide all other elements in the account picker if the pod is expanded.
3929 this.parentNode.classList.toggle('public-account-expanded', expanded);
3930 if (expanded) {
3931 this.centerPod_(pod, PUBLIC_EXPANDED_WIDTH, PUBLIC_EXPANDED_HEIGHT);
3932 } else {
3933 // Return the pod to its last position.
3934 pod.left = pod.lastPosition.left;
3935 pod.top = pod.lastPosition.top;
3936 // Pod placement has already finished by this point, but we still need
3937 // to make sure that the styles of all the elements in the pod row are
3938 // updated before being shown.
3939 this.handleAfterPodPlacement_();
3940 this.clearPodsAnimation_();
3941 }
3942 },
3943
3944 /**
3945 * Called when a pod needs to be centered.
3946 * @param {UserPod} pod Pod to be centered.
3947 * @param {number} podWidth The pod width.
3948 * @param {number} podHeight The pod height.
3949 * @private
3950 */
3951 centerPod_: function(pod, podWidth, podHeight) {
3952 // The original position of a public session pod is recorded in case of
3953 // future need.
3954 if (pod.isPublicSessionPod)
3955 pod.lastPosition = {left: pod.left, top: pod.top};
3956 // Avoid using offsetWidth and offsetHeight in case the pod is not fully
3957 // loaded yet.
3958 pod.left = (this.screenSize.width - podWidth) / 2;
3959 pod.top = (this.screenSize.height - podHeight) / 2;
3960 },
3961
3962 /**
3963 * Clears animation classes that may be added earlier to ensure a clean
3964 * state.
3965 * @private
3966 */
3967 clearPodsAnimation_: function() {
3968 var pods = this.pods;
3969 for (var pod of pods) {
3970 pod.imageElement.classList.remove('switch-image-animation');
3971 pod.smallPodImageElement.classList.remove('switch-image-animation');
3972 }
3973 },
3974
3975 /**
3910 * Called when a small or extra small pod is clicked to trigger the switch 3976 * Called when a small or extra small pod is clicked to trigger the switch
3911 * with the main pod. 3977 * with the main pod.
3978 * @param {UserPod} pod Pod to be switched with the main pod.
3912 */ 3979 */
3913 switchMainPod: function(pod) { 3980 switchMainPod: function(pod) {
3914 if (this.disabled) { 3981 if (this.disabled) {
3915 console.error('Cannot change main pod while sign-in UI is disabled.'); 3982 console.error('Cannot switch main pod while sign-in UI is disabled.');
3916 return; 3983 return;
3917 } 3984 }
3918 if (!this.mainPod_) { 3985 if (!this.mainPod_) {
3919 console.error('Attempt to switch a non-existing main pod.'); 3986 console.error('Attempt to switch a non-existing main pod.');
3920 return; 3987 return;
3921 } 3988 }
3922 // Find the index of the small pod. 3989 // Find the index of the small pod.
3923 var insert = 0; 3990 var insert = 0;
3924 var children = pod.parentNode.children; 3991 var children = pod.parentNode.children;
3925 while (insert < children.length && children[insert] != pod) 3992 while (insert < children.length && children[insert] != pod)
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
4260 if (this.alwaysFocusSinglePod && !pod) { 4327 if (this.alwaysFocusSinglePod && !pod) {
4261 if ($('login-header-bar').contains(e.target)) 4328 if ($('login-header-bar').contains(e.target))
4262 return; 4329 return;
4263 // If the click is outside the single pod, still focus on that pod 4330 // 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 4331 // but do not focus on input box any more. This makes virtual keyboard
4265 // (if present) disappear. 4332 // (if present) disappear.
4266 this.focusPod( 4333 this.focusPod(
4267 this.focusedPod_, true /* force */, true /* opt_skipInputFocus */); 4334 this.focusedPod_, true /* force */, true /* opt_skipInputFocus */);
4268 this.focusedPod_.userTypeBubbleElement.classList.remove('bubble-shown'); 4335 this.focusedPod_.userTypeBubbleElement.classList.remove('bubble-shown');
4269 this.focusedPod_.isActionBoxMenuHovered = false; 4336 this.focusedPod_.isActionBoxMenuHovered = false;
4337 // If the click is outside the public session pod, still focus on it
4338 // but do not expand it any more.
4339 if (this.focusedPod_.isPublicSessionPod)
4340 this.focusedPod_.expanded = false;
4270 } 4341 }
4271 }, 4342 },
4272 4343
4273 /** 4344 /**
4274 * Handler of mouse move event. 4345 * Handler of mouse move event.
4275 * @param {Event} e Click Event object. 4346 * @param {Event} e Click Event object.
4276 * @private 4347 * @private
4277 */ 4348 */
4278 handleMouseMove_: function(e) { 4349 handleMouseMove_: function(e) {
4279 if (this.disabled) 4350 if (this.disabled)
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4388 if (!editing) { 4459 if (!editing) {
4389 if (this.focusedPod_ && this.focusedPod_.nextElementSibling) 4460 if (this.focusedPod_ && this.focusedPod_.nextElementSibling)
4390 this.focusPod(this.focusedPod_.nextElementSibling); 4461 this.focusPod(this.focusedPod_.nextElementSibling);
4391 else 4462 else
4392 this.focusPod(this.firstElementChild); 4463 this.focusPod(this.firstElementChild);
4393 4464
4394 e.stopPropagation(); 4465 e.stopPropagation();
4395 } 4466 }
4396 break; 4467 break;
4397 case 'Enter': 4468 case 'Enter':
4398 if (this.focusedPod_) { 4469 // Keydown events on public session pods should only be handled by
4470 // their own handler.
4471 if (this.focusedPod_ && !this.focusedPod_.isPublicSessionPod) {
4399 var targetTag = e.target.tagName; 4472 var targetTag = e.target.tagName;
4400 if (e.target == this.focusedPod_.passwordElement || 4473 if (e.target == this.focusedPod_.passwordElement ||
4401 (this.focusedPod_.pinKeyboard && 4474 (this.focusedPod_.pinKeyboard &&
4402 e.target == this.focusedPod_.pinKeyboard.inputElement) || 4475 e.target == this.focusedPod_.pinKeyboard.inputElement) ||
4403 (targetTag != 'INPUT' && 4476 (targetTag != 'INPUT' &&
4404 targetTag != 'BUTTON' && 4477 targetTag != 'BUTTON' &&
4405 targetTag != 'A')) { 4478 targetTag != 'A')) {
4406 this.setActivatedPod(this.focusedPod_, e); 4479 this.setActivatedPod(this.focusedPod_, e);
4407 e.stopPropagation(); 4480 e.stopPropagation();
4408 } 4481 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
4500 if (pod && pod.multiProfilesPolicyApplied) { 4573 if (pod && pod.multiProfilesPolicyApplied) {
4501 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 4574 pod.userTypeBubbleElement.classList.remove('bubble-shown');
4502 } 4575 }
4503 } 4576 }
4504 }; 4577 };
4505 4578
4506 return { 4579 return {
4507 PodRow: PodRow 4580 PodRow: PodRow
4508 }; 4581 };
4509 }); 4582 });
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