This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8848 from fcampo/v1.0.1
- Loading branch information
Showing
8 changed files
with
139 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
var NewsletterManager = { | ||
load: function nlm_load() { | ||
loader.load('/shared/js/async_storage.js', | ||
function finishLoading() { | ||
NewsletterManager.start(); | ||
}); | ||
}, | ||
|
||
start: function nlm_start() { | ||
var self = this; | ||
window.asyncStorage.getItem('newsletter_email', function gotItem(item) { | ||
if (item) { // FTU saved the email when no connection available | ||
if (navigator.onLine) { | ||
self.sendNewsletter(item); | ||
} else { | ||
window.addEventListener('online', self.sendNewsletter(item)); | ||
} | ||
} | ||
}); | ||
}, | ||
|
||
sendNewsletter: function nlm_sendNewsletter(emailAddress) { | ||
loader.load('/ftu/js/basket-client.js', function basketLoaded() { | ||
Basket.send(emailAddress, function itemSent(err, data) { | ||
if (data && data.status == 'ok') { | ||
window.asyncStorage.removeItem('newsletter_email'); | ||
window.removeEventListener('online', sendNewsletter); | ||
} | ||
}); | ||
}); | ||
} | ||
}; | ||
|
||
|
||
// starting when we get a chance | ||
loader.load('/shared/js/l10n.js', function localized() { | ||
|
||
navigator.mozL10n.ready(function loadWhenIdle() { | ||
var idleObserver = { | ||
time: 5, | ||
onidle: function() { | ||
NewsletterManager.load(); | ||
navigator.removeIdleObserver(idleObserver); | ||
} | ||
}; | ||
navigator.addIdleObserver(idleObserver); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters