Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions doc/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,37 @@ <h3 class="date">$date$</h3>
$for(include-after)$
$include-after$
$endfor$
<script type="text/javascript">
(function() {
// write out a basic 'dropdown_link' reference element
var dropdown_link = document.createElement('a');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why an a link if it doesn't have a href? Should it just be a button instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

button elements add additional CSS. Using a a tag accomplishes what we want with minimal CSS additions.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. I'm curious what the button css required would need to be; but don't worry about it :)

dropdown_link.className = 'dropdown_link';
dropdown_link.innerHTML = '<b>+</b>&nbsp;';
dropdown_link.style.color = "#212121";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double quotes here (single quotes everywhere else)

dropdown_link.style.cursor = 'pointer';
document.querySelectorAll('nav ul li > ul > li').forEach(
function(element) {
var dropdown_link_copy = dropdown_link.cloneNode(true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this down below the early return?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved

var list = element.querySelector('ul');
if (!list)
return;
// add a clone of the node so the correct element is toggled
list.style.display = 'none';
element.setAttribute('state', 'up');
dropdown_link_copy.onclick = function() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would make more sense to have an open and a close function that you swap between?..... maybe not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue as insertAfter - use in only 1.5 places.

if (element.getAttribute('state') == 'down') {
element.setAttribute('state', 'up');
list.style.display = 'none';
dropdown_link_copy.querySelector('b').innerHTML = '+';
} else {
element.setAttribute('state', 'down');
list.style.display = 'block';
dropdown_link_copy.querySelector('b').innerHTML = '-';
}
}
element.insertBefore(dropdown_link_copy, element.querySelector('a'));
});
})();
</script>
</body>
</html>