Collapsible functionality implemented

This commit is contained in:
Luis Fernando Molina committed 2020-12-12 16:30:19 +01:00
1 parent 1fc049eb25
commit 583144b2f4
2 files changed
+70 -7

No files matched your search

+37
View File
@@ -324,4 +324,41 @@ a:active.docs-footer-link {
color: #d9534f;
background-color: #eee;
padding: 1 5 1 5;
}
/* Style the button that is used to open and close the docs-collapsible-element content */
.docs-collapsible-element {
background-color: #fdfdfd;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 125%;
}
/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
.active, .docs-collapsible-element:hover {
background-color: #eee;
}
/* Style the docs-collapsible-element content. Note: hidden by default */
.docs-collapsible-content {
padding: 0 18px;
display: none;
overflow: hidden;
}
.docs-collapsible-element:after {
content: '\02795'; /* Unicode character for "plus" sign (+) */
font-size: 8px;
color: white;
float: right;
margin-left: 5px;
}
.docs-collapsible-active:after {
content: "\2796"; /* Unicode character for "minus" sign (-) */
}
@@ -443,6 +443,30 @@ function newSuperalgosDocSpace() {
scrollingDiv.scrollTop = topPos
}
function enableCollapsibleContent() {
let collapsibleElementsArray = document.getElementsByClassName("docs-collapsible-element")
for (let i = 0; i < collapsibleElementsArray.length; i++) {
collapsibleElementsArray[i].addEventListener("click", function () {
this.classList.toggle("docs-collapsible-active")
let content = this.nextElementSibling
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
})
}
}
function disableCollapsibleContent() {
let collapsibleElementsArray = document.getElementsByClassName("docs-collapsible-element")
for (let i = 0; i < collapsibleElementsArray.length; i++) {
collapsibleElementsArray[i].removeEventListener("click", function () { })
}
}
function openSpaceAreaAndNavigateTo(category, type, project) {
navigateTo(category, type, project)
thisObject.sidePanelTab.open()
@@ -450,6 +474,8 @@ function newSuperalgosDocSpace() {
function navigateTo(category, type, project) {
disableCollapsibleContent()
docSchemaParagraphMap = new Map()
objectBeingRendered = {
category: category,
@@ -458,6 +484,7 @@ function newSuperalgosDocSpace() {
}
renderPage()
enableCollapsibleContent()
scrollToElement('docs-context-menu-clickeable-div')
}
@@ -542,16 +569,13 @@ function newSuperalgosDocSpace() {
paragraphIndex++
for (let i = 0; i < nodeAppDefinition.menuItems.length; i++) {
let menuItem = nodeAppDefinition.menuItems[i]
paragraph = {
style: "Subtitle",
text: menuItem.label
}
renderParagraph(paragraph, key)
paragraphIndex++
HTML = HTML + '<button type="button" class="docs-collapsible-element">' + menuItem.label + '</button>'
HTML = HTML + '<div class="docs-collapsible-content">'
paragraph = {
style: "Text",
text: menuItem.label + ' has the following properties:'
text: 'The ' + menuItem.label + ' menu item has the following properties:'
}
renderParagraph(paragraph, key)
paragraphIndex++
@@ -564,6 +588,8 @@ function newSuperalgosDocSpace() {
renderParagraph(paragraph, key)
paragraphIndex++
}
HTML = HTML + '</div>'
}
}
}