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

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: 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 ||
676 this.getParentPod_().getPodStyle() != UserPod.Style.LARGE)
jdufault 2017/06/15 17:52:09 Can parentPod can be null? based on isParentPodFoc
Wenzhao (Colin) Zang 2017/06/15 18:40:21 Done.
677 return;
678
679 if (!this.isParentPodFocused_())
jdufault 2017/06/15 17:52:09 nit: || !this.isParentPodFocused_()
Wenzhao (Colin) Zang 2017/06/15 18:40:21 Done.
679 return; 680 return;
680 681
681 if (!this.tooltipState_.active() || !this.tooltipState_.text) { 682 if (!this.tooltipState_.active() || !this.tooltipState_.text) {
682 this.hideTooltip_(); 683 this.hideTooltip_();
683 return; 684 return;
684 } 685 }
685 686
686 // Show the tooltip bubble. 687 // Show the tooltip bubble.
687 var bubbleContent = document.createElement('div'); 688 var bubbleContent = document.createElement('div');
688 bubbleContent.textContent = this.tooltipState_.text; 689 bubbleContent.textContent = this.tooltipState_.text;
689 690
690 /** @const */ var BUBBLE_OFFSET = CUSTOM_ICON_CONTAINER_SIZE / 2; 691 /** @const */ var BUBBLE_OFFSET = CUSTOM_ICON_CONTAINER_SIZE / 2;
691 // TODO(tengs): Introduce a special reauth state for the account picker, 692 // TODO(tengs): Introduce a special reauth state for the account picker,
692 // instead of showing the tooltip bubble here (crbug.com/409427). 693 // instead of showing the tooltip bubble here (crbug.com/409427).
693 /** @const */ var BUBBLE_PADDING = 8 + (this.iconId_ ? 0 : 23); 694 /** @const */ var BUBBLE_PADDING = 8 + (this.iconId_ ? 0 : 23);
694 $('bubble').showContentForElement(this, 695 $('bubble').showContentForElement(this,
695 cr.ui.Bubble.Attachment.LEFT, 696 cr.ui.Bubble.Attachment.LEFT,
696 bubbleContent, 697 bubbleContent,
697 BUBBLE_OFFSET, 698 BUBBLE_OFFSET,
698 BUBBLE_PADDING); 699 BUBBLE_PADDING);
699 }, 700 },
700 701
701 /** 702 /**
702 * Hides the tooltip. 703 * Hides the tooltip.
703 * @private 704 * @private
704 */ 705 */
705 hideTooltip_: function() { 706 hideTooltip_: function() {
706 $('bubble').hideForElement(this); 707 $('bubble').hideForElement(this);
708 },
709
710 /**
711 * Gets the parent pod (may be null) of this custom icon.
712 * @return {HTMLDivElement}
713 */
714 getParentPod_: function() {
715 var parentPod = this.parentNode;
716 while (parentPod && !parentPod.classList.contains('pod'))
717 parentPod = parentPod.parentNode;
718 return parentPod;
707 } 719 }
708 }; 720 };
709 721
710 /** 722 /**
711 * Unique salt added to user image URLs to prevent caching. Dictionary with 723 * Unique salt added to user image URLs to prevent caching. Dictionary with
712 * user names as keys. 724 * user names as keys.
713 * @type {Object} 725 * @type {Object}
714 */ 726 */
715 UserPod.userImageSalt_ = {}; 727 UserPod.userImageSalt_ = {};
716 728
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 this.parentNode.handlePublicPodExpansion(this, expanded); 2246 this.parentNode.handlePublicPodExpansion(this, expanded);
2235 }, 2247 },
2236 2248
2237 get advanced() { 2249 get advanced() {
2238 return this.classList.contains('advanced'); 2250 return this.classList.contains('advanced');
2239 }, 2251 },
2240 2252
2241 /** @override */ 2253 /** @override */
2242 get mainInput() { 2254 get mainInput() {
2243 if (this.expanded) 2255 if (this.expanded)
2244 return this.enterButtonElement; 2256 return this.querySelector('.monitoring-learn-more');
2245 else 2257 else
2246 return this.nameElement; 2258 return this.nameElement;
2247 }, 2259 },
2248 2260
2249 /** @override */ 2261 /** @override */
2250 decorate: function() { 2262 decorate: function() {
2251 UserPod.prototype.decorate.call(this); 2263 UserPod.prototype.decorate.call(this);
2252 2264
2253 this.classList.add('public-account'); 2265 this.classList.add('public-account');
2254 2266
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 var languageAndInputIcon = 2302 var languageAndInputIcon =
2291 this.querySelector('.language-and-input-dropdown'); 2303 this.querySelector('.language-and-input-dropdown');
2292 languageAndInputIcon.addEventListener( 2304 languageAndInputIcon.addEventListener(
2293 'click', this.transitionToAdvanced_.bind(this)); 2305 'click', this.transitionToAdvanced_.bind(this));
2294 2306
2295 var monitoringLearnMore = this.querySelector('.monitoring-learn-more'); 2307 var monitoringLearnMore = this.querySelector('.monitoring-learn-more');
2296 monitoringLearnMore.tabIndex = UserPodTabOrder.POD_INPUT; 2308 monitoringLearnMore.tabIndex = UserPodTabOrder.POD_INPUT;
2297 monitoringLearnMore.addEventListener( 2309 monitoringLearnMore.addEventListener(
2298 'click', this.onMonitoringLearnMoreClicked_.bind(this)); 2310 'click', this.onMonitoringLearnMoreClicked_.bind(this));
2299 2311
2312 this.enterButtonElement.tabIndex = UserPodTabOrder.POD_INPUT;
2300 this.enterButtonElement.addEventListener('click', (function(e) { 2313 this.enterButtonElement.addEventListener('click', (function(e) {
2301 this.enterButtonElement.disabled = true; 2314 this.enterButtonElement.disabled = true;
2302 var locale = this.querySelector('.language-select').value; 2315 var locale = this.querySelector('.language-select').value;
2303 var keyboardSelect = this.querySelector('.keyboard-select'); 2316 var keyboardSelect = this.querySelector('.keyboard-select');
2304 // The contents of |keyboardSelect| is updated asynchronously. If its 2317 // The contents of |keyboardSelect| is updated asynchronously. If its
2305 // locale does not match |locale|, it has not updated yet and the 2318 // locale does not match |locale|, it has not updated yet and the
2306 // currently selected keyboard layout may not be applicable to |locale|. 2319 // currently selected keyboard layout may not be applicable to |locale|.
2307 // Do not return any keyboard layout in this case and let the backend 2320 // Do not return any keyboard layout in this case and let the backend
2308 // choose a suitable layout. 2321 // choose a suitable layout.
2309 var keyboardLayout = 2322 var keyboardLayout =
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
3884 pod.nameElement.offsetWidth + actionBoxButton.offsetWidth); 3897 pod.nameElement.offsetWidth + actionBoxButton.offsetWidth);
3885 actionBoxMenu.style.right = 'auto'; 3898 actionBoxMenu.style.right = 'auto';
3886 actionBoxMenu.style.top = cr.ui.toCssPx(0); 3899 actionBoxMenu.style.top = cr.ui.toCssPx(0);
3887 } else { 3900 } else {
3888 actionBoxMenu.style.left = cr.ui.toCssPx( 3901 actionBoxMenu.style.left = cr.ui.toCssPx(
3889 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft); 3902 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3890 actionBoxMenu.style.right = 'auto'; 3903 actionBoxMenu.style.right = 'auto';
3891 actionBoxMenu.style.top = 3904 actionBoxMenu.style.top =
3892 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING); 3905 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING);
3893 } 3906 }
3907 // Update password container width based on the visibility of the
3908 // custom icon container.
3909 pod.querySelector('.password-container')
3910 .classList.toggle(
3911 'custom-icon-shown', !pod.customIconElement.hidden);
3894 // Add ripple animation. 3912 // Add ripple animation.
3895 var actionBoxRippleEffect = 3913 var actionBoxRippleEffect =
3896 pod.querySelector('.action-box-button.ripple-circle'); 3914 pod.querySelector('.action-box-button.ripple-circle');
3897 actionBoxRippleEffect.style.left = cr.ui.toCssPx( 3915 actionBoxRippleEffect.style.left = cr.ui.toCssPx(
3898 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft); 3916 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3899 actionBoxRippleEffect.style.top = 3917 actionBoxRippleEffect.style.top =
3900 cr.ui.toCssPx(actionBoxButton.style.marginTop); 3918 cr.ui.toCssPx(actionBoxButton.style.marginTop);
3901 // Adjust the vertical position of the pod if pin keyboard is shown. 3919 // Adjust the vertical position of the pod if pin keyboard is shown.
3902 if (pod.isPinShown() && !this.isScreenShrinked_()) 3920 if (pod.isPinShown() && !this.isScreenShrinked_())
3903 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2; 3921 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2;
3904 } 3922 }
3905 // Update the position of the sign-in banner if it's shown. 3923 // Update the position of the sign-in banner if it's shown.
3906 if ($('signin-banner').textContent.length != 0) { 3924 if ($('signin-banner').textContent.length != 0) {
3907 var bannerContainer = $('signin-banner-container1'); 3925 var bannerContainer = $('signin-banner-container1');
3908 bannerContainer.style.top = cr.ui.toCssPx(this.mainPod_.top / 2); 3926 bannerContainer.style.top = cr.ui.toCssPx(this.mainPod_.top / 2);
3909 if (this.pods.length <= POD_ROW_LIMIT) { 3927 if (this.pods.length <= POD_ROW_LIMIT) {
3910 bannerContainer.style.left = 3928 bannerContainer.style.left = cr.ui.toCssPx(
3911 cr.ui.toCssPx((this.screenSize.width - BANNER_MESSAGE_WIDTH) / 2); 3929 (this.screenSize.width - bannerContainer.offsetWidth) / 2);
3912 } 3930 }
3913 else { 3931 else {
3914 var leftPadding = 3932 var leftPadding = this.mainPod_.left -
3915 this.mainPod_.left - (BANNER_MESSAGE_WIDTH - CROS_POD_WIDTH) / 2; 3933 (bannerContainer.offsetWidth - CROS_POD_WIDTH) / 2;
3916 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0)); 3934 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0));
3917 } 3935 }
3918 } 3936 }
3919 }, 3937 },
3920 3938
3921 /** 3939 /**
3922 * Handles required UI changes when a public session pod toggles the 3940 * Handles required UI changes when a public session pod toggles the
3923 * expanded state. 3941 * expanded state.
3924 * @param {UserPod} pod Public session pod. 3942 * @param {UserPod} pod Public session pod.
3925 * @param {boolean} expanded Whether the pod is expanded or not. 3943 * @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) { 4591 if (pod && pod.multiProfilesPolicyApplied) {
4574 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 4592 pod.userTypeBubbleElement.classList.remove('bubble-shown');
4575 } 4593 }
4576 } 4594 }
4577 }; 4595 };
4578 4596
4579 return { 4597 return {
4580 PodRow: PodRow 4598 PodRow: PodRow
4581 }; 4599 };
4582 }); 4600 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698