-
-
Notifications
You must be signed in to change notification settings - Fork 87
doc/template.html: make modules list closable (fixes #50) #56
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
Conversation
doc/template.html
Outdated
} | ||
} | ||
element.insertBefore(dropdown_link_copy, | ||
element.querySelector('a').nextSibling); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this hard-wrapped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
doc/template.html
Outdated
dropdown_link.innerHTML = ' <b>+</b>'; // the space is for padding | ||
dropdown_link.style.cursor = 'pointer'; | ||
// hack in an ID name for the module list | ||
var collapsibleList = document.querySelectorAll('nav ul li > ul > li') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to assign this to a variable
doc/template.html
Outdated
dropdown_link.style.cursor = 'pointer'; | ||
// hack in an ID name for the module list | ||
var collapsibleList = document.querySelectorAll('nav ul li > ul > li') | ||
collapsibleList.forEach(function(element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I recall the return value of document.querySelectorAll
not actually being an array in some browsers, and hence methods don't work unless you get them from the Array prototype?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NodeList.forEach()
!= Array.forEach()
. Mozilla documentation, along with other things I've found, say that NodeList guarantees a forEach.
doc/template.html
Outdated
// write out a basic 'dropdown_link' reference element | ||
var dropdown_link = document.createElement('a'); | ||
dropdown_link.setAttribute('class', 'dropdown_link'); | ||
dropdown_link.onclick = function(e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why give an empty onclick
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
doc/template.html
Outdated
(function() { | ||
// write out a basic 'dropdown_link' reference element | ||
var dropdown_link = document.createElement('a'); | ||
dropdown_link.setAttribute('class', 'dropdown_link'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall .setAttribute("class"
having issues: assign to .className
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
doc/template.html
Outdated
} | ||
dropdown_link.innerHTML = ' <b>+</b>'; // the space is for padding | ||
dropdown_link.style.cursor = 'pointer'; | ||
// hack in an ID name for the module list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment isn't relevant any more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
doc/template.html
Outdated
var collapsibleList = document.querySelectorAll('nav ul li > ul > li') | ||
collapsibleList.forEach(function(element) { | ||
// add a clone of the node to prevent lingering element scoping | ||
// otherwise each time a dropdown is clicked it only does the last one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment.
collapsibleList.forEach(function(element) { | ||
// add a clone of the node to prevent lingering element scoping | ||
// otherwise each time a dropdown is clicked it only does the last one | ||
var dropdown_link_copy = dropdown_link.cloneNode(true); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
return; | ||
list.style.display = 'none'; | ||
element.setAttribute('state', 'up'); | ||
dropdown_link_copy.onclick = function() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
doc/template.html
Outdated
dropdown_link.innerHTML = ' <b>+</b>'; // the space is for padding | ||
dropdown_link.style.cursor = 'pointer'; | ||
document.querySelectorAll('nav ul li > ul > li').forEach( | ||
function(element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be indented one level further.
doc/template.html
Outdated
// write out a basic 'dropdown_link' reference element | ||
var dropdown_link = document.createElement('a'); | ||
dropdown_link.className = 'dropdown_link'; | ||
dropdown_link.innerHTML = ' <b>+</b>'; // the space is for padding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the space is padding then you should use
.
But, if it's just padding: why not use the css/style for it? i.e. dropdown_link.style["padding-left"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trying to reduce the amount of css required :P
<script type="text/javascript"> | ||
(function() { | ||
// write out a basic 'dropdown_link' reference element | ||
var dropdown_link = document.createElement('a'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
doc/template.html
Outdated
function(element) { | ||
var dropdown_link_copy = dropdown_link.cloneNode(true); | ||
var list = element.querySelector('ul'); | ||
if (!list || list.querySelectorAll('li').length == 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of list.querySelectorAll(...).length==1
you could use list.querySelector(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I did this was to not hide items that had only one subelement. Either I can remove this entirely or keep it as this; there's no way other than this to detect whether there's n
amount of elements.
2 similar comments
@daurnimator boop |
A few requests:
|
I'm pushing this but it'll probably look a bit weird to some.
Fixed.
I can probably change it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better :)
However, now you have the list bullet followed by the +/-: could you remove the list bullet? Or alternatively, perhaps the +/- could be the bullet?
Also, the + and - are different widths, so you get some slight movement when expanding/collapsing: could you make it a fixed width (possibly automatically fixed if you make it the bullet)
doc/template.html
Outdated
$endif$ | ||
<title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title> | ||
<style type="text/css">code{white-space: pre;}</style> | ||
<style type="text/css">code{white-space: pre;} b{color: #212121;}</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of changing here, could you set dropdown_link.style.color
?
d9c7d6d
to
9a49853
Compare
var dropdown_link = document.createElement('a'); | ||
dropdown_link.className = 'dropdown_link'; | ||
dropdown_link.innerHTML = '<b>+</b> '; | ||
dropdown_link.style.color = "#212121"; |
There was a problem hiding this comment.
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)
No description provided.