From fd33e5459785edb2bdde871b08f79dffd691ff21 Mon Sep 17 00:00:00 2001 From: "J. Ritchie Carroll" Date: Sat, 17 Jun 2023 18:53:35 -0500 Subject: [PATCH] Updated TOC in Default2022 presentation style to be resizable --- .../Default2022/Templates/TopicTemplate.html | 8 +++-- .../Default2022/scripts/presentationStyle.js | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/SHFB/Source/PresentationStyles/Default2022/Templates/TopicTemplate.html b/SHFB/Source/PresentationStyles/Default2022/Templates/TopicTemplate.html index b1919bf2..4f5e78fe 100644 --- a/SHFB/Source/PresentationStyles/Default2022/Templates/TopicTemplate.html +++ b/SHFB/Source/PresentationStyles/Default2022/Templates/TopicTemplate.html @@ -118,12 +118,12 @@ -
+
-
+
-
+
+ +
diff --git a/SHFB/Source/PresentationStyles/Default2022/scripts/presentationStyle.js b/SHFB/Source/PresentationStyles/Default2022/scripts/presentationStyle.js index af9c1473..27a35d77 100644 --- a/SHFB/Source/PresentationStyles/Default2022/scripts/presentationStyle.js +++ b/SHFB/Source/PresentationStyles/Default2022/scripts/presentationStyle.js @@ -21,6 +21,41 @@ // Ignore Spelling: fti json +//=============================================================================================================== +// This section contains the methods used to handle resizing the TOC section + +var resizer, tocDiv; + +window.onload = function() { + resizer = document.getElementById("Resizer"); + tocDiv = document.getElementById("TOCColumn"); + + resizer.addEventListener("mousedown", function(e) { + e.preventDefault(); + document.addEventListener("mousemove", ResizerMouseMove); + document.addEventListener("mouseup", ResizerMouseUp); + }); +} + +function ResizerMouseMove(e) { + const container = document.getElementById("ContentContainer"); + const containerRect = container.getBoundingClientRect(); + const newWidth = e.clientX - containerRect.left - 80; + + // Ensure that divs are not smaller than some arbitrary minimal width + const minWidth = 50; // pixels + const contentDivWidth = containerRect.width - newWidth; + + if (newWidth > minWidth && contentDivWidth > minWidth) { + tocDiv.style.width = newWidth + 'px'; + } +} + +function ResizerMouseUp() { + document.removeEventListener("mousemove", ResizerMouseMove); + document.removeEventListener("mouseup", ResizerMouseUp); +} + //=============================================================================================================== // This section contains the methods used to implement the language filter