(name, cls, comparator, is_checkbox = false)
| 421 | } |
| 422 | |
| 423 | function createColumnHeader(name, cls, comparator, is_checkbox = false) { |
| 424 | var th = document.createElement("TH"); |
| 425 | th.innerHTML = name; |
| 426 | th.classList.add(cls); |
| 427 | if (is_checkbox) |
| 428 | th.setAttribute("col_name", "bom-checkbox"); |
| 429 | else |
| 430 | th.setAttribute("col_name", name); |
| 431 | var span = document.createElement("SPAN"); |
| 432 | span.classList.add("sortmark"); |
| 433 | span.classList.add("none"); |
| 434 | th.appendChild(span); |
| 435 | var spacer = document.createElement("div"); |
| 436 | spacer.className = "column-spacer"; |
| 437 | th.appendChild(spacer); |
| 438 | spacer.onclick = function () { |
| 439 | if (currentSortColumn && th !== currentSortColumn) { |
| 440 | // Currently sorted by another column |
| 441 | currentSortColumn.childNodes[1].classList.remove(currentSortOrder); |
| 442 | currentSortColumn.childNodes[1].classList.add("none"); |
| 443 | currentSortColumn = null; |
| 444 | currentSortOrder = null; |
| 445 | } |
| 446 | if (currentSortColumn && th === currentSortColumn) { |
| 447 | // Already sorted by this column |
| 448 | if (currentSortOrder == "asc") { |
| 449 | // Sort by this column, descending order |
| 450 | bomSortFunction = function (a, b) { |
| 451 | return -comparator(a, b); |
| 452 | } |
| 453 | currentSortColumn.childNodes[1].classList.remove("asc"); |
| 454 | currentSortColumn.childNodes[1].classList.add("desc"); |
| 455 | currentSortOrder = "desc"; |
| 456 | } else { |
| 457 | // Unsort |
| 458 | bomSortFunction = null; |
| 459 | currentSortColumn.childNodes[1].classList.remove("desc"); |
| 460 | currentSortColumn.childNodes[1].classList.add("none"); |
| 461 | currentSortColumn = null; |
| 462 | currentSortOrder = null; |
| 463 | } |
| 464 | } else { |
| 465 | // Sort by this column, ascending order |
| 466 | bomSortFunction = comparator; |
| 467 | currentSortColumn = th; |
| 468 | currentSortColumn.childNodes[1].classList.remove("none"); |
| 469 | currentSortColumn.childNodes[1].classList.add("asc"); |
| 470 | currentSortOrder = "asc"; |
| 471 | } |
| 472 | populateBomBody(); |
| 473 | } |
| 474 | if (is_checkbox) { |
| 475 | spacer.onclick = fancyDblClickHandler( |
| 476 | spacer, spacer.onclick, checkboxSetUnsetAllHandler(name)); |
| 477 | } |
| 478 | return th; |
| 479 | } |
| 480 |
no test coverage detected