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

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

Issue 2222583002: Lock screen pin keyboard ui upgrades. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 4 years, 4 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; 62 var CROS_PIN_POD_WIDTH = 180;
jdufault 2016/08/05 21:58:52 Can we eliminate this variable entirely, or set it
sammiequon 2016/08/05 23:34:50 Done.
63 var CROS_PIN_POD_HEIGHT = 594; 63 var CROS_PIN_POD_HEIGHT = 417;
64 var PIN_EXTRA_WIDTH = 90;
65 64
66 /** 65 /**
67 * Minimal padding between user pod and virtual keyboard. 66 * Minimal padding between user pod and virtual keyboard.
68 * @type {number} 67 * @type {number}
69 * @const 68 * @const
70 */ 69 */
71 var USER_POD_KEYBOARD_MIN_PADDING = 20; 70 var USER_POD_KEYBOARD_MIN_PADDING = 20;
72 71
73 /** 72 /**
74 * Maximum time for which the pod row remains hidden until all user images 73 * Maximum time for which the pod row remains hidden until all user images
(...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2388 2387
2389 PodRow.prototype = { 2388 PodRow.prototype = {
2390 __proto__: HTMLDivElement.prototype, 2389 __proto__: HTMLDivElement.prototype,
2391 2390
2392 // Whether this user pod row is shown for the first time. 2391 // Whether this user pod row is shown for the first time.
2393 firstShown_: true, 2392 firstShown_: true,
2394 2393
2395 // True if inside focusPod(). 2394 // True if inside focusPod().
2396 insideFocusPod_: false, 2395 insideFocusPod_: false,
2397 2396
2397 // Whether the pin keyboard has been loaded.
2398 pinKeyboardLoaded_: false,
2399
2398 // Focused pod. 2400 // Focused pod.
2399 focusedPod_: undefined, 2401 focusedPod_: undefined,
2400 2402
2401 // Activated pod, i.e. the pod of current login attempt. 2403 // Activated pod, i.e. the pod of current login attempt.
2402 activatedPod_: undefined, 2404 activatedPod_: undefined,
2403 2405
2404 // Pod that was most recently focused, if any. 2406 // Pod that was most recently focused, if any.
2405 lastFocusedPod_: undefined, 2407 lastFocusedPod_: undefined,
2406 2408
2407 // Pods whose initial images haven't been loaded yet. 2409 // Pods whose initial images haven't been loaded yet.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 this.appendChild(userPod); 2545 this.appendChild(userPod);
2544 userPod.initialize(); 2546 userPod.initialize();
2545 }, 2547 },
2546 2548
2547 togglePinTransitions: function(enable) { 2549 togglePinTransitions: function(enable) {
2548 for (var i = 0; i < this.pods.length; ++i) 2550 for (var i = 0; i < this.pods.length; ++i)
2549 this.pods[i].toggleTransitions(enable); 2551 this.pods[i].toggleTransitions(enable);
2550 }, 2552 },
2551 2553
2552 setFocusedPodPinVisibility: function(visible) { 2554 setFocusedPodPinVisibility: function(visible) {
2555 this.pinKeyboardLoaded_ = true;
jdufault 2016/08/05 21:58:52 Can we just query the DOM and see if there is cont
sammiequon 2016/08/05 23:34:50 Done. For multiple pods we want the keyboard to ex
2553 if (this.focusedPod_ && this.focusedPod_.user.showPin) 2556 if (this.focusedPod_ && this.focusedPod_.user.showPin)
2554 this.focusedPod_.setPinVisibility(visible); 2557 this.focusedPod_.setPinVisibility(visible);
2555 }, 2558 },
2556 2559
2557 /** 2560 /**
2558 * Runs app with a given id from the list of loaded apps. 2561 * Runs app with a given id from the list of loaded apps.
2559 * @param {!string} app_id of an app to run. 2562 * @param {!string} app_id of an app to run.
2560 * @param {boolean=} opt_diagnosticMode Whether to run the app in 2563 * @param {boolean=} opt_diagnosticMode Whether to run the app in
2561 * diagnostic mode. Default is false. 2564 * diagnostic mode. Default is false.
2562 */ 2565 */
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2958 // One more iteration if it's not enough cells to place all pods. 2961 // One more iteration if it's not enough cells to place all pods.
2959 while (maxWidth >= this.columnsToWidth_(columns + 1) && 2962 while (maxWidth >= this.columnsToWidth_(columns + 1) &&
2960 columns * rows < this.pods.length && 2963 columns * rows < this.pods.length &&
2961 columns < MAX_NUMBER_OF_COLUMNS) { 2964 columns < MAX_NUMBER_OF_COLUMNS) {
2962 ++columns; 2965 ++columns;
2963 } 2966 }
2964 return {columns: columns, rows: rows}; 2967 return {columns: columns, rows: rows};
2965 }, 2968 },
2966 2969
2967 /** 2970 /**
2968 * Calculates the row and column of the given |pod|.
2969 * @param {UserPod} pod Pod we want the row and column of.
2970 * @param {number} columns Columns in the podrow.
2971 * @param {number} rows Rows in the podrow.
2972 * @return {{columns: number, rows: number}}
2973 * @private
2974 */
2975 findPodLocation_: function(pod, columns, rows) {
2976 var column = -1;
2977 var row = -1;
2978 var index = this.pods.indexOf(pod);
2979 if (index >= 0) {
2980 row = Math.floor(index / columns);
2981 column = index % columns;
2982 }
2983 else {
2984 console.error('Pod not found in pod row.');
2985 }
2986 return {column: column, row: row};
2987 },
2988
2989 /**
2990 * Places pods onto their positions onto pod grid. 2971 * Places pods onto their positions onto pod grid.
2991 * @private 2972 * @private
2992 */ 2973 */
2993 placePods_: function() { 2974 placePods_: function() {
2994 var isDesktopUserManager = Oobe.getInstance().displayType == 2975 var isDesktopUserManager = Oobe.getInstance().displayType ==
2995 DISPLAY_TYPE.DESKTOP_USER_MANAGER; 2976 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
2996 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible) 2977 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible)
2997 return; 2978 return;
2998 2979
2999 var layout = this.calculateLayout_(); 2980 var layout = this.calculateLayout_();
(...skipping 21 matching lines...) Expand all
3021 console.error('Pod offsetHeight (' + pod.offsetHeight + 3002 console.error('Pod offsetHeight (' + pod.offsetHeight +
3022 ') and POD_HEIGHT (' + height + ') are not equal.'); 3003 ') and POD_HEIGHT (' + height + ') are not equal.');
3023 } 3004 }
3024 if (pod.offsetWidth != width && 3005 if (pod.offsetWidth != width &&
3025 pod.offsetWidth != CROS_PIN_POD_WIDTH) { 3006 pod.offsetWidth != CROS_PIN_POD_WIDTH) {
3026 console.error('Pod offsetWidth (' + pod.offsetWidth + 3007 console.error('Pod offsetWidth (' + pod.offsetWidth +
3027 ') and POD_WIDTH (' + width + ') are not equal.'); 3008 ') and POD_WIDTH (' + width + ') are not equal.');
3028 } 3009 }
3029 var column = index % columns; 3010 var column = index % columns;
3030 var row = Math.floor(index / columns); 3011 var row = Math.floor(index / columns);
3031 var offsetFromPin = 0;
3032 if (row == pinPodLocation.row) {
3033 offsetFromPin = PIN_EXTRA_WIDTH / 2;
3034 if (column <= pinPodLocation.column)
3035 offsetFromPin *= -1;
3036 }
3037 3012
3038 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : 3013 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING :
3039 POD_ROW_PADDING; 3014 POD_ROW_PADDING;
3040 pod.left = rowPadding + column * (width + margin) + offsetFromPin; 3015 pod.left = rowPadding + column * (width + margin);
3041 3016
3042 // On desktop, we want the rows to always be equally spaced. 3017 // On desktop, we want the rows to always be equally spaced.
3043 pod.top = isDesktopUserManager ? row * (height + rowPadding) : 3018 pod.top = isDesktopUserManager ? row * (height + rowPadding) :
3044 row * height + rowPadding; 3019 row * height + rowPadding;
3045 }); 3020 });
3046 Oobe.getInstance().updateScreenSize(this.parentNode); 3021 Oobe.getInstance().updateScreenSize(this.parentNode);
3047 }, 3022 },
3048 3023
3049 /** 3024 /**
3050 * Number of columns. 3025 * Number of columns.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3119 } 3094 }
3120 } 3095 }
3121 3096
3122 // Clear any error messages for previous pod. 3097 // Clear any error messages for previous pod.
3123 if (!this.isFocused(podToFocus)) 3098 if (!this.isFocused(podToFocus))
3124 Oobe.clearErrors(); 3099 Oobe.clearErrors();
3125 3100
3126 var hadFocus = !!this.focusedPod_; 3101 var hadFocus = !!this.focusedPod_;
3127 this.focusedPod_ = podToFocus; 3102 this.focusedPod_ = podToFocus;
3128 if (podToFocus) { 3103 if (podToFocus) {
3129 this.setFocusedPodPinVisibility(true); 3104 // Only show the keyboard if it is fully loaded.
3105 if (this.pinKeyboardLoaded_)
3106 podToFocus.setPinVisibility(true);
3130 podToFocus.classList.remove('faded'); 3107 podToFocus.classList.remove('faded');
3131 podToFocus.classList.add('focused'); 3108 podToFocus.classList.add('focused');
3132 if (!podToFocus.multiProfilesPolicyApplied) { 3109 if (!podToFocus.multiProfilesPolicyApplied) {
3133 podToFocus.classList.toggle('signing-in', false); 3110 podToFocus.classList.toggle('signing-in', false);
3134 if (!opt_skipInputFocus) 3111 if (!opt_skipInputFocus)
3135 podToFocus.focusInput(); 3112 podToFocus.focusInput();
3136 } else { 3113 } else {
3137 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); 3114 podToFocus.userTypeBubbleElement.classList.add('bubble-shown');
3138 // Note it is not necessary to skip this focus request when 3115 // Note it is not necessary to skip this focus request when
3139 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| 3116 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied|
3140 // is false, it doesn't focus on the password input box by default. 3117 // is false, it doesn't focus on the password input box by default.
3141 podToFocus.focus(); 3118 podToFocus.focus();
3142 } 3119 }
3143 3120
3144 // focusPod() automatically loads wallpaper 3121 // focusPod() automatically loads wallpaper
3145 if (!podToFocus.user.isApp) 3122 if (!podToFocus.user.isApp)
3146 chrome.send('focusPod', [podToFocus.user.username]); 3123 chrome.send('focusPod', [podToFocus.user.username]);
3147 this.firstShown_ = false; 3124 this.firstShown_ = false;
3148 this.lastFocusedPod_ = podToFocus; 3125 this.lastFocusedPod_ = podToFocus;
3149 this.scrollFocusedPodIntoView(); 3126 this.scrollFocusedPodIntoView();
3150 } 3127 }
3151 this.insideFocusPod_ = false; 3128 this.insideFocusPod_ = false;
3152 this.placePods_();
3153 }, 3129 },
jdufault 2016/08/05 21:58:52 Why the removal?
sammiequon 2016/08/05 23:34:50 This was added to support multiple pods and to re
3154 3130
3155 /** 3131 /**
3156 * Resets wallpaper to the last active user's wallpaper, if any. 3132 * Resets wallpaper to the last active user's wallpaper, if any.
3157 */ 3133 */
3158 loadLastWallpaper: function() { 3134 loadLastWallpaper: function() {
3159 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) 3135 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp)
3160 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); 3136 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]);
3161 }, 3137 },
3162 3138
3163 /** 3139 /**
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
3525 if (pod && pod.multiProfilesPolicyApplied) { 3501 if (pod && pod.multiProfilesPolicyApplied) {
3526 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3502 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3527 } 3503 }
3528 } 3504 }
3529 }; 3505 };
3530 3506
3531 return { 3507 return {
3532 PodRow: PodRow 3508 PodRow: PodRow
3533 }; 3509 };
3534 }); 3510 });
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