1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 16:56:44 +02:00

[ticket/17371] Improve UX for disabled state

PHPBB-17371

Signed-off-by: Matt Friedman <maf675@gmail.com>
This commit is contained in:
Matt Friedman
2024-07-17 09:29:30 -07:00
parent 4da0a75efa
commit 7252345911
3 changed files with 27 additions and 6 deletions

View File

@@ -51,7 +51,7 @@ function PhpbbWebpush() {
// Service workers are only supported in secure context
if (window.isSecureContext !== true) {
subscribeButton.disabled = true;
setDisabledState();
return;
}
@@ -66,13 +66,33 @@ function PhpbbWebpush() {
.catch(error => {
console.info(error);
// Service worker could not be registered
subscribeButton.disabled = true;
setDisabledState();
});
} else {
subscribeButton.disabled = true;
setDisabledState();
}
};
/**
* Disable subscribing buttons, update subscribe button text and hide dropdown toggle
*
* @return void
*/
function setDisabledState() {
subscribeButton.disabled = true;
const notificationList = document.getElementById('notification-menu');
const subscribeToggle = notificationList.querySelector('.webpush-subscribe');
if (subscribeToggle) {
subscribeToggle.style.display = 'none';
}
if (subscribeButton.type === 'submit' || subscribeButton.classList.contains('button')) {
subscribeButton.value = subscribeButton.getAttribute('data-disabled-msg');
}
}
/**
* Update button state depending on notifications state
*