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

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

Issue 2129253002: Multi-pod support for lock screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 4 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
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 var DESKTOP_POD_WIDTH = 180; 52 var DESKTOP_POD_WIDTH = 180;
53 var MD_DESKTOP_POD_WIDTH = 160; 53 var MD_DESKTOP_POD_WIDTH = 160;
54 var PUBLIC_EXPANDED_BASIC_WIDTH = 500; 54 var PUBLIC_EXPANDED_BASIC_WIDTH = 500;
55 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610; 55 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610;
56 var CROS_POD_HEIGHT = 213; 56 var CROS_POD_HEIGHT = 213;
57 var DESKTOP_POD_HEIGHT = 226; 57 var DESKTOP_POD_HEIGHT = 226;
58 var MD_DESKTOP_POD_HEIGHT = 200; 58 var MD_DESKTOP_POD_HEIGHT = 200;
59 var POD_ROW_PADDING = 10; 59 var POD_ROW_PADDING = 10;
60 var DESKTOP_ROW_PADDING = 32; 60 var DESKTOP_ROW_PADDING = 32;
61 var CUSTOM_ICON_CONTAINER_SIZE = 40; 61 var CUSTOM_ICON_CONTAINER_SIZE = 40;
62 var PIN_EXTRA_WIDTH = 90;
62 63
63 /** 64 /**
64 * Minimal padding between user pod and virtual keyboard. 65 * Minimal padding between user pod and virtual keyboard.
65 * @type {number} 66 * @type {number}
66 * @const 67 * @const
67 */ 68 */
68 var USER_POD_KEYBOARD_MIN_PADDING = 20; 69 var USER_POD_KEYBOARD_MIN_PADDING = 20;
69 70
70 /** 71 /**
71 * Maximum time for which the pod row remains hidden until all user images 72 * Maximum time for which the pod row remains hidden until all user images
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 __proto__: HTMLDivElement.prototype, 696 __proto__: HTMLDivElement.prototype,
696 697
697 /** 698 /**
698 * Whether click on the pod can issue a user click auth attempt. The 699 * Whether click on the pod can issue a user click auth attempt. The
699 * attempt can be issued iff the pod was focused when the click 700 * attempt can be issued iff the pod was focused when the click
700 * started (i.e. on mouse down event). 701 * started (i.e. on mouse down event).
701 * @type {boolean} 702 * @type {boolean}
702 * @private 703 * @private
703 */ 704 */
704 userClickAuthAllowed_: false, 705 userClickAuthAllowed_: false,
706 pinKeyboardShown_: false,
jdufault 2016/07/12 00:22:25 Make this a getter and do a DOM query based on if
sammiequon 2016/07/12 19:35:56 Done.
705 707
706 /** @override */ 708 /** @override */
707 decorate: function() { 709 decorate: function() {
708 this.tabIndex = UserPodTabOrder.POD_INPUT; 710 this.tabIndex = UserPodTabOrder.POD_INPUT;
709 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; 711 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT;
710 712
711 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); 713 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this));
712 this.addEventListener('click', this.handleClickOnPod_.bind(this)); 714 this.addEventListener('click', this.handleClickOnPod_.bind(this));
713 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); 715 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this));
714 716
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 854
853 /** 855 /**
854 * Gets name element. 856 * Gets name element.
855 * @type {!HTMLDivElement} 857 * @type {!HTMLDivElement}
856 */ 858 */
857 get nameElement() { 859 get nameElement() {
858 return this.querySelector('.name'); 860 return this.querySelector('.name');
859 }, 861 },
860 862
861 /** 863 /**
864 * Gets name element.
865 * @type {!HTMLDivElement}
866 */
867 get nameContainerElement() {
868 return this.querySelector('.name-container');
869 },
870
871 /**
862 * Gets reauth name hint element. 872 * Gets reauth name hint element.
863 * @type {!HTMLDivElement} 873 * @type {!HTMLDivElement}
864 */ 874 */
865 get reauthNameHintElement() { 875 get reauthNameHintElement() {
866 return this.querySelector('.reauth-name-hint'); 876 return this.querySelector('.reauth-name-hint');
867 }, 877 },
868 878
869 /** 879 /**
870 * Gets the container holding the password field. 880 * Gets the container holding the password field.
871 * @type {!HTMLInputElement} 881 * @type {!HTMLInputElement}
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 } else if (this.user_.isApp) { 1132 } else if (this.user_.isApp) {
1123 this.setUserPodIconType('app'); 1133 this.setUserPodIconType('app');
1124 } 1134 }
1125 }, 1135 },
1126 1136
1127 toggleTransitions: function(enable) { 1137 toggleTransitions: function(enable) {
1128 this.classList.toggle('flying-pin-pod', enable); 1138 this.classList.toggle('flying-pin-pod', enable);
1129 }, 1139 },
1130 1140
1131 setPinVisibility: function(visible) { 1141 setPinVisibility: function(visible) {
1132 var elements = [this, this.authElement, this.imageElement, 1142 var elements = [this, this.authElement, this.imageElement,
jdufault 2016/07/12 00:22:25 This list is getting pretty long now and a number
sammiequon 2016/07/12 19:35:56 Done.
1133 this.signInElement, this.pinContainer]; 1143 this.signInElement, this.pinContainer,
1144 this.nameContainerElement];
1134 1145
1135 for (var idx = 0; idx < elements.length; idx++) { 1146 for (var idx = 0; idx < elements.length; idx++) {
1136 var currentElement = elements[idx]; 1147 var currentElement = elements[idx];
1137 currentElement.classList.toggle('pin-enabled', visible); 1148 currentElement.classList.toggle('pin-enabled', visible);
1138 currentElement.classList.toggle('pin-disabled', !visible); 1149 currentElement.classList.toggle('pin-disabled', !visible);
1139 } 1150 }
1151 this.pinKeyboardShown_ = visible;
1140 }, 1152 },
1141 1153
1142 setUserPodIconType: function(userTypeClass) { 1154 setUserPodIconType: function(userTypeClass) {
1143 this.userTypeIconAreaElement.classList.add(userTypeClass); 1155 this.userTypeIconAreaElement.classList.add(userTypeClass);
1144 this.userTypeIconAreaElement.hidden = false; 1156 this.userTypeIconAreaElement.hidden = false;
1145 }, 1157 },
1146 1158
1147 /** 1159 /**
1148 * The user that this pod represents. 1160 * The user that this pod represents.
1149 * @type {!Object} 1161 * @type {!Object}
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
2554 this.appendChild(userPod); 2566 this.appendChild(userPod);
2555 userPod.initialize(); 2567 userPod.initialize();
2556 }, 2568 },
2557 2569
2558 togglePinTransitions: function(enable) { 2570 togglePinTransitions: function(enable) {
2559 for (var i = 0; i < this.pods.length; ++i) 2571 for (var i = 0; i < this.pods.length; ++i)
2560 this.pods[i].toggleTransitions(enable); 2572 this.pods[i].toggleTransitions(enable);
2561 }, 2573 },
2562 2574
2563 setFocusedPodPinVisibility: function(visible) { 2575 setFocusedPodPinVisibility: function(visible) {
2564 if (this.focusedPod_ && this.focusedPod_.user.showPin) 2576 if (this.focusedPod_ && this.focusedPod_.user.showPin &&
2565 this.focusedPod_.setPinVisibility(visible); 2577 Oobe.getInstance().displayType == DISPLAY_TYPE.LOCK)
jdufault 2016/07/12 00:22:25 Why the Oobe.getInstance().displayType check? The
sammiequon 2016/07/12 19:35:56 Done.
2578 this.focusedPod_.setPinVisibility(visible);
2579 },
2580
2581 isPinShown_: function() {
2582 for (var i = 0; i < this.pods.length; ++i) {
2583 if (this.pods[i].pinKeyboardShown_)
2584 return true;
2585 }
2586 return false;
2566 }, 2587 },
2567 2588
2568 /** 2589 /**
2569 * Runs app with a given id from the list of loaded apps. 2590 * Runs app with a given id from the list of loaded apps.
2570 * @param {!string} app_id of an app to run. 2591 * @param {!string} app_id of an app to run.
2571 * @param {boolean=} opt_diagnosticMode Whether to run the app in 2592 * @param {boolean=} opt_diagnosticMode Whether to run the app in
2572 * diagnostic mode. Default is false. 2593 * diagnostic mode. Default is false.
2573 */ 2594 */
2574 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) { 2595 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) {
2575 var app = this.getPodWithAppId_(app_id); 2596 var app = this.getPodWithAppId_(app_id);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2920 * Returns width of podrow having |columns| number of columns. 2941 * Returns width of podrow having |columns| number of columns.
2921 * @private 2942 * @private
2922 */ 2943 */
2923 columnsToWidth_: function(columns) { 2944 columnsToWidth_: function(columns) {
2924 var isDesktopUserManager = Oobe.getInstance().displayType == 2945 var isDesktopUserManager = Oobe.getInstance().displayType ==
2925 DISPLAY_TYPE.DESKTOP_USER_MANAGER; 2946 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
2926 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] : 2947 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] :
2927 MARGIN_BY_COLUMNS[columns]; 2948 MARGIN_BY_COLUMNS[columns];
2928 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : 2949 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING :
2929 POD_ROW_PADDING; 2950 POD_ROW_PADDING;
2951
sammiequon 2016/07/08 18:04:32 Remove this line.
sammiequon 2016/07/12 19:35:56 Done.
2930 return 2 * rowPadding + columns * this.userPodWidth_ + 2952 return 2 * rowPadding + columns * this.userPodWidth_ +
2931 (columns - 1) * margin; 2953 (columns - 1) * margin;
2932 }, 2954 },
2933 2955
2934 /** 2956 /**
2935 * Returns height of podrow having |rows| number of rows. 2957 * Returns height of podrow having |rows| number of rows.
2936 * @private 2958 * @private
2937 */ 2959 */
2938 rowsToHeight_: function(rows) { 2960 rowsToHeight_: function(rows) {
2939 var isDesktopUserManager = Oobe.getInstance().displayType == 2961 var isDesktopUserManager = Oobe.getInstance().displayType ==
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2988 var layout = this.calculateLayout_(); 3010 var layout = this.calculateLayout_();
2989 var columns = this.columns = layout.columns; 3011 var columns = this.columns = layout.columns;
2990 var rows = this.rows = layout.rows; 3012 var rows = this.rows = layout.rows;
2991 var maxPodsNumber = columns * rows; 3013 var maxPodsNumber = columns * rows;
2992 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] : 3014 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] :
2993 MARGIN_BY_COLUMNS[columns]; 3015 MARGIN_BY_COLUMNS[columns];
2994 this.parentNode.setPreferredSize( 3016 this.parentNode.setPreferredSize(
2995 this.columnsToWidth_(columns), this.rowsToHeight_(rows)); 3017 this.columnsToWidth_(columns), this.rowsToHeight_(rows));
2996 var height = this.userPodHeight_; 3018 var height = this.userPodHeight_;
2997 var width = this.userPodWidth_; 3019 var width = this.userPodWidth_;
3020
3021 var pinShownRow = maxPodsNumber + 1;
3022 var pinShownColumn = maxPodsNumber + 1;
3023 var podWithPin = this.focusedPod_;
3024
3025 if (this.isPinShown_()) {
3026 this.pods.forEach(function(pod, index) {
3027 var column = index % columns;
3028 var row = Math.floor(index / columns);
3029 if(pod == podWithPin) {
3030 pinShownRow = row;
3031 pinShownColumn = column;
3032 }
3033 });
3034 }
3035
2998 this.pods.forEach(function(pod, index) { 3036 this.pods.forEach(function(pod, index) {
2999 if (index >= maxPodsNumber) { 3037 if (index >= maxPodsNumber) {
3000 pod.hidden = true; 3038 pod.hidden = true;
3001 return; 3039 return;
3002 } 3040 }
3003 pod.hidden = false; 3041 pod.hidden = false;
3004 if (pod.offsetHeight != height) { 3042 if (pod.offsetHeight != height) {
3005 console.error('Pod offsetHeight (' + pod.offsetHeight + 3043 console.error('Pod offsetHeight (' + pod.offsetHeight +
3006 ') and POD_HEIGHT (' + height + ') are not equal.'); 3044 ') and POD_HEIGHT (' + height + ') are not equal.');
3007 } 3045 }
3008 if (pod.offsetWidth != width) { 3046 if (pod.offsetWidth != width) {
3009 console.error('Pod offsetWidth (' + pod.offsetWidth + 3047 console.error('Pod offsetWidth (' + pod.offsetWidth +
3010 ') and POD_WIDTH (' + width + ') are not equal.'); 3048 ') and POD_WIDTH (' + width + ') are not equal.');
3011 } 3049 }
3012 var column = index % columns; 3050 var column = index % columns;
3013 var row = Math.floor(index / columns); 3051 var row = Math.floor(index / columns);
3052 var pinPadding = 0;
3053 if (row == pinShownRow) {
3054 pinPadding = PIN_EXTRA_WIDTH/2;
jdufault 2016/07/12 00:22:25 space between / operands.
sammiequon 2016/07/12 19:35:56 Done.
3055 if (column <= pinShownColumn)
3056 pinPadding *= -1;
3057 }
3058
3014 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : 3059 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING :
3015 POD_ROW_PADDING; 3060 POD_ROW_PADDING;
3016 pod.left = rowPadding + column * (width + margin); 3061 pod.left = rowPadding + column * (width + margin) + pinPadding;
3017 3062
3018 // On desktop, we want the rows to always be equally spaced. 3063 // On desktop, we want the rows to always be equally spaced.
3019 pod.top = isDesktopUserManager ? row * (height + rowPadding) : 3064 pod.top = isDesktopUserManager ? row * (height + rowPadding) :
3020 row * height + rowPadding; 3065 row * height + rowPadding;
3021 }); 3066 });
3022 Oobe.getInstance().updateScreenSize(this.parentNode); 3067 Oobe.getInstance().updateScreenSize(this.parentNode);
3023 }, 3068 },
3024 3069
3025 /** 3070 /**
3026 * Number of columns. 3071 * Number of columns.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3077 } 3122 }
3078 this.insideFocusPod_ = true; 3123 this.insideFocusPod_ = true;
3079 3124
3080 for (var i = 0, pod; pod = this.pods[i]; ++i) { 3125 for (var i = 0, pod; pod = this.pods[i]; ++i) {
3081 if (!this.alwaysFocusSinglePod) { 3126 if (!this.alwaysFocusSinglePod) {
3082 pod.isActionBoxMenuActive = false; 3127 pod.isActionBoxMenuActive = false;
3083 } 3128 }
3084 if (pod != podToFocus) { 3129 if (pod != podToFocus) {
3085 pod.isActionBoxMenuHovered = false; 3130 pod.isActionBoxMenuHovered = false;
3086 pod.classList.remove('focused'); 3131 pod.classList.remove('focused');
3132 pod.setPinVisibility(false);
3087 // On Desktop, the faded style is not set correctly, so we should 3133 // On Desktop, the faded style is not set correctly, so we should
3088 // manually fade out non-focused pods if there is a focused pod. 3134 // manually fade out non-focused pods if there is a focused pod.
3089 if (pod.user.isDesktopUser && podToFocus) 3135 if (pod.user.isDesktopUser && podToFocus)
3090 pod.classList.add('faded'); 3136 pod.classList.add('faded');
3091 else 3137 else
3092 pod.classList.remove('faded'); 3138 pod.classList.remove('faded');
3093 pod.reset(false); 3139 pod.reset(false);
3094 } 3140 }
3095 } 3141 }
3096 3142
3097 // Clear any error messages for previous pod. 3143 // Clear any error messages for previous pod.
3098 if (!this.isFocused(podToFocus)) 3144 if (!this.isFocused(podToFocus))
3099 Oobe.clearErrors(); 3145 Oobe.clearErrors();
3100 3146
3101 var hadFocus = !!this.focusedPod_; 3147 var hadFocus = !!this.focusedPod_;
3102 this.focusedPod_ = podToFocus; 3148 this.focusedPod_ = podToFocus;
3103 if (podToFocus) { 3149 if (podToFocus) {
3150 this.setFocusedPodPinVisibility(true);
3104 podToFocus.classList.remove('faded'); 3151 podToFocus.classList.remove('faded');
3105 podToFocus.classList.add('focused'); 3152 podToFocus.classList.add('focused');
3106 if (!podToFocus.multiProfilesPolicyApplied) { 3153 if (!podToFocus.multiProfilesPolicyApplied) {
3107 podToFocus.classList.toggle('signing-in', false); 3154 podToFocus.classList.toggle('signing-in', false);
3108 if (!opt_skipInputFocus) 3155 if (!opt_skipInputFocus)
3109 podToFocus.focusInput(); 3156 podToFocus.focusInput();
3110 } else { 3157 } else {
3111 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); 3158 podToFocus.userTypeBubbleElement.classList.add('bubble-shown');
3112 // Note it is not necessary to skip this focus request when 3159 // Note it is not necessary to skip this focus request when
3113 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| 3160 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied|
3114 // is false, it doesn't focus on the password input box by default. 3161 // is false, it doesn't focus on the password input box by default.
3115 podToFocus.focus(); 3162 podToFocus.focus();
3116 } 3163 }
3117 3164
3118 // focusPod() automatically loads wallpaper 3165 // focusPod() automatically loads wallpaper
3119 if (!podToFocus.user.isApp) 3166 if (!podToFocus.user.isApp)
3120 chrome.send('focusPod', [podToFocus.user.username]); 3167 chrome.send('focusPod', [podToFocus.user.username]);
3121 this.firstShown_ = false; 3168 this.firstShown_ = false;
3122 this.lastFocusedPod_ = podToFocus; 3169 this.lastFocusedPod_ = podToFocus;
3123 this.scrollFocusedPodIntoView(); 3170 this.scrollFocusedPodIntoView();
3124 } 3171 }
3125 this.insideFocusPod_ = false; 3172 this.insideFocusPod_ = false;
3173 this.placePods_();
jdufault 2016/07/12 00:22:25 Was this missing before?
sammiequon 2016/07/12 19:35:56 I added this because the pods shift when the pin k
3126 }, 3174 },
3127 3175
3128 /** 3176 /**
3129 * Resets wallpaper to the last active user's wallpaper, if any. 3177 * Resets wallpaper to the last active user's wallpaper, if any.
3130 */ 3178 */
3131 loadLastWallpaper: function() { 3179 loadLastWallpaper: function() {
3132 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) 3180 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp)
3133 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); 3181 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]);
3134 }, 3182 },
3135 3183
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
3497 if (pod && pod.multiProfilesPolicyApplied) { 3545 if (pod && pod.multiProfilesPolicyApplied) {
3498 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3546 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3499 } 3547 }
3500 } 3548 }
3501 }; 3549 };
3502 3550
3503 return { 3551 return {
3504 PodRow: PodRow 3552 PodRow: PodRow
3505 }; 3553 };
3506 }); 3554 });
OLDNEW
« ui/login/account_picker/user_pod_row.css ('K') | « ui/login/account_picker/user_pod_row.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698