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('saml-confirm-password', { | 5 Polymer({ |
7 onClose: function() { | 6 is: 'saml-confirm-password', |
8 this.disabled = true; | 7 |
9 this.$.cancelConfirmDlg.toggle(); | 8 properties: { |
| 9 email: String, |
| 10 |
| 11 disabled: { |
| 12 type: Boolean, |
| 13 value: false, |
| 14 observer: 'disabledChanged_' |
| 15 } |
10 }, | 16 }, |
11 | 17 |
12 onConfirmCancel: function() { | 18 ready: function() { |
13 this.fire('cancel'); | 19 /** |
| 20 * Workaround for |
| 21 * https://github.com/PolymerElements/neon-animation/issues/32 |
| 22 * TODO(dzhioev): Remove when fixed in Polymer. |
| 23 */ |
| 24 var pages = this.$.animatedPages; |
| 25 delete pages._squelchNextFinishEvent; |
| 26 Object.defineProperty(pages, '_squelchNextFinishEvent', |
| 27 { get: function() { return false; } }); |
14 }, | 28 }, |
15 | 29 |
16 reset: function() { | 30 reset: function() { |
17 this.$.cancelConfirmDlg.close(); | 31 this.$.cancelConfirmDlg.close(); |
18 this.disabled = false; | 32 this.disabled = false; |
19 this.$.closeButton.hidden = false; | 33 this.$.closeButton.hidden = false; |
20 this.$.animatedPages.selected = 0; | 34 if (this.$.animatedPages.selected != 0) |
| 35 this.$.animatedPages.selected = 0; |
21 this.$.passwordInput.value = ''; | 36 this.$.passwordInput.value = ''; |
22 }, | 37 }, |
23 | 38 |
24 invalidate: function() { | 39 invalidate: function() { |
25 this.$.passwordInput.isInvalid = true; | 40 this.$.passwordInput.isInvalid = true; |
26 }, | 41 }, |
27 | 42 |
28 focus: function() { | 43 focus: function() { |
29 if (this.$.animatedPages.selected == 0) | 44 if (this.$.animatedPages.selected == 0) |
30 this.$.passwordInput.focus(); | 45 this.$.passwordInput.focus(); |
31 }, | 46 }, |
32 | 47 |
33 onPasswordSubmitted: function() { | 48 onClose_: function() { |
34 var inputPassword = this.$.passwordInput.value; | 49 this.disabled = true; |
35 this.$.passwordInput.value = ''; | 50 this.$.cancelConfirmDlg.fitInto = this; |
36 if (!inputPassword) { | 51 this.$.cancelConfirmDlg.open(); |
37 this.invalidate(); | |
38 } else { | |
39 this.$.animatedPages.selected += 1; | |
40 this.$.closeButton.hidden = true; | |
41 this.fire('passwordEnter', {password: inputPassword}); | |
42 } | |
43 }, | 52 }, |
44 | 53 |
45 set disabled(value) { | 54 onConfirmCancel_: function() { |
46 this.$.confirmPasswordCard.classList.toggle('full-disabled', value); | 55 this.fire('cancel'); |
47 this.$.inputForm.disabled = value; | |
48 this.$.closeButton.disabled = value; | |
49 }, | 56 }, |
50 | 57 |
51 ready: function() { | 58 onPasswordSubmitted_: function() { |
52 this.$.cancelConfirmDlg.addEventListener('core-overlay-close-completed', | 59 if (!this.$.passwordInput.checkValidity()) |
53 function() { | 60 return; |
54 this.disabled = false; | 61 this.$.animatedPages.selected = 1; |
55 }.bind(this)); | 62 this.$.closeButton.hidden = true; |
| 63 this.fire('passwordEnter', {password: this.$.passwordInput.value}); |
| 64 }, |
| 65 |
| 66 onDialogOverlayClosed_: function() { |
| 67 this.disabled = false; |
| 68 }, |
| 69 |
| 70 disabledChanged_: function(disabled) { |
| 71 this.$.confirmPasswordCard.classList.toggle('full-disabled', disabled); |
| 72 }, |
| 73 |
| 74 onAnimationFinish_: function() { |
| 75 if (this.$.animatedPages.selected == 1) |
| 76 this.$.passwordInput.value = ''; |
56 } | 77 } |
57 }); | 78 }); |
OLD | NEW |