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

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

Issue 2956873002: Don't hide profile statistics counters with zero results (Closed)
Patch Set: always remove 'has-no-stats' when stats are loaded Created 3 years, 5 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 | « no previous file | ui/login/account_picker/user_pod_row.js » ('j') | 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 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 for (var key in stats_elements) { 1834 for (var key in stats_elements) {
1835 if (this.user.statistics[key].success) { 1835 if (this.user.statistics[key].success) {
1836 var count = this.user.statistics[key].count; 1836 var count = this.user.statistics[key].count;
1837 stats_elements[key].textContent = count; 1837 stats_elements[key].textContent = count;
1838 total_count += count; 1838 total_count += count;
1839 num_stats_loaded++; 1839 num_stats_loaded++;
1840 } 1840 }
1841 } 1841 }
1842 1842
1843 // this.classList is used for selecting the appropriate dialog. 1843 // this.classList is used for selecting the appropriate dialog.
1844 if (total_count) 1844 this.classList.remove('has-no-stats');
1845 this.classList.remove('has-no-stats');
1846 1845
1847 var is_synced_user = this.user.emailAddress !== ""; 1846 var is_synced_user = this.user.emailAddress !== "";
1848 // Write total number if all statistics are loaded. 1847 // Write total number if all statistics are loaded.
1849 if (num_stats_loaded === Object.keys(stats_elements).length) { 1848 if (num_stats_loaded === Object.keys(stats_elements).length) {
1850 if (!total_count) { 1849 if (!total_count) {
1851 this.classList.add('has-no-stats');
1852 var message = loadTimeData.getString( 1850 var message = loadTimeData.getString(
1853 is_synced_user ? 'removeUserWarningTextSyncNoStats' : 1851 is_synced_user ? 'removeUserWarningTextSyncNoStats' :
1854 'removeUserWarningTextNonSyncNoStats'); 1852 'removeUserWarningTextNonSyncNoStats');
1855 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath, 1853 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath,
1856 message); 1854 message);
1857 } else { 1855 } else {
1858 window.updateRemoveWarningDialogSetMessage = 1856 window.updateRemoveWarningDialogSetMessage =
1859 this.updateRemoveWarningDialogSetMessage_.bind(this); 1857 this.updateRemoveWarningDialogSetMessage_.bind(this);
1860 chrome.send('getRemoveWarningDialogMessage',[{ 1858 chrome.send('getRemoveWarningDialogMessage',[{
1861 profilePath: this.user.profilePath, 1859 profilePath: this.user.profilePath,
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
2621 2619
2622 var isLockedUser = this.user.needsSignin; 2620 var isLockedUser = this.user.needsSignin;
2623 var isLegacySupervisedUser = this.user.legacySupervisedUser; 2621 var isLegacySupervisedUser = this.user.legacySupervisedUser;
2624 var isChildUser = this.user.childUser; 2622 var isChildUser = this.user.childUser;
2625 var isSyncedUser = this.user.emailAddress !== ""; 2623 var isSyncedUser = this.user.emailAddress !== "";
2626 var isProfileLoaded = this.user.isProfileLoaded; 2624 var isProfileLoaded = this.user.isProfileLoaded;
2627 this.classList.toggle('locked', isLockedUser); 2625 this.classList.toggle('locked', isLockedUser);
2628 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); 2626 this.classList.toggle('legacy-supervised', isLegacySupervisedUser);
2629 this.classList.toggle('child', isChildUser); 2627 this.classList.toggle('child', isChildUser);
2630 this.classList.toggle('synced', isSyncedUser); 2628 this.classList.toggle('synced', isSyncedUser);
2631 this.classList.toggle('has-no-stats', 2629 this.classList.toggle('has-no-stats',
xiyuan 2017/06/27 17:33:33 Should we remove this too ?
dullweber 2017/06/28 09:39:44 yes, we can probably remove has-no-stats completel
2632 !isProfileLoaded && !this.user.statistics.length); 2630 !isProfileLoaded && !this.user.statistics.length);
2633 2631
2634 if (this.isAuthTypeUserClick) 2632 if (this.isAuthTypeUserClick)
2635 this.passwordLabelElement.textContent = this.authValue; 2633 this.passwordLabelElement.textContent = this.authValue;
2636 2634
2637 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( 2635 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF(
2638 'passwordFieldAccessibleName', this.user_.emailAddress)); 2636 'passwordFieldAccessibleName', this.user_.emailAddress));
2639 2637
2640 UserPod.prototype.updateActionBoxArea.call(this); 2638 UserPod.prototype.updateActionBoxArea.call(this);
2641 }, 2639 },
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
3567 for (var pod of pods) { 3565 for (var pod of pods) {
3568 pod.parentNode.removeChild(pod); 3566 pod.parentNode.removeChild(pod);
3569 } 3567 }
3570 if (pods.length <= POD_ROW_LIMIT) { 3568 if (pods.length <= POD_ROW_LIMIT) {
3571 for (var pod of pods) { 3569 for (var pod of pods) {
3572 this.appendChild(pod); 3570 this.appendChild(pod);
3573 } 3571 }
3574 } else { 3572 } else {
3575 // When the user count exceeds the limit (currently set to 2), only the 3573 // When the user count exceeds the limit (currently set to 2), only the
3576 // main pod still has pow row as parent, all other pods should be 3574 // main pod still has pow row as parent, all other pods should be
3577 // appended to the container with scroll bar. 3575 // appended to the container with scroll bar.
3578 for (var pod of pods) { 3576 for (var pod of pods) {
3579 if (pod == this.mainPod_) 3577 if (pod == this.mainPod_)
3580 this.appendChild(pod); 3578 this.appendChild(pod);
3581 else 3579 else
3582 this.smallPodsContainer.appendChild(pod); 3580 this.smallPodsContainer.appendChild(pod);
3583 } 3581 }
3584 } 3582 }
3585 }, 3583 },
3586 3584
3587 /** 3585 /**
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3665 } 3663 }
3666 // The size of the smallPodsContainer must be updated to avoid overflow. 3664 // The size of the smallPodsContainer must be updated to avoid overflow.
3667 this.smallPodsContainer.style.height = 3665 this.smallPodsContainer.style.height =
3668 cr.ui.toCssPx(this.screenSize.height); 3666 cr.ui.toCssPx(this.screenSize.height);
3669 this.smallPodsContainer.style.width = cr.ui.toCssPx(CROS_SMALL_POD_WIDTH); 3667 this.smallPodsContainer.style.width = cr.ui.toCssPx(CROS_SMALL_POD_WIDTH);
3670 3668
3671 var LEFT_PADDING = this.isPortraitMode_() ? 0 : 98; 3669 var LEFT_PADDING = this.isPortraitMode_() ? 0 : 98;
3672 var MIDDLE_PADDING = this.isPortraitMode_() ? 84 : 220; 3670 var MIDDLE_PADDING = this.isPortraitMode_() ? 84 : 220;
3673 var contentsWidth = LEFT_PADDING + 3671 var contentsWidth = LEFT_PADDING +
3674 CROS_POD_WIDTH + MIDDLE_PADDING + CROS_SMALL_POD_WIDTH; 3672 CROS_POD_WIDTH + MIDDLE_PADDING + CROS_SMALL_POD_WIDTH;
3675 var blankWidth = this.screenSize.width - contentsWidth; 3673 var blankWidth = this.screenSize.width - contentsWidth;
3676 var actualLeftPadding = LEFT_PADDING; 3674 var actualLeftPadding = LEFT_PADDING;
3677 actualLeftPadding += 3675 actualLeftPadding +=
3678 this.isPortraitMode_() ? blankWidth * 2 / 3 : blankWidth / 2; 3676 this.isPortraitMode_() ? blankWidth * 2 / 3 : blankWidth / 2;
3679 var SMALL_POD_PADDING = 54; 3677 var SMALL_POD_PADDING = 54;
3680 var actualSmallPodPadding = SMALL_POD_PADDING; 3678 var actualSmallPodPadding = SMALL_POD_PADDING;
3681 var smallPodsTotalHeight = (pods.length - 1) * CROS_SMALL_POD_HEIGHT + 3679 var smallPodsTotalHeight = (pods.length - 1) * CROS_SMALL_POD_HEIGHT +
3682 (pods.length - 2) * actualSmallPodPadding; 3680 (pods.length - 2) * actualSmallPodPadding;
3683 3681
3684 var SCROLL_TOP_PADDING = this.isPortraitMode_() ? 66 : 72; 3682 var SCROLL_TOP_PADDING = this.isPortraitMode_() ? 66 : 72;
3685 if (smallPodsTotalHeight + SCROLL_TOP_PADDING * 2 > 3683 if (smallPodsTotalHeight + SCROLL_TOP_PADDING * 2 >
(...skipping 11 matching lines...) Expand all
3697 (pods.length - 2) * actualSmallPodPadding; 3695 (pods.length - 2) * actualSmallPodPadding;
3698 } 3696 }
3699 // If virtual keyboard is not shown, or the updated total height still 3697 // If virtual keyboard is not shown, or the updated total height still
3700 // exceeds screen height, fall to the scrollable container case. 3698 // exceeds screen height, fall to the scrollable container case.
3701 if (smallPodsTotalHeight + SCROLL_TOP_PADDING * 2 > 3699 if (smallPodsTotalHeight + SCROLL_TOP_PADDING * 2 >
3702 this.screenSize.height) { 3700 this.screenSize.height) {
3703 this.placePodsOnScrollableContainer_(); 3701 this.placePodsOnScrollableContainer_();
3704 return; 3702 return;
3705 } 3703 }
3706 } 3704 }
3707 3705
3708 // Start positioning of the main pod and the smallPodsContainer. 3706 // Start positioning of the main pod and the smallPodsContainer.
3709 this.mainPod_.left = actualLeftPadding; 3707 this.mainPod_.left = actualLeftPadding;
3710 this.mainPod_.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2; 3708 this.mainPod_.top = (this.screenSize.height - CROS_POD_HEIGHT) / 2;
3711 this.smallPodsContainer.style.left = 3709 this.smallPodsContainer.style.left =
3712 cr.ui.toCssPx(actualLeftPadding + CROS_POD_WIDTH + MIDDLE_PADDING); 3710 cr.ui.toCssPx(actualLeftPadding + CROS_POD_WIDTH + MIDDLE_PADDING);
3713 this.smallPodsContainer.style.top = cr.ui.toCssPx(0); 3711 this.smallPodsContainer.style.top = cr.ui.toCssPx(0);
3714 // Start positioning of the small pods inside the smallPodsContainer. 3712 // Start positioning of the small pods inside the smallPodsContainer.
3715 var smallPodsTopPadding = 3713 var smallPodsTopPadding =
3716 (this.screenSize.height - smallPodsTotalHeight) / 2; 3714 (this.screenSize.height - smallPodsTotalHeight) / 2;
3717 for (var pod of pods) { 3715 for (var pod of pods) {
3718 if (pod == this.mainPod_) { 3716 if (pod == this.mainPod_) {
3719 continue; 3717 continue;
3720 } 3718 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3773 } 3771 }
3774 scrollHeight -= EXTRA_SMALL_POD_PADDING; 3772 scrollHeight -= EXTRA_SMALL_POD_PADDING;
3775 // The smallPodsContainer should occupy the full screen vertically. 3773 // The smallPodsContainer should occupy the full screen vertically.
3776 this.smallPodsContainer.style.height = 3774 this.smallPodsContainer.style.height =
3777 cr.ui.toCssPx(this.screenSize.height); 3775 cr.ui.toCssPx(this.screenSize.height);
3778 this.smallPodsContainer.style.width = cr.ui.toCssPx( 3776 this.smallPodsContainer.style.width = cr.ui.toCssPx(
3779 SCROLL_LEFT_PADDING + CROS_EXTRA_SMALL_POD_WIDTH + 3777 SCROLL_LEFT_PADDING + CROS_EXTRA_SMALL_POD_WIDTH +
3780 SCROLL_RIGHT_PADDING); 3778 SCROLL_RIGHT_PADDING);
3781 3779
3782 // SCROLL_TOP_PADDING denotes the smallest top padding we can tolerate 3780 // SCROLL_TOP_PADDING denotes the smallest top padding we can tolerate
3783 // before allowing the container to overflow and show the scroll bar. 3781 // before allowing the container to overflow and show the scroll bar.
3784 var actualTopPadding = SCROLL_TOP_PADDING; 3782 var actualTopPadding = SCROLL_TOP_PADDING;
3785 if ((this.screenSize.height - scrollHeight) / 2 > actualTopPadding) { 3783 if ((this.screenSize.height - scrollHeight) / 2 > actualTopPadding) {
3786 // Edge case: the total height of the scrollable container does not 3784 // Edge case: the total height of the scrollable container does not
3787 // exceed the screen height (minus the neceesary padding), so the 3785 // exceed the screen height (minus the neceesary padding), so the
3788 // scroll bar will not appear. 3786 // scroll bar will not appear.
3789 // In this case, we still want to keep the extra small pod size and 3787 // In this case, we still want to keep the extra small pod size and
3790 // the overlay, but the top and bottom padding should be adjusted 3788 // the overlay, but the top and bottom padding should be adjusted
3791 // to ensure a symmetric layout. 3789 // to ensure a symmetric layout.
3792 actualTopPadding = (this.screenSize.height - scrollHeight) / 2; 3790 actualTopPadding = (this.screenSize.height - scrollHeight) / 2;
3793 } else if (!this.isScreenShrinked_()) { 3791 } else if (!this.isScreenShrinked_()) {
3794 // The scroll bar will definitely be shown if we reach here. A gradient 3792 // The scroll bar will definitely be shown if we reach here. A gradient
3795 // mask is applied to avoid blocking the header bar if the virtual 3793 // mask is applied to avoid blocking the header bar if the virtual
3796 // keyboard is not shown. When the keyboard is shown, there's no need 3794 // keyboard is not shown. When the keyboard is shown, there's no need
3797 // to add the mask and the original top padding value should be kept. 3795 // to add the mask and the original top padding value should be kept.
3798 actualTopPadding = SCROLL_MASK_HEIGHT; 3796 actualTopPadding = SCROLL_MASK_HEIGHT;
3799 this.showScrollMask_(); 3797 this.showScrollMask_();
3800 } 3798 }
3801 3799
3802 // Start positioning of the small pods inside the smallPodsContainer. 3800 // Start positioning of the small pods inside the smallPodsContainer.
3803 var topPadding = actualTopPadding; 3801 var topPadding = actualTopPadding;
3804 var lastPod = undefined; 3802 var lastPod = undefined;
3805 for (var pod of pods) { 3803 for (var pod of pods) {
3806 if (pod == this.mainPod_) { 3804 if (pod == this.mainPod_) {
3807 continue; 3805 continue;
3808 } 3806 }
3809 pod.left = SCROLL_LEFT_PADDING; 3807 pod.left = SCROLL_LEFT_PADDING;
3810 pod.top = topPadding; 3808 pod.top = topPadding;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
4091 // Add switch animation. 4089 // Add switch animation.
4092 this.mainPod_.smallPodImageElement.classList.add( 4090 this.mainPod_.smallPodImageElement.classList.add(
4093 'switch-image-animation'); 4091 'switch-image-animation');
4094 pod.imageElement.classList.add('switch-image-animation'); 4092 pod.imageElement.classList.add('switch-image-animation');
4095 4093
4096 // Switch parent and position of the two pods. 4094 // Switch parent and position of the two pods.
4097 var left = pod.left; 4095 var left = pod.left;
4098 var top = pod.top; 4096 var top = pod.top;
4099 // Edge case: paddingBottom should be switched too because there's a 4097 // Edge case: paddingBottom should be switched too because there's a
4100 // chance that the small pod was at the end of the scrollable container 4098 // chance that the small pod was at the end of the scrollable container
4101 // and had a non-zero paddingBottom. 4099 // and had a non-zero paddingBottom.
4102 var paddingBottom = pod.style.paddingBottom; 4100 var paddingBottom = pod.style.paddingBottom;
4103 var parent = pod.parentNode; 4101 var parent = pod.parentNode;
4104 parent.removeChild(pod); 4102 parent.removeChild(pod);
4105 this.appendChild(pod); 4103 this.appendChild(pod);
4106 pod.left = this.mainPod_.left; 4104 pod.left = this.mainPod_.left;
4107 pod.top = this.mainPod_.top; 4105 pod.top = this.mainPod_.top;
4108 pod.style.paddingBottom = cr.ui.toCssPx(0); 4106 pod.style.paddingBottom = cr.ui.toCssPx(0);
4109 4107
4110 this.removeChild(this.mainPod_); 4108 this.removeChild(this.mainPod_);
4111 // It must have the same index with the original small pod, instead 4109 // It must have the same index with the original small pod, instead
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
4697 if (pod && pod.multiProfilesPolicyApplied) { 4695 if (pod && pod.multiProfilesPolicyApplied) {
4698 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 4696 pod.userTypeBubbleElement.classList.remove('bubble-shown');
4699 } 4697 }
4700 } 4698 }
4701 }; 4699 };
4702 4700
4703 return { 4701 return {
4704 PodRow: PodRow 4702 PodRow: PodRow
4705 }; 4703 };
4706 }); 4704 });
OLDNEW
« no previous file with comments | « no previous file | ui/login/account_picker/user_pod_row.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698