Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: chrome/browser/resources/chromeos/login/offline_gaia.js

Issue 1179323005: Polymer upgraded to 1.0 in login flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@polymer_pre_migration
Patch Set: Comments addressed. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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('offline-gaia', (function() { 5 Polymer((function() {
7 var DEFAULT_EMAIL_DOMAIN = '@gmail.com'; 6 var DEFAULT_EMAIL_DOMAIN = '@gmail.com';
8 7
9 return { 8 return {
10 onTransitionEnd: function() { 9 is: 'offline-gaia',
10
11 properties: {
12 disabled: {
13 type: Boolean,
14 value: false
15 },
16
17 enterpriseInfo: String,
18
19 emailDomain: String
20 },
21
22 ready: function() {
23 /**
24 * Workaround for
25 * https://github.com/PolymerElements/neon-animation/issues/32
26 * TODO(dzhioev): Remove when fixed in Polymer.
27 */
28 var pages = this.$.animatedPages;
29 delete pages._squelchNextFinishEvent;
30 Object.defineProperty(pages, '_squelchNextFinishEvent',
31 { get: function() { return false; } });
32 },
33
34 onAnimationFinish_: function() {
35 this.$.backButton.hidden = this.isEmailSectionActive_();
11 this.focus(); 36 this.focus();
12 }, 37 },
13 38
14 focus: function() { 39 focus: function() {
15 if (this.$.animatedPages.selected == 'emailSection') 40 if (this.isEmailSectionActive_())
16 this.$.emailInput.focus(); 41 this.$.emailInput.focus();
17 else 42 else
18 this.$.passwordInput.focus(); 43 this.$.passwordInput.focus();
19 }, 44 },
20 45
21 onForgotPasswordClicked: function() { 46 onForgotPasswordClicked_: function() {
22 this.$.forgotPasswordDlg.toggle(); 47 this.$.forgotPasswordDlg.fitInto = this;
48 this.disabled = true;
49 this.$.forgotPasswordDlg.open();
50 this.$.passwordCard.classList.add('full-disabled');
51 this.$.forgotPasswordDlg.focus();
23 }, 52 },
24 53
25 onForgotPasswordKeyDown: function(e) { 54 onDialogOverlayClosed_: function() {
26 if (e.keyCode == 13 || e.keyCode == 32) 55 this.disabled = false;
27 return this.onForgotPasswordClicked(); 56 this.$.passwordCard.classList.remove('full-disabled');
28 },
29
30 onKeyDownOnDialog: function(e) {
31 if (e.keyCode == 27) {
32 // Esc
33 this.$.forgotPasswordDlg.close();
34 e.preventDefault();
35 }
36 }, 57 },
37 58
38 setEmail: function(email) { 59 setEmail: function(email) {
39 // Reorder elements for proper animation for rtl languages.
40 if (document.querySelector('html[dir=rtl]')) {
41 this.$.emailSection.parentNode.insertBefore(this.$.passwordSection,
42 this.$.emailSection);
43 }
44 if (email) { 60 if (email) {
45 if (this.emailDomain) 61 if (this.emailDomain)
46 email = email.replace(this.emailDomain, ''); 62 email = email.replace(this.emailDomain, '');
47 this.switchToPasswordCard(email); 63 this.switchToPasswordCard(email);
48 this.$.passwordInput.isInvalid = true; 64 this.$.passwordInput.isInvalid = true;
49 } else { 65 } else {
50 this.$.emailInput.value = ''; 66 this.$.emailInput.value = '';
51 this.switchToEmailCard(); 67 this.switchToEmailCard();
52 } 68 }
53 }, 69 },
54 70
55 onBack: function() { 71 onBack_: function() {
72 this.$.backButton.hidden = true;
56 this.switchToEmailCard(); 73 this.switchToEmailCard();
57 }, 74 },
58 75
76 isRTL_: function() {
77 return !!document.querySelector('html[dir=rtl]');
78 },
79
80 isEmailSectionActive_: function() {
81 return this.$.animatedPages.selected == 'emailSection';
82 },
83
59 switchToEmailCard() { 84 switchToEmailCard() {
60 this.$.passwordInput.value = ''; 85 this.$.passwordInput.value = '';
61 this.$.passwordInput.isInvalid = false; 86 this.$.passwordInput.isInvalid = false;
62 this.$.emailInput.isInvalid = false; 87 this.$.emailInput.isInvalid = false;
63 this.$.backButton.hidden = true; 88 if (this.isEmailSectionActive_())
89 return;
90 this.$.animatedPages.entryAnimation =
91 'slide-from-' + (this.isRTL_() ? 'right' : 'left') + '-animation';
92 this.$.animatedPages.exitAnimation =
93 'slide-' + (this.isRTL_() ? 'left' : 'right') + '-animation';
64 this.$.animatedPages.selected = 'emailSection'; 94 this.$.animatedPages.selected = 'emailSection';
65 }, 95 },
66 96
67 switchToPasswordCard(email) { 97 switchToPasswordCard(email) {
68 this.$.emailInput.value = email; 98 this.$.emailInput.value = email;
69 if (email.indexOf('@') === -1) { 99 if (email.indexOf('@') === -1) {
70 if (this.emailDomain) 100 if (this.emailDomain)
71 email = email + this.emailDomain; 101 email = email + this.emailDomain;
72 else 102 else
73 email = email + DEFAULT_EMAIL_DOMAIN; 103 email = email + DEFAULT_EMAIL_DOMAIN;
74 } 104 }
75 this.$.passwordHeader.email = email; 105 this.$.passwordHeader.email = email;
76 this.$.backButton.hidden = false; 106 if (!this.isEmailSectionActive_())
107 return;
108 this.$.animatedPages.entryAnimation =
109 'slide-from-' + (this.isRTL_() ? 'left' : 'right') + '-animation';
110 this.$.animatedPages.exitAnimation =
111 'slide-' + (this.isRTL_() ? 'right' : 'left') + '-animation';
77 this.$.animatedPages.selected = 'passwordSection'; 112 this.$.animatedPages.selected = 'passwordSection';
78 }, 113 },
79 114
80 onEmailSubmitted: function() { 115 onEmailSubmitted_: function() {
81 if (this.$.emailInput.checkValidity()) 116 if (this.$.emailInput.checkValidity())
82 this.switchToPasswordCard(this.$.emailInput.value); 117 this.switchToPasswordCard(this.$.emailInput.value);
83 else 118 else
84 this.$.emailInput.focus(); 119 this.$.emailInput.focus();
85 }, 120 },
86 121
87 onPasswordSubmitted: function() { 122 onPasswordSubmitted_: function() {
88 if (!this.$.passwordInput.checkValidity()) 123 if (!this.$.passwordInput.checkValidity())
89 return; 124 return;
90 var msg = { 125 var msg = {
91 'useOffline': true, 126 'useOffline': true,
92 'email': this.$.passwordHeader.email, 127 'email': this.$.passwordHeader.email,
93 'password': this.$.passwordInput.value 128 'password': this.$.passwordInput.value
94 }; 129 };
95 this.$.passwordInput.value = ''; 130 this.$.passwordInput.value = '';
96 this.fire('authCompleted', msg); 131 this.fire('authCompleted', msg);
97 } 132 }
98 }; 133 };
99 })()); 134 })());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698