Skip to content

Commit 7fe0aa0

Browse files
authored
Merge pull request #122 from iMattPro/fixes
More popup setting tweaks
2 parents e9af8d0 + 1a474a1 commit 7fe0aa0

File tree

7 files changed

+21
-28
lines changed

7 files changed

+21
-28
lines changed

language/en/webpushnotifications_module_ucp.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
'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.',
5454
'NOTIFY_WEBPUSH_POPUP_ALLOW' => 'Allow',
5555
'NOTIFY_WEBPUSH_POPUP_DENY' => 'Deny',
56-
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Disable “Allow Browser Notifications” prompts',
57-
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Toggle this on to stop us from asking you to enable web push notifications on any of your devices. Note that we won’t be able to alert you if your web push notifications ever become disabled.',
56+
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Notification reminder pop-ups',
57+
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'We show a reminder asking you to allow browser notifications when they are not currently enabled or when we cannot detect them. Turn this off to permanently stop these reminder pop-ups on all your devices. If you turn this off, you will not be warned if your browser notifications stop working in the future.',
58+
'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Enable reminders',
59+
'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Disable reminders',
5860
]);

language/ru/webpushnotifications_module_ucp.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
'NOTIFY_WEBPUSH_POPUP_MESSAGE' => 'Браузерные уведомления позволяют быстро получать информацию о новых ответах, личных сообщениях и других активностях на данной конференции. Функцию можно отключить или включить в любое время в настройках уведомлений в Личном разделе.',
5454
'NOTIFY_WEBPUSH_POPUP_ALLOW' => 'Включить',
5555
'NOTIFY_WEBPUSH_POPUP_DENY' => 'Отклонить',
56-
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Отключить запросы «Включить браузерные уведомления»',
57-
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Включите этот параметр, чтобы мы больше не спрашивали вас о включении веб-push-уведомлений на любом из ваших устройств. Обратите внимание, что в этом случае мы не сможем предупредить вас, если веб-push-уведомления будут отключены.',
56+
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Всплывающие напоминания о уведомлениях',
57+
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Мы показываем напоминание с просьбой разрешить уведомления браузера, если они сейчас не включены или если мы не можем их обнаружить. Отключите эту функцию, чтобы навсегда убрать эти напоминания на всех ваших устройствах. Если вы отключите эту функцию, вы больше не будете получать предупреждения, если уведомления браузера перестанут работать в будущем.',
58+
'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Включить напоминания',
59+
'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Отключить напоминания',
5860
]);

notification/method/webpush.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public function get_ucp_template_data(helper $controller_helper, form_helper $fo
395395
'U_WEBPUSH_WORKER_URL' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_worker_controller'),
396396
'SUBSCRIPTIONS' => $subscriptions,
397397
'WEBPUSH_FORM_TOKENS' => $form_helper->get_form_tokens(\phpbb\webpushnotifications\ucp\controller\webpush::FORM_TOKEN_UCP),
398-
'S_WEBPUSH_POPUP_PROMPT' => $this->config['wpn_webpush_popup_prompt'] && $this->user->id() != ANONYMOUS && $this->user->data['user_type'] != USER_IGNORE && !($this->user->data['user_wpn_popup_disabled'] ?? 0),
398+
'S_WEBPUSH_POPUP_PROMPT' => $this->config['wpn_webpush_popup_prompt'] && $this->user->id() != ANONYMOUS && $this->user->data['user_type'] != USER_IGNORE,
399399
'S_WEBPUSH_POPUP_DISABLED' => $this->user->data['user_wpn_popup_disabled'] ?? 0,
400400
];
401401
}

styles/all/template/webpush.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -389,19 +389,10 @@ function PhpbbWebpush() {
389389
.then(data => {
390390
loadingIndicator.fadeOut(phpbb.alertTime);
391391
if (data.success) {
392-
// Update toggle icon based on new state
392+
// Update button text based on new state
393393
const button = document.getElementById('toggle_popup_prompt');
394394
if (button) {
395-
const icon = button.querySelector('i');
396-
if (icon) {
397-
if (data.disabled) {
398-
icon.classList.remove('fa-toggle-off');
399-
icon.classList.add('fa-toggle-on');
400-
} else {
401-
icon.classList.remove('fa-toggle-on');
402-
icon.classList.add('fa-toggle-off');
403-
}
404-
}
395+
button.value = data.disabled ? button.getAttribute('data-l-enable') : button.getAttribute('data-l-disable');
405396
}
406397
if ('form_tokens' in data) {
407398
updateFormTokens(data.form_tokens);

styles/all/template/webpush_popup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% if S_WEBPUSH_POPUP_PROMPT %}
1+
{% if S_WEBPUSH_POPUP_PROMPT and not S_WEBPUSH_POPUP_DISABLED %}
22
<div id="wpn_popup_prompt" class="wpn-popup-overlay" style="display:none;" role="dialog" aria-modal="true" aria-labelledby="wpn_popup_title" aria-describedby="wpn_popup_message">
33
<div class="wpn-popup-container">
44
<div class="wpn-popup-content">

styles/prosilver/template/event/ucp_notifications_content_before.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
<input id="unsubscribe_webpush" type="submit" name="unsubscribe_webpush" value="{{ lang('NOTIFY_WEBPUSH_DISABLE') }}" class="wpn button1 button button-form hidden">
1010
</dd>
1111
</dl>
12+
{% if S_WEBPUSH_POPUP_PROMPT %}
1213
<dl>
1314
<dt><label for="toggle_popup_prompt">{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE') ~ lang('COLON') }}</label><br><span>{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN') }}</span></dt>
1415
<dd>
15-
<button id="toggle_popup_prompt" type="button" name="toggle_popup_prompt" aria-label="{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE') }}">
16-
<i class="icon icon-lg fa-fw fa-toggle-{% if S_WEBPUSH_POPUP_DISABLED %}on{% else %}off{% endif %}" aria-hidden="true"></i>
17-
</button>
16+
<input id="toggle_popup_prompt" type="button" name="toggle_popup_prompt" value="{{ lang(S_WEBPUSH_POPUP_DISABLED ? 'NOTIFY_WEBPUSH_POPUP_ENABLER' : 'NOTIFY_WEBPUSH_POPUP_DISABLER') }}" class="button1 button button-form" data-l-disable="{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLER')|e('html_attr') }}" data-l-enable="{{ lang('NOTIFY_WEBPUSH_POPUP_ENABLER')|e('html_attr') }}">
1817
</dd>
1918
</dl>
19+
{% endif %}
2020
</fieldset>
2121
</div>
2222
</div>

tests/functional/functional_test.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,9 @@ public function test_popup_preference_toggle()
178178
$this->assertCount(1, $crawler->filter('#toggle_popup_prompt'));
179179
$this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_DISABLE', $crawler->filter('label[for="toggle_popup_prompt"]')->text());
180180

181-
// Assert toggle is initially off (prompts enabled)
182-
$toggle_icon = $crawler->filter('#toggle_popup_prompt i');
183-
$this->assertCount(1, $toggle_icon);
184-
$this->assertTrue($toggle_icon->attr('class') !== null && strpos($toggle_icon->attr('class'), 'fa-toggle-off') !== false);
181+
// Assert button text shows "Disable" initially (prompts enabled)
182+
$button_value = $crawler->filter('#toggle_popup_prompt')->attr('value');
183+
$this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_DISABLER', $button_value);
185184

186185
// After user disables popup (in reality this would be via AJAX, but we test the state)
187186
// Set user preference to disabled via DB
@@ -194,10 +193,9 @@ public function test_popup_preference_toggle()
194193
// Reload page
195194
$crawler = self::request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');
196195

197-
// Assert toggle is now on (prompts disabled)
198-
$toggle_icon = $crawler->filter('#toggle_popup_prompt i');
199-
$this->assertCount(1, $toggle_icon);
200-
$this->assertTrue($toggle_icon->attr('class') !== null && strpos($toggle_icon->attr('class'), 'fa-toggle-on') !== false);
196+
// Assert button text shows "Enable" now (prompts disabled)
197+
$button_value = $crawler->filter('#toggle_popup_prompt')->attr('value');
198+
$this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_ENABLER', $button_value);
201199

202200
// Assert popup is not shown on index when user has disabled it
203201
$crawler = self::request('GET', 'index.php');

0 commit comments

Comments
 (0)