main app code and some default modules
This commit is contained in:
parent
eb0285789f
commit
abd2dadb45
7 changed files with 407 additions and 0 deletions
41
www/js/install-button.js
Normal file
41
www/js/install-button.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
define(function(require) {
|
||||
var install = require('install');
|
||||
|
||||
function update() {
|
||||
var btn = document.getElementById('install-btn');
|
||||
if(install.state == 'uninstalled') {
|
||||
btn.style.display = 'block';
|
||||
}
|
||||
else if(install.state == 'installed' || install.state == 'unsupported') {
|
||||
btn.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
var btn = document.getElementById('install-btn');
|
||||
btn.addEventListener('click', function() {
|
||||
install();
|
||||
});
|
||||
|
||||
install.on('change', update);
|
||||
|
||||
install.on('error', function(e, err) {
|
||||
// Feel free to customize this
|
||||
alert('There was an error during installation.');
|
||||
});
|
||||
|
||||
install.on('showiOSInstall', function() {
|
||||
// Feel free to customize this
|
||||
alert('To install, press the forward arrow in Safari ' +
|
||||
'and touch "Add to Home Screen"');
|
||||
});
|
||||
}
|
||||
|
||||
if(!document.getElementById('install-btn')) {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
}
|
||||
else {
|
||||
init();
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue