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

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

Issue 2947933002: Fix style issues for right-to-left languages (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
« no previous file with comments | « ui/login/account_picker/md_user_pod_row.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3837 matching lines...) Expand 10 before | Expand all | Expand 10 after
3848 }, 3848 },
3849 3849
3850 /** 3850 /**
3851 * Called after pod placement and before showing the pod row. Updates 3851 * Called after pod placement and before showing the pod row. Updates
3852 * elements whose style may depend on the pod placement outcome. 3852 * elements whose style may depend on the pod placement outcome.
3853 * @private 3853 * @private
3854 */ 3854 */
3855 handleAfterPodPlacement_: function() { 3855 handleAfterPodPlacement_: function() {
3856 var pods = this.pods; 3856 var pods = this.pods;
3857 for (var pod of pods) { 3857 for (var pod of pods) {
3858 if (pods.length > POD_ROW_LIMIT && pod != this.mainPod_) 3858 if (pod.getPodStyle() != UserPod.Style.LARGE)
3859 continue; 3859 continue;
3860 // Make sure that user name on each large pod is centered and extra 3860 // Make sure that user name on each large pod is centered and extra
3861 // long names don't exceed maximum pod width. 3861 // long names don't exceed maximum pod width.
3862 var nameArea = pod.querySelector('.name-container'); 3862 var nameArea = pod.querySelector('.name-container');
3863 var leftMargin = (CROS_POD_WIDTH - pod.nameElement.offsetWidth) / 2; 3863 var leftMargin = (CROS_POD_WIDTH - pod.nameElement.offsetWidth) / 2;
3864 if (leftMargin > 0) 3864 if (leftMargin > 0) {
3865 nameArea.style.left = cr.ui.toCssPx(leftMargin); 3865 nameArea.style.left = cr.ui.toCssPx(leftMargin);
3866 else { 3866 nameArea.style.right = 'auto';
3867 } else {
3867 pod.nameElement.style.width = cr.ui.toCssPx(CROS_POD_WIDTH); 3868 pod.nameElement.style.width = cr.ui.toCssPx(CROS_POD_WIDTH);
3868 nameArea.style.left = cr.ui.toCssPx(0); 3869 nameArea.style.left = cr.ui.toCssPx(0);
3870 nameArea.style.right = 'auto';
3869 } 3871 }
3872
3870 // Update info container area for public session pods. 3873 // Update info container area for public session pods.
3871 if (pod.isPublicSessionPod) { 3874 if (pod.isPublicSessionPod) {
3872 var infoElement = pod.querySelector('.info'); 3875 var infoElement = pod.querySelector('.info');
3873 var infoIcon = pod.querySelector('.learn-more'); 3876 var infoIcon = pod.querySelector('.learn-more');
3874 var totalWidth = PUBLIC_SESSION_ICON_WIDTH + infoElement.offsetWidth; 3877 var totalWidth = PUBLIC_SESSION_ICON_WIDTH + infoElement.offsetWidth;
3875 var infoLeftMargin = (CROS_POD_WIDTH - totalWidth) / 2; 3878 var infoLeftMargin = (CROS_POD_WIDTH - totalWidth) / 2;
3876 if (infoLeftMargin > 0) { 3879 if (infoLeftMargin > 0) {
3877 infoIcon.style.left = cr.ui.toCssPx(infoLeftMargin); 3880 infoIcon.style.left = cr.ui.toCssPx(infoLeftMargin);
3881 infoIcon.style.right = 'auto';
3878 infoElement.style.left = 3882 infoElement.style.left =
3879 cr.ui.toCssPx(infoLeftMargin + PUBLIC_SESSION_ICON_WIDTH); 3883 cr.ui.toCssPx(infoLeftMargin + PUBLIC_SESSION_ICON_WIDTH);
3884 infoElement.style.right = 'auto';
3880 } else { 3885 } else {
3881 infoIcon.style.left = cr.ui.toCssPx(0); 3886 infoIcon.style.left = cr.ui.toCssPx(0);
3887 infoIcon.style.right = 'auto';
3882 infoElement.style.left = cr.ui.toCssPx(PUBLIC_SESSION_ICON_WIDTH); 3888 infoElement.style.left = cr.ui.toCssPx(PUBLIC_SESSION_ICON_WIDTH);
3889 infoElement.style.right = 'auto';
3883 infoElement.style.width = cr.ui.toCssPx( 3890 infoElement.style.width = cr.ui.toCssPx(
3884 CROS_POD_WIDTH - PUBLIC_SESSION_ICON_WIDTH - 3891 CROS_POD_WIDTH - PUBLIC_SESSION_ICON_WIDTH -
3885 infoElement.style.paddingLeft); 3892 infoElement.style.paddingLeft);
3886 } 3893 }
3887 // If the public session pod is already expanded, make sure it's 3894 // If the public session pod is already expanded, make sure it's
3888 // still centered. 3895 // still centered.
3889 if (pod.expanded) 3896 if (pod.expanded)
3890 this.centerPod_(pod, PUBLIC_EXPANDED_WIDTH, PUBLIC_EXPANDED_HEIGHT); 3897 this.centerPod_(pod, PUBLIC_EXPANDED_WIDTH, PUBLIC_EXPANDED_HEIGHT);
3891 } 3898 }
3899
3892 // Update action box menu position to ensure it doesn't overlap with 3900 // Update action box menu position to ensure it doesn't overlap with
3893 // elements outside the pod. 3901 // elements outside the pod.
3894 var actionBoxMenu = pod.querySelector('.action-box-menu'); 3902 var actionBoxMenu = pod.querySelector('.action-box-menu');
3895 var actionBoxButton = pod.querySelector('.action-box-button'); 3903 var actionBoxButton = pod.querySelector('.action-box-button');
3896 var MENU_TOP_PADDING = 7; 3904 var MENU_TOP_PADDING = 7;
3897 if (this.isPortraitMode_() && pods.length > 1) { 3905 if (this.isPortraitMode_() && pods.length > 1) {
3898 // Confine the menu inside the pod when it may overlap with outside 3906 // Confine the menu inside the pod when it may overlap with outside
3899 // elements. 3907 // elements.
3900 actionBoxMenu.style.left = 'auto'; 3908 actionBoxMenu.style.left = 'auto';
3901 actionBoxMenu.style.right = cr.ui.toCssPx(0); 3909 actionBoxMenu.style.right = cr.ui.toCssPx(0);
3902 actionBoxMenu.style.top = 3910 actionBoxMenu.style.top =
3903 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING); 3911 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING);
3904 } else if (!this.isPortraitMode_() && this.isScreenShrinked_()) { 3912 } else if (!this.isPortraitMode_() && this.isScreenShrinked_()) {
3905 // Prevent the virtual keyboard from blocking the remove user button. 3913 // Prevent the virtual keyboard from blocking the remove user button.
3906 actionBoxMenu.style.left = cr.ui.toCssPx( 3914 actionBoxMenu.style.left = cr.ui.toCssPx(
3907 pod.nameElement.offsetWidth + actionBoxButton.offsetWidth); 3915 pod.nameElement.offsetWidth + actionBoxButton.offsetWidth);
3908 actionBoxMenu.style.right = 'auto'; 3916 actionBoxMenu.style.right = 'auto';
3909 actionBoxMenu.style.top = cr.ui.toCssPx(0); 3917 actionBoxMenu.style.top = cr.ui.toCssPx(0);
3910 } else { 3918 } else {
3911 actionBoxMenu.style.left = cr.ui.toCssPx( 3919 actionBoxMenu.style.left = cr.ui.toCssPx(
3912 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft); 3920 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3913 actionBoxMenu.style.right = 'auto'; 3921 actionBoxMenu.style.right = 'auto';
3914 actionBoxMenu.style.top = 3922 actionBoxMenu.style.top =
3915 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING); 3923 cr.ui.toCssPx(actionBoxButton.offsetHeight + MENU_TOP_PADDING);
3916 } 3924 }
3925
3917 // Update password container width based on the visibility of the 3926 // Update password container width based on the visibility of the
3918 // custom icon container. 3927 // custom icon container.
3919 pod.querySelector('.password-container') 3928 pod.querySelector('.password-container')
3920 .classList.toggle( 3929 .classList.toggle(
3921 'custom-icon-shown', !pod.customIconElement.hidden); 3930 'custom-icon-shown', !pod.customIconElement.hidden);
3922 // Add ripple animation. 3931 // Add ripple animation.
3923 var actionBoxRippleEffect = 3932 var actionBoxRippleEffect =
3924 pod.querySelector('.action-box-button.ripple-circle'); 3933 pod.querySelector('.action-box-button.ripple-circle');
3925 actionBoxRippleEffect.style.left = cr.ui.toCssPx( 3934 actionBoxRippleEffect.style.left = cr.ui.toCssPx(
3926 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft); 3935 pod.nameElement.offsetWidth + actionBoxButton.style.marginLeft);
3936 actionBoxRippleEffect.style.right = 'auto';
3927 actionBoxRippleEffect.style.top = 3937 actionBoxRippleEffect.style.top =
3928 cr.ui.toCssPx(actionBoxButton.style.marginTop); 3938 cr.ui.toCssPx(actionBoxButton.style.marginTop);
3929 // Adjust the vertical position of the pod if pin keyboard is shown. 3939 // Adjust the vertical position of the pod if pin keyboard is shown.
3930 if (pod.isPinShown() && !this.isScreenShrinked_()) 3940 if (pod.isPinShown() && !this.isScreenShrinked_())
3931 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2; 3941 pod.top = (this.screenSize.height - CROS_POD_HEIGHT_WITH_PIN) / 2;
3942
3943 // In the end, switch direction of the above elements if right-to-left
3944 // language is used.
3945 if (isRTL()) {
3946 this.switchDirection_(nameArea);
3947 this.switchDirection_(actionBoxMenu);
3948 this.switchDirection_(actionBoxRippleEffect);
3949 if (pod.isPublicSessionPod) {
3950 this.switchDirection_(pod.querySelector('.info'));
3951 this.switchDirection_(pod.querySelector('.learn-more'));
3952 }
3953 }
3932 } 3954 }
3933 // Update the position of the sign-in banner if it's shown. 3955 // Update the position of the sign-in banner if it's shown.
3934 if ($('signin-banner').textContent.length != 0) { 3956 if ($('signin-banner').textContent.length != 0) {
3935 var bannerContainer = $('signin-banner-container1'); 3957 var bannerContainer = $('signin-banner-container1');
3936 bannerContainer.style.top = cr.ui.toCssPx(this.mainPod_.top / 2); 3958 bannerContainer.style.top = cr.ui.toCssPx(this.mainPod_.top / 2);
3937 if (this.pods.length <= POD_ROW_LIMIT) { 3959 if (this.pods.length <= POD_ROW_LIMIT) {
3938 bannerContainer.style.left = cr.ui.toCssPx( 3960 bannerContainer.style.left = cr.ui.toCssPx(
3939 (this.screenSize.width - bannerContainer.offsetWidth) / 2); 3961 (this.screenSize.width - bannerContainer.offsetWidth) / 2);
3940 } 3962 }
3941 else { 3963 else {
3942 var leftPadding = this.mainPod_.left - 3964 var leftPadding = this.mainPod_.left -
3943 (bannerContainer.offsetWidth - CROS_POD_WIDTH) / 2; 3965 (bannerContainer.offsetWidth - CROS_POD_WIDTH) / 2;
3944 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0)); 3966 bannerContainer.style.left = cr.ui.toCssPx(Math.max(leftPadding, 0));
3945 } 3967 }
3946 } 3968 }
3947 }, 3969 },
3948 3970
3949 /** 3971 /**
3972 * Helper function for right-to-left languages.
3973 * @param {!HTMLElement} el Element whose style needs to change.
3974 * @private
3975 */
3976 switchDirection_: function(el) {
xiyuan 2017/06/20 19:14:36 nit: Move this out of the class, similar to remove
Wenzhao (Colin) Zang 2017/06/20 20:43:50 Done.
3977 var leftStyle = el.style.left;
3978 el.style.left = el.style.right;
3979 el.style.right = leftStyle;
3980 },
3981
3982 /**
3950 * Handles required UI changes when a public session pod toggles the 3983 * Handles required UI changes when a public session pod toggles the
3951 * expanded state. 3984 * expanded state.
3952 * @param {UserPod} pod Public session pod. 3985 * @param {UserPod} pod Public session pod.
3953 * @param {boolean} expanded Whether the pod is expanded or not. 3986 * @param {boolean} expanded Whether the pod is expanded or not.
3954 */ 3987 */
3955 handlePublicPodExpansion: function(pod, expanded) { 3988 handlePublicPodExpansion: function(pod, expanded) {
3956 // Hide all other elements in the account picker if the pod is expanded. 3989 // Hide all other elements in the account picker if the pod is expanded.
3957 this.parentNode.classList.toggle('public-account-expanded', expanded); 3990 this.parentNode.classList.toggle('public-account-expanded', expanded);
3958 if (expanded) { 3991 if (expanded) {
3959 this.centerPod_(pod, PUBLIC_EXPANDED_WIDTH, PUBLIC_EXPANDED_HEIGHT); 3992 this.centerPod_(pod, PUBLIC_EXPANDED_WIDTH, PUBLIC_EXPANDED_HEIGHT);
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
4601 if (pod && pod.multiProfilesPolicyApplied) { 4634 if (pod && pod.multiProfilesPolicyApplied) {
4602 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 4635 pod.userTypeBubbleElement.classList.remove('bubble-shown');
4603 } 4636 }
4604 } 4637 }
4605 }; 4638 };
4606 4639
4607 return { 4640 return {
4608 PodRow: PodRow 4641 PodRow: PodRow
4609 }; 4642 };
4610 }); 4643 });
OLDNEW
« no previous file with comments | « ui/login/account_picker/md_user_pod_row.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698