Start to hook up each of the screen modules. #13
Conversation
* Add Utils.once which is a one time event handler.
|
@shane-tomlinson Hi Shane! I'll try to take a look today to the code!!!! :) |
| DIALOG_SELECTOR = '#fxa-error-overlay', | ||
| TITLE_SELECTOR = '#fxa-error-title', | ||
| MESSAGE_SELECTOR = '#fxa-error-msg', | ||
| CLOSE_BUTTON_SELECTOR = '#fxa-error-ok'; |
borjasalguero
Nov 11, 2013
Owner
In this case I would avoid the use of $. Instead you could use the following idea:
https://github.com/mozilla-b2g/gaia/blob/master/apps/sms/js/message_manager.js#L38
With this approach you are caching DOM elements (you can execute this in the init method), and we would adapt your code to Gaia code style! :)
In this case I would avoid the use of $. Instead you could use the following idea:
https://github.com/mozilla-b2g/gaia/blob/master/apps/sms/js/message_manager.js#L38
With this approach you are caching DOM elements (you can execute this in the init method), and we would adapt your code to Gaia code style! :)
| <a id="fxa-summary-email"></a>, your Firefox Account is ready to go! | ||
| </p> | ||
| <p data-l10n-id="fxa-signin-success-use-services"> | ||
| Now you can use <span id="ff_account--success-email">cookies</span> to access services like Marketplace and Where’s My Fox. |
borjasalguero
Nov 11, 2013
Owner
In this case we should avoid the mix of hash & underscore. In this case this would be ffaccount-success-email to follow Gaia code guidelines.
In this case we should avoid the mix of hash & underscore. In this case this would be ffaccount-success-email to follow Gaia code guidelines.
| @@ -6,6 +6,7 @@ | |||
| <link href="../shared/style/headers.css" rel="stylesheet" type="text/css"> | |||
| <link href="../shared/style/switches.css" rel="stylesheet" type="text/css"> | |||
| <link href="../shared/style/buttons.css" rel="stylesheet" type="text/css"> | |||
| <link href="../shared/style/confirm.css" rel="stylesheet" type="text/css"> | |||
borjasalguero
Nov 11, 2013
Owner
Why do we need confirm?
Why do we need confirm?
| <script src="shared/js/lazy_loader.js"></script> | ||
| <script src="shared/js/l10n.js"></script> | ||
| <script src="js/utils.js"></script> | ||
| <script src="js/fxam_overlay.js"></script> | ||
| <script src="js/fxam_error_overlay.js"></script> |
borjasalguero
Nov 11, 2013
Owner
We should add defer, and a LazyLoading of the elements.
We should add defer, and a LazyLoading of the elements.
|
|
||
|
|
||
| <!-- state modules --> | ||
| <script src="js/fxam_intro.js"></script> |
borjasalguero
Nov 11, 2013
Owner
Same here, and this would be one of the key points. As we don't know the entire set of steps from the beginning, we need to lazy load the steps. So imagine that we are on the fist step fxam_intro.js, when clicking next we would lazyload this code, only if needed (saving a lot of memory). We would need something like https://github.com/mozilla-b2g/gaia/blob/master/apps/sms/js/startup.js#L100 for loading the module asap.
Same here, and this would be one of the key points. As we don't know the entire set of steps from the beginning, we need to lazy load the steps. So imagine that we are on the fist step fxam_intro.js, when clicking next we would lazyload this code, only if needed (saving a lot of memory). We would need something like https://github.com/mozilla-b2g/gaia/blob/master/apps/sms/js/startup.js#L100 for loading the module asap.
|
|
||
|
|
||
| <!-- Error message overlay --> | ||
| <form role="dialog" data-type="confirm" id="fxa-error-overlay" class="fade-in"> |
borjasalguero
Nov 11, 2013
Owner
Could be a simple alert?
Could be a simple alert?
shane-tomlinson
Nov 12, 2013
Author
I tried an alert and nothing was displayed. This dialog comes from the FTU code itself, so I thought I would keep it consistent. This is also why confirm.css is loaded.
I tried an alert and nothing was displayed. This dialog comes from the FTU code itself, so I thought I would keep it consistent. This is also why confirm.css is loaded.
| * Module checks the validity of an email address, and if valid, | ||
| * determine which screen to go to next. | ||
| */ | ||
| FxaModuleEnterEmail = (function() { |
borjasalguero
Nov 11, 2013
Owner
As all modules have the same structure, why dont we create a Module object, and FxaModuleEnterEmail will extend basic Module object. Wdyt? With this approach we would have a clear structure of a Module.
As all modules have the same structure, why dont we create a Module object, and FxaModuleEnterEmail will extend basic Module object. Wdyt? With this approach we would have a clear structure of a Module.
shane-tomlinson
Nov 12, 2013
Author
Done.
Done.
| } | ||
|
|
||
| function showInvalidEmail() { | ||
| // TODO - Hook up to i18n |
borjasalguero
Nov 11, 2013
Owner
Let's create l10n entities! :)
For loading them we use something lie var _ = navigator.mozL10n.get;, so asking for the label l10n-email would be _('l10n-email') :)
Let's create l10n entities! :)
For loading them we use something lie var _ = navigator.mozL10n.get;, so asking for the label l10n-email would be _('l10n-email') :)
| // User can abort FTE without entering an email address. | ||
| if ( ! email) return done(FxaModuleStates.DONE); | ||
|
|
||
| console.log("entered email", email); |
borjasalguero
Nov 11, 2013
Owner
Remove logs! :)
Remove logs! :)
| }, 500); | ||
| } | ||
|
|
||
| var Module = { |
borjasalguero
Nov 11, 2013
Owner
Probably this could be the structure of the Module object should have, and the structure that all the modules should inherit
Probably this could be the structure of the Module object should have, and the structure that all the modules should inherit
| @@ -0,0 +1,38 @@ | |||
| var FxaModuleErrorOverlay = (function() { | |||
borjasalguero
Nov 11, 2013
Owner
Could we change this code following same structure as https://github.com/borjasalguero/gaia/blob/fxa_proposal_complete/apps/system/fxa/js/fxam_overlay.js ?
Could we change this code following same structure as https://github.com/borjasalguero/gaia/blob/fxa_proposal_complete/apps/system/fxa/js/fxam_overlay.js ?
| show: function fxam_error_overlay_show(title, message) { | ||
| var overlayEl = $(DIALOG_SELECTOR); | ||
| var titleEl = $(TITLE_SELECTOR); | ||
| var messageEl = $(MESSAGE_SELECTOR); |
borjasalguero
Nov 11, 2013
Owner
This is a general thing, but caching element is needed in all JS classes.
This is a general thing, but caching element is needed in all JS classes.
| @@ -9,42 +10,30 @@ var FxaModuleNavigation = { | |||
| // Load view | |||
| LazyLoader._js('view/view_' + flow + '.js', function loaded() { | |||
| this.view = View; | |||
| this.maxSteps = Object.keys(View).length; | |||
| this.currentStep = this.view[0]; | |||
| this.maxSteps = View.length; | |||
borjasalguero
Nov 11, 2013
Owner
If I'm not wrong, with steps approach we dont know actually the max number of steps, because if sign in & sign up differs in some way (imagine that UX adds a new step in the middle for sign up), this could not work... Maybe we should think how to deal with the navigation without using maxSteps... :(
If I'm not wrong, with steps approach we dont know actually the max number of steps, because if sign in & sign up differs in some way (imagine that UX adds a new step in the middle for sign up), this could not work... Maybe we should think how to deal with the navigation without using maxSteps... :(
|
When testing, in the email step, I have the following: :(. Furthermore when testing I can not use the keyboard in this step, and I dont know why (previously was working). Regarding the new code, main things to be fixed are:
That's all from my side. If I can help you with this let me know and I will send you a PR to your branch! Thanks for your great job! :) |
* Convert fxam_states to contain both the id of the element to load plus the name of the module to initialize. * The template element contains script elements which are scripts to lazy load.
Lazy load the FxA js
* remove $ and declaring all the selectors at the top of the file * in init, call importElements.
Start to hook up each of the screen modules.
@borjasalguero, @sergi, @OlavHN - I have taken the code that I wrote during the Madrid work week and ported it here, attempting to follow naming conventions as much as possible. There is a lot of duplication in the modules - for instance set-password and enter-password are very similar. I did this intentionally to come up with approaches tailored to the screen and then create a generalization out of those approaches. I am not doing any lazy loading of the modules yet, but this should be possible.
I was able to simplify fxam_navigation.js a bit, and the ability to go forward and back through the states works well.
Items that still need completed:
To test, some values are hard coded:
newuser@newuser.com.password