@@ -31,13 +31,16 @@ goog.require('goog.dom.selection');
31
31
* UI component for the user to enter their email.
32
32
* @param {function() } onEmailEnter Callback to invoke when enter key (or its
33
33
* equivalent) is detected.
34
+ * @param {function() } onCancelClick Callback to invoke when cancel button
35
+ * is clicked.
34
36
* @param {string= } opt_email The email to prefill.
35
37
* @param {goog.dom.DomHelper= } opt_domHelper Optional DOM helper.
36
38
* @constructor
37
39
* @extends {firebaseui.auth.ui.page.Base }
38
40
*/
39
41
firebaseui . auth . ui . page . SignIn = function (
40
42
onEmailEnter ,
43
+ onCancelClick ,
41
44
opt_email ,
42
45
opt_domHelper ) {
43
46
firebaseui . auth . ui . page . SignIn . base (
@@ -48,6 +51,7 @@ firebaseui.auth.ui.page.SignIn = function(
48
51
opt_domHelper ,
49
52
'signIn' ) ;
50
53
this . onEmailEnter_ = onEmailEnter ;
54
+ this . onCancelClick_ = onCancelClick ;
51
55
} ;
52
56
goog . inherits ( firebaseui . auth . ui . page . SignIn , firebaseui . auth . ui . page . Base ) ;
53
57
@@ -56,23 +60,33 @@ goog.inherits(firebaseui.auth.ui.page.SignIn, firebaseui.auth.ui.page.Base);
56
60
firebaseui . auth . ui . page . SignIn . prototype . enterDocument = function ( ) {
57
61
this . initEmailElement ( this . onEmailEnter_ ) ;
58
62
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_ ( ) ;
65
66
firebaseui . auth . ui . page . SignIn . base ( this , 'enterDocument' ) ;
66
67
} ;
67
68
68
69
69
70
/** @override */
70
71
firebaseui . auth . ui . page . SignIn . prototype . disposeInternal = function ( ) {
71
72
this . onEmailEnter_ = null ;
73
+ this . onCancelClick_ = null ;
72
74
firebaseui . auth . ui . page . SignIn . base ( this , 'disposeInternal' ) ;
73
75
} ;
74
76
75
77
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
+
76
90
goog . mixin (
77
91
firebaseui . auth . ui . page . SignIn . prototype ,
78
92
/** @lends {firebaseui.auth.ui.page.SignIn.prototype} */
@@ -92,6 +106,8 @@ goog.mixin(
92
106
// For form.
93
107
getSubmitElement :
94
108
firebaseui . auth . ui . element . form . getSubmitElement ,
109
+ getSecondaryLinkElement :
110
+ firebaseui . auth . ui . element . form . getSecondaryLinkElement ,
95
111
initFormElement :
96
112
firebaseui . auth . ui . element . form . initFormElement
97
113
} ) ;
0 commit comments