@@ -31,13 +31,16 @@ goog.require('goog.dom.selection');
3131 * UI component for the user to enter their email.
3232 * @param {function() } onEmailEnter Callback to invoke when enter key (or its
3333 * equivalent) is detected.
34+ * @param {function() } onCancelClick Callback to invoke when cancel button
35+ * is clicked.
3436 * @param {string= } opt_email The email to prefill.
3537 * @param {goog.dom.DomHelper= } opt_domHelper Optional DOM helper.
3638 * @constructor
3739 * @extends {firebaseui.auth.ui.page.Base }
3840 */
3941firebaseui . auth . ui . page . SignIn = function (
4042 onEmailEnter ,
43+ onCancelClick ,
4144 opt_email ,
4245 opt_domHelper ) {
4346 firebaseui . auth . ui . page . SignIn . base (
@@ -48,6 +51,7 @@ firebaseui.auth.ui.page.SignIn = function(
4851 opt_domHelper ,
4952 'signIn' ) ;
5053 this . onEmailEnter_ = onEmailEnter ;
54+ this . onCancelClick_ = onCancelClick ;
5155} ;
5256goog . inherits ( firebaseui . auth . ui . page . SignIn , firebaseui . auth . ui . page . Base ) ;
5357
@@ -56,23 +60,33 @@ goog.inherits(firebaseui.auth.ui.page.SignIn, firebaseui.auth.ui.page.Base);
5660firebaseui . auth . ui . page . SignIn . prototype . enterDocument = function ( ) {
5761 this . initEmailElement ( this . onEmailEnter_ ) ;
5862 var self = this ;
59- // Handle a click on the submit button.
60- this . initFormElement ( this . onEmailEnter_ ) ;
61- // Auto focus the email input and put the cursor at the end.
62- this . getEmailElement ( ) . focus ( ) ;
63- goog . dom . selection . setCursorPosition (
64- this . getEmailElement ( ) , ( this . getEmailElement ( ) . value || '' ) . length ) ;
63+ // Handle a click on the submit button or cancel button.
64+ this . initFormElement ( this . onEmailEnter_ , this . onCancelClick_ ) ;
65+ this . setupFocus_ ( ) ;
6566 firebaseui . auth . ui . page . SignIn . base ( this , 'enterDocument' ) ;
6667} ;
6768
6869
6970/** @override */
7071firebaseui . auth . ui . page . SignIn . prototype . disposeInternal = function ( ) {
7172 this . onEmailEnter_ = null ;
73+ this . onCancelClick_ = null ;
7274 firebaseui . auth . ui . page . SignIn . base ( this , 'disposeInternal' ) ;
7375} ;
7476
7577
78+ /**
79+ * Sets up the focus order and auto focus.
80+ * @private
81+ */
82+ firebaseui . auth . ui . page . SignIn . prototype . setupFocus_ = function ( ) {
83+ // Auto focus the email input and put the cursor at the end.
84+ this . getEmailElement ( ) . focus ( ) ;
85+ goog . dom . selection . setCursorPosition (
86+ this . getEmailElement ( ) , ( this . getEmailElement ( ) . value || '' ) . length ) ;
87+ } ;
88+
89+
7690goog . mixin (
7791 firebaseui . auth . ui . page . SignIn . prototype ,
7892 /** @lends {firebaseui.auth.ui.page.SignIn.prototype} */
@@ -92,6 +106,8 @@ goog.mixin(
92106 // For form.
93107 getSubmitElement :
94108 firebaseui . auth . ui . element . form . getSubmitElement ,
109+ getSecondaryLinkElement :
110+ firebaseui . auth . ui . element . form . getSecondaryLinkElement ,
95111 initFormElement :
96112 firebaseui . auth . ui . element . form . initFormElement
97113 } ) ;
0 commit comments