(displayRecords, columns, view, itemHeight, paddingVertical, verticalGap)
| 19183 | const dx = ev.clientX - startX; |
| 19184 | let nw = startW + dx; |
| 19185 | nw = Math.max(def.min, Math.min(def.max, nw)); |
| 19186 | listViewColumnState.widths[colId] = Math.round(nw); |
| 19187 | applyListViewColumnLayoutToGrid(); |
| 19188 | } |
| 19189 | function onUp() { |
| 19190 | document.removeEventListener('mousemove', onMove); |
| 19191 | document.removeEventListener('mouseup', onUp); |
| 19192 | persistListViewColumnState(); |
| 19193 | } |
| 19194 | document.addEventListener('mousemove', onMove); |
| 19195 | document.addEventListener('mouseup', onUp); |
| 19196 | }); |
| 19197 | wrapEl.appendChild(handle); |
| 19198 | } |
| 19199 | |
| 19200 | function clearListViewColumnDropIndicators(headerInfo) { |
| 19201 | if (!headerInfo) return; |
| 19202 | headerInfo.querySelectorAll('.list-view-col-drop-before, .list-view-col-drop-after').forEach(el => { |
| 19203 | el.classList.remove('list-view-col-drop-before', 'list-view-col-drop-after'); |
| 19204 | }); |
| 19205 | } |
| 19206 | |
| 19207 | function getListViewColumnDropTarget(headerInfo, clientX, fromId) { |
| 19208 | const wraps = Array.from(headerInfo.children).filter(el => { |
| 19209 | return el.hasAttribute('data-list-col') |
| 19210 | && el.style.display !== 'none' |
| 19211 | && el.getAttribute('data-list-col') !== fromId; |
| 19212 | }); |
| 19213 | if (wraps.length === 0) return null; |
| 19214 | for (const el of wraps) { |
| 19215 | const rect = el.getBoundingClientRect(); |
| 19216 | if (clientX < rect.left + rect.width / 2) { |
| 19217 | return { el, id: el.getAttribute('data-list-col'), place: 'before' }; |
| 19218 | } |
| 19219 | } |
| 19220 | const last = wraps[wraps.length - 1]; |
| 19221 | return { el: last, id: last.getAttribute('data-list-col'), place: 'after' }; |
| 19222 | } |
| 19223 | |
| 19224 | function reorderListViewColumn(fromId, targetId, place) { |
| 19225 | const state = ensureListViewColumnState(); |
| 19226 | const current = normalizeListViewColumnOrder(state.order); |
| 19227 | if (fromId === targetId) return false; |
| 19228 | const order = current.filter(id => id !== fromId); |
| 19229 | let idx = order.indexOf(targetId); |
| 19230 | if (idx < 0) return false; |
| 19231 | if (place === 'after') idx += 1; |
| 19232 | order.splice(idx, 0, fromId); |
| 19233 | const unchanged = order.length === current.length && order.every((id, i) => id === current[i]); |
| 19234 | if (unchanged) return false; |
| 19235 | state.order = order; |
| 19236 | return true; |
| 19237 | } |
| 19238 | |
| 19239 | function suppressClickAfterColumnReorder(wrapEl) { |
| 19240 | const suppress = (e) => { |
| 19241 | e.preventDefault(); |
| 19242 | e.stopImmediatePropagation(); |
no test coverage detected