-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged changes from J. Ritchie Carroll to support a resizable TOC column. Added a new ResizableTocColumn transformation argument to allow it to be enabled.
- Loading branch information
1 parent
e446e6d
commit 48faed9
Showing
4 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// System : Sandcastle Tools Standard Presentation Styles | ||
// File : Default2022Transformation.cs | ||
// Author : Eric Woodruff ([email protected]) | ||
// Updated : 02/18/2023 | ||
// Updated : 07/04/2023 | ||
// Note : Copyright 2022-2023, Eric Woodruff, All rights reserved | ||
// | ||
// This file contains the class used to generate a MAML or API HTML topic from the raw topic XML data for the | ||
|
@@ -18,7 +18,7 @@ | |
// 03/16/2022 EFW Created the code | ||
//=============================================================================================================== | ||
|
||
// Ignore Spelling: fa | ||
// Ignore Spelling: fa resizer | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
@@ -76,6 +76,12 @@ public Default2022Transformation(Default2022PresentationStyle presentationStyle) | |
/// </summary> | ||
private string RootBreadcrumbTitleText => this.TransformationArguments[nameof(RootBreadcrumbTitleText)].Value; | ||
|
||
/// <summary> | ||
/// Enable the resizable table of contents column | ||
/// </summary> | ||
private bool ResizableTocColumn => Boolean.TryParse(this.TransformationArguments[nameof(ResizableTocColumn)].Value, | ||
out bool resizableTocColumn) && resizableTocColumn; | ||
|
||
/// <summary> | ||
/// Render collapsible sections | ||
/// </summary> | ||
|
@@ -198,8 +204,10 @@ protected override void CreateTransformationArguments() | |
"Sandcastle MAML Guide or XML Comments Guide."), | ||
new TransformationArgument(nameof(RootBreadcrumbTitleText), true, true, "Docs", "Specify the " + | ||
"text to use for the root breadcrumb's title. The default if blank is \"Docs\"."), | ||
new TransformationArgument(nameof(ResizableTocColumn), true, true, "False", "Indicate whether " + | ||
"or not to enable the resizable table of contents column. True to enable it, false if not."), | ||
new TransformationArgument(nameof(CollapsibleSections), true, true, "True", "Indicate whether " + | ||
"whether or not collapsible sections are rendered. True to include them, false if not."), | ||
"or not collapsible sections are rendered. True to include them, false if not."), | ||
new TransformationArgument(nameof(LogoFile), true, true, null, | ||
"An optional logo file to insert into the topic headers. Specify the filename only, omit " + | ||
"the path.\r\n\r\n" + | ||
|
@@ -613,14 +621,27 @@ protected override XDocument RenderTopic() | |
$"href=\"{this.StyleSheetPath + Path.GetFileName(localeSpecificStyleSheet)}\" />"; | ||
} | ||
|
||
string resizableTocStyle = String.Empty, resizerStyle = "is-hidden", resizableContentStyle = String.Empty; | ||
|
||
if(this.ResizableTocColumn) | ||
{ | ||
resizableTocStyle = " toc-resizable"; | ||
resizerStyle = "toc-resizer"; | ||
resizableContentStyle = " toc-resizable-content"; | ||
} | ||
|
||
pageTemplate = LoadTemplateFile(this.TopicTemplatePath, new[] { | ||
("{@Locale}", this.Locale), | ||
("{@LocaleLowercase}", this.Locale.ToLowerInvariant()), | ||
("{@IconPath}", this.IconPath), | ||
("{@StyleSheetPath}", this.StyleSheetPath), | ||
("{@LocaleSpecificStyleSheet}", localeSpecificStyleSheet), | ||
("{@ScriptPath}", this.ScriptPath), | ||
("{@DefaultLanguage}", this.DefaultLanguage) }); | ||
("{@DefaultLanguage}", this.DefaultLanguage), | ||
("{@ResizableTocStyle}", resizableTocStyle), | ||
("{@ResizerStyle}", resizerStyle), | ||
("{@ResizableContentStyle}", resizableContentStyle), | ||
}); | ||
} | ||
|
||
// Set the default language and connect the language-specific text, and language filter on startup | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ | |
// System : Sandcastle Help File Builder | ||
// File : presentationStyle.js | ||
// Author : Eric Woodruff ([email protected]) | ||
// Updated : 08/13/2022 | ||
// Note : Copyright 2014-2022, Eric Woodruff, All rights reserved | ||
// Portions Copyright 2010-2022 Microsoft, All rights reserved | ||
// Updated : 07/04/2023 | ||
// Note : Copyright 2014-2023, Eric Woodruff, All rights reserved | ||
// Portions Copyright 2010-2023 Microsoft, All rights reserved | ||
// | ||
// This file contains the methods necessary to implement the language filtering, collapsible section, and | ||
// copy to clipboard options. | ||
|
@@ -19,7 +19,7 @@ | |
// 05/04/2014 EFW Created the code based on the MS Help Viewer script | ||
//=============================================================================================================== | ||
|
||
// Ignore Spelling: fti json | ||
// Ignore Spelling: fti json Resizer mousedown mouseup mousemove | ||
|
||
//=============================================================================================================== | ||
// This section contains the methods used to implement the language filter | ||
|
@@ -684,3 +684,44 @@ function SearchForKeywords(keywords, fileInfo, wordDictionary, sortByTitle) | |
|
||
return content; | ||
} | ||
|
||
//=============================================================================================================== | ||
// This section contains the methods used to handle resizing the TOC section. | ||
// Changes made by J. Ritchie Carroll. | ||
|
||
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); | ||
} |