Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend parameter view #2751

Merged
merged 2 commits into from Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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