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

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: FIxed patch set 1 errors. 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 CROS_PIN_POD_WIDTH = 270;
63 var CROS_PIN_POD_HEIGHT = 594;
64 var PIN_EXTRA_WIDTH = 90;
62 65
63 /** 66 /**
64 * Minimal padding between user pod and virtual keyboard. 67 * Minimal padding between user pod and virtual keyboard.
65 * @type {number} 68 * @type {number}
66 * @const 69 * @const
67 */ 70 */
68 var USER_POD_KEYBOARD_MIN_PADDING = 20; 71 var USER_POD_KEYBOARD_MIN_PADDING = 20;
69 72
70 /** 73 /**
71 * Maximum time for which the pod row remains hidden until all user images 74 * Maximum time for which the pod row remains hidden until all user images
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 }, 831 },
829 832
830 /** 833 /**
831 * Height number of pixels. 834 * Height number of pixels.
832 */ 835 */
833 get height() { 836 get height() {
834 return this.offsetHeight; 837 return this.offsetHeight;
835 }, 838 },
836 839
837 /** 840 /**
838 * Gets the authorization element of the pod.
839 * @type {!HTMLDivElement}
840 */
841 get authElement() {
842 return this.querySelector('.auth-container');
843 },
844
845 /**
846 * Gets image pane element.
847 * @type {!HTMLDivElement}
848 */
849 get imagePaneElement() {
850 return this.querySelector('.user-image-pane');
851 },
852
853 /**
854 * Gets image element. 841 * Gets image element.
855 * @type {!HTMLImageElement} 842 * @type {!HTMLImageElement}
856 */ 843 */
857 get imageElement() { 844 get imageElement() {
858 return this.querySelector('.user-image'); 845 return this.querySelector('.user-image');
859 }, 846 },
860 847
861 /** 848 /**
862 * Gets name element. 849 * Gets name element.
863 * @type {!HTMLDivElement} 850 * @type {!HTMLDivElement}
(...skipping 29 matching lines...) Expand all
893 /** 880 /**
894 * Gets the password label, which is used to show a message where the 881 * Gets the password label, which is used to show a message where the
895 * password field is normally. 882 * password field is normally.
896 * @type {!HTMLInputElement} 883 * @type {!HTMLInputElement}
897 */ 884 */
898 get passwordLabelElement() { 885 get passwordLabelElement() {
899 return this.querySelector('.password-label'); 886 return this.querySelector('.password-label');
900 }, 887 },
901 888
902 /** 889 /**
903 * Gets the pin-container of the pod.
904 * @type {!HTMLDivElement}
905 */
906 get pinContainer() {
907 return this.querySelector('.pin-container');
908 },
909
910 /**
911 * Gets the pin-keyboard of the pod. 890 * Gets the pin-keyboard of the pod.
912 * @type {!HTMLElement} 891 * @type {!HTMLElement}
913 */ 892 */
914 get pinKeyboard() { 893 get pinKeyboard() {
915 return this.querySelector('pin-keyboard'); 894 return this.querySelector('pin-keyboard');
916 }, 895 },
917 896
918 /** 897 /**
919 * Gets user online sign in hint element. 898 * Gets user online sign in hint element.
920 * @type {!HTMLDivElement} 899 * @type {!HTMLDivElement}
921 */ 900 */
922 get reauthWarningElement() { 901 get reauthWarningElement() {
923 return this.querySelector('.reauth-hint-container'); 902 return this.querySelector('.reauth-hint-container');
924 }, 903 },
925 904
926 /** 905 /**
927 * Gets the signed in indicator of the pod.
928 * @type {!HTMLDivElement}
929 */
930 get signInElement() {
931 return this.querySelector('.signed-in-indicator');
932 },
933
934 /**
935 * Gets the container holding the launch app button. 906 * Gets the container holding the launch app button.
936 * @type {!HTMLButtonElement} 907 * @type {!HTMLButtonElement}
937 */ 908 */
938 get launchAppButtonContainerElement() { 909 get launchAppButtonContainerElement() {
939 return this.querySelector('.launch-app-button-container'); 910 return this.querySelector('.launch-app-button-container');
940 }, 911 },
941 912
942 /** 913 /**
943 * Gets launch app button. 914 * Gets launch app button.
944 * @type {!HTMLButtonElement} 915 * @type {!HTMLButtonElement}
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 } else if (this.user_.isApp) { 1101 } else if (this.user_.isApp) {
1131 this.setUserPodIconType('app'); 1102 this.setUserPodIconType('app');
1132 } 1103 }
1133 }, 1104 },
1134 1105
1135 toggleTransitions: function(enable) { 1106 toggleTransitions: function(enable) {
1136 this.classList.toggle('flying-pin-pod', enable); 1107 this.classList.toggle('flying-pin-pod', enable);
1137 }, 1108 },
1138 1109
1139 setPinVisibility: function(visible) { 1110 setPinVisibility: function(visible) {
1140 var elements = [this, this.authElement, this.imagePaneElement, 1111 var elements = this.querySelectorAll('.pin-modifiable');
jdufault 2016/07/12 19:51:26 What about var elements = Array(this.querySelec
sammiequon 2016/07/12 23:20:18 Array() seems to make an array of arrays where the
jdufault 2016/07/12 23:37:46 Okay - how about just making a helper function the
sammiequon 2016/07/16 01:48:48 Done.
1141 this.imageElement, this.pinContainer]; 1112 var elements_array = Array.prototype.slice.call(elements);
1113 elements_array.push(this);
1142 1114
1143 for (var idx = 0; idx < elements.length; idx++) { 1115 for (var idx = 0; idx < elements_array.length; idx++) {
1144 var currentElement = elements[idx]; 1116 var currentElement = elements_array[idx];
1145 currentElement.classList.toggle('pin-enabled', visible); 1117 currentElement.classList.toggle('pin-enabled', visible);
1146 currentElement.classList.toggle('pin-disabled', !visible); 1118 currentElement.classList.toggle('pin-disabled', !visible);
1147 } 1119 }
1148 1120
1149 // Set the focus to the input element after showing/hiding pin keyboard. 1121 // Set the focus to the input element after showing/hiding pin keyboard.
1150 if (visible) 1122 if (visible)
1151 this.pinKeyboard.focus(); 1123 this.pinKeyboard.focus();
1152 else 1124 else
1153 this.mainInput.focus(); 1125 this.mainInput.focus();
1154 }, 1126 },
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
2572 togglePinTransitions: function(enable) { 2544 togglePinTransitions: function(enable) {
2573 for (var i = 0; i < this.pods.length; ++i) 2545 for (var i = 0; i < this.pods.length; ++i)
2574 this.pods[i].toggleTransitions(enable); 2546 this.pods[i].toggleTransitions(enable);
2575 }, 2547 },
2576 2548
2577 setFocusedPodPinVisibility: function(visible) { 2549 setFocusedPodPinVisibility: function(visible) {
2578 if (this.focusedPod_ && this.focusedPod_.user.showPin) 2550 if (this.focusedPod_ && this.focusedPod_.user.showPin)
2579 this.focusedPod_.setPinVisibility(visible); 2551 this.focusedPod_.setPinVisibility(visible);
2580 }, 2552 },
2581 2553
2554 isPinShown_: function() {
2555 for (var i = 0; i < this.pods.length; ++i) {
2556 if (this.pods[i].classList.contains('pin-enabled'))
jdufault 2016/07/12 19:51:26 This class check is happening in a couple of place
sammiequon 2016/07/12 23:20:18 Done. I think the other check is in another CL tho
jdufault 2016/07/12 23:37:46 Okay - please make sure you update that CL as well
sammiequon 2016/07/16 01:48:48 Done.
2557 return true;
2558 }
2559 return false;
2560 },
2561
2582 /** 2562 /**
2583 * Runs app with a given id from the list of loaded apps. 2563 * Runs app with a given id from the list of loaded apps.
2584 * @param {!string} app_id of an app to run. 2564 * @param {!string} app_id of an app to run.
2585 * @param {boolean=} opt_diagnosticMode Whether to run the app in 2565 * @param {boolean=} opt_diagnosticMode Whether to run the app in
2586 * diagnostic mode. Default is false. 2566 * diagnostic mode. Default is false.
2587 */ 2567 */
2588 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) { 2568 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) {
2589 var app = this.getPodWithAppId_(app_id); 2569 var app = this.getPodWithAppId_(app_id);
2590 if (app) { 2570 if (app) {
2591 var activationEvent = cr.doc.createEvent('MouseEvents'); 2571 var activationEvent = cr.doc.createEvent('MouseEvents');
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 var layout = this.calculateLayout_(); 2982 var layout = this.calculateLayout_();
3003 var columns = this.columns = layout.columns; 2983 var columns = this.columns = layout.columns;
3004 var rows = this.rows = layout.rows; 2984 var rows = this.rows = layout.rows;
3005 var maxPodsNumber = columns * rows; 2985 var maxPodsNumber = columns * rows;
3006 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] : 2986 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] :
3007 MARGIN_BY_COLUMNS[columns]; 2987 MARGIN_BY_COLUMNS[columns];
3008 this.parentNode.setPreferredSize( 2988 this.parentNode.setPreferredSize(
3009 this.columnsToWidth_(columns), this.rowsToHeight_(rows)); 2989 this.columnsToWidth_(columns), this.rowsToHeight_(rows));
3010 var height = this.userPodHeight_; 2990 var height = this.userPodHeight_;
3011 var width = this.userPodWidth_; 2991 var width = this.userPodWidth_;
2992
2993 var pinShownRow = maxPodsNumber + 1;
2994 var pinShownColumn = maxPodsNumber + 1;
2995 var podWithPin = this.focusedPod_;
2996
2997 if (this.isPinShown_()) {
2998 this.pods.forEach(function(pod, index) {
2999 var column = index % columns;
3000 var row = Math.floor(index / columns);
3001 if (pod == podWithPin) {
3002 pinShownRow = row;
3003 pinShownColumn = column;
3004 }
3005 });
3006 }
3007
3012 this.pods.forEach(function(pod, index) { 3008 this.pods.forEach(function(pod, index) {
3013 if (index >= maxPodsNumber) { 3009 if (index >= maxPodsNumber) {
3014 pod.hidden = true; 3010 pod.hidden = true;
3015 return; 3011 return;
3016 } 3012 }
3017 pod.hidden = false; 3013 pod.hidden = false;
3018 if (pod.offsetHeight != height) { 3014 if (pod.offsetHeight != height &&
3015 pod.offsetHeight != CROS_PIN_POD_HEIGHT) {
jdufault 2016/07/12 19:51:26 Can we just set height/width to the expected value
sammiequon 2016/07/12 23:20:18 The height/width is being set in another function
jdufault 2016/07/12 23:37:46 It's probably worthwhile to investigate then to ma
3019 console.error('Pod offsetHeight (' + pod.offsetHeight + 3016 console.error('Pod offsetHeight (' + pod.offsetHeight +
3020 ') and POD_HEIGHT (' + height + ') are not equal.'); 3017 ') and POD_HEIGHT (' + height + ') are not equal.');
3021 } 3018 }
3022 if (pod.offsetWidth != width) { 3019 if (pod.offsetWidth != width &&
3020 pod.offsetWidth != CROS_PIN_POD_WIDTH) {
3023 console.error('Pod offsetWidth (' + pod.offsetWidth + 3021 console.error('Pod offsetWidth (' + pod.offsetWidth +
3024 ') and POD_WIDTH (' + width + ') are not equal.'); 3022 ') and POD_WIDTH (' + width + ') are not equal.');
3025 } 3023 }
3026 var column = index % columns; 3024 var column = index % columns;
3027 var row = Math.floor(index / columns); 3025 var row = Math.floor(index / columns);
3026 var pinPadding = 0;
3027 if (row == pinShownRow) {
3028 pinPadding = PIN_EXTRA_WIDTH / 2;
3029 if (column <= pinShownColumn)
3030 pinPadding *= -1;
jdufault 2016/07/12 19:51:26 We want negative padding?
sammiequon 2016/07/12 23:20:18 I renamed it offsetFromPin. The pods on the left o
3031 }
3032
3028 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : 3033 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING :
3029 POD_ROW_PADDING; 3034 POD_ROW_PADDING;
3030 pod.left = rowPadding + column * (width + margin); 3035 pod.left = rowPadding + column * (width + margin) + pinPadding;
3031 3036
3032 // On desktop, we want the rows to always be equally spaced. 3037 // On desktop, we want the rows to always be equally spaced.
3033 pod.top = isDesktopUserManager ? row * (height + rowPadding) : 3038 pod.top = isDesktopUserManager ? row * (height + rowPadding) :
3034 row * height + rowPadding; 3039 row * height + rowPadding;
3035 }); 3040 });
3036 Oobe.getInstance().updateScreenSize(this.parentNode); 3041 Oobe.getInstance().updateScreenSize(this.parentNode);
3037 }, 3042 },
3038 3043
3039 /** 3044 /**
3040 * Number of columns. 3045 * Number of columns.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3091 } 3096 }
3092 this.insideFocusPod_ = true; 3097 this.insideFocusPod_ = true;
3093 3098
3094 for (var i = 0, pod; pod = this.pods[i]; ++i) { 3099 for (var i = 0, pod; pod = this.pods[i]; ++i) {
3095 if (!this.alwaysFocusSinglePod) { 3100 if (!this.alwaysFocusSinglePod) {
3096 pod.isActionBoxMenuActive = false; 3101 pod.isActionBoxMenuActive = false;
3097 } 3102 }
3098 if (pod != podToFocus) { 3103 if (pod != podToFocus) {
3099 pod.isActionBoxMenuHovered = false; 3104 pod.isActionBoxMenuHovered = false;
3100 pod.classList.remove('focused'); 3105 pod.classList.remove('focused');
3106 pod.setPinVisibility(false);
3101 // On Desktop, the faded style is not set correctly, so we should 3107 // On Desktop, the faded style is not set correctly, so we should
3102 // manually fade out non-focused pods if there is a focused pod. 3108 // manually fade out non-focused pods if there is a focused pod.
3103 if (pod.user.isDesktopUser && podToFocus) 3109 if (pod.user.isDesktopUser && podToFocus)
3104 pod.classList.add('faded'); 3110 pod.classList.add('faded');
3105 else 3111 else
3106 pod.classList.remove('faded'); 3112 pod.classList.remove('faded');
3107 pod.reset(false); 3113 pod.reset(false);
3108 } 3114 }
3109 } 3115 }
3110 3116
3111 // Clear any error messages for previous pod. 3117 // Clear any error messages for previous pod.
3112 if (!this.isFocused(podToFocus)) 3118 if (!this.isFocused(podToFocus))
3113 Oobe.clearErrors(); 3119 Oobe.clearErrors();
3114 3120
3115 var hadFocus = !!this.focusedPod_; 3121 var hadFocus = !!this.focusedPod_;
3116 this.focusedPod_ = podToFocus; 3122 this.focusedPod_ = podToFocus;
3117 if (podToFocus) { 3123 if (podToFocus) {
3124 this.setFocusedPodPinVisibility(true);
3118 podToFocus.classList.remove('faded'); 3125 podToFocus.classList.remove('faded');
3119 podToFocus.classList.add('focused'); 3126 podToFocus.classList.add('focused');
3120 if (!podToFocus.multiProfilesPolicyApplied) { 3127 if (!podToFocus.multiProfilesPolicyApplied) {
3121 podToFocus.classList.toggle('signing-in', false); 3128 podToFocus.classList.toggle('signing-in', false);
3122 if (!opt_skipInputFocus) 3129 if (!opt_skipInputFocus)
3123 podToFocus.focusInput(); 3130 podToFocus.focusInput();
3124 } else { 3131 } else {
3125 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); 3132 podToFocus.userTypeBubbleElement.classList.add('bubble-shown');
3126 // Note it is not necessary to skip this focus request when 3133 // Note it is not necessary to skip this focus request when
3127 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| 3134 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied|
3128 // is false, it doesn't focus on the password input box by default. 3135 // is false, it doesn't focus on the password input box by default.
3129 podToFocus.focus(); 3136 podToFocus.focus();
3130 } 3137 }
3131 3138
3132 // focusPod() automatically loads wallpaper 3139 // focusPod() automatically loads wallpaper
3133 if (!podToFocus.user.isApp) 3140 if (!podToFocus.user.isApp)
3134 chrome.send('focusPod', [podToFocus.user.username]); 3141 chrome.send('focusPod', [podToFocus.user.username]);
3135 this.firstShown_ = false; 3142 this.firstShown_ = false;
3136 this.lastFocusedPod_ = podToFocus; 3143 this.lastFocusedPod_ = podToFocus;
3137 this.scrollFocusedPodIntoView(); 3144 this.scrollFocusedPodIntoView();
3138 } 3145 }
3139 this.insideFocusPod_ = false; 3146 this.insideFocusPod_ = false;
3147 this.placePods_();
3140 }, 3148 },
3141 3149
3142 /** 3150 /**
3143 * Resets wallpaper to the last active user's wallpaper, if any. 3151 * Resets wallpaper to the last active user's wallpaper, if any.
3144 */ 3152 */
3145 loadLastWallpaper: function() { 3153 loadLastWallpaper: function() {
3146 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) 3154 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp)
3147 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); 3155 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]);
3148 }, 3156 },
3149 3157
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 if (pod && pod.multiProfilesPolicyApplied) { 3519 if (pod && pod.multiProfilesPolicyApplied) {
3512 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3520 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3513 } 3521 }
3514 } 3522 }
3515 }; 3523 };
3516 3524
3517 return { 3525 return {
3518 PodRow: PodRow 3526 PodRow: PodRow
3519 }; 3527 };
3520 }); 3528 });
OLDNEW
« no previous file with comments | « ui/login/account_picker/user_pod_row.css ('k') | ui/login/account_picker/user_pod_template.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698