Page MenuHomePhabricator

Highlight current section in TOC on donor support pages
Closed, ResolvedPublic

Description

e.g. https://donate.wikimedia.org/wiki/Problems_donating

See https://wikimediafoundation.org/about/jobs/ for an example on the new site.

@schoenbaechler Would you be able to look into this? We need some javascript which adds an -active class on the correct <a> in the table of contents. I already added some CSS with the relevant styles.

Event Timeline

Hey @Pcoombe, just noting that I’ve seen this ping and am going to tackle it next week!

Tried to setup an environment where I could work on this code. Doesn’t quite work yet, I think I didn’t set it up properly. Tried to customize a script I’ve found on CodePen but I get this error when trying to look at the page on Donatewiki: ”Uncaught SyntaxError: Unexpected token &”. Could you have a look at it @Pcoombe and give me a hint? Thanks.

The templates I’ve created

Problems donating interactive nav
https://donate.wikimedia.org/w/index.php?title=Template:Support_Page_interactive_nav/js&action=edit

Problems donating interactive nav/js
https://donate.wikimedia.org/w/index.php?title=Template:Support_Page_interactive_nav/js&action=edit

@schoenbaechler

Well, my previous idea didn't work. The && still keeps on getting escaped when included in a wiki page. For various reasons we should try to get away from directly including scripts like this anyway. I've added your code to https://donate.wikimedia.org/wiki/MediaWiki:SupportPage.js, which is loaded on all the existing support pages, and given you admin rights so that you can edit it.

Made a few fixes to the code and I got the smooth scrolling part working. Found that some of the IDs had special characters in so you can't just pass them as jQuery selectors directly. I haven't got the highlighting current section part working yet, going to take a break from it for a while if you want to carry on looking at that.

Thanks!

Hey @Pcoombe , thanks and smooth scrolling looks great so far!

Re: highlight current section I have a slight premonition that this is beyond my coding skills! I’ll never know if I’ll never try sooo I’m diving into it right now :)

Pcoombe claimed this task.

Okay, think I've got this working now!