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:
@@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user