Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace jQuery with vanilla JavaScript #160

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

Merged
merged 6 commits into from
Jul 14, 2023
Merged

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Jul 13, 2023

Possibly fixes #159.

Is there a good way to test this?

@JulienPalard
Copy link
Member

Is there a good way to test this?

Yes, run the command in the README like:

python3 ./build_docs.py --quick --build-root ./build_root --www-root ./www --log-directory ./logs --group $(id -g) --skip-cache-invalidation

you can limit it to one language and one version for a faster build by adding --language en --branch main.

@egeakman
Copy link
Contributor

Ah, I almost opened a pull request for this, you were quicker :D

@hugovk
Copy link
Member Author

hugovk commented Jul 13, 2023

I ran:

python3 ./build_docs.py --quick --build-root ./build_root --www-root ./www --log-directory ./logs --group $(id -g) --skip-cache-invalidation --language en --branch origin/main

I didn't get any console errors, but also didn't see the switchers:

image

I then did two languages and two versions:

python3 ./build_docs.py --quick --build-root ./build_root --www-root ./www --log-directory ./logs --group $(id -g) --skip-cache-invalidation --language en fr --branch 3.13 --branch 3.12

And served the pages via python -m http.server -d www, but again saw no switchers for any of the four.

@egeakman
Copy link
Contributor

egeakman commented Jul 13, 2023

In my version, I can't see the switchers until I resize the page enough to see the mobile view. It works as intended and no JS errors. Is this the case you're facing too @hugovk?

image

@hugovk
Copy link
Member Author

hugovk commented Jul 13, 2023

Ah right, thanks, and I had old results in the www directory so this time I deleted it first.

rm -rf www
python3 ./build_docs.py --quick --build-root ./build_root --www-root ./www --log-directory ./logs --group $(id -g) --skip-cache-invalidation --language en fr --branch 3.13
python3 -m http.server -d www

Here's main on the left, with console errors and no switchers; and this PR on the right with no errors and switchers:

image

@egeakman
Copy link
Contributor

egeakman commented Jul 13, 2023

<select> is missing in the switcher div, switchers.js is not populating it for some reason:

image

How it should be:

image

@hugovk hugovk marked this pull request as draft July 14, 2023 06:13
@hugovk hugovk marked this pull request as ready for review July 14, 2023 06:50
@hugovk
Copy link
Member Author

hugovk commented Jul 14, 2023

Okay, looks like it's working now at the top:

image

And in the mobile sidebar:

image

There was a problem that $('.version_switcher_placeholder') returned all placeholders, but document.querySelector('.version_switcher_placeholder'); returned only the first. So we need to use querySelectorAll and loop.

There was also a possible issue with adding too many quotes near the quote_attr calls.

@JulienPalard
Copy link
Member

I'm very happy to see this land, thanks for the work!

@JulienPalard JulienPalard merged commit 952c9ee into python:main Jul 14, 2023
@hugovk hugovk deleted the rm-jquery branch July 14, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

switchers.js not compatible with Sphinx 6 / requires jQuery
3 participants