Skip to content

Commit c29000e

Browse files
prakhar1989bojeil-google
authored andcommitted
incorporated PR feedback: selectively calling name element init
1 parent cc097c8 commit c29000e

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

javascript/ui/element/name.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ element.name.validate_ = function(nameElement, errorElement) {
7676
element.name.initNameElement = function() {
7777
var nameElement = element.name.getNameElement.call(this);
7878
var errorElement = element.name.getNameErrorElement.call(this);
79-
if (nameElement && errorElement) {
80-
element.listenForInputEvent(this, nameElement, function(e) {
81-
// Clear but not show error on-the-fly.
82-
if (element.isShown(errorElement)) {
83-
element.setValid(nameElement, true);
84-
element.hide(errorElement);
85-
}
86-
});
87-
}
79+
element.listenForInputEvent(this, nameElement, function(e) {
80+
// Clear but not show error on-the-fly.
81+
if (element.isShown(errorElement)) {
82+
element.setValid(nameElement, true);
83+
element.hide(errorElement);
84+
}
85+
});
8886
};
8987

9088

javascript/ui/page/passwordsignup.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ goog.require('firebaseui.auth.ui.page.Base');
3131
/**
3232
* Password sign-up UI component.
3333
* @param {?string} tosUrl The ToS URL.
34-
* @param {bool} showDisplayName Whether to show the display name.
34+
* @param {boolean} showDisplayName Whether to show the display name.
3535
* @param {function()} onSubmitClick Callback to invoke when the submit button
3636
* is clicked.
3737
* @param {function()=} opt_onCancelClick Callback to invoke when the cancel
@@ -65,6 +65,7 @@ firebaseui.auth.ui.page.PasswordSignUp = function(
6565
'passwordSignUp');
6666
this.onSubmitClick_ = onSubmitClick;
6767
this.onCancelClick_ = opt_onCancelClick;
68+
this.showDisplayName_ = showDisplayName;
6869
};
6970
goog.inherits(firebaseui.auth.ui.page.PasswordSignUp,
7071
firebaseui.auth.ui.page.Base);
@@ -73,7 +74,9 @@ goog.inherits(firebaseui.auth.ui.page.PasswordSignUp,
7374
/** @override */
7475
firebaseui.auth.ui.page.PasswordSignUp.prototype.enterDocument = function() {
7576
this.initEmailElement();
76-
this.initNameElement();
77+
if (this.showDisplayName_) {
78+
this.initNameElement();
79+
}
7780
this.initNewPasswordElement();
7881
this.initFormElement(this.onSubmitClick_, this.onCancelClick_);
7982
this.setupFocus_();
@@ -95,8 +98,12 @@ firebaseui.auth.ui.page.PasswordSignUp.prototype.disposeInternal = function() {
9598
*/
9699
firebaseui.auth.ui.page.PasswordSignUp.prototype.setupFocus_ = function() {
97100
// Focus order.
98-
this.focusToNextOnEnter(this.getEmailElement(), this.getNameElement());
99-
this.focusToNextOnEnter(this.getNameElement(), this.getNewPasswordElement());
101+
if (this.showDisplayName_) {
102+
this.focusToNextOnEnter(this.getEmailElement(), this.getNameElement());
103+
this.focusToNextOnEnter(this.getNameElement(), this.getNewPasswordElement());
104+
} else {
105+
this.focusToNextOnEnter(this.getEmailElement(), this.getNewPasswordElement());
106+
}
100107

101108
// On enter in password element.
102109
// TODO: Investigate why the compiler complains about onSubmitClick_ being
@@ -108,7 +115,8 @@ firebaseui.auth.ui.page.PasswordSignUp.prototype.setupFocus_ = function() {
108115
// Auto focus.
109116
if (!firebaseui.auth.ui.element.getInputValue(this.getEmailElement())) {
110117
this.getEmailElement().focus();
111-
} else if (!firebaseui.auth.ui.element.getInputValue(this.getNameElement())) {
118+
} else if (this.showDisplayName_ &&
119+
!firebaseui.auth.ui.element.getInputValue(this.getNameElement())) {
112120
this.getNameElement().focus();
113121
} else {
114122
this.getNewPasswordElement().focus();

0 commit comments

Comments
 (0)