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

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