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
67
gaia/apps/settings/js/firefox_accounts/menu.js
Executable file
67
gaia/apps/settings/js/firefox_accounts/menu.js
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
/* global FxAccountsIACHelper, Normalizer */
|
||||
/* exported FxaMenu */
|
||||
|
||||
'use strict';
|
||||
|
||||
var FxaMenu = (function fxa_menu() {
|
||||
var fxaHelper,
|
||||
menuStatus;
|
||||
|
||||
function init(helper) {
|
||||
// allow mock to be passed in for unit testing
|
||||
fxaHelper = helper || FxAccountsIACHelper;
|
||||
menuStatus = document.getElementById('fxa-desc');
|
||||
if(window.VulpesCompat){menuStatus.removeAttribute('data-l10n-id');menuStatus.textContent=(document.documentElement.lang||navigator.language).startsWith('fr')?'Service non disponible sur ce bureau':'Service unavailable on this desktop';return;}
|
||||
|
||||
// listen for status updates
|
||||
onVisibilityChange();
|
||||
// start by asking for current status
|
||||
refreshStatus();
|
||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
||||
}
|
||||
|
||||
function refreshStatus() {
|
||||
fxaHelper.getAccount(onStatusChange, onStatusError);
|
||||
}
|
||||
|
||||
// if e == null, user is logged out.
|
||||
// if e.verified, user is logged in & verified.
|
||||
// if !e.verified, user is logged in & unverified.
|
||||
function onStatusChange(e) {
|
||||
var email = e ? Normalizer.escapeHTML(e.email) : '';
|
||||
|
||||
if (!e) {
|
||||
menuStatus.setAttribute('data-l10n-id', 'fxa-invitation');
|
||||
menuStatus.removeAttribute('data-l10n-args');
|
||||
} else if (e.verified) {
|
||||
document.l10n.setAttributes(menuStatus, 'fxa-logged-in-text', {
|
||||
email: email
|
||||
});
|
||||
} else { // unverified
|
||||
document.l10n.setAttributes(menuStatus, 'fxa-confirm-email', {
|
||||
email: email
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onStatusError(err) {
|
||||
console.error('FxaMenu: Error getting Firefox Account: ' + err.error);
|
||||
}
|
||||
|
||||
function onVisibilityChange() {
|
||||
if (document.hidden) {
|
||||
fxaHelper.removeEventListener('onlogin', refreshStatus);
|
||||
fxaHelper.removeEventListener('onverified', refreshStatus);
|
||||
fxaHelper.removeEventListener('onlogout', refreshStatus);
|
||||
} else {
|
||||
fxaHelper.addEventListener('onlogin', refreshStatus);
|
||||
fxaHelper.addEventListener('onverified', refreshStatus);
|
||||
fxaHelper.addEventListener('onlogout', refreshStatus);
|
||||
refreshStatus();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
init: init
|
||||
};
|
||||
})();
|
||||
Loading…
Reference in a new issue