ui: use hidden state for shell dropdowns
This commit is contained in:
+9
-9
@@ -10,33 +10,33 @@
|
||||
var mobileNav = document.querySelector('.mobile-nav');
|
||||
|
||||
if (dropdown) {
|
||||
dropdown.style.display = 'none';
|
||||
dropdown.hidden = true;
|
||||
}
|
||||
if (mobileNav) {
|
||||
mobileNav.style.display = 'none';
|
||||
mobileNav.hidden = true;
|
||||
}
|
||||
|
||||
if (avatar && dropdown) {
|
||||
avatar.addEventListener('click', function (event) {
|
||||
event.stopPropagation();
|
||||
dropdown.style.display = dropdown.style.display === 'none' ? 'block' : 'none';
|
||||
dropdown.hidden = !dropdown.hidden;
|
||||
});
|
||||
}
|
||||
|
||||
if (hamburger && mobileNav) {
|
||||
hamburger.addEventListener('click', function (event) {
|
||||
event.stopPropagation();
|
||||
mobileNav.style.display = mobileNav.style.display === 'none' ? 'block' : 'none';
|
||||
hamburger.classList.toggle('open', mobileNav.style.display !== 'none');
|
||||
mobileNav.hidden = !mobileNav.hidden;
|
||||
hamburger.classList.toggle('open', !mobileNav.hidden);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('click', function (event) {
|
||||
if (dropdown && !event.target.closest('.user-menu')) {
|
||||
dropdown.style.display = 'none';
|
||||
dropdown.hidden = true;
|
||||
}
|
||||
if (mobileNav && !event.target.closest('.navbar') && !event.target.closest('.mobile-nav')) {
|
||||
mobileNav.style.display = 'none';
|
||||
mobileNav.hidden = true;
|
||||
if (hamburger) {
|
||||
hamburger.classList.remove('open');
|
||||
}
|
||||
@@ -52,7 +52,7 @@
|
||||
document.querySelectorAll('[data-action="profile"]').forEach(function (button) {
|
||||
button.addEventListener('click', function () {
|
||||
if (dropdown) {
|
||||
dropdown.style.display = 'none';
|
||||
dropdown.hidden = true;
|
||||
}
|
||||
window.location.href = ((window.CrankRoutes && window.CrankRoutes.settings) || '/settings') + '#profile';
|
||||
});
|
||||
@@ -61,7 +61,7 @@
|
||||
document.querySelectorAll('[data-action="settings-link"]').forEach(function (button) {
|
||||
button.addEventListener('click', function () {
|
||||
if (dropdown) {
|
||||
dropdown.style.display = 'none';
|
||||
dropdown.hidden = true;
|
||||
}
|
||||
window.location.href = (window.CrankRoutes && window.CrankRoutes.settings) || '/settings';
|
||||
});
|
||||
|
||||
@@ -169,7 +169,7 @@ function renderWorkspaceList() {
|
||||
manageLink.href = (window.CrankRoutes && window.CrankRoutes.workspaceSetup) || '/workspace-setup';
|
||||
manageLink.addEventListener('click', function() {
|
||||
var dd = document.getElementById('ws-dropdown');
|
||||
if (dd) dd.style.display = 'none';
|
||||
if (dd) dd.hidden = true;
|
||||
});
|
||||
manageLink.appendChild(
|
||||
buildIconSvg(
|
||||
@@ -222,7 +222,7 @@ function initWorkspaceSwitcher() {
|
||||
function toggleWsSwitcher(e) {
|
||||
e.stopPropagation();
|
||||
var dd = document.getElementById('ws-dropdown');
|
||||
if (dd) dd.style.display = dd.style.display === 'none' ? '' : 'none';
|
||||
if (dd) dd.hidden = !dd.hidden;
|
||||
}
|
||||
|
||||
function switchWorkspace(workspaceId) {
|
||||
@@ -230,7 +230,7 @@ function switchWorkspace(workspaceId) {
|
||||
if (!workspace) return;
|
||||
|
||||
var dd = document.getElementById('ws-dropdown');
|
||||
if (dd) dd.style.display = 'none';
|
||||
if (dd) dd.hidden = true;
|
||||
|
||||
if (!window.CrankApi || !window.CrankAuth || typeof window.CrankAuth.replaceSession !== 'function') {
|
||||
cacheCurrentWorkspace(workspace);
|
||||
@@ -282,6 +282,6 @@ window.addEventListener('crank:sessionchange', function() {
|
||||
document.addEventListener('click', function(e) {
|
||||
if (!e.target.closest('#ws-switcher')) {
|
||||
var dd = document.getElementById('ws-dropdown');
|
||||
if (dd) dd.style.display = 'none';
|
||||
if (dd) dd.hidden = true;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user