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

Function handleFolderDragStart

public/js/folderManager.js:1923–2079  ·  view source on GitHub ↗
(ev, fullPath, optEl)

Source from the content-addressed store, hash-verified

1921}
1922
1923function handleFolderDragStart(ev, fullPath, optEl) {
1924 const dt = ev.dataTransfer;
1925 if (!dt) return;
1926
1927 // Drag payload
1928 try { dt.setData('application/x-filerise-folder', fullPath); } catch (e) {}
1929 try { dt.setData('text/plain', fullPath); } catch (e) {}
1930 dt.effectAllowed = 'move';
1931
1932 const row = optEl.closest('.folder-row') || optEl;
1933 if (!row || !dt.setDragImage) return;
1934
1935 const isDark = document.body.classList.contains('dark-mode');
1936
1937 // --- Resolve folder colors from CSS vars (per-folder color picker) ---
1938 let frontColor = '';
1939 let backColor = '';
1940 let strokeColor = '';
1941 try {
1942 const src = optEl || row;
1943 if (src) {
1944 const cs = getComputedStyle(src);
1945 frontColor = (cs.getPropertyValue('--filr-folder-front') || '').trim();
1946 backColor = (cs.getPropertyValue('--filr-folder-back') || '').trim();
1947 strokeColor = (cs.getPropertyValue('--filr-folder-stroke') || '').trim();
1948 }
1949 } catch (e) {
1950 // fall through to defaults
1951 }
1952
1953 // Fallback to your default palette if no custom color is set
1954 if (!frontColor) frontColor = isDark ? '#facc6b' : '#e2b158';
1955 if (!backColor) backColor = isDark ? '#f5d88a' : '#f0d084';
1956 if (!strokeColor) strokeColor = isDark ? '#854d0e' : '#996a1e';
1957
1958 // --- Drag ghost pill ---
1959 const ghost = document.createElement('div');
1960 ghost.className = 'folder-drag-ghost';
1961
1962 const rowStyles = getComputedStyle(row);
1963
1964 Object.assign(ghost.style, {
1965 position: 'fixed',
1966 top: '-9999px',
1967 left: '-9999px',
1968 pointerEvents: 'none',
1969 zIndex: '99999',
1970
1971 display: 'inline-flex',
1972 alignItems: 'center',
1973 gap: '6px',
1974 padding: '2px 10px',
1975 borderRadius: '999px',
1976 whiteSpace: 'nowrap',
1977
1978 fontFamily: rowStyles.fontFamily,
1979 fontSize: rowStyles.fontSize,
1980

Callers 1

makeChildLiFunction · 0.85

Calls 2

folderSVGFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected