Spaces:
Running
Running
Commit ·
73ae9fa
1
Parent(s): af270a2
Fix file menu action clicks and star icon rendering
Browse files- js/ui/uiRenderer.js +19 -8
js/ui/uiRenderer.js
CHANGED
|
@@ -171,7 +171,7 @@ export class UIRenderer {
|
|
| 171 |
<div class="quick-actions">
|
| 172 |
<button class="quick-btn" data-action="preview" title="Preview"><i class="ph-fill ph-eye"></i></button>
|
| 173 |
<button class="quick-btn" data-action="download" title="Download"><i class="ph-fill ph-download-simple"></i></button>
|
| 174 |
-
<button class="quick-btn" data-action="star" title="${starred ? 'Unstar' : 'Star'}"><i class="ph-
|
| 175 |
<button class="quick-btn" data-action="rename" title="Rename"><i class="ph-fill ph-pencil-simple"></i></button>
|
| 176 |
<button class="quick-btn" data-action="history" title="History"><i class="ph-fill ph-clock-counter-clockwise"></i></button>
|
| 177 |
</div>`;
|
|
@@ -183,7 +183,7 @@ export class UIRenderer {
|
|
| 183 |
<span class="list-meta">${size} • ${ext}</span>
|
| 184 |
</div>
|
| 185 |
<div class="list-actions">
|
| 186 |
-
<button class="icon-btn" data-action="star" title="${starred ? 'Unstar' : 'Star'}"><i class="ph-
|
| 187 |
<button class="icon-btn" data-action="rename" title="Rename"><i class="ph-fill ph-pencil-simple"></i></button>
|
| 188 |
<button class="icon-btn" data-action="history" title="History"><i class="ph-fill ph-clock-counter-clockwise"></i></button>
|
| 189 |
<button class="icon-btn" data-action="download" title="Download"><i class="ph-fill ph-download-simple"></i></button>
|
|
@@ -196,18 +196,21 @@ export class UIRenderer {
|
|
| 196 |
actions.onPreview(file);
|
| 197 |
};
|
| 198 |
|
| 199 |
-
|
| 200 |
-
const btn = e.target.closest('[data-action]');
|
| 201 |
-
if (!btn) return;
|
| 202 |
-
e.stopPropagation();
|
| 203 |
-
card.querySelectorAll('.dropdown-menu.open').forEach(m => m.classList.remove('open'));
|
| 204 |
-
const action = btn.dataset.action;
|
| 205 |
if (action === 'preview') actions.onPreview(file);
|
| 206 |
else if (action === 'download') actions.onDownload(url, file.name);
|
| 207 |
else if (action === 'rename') actions.onRename(file.path, file.name);
|
| 208 |
else if (action === 'star') actions.onStar(file.path);
|
| 209 |
else if (action === 'delete') actions.onDelete(file.path, file.name);
|
| 210 |
else if (action === 'history') actions.onHistory(file.path, file.name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
});
|
| 212 |
|
| 213 |
const menuBtn = card.querySelector('.card-menu-btn');
|
|
@@ -223,6 +226,14 @@ export class UIRenderer {
|
|
| 223 |
};
|
| 224 |
|
| 225 |
menu.onclick = (e) => e.stopPropagation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
}
|
| 227 |
|
| 228 |
this.containers.files.appendChild(card);
|
|
|
|
| 171 |
<div class="quick-actions">
|
| 172 |
<button class="quick-btn" data-action="preview" title="Preview"><i class="ph-fill ph-eye"></i></button>
|
| 173 |
<button class="quick-btn" data-action="download" title="Download"><i class="ph-fill ph-download-simple"></i></button>
|
| 174 |
+
<button class="quick-btn" data-action="star" title="${starred ? 'Unstar' : 'Star'}"><i class="ph-bold ph-star"></i></button>
|
| 175 |
<button class="quick-btn" data-action="rename" title="Rename"><i class="ph-fill ph-pencil-simple"></i></button>
|
| 176 |
<button class="quick-btn" data-action="history" title="History"><i class="ph-fill ph-clock-counter-clockwise"></i></button>
|
| 177 |
</div>`;
|
|
|
|
| 183 |
<span class="list-meta">${size} • ${ext}</span>
|
| 184 |
</div>
|
| 185 |
<div class="list-actions">
|
| 186 |
+
<button class="icon-btn" data-action="star" title="${starred ? 'Unstar' : 'Star'}"><i class="ph-bold ph-star"></i></button>
|
| 187 |
<button class="icon-btn" data-action="rename" title="Rename"><i class="ph-fill ph-pencil-simple"></i></button>
|
| 188 |
<button class="icon-btn" data-action="history" title="History"><i class="ph-fill ph-clock-counter-clockwise"></i></button>
|
| 189 |
<button class="icon-btn" data-action="download" title="Download"><i class="ph-fill ph-download-simple"></i></button>
|
|
|
|
| 196 |
actions.onPreview(file);
|
| 197 |
};
|
| 198 |
|
| 199 |
+
const runAction = (action) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
if (action === 'preview') actions.onPreview(file);
|
| 201 |
else if (action === 'download') actions.onDownload(url, file.name);
|
| 202 |
else if (action === 'rename') actions.onRename(file.path, file.name);
|
| 203 |
else if (action === 'star') actions.onStar(file.path);
|
| 204 |
else if (action === 'delete') actions.onDelete(file.path, file.name);
|
| 205 |
else if (action === 'history') actions.onHistory(file.path, file.name);
|
| 206 |
+
};
|
| 207 |
+
|
| 208 |
+
card.addEventListener('click', (e) => {
|
| 209 |
+
const btn = e.target.closest('[data-action]');
|
| 210 |
+
if (!btn) return;
|
| 211 |
+
e.stopPropagation();
|
| 212 |
+
card.querySelectorAll('.dropdown-menu.open').forEach(m => m.classList.remove('open'));
|
| 213 |
+
runAction(btn.dataset.action);
|
| 214 |
});
|
| 215 |
|
| 216 |
const menuBtn = card.querySelector('.card-menu-btn');
|
|
|
|
| 226 |
};
|
| 227 |
|
| 228 |
menu.onclick = (e) => e.stopPropagation();
|
| 229 |
+
menu.querySelectorAll('[data-action]').forEach((btn) => {
|
| 230 |
+
btn.onclick = (e) => {
|
| 231 |
+
e.preventDefault();
|
| 232 |
+
e.stopPropagation();
|
| 233 |
+
menu.classList.remove('open');
|
| 234 |
+
runAction(btn.dataset.action);
|
| 235 |
+
};
|
| 236 |
+
});
|
| 237 |
}
|
| 238 |
|
| 239 |
this.containers.files.appendChild(card);
|