Skip to content

Commit

Permalink
prepare new version
Browse files Browse the repository at this point in the history
  • Loading branch information
iworks committed Jul 4, 2024
1 parent 75db006 commit 6f33804
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 36 deletions.
65 changes: 32 additions & 33 deletions assets/scripts/frontend.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
/**
* PWA — easy way to Progressive Web App - v1.5.9
* PWA — easy way to Progressive Web App - v1.6.0
* https://github.com/iworks/iworks-pwa
* Copyright (c) 2024; * Licensed GPLv3+ */
window.addEventListener('load', function(event) {
var iworks_pwa_deferred_prompt;
const iworks_pwa_add_button = document.querySelector('#iworks-pwa-add-button');
const iworks_pwa_add_button_container = document.querySelector('#iworks-pwa-add-button-container');
if (iworks_pwa_add_button) {
window.addEventListener('beforeinstallprompt', function(event) {
// Prevent Chrome 67 and earlier from automatically showing the prompt
event.preventDefault();
// Stash the event so it can be triggered later.
iworks_pwa_deferred_prompt = event;
// Update UI to notify the user they can add to home screen
iworks_pwa_add_button_container.style.display = 'block';
iworks_pwa_add_button.addEventListener('click', function() {
// hide our user interface that shows our A2HS button
iworks_pwa_add_button_container.style.display = 'none';
// Show the prompt
iworks_pwa_deferred_prompt.prompt();
// Wait for the user to respond to the prompt
iworks_pwa_deferred_prompt.userChoice.then(function(choiceResult) {
if (choiceResult.outcome === 'accepted') {
// console.log('User accepted the A2HS prompt');
} else {
// console.log('User dismissed the A2HS prompt');
}
iworks_pwa_deferred_prompt = null;
});
});
});
}
var iworks_pwa_deferred_prompt;
const iworks_pwa_add_button = document.querySelector('#iworks-pwa-add-button');
const iworks_pwa_add_button_container = document.querySelector('#iworks-pwa-add-button-container');
if (iworks_pwa_add_button) {
window.addEventListener('beforeinstallprompt', function(event) {
// Prevent Chrome 67 and earlier from automatically showing the prompt
event.preventDefault();
// Stash the event so it can be triggered later.
iworks_pwa_deferred_prompt = event;
// Update UI to notify the user they can add to home screen
iworks_pwa_add_button_container.style.display = 'block';
iworks_pwa_add_button.addEventListener('click', function() {
// hide our user interface that shows our A2HS button
iworks_pwa_add_button_container.style.display = 'none';
// Show the prompt
iworks_pwa_deferred_prompt.prompt();
// Wait for the user to respond to the prompt
iworks_pwa_deferred_prompt.userChoice.then(function(choiceResult) {
if (choiceResult.outcome === 'accepted') {
// console.log('User accepted the A2HS prompt');
} else {
// console.log('User dismissed the A2HS prompt');
}
iworks_pwa_deferred_prompt = null;
});
});
});
}
});

if ('serviceWorker' in navigator) {
navigator.serviceWorker.register(window.iworks_pwa.serviceWorkerUri)
.then(function(reg) {})
.catch(function(err) {});
navigator.serviceWorker.register(window.iworks_pwa.serviceWorkerUri)
.then(function(reg) {})
.catch(function(err) {});
}
2 changes: 1 addition & 1 deletion assets/scripts/frontend.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "PWA — easy way to Progressive Web App",
"tagline": "Your easy way to Progressive Web Application.",
"description": "Progressive Web Apps (PWA) is a technology that combines the best of mobile web and the best of mobile apps to create a superior mobile web experience. They are installed on the phone like a normal app (web app) and can be accessed from the home screen.",
"version": "1.5.9",
"version": "1.6.0",
"homepage": "https://github.com/iworks/iworks-pwa",
"author": [
{
Expand All @@ -17,7 +17,7 @@
"PHP": "8.0"
},
"tested": {
"WordPress": "6.4"
"WordPress": "6.5"
},
"devDependencies": {
"ajv-keywords": "^3.2.0",
Expand Down

0 comments on commit 6f33804

Please sign in to comment.