Closed (fixed)
Project:
Table of Contents
Version:
6.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
21 Feb 2009 at 16:32 UTC
Updated:
2 Aug 2009 at 08:30 UTC
Jump to comment: Most recent file
Users that do not have Javascript enabled will still see the 'hide' link in the table of contents, but the link will do nothing. It should either not be there for non-JS users, or it should link back to the page with the table of contents collapsed/expanded. The first option seems more desirable.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | tableofcontents-379322-1.patch | 1.09 KB | ozzin |
Comments
Comment #1
ozzin commentedThis patch removes the creation of the 'hide' link from the module and moves it to the tableofcontents.js file. That way, users that do not have Javascript enabled will never see the link. If this is to be combined with one of the previous ideas of having show/hide being optional, one would need to set a javascript variable and then check this before creating the link.
Comment #2
AlexisWilke commentedDone in 3.x-dev. Although what I do is show the link if jQuery is available instead.
Thank you.
Alexis Wilke
Comment #3
ozzin commentedAm I right in thinking that the link is still being created in HTML, but is now hidden in CSS and then revealed in JavaScript? If so, this will still not work for users that are not using a CSS-enabled browser, such as Lynx or other text browsers. It may also create problems for accessibility-oriented browsers, though I don't know much about these. This is why the original patch does not create the link through HTML at all: since it's a link that is *only* used if JS is enabled (assuming that this is still the case), it may as well be entirely created through JS, thereby avoiding any issues with any types of browsers.
Using the idea in the original patch, you just have to supply a variable from PHP to JS to say whether 'hideshow' is set to true or not, and then create the link as before if it is set to true.
Best wishes,
ozzin
Comment #4
AlexisWilke commentedozzin,
Indeed.
Could you tell me how I could best make this work... I have a flag to make the TOC appear hidden (closed) by default. Do you think that should also be done in Javascript?
I guess it should go like this:
* HTML includes the title + list.
* Add a small <script>...</script> that sets a variable to know whether the table should be closed and whether the hide/show link should be shown.
* Javascript is run and (1) hides the table if marked that way, (2) add the hide/show link.
Thank you.
Alexis
Comment #5
AlexisWilke commentedOkay. That should now be fixed. The hide/show labels can be defined in Javascript with Drupal.t() for translation.
Let me know if you still see a problem and reactivate the issue if so.
Thank you!
Alexis Wilke