Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
89
gaia/tv_apps/smart-system/fxa/js/screens/fxam_coppa.js
Executable file
89
gaia/tv_apps/smart-system/fxa/js/screens/fxam_coppa.js
Executable file
|
|
@ -0,0 +1,89 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* This module allow the user to select her age from a date picker and checks
|
||||
* that she is old enough to create a Firefox account. Otherwise, it shows an
|
||||
* error.
|
||||
*/
|
||||
|
||||
/* global FxaModuleUI, FxaModule, FxaModuleStates, FxaModuleNavigation */
|
||||
/* exported FxaModuleCoppa */
|
||||
|
||||
var FxaModuleCoppa = (function() {
|
||||
|
||||
var MINIMUM_AGE = 13;
|
||||
|
||||
function _populateSelect(select) {
|
||||
var currentYear = new Date().getFullYear();
|
||||
var start = currentYear - MINIMUM_AGE;
|
||||
for (var year = start; year <= currentYear; year++) {
|
||||
var option = document.createElement('option');
|
||||
option.value= year;
|
||||
if (year == start) {
|
||||
option.setAttribute('data-l10n-id', 'fxa-age-earlier');
|
||||
option.setAttribute('data-l10n-args', '{ "year": "' + year + '" }');
|
||||
} else {
|
||||
option.textContent = year;
|
||||
}
|
||||
select.appendChild(option);
|
||||
}
|
||||
}
|
||||
|
||||
function _enableNext(age) {
|
||||
if (age === '0') {
|
||||
FxaModuleUI.disableNextButton();
|
||||
return;
|
||||
}
|
||||
FxaModuleUI.enableNextButton();
|
||||
}
|
||||
|
||||
var Module = Object.create(FxaModule);
|
||||
Module.init = function init(options) {
|
||||
this.importElements('fxa-age-select');
|
||||
|
||||
this.isFTU = !!(options && options.isftu);
|
||||
|
||||
// Initially we only have one value ("Year of birth") in the age
|
||||
// selection element.
|
||||
if (this.fxaAgeSelect.length == 1) {
|
||||
_populateSelect(this.fxaAgeSelect);
|
||||
}
|
||||
|
||||
_enableNext(this.fxaAgeSelect.value);
|
||||
|
||||
// If COPPA is part of the sign up flow, then we need to add a step to the
|
||||
// progress bar. Don't increment if the user is moving backwards, though.
|
||||
if (!FxaModuleNavigation.backAnim) {
|
||||
FxaModuleUI.increaseMaxStepsBy(1);
|
||||
}
|
||||
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.fxaAgeSelect.addEventListener('change', () => {
|
||||
_enableNext(this.fxaAgeSelect.value);
|
||||
});
|
||||
|
||||
this.initialized = true;
|
||||
};
|
||||
|
||||
Module.onNext = function onNext(gotoNextStepCallback) {
|
||||
if (new Date().getFullYear() - this.fxaAgeSelect.value < MINIMUM_AGE) {
|
||||
this.showErrorResponse({
|
||||
error: this.isFTU ? 'COPPA_FTU_ERROR' : 'COPPA_ERROR'
|
||||
});
|
||||
return;
|
||||
}
|
||||
gotoNextStepCallback(FxaModuleStates.SET_PASSWORD);
|
||||
};
|
||||
|
||||
Module.onBack = function onBack() {
|
||||
FxaModuleUI.decreaseMaxStepsBy(1);
|
||||
};
|
||||
|
||||
return Module;
|
||||
})();
|
||||
288
gaia/tv_apps/smart-system/fxa/js/screens/fxam_enter_email.js
Executable file
288
gaia/tv_apps/smart-system/fxa/js/screens/fxam_enter_email.js
Executable file
|
|
@ -0,0 +1,288 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
/* global BrowserFrame */
|
||||
/* global EntrySheet */
|
||||
/* global ERROR_INVALID_SYNC_ACCOUNT */
|
||||
/* global FxaModule */
|
||||
/* global FxaModuleKeyNavigation */
|
||||
/* global FxaModuleManager */
|
||||
/* global FxaModuleNavigation */
|
||||
/* global FxaModuleOverlay */
|
||||
/* global FxModuleServerRequest */
|
||||
/* global FxaModuleStates */
|
||||
/* global FxaModuleUI */
|
||||
/* global KeyEvent */
|
||||
|
||||
/* exported FxaModuleEnterEmail */
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* This module checks the validity of an email address, and if valid,
|
||||
* determines which screen to go next.
|
||||
*/
|
||||
|
||||
var FxaModuleEnterEmail = (function() {
|
||||
|
||||
var _ = null;
|
||||
var termsUrl = 'https://accounts.firefox.com/legal/terms';
|
||||
var privacyUrl = 'https://accounts.firefox.com/legal/privacy';
|
||||
|
||||
function _isEmailValid(emailEl) {
|
||||
return emailEl && emailEl.value && emailEl.validity.valid;
|
||||
}
|
||||
|
||||
function _loadSignIn(done) {
|
||||
done(FxaModuleStates.ENTER_PASSWORD);
|
||||
}
|
||||
|
||||
function _loadSignUp(done) {
|
||||
done(FxaModuleStates.SET_PASSWORD);
|
||||
}
|
||||
|
||||
function _enableNext(emailEl) {
|
||||
if (_isEmailValid(emailEl)) {
|
||||
FxaModuleUI.enableNextButton();
|
||||
} else {
|
||||
FxaModuleUI.disableNextButton();
|
||||
}
|
||||
}
|
||||
|
||||
var Module = Object.create(FxaModule);
|
||||
Module.init = function init(options) {
|
||||
_ = navigator.mozL10n.get;
|
||||
|
||||
// Cache static HTML elements
|
||||
this.importElements(
|
||||
'fxa-email-input',
|
||||
'fxa-email-clean-btn',
|
||||
'fxa-logo',
|
||||
'fxa-notice'
|
||||
);
|
||||
|
||||
// Blocks the navigation until check the condition
|
||||
_enableNext(this.fxaEmailInput);
|
||||
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// dynamically construct and localize ToS/PN notice
|
||||
// XXX This relies on the current l10n fallback mechanism which will change
|
||||
// in the future; a real solution involves DOM overlays:
|
||||
// https://bugzil.la/994357
|
||||
var noticeText = _('fxa-notice');
|
||||
var tosReplaced = noticeText.replace(
|
||||
/{{\s*tos\s*}}/,
|
||||
'<a id="fxa-terms" href="' + termsUrl + '">Terms of Service</a>'
|
||||
);
|
||||
var tosPnReplaced = tosReplaced.replace(
|
||||
/{{\s*pn\s*}}/,
|
||||
'<a id="fxa-privacy" href="' + privacyUrl + '">Privacy Notice</a>'
|
||||
);
|
||||
this.fxaNotice.innerHTML = tosPnReplaced;
|
||||
|
||||
// manually import a few elements after innerHTMLing
|
||||
this.fxaPrivacy = document.getElementById('fxa-privacy');
|
||||
this.fxaPrivacy.setAttribute('data-l10n-id', 'fxa-pn');
|
||||
this.fxaTerms = document.getElementById('fxa-terms');
|
||||
this.fxaTerms.setAttribute('data-l10n-id', 'fxa-tos');
|
||||
|
||||
this.isFTU = !!(options && options.isftu);
|
||||
|
||||
// Add listeners
|
||||
this.fxaEmailInput.addEventListener(
|
||||
'input',
|
||||
function onInput(event) {
|
||||
if(this.fxaEmailInput.value) {
|
||||
this.fxaEmailCleanBtn.classList.add('show');
|
||||
} else {
|
||||
this.fxaEmailCleanBtn.classList.remove('show');
|
||||
}
|
||||
_enableNext(event.target);
|
||||
}.bind(this)
|
||||
);
|
||||
this.fxaEmailInput.addEventListener(
|
||||
'focus',
|
||||
function onFocus() {
|
||||
this.fxaLogo.setAttribute('hidden', true);
|
||||
if(this.fxaEmailInput.value) {
|
||||
this.fxaEmailCleanBtn.classList.add('show');
|
||||
// The input can only be selected at the next event queue
|
||||
setTimeout(this.fxaEmailInput.select.bind(this.fxaEmailInput));
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
this.fxaEmailInput.addEventListener(
|
||||
'blur',
|
||||
function onBlur() {
|
||||
this.fxaLogo.removeAttribute('hidden');
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.fxaEmailCleanBtn.addEventListener(
|
||||
'click',
|
||||
function onMouseDown(e) {
|
||||
if(e.button === 0 ||
|
||||
(e.keyCode && e.keyCode === KeyEvent.DOM_VK_RETURN)) {
|
||||
this.fxaEmailInput.value = '';
|
||||
FxaModuleKeyNavigation.focus(this.fxaEmailInput);
|
||||
this.fxaEmailCleanBtn.classList.remove('show');
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.fxaTerms.addEventListener('click', onExternalLinkClick.bind(this));
|
||||
this.fxaPrivacy.addEventListener('click', onExternalLinkClick.bind(this));
|
||||
|
||||
function onExternalLinkClick(e) {
|
||||
/*jshint validthis:true */
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (!navigator.onLine) {
|
||||
return this.showErrorResponse({error: 'OFFLINE'});
|
||||
}
|
||||
var url = e.target.href;
|
||||
if (this.entrySheet) {
|
||||
this.entrySheet.close();
|
||||
this.entrySheet = null;
|
||||
}
|
||||
this.entrySheet = new EntrySheet(
|
||||
window.top.document.getElementById('screen'),
|
||||
// Prefix url with LRM character
|
||||
// This ensures truncation occurs correctly in an RTL document
|
||||
// We can remove this when bug 1154438 is fixed.
|
||||
'\u200E' + url,
|
||||
new BrowserFrame({
|
||||
url: url,
|
||||
oop: true
|
||||
})
|
||||
);
|
||||
this.entrySheet.open();
|
||||
}
|
||||
|
||||
document.addEventListener(
|
||||
'visibilitychange',
|
||||
onVisibilityChange.bind(this)
|
||||
);
|
||||
|
||||
function onVisibilityChange() {
|
||||
/*jshint validthis:true */
|
||||
if (document.hidden) {
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
if (this.entrySheet) {
|
||||
this.entrySheet.close();
|
||||
this.entrySheet = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('holdhome', hideEntrySheet.bind(this));
|
||||
window.addEventListener('home', hideEntrySheet.bind(this));
|
||||
window.addEventListener('activityrequesting', hideEntrySheet.bind(this));
|
||||
|
||||
function hideEntrySheet() {
|
||||
/*jshint validthis:true */
|
||||
if (this.entrySheet) {
|
||||
this.entrySheet.close();
|
||||
this.entrySheet = null;
|
||||
}
|
||||
window.removeEventListener('holdhome', hideEntrySheet);
|
||||
window.removeEventListener('home', hideEntrySheet);
|
||||
window.removeEventListener('activityrequesting', hideEntrySheet);
|
||||
}
|
||||
|
||||
// Ensure that pressing 'ENTER' (keycode 13) we send the form
|
||||
// as expected
|
||||
this.fxaEmailInput.addEventListener(
|
||||
'keypress',
|
||||
function onKeypress(event) {
|
||||
if (_isEmailValid(this.fxaEmailInput) && event.keyCode === 13) {
|
||||
document.activeElement.blur();
|
||||
FxaModuleNavigation.next();
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
// There are 3 reasons why using setTimeout at this place:
|
||||
// 1. Focus() only works in the setTimeout callback here
|
||||
// 2. The input will be focused first and the keyboard will be brought
|
||||
// up. We need to do this after the slide up animation of the parent
|
||||
// fxa_dialog. But the fxa iframe has no way to know when the slide up
|
||||
// animation is finished.
|
||||
// 3. Put the FxaModuleKeyNavigation.add in the onanimate callback in
|
||||
// fxam_navigation.js doesn't work, since there is no animation for the
|
||||
// first page in the flow.
|
||||
setTimeout(() => {
|
||||
FxaModuleKeyNavigation.add([
|
||||
'#fxa-email-input',
|
||||
'#fxa-email-clean-btn',
|
||||
'#fxa-module-next',
|
||||
'#fxa-privacy',
|
||||
'#fxa-terms'
|
||||
]);
|
||||
}, 500);
|
||||
|
||||
// Avoid to add listener twice
|
||||
this.initialized = true;
|
||||
};
|
||||
|
||||
Module.onAnimate = function onAnimate() {
|
||||
FxaModuleKeyNavigation.add([
|
||||
'#fxa-email-input',
|
||||
'#fxa-email-clean-btn',
|
||||
'#fxa-module-next',
|
||||
'#fxa-privacy',
|
||||
'#fxa-terms'
|
||||
]);
|
||||
};
|
||||
|
||||
Module.onNext = function onNext(gotoNextStepCallback) {
|
||||
FxaModuleOverlay.show('fxa-connecting');
|
||||
|
||||
var email = this.fxaEmailInput.value;
|
||||
|
||||
FxModuleServerRequest.checkEmail(email, response => {
|
||||
FxaModuleOverlay.hide();
|
||||
FxaModuleManager.setParam('email', email);
|
||||
if (response && response.registered) {
|
||||
FxaModuleKeyNavigation.remove([
|
||||
'#fxa-email-input',
|
||||
'#fxa-email-clean-btn',
|
||||
'#fxa-module-next',
|
||||
'#fxa-privacy',
|
||||
'#fxa-terms'
|
||||
]);
|
||||
_loadSignIn(gotoNextStepCallback);
|
||||
} else if (this.isFTU) {
|
||||
// XXX Skip COPPA verification during FTU: if a child has a mobile
|
||||
// device, we assume a parent/guardian has given it to them, which
|
||||
// implies parental consent. So, we skip to the next step in the
|
||||
// signup flow, the set-password screen. See also bug 1010598.
|
||||
_loadSignUp(gotoNextStepCallback);
|
||||
} else if (response && !response.registered) {
|
||||
// XXX On the TV we don't allow the creation of new FxA users because
|
||||
// we only use FxA on Sync and we are unable to create new Sync
|
||||
// users. So we show an error to the user, asking her to go to
|
||||
// Desktop or Android to do the creation flow.
|
||||
FxaModuleKeyNavigation.disable();
|
||||
this.showErrorResponse({error: ERROR_INVALID_SYNC_ACCOUNT});
|
||||
} else {
|
||||
FxaModuleKeyNavigation.disable();
|
||||
this.showErrorResponse({error: 'OFFLINE'});
|
||||
}
|
||||
}, error => {
|
||||
FxaModuleKeyNavigation.disable();
|
||||
this.showErrorResponse(error);
|
||||
});
|
||||
};
|
||||
|
||||
Module.onBack = function onBack() {
|
||||
FxaModuleUI.enableNextButton();
|
||||
};
|
||||
|
||||
return Module;
|
||||
|
||||
}());
|
||||
|
||||
237
gaia/tv_apps/smart-system/fxa/js/screens/fxam_enter_password.js
Executable file
237
gaia/tv_apps/smart-system/fxa/js/screens/fxam_enter_password.js
Executable file
|
|
@ -0,0 +1,237 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
/* global ERROR_INVALID_SYNC_ACCOUNT */
|
||||
/* global FxaModule */
|
||||
/* global FxaModuleKeyNavigation */
|
||||
/* global FxaModuleManager */
|
||||
/* global FxaModuleNavigation */
|
||||
/* global FxaModuleOverlay */
|
||||
/* global FxModuleServerRequest */
|
||||
/* global FxaModuleUI */
|
||||
/* global KeyEvent */
|
||||
|
||||
/* exported FxaModuleEnterPassword */
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* This module checks the validity of password given email address, and if
|
||||
* valid, determine which screen to go next.
|
||||
*/
|
||||
|
||||
var FxaModuleEnterPassword = (function() {
|
||||
|
||||
var _ = null;
|
||||
|
||||
function _isPasswordValid(passwordEl) {
|
||||
var passwordValue = passwordEl.value;
|
||||
return passwordValue && passwordEl.validity.valid;
|
||||
}
|
||||
|
||||
function _enableNext(passwordEl) {
|
||||
if (_isPasswordValid(passwordEl)) {
|
||||
FxaModuleUI.enableNextButton();
|
||||
} else {
|
||||
FxaModuleUI.disableNextButton();
|
||||
}
|
||||
}
|
||||
|
||||
function _cleanForm(passwordEl, passwordCheck) {
|
||||
passwordEl.value = '';
|
||||
passwordCheck.checked = false;
|
||||
passwordEl.setAttribute('type', 'password');
|
||||
}
|
||||
|
||||
function _togglePasswordVisibility() {
|
||||
/*jshint validthis:true*/
|
||||
var passwordFieldType = !!this.fxaShowPw.checked ? 'text' : 'password';
|
||||
this.fxaPwInput.setAttribute('type', passwordFieldType);
|
||||
}
|
||||
|
||||
function _forgotPassword() {
|
||||
/*jshint validthis:true*/
|
||||
var self = this;
|
||||
if (this.isFTU) {
|
||||
return this.showErrorResponse({
|
||||
error: 'RESET_PASSWORD_ERROR'
|
||||
});
|
||||
}
|
||||
// Note: we don't need to pass a success callback, but we do need an errback
|
||||
FxModuleServerRequest.requestPasswordReset(
|
||||
this.email,
|
||||
null,
|
||||
function on_reset_error() {
|
||||
self.showErrorResponse({
|
||||
error: 'UNKNOWN_ERROR'
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var Module = Object.create(FxaModule);
|
||||
Module.init = function init(options) {
|
||||
|
||||
if (!this.initialized) {
|
||||
_ = navigator.mozL10n.get;
|
||||
// Cache DOM elements
|
||||
this.importElements(
|
||||
'fxa-hello-known-user',
|
||||
'fxa-pw-input',
|
||||
'fxa-show-pw',
|
||||
'fxa-forgot-password',
|
||||
'fxa-pw-clean-btn'
|
||||
);
|
||||
// Add listeners
|
||||
this.fxaPwInput.addEventListener(
|
||||
'input',
|
||||
function onInput(event) {
|
||||
if(this.fxaPwInput.value) {
|
||||
this.fxaPwCleanBtn.classList.add('show');
|
||||
} else {
|
||||
this.fxaPwCleanBtn.classList.remove('show');
|
||||
}
|
||||
_enableNext(event.target);
|
||||
}.bind(this)
|
||||
);
|
||||
// Ensure that pressing 'ENTER' (keycode 13) we send the form
|
||||
// as expected
|
||||
this.fxaPwInput.addEventListener(
|
||||
'keypress',
|
||||
function onKeypress(event) {
|
||||
if (_isPasswordValid(this.fxaPwInput) && event.keyCode === 13) {
|
||||
document.activeElement.blur();
|
||||
FxaModuleNavigation.done();
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.fxaPwInput.addEventListener('focus', () => {
|
||||
setTimeout(this.fxaPwInput.select.bind(this.fxaPwInput));
|
||||
});
|
||||
|
||||
this.fxaPwCleanBtn.addEventListener(
|
||||
'click',
|
||||
function onCleanButtonClick(e) {
|
||||
if(e.button === 0 ||
|
||||
(e.keyCode && e.keyCode === KeyEvent.DOM_VK_RETURN)) {
|
||||
this.fxaPwInput.value = '';
|
||||
FxaModuleKeyNavigation.focus(this.fxaPwInput);
|
||||
this.fxaPwCleanBtn.classList.remove('show');
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.fxaShowPw.addEventListener('keypress', e => {
|
||||
if (e.keyCode && e.keyCode === KeyEvent.DOM_VK_RETURN) {
|
||||
this.fxaShowPw.checked = !this.fxaShowPw.checked;
|
||||
_togglePasswordVisibility.bind(this)();
|
||||
}
|
||||
});
|
||||
|
||||
this.fxaShowPw.addEventListener(
|
||||
'change',
|
||||
_togglePasswordVisibility.bind(this),
|
||||
false
|
||||
);
|
||||
|
||||
this.fxaForgotPassword.addEventListener(
|
||||
'click',
|
||||
_forgotPassword.bind(this),
|
||||
false
|
||||
);
|
||||
|
||||
this.fxaForgotPassword.addEventListener('keypress', e => {
|
||||
if (e.keyCode && e.keyCode === KeyEvent.DOM_VK_RETURN) {
|
||||
_forgotPassword.bind(this)();
|
||||
}
|
||||
});
|
||||
// Avoid repeated initialization
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
if (!options || !options.email) {
|
||||
console.error('Options are not sent properly. Email not available');
|
||||
return;
|
||||
}
|
||||
|
||||
this.isFTU = !!(options && options.isftu);
|
||||
this.email = options.email;
|
||||
|
||||
var helloUserText = _('fxa-hello-user');
|
||||
helloUserText = helloUserText.replace(
|
||||
/{{\s*email\s*}}/,
|
||||
'<a id="fxa-known-user-email">' + this.email + '</a>'
|
||||
);
|
||||
this.fxaHelloKnownUser.innerHTML = helloUserText;
|
||||
|
||||
_cleanForm(
|
||||
this.fxaPwInput,
|
||||
this.fxaShowPw
|
||||
);
|
||||
|
||||
_enableNext(this.fxaPwInput);
|
||||
|
||||
// There are 3 reasons why using setTimeout at this place:
|
||||
// 1. Focus() only works in the setTimeout callback here
|
||||
// 2. The input will be focused first and the keyboard will be brought
|
||||
// up. We need to do this after the slide up animation of the parent
|
||||
// fxa_dialog. But the fxa iframe has no way to know when the slide up
|
||||
// animation is finished.
|
||||
// 3. Put the FxaModuleKeyNavigation.add in the onanimate callback in
|
||||
// fxam_navigation.js doesn't work, since there is no animation for the
|
||||
// first page in the flow.
|
||||
setTimeout(() => {
|
||||
FxaModuleKeyNavigation.add([
|
||||
'#fxa-pw-input', '#fxa-forgot-password',
|
||||
'#fxa-show-pw', '#fxa-module-done', '#fxa-pw-clean-btn']);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
Module.onBack = function onBack() {
|
||||
FxaModuleKeyNavigation.remove([
|
||||
'#fxa-pw-input', '#fxa-forgot-password',
|
||||
'#fxa-show-pw', '#fxa-module-done', '#fxa-pw-clean-btn']);
|
||||
};
|
||||
|
||||
Module.onDone = function onDone(done) {
|
||||
FxaModuleOverlay.show('fxa-connecting');
|
||||
|
||||
FxaModuleManager.setParam('success', true);
|
||||
FxModuleServerRequest.signIn(
|
||||
this.email,
|
||||
this.fxaPwInput.value,
|
||||
function onServerResponse(response) {
|
||||
FxaModuleOverlay.hide();
|
||||
FxaModuleKeyNavigation.remove([
|
||||
'#fxa-pw-input', '#fxa-forgot-password',
|
||||
'#fxa-show-pw', '#fxa-module-done', '#fxa-pw-clean-btn']);
|
||||
|
||||
if (!response.authenticated) {
|
||||
// XXX For now, because we don't allow the creation of new accounts
|
||||
// on the TV, we log the user out and show a dialog asking the
|
||||
// user to go to desktop or android to create the account and
|
||||
// retry from the TV.
|
||||
FxModuleServerRequest.logout(() => {
|
||||
this.showErrorResponse({error: ERROR_INVALID_SYNC_ACCOUNT});
|
||||
FxaModuleManager.close('DIALOG_CLOSED_BY_USER');
|
||||
}, this.showErrorResponse);
|
||||
return;
|
||||
}
|
||||
done();
|
||||
}.bind(this),
|
||||
function onError(response) {
|
||||
FxaModuleKeyNavigation.disable();
|
||||
_cleanForm(
|
||||
this.fxaPwInput,
|
||||
this.fxaShowPw
|
||||
);
|
||||
this.showErrorResponse(response);
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
return Module;
|
||||
|
||||
}());
|
||||
|
||||
199
gaia/tv_apps/smart-system/fxa/js/screens/fxam_refresh_auth.js
Executable file
199
gaia/tv_apps/smart-system/fxa/js/screens/fxam_refresh_auth.js
Executable file
|
|
@ -0,0 +1,199 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
/* global FxaModule */
|
||||
/* global FxaModuleKeyNavigation */
|
||||
/* global FxaModuleNavigation */
|
||||
/* global FxaModuleOverlay */
|
||||
/* global FxaModuleStates */
|
||||
/* global FxaModuleUI */
|
||||
/* global FxModuleServerRequest */
|
||||
/* global KeyEvent */
|
||||
/* exported FxaModuleRefreshAuth */
|
||||
/* jshint unused:false */
|
||||
|
||||
'use strict';
|
||||
|
||||
var FxaModuleRefreshAuth = (function() {
|
||||
|
||||
function _isPasswordValid(passwordEl) {
|
||||
var passwordValue = passwordEl.value;
|
||||
return passwordValue && passwordEl.validity.valid;
|
||||
}
|
||||
|
||||
function _enableDone(passwordEl) {
|
||||
if (_isPasswordValid(passwordEl)) {
|
||||
FxaModuleUI.enableDoneButton();
|
||||
} else {
|
||||
FxaModuleUI.disableDoneButton();
|
||||
}
|
||||
}
|
||||
|
||||
function _cleanForm(passwordEl, passwordCheck) {
|
||||
passwordEl.value = '';
|
||||
passwordCheck.checked = false;
|
||||
passwordEl.setAttribute('type', 'password');
|
||||
FxaModuleUI.disableDoneButton();
|
||||
}
|
||||
|
||||
function _togglePasswordVisibility() {
|
||||
/*jshint validthis:true*/
|
||||
var passwordFieldType =
|
||||
!!this.fxaShowPwRefresh.checked ? 'text' : 'password';
|
||||
this.fxaPwInputRefresh.setAttribute('type', passwordFieldType);
|
||||
}
|
||||
|
||||
function _requestPasswordReset(email, done) {
|
||||
/*jshint validthis:true */
|
||||
FxModuleServerRequest.requestPasswordReset(
|
||||
email,
|
||||
function onSuccess(response) {
|
||||
done();
|
||||
},
|
||||
function onError(response) {
|
||||
this._showCouldNotResetPassword();
|
||||
}.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
function _showCouldNotResetPassword() {
|
||||
/*jshint validthis:true */
|
||||
this.showErrorResponse({
|
||||
error: 'RESET_PASSWORD_ERROR'
|
||||
});
|
||||
}
|
||||
|
||||
function _forgotPassword() {
|
||||
/*jshint validthis:true */
|
||||
FxaModuleOverlay.show('fxa-requesting-password-reset');
|
||||
_requestPasswordReset.call(
|
||||
this,
|
||||
this.email,
|
||||
function() {
|
||||
FxaModuleOverlay.hide();
|
||||
FxaModuleStates.setState(FxaModuleStates.PASSWORD_RESET_SUCCESS);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
var Module = Object.create(FxaModule);
|
||||
Module.init = function init(options) {
|
||||
if (!this.initialized) {
|
||||
// Cache DOM elements.
|
||||
this.importElements(
|
||||
'fxa-pw-input-refresh',
|
||||
'fxa-show-pw-refresh',
|
||||
'fxa-forgot-password-refresh',
|
||||
'fxa-pw-clean-btn'
|
||||
);
|
||||
|
||||
this.fxaPwInputRefresh.addEventListener('input', (function(event) {
|
||||
if(this.fxaPwInputRefresh.value) {
|
||||
this.fxaPwCleanBtn.classList.add('show');
|
||||
} else {
|
||||
this.fxaPwCleanBtn.classList.remove('show');
|
||||
}
|
||||
_enableDone(event.target);
|
||||
}).bind(this));
|
||||
|
||||
this.fxaPwCleanBtn.addEventListener(
|
||||
'click',
|
||||
function onCleanButtonClick(e) {
|
||||
if(e.button === 0 ||
|
||||
(e.keyCode && e.keyCode === KeyEvent.DOM_VK_RETURN)) {
|
||||
this.fxaPwInputRefresh.value = '';
|
||||
FxaModuleKeyNavigation.focus(this.fxaPwInputRefresh);
|
||||
this.fxaPwCleanBtn.classList.remove('show');
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.fxaShowPwRefresh.addEventListener('change', (function() {
|
||||
var passwordFieldType = !!this.fxaShowPwRefresh.checked ? 'text' :
|
||||
'password';
|
||||
}).bind(this), false);
|
||||
|
||||
// Ensure that pressing 'ENTER' (keycode 13) we send the form
|
||||
// as expected
|
||||
this.fxaPwInputRefresh.addEventListener('keypress', event => {
|
||||
if (_isPasswordValid(this.fxaPwInputRefresh) && event.keyCode === 13) {
|
||||
document.activeElement.blur();
|
||||
FxaModuleNavigation.done();
|
||||
}
|
||||
});
|
||||
|
||||
this.fxaPwInputRefresh.addEventListener('focus', () => {
|
||||
setTimeout(this.fxaPwInputRefresh.select.bind(this.fxaPwInputRefresh));
|
||||
});
|
||||
|
||||
this.fxaShowPwRefresh.addEventListener('keypress', e => {
|
||||
if (e.keyCode && e.keyCode === KeyEvent.DOM_VK_RETURN) {
|
||||
this.fxaShowPwRefresh.checked = !this.fxaShowPwRefresh.checked;
|
||||
_togglePasswordVisibility.bind(this)();
|
||||
}
|
||||
});
|
||||
|
||||
this.fxaShowPwRefresh.addEventListener(
|
||||
'change',
|
||||
_togglePasswordVisibility.bind(this),
|
||||
false
|
||||
);
|
||||
|
||||
this.fxaForgotPasswordRefresh.addEventListener('click',
|
||||
_forgotPassword.bind(this),
|
||||
false);
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
if (!options || !options.email) {
|
||||
console.error('Options are not sent properly. Email not available');
|
||||
return;
|
||||
}
|
||||
|
||||
this.email = options.email;
|
||||
|
||||
_cleanForm(this.fxaPwInputRefresh, this.fxaShowPwRefresh);
|
||||
_enableDone(this.fxaPwInputRefresh);
|
||||
|
||||
// There are 3 reasons why using setTimeout at this place:
|
||||
// 1. Focus() only works in the setTimeout callback here
|
||||
// 2. The input will be focused first and the keyboard will be brought
|
||||
// up. We need to do this after the slide up animation of the parent
|
||||
// fxa_dialog. But the fxa iframe has no way to know when the slide up
|
||||
// animation is finished.
|
||||
// 3. Put the FxaModuleKeyNavigation.add in the onanimate callback in
|
||||
// fxam_navigation.js doesn't work, since there is no animation for the
|
||||
// first page in the flow.
|
||||
setTimeout(() => {
|
||||
FxaModuleKeyNavigation.add([
|
||||
'#fxa-pw-input-refresh', '#fxa-show-pw-refresh',
|
||||
'#fxa-forgot-password-refresh', '#fxa-module-done',
|
||||
'#fxa-pw-clean-btn']);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
Module.onDone = function onDone(callback) {
|
||||
FxaModuleOverlay.show('fxa-connecting');
|
||||
|
||||
FxModuleServerRequest.signIn(
|
||||
this.email,
|
||||
this.fxaPwInputRefresh.value,
|
||||
function onServerResponse(response) {
|
||||
FxaModuleOverlay.hide();
|
||||
FxaModuleKeyNavigation.remove([
|
||||
'#fxa-pw-input-refresh', '#fxa-show-pw-refresh',
|
||||
'#fxa-forgot-password-refresh', '#fxa-module-done',
|
||||
'#fxa-pw-clean-btn']);
|
||||
callback();
|
||||
}, function onError(response) {
|
||||
FxaModuleKeyNavigation.disable();
|
||||
_cleanForm(this.fxaPwInputRefresh,
|
||||
this.fxaShowPwRefresh);
|
||||
this.showErrorResponse(response);
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
return Module;
|
||||
})();
|
||||
130
gaia/tv_apps/smart-system/fxa/js/screens/fxam_set_password.js
Executable file
130
gaia/tv_apps/smart-system/fxa/js/screens/fxam_set_password.js
Executable file
|
|
@ -0,0 +1,130 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
/* global FxaModuleUI, FxaModuleOverlay, FxaModule, FxModuleServerRequest,
|
||||
FxaModuleManager, FxaModuleStates */
|
||||
/* exported FxaModuleSetPassword */
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Takes care of a new user's set password screen. If password is valid,
|
||||
* attempt to stage the user.
|
||||
*/
|
||||
var FxaModuleSetPassword = (function() {
|
||||
|
||||
var _ = null;
|
||||
|
||||
function _isPasswordValid(passwordEl) {
|
||||
var passwordValue = passwordEl.value;
|
||||
return passwordValue && passwordEl.validity.valid;
|
||||
}
|
||||
|
||||
function _enableNext(passwordEl) {
|
||||
if (_isPasswordValid(passwordEl)) {
|
||||
FxaModuleUI.enableNextButton();
|
||||
} else {
|
||||
FxaModuleUI.disableNextButton();
|
||||
}
|
||||
}
|
||||
|
||||
function _cleanForm(passwordEl, passwordCheck) {
|
||||
passwordEl.value = '';
|
||||
passwordCheck.checked = false;
|
||||
passwordEl.setAttribute('type', 'password');
|
||||
}
|
||||
|
||||
function _showRegistering() {
|
||||
FxaModuleOverlay.show('fxa-connecting');
|
||||
}
|
||||
|
||||
function _hideRegistering() {
|
||||
FxaModuleOverlay.hide();
|
||||
}
|
||||
|
||||
function _showUserNotCreated() {
|
||||
/*jshint validthis:true */
|
||||
this.showErrorResponse({
|
||||
error: 'CANNOT_CREATE_ACCOUNT'
|
||||
});
|
||||
}
|
||||
|
||||
function _togglePasswordVisibility() {
|
||||
/*jshint validthis:true */
|
||||
var passwordFieldType = !!this.fxaShowPwSet.checked ? 'text' : 'password';
|
||||
this.fxaPwSetInput.setAttribute('type', passwordFieldType);
|
||||
}
|
||||
|
||||
var Module = Object.create(FxaModule);
|
||||
Module.init = function init(options) {
|
||||
|
||||
if (!this.initialized) {
|
||||
// l10n manager
|
||||
_ = navigator.mozL10n.get;
|
||||
// Cache DOM elements
|
||||
this.importElements(
|
||||
'fxa-pw-set-input',
|
||||
'fxa-show-pw-set',
|
||||
'fxa-hello-user'
|
||||
);
|
||||
// Add Listeners
|
||||
this.fxaPwSetInput.addEventListener(
|
||||
'input',
|
||||
function onInput(event) {
|
||||
_enableNext(event.target);
|
||||
}
|
||||
);
|
||||
|
||||
this.fxaShowPwSet.addEventListener(
|
||||
'change',
|
||||
_togglePasswordVisibility.bind(this),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
|
||||
this.email = options.email;
|
||||
|
||||
var helloUserText = _('fxa-hello-user');
|
||||
helloUserText = helloUserText.replace(
|
||||
/{{\s*email\s*}}/,
|
||||
'<a id="fxa-user-set-email">' + this.email + '</a>'
|
||||
);
|
||||
this.fxaHelloUser.innerHTML = helloUserText;
|
||||
|
||||
_cleanForm(
|
||||
this.fxaPwSetInput,
|
||||
this.fxaShowPwSet
|
||||
);
|
||||
|
||||
_enableNext(this.fxaPwSetInput);
|
||||
};
|
||||
|
||||
Module.onNext = function onNext(gotoNextStepCallback) {
|
||||
_showRegistering();
|
||||
FxModuleServerRequest.signUp(
|
||||
this.email,
|
||||
this.fxaPwSetInput.value,
|
||||
function(response) {
|
||||
_hideRegistering();
|
||||
|
||||
FxaModuleManager.setParam('success', true);
|
||||
|
||||
var isAccountCreated = response.accountCreated;
|
||||
|
||||
if (!isAccountCreated) {
|
||||
_showUserNotCreated.call(this);
|
||||
return;
|
||||
}
|
||||
|
||||
gotoNextStepCallback(FxaModuleStates.SIGNUP_SUCCESS);
|
||||
}.bind(this),
|
||||
this.showErrorResponse
|
||||
);
|
||||
};
|
||||
|
||||
return Module;
|
||||
|
||||
}());
|
||||
|
||||
27
gaia/tv_apps/smart-system/fxa/js/screens/fxam_signin_success.js
Executable file
27
gaia/tv_apps/smart-system/fxa/js/screens/fxam_signin_success.js
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
/* global FxaModule, FxaModuleStates, FxaModuleUI */
|
||||
/* exported FxaModuleSigninSuccess */
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Display the signup success message to the user.
|
||||
*/
|
||||
var FxaModuleSigninSuccess = (function() {
|
||||
|
||||
var Module = Object.create(FxaModule);
|
||||
|
||||
Module.init = function init() {
|
||||
FxaModuleUI.focusDoneButton();
|
||||
};
|
||||
|
||||
Module.onNext = function onNext(done) {
|
||||
done(FxaModuleStates.DONE);
|
||||
};
|
||||
|
||||
return Module;
|
||||
|
||||
}());
|
||||
|
||||
36
gaia/tv_apps/smart-system/fxa/js/screens/fxam_signup_success.js
Executable file
36
gaia/tv_apps/smart-system/fxa/js/screens/fxam_signup_success.js
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
/* global FxaModule, FxaModuleStates */
|
||||
/* exported FxaModuleSignupSuccess */
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Display the signup success message to the user.
|
||||
*/
|
||||
var FxaModuleSignupSuccess = (function() {
|
||||
|
||||
var Module = Object.create(FxaModule);
|
||||
Module.init = function init(options) {
|
||||
options = options || {};
|
||||
this.importElements(
|
||||
'fxa-will-send-email'
|
||||
);
|
||||
|
||||
var willSendText = navigator.mozL10n.get('fxa-will-send-email');
|
||||
willSendText = willSendText.replace(
|
||||
/{{\s*email\s*}}/,
|
||||
'<strong>' + options.email + '</strong>'
|
||||
);
|
||||
this.fxaWillSendEmail.innerHTML = willSendText;
|
||||
};
|
||||
|
||||
Module.onNext = function onNext(done) {
|
||||
done(FxaModuleStates.DONE);
|
||||
};
|
||||
|
||||
return Module;
|
||||
|
||||
}());
|
||||
|
||||
Loading…
Reference in a new issue