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
3 // found in the LICENSE file.
6 var DEFAULT_EMAIL_DOMAIN
= '@gmail.com';
17 enterpriseInfo
: String
,
25 * https://github.com/PolymerElements/neon-animation/issues/32
26 * TODO(dzhioev): Remove when fixed in Polymer.
28 var pages
= this.$.animatedPages
;
29 delete pages
._squelchNextFinishEvent
;
30 Object
.defineProperty(pages
, '_squelchNextFinishEvent',
31 { get: function() { return false; } });
34 onAnimationFinish_: function() {
35 this.$.backButton
.hidden
= this.isEmailSectionActive_();
40 if (this.isEmailSectionActive_())
41 this.$.emailInput
.focus();
43 this.$.passwordInput
.focus();
46 onForgotPasswordClicked_: function() {
47 this.$.forgotPasswordDlg
.fitInto
= this;
49 this.$.forgotPasswordDlg
.open();
50 this.$.passwordCard
.classList
.add('full-disabled');
51 this.$.forgotPasswordDlg
.focus();
54 onDialogOverlayClosed_: function() {
55 this.disabled
= false;
56 this.$.passwordCard
.classList
.remove('full-disabled');
59 setEmail: function(email
) {
62 email
= email
.replace(this.emailDomain
, '');
63 this.switchToPasswordCard(email
);
64 this.$.passwordInput
.isInvalid
= true;
66 this.$.emailInput
.value
= '';
67 this.switchToEmailCard();
72 this.$.backButton
.hidden
= true;
73 this.switchToEmailCard();
77 return !!document
.querySelector('html[dir=rtl]');
80 isEmailSectionActive_: function() {
81 return this.$.animatedPages
.selected
== 'emailSection';
85 this.$.passwordInput
.value
= '';
86 this.$.passwordInput
.isInvalid
= false;
87 this.$.emailInput
.isInvalid
= false;
88 if (this.isEmailSectionActive_())
90 this.$.animatedPages
.entryAnimation
=
91 'slide-from-' + (this.isRTL_() ? 'right' : 'left') + '-animation';
92 this.$.animatedPages
.exitAnimation
=
93 'slide-' + (this.isRTL_() ? 'left' : 'right') + '-animation';
94 this.$.animatedPages
.selected
= 'emailSection';
97 switchToPasswordCard(email
) {
98 this.$.emailInput
.value
= email
;
99 if (email
.indexOf('@') === -1) {
100 if (this.emailDomain
)
101 email
= email
+ this.emailDomain
;
103 email
= email
+ DEFAULT_EMAIL_DOMAIN
;
105 this.$.passwordHeader
.email
= email
;
106 if (!this.isEmailSectionActive_())
108 this.$.animatedPages
.entryAnimation
=
109 'slide-from-' + (this.isRTL_() ? 'left' : 'right') + '-animation';
110 this.$.animatedPages
.exitAnimation
=
111 'slide-' + (this.isRTL_() ? 'right' : 'left') + '-animation';
112 this.$.animatedPages
.selected
= 'passwordSection';
115 onEmailSubmitted_: function() {
116 if (this.$.emailInput
.checkValidity())
117 this.switchToPasswordCard(this.$.emailInput
.value
);
119 this.$.emailInput
.focus();
122 onPasswordSubmitted_: function() {
123 if (!this.$.passwordInput
.checkValidity())
127 'email': this.$.passwordHeader
.email
,
128 'password': this.$.passwordInput
.value
130 this.$.passwordInput
.value
= '';
131 this.fire('authCompleted', msg
);