OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 */ | 44 */ |
45 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2; | 45 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2; |
46 | 46 |
47 /** | 47 /** |
48 * Variables used for pod placement processing. Width and height should be | 48 * Variables used for pod placement processing. Width and height should be |
49 * synced with computed CSS sizes of pods. | 49 * synced with computed CSS sizes of pods. |
50 */ | 50 */ |
51 var POD_WIDTH = 180; | 51 var POD_WIDTH = 180; |
52 var PUBLIC_EXPANDED_WIDTH = 420; | 52 var PUBLIC_EXPANDED_WIDTH = 420; |
53 var CROS_POD_HEIGHT = 213; | 53 var CROS_POD_HEIGHT = 213; |
54 var DESKTOP_POD_HEIGHT = 216; | 54 var DESKTOP_POD_HEIGHT = 226; |
55 var POD_ROW_PADDING = 10; | 55 var POD_ROW_PADDING = 10; |
56 var DESKTOP_ROW_PADDING = 15; | 56 var DESKTOP_ROW_PADDING = 15; |
57 | 57 |
58 /** | 58 /** |
59 * Minimal padding between user pod and virtual keyboard. | 59 * Minimal padding between user pod and virtual keyboard. |
60 * @type {number} | 60 * @type {number} |
61 * @const | 61 * @const |
62 */ | 62 */ |
63 var USER_POD_KEYBOARD_MIN_PADDING = 20; | 63 var USER_POD_KEYBOARD_MIN_PADDING = 20; |
64 | 64 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 this.handleActionAreaButtonClick_.bind(this)); | 189 this.handleActionAreaButtonClick_.bind(this)); |
190 this.actionBoxAreaElement.addEventListener('keydown', | 190 this.actionBoxAreaElement.addEventListener('keydown', |
191 this.handleActionAreaButtonKeyDown_.bind(this)); | 191 this.handleActionAreaButtonKeyDown_.bind(this)); |
192 | 192 |
193 this.actionBoxMenuRemoveElement.addEventListener('click', | 193 this.actionBoxMenuRemoveElement.addEventListener('click', |
194 this.handleRemoveCommandClick_.bind(this)); | 194 this.handleRemoveCommandClick_.bind(this)); |
195 this.actionBoxMenuRemoveElement.addEventListener('keydown', | 195 this.actionBoxMenuRemoveElement.addEventListener('keydown', |
196 this.handleRemoveCommandKeyDown_.bind(this)); | 196 this.handleRemoveCommandKeyDown_.bind(this)); |
197 this.actionBoxMenuRemoveElement.addEventListener('blur', | 197 this.actionBoxMenuRemoveElement.addEventListener('blur', |
198 this.handleRemoveCommandBlur_.bind(this)); | 198 this.handleRemoveCommandBlur_.bind(this)); |
199 | 199 this.actionBoxRemoveUserWarningButtonElement.addEventListener( |
200 if (this.actionBoxRemoveUserWarningButtonElement) { | 200 'click', |
201 this.actionBoxRemoveUserWarningButtonElement.addEventListener( | 201 this.handleRemoveUserConfirmationClick_.bind(this)); |
202 'click', | |
203 this.handleRemoveUserConfirmationClick_.bind(this)); | |
204 } | |
205 }, | 202 }, |
206 | 203 |
207 /** | 204 /** |
208 * Initializes the pod after its properties set and added to a pod row. | 205 * Initializes the pod after its properties set and added to a pod row. |
209 */ | 206 */ |
210 initialize: function() { | 207 initialize: function() { |
211 this.passwordElement.addEventListener('keydown', | 208 this.passwordElement.addEventListener('keydown', |
212 this.parentNode.handleKeyDown.bind(this.parentNode)); | 209 this.parentNode.handleKeyDown.bind(this.parentNode)); |
213 this.passwordElement.addEventListener('keypress', | 210 this.passwordElement.addEventListener('keypress', |
214 this.handlePasswordKeyPress_.bind(this)); | 211 this.handlePasswordKeyPress_.bind(this)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 }, | 272 }, |
276 | 273 |
277 /** | 274 /** |
278 * Height number of pixels. | 275 * Height number of pixels. |
279 */ | 276 */ |
280 get height() { | 277 get height() { |
281 return this.offsetHeight; | 278 return this.offsetHeight; |
282 }, | 279 }, |
283 | 280 |
284 /** | 281 /** |
285 * Gets signed in indicator element. | |
286 * @type {!HTMLDivElement} | |
287 */ | |
288 get signedInIndicatorElement() { | |
289 return this.querySelector('.signed-in-indicator'); | |
290 }, | |
291 | |
292 /** | |
293 * Gets image element. | 282 * Gets image element. |
294 * @type {!HTMLImageElement} | 283 * @type {!HTMLImageElement} |
295 */ | 284 */ |
296 get imageElement() { | 285 get imageElement() { |
297 return this.querySelector('.user-image'); | 286 return this.querySelector('.user-image'); |
298 }, | 287 }, |
299 | 288 |
300 /** | 289 /** |
301 * Gets name element. | 290 * Gets name element. |
302 * @type {!HTMLDivElement} | 291 * @type {!HTMLDivElement} |
303 */ | 292 */ |
304 get nameElement() { | 293 get nameElement() { |
305 return this.querySelector('.name'); | 294 return this.querySelector('.name'); |
306 }, | 295 }, |
307 | 296 |
308 /** | 297 /** |
| 298 * Gets the container holding the password field. |
| 299 * @type {!HTMLInputElement} |
| 300 */ |
| 301 get passwordEntryContainerElement() { |
| 302 return this.querySelector('.password-entry-container'); |
| 303 }, |
| 304 |
| 305 /** |
309 * Gets password field. | 306 * Gets password field. |
310 * @type {!HTMLInputElement} | 307 * @type {!HTMLInputElement} |
311 */ | 308 */ |
312 get passwordElement() { | 309 get passwordElement() { |
313 return this.querySelector('.password'); | 310 return this.querySelector('.password'); |
314 }, | 311 }, |
315 | 312 |
316 /** | 313 /** |
317 * Gets the password label, which is used to show a message where the | 314 * Gets the password label, which is used to show a message where the |
318 * password field is normally. | 315 * password field is normally. |
319 * @type {!HTMLInputElement} | 316 * @type {!HTMLInputElement} |
320 */ | 317 */ |
321 get passwordLabelElement() { | 318 get passwordLabelElement() { |
322 return this.querySelector('.password-label'); | 319 return this.querySelector('.password-label'); |
323 }, | 320 }, |
324 | 321 |
325 /** | 322 /** |
326 * Gets Caps Lock hint image. | |
327 * @type {!HTMLImageElement} | |
328 */ | |
329 get capslockHintElement() { | |
330 return this.querySelector('.capslock-hint'); | |
331 }, | |
332 | |
333 /** | |
334 * Gets user sign in button. | 323 * Gets user sign in button. |
335 * @type {!HTMLButtonElement} | 324 * @type {!HTMLButtonElement} |
336 */ | 325 */ |
337 get signinButtonElement() { | 326 get signinButtonElement() { |
338 return this.querySelector('.signin-button'); | 327 return this.querySelector('.signin-button'); |
339 }, | 328 }, |
340 | 329 |
341 /** | 330 /** |
| 331 * Gets the container holding the launch app button. |
| 332 * @type {!HTMLButtonElement} |
| 333 */ |
| 334 get launchAppButtonContainerElement() { |
| 335 return this.querySelector('.launch-app-button-container'); |
| 336 }, |
| 337 |
| 338 /** |
342 * Gets launch app button. | 339 * Gets launch app button. |
343 * @type {!HTMLButtonElement} | 340 * @type {!HTMLButtonElement} |
344 */ | 341 */ |
345 get launchAppButtonElement() { | 342 get launchAppButtonElement() { |
346 return this.querySelector('.launch-app-button'); | 343 return this.querySelector('.launch-app-button'); |
347 }, | 344 }, |
348 | 345 |
349 /** | 346 /** |
350 * Gets action box area. | 347 * Gets action box area. |
351 * @type {!HTMLInputElement} | 348 * @type {!HTMLInputElement} |
(...skipping 12 matching lines...) Expand all Loading... |
364 | 361 |
365 /** | 362 /** |
366 * Gets user type bubble like multi-profiles policy restriction message. | 363 * Gets user type bubble like multi-profiles policy restriction message. |
367 * @type {!HTMLDivElement} | 364 * @type {!HTMLDivElement} |
368 */ | 365 */ |
369 get userTypeBubbleElement() { | 366 get userTypeBubbleElement() { |
370 return this.querySelector('.user-type-bubble'); | 367 return this.querySelector('.user-type-bubble'); |
371 }, | 368 }, |
372 | 369 |
373 /** | 370 /** |
374 * Gets user type icon. | |
375 * @type {!HTMLDivElement} | |
376 */ | |
377 get userTypeIconElement() { | |
378 return this.querySelector('.user-type-icon-image'); | |
379 }, | |
380 | |
381 /** | |
382 * Gets action box menu. | |
383 * @type {!HTMLInputElement} | |
384 */ | |
385 get actionBoxMenuElement() { | |
386 return this.querySelector('.action-box-menu'); | |
387 }, | |
388 | |
389 /** | |
390 * Gets action box menu title. | |
391 * @type {!HTMLInputElement} | |
392 */ | |
393 get actionBoxMenuTitleElement() { | |
394 return this.querySelector('.action-box-menu-title'); | |
395 }, | |
396 | |
397 /** | |
398 * Gets action box menu title, user name item. | 371 * Gets action box menu title, user name item. |
399 * @type {!HTMLInputElement} | 372 * @type {!HTMLInputElement} |
400 */ | 373 */ |
401 get actionBoxMenuTitleNameElement() { | 374 get actionBoxMenuTitleNameElement() { |
402 return this.querySelector('.action-box-menu-title-name'); | 375 return this.querySelector('.action-box-menu-title-name'); |
403 }, | 376 }, |
404 | 377 |
405 /** | 378 /** |
406 * Gets action box menu title, user email item. | 379 * Gets action box menu title, user email item. |
407 * @type {!HTMLInputElement} | 380 * @type {!HTMLInputElement} |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 426 |
454 /** | 427 /** |
455 * Gets action box menu, remove user command item div. | 428 * Gets action box menu, remove user command item div. |
456 * @type {!HTMLInputElement} | 429 * @type {!HTMLInputElement} |
457 */ | 430 */ |
458 get actionBoxRemoveUserWarningButtonElement() { | 431 get actionBoxRemoveUserWarningButtonElement() { |
459 return this.querySelector('.remove-warning-button'); | 432 return this.querySelector('.remove-warning-button'); |
460 }, | 433 }, |
461 | 434 |
462 /** | 435 /** |
463 * Gets the locked user indicator box. | |
464 * @type {!HTMLInputElement} | |
465 */ | |
466 get lockedIndicatorElement() { | |
467 return this.querySelector('.locked-indicator'); | |
468 }, | |
469 | |
470 /** | |
471 * Gets the supervised user indicator box. | |
472 * @type {!HTMLInputElement} | |
473 */ | |
474 get supervisedUserIndicatorElement() { | |
475 return this.querySelector('.supervised-indicator'); | |
476 }, | |
477 | |
478 /** | |
479 * Gets the custom icon. This icon is normally hidden, but can be shown | 436 * Gets the custom icon. This icon is normally hidden, but can be shown |
480 * using the chrome.screenlockPrivate API. | 437 * using the chrome.screenlockPrivate API. |
481 * @type {!HTMLDivElement} | 438 * @type {!HTMLDivElement} |
482 */ | 439 */ |
483 get customIconElement() { | 440 get customIconElement() { |
484 return this.querySelector('.custom-icon'); | 441 return this.querySelector('.custom-icon'); |
485 }, | 442 }, |
486 | 443 |
487 /** | 444 /** |
488 * Updates the user pod element. | 445 * Updates the user pod element. |
489 */ | 446 */ |
490 update: function() { | 447 update: function() { |
491 this.imageElement.src = 'chrome://userimage/' + this.user.username + | 448 this.imageElement.src = 'chrome://userimage/' + this.user.username + |
492 '?id=' + UserPod.userImageSalt_[this.user.username]; | 449 '?id=' + UserPod.userImageSalt_[this.user.username]; |
493 | 450 |
494 this.nameElement.textContent = this.user_.displayName; | 451 this.nameElement.textContent = this.user_.displayName; |
495 this.signedInIndicatorElement.hidden = !this.user_.signedIn; | 452 this.classList.toggle('signed-in', this.user_.signedIn); |
496 | 453 |
497 this.signinButtonElement.hidden = !this.isAuthTypeOnlineSignIn; | |
498 if (this.isAuthTypeUserClick) | 454 if (this.isAuthTypeUserClick) |
499 this.passwordLabelElement.textContent = this.authValue; | 455 this.passwordLabelElement.textContent = this.authValue; |
500 | 456 |
501 this.updateActionBoxArea(); | 457 this.updateActionBoxArea(); |
502 | 458 |
503 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( | 459 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( |
504 'passwordFieldAccessibleName', this.user_.emailAddress)); | 460 'passwordFieldAccessibleName', this.user_.emailAddress)); |
505 | 461 |
506 this.customizeUserPodPerUserType(); | 462 this.customizeUserPodPerUserType(); |
507 }, | 463 }, |
508 | 464 |
509 updateActionBoxArea: function() { | 465 updateActionBoxArea: function() { |
510 if (this.user_.publicAccount || this.user_.isApp) { | 466 if (this.user_.publicAccount || this.user_.isApp) { |
511 this.actionBoxAreaElement.hidden = true; | 467 this.actionBoxAreaElement.hidden = true; |
512 return; | 468 return; |
513 } | 469 } |
514 | 470 |
515 this.actionBoxAreaElement.hidden = false; | |
516 this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove; | 471 this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove; |
517 | 472 |
518 this.actionBoxAreaElement.setAttribute( | 473 this.actionBoxAreaElement.setAttribute( |
519 'aria-label', loadTimeData.getStringF( | 474 'aria-label', loadTimeData.getStringF( |
520 'podMenuButtonAccessibleName', this.user_.emailAddress)); | 475 'podMenuButtonAccessibleName', this.user_.emailAddress)); |
521 this.actionBoxMenuRemoveElement.setAttribute( | 476 this.actionBoxMenuRemoveElement.setAttribute( |
522 'aria-label', loadTimeData.getString( | 477 'aria-label', loadTimeData.getString( |
523 'podMenuRemoveItemAccessibleName')); | 478 'podMenuRemoveItemAccessibleName')); |
524 this.actionBoxMenuTitleNameElement.textContent = this.user_.isOwner ? | 479 this.actionBoxMenuTitleNameElement.textContent = this.user_.isOwner ? |
525 loadTimeData.getStringF('ownerUserPattern', this.user_.displayName) : | 480 loadTimeData.getStringF('ownerUserPattern', this.user_.displayName) : |
526 this.user_.displayName; | 481 this.user_.displayName; |
527 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress; | 482 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress; |
528 this.actionBoxMenuTitleEmailElement.hidden = | 483 this.actionBoxMenuTitleEmailElement.hidden = |
529 this.user_.locallyManagedUser; | 484 this.user_.locallyManagedUser; |
530 | 485 |
531 this.actionBoxMenuCommandElement.textContent = | 486 this.actionBoxMenuCommandElement.textContent = |
532 loadTimeData.getString('removeUser'); | 487 loadTimeData.getString('removeUser'); |
533 }, | 488 }, |
534 | 489 |
535 customizeUserPodPerUserType: function() { | 490 customizeUserPodPerUserType: function() { |
536 if (this.user_.locallyManagedUser && !this.user_.isDesktopUser) { | 491 if (this.user_.locallyManagedUser && !this.user_.isDesktopUser) { |
537 this.setUserPodIconType('supervised'); | 492 this.setUserPodIconType('supervised'); |
538 } else if (this.multiProfilesPolicyApplied) { | 493 } else if (this.multiProfilesPolicyApplied) { |
539 // Mark user pod as not focusable which in addition to the grayed out | 494 // Mark user pod as not focusable which in addition to the grayed out |
540 // filter makes it look in disabled state. | 495 // filter makes it look in disabled state. |
541 this.classList.add('multiprofiles-policy-applied'); | 496 this.classList.add('multiprofiles-policy-applied'); |
542 this.setUserPodIconType('policy'); | 497 this.setUserPodIconType('policy'); |
543 | 498 |
544 this.querySelector('.mp-policy-title').hidden = false; | |
545 if (this.user.multiProfilesPolicy == 'primary-only') | 499 if (this.user.multiProfilesPolicy == 'primary-only') |
546 this.querySelector('.mp-policy-primary-only-msg').hidden = false; | 500 this.querySelector('.mp-policy-primary-only-msg').hidden = false; |
547 else if (this.user.multiProfilesPolicy == 'owner-primary-only') | 501 else if (this.user.multiProfilesPolicy == 'owner-primary-only') |
548 this.querySelector('.mp-owner-primary-only-msg').hidden = false; | 502 this.querySelector('.mp-owner-primary-only-msg').hidden = false; |
549 else | 503 else |
550 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; | 504 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; |
551 } else if (this.user_.isApp) { | 505 } else if (this.user_.isApp) { |
552 this.setUserPodIconType('app'); | 506 this.setUserPodIconType('app'); |
553 } | 507 } |
554 }, | 508 }, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 */ | 556 */ |
603 get isActionBoxMenuActive() { | 557 get isActionBoxMenuActive() { |
604 return this.actionBoxAreaElement.classList.contains('active'); | 558 return this.actionBoxAreaElement.classList.contains('active'); |
605 }, | 559 }, |
606 set isActionBoxMenuActive(active) { | 560 set isActionBoxMenuActive(active) { |
607 if (active == this.isActionBoxMenuActive) | 561 if (active == this.isActionBoxMenuActive) |
608 return; | 562 return; |
609 | 563 |
610 if (active) { | 564 if (active) { |
611 this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove; | 565 this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove; |
612 if (this.actionBoxRemoveUserWarningElement) | 566 this.actionBoxRemoveUserWarningElement.hidden = true; |
613 this.actionBoxRemoveUserWarningElement.hidden = true; | |
614 | 567 |
615 // Clear focus first if another pod is focused. | 568 // Clear focus first if another pod is focused. |
616 if (!this.parentNode.isFocused(this)) { | 569 if (!this.parentNode.isFocused(this)) { |
617 this.parentNode.focusPod(undefined, true); | 570 this.parentNode.focusPod(undefined, true); |
618 this.actionBoxAreaElement.focus(); | 571 this.actionBoxAreaElement.focus(); |
619 } | 572 } |
620 | 573 |
621 // Hide user-type-bubble. | 574 // Hide user-type-bubble. |
622 this.userTypeBubbleElement.classList.remove('bubble-shown'); | 575 this.userTypeBubbleElement.classList.remove('bubble-shown'); |
623 | 576 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 if (this.expanded) | 1014 if (this.expanded) |
1062 return this.enterButtonElement; | 1015 return this.enterButtonElement; |
1063 else | 1016 else |
1064 return this.nameElement; | 1017 return this.nameElement; |
1065 }, | 1018 }, |
1066 | 1019 |
1067 /** @override */ | 1020 /** @override */ |
1068 decorate: function() { | 1021 decorate: function() { |
1069 UserPod.prototype.decorate.call(this); | 1022 UserPod.prototype.decorate.call(this); |
1070 | 1023 |
1071 this.classList.remove('need-password'); | |
1072 this.classList.add('public-account'); | 1024 this.classList.add('public-account'); |
1073 | 1025 |
1074 this.nameElement.addEventListener('keydown', (function(e) { | 1026 this.nameElement.addEventListener('keydown', (function(e) { |
1075 if (e.keyIdentifier == 'Enter') { | 1027 if (e.keyIdentifier == 'Enter') { |
1076 this.parentNode.setActivatedPod(this, e); | 1028 this.parentNode.setActivatedPod(this, e); |
1077 // Stop this keydown event from bubbling up to PodRow handler. | 1029 // Stop this keydown event from bubbling up to PodRow handler. |
1078 e.stopPropagation(); | 1030 e.stopPropagation(); |
1079 // Prevent default so that we don't trigger a 'click' event on the | 1031 // Prevent default so that we don't trigger a 'click' event on the |
1080 // newly focused "Enter" button. | 1032 // newly focused "Enter" button. |
1081 e.preventDefault(); | 1033 e.preventDefault(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 var node = $('user-pod-template').cloneNode(true); | 1133 var node = $('user-pod-template').cloneNode(true); |
1182 node.removeAttribute('id'); | 1134 node.removeAttribute('id'); |
1183 return node; | 1135 return node; |
1184 }); | 1136 }); |
1185 | 1137 |
1186 DesktopUserPod.prototype = { | 1138 DesktopUserPod.prototype = { |
1187 __proto__: UserPod.prototype, | 1139 __proto__: UserPod.prototype, |
1188 | 1140 |
1189 /** @override */ | 1141 /** @override */ |
1190 get mainInput() { | 1142 get mainInput() { |
1191 if (!this.passwordElement.hidden) | 1143 if (this.user.needsSignin) |
1192 return this.passwordElement; | 1144 return this.passwordElement; |
1193 else | 1145 else |
1194 return this.nameElement; | 1146 return this.nameElement; |
1195 }, | 1147 }, |
1196 | 1148 |
1197 /** @override */ | 1149 /** @override */ |
1198 decorate: function() { | |
1199 UserPod.prototype.decorate.call(this); | |
1200 }, | |
1201 | |
1202 /** @override */ | |
1203 update: function() { | 1150 update: function() { |
1204 this.imageElement.src = this.user.userImage; | 1151 this.imageElement.src = this.user.userImage; |
1205 this.nameElement.textContent = this.user.displayName; | 1152 this.nameElement.textContent = this.user.displayName; |
1206 | 1153 |
1207 var isLockedUser = this.user.needsSignin; | 1154 var isLockedUser = this.user.needsSignin; |
1208 var isSupervisedUser = this.user.locallyManagedUser; | 1155 var isSupervisedUser = this.user.locallyManagedUser; |
1209 this.signinButtonElement.hidden = true; | 1156 this.classList.toggle('locked', isLockedUser); |
1210 this.lockedIndicatorElement.hidden = !isLockedUser; | 1157 this.classList.toggle('supervised-user', isSupervisedUser); |
1211 this.supervisedUserIndicatorElement.hidden = !isSupervisedUser; | |
1212 this.passwordElement.hidden = !isLockedUser; | |
1213 this.nameElement.hidden = isLockedUser; | |
1214 | 1158 |
1215 if (this.isAuthTypeUserClick) | 1159 if (this.isAuthTypeUserClick) |
1216 this.passwordLabelElement.textContent = this.authValue; | 1160 this.passwordLabelElement.textContent = this.authValue; |
1217 | 1161 |
1218 this.actionBoxRemoveUserWarningTextElement.hidden = isSupervisedUser; | 1162 this.actionBoxRemoveUserWarningTextElement.hidden = isSupervisedUser; |
1219 this.actionBoxRemoveSupervisedUserWarningTextElement.hidden = | 1163 this.actionBoxRemoveSupervisedUserWarningTextElement.hidden = |
1220 !isSupervisedUser; | 1164 !isSupervisedUser; |
1221 | 1165 |
1222 UserPod.prototype.updateActionBoxArea.call(this); | 1166 UserPod.prototype.updateActionBoxArea.call(this); |
1223 }, | 1167 }, |
1224 | 1168 |
1225 /** @override */ | 1169 /** @override */ |
1226 focusInput: function() { | 1170 focusInput: function() { |
1227 // For focused pods, display the name unless the pod is locked. | |
1228 var isLockedUser = this.user.needsSignin; | |
1229 var isSupervisedUser = this.user.locallyManagedUser; | |
1230 this.signinButtonElement.hidden = true; | |
1231 this.lockedIndicatorElement.hidden = !isLockedUser; | |
1232 this.supervisedUserIndicatorElement.hidden = !isSupervisedUser; | |
1233 this.passwordElement.hidden = !isLockedUser; | |
1234 this.nameElement.hidden = isLockedUser; | |
1235 | |
1236 // Move tabIndex from the whole pod to the main input. | 1171 // Move tabIndex from the whole pod to the main input. |
1237 this.tabIndex = -1; | 1172 this.tabIndex = -1; |
1238 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; | 1173 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; |
1239 this.mainInput.focus(); | 1174 this.mainInput.focus(); |
1240 }, | 1175 }, |
1241 | 1176 |
1242 /** @override */ | 1177 /** @override */ |
1243 reset: function(takeFocus) { | |
1244 // Always display the user's name for unfocused pods. | |
1245 if (!takeFocus) | |
1246 this.nameElement.hidden = false; | |
1247 UserPod.prototype.reset.call(this, takeFocus); | |
1248 }, | |
1249 | |
1250 /** @override */ | |
1251 activate: function(e) { | 1178 activate: function(e) { |
1252 if (this.passwordElement.hidden) { | 1179 if (!this.user.needsSignin) { |
1253 Oobe.launchUser(this.user.emailAddress, this.user.displayName); | 1180 Oobe.launchUser(this.user.emailAddress, this.user.displayName); |
1254 } else if (!this.passwordElement.value) { | 1181 } else if (!this.passwordElement.value) { |
1255 return false; | 1182 return false; |
1256 } else { | 1183 } else { |
1257 chrome.send('authenticatedLaunchUser', | 1184 chrome.send('authenticatedLaunchUser', |
1258 [this.user.emailAddress, | 1185 [this.user.emailAddress, |
1259 this.user.displayName, | 1186 this.user.displayName, |
1260 this.passwordElement.value]); | 1187 this.passwordElement.value]); |
1261 } | 1188 } |
1262 this.passwordElement.value = ''; | 1189 this.passwordElement.value = ''; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 | 1235 |
1309 /** @override */ | 1236 /** @override */ |
1310 update: function() { | 1237 update: function() { |
1311 this.imageElement.src = this.user.iconUrl; | 1238 this.imageElement.src = this.user.iconUrl; |
1312 if (this.user.iconHeight && this.user.iconWidth) { | 1239 if (this.user.iconHeight && this.user.iconWidth) { |
1313 this.imageElement.style.height = this.user.iconHeight; | 1240 this.imageElement.style.height = this.user.iconHeight; |
1314 this.imageElement.style.width = this.user.iconWidth; | 1241 this.imageElement.style.width = this.user.iconWidth; |
1315 } | 1242 } |
1316 this.imageElement.alt = this.user.label; | 1243 this.imageElement.alt = this.user.label; |
1317 this.imageElement.title = this.user.label; | 1244 this.imageElement.title = this.user.label; |
1318 this.passwordElement.hidden = true; | 1245 this.passwordEntryContainerElement.hidden = true; |
1319 this.signinButtonElement.hidden = true; | 1246 this.launchAppButtonContainerElement.hidden = false; |
1320 this.launchAppButtonElement.hidden = false; | |
1321 this.signedInIndicatorElement.hidden = true; | |
1322 this.nameElement.textContent = this.user.label; | 1247 this.nameElement.textContent = this.user.label; |
1323 | 1248 |
1324 UserPod.prototype.updateActionBoxArea.call(this); | 1249 UserPod.prototype.updateActionBoxArea.call(this); |
1325 UserPod.prototype.customizeUserPodPerUserType.call(this); | 1250 UserPod.prototype.customizeUserPodPerUserType.call(this); |
1326 }, | 1251 }, |
1327 | 1252 |
1328 /** @override */ | 1253 /** @override */ |
1329 get mainInput() { | 1254 get mainInput() { |
1330 return this.launchAppButtonElement; | 1255 return this.launchAppButtonElement; |
1331 }, | 1256 }, |
1332 | 1257 |
1333 /** @override */ | 1258 /** @override */ |
1334 focusInput: function() { | 1259 focusInput: function() { |
1335 this.signinButtonElement.hidden = true; | |
1336 this.launchAppButtonElement.hidden = false; | |
1337 this.passwordElement.hidden = true; | |
1338 | |
1339 // Move tabIndex from the whole pod to the main input. | 1260 // Move tabIndex from the whole pod to the main input. |
1340 this.tabIndex = -1; | 1261 this.tabIndex = -1; |
1341 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; | 1262 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; |
1342 this.mainInput.focus(); | 1263 this.mainInput.focus(); |
1343 }, | 1264 }, |
1344 | 1265 |
1345 /** @override */ | 1266 /** @override */ |
1346 get forceOnlineSignin() { | 1267 get forceOnlineSignin() { |
1347 return false; | 1268 return false; |
1348 }, | 1269 }, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 | 1337 |
1417 // Activated pod, i.e. the pod of current login attempt. | 1338 // Activated pod, i.e. the pod of current login attempt. |
1418 activatedPod_: undefined, | 1339 activatedPod_: undefined, |
1419 | 1340 |
1420 // Pod that was most recently focused, if any. | 1341 // Pod that was most recently focused, if any. |
1421 lastFocusedPod_: undefined, | 1342 lastFocusedPod_: undefined, |
1422 | 1343 |
1423 // Pods whose initial images haven't been loaded yet. | 1344 // Pods whose initial images haven't been loaded yet. |
1424 podsWithPendingImages_: [], | 1345 podsWithPendingImages_: [], |
1425 | 1346 |
1426 // Whether pod creation is animated. | |
1427 userAddIsAnimated_: false, | |
1428 | |
1429 // Whether pod placement has been postponed. | 1347 // Whether pod placement has been postponed. |
1430 podPlacementPostponed_: false, | 1348 podPlacementPostponed_: false, |
1431 | 1349 |
1432 // Standard user pod height/width. | 1350 // Standard user pod height/width. |
1433 userPodHeight_: 0, | 1351 userPodHeight_: 0, |
1434 userPodWidth_: 0, | 1352 userPodWidth_: 0, |
1435 | 1353 |
1436 // Array of apps that are shown in addition to other user pods. | 1354 // Array of apps that are shown in addition to other user pods. |
1437 apps_: [], | 1355 apps_: [], |
1438 | 1356 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 else | 1458 else |
1541 userPod = new UserPod({user: user}); | 1459 userPod = new UserPod({user: user}); |
1542 | 1460 |
1543 userPod.hidden = false; | 1461 userPod.hidden = false; |
1544 return userPod; | 1462 return userPod; |
1545 }, | 1463 }, |
1546 | 1464 |
1547 /** | 1465 /** |
1548 * Add an existing user pod to this pod row. | 1466 * Add an existing user pod to this pod row. |
1549 * @param {!Object} user User info dictionary. | 1467 * @param {!Object} user User info dictionary. |
1550 * @param {boolean} animated Whether to use init animation. | |
1551 */ | 1468 */ |
1552 addUserPod: function(user, animated) { | 1469 addUserPod: function(user) { |
1553 var userPod = this.createUserPod(user); | 1470 var userPod = this.createUserPod(user); |
1554 if (animated) { | |
1555 userPod.classList.add('init'); | |
1556 userPod.nameElement.classList.add('init'); | |
1557 } | |
1558 | |
1559 this.appendChild(userPod); | 1471 this.appendChild(userPod); |
1560 userPod.initialize(); | 1472 userPod.initialize(); |
1561 }, | 1473 }, |
1562 | 1474 |
1563 /** | 1475 /** |
1564 * Runs app with a given id from the list of loaded apps. | 1476 * Runs app with a given id from the list of loaded apps. |
1565 * @param {!string} app_id of an app to run. | 1477 * @param {!string} app_id of an app to run. |
1566 * @param {boolean=} opt_diagnostic_mode Whether to run the app in | 1478 * @param {boolean=} opt_diagnostic_mode Whether to run the app in |
1567 * diagnostic mode. Default is false. | 1479 * diagnostic mode. Default is false. |
1568 */ | 1480 */ |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 */ | 1512 */ |
1601 indexOf_: function(pod) { | 1513 indexOf_: function(pod) { |
1602 for (var i = 0; i < this.pods.length; ++i) { | 1514 for (var i = 0; i < this.pods.length; ++i) { |
1603 if (pod == this.pods[i]) | 1515 if (pod == this.pods[i]) |
1604 return i; | 1516 return i; |
1605 } | 1517 } |
1606 return -1; | 1518 return -1; |
1607 }, | 1519 }, |
1608 | 1520 |
1609 /** | 1521 /** |
1610 * Start first time show animation. | |
1611 */ | |
1612 startInitAnimation: function() { | |
1613 // Schedule init animation. | |
1614 for (var i = 0, pod; pod = this.pods[i]; ++i) { | |
1615 window.setTimeout(removeClass, 500 + i * 70, pod, 'init'); | |
1616 window.setTimeout(removeClass, 700 + i * 70, pod.nameElement, 'init'); | |
1617 } | |
1618 }, | |
1619 | |
1620 /** | |
1621 * Start login success animation. | |
1622 */ | |
1623 startAuthenticatedAnimation: function() { | |
1624 var activated = this.indexOf_(this.activatedPod_); | |
1625 if (activated == -1) | |
1626 return; | |
1627 | |
1628 for (var i = 0, pod; pod = this.pods[i]; ++i) { | |
1629 if (i < activated) | |
1630 pod.classList.add('left'); | |
1631 else if (i > activated) | |
1632 pod.classList.add('right'); | |
1633 else | |
1634 pod.classList.add('zoom'); | |
1635 } | |
1636 }, | |
1637 | |
1638 /** | |
1639 * Populates pod row with given existing users and start init animation. | 1522 * Populates pod row with given existing users and start init animation. |
1640 * @param {array} users Array of existing user emails. | 1523 * @param {array} users Array of existing user emails. |
1641 * @param {boolean} animated Whether to use init animation. | |
1642 */ | 1524 */ |
1643 loadPods: function(users, animated) { | 1525 loadPods: function(users) { |
1644 this.users_ = users; | 1526 this.users_ = users; |
1645 this.userAddIsAnimated_ = animated; | |
1646 | 1527 |
1647 this.rebuildPods(); | 1528 this.rebuildPods(); |
1648 }, | 1529 }, |
1649 | 1530 |
1650 /** | 1531 /** |
1651 * Scrolls focused user pod into view. | 1532 * Scrolls focused user pod into view. |
1652 */ | 1533 */ |
1653 scrollFocusedPodIntoView: function() { | 1534 scrollFocusedPodIntoView: function() { |
1654 var pod = this.focusedPod_; | 1535 var pod = this.focusedPod_; |
1655 if (!pod) | 1536 if (!pod) |
(...skipping 25 matching lines...) Expand all Loading... |
1681 this.innerHTML = ''; | 1562 this.innerHTML = ''; |
1682 this.focusedPod_ = undefined; | 1563 this.focusedPod_ = undefined; |
1683 this.activatedPod_ = undefined; | 1564 this.activatedPod_ = undefined; |
1684 this.lastFocusedPod_ = undefined; | 1565 this.lastFocusedPod_ = undefined; |
1685 | 1566 |
1686 // Switch off animation | 1567 // Switch off animation |
1687 Oobe.getInstance().toggleClass('flying-pods', false); | 1568 Oobe.getInstance().toggleClass('flying-pods', false); |
1688 | 1569 |
1689 // Populate the pod row. | 1570 // Populate the pod row. |
1690 for (var i = 0; i < this.users_.length; ++i) | 1571 for (var i = 0; i < this.users_.length; ++i) |
1691 this.addUserPod(this.users_[i], this.userAddIsAnimated_); | 1572 this.addUserPod(this.users_[i]); |
1692 | 1573 |
1693 for (var i = 0, pod; pod = this.pods[i]; ++i) | 1574 for (var i = 0, pod; pod = this.pods[i]; ++i) |
1694 this.podsWithPendingImages_.push(pod); | 1575 this.podsWithPendingImages_.push(pod); |
1695 | 1576 |
1696 // TODO(nkostylev): Edge case handling when kiosk apps are not fitting. | 1577 // TODO(nkostylev): Edge case handling when kiosk apps are not fitting. |
1697 if (this.shouldShowApps_) { | 1578 if (this.shouldShowApps_) { |
1698 for (var i = 0; i < this.apps_.length; ++i) | 1579 for (var i = 0; i < this.apps_.length; ++i) |
1699 this.addUserPod(this.apps_[i], this.userAddIsAnimated_); | 1580 this.addUserPod(this.apps_[i]); |
1700 } | 1581 } |
1701 | 1582 |
1702 // Make sure we eventually show the pod row, even if some image is stuck. | 1583 // Make sure we eventually show the pod row, even if some image is stuck. |
1703 setTimeout(function() { | 1584 setTimeout(function() { |
1704 $('pod-row').classList.remove('images-loading'); | 1585 $('pod-row').classList.remove('images-loading'); |
1705 }, POD_ROW_IMAGES_LOAD_TIMEOUT_MS); | 1586 }, POD_ROW_IMAGES_LOAD_TIMEOUT_MS); |
1706 | 1587 |
1707 var isCrosAccountPicker = $('login-header-bar').signinUIState == | 1588 var isCrosAccountPicker = $('login-header-bar').signinUIState == |
1708 SIGNIN_UI_STATE.ACCOUNT_PICKER; | 1589 SIGNIN_UI_STATE.ACCOUNT_PICKER; |
1709 var isDesktopUserManager = Oobe.getInstance().displayType == | 1590 var isDesktopUserManager = Oobe.getInstance().displayType == |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 if (this.podsWithPendingImages_.length == 0) { | 2284 if (this.podsWithPendingImages_.length == 0) { |
2404 this.classList.remove('images-loading'); | 2285 this.classList.remove('images-loading'); |
2405 } | 2286 } |
2406 } | 2287 } |
2407 }; | 2288 }; |
2408 | 2289 |
2409 return { | 2290 return { |
2410 PodRow: PodRow | 2291 PodRow: PodRow |
2411 }; | 2292 }; |
2412 }); | 2293 }); |
OLD | NEW |