Files
anonymous_github/public/script/template-state.js
T
Thomas DurieuxandClaude Opus 5.5 2600bfa2f6 fix(ui): go-to-line popover, selection overlap, copy icon, date and checkout layout
- Go to line: themed popover under the file toolbar (line or line:column,
  range check) instead of Ace's unthemed prompt
- Code selection: no per-box outline, so multi-line selections no longer
  overlap at the joins; single-line matches keep an inset outline
- My work: copy-link is an icon button (URL in the tooltip); phone cards
  drop the URL row and truncate long names
- Date fields: drop WebKit's native button styling so they fit their column
- Submit bar: the checkout note gets its own line under the button

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:33:06 +00:00

68 lines
3.3 KiB
JavaScript

import { computed } from "vue";
// Local state formerly initialized by templates; list aliases are computed.
export function initializeTemplate(name, state) {
if (name === "partials/explorer.htm") {
state.sidebarCollapsed = window.matchMedia?.("(max-width: 767px)").matches || false;
state.sidebarHidden = false;
state.dirExpanded = false;
state.moreOpen = false;
state.tocOpen = false;
state.gotoOpen = false;
state.gotoValue = "";
state.gotoError = "";
state.mdFindOpen = false;
state.mdFindQuery = "";
state.mdFindTotal = 0;
state.mdFindIndex = 0;
state.mdFindCase = false;
state.accountOpen = false;
state.helpOpen = false;
state.sidebarWidth = Math.min(520, Math.max(220, Number(localStorage.getItem("sidebarWidth")) || 280));
// Shared with the app bar so the brand column lines up with the file tree.
document.documentElement.style.setProperty("--sidebar-w", state.sidebarWidth + "px");
state.startSidebarResize = (event) => {
event.preventDefault();
const startX = event.clientX;
const startWidth = state.sidebarWidth;
const move = (e) => {
state.sidebarWidth = Math.min(520, Math.max(220, startWidth + e.clientX - startX));
document.documentElement.style.setProperty("--sidebar-w", state.sidebarWidth + "px");
};
const up = () => {
window.removeEventListener("pointermove", move);
window.removeEventListener("pointerup", up);
document.body.classList.remove("is-resizing");
localStorage.setItem("sidebarWidth", String(state.sidebarWidth));
};
document.body.classList.add("is-resizing");
window.addEventListener("pointermove", move);
window.addEventListener("pointerup", up);
};
}
if (name === "partials/anonymize.htm") {
state.prTabState = { active: state.options.diff ? "diff" : "comments" };
state.watchGroup(["options.diff", "options.comments"], () => {
if (!state.options[state.prTabState.active]) state.prTabState.active = state.options.diff ? "diff" : state.options.comments ? "comments" : null;
});
}
if (name === "partials/gist.htm") state.tabState = { active: state.details?.files ? "files" : "comments" };
if (["partials/conferences.htm", "partials/conference.htm"].includes(name)) {
state.statusLabels = { ready: "Ready", expired: "Expired", removed: "Removed" };
}
const lists = {
"partials/dashboard.htm": ["filteredItems", () => state.items, "itemFilter"],
"partials/conferences.htm": ["filteredConferences", () => state.conferences, "conferenceFilter"],
"partials/conference.htm": ["filteredRepositories", () => state.conference?.repositories, "repoFiler"],
"partials/admin/repositories.htm": ["filteredRepositories", () => state.repositories, "repoFiler"],
"partials/admin/user.htm": ["filteredRepositories", () => state.repositories, "repoFiler"],
"partials/admin/users.htm": ["filteredUsers", () => state.users, "userFiler"],
"partials/admin/conferences.htm": ["filteredConferences", () => state.conferences],
};
const list = lists[name];
if (list) {
const value = computed(() => state.fmt.orderBy(state.fmt.filter(list[1](), state[list[2]]), state.orderBy));
Object.defineProperty(state, list[0], { configurable: true, get: () => value.value });
}
}