BlueGit

timfa filemanager

Merge fix: animate update badge in user dropdown

timfa Tim Falken · pushed by timfa

Authored 2026-05-17 · 6 months ago

Hash
90f5880c180456e76d49ab7cdbc807efc633573a
3 files changed +66 −0
.github/technical-reference.md +2 −0
@@ -171,6 +171,8 @@
171 171 - loadOneFolderIcon(iconEl) - Fetches /api/files/folder-icon then the thumbnail blob and overlays it inside the folder SVG; no-op if no icon available.
172 172 - applyFolderThumbnail(iconEl, srcUrl) - Injects an SVG <image> element clipped to the folder outline path into the folder's icon SVG.
173 173 - initTopbarDropdowns() / closeTopbarDropdowns() - Controls Upload/User roll-down menus (open/close, outside-click close, Escape close) without resizing the top bar.
174 - setAdminUpdateBadge(count) - Renders the update-count badge and coordinates its anchor between User trigger and Admin menu item.
175 - syncAdminUpdateBadgeAnchor() / animateBadgeToTarget(targetEl) - Moves the update badge between User trigger and Admin menu item with a smooth transition while the User dropdown opens/closes.
174 176 - openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail files from the folder (including video thumbnails); allows selection, clearing, and cancellation.
175 177 - openIconPickerModal(options) - Shared icon-picker modal used by folder-icon and global-favicon flows; includes live thumbnail-name filtering.
176 178 - openGlobalFaviconPicker() - Opens a debounced, server-backed image-search modal across all accessible roots and sets/clears global favicon via `/files/global-favicon`.
@@ -171,6 +171,8 @@
171- loadOneFolderIcon(iconEl) - Fetches /api/files/folder-icon then the thumbnail blob and overlays it inside the folder SVG; no-op if no icon available.
171- loadOneFolderIcon(iconEl) - Fetches /api/files/folder-icon then the thumbnail blob and overlays it inside the folder SVG; no-op if no icon available.
172- applyFolderThumbnail(iconEl, srcUrl) - Injects an SVG <image> element clipped to the folder outline path into the folder's icon SVG.
172- applyFolderThumbnail(iconEl, srcUrl) - Injects an SVG <image> element clipped to the folder outline path into the folder's icon SVG.
173- initTopbarDropdowns() / closeTopbarDropdowns() - Controls Upload/User roll-down menus (open/close, outside-click close, Escape close) without resizing the top bar.
173- initTopbarDropdowns() / closeTopbarDropdowns() - Controls Upload/User roll-down menus (open/close, outside-click close, Escape close) without resizing the top bar.
174- setAdminUpdateBadge(count) - Renders the update-count badge and coordinates its anchor between User trigger and Admin menu item.
175- syncAdminUpdateBadgeAnchor() / animateBadgeToTarget(targetEl) - Moves the update badge between User trigger and Admin menu item with a smooth transition while the User dropdown opens/closes.
174- openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail files from the folder (including video thumbnails); allows selection, clearing, and cancellation.
176- openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail files from the folder (including video thumbnails); allows selection, clearing, and cancellation.
175- openIconPickerModal(options) - Shared icon-picker modal used by folder-icon and global-favicon flows; includes live thumbnail-name filtering.
177- openIconPickerModal(options) - Shared icon-picker modal used by folder-icon and global-favicon flows; includes live thumbnail-name filtering.
176- openGlobalFaviconPicker() - Opens a debounced, server-backed image-search modal across all accessible roots and sets/clears global favicon via `/files/global-favicon`.
178- openGlobalFaviconPicker() - Opens a debounced, server-backed image-search modal across all accessible roots and sets/clears global favicon via `/files/global-favicon`.
public/app.js +58 −0
@@ -4982,6 +4982,59 @@ async function deleteItem (item)
4982 4982
4983 4983 let _adminUpdateStatus = null;
4984 4984
4985 function animateBadgeToTarget (targetEl)
4986 {
4987 const badge = document.getElementById('admin-update-badge');
4988 if (!badge || !targetEl) return;
4989 if (badge.parentElement === targetEl) return;
4990
4991 const from = badge.getBoundingClientRect();
4992 targetEl.appendChild(badge);
4993 const to = badge.getBoundingClientRect();
4994
4995 const dx = from.left - to.left;
4996 const dy = from.top - to.top;
4997
4998 badge.style.transition = 'none';
4999 badge.style.transform = `translate(${dx}px, ${dy}px)`;
5000 badge.style.willChange = 'transform';
5001
5002 requestAnimationFrame(() =>
5003 {
5004 badge.style.transition = 'transform 240ms cubic-bezier(0.22, 1, 0.36, 1)';
5005 badge.style.transform = 'translate(0, 0)';
5006 });
5007
5008 const cleanup = () =>
5009 {
5010 badge.style.transition = '';
5011 badge.style.transform = '';
5012 badge.style.willChange = '';
5013 badge.removeEventListener('transitionend', cleanup);
5014 };
5015 badge.addEventListener('transitionend', cleanup);
5016 }
5017
5018 function syncAdminUpdateBadgeAnchor ()
5019 {
5020 const badge = document.getElementById('admin-update-badge');
5021 const userMenuBtn = document.getElementById('btn-user-menu');
5022 const adminBtn = document.getElementById('btn-admin');
5023 if (!badge || !userMenuBtn || !adminBtn) return;
5024
5025 const userDropdown = userMenuBtn.closest('.topbar-dropdown');
5026 const userMenuOpen = !!(userDropdown && userDropdown.classList.contains('open'));
5027 const target = userMenuOpen ? adminBtn : userMenuBtn;
5028
5029 if (badge.classList.contains('hidden'))
5030 {
5031 if (badge.parentElement !== userMenuBtn) userMenuBtn.appendChild(badge);
5032 return;
5033 }
5034
5035 animateBadgeToTarget(target);
5036 }
5037
4985 5038 function setAdminUpdateBadge (count)
4986 5039 {
4987 5040 const badge = document.getElementById('admin-update-badge');
@@ -4992,6 +5045,7 @@ function setAdminUpdateBadge (count)
4992 5045 {
4993 5046 badge.classList.add('hidden');
4994 5047 badge.textContent = '';
5048 if (badge.parentElement !== userMenuBtn) userMenuBtn.appendChild(badge);
4995 5049 userMenuBtn.removeAttribute('data-update-count');
4996 5050 return;
4997 5051 }
@@ -5001,6 +5055,7 @@ function setAdminUpdateBadge (count)
5001 5055 badge.textContent = capped >= 99 ? '99+' : String(capped);
5002 5056 badge.classList.remove('hidden');
5003 5057 userMenuBtn.dataset.updateCount = String(whole);
5058 syncAdminUpdateBadgeAnchor();
5004 5059 }
5005 5060
5006 5061 function pulseAdminUpdateButton ()
@@ -5881,6 +5936,8 @@ function closeTopbarDropdowns ()
5881 5936 const trigger = dropdown.querySelector('button[aria-expanded]');
5882 5937 if (trigger) trigger.setAttribute('aria-expanded', 'false');
5883 5938 });
5939
5940 syncAdminUpdateBadgeAnchor();
5884 5941 }
5885 5942
5886 5943 function initTopbarDropdowns ()
@@ -5899,6 +5956,7 @@ function initTopbarDropdowns ()
5899 5956 {
5900 5957 dropdown.classList.add('open');
5901 5958 trigger.setAttribute('aria-expanded', 'true');
5959 syncAdminUpdateBadgeAnchor();
5902 5960 }
5903 5961 });
5904 5962
@@ -4982,6 +4982,59 @@ async function deleteItem (item)
4982
4982
4983let _adminUpdateStatus = null;
4983let _adminUpdateStatus = null;
4984
4984
4985function animateBadgeToTarget (targetEl)
4986{
4987 const badge = document.getElementById('admin-update-badge');
4988 if (!badge || !targetEl) return;
4989 if (badge.parentElement === targetEl) return;
4990
4991 const from = badge.getBoundingClientRect();
4992 targetEl.appendChild(badge);
4993 const to = badge.getBoundingClientRect();
4994
4995 const dx = from.left - to.left;
4996 const dy = from.top - to.top;
4997
4998 badge.style.transition = 'none';
4999 badge.style.transform = `translate(${dx}px, ${dy}px)`;
5000 badge.style.willChange = 'transform';
5001
5002 requestAnimationFrame(() =>
5003 {
5004 badge.style.transition = 'transform 240ms cubic-bezier(0.22, 1, 0.36, 1)';
5005 badge.style.transform = 'translate(0, 0)';
5006 });
5007
5008 const cleanup = () =>
5009 {
5010 badge.style.transition = '';
5011 badge.style.transform = '';
5012 badge.style.willChange = '';
5013 badge.removeEventListener('transitionend', cleanup);
5014 };
5015 badge.addEventListener('transitionend', cleanup);
5016}
5017
5018function syncAdminUpdateBadgeAnchor ()
5019{
5020 const badge = document.getElementById('admin-update-badge');
5021 const userMenuBtn = document.getElementById('btn-user-menu');
5022 const adminBtn = document.getElementById('btn-admin');
5023 if (!badge || !userMenuBtn || !adminBtn) return;
5024
5025 const userDropdown = userMenuBtn.closest('.topbar-dropdown');
5026 const userMenuOpen = !!(userDropdown && userDropdown.classList.contains('open'));
5027 const target = userMenuOpen ? adminBtn : userMenuBtn;
5028
5029 if (badge.classList.contains('hidden'))
5030 {
5031 if (badge.parentElement !== userMenuBtn) userMenuBtn.appendChild(badge);
5032 return;
5033 }
5034
5035 animateBadgeToTarget(target);
5036}
5037
4985function setAdminUpdateBadge (count)
5038function setAdminUpdateBadge (count)
4986{
5039{
4987 const badge = document.getElementById('admin-update-badge');
5040 const badge = document.getElementById('admin-update-badge');
@@ -4992,6 +5045,7 @@ function setAdminUpdateBadge (count)
4992 {
5045 {
4993 badge.classList.add('hidden');
5046 badge.classList.add('hidden');
4994 badge.textContent = '';
5047 badge.textContent = '';
5048 if (badge.parentElement !== userMenuBtn) userMenuBtn.appendChild(badge);
4995 userMenuBtn.removeAttribute('data-update-count');
5049 userMenuBtn.removeAttribute('data-update-count');
4996 return;
5050 return;
4997 }
5051 }
@@ -5001,6 +5055,7 @@ function setAdminUpdateBadge (count)
5001 badge.textContent = capped >= 99 ? '99+' : String(capped);
5055 badge.textContent = capped >= 99 ? '99+' : String(capped);
5002 badge.classList.remove('hidden');
5056 badge.classList.remove('hidden');
5003 userMenuBtn.dataset.updateCount = String(whole);
5057 userMenuBtn.dataset.updateCount = String(whole);
5058 syncAdminUpdateBadgeAnchor();
5004}
5059}
5005
5060
5006function pulseAdminUpdateButton ()
5061function pulseAdminUpdateButton ()
@@ -5881,6 +5936,8 @@ function closeTopbarDropdowns ()
5881 const trigger = dropdown.querySelector('button[aria-expanded]');
5936 const trigger = dropdown.querySelector('button[aria-expanded]');
5882 if (trigger) trigger.setAttribute('aria-expanded', 'false');
5937 if (trigger) trigger.setAttribute('aria-expanded', 'false');
5883 });
5938 });
5939
5940 syncAdminUpdateBadgeAnchor();
5884}
5941}
5885
5942
5886function initTopbarDropdowns ()
5943function initTopbarDropdowns ()
@@ -5899,6 +5956,7 @@ function initTopbarDropdowns ()
5899 {
5956 {
5900 dropdown.classList.add('open');
5957 dropdown.classList.add('open');
5901 trigger.setAttribute('aria-expanded', 'true');
5958 trigger.setAttribute('aria-expanded', 'true');
5959 syncAdminUpdateBadgeAnchor();
5902 }
5960 }
5903 });
5961 });
5904
5962
public/style.css +6 −0
@@ -315,6 +315,7 @@ button.danger.admin-update-highlight {
315 315 border-radius: 6px;
316 316 padding: 0.45rem 0.55rem;
317 317 text-align: left;
318 position: relative;
318 319 }
319 320
320 321 .topbar-menu-item svg {
@@ -328,6 +329,11 @@ button.danger.admin-update-highlight {
328 329 color: var(--text);
329 330 }
330 331
332 .topbar-menu-item .topbar-badge {
333 top: -0.24rem;
334 right: -0.22rem;
335 }
336
331 337 .top-search {
332 338 display: flex;
333 339 align-items: center;
@@ -315,6 +315,7 @@ button.danger.admin-update-highlight {
315 border-radius: 6px;
315 border-radius: 6px;
316 padding: 0.45rem 0.55rem;
316 padding: 0.45rem 0.55rem;
317 text-align: left;
317 text-align: left;
318 position: relative;
318}
319}
319
320
320.topbar-menu-item svg {
321.topbar-menu-item svg {
@@ -328,6 +329,11 @@ button.danger.admin-update-highlight {
328 color: var(--text);
329 color: var(--text);
329}
330}
330
331
332.topbar-menu-item .topbar-badge {
333 top: -0.24rem;
334 right: -0.22rem;
335}
336
331.top-search {
337.top-search {
332 display: flex;
338 display: flex;
333 align-items: center;
339 align-items: center;