MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / toggleSelectionMode

Function toggleSelectionMode

src/pages/fileBrowser/fileBrowser.js:693–771  ·  view source on GitHub ↗
(active)

Source from the content-addressed store, hash-verified

691 }
692
693 function toggleSelectionMode(active) {
694 const $list = $content.get("#list");
695 if (active) {
696 $list.classList.add("selection-mode");
697 const $header = tag("div", {
698 className: "selection-header",
699 });
700
701 const selectAllCheckbox = Checkbox("", false);
702 const $count = tag("span", {
703 className: "text selection-count",
704 textContent: "0 items selected",
705 });
706
707 // Handle select all functionality
708 selectAllCheckbox.onclick = () => {
709 const checked = selectAllCheckbox.checked;
710 const items = $list.querySelectorAll(".tile:not(.selection-header)");
711 items.forEach((item) => {
712 const checkbox = item.querySelector(".input-checkbox");
713 if (checkbox) {
714 checkbox.checked = checked;
715 const url = item.querySelector("data-url").textContent;
716 if (checked) {
717 selectedItems.add(url);
718 } else {
719 selectedItems.delete(url);
720 }
721 }
722 });
723 updateSelectionCount($count);
724 };
725
726 $header.append(selectAllCheckbox, $count);
727 $list.insertBefore($header, $list.firstChild);
728
729 // Add checkboxes to list items
730 $list
731 .querySelectorAll(".tile:not(.selection-header)")
732 .forEach((item) => {
733 const checkbox = Checkbox("", false);
734 checkbox.onclick = () => {
735 const url = item.querySelector("data-url").textContent;
736 if (checkbox.checked) {
737 selectedItems.add(url);
738 } else {
739 selectedItems.delete(url);
740 }
741 updateSelectionCount($count);
742 };
743 item.prepend(checkbox);
744 });
745
746 $addMenuToggler.style.display = "none";
747 $menuToggler.style.display = "none";
748 $selectionMenuToggler.style.display = "";
749 updatePasteToggler();
750

Callers 1

FileBrowserIncludeFunction · 0.85

Calls 8

updateSelectionCountFunction · 0.85
updatePasteTogglerFunction · 0.85
addMethod · 0.80
appendMethod · 0.80
deleteMethod · 0.65
getMethod · 0.45
removeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected