Skip to content

Commit

Permalink
Merge pull request #2751 from gassmoeller/extend_parameter_view
Browse files Browse the repository at this point in the history
Extend parameter view
  • Loading branch information
tjhei committed Jan 6, 2019
2 parents 314f5e7 + 729fd3a commit 8a59cbb
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 3 deletions.
93 changes: 93 additions & 0 deletions doc/parameter_view/parameters.js
Expand Up @@ -20,6 +20,7 @@


demangleStrings();
reorderList();

function demangleStrings() {
mangledStrings = document.getElementsByClassName("mangled");
Expand All @@ -31,6 +32,43 @@ function demangleStrings() {
return;
}

function expand(collection) {
var i;
for (i = 0; i < collection.length; i++) {
collection[i].classList.add("active");
var content = collection[i].nextElementSibling;
content.style.display = "block";
}
}

function collapse(collection) {
var i;
for (i = 0; i < collection.length; i++) {
collection[i].classList.remove("active");
var content = collection[i].nextElementSibling;
content.style.display = "none";
}
}

function expandAll() {
var coll = document.getElementsByClassName("collapsible");
expand(coll)
}

function collapseAll() {
var coll = document.getElementsByClassName("collapsible");
collapse(coll)
}

function expandAllSubsections() {
var coll = document.getElementsByClassName("subsection");
expand(coll)
}

function collapseAllSubsections() {
var coll = document.getElementsByClassName("subsection");
collapse(coll)
}

var coll = document.getElementsByClassName("collapsible");
var i;
Expand All @@ -46,3 +84,58 @@ for (i = 0; i < coll.length; i++) {
}
});
}

function sortTopNodes(ClassType) {
var list, i, switching, shouldSwitch;
list = document.getElementById("ParameterList");
switching = true;

/* Make a loop that will continue until
no switching has been done: */
while (switching) {
// Start by saying: no switching is done:
switching = false;
children = list.children;
// parameters = children.getElementbyClassName("parameter");

// Loop through all list items:
for (i = 0; i < (children.length - 1); i++) {
if (children[i].children[0].classList.contains(ClassType) && children[i+1].children[0].classList.contains(ClassType)) {
// Start by saying there should be no switching:
shouldSwitch = false;
/* Check if the next item should
switch place with the current item: */
if (children[i].children[0].innerHTML.toLowerCase() > children[i + 1].children[0].innerHTML.toLowerCase()) {
/* If next item is alphabetically lower than current item,
mark as a switch and break the loop: */
shouldSwitch = true;
break;
}
}
}

if (shouldSwitch) {
/* If a switch has been marked, make the switch
and mark the switch as done: */
children[i].parentNode.insertBefore(children[i + 1], children[i]);
switching = true;
}
}
}

function reorderList() {
var list, i;
list = document.getElementById("ParameterList");

/* Move parameters to the front */
children = list.children;

for (i = 0; i < children.length; i++) {
if (children[i].children[0].classList.contains("parameter")) {
children[i].parentNode.insertBefore(children[i], children[0]);
}
}

sortTopNodes("parameter");
sortTopNodes("subsection");
}
15 changes: 12 additions & 3 deletions doc/parameter_view/parameters.xsl
Expand Up @@ -10,8 +10,17 @@
<link rel="stylesheet" type="text/css" href="parameters.css"></link>
</head>
<body>
<h2>ASPECT input parameters</h2>
<ul>
<h2>
ASPECT input parameters
</h2>

<div>
<button onclick="expandAll()">Expand all</button>
<button onclick="collapseAll()">Collapse all</button>
<button onclick="expandAllSubsections()">Expand subsections</button>
<button onclick="collapseAllSubsections()">Collapse subsections</button>
</div>
<ul id="ParameterList">
<xsl:apply-templates
select="ParameterHandler/*" />
</ul>
Expand All @@ -32,7 +41,7 @@
</div>
</xsl:when>
<xsl:otherwise>
<div class="collapsible mangled">
<div class="collapsible subsection mangled">
subsection <b> <xsl:value-of select="name()" /> </b>
</div>
</xsl:otherwise>
Expand Down

0 comments on commit 8a59cbb

Please sign in to comment.