From d01ac3e82a6cd8e136248c099e22551a47242660 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 16 Dec 2025 23:18:07 -0800 Subject: [PATCH 1/6] Re-name Decline to Deny --- .../en/webpushnotifications_module_acp.php | 2 +- .../en/webpushnotifications_module_ucp.php | 2 +- .../ru/webpushnotifications_module_ucp.php | 2 +- styles/all/template/webpush.js | 40 +++++++++++-------- styles/all/template/webpush_popup.html | 2 +- styles/all/theme/phpbb_wpn.css | 4 +- tests/functional/functional_test.php | 2 +- 7 files changed, 30 insertions(+), 24 deletions(-) diff --git a/language/en/webpushnotifications_module_acp.php b/language/en/webpushnotifications_module_acp.php index bf4edbe..9d83cd0 100644 --- a/language/en/webpushnotifications_module_acp.php +++ b/language/en/webpushnotifications_module_acp.php @@ -51,6 +51,6 @@ 'WEBPUSH_DROPDOWN_SUBSCRIBE' => 'Show web push settings in the notification dropdown', 'WEBPUSH_DROPDOWN_SUBSCRIBE_EXPLAIN'=> 'Show or hide the “Enable Web Push” toggle switch in the notification dropdown. This allows users to easily enable or disable push notifications from any page of the forum.', 'WEBPUSH_POPUP_PROMPT' => 'Show popup prompt for unsubscribed members', - 'WEBPUSH_POPUP_PROMPT_EXPLAIN' => 'Display a popup message asking registered members if they want to receive push notifications. The popup will only appear to members who are not currently subscribed and have not previously declined.', + 'WEBPUSH_POPUP_PROMPT_EXPLAIN' => 'Display a popup message asking registered members if they want to receive push notifications. The popup will only appear to members who are not currently subscribed and have not previously denied.', 'WEBPUSH_INSECURE_SERVER_ERROR' => 'This board is not using a secure SSL/HTTPS protocol, which is required for enabling web push notifications. Alternatively, the server environment might be misconfigured. Ensure that the HTTPS and HEADER_CLIENT_PROTO server environment variables are correctly configured.', ]); diff --git a/language/en/webpushnotifications_module_ucp.php b/language/en/webpushnotifications_module_ucp.php index 31ed884..be503ca 100644 --- a/language/en/webpushnotifications_module_ucp.php +++ b/language/en/webpushnotifications_module_ucp.php @@ -52,5 +52,5 @@ 'NOTIFY_WEBPUSH_POPUP_TITLE' => 'Allow browser notifications?', 'NOTIFY_WEBPUSH_POPUP_MESSAGE' => 'We would like to send you browser notifications for replies, private messages, and relevant forum activity. Optional — you can manage these settings at any time.', 'NOTIFY_WEBPUSH_POPUP_ALLOW' => 'Allow', - 'NOTIFY_WEBPUSH_POPUP_DECLINE' => 'Decline', + 'NOTIFY_WEBPUSH_POPUP_DENY' => 'Deny', ]); diff --git a/language/ru/webpushnotifications_module_ucp.php b/language/ru/webpushnotifications_module_ucp.php index 6b08e2b..10b5e7a 100644 --- a/language/ru/webpushnotifications_module_ucp.php +++ b/language/ru/webpushnotifications_module_ucp.php @@ -52,5 +52,5 @@ 'NOTIFY_WEBPUSH_POPUP_TITLE' => 'Включить браузерные уведомления?', 'NOTIFY_WEBPUSH_POPUP_MESSAGE' => 'Браузерные уведомления позволяют быстро получать информацию о новых ответах, личных сообщениях и других активностях на данной конференции. Функцию можно отключить или включить в любое время в настройках уведомлений в Личном разделе.', 'NOTIFY_WEBPUSH_POPUP_ALLOW' => 'Включить', - 'NOTIFY_WEBPUSH_POPUP_DECLINE' => 'Отклонить', + 'NOTIFY_WEBPUSH_POPUP_DENY' => 'Отклонить', ]); diff --git a/styles/all/template/webpush.js b/styles/all/template/webpush.js index 0968dff..6c00d05 100644 --- a/styles/all/template/webpush.js +++ b/styles/all/template/webpush.js @@ -126,8 +126,8 @@ function PhpbbWebpush() { return; } - // Check if user declined on this browser - if (getDeclined() === 'true') { + // Check if user denied prompt on this browser + if (promptDenied.get() === 'true') { return; } @@ -157,7 +157,7 @@ function PhpbbWebpush() { }, 1000); const allowBtn = document.getElementById('wpn_popup_allow'); - const declineBtn = document.getElementById('wpn_popup_decline'); + const denyBtn = document.getElementById('wpn_popup_deny'); const overlay = document.getElementById('wpn_popup_prompt'); if (allowBtn) { @@ -168,11 +168,11 @@ function PhpbbWebpush() { }); } - if (declineBtn) { - declineBtn.addEventListener('click', (event) => { + if (denyBtn) { + denyBtn.addEventListener('click', (event) => { event.stopPropagation(); popup.style.display = 'none'; - setDeclined(); + promptDenied.set(); }); } @@ -180,7 +180,7 @@ function PhpbbWebpush() { overlay.addEventListener('click', (event) => { if (event.target === overlay) { popup.style.display = 'none'; - setDeclined(); + promptDenied.set(); } }); } @@ -328,7 +328,7 @@ function PhpbbWebpush() { if ('form_tokens' in response) { updateFormTokens(response.form_tokens); } - resetDeclined(); + promptDenied.remove(); const popup = document.getElementById('wpn_popup_prompt'); if (popup) { popup.style.display = 'none'; @@ -379,15 +379,21 @@ function PhpbbWebpush() { return outputArray; } - function setDeclined() { - localStorage.setItem('wpn_popup_declined', 'true'); - } - function getDeclined() { - return localStorage.getItem('wpn_popup_declined'); - } - function resetDeclined() { - localStorage.removeItem('wpn_popup_declined'); - } + const promptDenied = { + key: 'wpn_popup_denied', + + set() { + localStorage.setItem(this.key, 'true'); + }, + + get() { + return localStorage.getItem(this.key); + }, + + remove() { + localStorage.removeItem(this.key); + } + }; } function domReady(callBack) { diff --git a/styles/all/template/webpush_popup.html b/styles/all/template/webpush_popup.html index ef893c6..dea6c96 100644 --- a/styles/all/template/webpush_popup.html +++ b/styles/all/template/webpush_popup.html @@ -6,7 +6,7 @@

{{ lang('NOTIFY_WEBPUSH_POPUP_TITLE') }}

{{ lang('NOTIFY_WEBPUSH_POPUP_MESSAGE') }}

- +
diff --git a/styles/all/theme/phpbb_wpn.css b/styles/all/theme/phpbb_wpn.css index 53d8913..38d829f 100644 --- a/styles/all/theme/phpbb_wpn.css +++ b/styles/all/theme/phpbb_wpn.css @@ -130,12 +130,12 @@ background: #0052a3; } -.wpn-popup-btn-decline { +.wpn-popup-btn-deny { background: #f0f0f0; color: #666666; } -.wpn-popup-btn-decline:hover { +.wpn-popup-btn-deny:hover { background: #e0e0e0; } diff --git a/tests/functional/functional_test.php b/tests/functional/functional_test.php index 76b08aa..c705e68 100644 --- a/tests/functional/functional_test.php +++ b/tests/functional/functional_test.php @@ -159,7 +159,7 @@ public function test_popup_prompt() $this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_TITLE', $crawler->filter('.wpn-popup-title')->text()); $this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_MESSAGE', $crawler->filter('.wpn-popup-message')->text()); $this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_ALLOW', $crawler->filter('#wpn_popup_allow')->text()); - $this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_DECLINE', $crawler->filter('#wpn_popup_decline')->text()); + $this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_DENY', $crawler->filter('#wpn_popup_deny')->text()); } protected function set_acp_option($option, $value) From 98ef474a7536ace8609124c647afff08c0100809 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 16 Dec 2025 23:18:29 -0800 Subject: [PATCH 2/6] Misc javascript code fixes --- styles/all/template/webpush.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/styles/all/template/webpush.js b/styles/all/template/webpush.js index 6c00d05..e57b5d3 100644 --- a/styles/all/template/webpush.js +++ b/styles/all/template/webpush.js @@ -1,8 +1,8 @@ /* global phpbb */ -'use strict'; - function PhpbbWebpush() { + 'use strict'; + /** @type {string} URL to service worker */ let serviceWorkerUrl = ''; @@ -164,7 +164,9 @@ function PhpbbWebpush() { allowBtn.addEventListener('click', (event) => { event.stopPropagation(); popup.style.display = 'none'; - subscribeButtonHandler({ preventDefault: () => {} }); + subscribeButtonHandler({ + preventDefault: () => {} + }); }); } @@ -397,6 +399,8 @@ function PhpbbWebpush() { } function domReady(callBack) { + 'use strict'; + if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', callBack); } else { @@ -407,6 +411,8 @@ function domReady(callBack) { phpbb.webpush = new PhpbbWebpush(); domReady(() => { + 'use strict'; + /* global phpbbWebpushOptions */ phpbb.webpush.init(phpbbWebpushOptions); }); From 27d927ebc2db26d974212a05ffc2a67a513ac29d Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 16 Dec 2025 23:18:49 -0800 Subject: [PATCH 3/6] Add alert bell icon to prompt --- styles/all/template/webpush_popup.html | 8 +++++++- styles/all/theme/phpbb_wpn.css | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/styles/all/template/webpush_popup.html b/styles/all/template/webpush_popup.html index dea6c96..deb9133 100644 --- a/styles/all/template/webpush_popup.html +++ b/styles/all/template/webpush_popup.html @@ -2,7 +2,13 @@