Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start to hook up each of the screen modules. #13

Merged
merged 17 commits into from Nov 12, 2013
Merged

Start to hook up each of the screen modules. #13

merged 17 commits into from Nov 12, 2013

Conversation

@shane-tomlinson
Copy link

@shane-tomlinson shane-tomlinson commented Nov 7, 2013

@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:

  • - [@borjasalguero] Hook up calls for check email, create account, authenticate account, reset password.
  • - Error screens for "password too short", "cannot sign in", "cannot create account".
  • - Ensure swiping works (hook up to onhashchange). - is this a requirement?
  • - Make the transitions more awesome. See #14
  • - Correct text needs filled in for completion screens.
  • - Reset password link needs to be hooked up. See #16
  • - Center the input elements on focus.
  • - TOS/PP agreements need to be hooked up. #27
  • - Real TOS/PP text needed.
  • - TOS/PP navigation needs to be done. (back button only) #27
  • - l10n of embedded strings for the error screens.
  • - ensure template text matches https://bug905637.bugzilla.mozilla.org/attachment.cgi?id=825368
  • - l10n of strings embedded in the templates. See #22
  • - Cleanup - is onBack needed inside of each module?
  • - Cleanup - get rid of all console messages.
  • - possible lazy loading of module JS.
  • - Lazy load the error element and JS
  • - HTML class name cleanup.
  • - Fix gjslint errors. See #18
  • - Put modules into a subdirectory
  • - Convert img tags to background images for device size/scaling.

To test, some values are hard coded:

  • To follow new user flow - enter newuser@newuser.com.
  • To follow existing user flow - enter an other email address.
  • The only acceptable password is password
@borjasalguero
Copy link
Owner

@borjasalguero borjasalguero commented Nov 8, 2013

@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';

This comment has been minimized.

@borjasalguero

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! :)

<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.

This comment has been minimized.

@borjasalguero

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.

@@ -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">

This comment has been minimized.

@borjasalguero

borjasalguero Nov 11, 2013
Owner

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>

This comment has been minimized.

@borjasalguero

borjasalguero Nov 11, 2013
Owner

We should add defer, and a LazyLoading of the elements.



<!-- state modules -->
<script src="js/fxam_intro.js"></script>

This comment has been minimized.

@borjasalguero

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.



<!-- Error message overlay -->
<form role="dialog" data-type="confirm" id="fxa-error-overlay" class="fade-in">

This comment has been minimized.

@borjasalguero

borjasalguero Nov 11, 2013
Owner

Could be a simple alert?

This comment has been minimized.

@shane-tomlinson

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.

* Module checks the validity of an email address, and if valid,
* determine which screen to go to next.
*/
FxaModuleEnterEmail = (function() {

This comment has been minimized.

@borjasalguero

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.

This comment has been minimized.

}

function showInvalidEmail() {
// TODO - Hook up to i18n

This comment has been minimized.

@borjasalguero

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') :)

// User can abort FTE without entering an email address.
if ( ! email) return done(FxaModuleStates.DONE);

console.log("entered email", email);

This comment has been minimized.

@borjasalguero

borjasalguero Nov 11, 2013
Owner

Remove logs! :)

}, 500);
}

var Module = {

This comment has been minimized.

@borjasalguero

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

@@ -0,0 +1,38 @@
var FxaModuleErrorOverlay = (function() {

This comment has been minimized.

show: function fxam_error_overlay_show(title, message) {
var overlayEl = $(DIALOG_SELECTOR);
var titleEl = $(TITLE_SELECTOR);
var messageEl = $(MESSAGE_SELECTOR);

This comment has been minimized.

@borjasalguero

borjasalguero Nov 11, 2013
Owner

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;

This comment has been minimized.

@borjasalguero

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... :(

@borjasalguero
Copy link
Owner

@borjasalguero borjasalguero commented Nov 11, 2013

When testing, in the email step, I have the following:

E/GeckoConsole( 3471): [JavaScript Error: "TypeError: step is null" {file: "app://system.gaiamobile.org/fxa/js/fxam_ui.js" line: 39}]
E/GeckoConsole( 3471): Content JS LOG at app://system.gaiamobile.org/fxa/js/fxam_ui.js:38 in FxaModuleUI.loadStep: step null 2

:(. 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:

  • Lazy load resources. Now we are loading all steps with all the JS tied to that steps. We should load step by step.
  • Inheritance: Module object. All modules/steps are clearly instances of an object Module (actually your code is following the patter, we only have to use inheritance!), so we would need to create it, and every step will be an extension of that object.
  • Cache UI elements. Avoid the use of $ and cache elements during the init method.
  • Naming. Use Gaia conventions. Avoid mix of _ and - in the same class name.
  • l10n & linting. We should ensure that Travis is going to be happy with our linting, and l10n is something that we should add as we are adding patches, because at the end is going to be a pain to come back and review all pending l10n tags!

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! :)

OlavHN and others added 7 commits Nov 12, 2013
* 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.
* remove $ and declaring all the selectors at the top of the file
* in init, call importElements.
shane-tomlinson pushed a commit that referenced this pull request Nov 12, 2013
Start to hook up each of the screen modules.
@shane-tomlinson shane-tomlinson merged commit 967c877 into borjasalguero:fxa_proposal_complete Nov 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants