MCPcopy Create free account
hub / github.com/breck7/scroll / validateStructureMove

Function validateStructureMove

external/.datatables.js:17502–17524  ·  view source on GitHub ↗

* For a given structure check that the move is valid. * @param structure * @param from * @param to * @returns

(structure, from, to)

Source from the content-addressed store, hash-verified

17500 * @returns
17501 */
17502 function validateStructureMove(structure, from, to) {
17503 var header = structureFill(structure)
17504 var i
17505 // Shuffle the header cells around
17506 for (i = 0; i < header.length; i++) {
17507 arrayMove(header[i], from[0], from.length, to)
17508 }
17509 // Sanity check that the headers are next to each other
17510 for (i = 0; i < header.length; i++) {
17511 var seen = []
17512 for (var j = 0; j < header[i].length; j++) {
17513 var cell = header[i][j]
17514 if (!seen.includes(cell)) {
17515 // Hasn't been seen before
17516 seen.push(cell)
17517 } else if (seen[seen.length - 1] !== cell) {
17518 // Has been seen before and is not the previous cell - validation failed
17519 return false
17520 }
17521 }
17522 }
17523 return true
17524 }
17525
17526 /**
17527 * This is one possible UI for column reordering in DataTables. In this case

Callers 1

validateMoveFunction · 0.85

Calls 2

structureFillFunction · 0.85
arrayMoveFunction · 0.85

Tested by

no test coverage detected