| OLD | NEW |
| 1 /* Copyright 2015 The Chromium Authors. All rights reserved. | 1 /* Copyright 2015 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 Polymer('offline-gaia', (function() { | 6 Polymer('offline-gaia', (function() { |
| 7 var DEFAULT_EMAIL_DOMAIN = '@gmail.com'; | 7 var DEFAULT_EMAIL_DOMAIN = '@gmail.com'; |
| 8 | 8 |
| 9 return { | 9 return { |
| 10 onTransitionEnd: function() { | 10 onTransitionEnd: function() { |
| 11 this.focus(); | 11 this.focus(); |
| 12 }, | 12 }, |
| 13 | 13 |
| 14 focus: function() { | 14 focus: function() { |
| 15 if (this.$.animatedPages.selected == 0) | 15 if (this.$.animatedPages.selected == 'emailSection') |
| 16 this.$.emailInput.focus(); | 16 this.$.emailInput.focus(); |
| 17 else | 17 else |
| 18 this.$.passwordInput.focus(); | 18 this.$.passwordInput.focus(); |
| 19 }, | 19 }, |
| 20 | 20 |
| 21 onForgotPasswordClicked: function() { | 21 onForgotPasswordClicked: function() { |
| 22 this.$.forgotPasswordDlg.toggle(); | 22 this.$.forgotPasswordDlg.toggle(); |
| 23 }, | 23 }, |
| 24 | 24 |
| 25 onForgotPasswordKeyDown: function(e) { | 25 onForgotPasswordKeyDown: function(e) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 'password': this.$.passwordInput.inputValue | 54 'password': this.$.passwordInput.inputValue |
| 55 }; | 55 }; |
| 56 this.$.passwordInput.inputValue = ''; | 56 this.$.passwordInput.inputValue = ''; |
| 57 this.fire('authCompleted', msg); | 57 this.fire('authCompleted', msg); |
| 58 } | 58 } |
| 59 }.bind(this)); | 59 }.bind(this)); |
| 60 | 60 |
| 61 }, | 61 }, |
| 62 | 62 |
| 63 setEmail: function(email) { | 63 setEmail: function(email) { |
| 64 // Reorder elements for proper animation for rtl languages. |
| 65 if (document.querySelector('html[dir=rtl]')) { |
| 66 this.$.emailSection.parentNode.insertBefore(this.$.passwordSection, |
| 67 this.$.emailSection); |
| 68 } |
| 64 if (email) { | 69 if (email) { |
| 65 if (this.emailDomain) | 70 if (this.emailDomain) |
| 66 email = email.replace(this.emailDomain, ''); | 71 email = email.replace(this.emailDomain, ''); |
| 67 this.switchToPasswordCard(email); | 72 this.switchToPasswordCard(email); |
| 68 this.$.passwordInput.setValid(false); | 73 this.$.passwordInput.setValid(false); |
| 69 } else { | 74 } else { |
| 70 this.$.emailInput.inputValue = ''; | 75 this.$.emailInput.inputValue = ''; |
| 71 this.switchToEmailCard(); | 76 this.switchToEmailCard(); |
| 72 } | 77 } |
| 73 }, | 78 }, |
| 74 | 79 |
| 75 onBack: function() { | 80 onBack: function() { |
| 76 this.switchToEmailCard(); | 81 this.switchToEmailCard(); |
| 77 }, | 82 }, |
| 78 | 83 |
| 79 switchToEmailCard() { | 84 switchToEmailCard() { |
| 80 this.$.passwordInput.inputValue = ''; | 85 this.$.passwordInput.inputValue = ''; |
| 81 this.$.passwordInput.setValid(true); | 86 this.$.passwordInput.setValid(true); |
| 82 this.$.emailInput.setValid(true); | 87 this.$.emailInput.setValid(true); |
| 83 this.$.backButton.hidden = true; | 88 this.$.backButton.hidden = true; |
| 84 this.$.animatedPages.selected = 0; | 89 this.$.animatedPages.selected = 'emailSection'; |
| 85 }, | 90 }, |
| 86 | 91 |
| 87 switchToPasswordCard(email) { | 92 switchToPasswordCard(email) { |
| 88 this.$.emailInput.inputValue = email; | 93 this.$.emailInput.inputValue = email; |
| 89 if (email.indexOf('@') === -1) { | 94 if (email.indexOf('@') === -1) { |
| 90 if (this.emailDomain) | 95 if (this.emailDomain) |
| 91 email = email + this.emailDomain; | 96 email = email + this.emailDomain; |
| 92 else | 97 else |
| 93 email = email + DEFAULT_EMAIL_DOMAIN; | 98 email = email + DEFAULT_EMAIL_DOMAIN; |
| 94 } | 99 } |
| 95 this.$.passwordHeader.email = email; | 100 this.$.passwordHeader.email = email; |
| 96 this.$.backButton.hidden = false; | 101 this.$.backButton.hidden = false; |
| 97 this.$.animatedPages.selected = 1; | 102 this.$.animatedPages.selected = 'passwordSection'; |
| 98 } | 103 } |
| 99 }; | 104 }; |
| 100 })()); | 105 })()); |
| OLD | NEW |