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

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

Issue 2936173002: Fix misplacement of signin overlay and critical update message banner (Closed)
Patch Set: Address comments 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 /**
(...skipping 10 matching lines...) Expand all
21 var CROS_SMALL_POD_HEIGHT = 74; 21 var CROS_SMALL_POD_HEIGHT = 74;
22 var CROS_EXTRA_SMALL_POD_HEIGHT = 60; 22 var CROS_EXTRA_SMALL_POD_HEIGHT = 60;
23 var DESKTOP_POD_HEIGHT = 226; 23 var DESKTOP_POD_HEIGHT = 226;
24 var MD_DESKTOP_POD_HEIGHT = 200; 24 var MD_DESKTOP_POD_HEIGHT = 200;
25 var PUBLIC_EXPANDED_HEIGHT = 324; 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;
32 var CROS_POD_HEIGHT_WITH_PIN = 618; 31 var CROS_POD_HEIGHT_WITH_PIN = 618;
33 var PUBLIC_SESSION_ICON_WIDTH = 12; 32 var PUBLIC_SESSION_ICON_WIDTH = 12;
34 33
35 /** 34 /**
36 * The maximum number of users that each pod placement method can handle. 35 * The maximum number of users that each pod placement method can handle.
37 */ 36 */
38 var POD_ROW_LIMIT = 2; 37 var POD_ROW_LIMIT = 2;
39 var LANDSCAPE_MODE_LIMIT = 6; 38 var LANDSCAPE_MODE_LIMIT = 6;
40 var PORTRAIT_MODE_LIMIT = 9; 39 var PORTRAIT_MODE_LIMIT = 9;
41 40
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 }, 655 },
657 656
658 /** 657 /**
659 * Returns whether the user pod to which the custom icon belongs is focused. 658 * Returns whether the user pod to which the custom icon belongs is focused.
660 * @return {boolean} 659 * @return {boolean}
661 * @private 660 * @private
662 */ 661 */
663 isParentPodFocused_: function() { 662 isParentPodFocused_: function() {
664 if ($('account-picker').hidden) 663 if ($('account-picker').hidden)
665 return false; 664 return false;
666 var parentPod = this.parentNode; 665 var parentPod = this.getParentPod_();
667 while (parentPod && !parentPod.classList.contains('pod'))
668 parentPod = parentPod.parentNode;
669 return parentPod && parentPod.parentNode.isFocused(parentPod); 666 return parentPod && parentPod.parentNode.isFocused(parentPod);
670 }, 667 },
671 668
672 /** 669 /**
673 * Depending on {@code this.tooltipState_}, it updates tooltip visibility 670 * Depending on {@code this.tooltipState_}, it updates tooltip visibility
674 * and text. 671 * and text.
675 * @private 672 * @private
676 */ 673 */
677 updateTooltip_: function() { 674 updateTooltip_: function() {
678 if (this.hidden || !this.isParentPodFocused_()) 675 if (this.hidden || !this.getParentPod_() ||
676 this.getParentPod_().getPodStyle() != UserPod.Style.LARGE ||
677 !this.isParentPodFocused_())
jdufault 2017/06/15 19:04:09 multi-line if means that the body needs braces ({}
Wenzhao (Colin) Zang 2017/06/15 21:40:47 Done. Sorry I missed that in the style guide. FYI
679 return; 678 return;
680 679
681 if (!this.tooltipState_.active() || !this.tooltipState_.text) { 680 if (!this.tooltipState_.active() || !this.tooltipState_.text) {
682 this.hideTooltip_(); 681 this.hideTooltip_();
683 return; 682 return;
684 } 683 }
685 684
686 // Show the tooltip bubble. 685 // Show the tooltip bubble.
687 var bubbleContent = document.createElement('div'); 686 var bubbleContent = document.createElement('div');
688 bubbleContent.textContent = this.tooltipState_.text; 687 bubbleContent.textContent = this.tooltipState_.text;
689 688
690 /** @const */ var BUBBLE_OFFSET = CUSTOM_ICON_CONTAINER_SIZE / 2; 689 /** @const */ var BUBBLE_OFFSET = CUSTOM_ICON_CONTAINER_SIZE / 2;
691 // TODO(tengs): Introduce a special reauth state for the account picker, 690 // TODO(tengs): Introduce a special reauth state for the account picker,
692 // instead of showing the tooltip bubble here (crbug.com/409427). 691 // instead of showing the tooltip bubble here (crbug.com/409427).
693 /** @const */ var BUBBLE_PADDING = 8 + (this.iconId_ ? 0 : 23); 692 /** @const */ var BUBBLE_PADDING = 8 + (this.iconId_ ? 0 : 23);
694 $('bubble').showContentForElement(this, 693 $('bubble').showContentForElement(this,
695 cr.ui.Bubble.Attachment.LEFT, 694 cr.ui.Bubble.Attachment.LEFT,
696 bubbleContent, 695 bubbleContent,
697 BUBBLE_OFFSET, 696 BUBBLE_OFFSET,
698 BUBBLE_PADDING); 697 BUBBLE_PADDING);
699 }, 698 },
700 699
701 /** 700 /**
702 * Hides the tooltip. 701 * Hides the tooltip.
703 * @private 702 * @private
704 */ 703 */
705 hideTooltip_: function() { 704 hideTooltip_: function() {
706 $('bubble').hideForElement(this); 705 $('bubble').hideForElement(this);
706 },
707
708 /**
709 * Gets the parent pod (may be null) of this custom icon.
710 * @return {HTMLDivElement}
711 */
712 getParentPod_: function() {
713 var parentPod = this.parentNode;
714 while (parentPod && !parentPod.classList.contains('pod'))
715 parentPod = parentPod.parentNode;
716 return parentPod;
707 } 717 }
708 }; 718 };
709 719
710 /** 720 /**
711 * Unique salt added to user image URLs to prevent caching. Dictionary with 721 * Unique salt added to user image URLs to prevent caching. Dictionary with
712 * user names as keys. 722 * user names as keys.
713 * @type {Object} 723 * @type {Object}
714 */ 724 */
715 UserPod.userImageSalt_ = {}; 725 UserPod.userImageSalt_ = {};
716 726
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 this.parentNode.handlePublicPodExpansion(this, expanded); 2244 this.parentNode.handlePublicPodExpansion(this, expanded);
2235 }, 2245 },
2236 2246
2237 get advanced() { 2247 get advanced() {
2238 return this.classList.contains('advanced'); 2248 return this.classList.contains('advanced');
2239 }, 2249 },
2240 2250
2241 /** @override */ 2251 /** @override */
2242 get mainInput() { 2252 get mainInput() {
2243 if (this.expanded) 2253 if (this.expanded)
2244 return this.enterButtonElement; 2254 return this.querySelector('.monitoring-learn-more');
2245 else 2255 else
2246 return this.nameElement; 2256 return this.nameElement;
2247 }, 2257 },
2248 2258
2249 /** @override */ 2259 /** @override */
2250 decorate: function() { 2260 decorate: function() {
2251 UserPod.prototype.decorate.call(this); 2261 UserPod.prototype.decorate.call(this);
2252 2262
2253 this.classList.add('public-account'); 2263 this.classList.add('public-account');
2254 2264
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 var languageAndInputIcon = 2300 var languageAndInputIcon =
2291 this.querySelector('.language-and-input-dropdown'); 2301 this.querySelector('.language-and-input-dropdown');
2292 languageAndInputIcon.addEventListener( 2302 languageAndInputIcon.addEventListener(
2293 'click', this.transitionToAdvanced_.bind(this)); 2303 'click', this.transitionToAdvanced_.bind(this));
2294 2304
2295 var monitoringLearnMore = this.querySelector('.monitoring-learn-more'); 2305 var monitoringLearnMore = this.querySelector('.monitoring-learn-more');
2296 monitoringLearnMore.tabIndex = UserPodTabOrder.POD_INPUT; 2306 monitoringLearnMore.tabIndex = UserPodTabOrder.POD_INPUT;
2297 monitoringLearnMore.addEventListener( 2307 monitoringLearnMore.addEventListener(
2298 'click', this.onMonitoringLearnMoreClicked_.bind(this)); 2308 'click', this.onMonitoringLearnMoreClicked_.bind(this));
2299 2309
2310 this.enterButtonElement.tabIndex = UserPodTabOrder.POD_INPUT;
2300 this.enterButtonElement.addEventListener('click', (function(e) { 2311 this.enterButtonElement.addEventListener('click', (function(e) {
2301 this.enterButtonElement.disabled = true; 2312 this.enterButtonElement.disabled = true;
2302 var locale = this.querySelector('.language-select').value; 2313 var locale = this.querySelector('.language-select').value;
2303 var keyboardSelect = this.querySelector('.keyboard-select'); 2314 var keyboardSelect = this.querySelector('.keyboard-select');
2304 // The contents of |keyboardSelect| is updated asynchronously. If its 2315 // The contents of |keyboardSelect| is updated asynchronously. If its
2305 // locale does not match |locale|, it has not updated yet and the 2316 // locale does not match |locale|, it has not updated yet and the
2306 // currently selected keyboard layout may not be applicable to |locale|. 2317 // currently selected keyboard layout may not be applicable to |locale|.
2307 // Do not return any keyboard layout in this case and let the backend 2318 // Do not return any keyboard layout in this case and let the backend
2308 // choose a suitable layout. 2319 // choose a suitable layout.
2309 var keyboardLayout = 2320 var keyboardLayout =
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
3884 pod.nameElement.offsetWidth + actionBoxButton.offsetWidth); 3895 pod.nameElement.offsetWidth + actionBoxButton.offsetWidth);
3885 actionBoxMenu.style.right = 'auto'; 3896 actionBoxMenu.style.right = 'auto';
3886 actionBoxMenu.style.top = cr.ui.toCssPx(0); 3897 actionBoxMenu.style.top = cr.ui.toCssPx(0);
3887 } else { 3898 } else {
3888 actionBoxMenu.style.left = cr.ui.toCssPx( 3899 actionBoxMenu.style.left = cr.ui.toCssPx(
3889 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft); 3900 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3890 actionBoxMenu.style.right = 'auto'; 3901 actionBoxMenu.style.right = 'auto';
3891 actionBoxMenu.style.top = 3902 actionBoxMenu.style.top =
3892 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING); 3903 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING);
3893 } 3904 }
3905 // Update password container width based on the visibility of the
3906 // custom icon container.
3907 pod.querySelector('.password-container')
3908 .classList.toggle(
3909 'custom-icon-shown', !pod.customIconElement.hidden);
3894 // Add ripple animation. 3910 // Add ripple animation.
3895 var actionBoxRippleEffect = 3911 var actionBoxRippleEffect =
3896 pod.querySelector('.action-box-button.ripple-circle'); 3912 pod.querySelector('.action-box-button.ripple-circle');
3897 actionBoxRippleEffect.style.left = cr.ui.toCssPx( 3913 actionBoxRippleEffect.style.left = cr.ui.toCssPx(
3898 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft); 3914 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3899 actionBoxRippleEffect.style.top = 3915 actionBoxRippleEffect.style.top =
3900 cr.ui.toCssPx(actionBoxButton.style.marginTop); 3916 cr.ui.toCssPx(actionBoxButton.style.marginTop);
3901 // Adjust the vertical position of the pod if pin keyboard is shown. 3917 // Adjust the vertical position of the pod if pin keyboard is shown.
3902 if (pod.isPinShown() && !this.isScreenShrinked_()) 3918 if (pod.isPinShown() && !this.isScreenShrinked_())
3903 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2; 3919 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2;
3904 } 3920 }
3905 // Update the position of the sign-in banner if it's shown. 3921 // Update the position of the sign-in banner if it's shown.
3906 if ($('signin-banner').textContent.length != 0) { 3922 if ($('signin-banner').textContent.length != 0) {
3907 var bannerContainer = $('signin-banner-container1'); 3923 var bannerContainer = $('signin-banner-container1');
3908 bannerContainer.style.top = cr.ui.toCssPx(this.mainPod_.top / 2); 3924 bannerContainer.style.top = cr.ui.toCssPx(this.mainPod_.top / 2);
3909 if (this.pods.length <= POD_ROW_LIMIT) { 3925 if (this.pods.length <= POD_ROW_LIMIT) {
3910 bannerContainer.style.left = 3926 bannerContainer.style.left = cr.ui.toCssPx(
3911 cr.ui.toCssPx((this.screenSize.width - BANNER_MESSAGE_WIDTH) / 2); 3927 (this.screenSize.width - bannerContainer.offsetWidth) / 2);
3912 } 3928 }
3913 else { 3929 else {
3914 var leftPadding = 3930 var leftPadding = this.mainPod_.left -
3915 this.mainPod_.left - (BANNER_MESSAGE_WIDTH - CROS_POD_WIDTH) / 2; 3931 (bannerContainer.offsetWidth - CROS_POD_WIDTH) / 2;
3916 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0)); 3932 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0));
3917 } 3933 }
3918 } 3934 }
3919 }, 3935 },
3920 3936
3921 /** 3937 /**
3922 * Handles required UI changes when a public session pod toggles the 3938 * Handles required UI changes when a public session pod toggles the
3923 * expanded state. 3939 * expanded state.
3924 * @param {UserPod} pod Public session pod. 3940 * @param {UserPod} pod Public session pod.
3925 * @param {boolean} expanded Whether the pod is expanded or not. 3941 * @param {boolean} expanded Whether the pod is expanded or not.
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
4573 if (pod && pod.multiProfilesPolicyApplied) { 4589 if (pod && pod.multiProfilesPolicyApplied) {
4574 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 4590 pod.userTypeBubbleElement.classList.remove('bubble-shown');
4575 } 4591 }
4576 } 4592 }
4577 }; 4593 };
4578 4594
4579 return { 4595 return {
4580 PodRow: PodRow 4596 PodRow: PodRow
4581 }; 4597 };
4582 }); 4598 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698