Jump to content

User talk:SGrabarczuk (WMF)/faq

About this board

Nux (talkcontribs)

Hi. For the sake of future compatibility and fixes I think it would be best to add a some mw.uitls function for the flying toc. Having a function would be much easier to fix instead of changing 10s or 100s of custom JS pages.

So you should add a function that converts new ToC to a static ToC. Maybe something like `mw.util.tocMakeStatic();`.

Note that current suggestion is not a complete code snippet:

$('.mw-table-of-contents-container')
.removeClass('mw-sticky-header-element' )
.removeClass('mw-table-of-contents-container')
.appendTo(document.getElementsByTagName('mw:tocplace')[0])

Couple of problems there:

  1. When you decide to add another class to sticky toc another class would need to be removed.
  2. Even currently there is bug there. A class `vector-sticky-header-enabled` should be removed from `html` tag.
  3. When you run above code the ToC is not fully working as a sttic ToC. It has a scrollbar.
  4. You might decide to change the name of the tag from mw:tocplace to a div in future. In that case the code would just stop working and also brake new ToC. You don't check if `getElementsByTagName` is empty and so you would just remove classes.

Cheers, Nux (talk) 20:43, 10 August 2022 (UTC)

Reply to "Static ToC function"
There are no older topics