| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Pod width. 170px Pod + 10px padding + 10px margin on both sides. | 10 // Pod width. 170px Pod + 10px padding + 10px margin on both sides. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 * The user that this pod represents. | 168 * The user that this pod represents. |
| 169 * @type {!Object} | 169 * @type {!Object} |
| 170 */ | 170 */ |
| 171 user_: undefined, | 171 user_: undefined, |
| 172 get user() { | 172 get user() { |
| 173 return this.user_; | 173 return this.user_; |
| 174 }, | 174 }, |
| 175 set user(userDict) { | 175 set user(userDict) { |
| 176 this.user_ = userDict; | 176 this.user_ = userDict; |
| 177 | 177 |
| 178 this.updateUserImage(); |
| 179 |
| 178 this.nameElement.textContent = userDict.name; | 180 this.nameElement.textContent = userDict.name; |
| 179 this.imageElement.src = userDict.imageUrl; | |
| 180 this.removeUserButtonElement.hidden = !userDict.canRemove; | 181 this.removeUserButtonElement.hidden = !userDict.canRemove; |
| 181 this.signedInIndicatorElement.hidden = !userDict.signedIn; | 182 this.signedInIndicatorElement.hidden = !userDict.signedIn; |
| 182 | 183 |
| 183 if (this.isGuest) { | 184 if (this.isGuest) { |
| 184 this.imageElement.title = userDict.name; | 185 this.imageElement.title = userDict.name; |
| 185 this.enterButtonElement.hidden = false; | 186 this.enterButtonElement.hidden = false; |
| 186 this.passwordElement.hidden = true; | 187 this.passwordElement.hidden = true; |
| 187 this.signinButtonElement.hidden = true; | 188 this.signinButtonElement.hidden = true; |
| 188 } else { | 189 } else { |
| 189 var needSignin = this.needGaiaSignin; | 190 var needSignin = this.needGaiaSignin; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 257 |
| 257 /** | 258 /** |
| 258 * Whether the password field is empty. | 259 * Whether the password field is empty. |
| 259 * @type {boolean} | 260 * @type {boolean} |
| 260 */ | 261 */ |
| 261 set passwordEmpty(empty) { | 262 set passwordEmpty(empty) { |
| 262 this.passwordElement.classList[empty ? 'add' : 'remove']('empty'); | 263 this.passwordElement.classList[empty ? 'add' : 'remove']('empty'); |
| 263 }, | 264 }, |
| 264 | 265 |
| 265 /** | 266 /** |
| 267 * Updates the image element of the user. |
| 268 */ |
| 269 updateUserImage: function() { |
| 270 this.imageElement.src = this.isGuest ? |
| 271 'chrome://theme/IDR_LOGIN_GUEST' : |
| 272 'chrome://userimage/' + this.user.emailAddress + |
| 273 '?id=' + (new Date()).getTime(); |
| 274 }, |
| 275 |
| 276 /** |
| 266 * Focuses on input element. | 277 * Focuses on input element. |
| 267 */ | 278 */ |
| 268 focusInput: function() { | 279 focusInput: function() { |
| 269 if (!this.isGuest) { | 280 if (!this.isGuest) { |
| 270 var needSignin = this.needGaiaSignin; | 281 var needSignin = this.needGaiaSignin; |
| 271 this.signinButtonElement.hidden = !needSignin; | 282 this.signinButtonElement.hidden = !needSignin; |
| 272 this.passwordElement.hidden = needSignin; | 283 this.passwordElement.hidden = needSignin; |
| 273 } | 284 } |
| 274 this.mainInput.focus(); | 285 this.mainInput.focus(); |
| 275 }, | 286 }, |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 /** | 604 /** |
| 594 * Shows signin UI. | 605 * Shows signin UI. |
| 595 * @param {string} email Email for signin UI. | 606 * @param {string} email Email for signin UI. |
| 596 */ | 607 */ |
| 597 showSigninUI: function(email) { | 608 showSigninUI: function(email) { |
| 598 this.rowEnabled = false; | 609 this.rowEnabled = false; |
| 599 Oobe.showSigninUI(email); | 610 Oobe.showSigninUI(email); |
| 600 }, | 611 }, |
| 601 | 612 |
| 602 /** | 613 /** |
| 614 * Updates current image of a user. |
| 615 * @param {string} email Email of the user for which to update the image. |
| 616 * @public |
| 617 */ |
| 618 updateUserImage: function(email) { |
| 619 for (var i = 0; i < this.pods.length; ++i) { |
| 620 if (this.pods[i].user.emailAddress == email) |
| 621 this.pods[i].updateUserImage(); |
| 622 } |
| 623 }, |
| 624 |
| 625 /** |
| 603 * Handler of click event. | 626 * Handler of click event. |
| 604 * @param {Event} e Click Event object. | 627 * @param {Event} e Click Event object. |
| 605 * @private | 628 * @private |
| 606 */ | 629 */ |
| 607 handleClick_: function(e) { | 630 handleClick_: function(e) { |
| 608 if (!this.rowEnabled) | 631 if (!this.rowEnabled) |
| 609 return; | 632 return; |
| 610 // Clears focus if not clicked on a pod. | 633 // Clears focus if not clicked on a pod. |
| 611 if (e.target.parentNode != this && | 634 if (e.target.parentNode != this && |
| 612 e.target.parentNode.parentNode != this) | 635 e.target.parentNode.parentNode != this) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 this.ownerDocument.removeEventListener( | 720 this.ownerDocument.removeEventListener( |
| 698 event, this.listeners_[event][0], this.listeners_[event][1]); | 721 event, this.listeners_[event][0], this.listeners_[event][1]); |
| 699 } | 722 } |
| 700 } | 723 } |
| 701 }; | 724 }; |
| 702 | 725 |
| 703 return { | 726 return { |
| 704 PodRow: PodRow | 727 PodRow: PodRow |
| 705 }; | 728 }; |
| 706 }); | 729 }); |
| OLD | NEW |