MCPcopy Create free account
hub / github.com/error311/FileRise / fileDragStartHandler

Function fileDragStartHandler

public/js/fileDragDrop.js:231–268  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

229
230/* ---------------- drag start (rows/cards) ---------------- */
231export function fileDragStartHandler(event) {
232 try { cancelHoverPreview(); } catch (e) {}
233 const row = getRowEl(event.currentTarget);
234 if (!row) return;
235
236 // Use current selection if present; otherwise drag just this row’s file
237 let names = getSelectedFileNames(row);
238 if (names.length === 0) {
239 const single = getNameFromAny(row);
240 if (single) names = [single];
241 }
242 if (names.length === 0) return;
243
244 const sourceFolder = getPaneFolderForElement(row) || window.currentFolder || 'root';
245 const sourceId = getPaneSourceIdForElement(row) || getActiveSourceId();
246 const fileList = getPaneFileDataForElement(row);
247 const totals = getTransferTotalsForNames(names, fileList);
248 const payload = {
249 files: names,
250 sourceFolder,
251 sourceId,
252 totalBytes: totals.totalBytes,
253 totalItems: totals.itemCount,
254 bytesKnown: totals.bytesKnown
255 };
256
257 // primary payload
258 event.dataTransfer.setData('application/json', JSON.stringify(payload));
259 // fallback (lets some environments read something human)
260 event.dataTransfer.setData('text/plain', names.join('\n'));
261
262 // nicer drag image
263 const dragLabel = (names.length === 1) ? names[0] : `${names.length} files`;
264 const ghost = makeDragImage(dragLabel, names.length === 1 ? 'insert_drive_file' : 'folder');
265 event.dataTransfer.setDragImage(ghost, 6, 6);
266 // clean up the ghost as soon as the browser has captured it
267 setTimeout(() => { try { document.body.removeChild(ghost); } catch (e) { } }, 0);
268}
269
270/* ---------------- folder targets ---------------- */
271export function folderDragOverHandler(event) {

Callers

nothing calls this directly

Calls 10

cancelHoverPreviewFunction · 0.85
getRowElFunction · 0.85
getSelectedFileNamesFunction · 0.85
getNameFromAnyFunction · 0.85
getPaneFolderForElementFunction · 0.85
makeDragImageFunction · 0.85
getActiveSourceIdFunction · 0.70

Tested by

no test coverage detected