@@ -92,23 +98,41 @@ function showToast(msg, type = 'success') {
function buildTransferDropdown(sourceId, currentUsername) {
const others = ALL_ACCOUNTS.filter(a => a.username !== currentUsername);
if (!others.length) {
- return `
`;
+ return `
`;
}
- const items = others.map(a =>
- `
- ${escHtml(a.username)}${a.display_name ? ' — '+escHtml(a.display_name)+'' : ''}
- `
- ).join('');
- return `
`;
+ return `
`;
}
+function openTransferMenu(e, sourceId, currentUsername) {
+ e.stopPropagation();
+ const btn = e.currentTarget;
+ const rect = btn.getBoundingClientRect();
+ const menu = document.getElementById('transfer-menu');
+ const list = document.getElementById('transfer-menu-list');
+ const others = ALL_ACCOUNTS.filter(a => a.username !== currentUsername);
+
+ list.innerHTML = others.map(a =>
+ `
+ ${escHtml(a.username)}
+ ${a.display_name ? ' — '+escHtml(a.display_name)+'' : ''}
+ `
+ ).join('');
+
+ // Positionne sous le bouton, recadre si déborde à droite
+ menu.style.display = 'block';
+ const menuW = menu.offsetWidth;
+ let left = rect.left;
+ if (left + menuW > window.innerWidth - 8) left = window.innerWidth - menuW - 8;
+ menu.style.top = (rect.bottom + 4) + 'px';
+ menu.style.left = left + 'px';
+}
+
+// Ferme le menu si on clique ailleurs
+document.addEventListener('click', () => {
+ document.getElementById('transfer-menu').style.display = 'none';
+});
+
function doTransfer(e, sourceId, targetId, targetName) {
e.preventDefault();
const fd = new FormData();