MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / initializeFloatingToc

Function initializeFloatingToc

codeclash/viewer/static/js/app.js:295–342  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

293
294// Floating Table of Contents functionality
295function initializeFloatingToc() {
296 const tocMenu = document.getElementById("toc-menu");
297 const tocClose = document.getElementById("toc-close");
298 const tocToggle = document.getElementById("toc-toggle");
299
300 if (!tocMenu || !tocClose || !tocToggle) {
301 return;
302 }
303
304 // Check if we're on mobile
305 const isMobile = window.innerWidth <= 768;
306
307 // Hide menu by default on mobile
308 if (isMobile) {
309 tocMenu.classList.add("hidden");
310 }
311
312 // Set initial visibility state
313 updateTocVisibility();
314
315 // Toggle button click
316 tocToggle.addEventListener("click", function (e) {
317 e.stopPropagation();
318 toggleTocMenu();
319 });
320
321 // Close TOC menu
322 tocClose.addEventListener("click", function (e) {
323 e.stopPropagation();
324 closeTocMenu();
325 });
326
327 // Prevent menu from closing when clicking inside
328 tocMenu.addEventListener("click", function (e) {
329 e.stopPropagation();
330 });
331
332 // Handle window resize to update mobile state
333 window.addEventListener("resize", function () {
334 const isMobileNow = window.innerWidth <= 768;
335 if (isMobileNow && !tocMenu.classList.contains("hidden")) {
336 // On mobile, ensure proper visibility class
337 updateTocVisibility();
338 }
339 });
340
341 // TOC keyboard shortcuts are now handled in the main keyboard handler
342}
343
344function toggleTocMenu() {
345 const tocMenu = document.getElementById("toc-menu");

Callers 1

app.jsFile · 0.85

Calls 3

updateTocVisibilityFunction · 0.85
toggleTocMenuFunction · 0.85
closeTocMenuFunction · 0.85

Tested by

no test coverage detected