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

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

Issue 2931063004: Extract colors from wallpaper and dynamically update login screen overlay (Closed)
Patch Set: Will clean up this CL when crbug.com/733709 is fixed 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_screen_account_picker.js ('k') | ui/login/md_screen_container.css » ('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 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 2827
2828 // Array of users that are shown (public/supervised/regular). 2828 // Array of users that are shown (public/supervised/regular).
2829 users_: [], 2829 users_: [],
2830 2830
2831 // If we're in Touch View mode. 2831 // If we're in Touch View mode.
2832 touchViewEnabled_: false, 2832 touchViewEnabled_: false,
2833 2833
2834 // If testing mode is enabled. 2834 // If testing mode is enabled.
2835 testingModeEnabled_: false, 2835 testingModeEnabled_: false,
2836 2836
2837 overlayColors_: {maskColor: undefined, scrollColor: undefined},
2838
2837 /** @override */ 2839 /** @override */
2838 decorate: function() { 2840 decorate: function() {
2839 // Event listeners that are installed for the time period during which 2841 // Event listeners that are installed for the time period during which
2840 // the element is visible. 2842 // the element is visible.
2841 this.listeners_ = { 2843 this.listeners_ = {
2842 focus: [this.handleFocus_.bind(this), true /* useCapture */], 2844 focus: [this.handleFocus_.bind(this), true /* useCapture */],
2843 click: [this.handleClick_.bind(this), true], 2845 click: [this.handleClick_.bind(this), true],
2844 mousemove: [this.handleMouseMove_.bind(this), false], 2846 mousemove: [this.handleMouseMove_.bind(this), false],
2845 keydown: [this.handleKeyDown.bind(this), false] 2847 keydown: [this.handleKeyDown.bind(this), false]
2846 }; 2848 };
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
3126 rebuildPods: function() { 3128 rebuildPods: function() {
3127 var emptyPodRow = this.pods.length == 0; 3129 var emptyPodRow = this.pods.length == 0;
3128 3130
3129 // Clear existing pods. 3131 // Clear existing pods.
3130 this.innerHTML = ''; 3132 this.innerHTML = '';
3131 this.focusedPod_ = undefined; 3133 this.focusedPod_ = undefined;
3132 this.activatedPod_ = undefined; 3134 this.activatedPod_ = undefined;
3133 this.lastFocusedPod_ = undefined; 3135 this.lastFocusedPod_ = undefined;
3134 this.mainPod_ = undefined; 3136 this.mainPod_ = undefined;
3135 this.smallPodsContainer.innerHTML = ''; 3137 this.smallPodsContainer.innerHTML = '';
3138 this.topMask.innerHTML = '';
3139 this.bottomMask.innerHTML = '';
3136 3140
3137 // Switch off animation 3141 // Switch off animation
3138 Oobe.getInstance().toggleClass('flying-pods', false); 3142 Oobe.getInstance().toggleClass('flying-pods', false);
3139 3143
3140 for (var i = 0; i < this.users_.length; ++i) 3144 for (var i = 0; i < this.users_.length; ++i)
3141 this.addUserPod(this.users_[i]); 3145 this.addUserPod(this.users_[i]);
3142 3146
3143 for (var i = 0, pod; pod = this.pods[i]; ++i) 3147 for (var i = 0, pod; pod = this.pods[i]; ++i)
3144 this.podsWithPendingImages_.push(pod); 3148 this.podsWithPendingImages_.push(pod);
3145 3149
3146 // TODO(nkostylev): Edge case handling when kiosk apps are not fitting. 3150 // TODO(nkostylev): Edge case handling when kiosk apps are not fitting.
3147 if (this.shouldShowApps_) { 3151 if (this.shouldShowApps_) {
3148 for (var i = 0; i < this.apps_.length; ++i) 3152 for (var i = 0; i < this.apps_.length; ++i)
3149 this.addUserPod(this.apps_[i]); 3153 this.addUserPod(this.apps_[i]);
3150 } 3154 }
3151 3155
3152 // Make sure we eventually show the pod row, even if some image is stuck. 3156 // Make sure we eventually show the pod row, even if some image is stuck.
3153 setTimeout(function() { 3157 setTimeout(function() {
3154 $('pod-row').classList.remove('images-loading'); 3158 $('pod-row').classList.remove('images-loading');
3159 this.smallPodsContainer.classList.remove('images-loading');
3160 this.topMask.classList.remove('images-loading');
3161 this.bottomMask.classList.remove('images-loading');
3155 }, POD_ROW_IMAGES_LOAD_TIMEOUT_MS); 3162 }, POD_ROW_IMAGES_LOAD_TIMEOUT_MS);
3156 3163
3157 var isAccountPicker = $('login-header-bar').signinUIState == 3164 var isAccountPicker = $('login-header-bar').signinUIState ==
3158 SIGNIN_UI_STATE.ACCOUNT_PICKER; 3165 SIGNIN_UI_STATE.ACCOUNT_PICKER;
3159 3166
3160 // Immediately recalculate pods layout only when current UI is account 3167 // Immediately recalculate pods layout only when current UI is account
3161 // picker. Otherwise postpone it. 3168 // picker. Otherwise postpone it.
3162 if (isAccountPicker) { 3169 if (isAccountPicker) {
3163 this.placePods_(); 3170 this.placePods_();
3164 this.maybePreselectPod(); 3171 this.maybePreselectPod();
(...skipping 18 matching lines...) Expand all
3183 3190
3184 /** 3191 /**
3185 * Gets the container of small pods. 3192 * Gets the container of small pods.
3186 * @type {!HTMLDivElement} 3193 * @type {!HTMLDivElement}
3187 */ 3194 */
3188 get smallPodsContainer() { 3195 get smallPodsContainer() {
3189 return document.querySelector('.small-pod-container'); 3196 return document.querySelector('.small-pod-container');
3190 }, 3197 },
3191 3198
3192 /** 3199 /**
3200 * Gets the gradient mask at the top.
3201 * @type {!HTMLDivElement}
3202 */
3203 get topMask() {
3204 return document.querySelector('.small-pod-container-mask');
3205 },
3206
3207 /**
3208 * Gets the gradient mask at the bottom.
3209 * @type {!HTMLDivElement}
3210 */
3211 get bottomMask() {
3212 return document.querySelector('.small-pod-container-mask.rotate');
3213 },
3214
3215 /**
3193 * Adds given apps to the pod row. 3216 * Adds given apps to the pod row.
3194 * @param {array} apps Array of apps. 3217 * @param {array} apps Array of apps.
3195 */ 3218 */
3196 setApps: function(apps) { 3219 setApps: function(apps) {
3197 this.apps_ = apps; 3220 this.apps_ = apps;
3198 this.rebuildPods(); 3221 this.rebuildPods();
3199 chrome.send('kioskAppsLoaded'); 3222 chrome.send('kioskAppsLoaded');
3200 3223
3201 // Check whether there's a pending kiosk app error. 3224 // Check whether there's a pending kiosk app error.
3202 window.setTimeout(function() { 3225 window.setTimeout(function() {
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
3693 3716
3694 /** 3717 /**
3695 * Called when the LANDSCAPE_MODE_LIMIT or PORTRAIT_MODE_LIMIT is exceeded 3718 * Called when the LANDSCAPE_MODE_LIMIT or PORTRAIT_MODE_LIMIT is exceeded
3696 * and the scrollable container is shown. 3719 * and the scrollable container is shown.
3697 * @private 3720 * @private
3698 */ 3721 */
3699 placePodsOnScrollableContainer_: function() { 3722 placePodsOnScrollableContainer_: function() {
3700 this.smallPodsContainer.hidden = false; 3723 this.smallPodsContainer.hidden = false;
3701 // Add a dark overlay. 3724 // Add a dark overlay.
3702 this.smallPodsContainer.classList.add('scroll'); 3725 this.smallPodsContainer.classList.add('scroll');
3726 if (this.overlayColors_.scrollColor) {
3727 this.smallPodsContainer.style.backgroundColor =
3728 this.overlayColors_.scrollColor;
3729 }
3703 var pods = this.pods; 3730 var pods = this.pods;
3704 this.mainPod_.setPodStyle(UserPod.Style.LARGE); 3731 this.mainPod_.setPodStyle(UserPod.Style.LARGE);
3705 for (var pod of pods) { 3732 for (var pod of pods) {
3706 if (pod != this.mainPod_) { 3733 if (pod != this.mainPod_) {
3707 // All pods except the main one must be set to the extra small style. 3734 // All pods except the main one must be set to the extra small style.
3708 pod.setPodStyle(UserPod.Style.EXTRA_SMALL); 3735 pod.setPodStyle(UserPod.Style.EXTRA_SMALL);
3709 } 3736 }
3710 } 3737 }
3711 3738
3712 var SCROLL_LEFT_PADDING = this.isPortraitMode_() ? 46 : 72; 3739 var SCROLL_LEFT_PADDING = this.isPortraitMode_() ? 46 : 72;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3781 3808
3782 /** 3809 /**
3783 * Called each time before pod placement to ensure we start with the 3810 * Called each time before pod placement to ensure we start with the
3784 * initial state, which is ready to place only one user pod. The styles 3811 * initial state, which is ready to place only one user pod. The styles
3785 * of elements necessary for other placement methods must be set 3812 * of elements necessary for other placement methods must be set
3786 * explicitly each time. 3813 * explicitly each time.
3787 * @private 3814 * @private
3788 */ 3815 */
3789 handleBeforePodPlacement_: function() { 3816 handleBeforePodPlacement_: function() {
3790 this.smallPodsContainer.hidden = true; 3817 this.smallPodsContainer.hidden = true;
3791 document.querySelector('.small-pod-container-mask').hidden = true; 3818 this.topMask.hidden = true;
3792 document.querySelector('.small-pod-container-mask.rotate').hidden = true; 3819 this.bottomMask.hidden = true;
3793 this.smallPodsContainer.classList.remove('scroll'); 3820 this.smallPodsContainer.classList.remove('scroll');
3821 if (this.overlayColors_.scrollColor)
3822 this.smallPodsContainer.style.backgroundColor = 'unset';
3794 var pods = this.pods; 3823 var pods = this.pods;
3795 for (var pod of pods) { 3824 for (var pod of pods) {
3796 // There is a chance that one of the pods has a bottom padding, so 3825 // There is a chance that one of the pods has a bottom padding, so
3797 // reset all of them to be safe. This is because if the pod was at 3826 // reset all of them to be safe. This is because if the pod was at
3798 // the last position in the scrollable container, a bottom padding 3827 // the last position in the scrollable container, a bottom padding
3799 // was added to ensure a symmetric layout. 3828 // was added to ensure a symmetric layout.
3800 pod.style.paddingBottom = cr.ui.toCssPx(0); 3829 pod.style.paddingBottom = cr.ui.toCssPx(0);
3801 } 3830 }
3802 this.clearPodsAnimation_(); 3831 this.clearPodsAnimation_();
3803 this.hideEmptyArea_(); 3832 this.hideEmptyArea_();
(...skipping 20 matching lines...) Expand all
3824 */ 3853 */
3825 isScreenShrinked_: function() { 3854 isScreenShrinked_: function() {
3826 return this.screenSize.height <= Oobe.getInstance().clientAreaSize.height; 3855 return this.screenSize.height <= Oobe.getInstance().clientAreaSize.height;
3827 }, 3856 },
3828 3857
3829 /** 3858 /**
3830 * Called when scroll bar is shown and we need a mask for the header bar. 3859 * Called when scroll bar is shown and we need a mask for the header bar.
3831 * @private 3860 * @private
3832 */ 3861 */
3833 showScrollMask_: function() { 3862 showScrollMask_: function() {
3834 var topMask = document.querySelector('.small-pod-container-mask'); 3863 this.topMask.hidden = false;
3835 topMask.hidden = false; 3864 this.topMask.style.left = this.smallPodsContainer.style.left;
3836 topMask.style.left = this.smallPodsContainer.style.left; 3865 this.topMask.style.width = this.smallPodsContainer.style.width;
3837 topMask.style.width = this.smallPodsContainer.style.width; 3866 this.bottomMask.hidden = false;
3838 // The bottom mask is a rotation of the top mask. 3867 this.bottomMask.style.left = this.smallPodsContainer.style.left;
3839 var bottomMask = 3868 this.bottomMask.style.width = this.smallPodsContainer.style.width;
3840 document.querySelector('.small-pod-container-mask.rotate');
3841 bottomMask.hidden = false;
3842 bottomMask.style.left = this.smallPodsContainer.style.left;
3843 bottomMask.style.width = this.smallPodsContainer.style.width;
3844 // The bottom mask should overlap with the header bar, and its z-index 3869 // The bottom mask should overlap with the header bar, and its z-index
3845 // is chosen to ensure it does not block users from using the header bar. 3870 // is chosen to ensure it does not block users from using the header bar.
3846 bottomMask.style.top = 3871 this.bottomMask.style.top =
3847 cr.ui.toCssPx(this.screenSize.height - SCROLL_MASK_HEIGHT); 3872 cr.ui.toCssPx(this.screenSize.height - SCROLL_MASK_HEIGHT);
3873 if (this.overlayColors_.maskColor) {
3874 var maskGradient = this.getMaskGradient_(this.overlayColors_.maskColor);
3875 this.topMask.style.background = maskGradient;
3876 this.bottomMask.style.background = maskGradient;
3877 }
3848 }, 3878 },
3849 3879
3850 /** 3880 /**
3851 * Called after pod placement and before showing the pod row. Updates 3881 * Called after pod placement and before showing the pod row. Updates
3852 * elements whose style may depend on the pod placement outcome. 3882 * elements whose style may depend on the pod placement outcome.
3853 * @private 3883 * @private
3854 */ 3884 */
3855 handleAfterPodPlacement_: function() { 3885 handleAfterPodPlacement_: function() {
3856 var pods = this.pods; 3886 var pods = this.pods;
3857 for (var pod of pods) { 3887 for (var pod of pods) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
4077 * @param {string} message Text to be displayed or empty to hide the banner. 4107 * @param {string} message Text to be displayed or empty to hide the banner.
4078 */ 4108 */
4079 showBannerMessage: function(message) { 4109 showBannerMessage: function(message) {
4080 var banner = $('signin-banner'); 4110 var banner = $('signin-banner');
4081 banner.textContent = message; 4111 banner.textContent = message;
4082 banner.classList.toggle('message-set', !!message); 4112 banner.classList.toggle('message-set', !!message);
4083 $('signin-banner-container1').hidden = banner.textContent.length == 0; 4113 $('signin-banner-container1').hidden = banner.textContent.length == 0;
4084 }, 4114 },
4085 4115
4086 /** 4116 /**
4117 * Sets login screen overlay colors based on colors extracted from the
4118 * wallpaper.
4119 * @param {string} maskColor Color for the gradient mask.
4120 * @param {string} scrollColor Color for the small pods container.
4121 * @param {string} backgroundColor Color for the whole background.
4122 */
4123 setOverlayColors: function(maskColor, scrollColor, backgroundColor) {
4124 $('login-shield').style.backgroundColor = backgroundColor;
4125 if (this.smallPodsContainer.classList.contains('scroll'))
4126 this.smallPodsContainer.style.backgroundColor = scrollColor;
4127 if (!this.topMask.hidden) {
4128 var maskGradient = this.getMaskGradient_(maskColor);
4129 this.topMask.style.background = maskGradient;
4130 this.bottomMask.style.background = maskGradient;
4131 }
4132 // Save the colors because the scrollable container and the masks may
4133 // become visible later.
4134 this.overlayColors_.maskColor = maskColor;
4135 this.overlayColors_.scrollColor = scrollColor;
4136 },
4137
4138 /**
4139 * Helper function to create a style string for the scroll masks.
4140 * @param {string} maskColor Color for the gradient mask.
4141 * @return {string} A CSS style.
4142 */
4143 getMaskGradient_: function(maskColor) {
4144 return 'linear-gradient(' + maskColor + ', transparent)';
4145 },
4146
4147 /**
4087 * Whether the pod is currently focused. 4148 * Whether the pod is currently focused.
4088 * @param {UserPod} pod Pod to check for focus. 4149 * @param {UserPod} pod Pod to check for focus.
4089 * @return {boolean} Pod focus status. 4150 * @return {boolean} Pod focus status.
4090 */ 4151 */
4091 isFocused: function(pod) { 4152 isFocused: function(pod) {
4092 return this.focusedPod_ == pod; 4153 return this.focusedPod_ == pod;
4093 }, 4154 },
4094 4155
4095 /** 4156 /**
4096 * Focuses a given user pod or clear focus when given null. 4157 * Focuses a given user pod or clear focus when given null.
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
4579 */ 4640 */
4580 handlePodImageLoad: function(pod) { 4641 handlePodImageLoad: function(pod) {
4581 var index = this.podsWithPendingImages_.indexOf(pod); 4642 var index = this.podsWithPendingImages_.indexOf(pod);
4582 if (index == -1) { 4643 if (index == -1) {
4583 return; 4644 return;
4584 } 4645 }
4585 4646
4586 this.podsWithPendingImages_.splice(index, 1); 4647 this.podsWithPendingImages_.splice(index, 1);
4587 if (this.podsWithPendingImages_.length == 0) { 4648 if (this.podsWithPendingImages_.length == 0) {
4588 this.classList.remove('images-loading'); 4649 this.classList.remove('images-loading');
4650 this.smallPodsContainer.classList.remove('images-loading');
4651 this.topMask.classList.remove('images-loading');
4652 this.bottomMask.classList.remove('images-loading');
4589 } 4653 }
4590 }, 4654 },
4591 4655
4592 /** 4656 /**
4593 * Preselects pod, if needed. 4657 * Preselects pod, if needed.
4594 */ 4658 */
4595 maybePreselectPod: function() { 4659 maybePreselectPod: function() {
4596 var pod = this.preselectedPod; 4660 var pod = this.preselectedPod;
4597 this.focusPod(pod); 4661 this.focusPod(pod);
4598 4662
4599 // Hide user-type-bubble in case all user pods are disabled and we focus 4663 // Hide user-type-bubble in case all user pods are disabled and we focus
4600 // first pod. 4664 // first pod.
4601 if (pod && pod.multiProfilesPolicyApplied) { 4665 if (pod && pod.multiProfilesPolicyApplied) {
4602 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 4666 pod.userTypeBubbleElement.classList.remove('bubble-shown');
4603 } 4667 }
4604 } 4668 }
4605 }; 4669 };
4606 4670
4607 return { 4671 return {
4608 PodRow: PodRow 4672 PodRow: PodRow
4609 }; 4673 };
4610 }); 4674 });
OLDNEW
« no previous file with comments | « ui/login/account_picker/md_screen_account_picker.js ('k') | ui/login/md_screen_container.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698