-
2014-01-27
FreakC
This is just a small request. The initial rendering of the page has the TOC open, and the TOC will be closed on small devices. This causes browsers (at least IE) to jump to a wrong position when given an anchor. I use an embedded IE window (IE11, Win 8.1) in an app to display online help. The window's width is 800 pixels. An URL like
www.example.com/doku.php?id=page#anchor
causes the page to scroll far below its anchor, depending on the size of the TOC, even if the TOC is invisible (the CSS for small devices closes the TOC due to the width of 800 px).
The fix is easy. In page.js, line 13, replace
dw_page.makeToggle('#dw__toc h3','#dw__toc > div');
with
dw_page.makeToggle('#dw__toc h3','#dw__toc > div', -1);
-
2014-03-17
Klap-in
Do I interpret this suggestion correct, when i think it will close always the ToC (so also at wide screens)?
That is not a desired behavior.
Is there a way to make that this javascript behavior depends on the screen size? sniffing for existance of some classes? is that desired?
(I can still reproduce the issue in the last version of DokuWiki)
-
2014-03-18
FreakC
No, the TOC will be visible on non-PDA sized screens - the initial setting is changed later. So, the desired behavior is to open a closed TOC on bigger devices. Now, an open TOC is closed on smaller devices, leading to rendering problems on some browsers (the browser thinks that the anchor is more down the page than it actually is).
-
2014-03-18
Klap-in
Interesting.
I haven't test your solution so far, but "the initial setting is changed later" means that it is changes before displaying? or just when it is displaying so that the big screens have gotten jumps?
-
2014-03-18
andi
We usually try to keep DokuWiki usable even without JavaScript. Closing the TOC by default would hide information permanently when JS is unavailable.
-
2014-03-18
Klap-in
I test it. Now the big screens got a small jump.
@andi, and when using the "no-js" vs "js" class at <html> element?
-
2014-03-18
Klap-in
@andi, and when js is not working this dw_page.makeToggle('#dw__toc h3','#dw__toc > div', -1); is not called, is it?
-
2014-03-18
FreakC
We are talking about the method setState() here. My suggested fix is called during dw_page.init(); after that, it is called during tpl_dokuwiki_mobile(), which sets the state according to whether a desktop or a mobile setting has been discovered. Insofar, the TOC's final state is determined after the init phase.
Without JS, nothing is called, of course, and the TOC is displayed initially, I guess.
-
2014-03-18
andi
ah okay. sounds better then ;-)
-
2014-03-18
Klap-in
Your fix, moves the issue to the desktop mode instead of the mobile mode. (However, there the effect of a toggling ToC is much smaller.)
My suggestion: a screen mode dependent initialization of the toggle state is required.
difficulty:
tpl_dokuwiki_mobile() is part of the template javascript. So not (yet) available in the core javascript.