| 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 */ | |
| 5 | 4 |
| 6 Polymer('gaia-password-changed', { | 5 Polymer({ |
| 6 is: 'gaia-password-changed', |
| 7 |
| 8 properties: { |
| 9 email: String, |
| 10 |
| 11 disabled: { |
| 12 type: Boolean, |
| 13 value: false |
| 14 } |
| 15 }, |
| 16 |
| 17 ready: function() { |
| 18 /** |
| 19 * Workaround for |
| 20 * https://github.com/PolymerElements/neon-animation/issues/32 |
| 21 * TODO(dzhioev): Remove when fixed in Polymer. |
| 22 */ |
| 23 var pages = this.$.animatedPages; |
| 24 delete pages._squelchNextFinishEvent; |
| 25 Object.defineProperty(pages, '_squelchNextFinishEvent', |
| 26 { get: function() { return false; } }); |
| 27 }, |
| 28 |
| 7 invalidate: function() { | 29 invalidate: function() { |
| 8 this.$.oldPasswordInput.isInvalid = true; | 30 this.$.oldPasswordInput.isInvalid = true; |
| 9 }, | 31 }, |
| 10 | 32 |
| 11 reset: function() { | 33 reset: function() { |
| 12 this.$.animatedPages.selected = 0; | 34 this.$.animatedPages.selected = 0; |
| 13 this.clearPassword(); | 35 this.clearPassword(); |
| 14 this.$.oldPasswordInput.isInvalid = false; | 36 this.$.oldPasswordInput.isInvalid = false; |
| 15 this.disabled = false; | 37 this.disabled = false; |
| 16 this.$.closeButton.hidden = false; | 38 this.$.closeButton.hidden = false; |
| 17 this.$.oldPasswordCard.classList.remove('disabled'); | 39 this.$.oldPasswordCard.classList.remove('disabled'); |
| 18 }, | 40 }, |
| 19 | 41 |
| 20 ready: function() { | |
| 21 this.$.oldPasswordInputForm.addEventListener('submit', function() { | |
| 22 var inputPassword = this.$.oldPasswordInput.value; | |
| 23 if (!inputPassword) | |
| 24 this.invalidate(); | |
| 25 else { | |
| 26 this.$.oldPasswordCard.classList.add('disabled'); | |
| 27 this.disabled = true; | |
| 28 this.fire('passwordEnter', {password: inputPassword}); | |
| 29 } | |
| 30 }.bind(this)); | |
| 31 }, | |
| 32 | 42 |
| 33 focus: function() { | 43 focus: function() { |
| 34 if (this.$.animatedPages.selected == 0) | 44 if (this.$.animatedPages.selected == 0) |
| 35 this.$.oldPasswordInput.focus(); | 45 this.$.oldPasswordInput.focus(); |
| 36 }, | 46 }, |
| 37 | 47 |
| 38 set disabled(value) { | 48 onPasswordSubmitted_: function() { |
| 39 this.$.oldPasswordInputForm.disabled = value; | 49 if (!this.$.oldPasswordInput.checkValidity()) |
| 50 return; |
| 51 this.$.oldPasswordCard.classList.add('disabled'); |
| 52 this.disabled = true; |
| 53 this.fire('passwordEnter', {password: this.$.oldPasswordInput.value}); |
| 40 }, | 54 }, |
| 41 | 55 |
| 42 onForgotPasswordClicked: function() { | 56 onForgotPasswordClicked_: function() { |
| 43 this.clearPassword(); | 57 this.clearPassword(); |
| 44 this.$.animatedPages.selected += 1; | 58 this.$.animatedPages.selected += 1; |
| 45 }, | 59 }, |
| 46 | 60 |
| 47 onTryAgainClicked: function() { | 61 onTryAgainClicked_: function() { |
| 48 this.$.oldPasswordInput.isInvalid = false; | 62 this.$.oldPasswordInput.isInvalid = false; |
| 49 this.$.animatedPages.selected -= 1; | 63 this.$.animatedPages.selected -= 1; |
| 50 }, | 64 }, |
| 51 | 65 |
| 52 onTransitionEnd: function() { | 66 onAnimationFinish_: function() { |
| 53 this.focus(); | 67 this.focus(); |
| 54 }, | 68 }, |
| 55 | 69 |
| 56 clearPassword: function() { | 70 clearPassword: function() { |
| 57 this.$.oldPasswordInput.value = ''; | 71 this.$.oldPasswordInput.value = ''; |
| 58 }, | 72 }, |
| 59 | 73 |
| 60 onProceedClicked: function() { | 74 onProceedClicked_: function() { |
| 61 this.disabled = true; | 75 this.disabled = true; |
| 62 this.$.closeButton.hidden = true; | 76 this.$.closeButton.hidden = true; |
| 63 this.$.animatedPages.selected = 2; | 77 this.$.animatedPages.selected = 2; |
| 64 this.fire('proceedAnyway'); | 78 this.fire('proceedAnyway'); |
| 65 }, | 79 }, |
| 66 | 80 |
| 67 onClose: function() { | 81 onClose_: function() { |
| 68 this.disabled = true; | |
| 69 this.fire('cancel'); | 82 this.fire('cancel'); |
| 70 }, | 83 } |
| 71 }); | 84 }); |
| OLD | NEW |