Skip to content
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

back to top link #80

Closed
2 tasks done
Zavy86 opened this issue Dec 20, 2023 · 12 comments
Closed
2 tasks done

back to top link #80

Zavy86 opened this issue Dec 20, 2023 · 12 comments
Labels
enhancement New feature or request
Milestone

Comments

@Zavy86
Copy link
Owner

Zavy86 commented Dec 20, 2023

There are only 2 (fairly minor) features that I feel are missing:

  • A right side bar with content of headings on the page that is being viewed (created from H2 and H3 headings on the page) to make navigation within the page easier
  • A back to top button to prevent sometimes long scrolling up

Originally posted by @stormpaul in https://github.com/Zavy86/WikiDocs/issues/75#issuecomment-1864726381

@Zavy86 Zavy86 assigned Zavy86 and unassigned Zavy86 Dec 20, 2023
@Zavy86 Zavy86 added the enhancement New feature or request label Dec 20, 2023
@Zavy86 Zavy86 assigned Zavy86 and unassigned Zavy86 Dec 20, 2023
@bverkron
Copy link

bverkron commented Dec 29, 2023

A right side bar with content of headings on the page that is being viewed (created from H2 and H3 headings on the page) to make navigation within the page easier

Would love a table of contents!

@bverkron
Copy link

Edit: I see that you can manually add a table of contents with the [toc] syntax but having an automatically generated ToC on each page would be much easier and avoid using custom syntax that may not be supported in other wiki platforms / renderers.

Also IMO it should created the ToC based on all headings tags not just h2 and h3.

@Zavy86 Zavy86 changed the title sidebar and back to top back to top link Jan 18, 2024
@ffiesta
Copy link
Contributor

ffiesta commented Jun 7, 2024

Hi,

I have 2 ways to go to TOP

  1. markdown Mode
\> [Homepage](/biblio.code)  

[Go UP](#homepage)
  1. html code Mode
<a href="#" style="position: fixed;bottom: 15px;right: 30px;z-index: 99;font-size: 12px;border: none;outline: none;background-color: red;color: white;cursor: pointer;padding: 15px;border-radius: 4px;" target="_top">TOP</a>   

image

@Zavy86 Zavy86 added this to the Release 1.1 milestone Aug 22, 2024
@Zavy86
Copy link
Owner Author

Zavy86 commented Aug 22, 2024

we can add a green (main color) button in the bottom of the page..

@ffiesta
Copy link
Contributor

ffiesta commented Oct 1, 2024

Due to my basic PHP knowledge, it is preferable to be "someone" with more knowledge to add the back to top link to the wikidocs code.

Teste on wikidocs 1.0.37 and 1.0.42.

The line numbers refer to the approximate location.

  1. Add code to file template.inc.php after </main> line341 :
<button onclick="topFunction()" id="myBtn" title="Go to top" style="display: none; position: fixed;bottom: 15px;right: 30px;z-index: 99;font-size: 12px;border: none;outline: none;background-color: #4caf50;color: white;cursor: pointer;padding: 15px;border-radius: 4px;">Top</button>
  1. Add code to file template.inc.php after <?php endif; ?> line379:
<script>
// Get the button Top
let mybutton = document.getElementById("myBtn");

// When the user scrolls down 30px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
 if (document.body.scrollTop > 40 || document.documentElement.scrollTop > 40) {
   mybutton.style.display = "block";
 } else {
   mybutton.style.display = "none";
 }
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
 document.body.scrollTop = 0;
 document.documentElement.scrollTop = 0;
}
</script>

@ffiesta
Copy link
Contributor

ffiesta commented Oct 1, 2024

Image without Top Button
Screenshot_20241001-165313_Brave

Image with Top Button
Screenshot_20241001-165323_Brave

📝 The code only add the green TOP button on right lower corner of webpage.

@leomoon
Copy link
Collaborator

leomoon commented Oct 1, 2024

Edit: I see that you can manually add a table of contents with the [toc] syntax but having an automatically generated ToC on each page would be much easier and avoid using custom syntax that may not be supported in other wiki platforms / renderers.

Also IMO it should created the ToC based on all headings tags not just h2 and h3.

About the TOC, not everyone like TOC on every doc.

One example would be a short page doesn't need TOC...

We want to follow standard wiki workflows.

@ffiesta
Copy link
Contributor

ffiesta commented Oct 1, 2024

Edit: I see that you can manually add a table of contents with the [toc] syntax but having an automatically generated ToC on each page would be much easier and avoid using custom syntax that may not be supported in other wiki platforms / renderers.
Also IMO it should created the ToC based on all headings tags not just h2 and h3.

About the TOC, not everyone like TOC on every doc.

One example would be a short page doesn't need TOC...

We want to follow standard wiki workflows.

Hi @leomoon , I don't understand what you mean by TOC, but if you are referencing the text with dot point,

  • the 3 dot's and names are my folders, not go to top button

The code only add the lower right corner green top button

image

Images is to show with-out and with top button!!!

Code is based on: https://www.w3schools.com/howto/howto_js_scroll_to_top.asp

@leomoon
Copy link
Collaborator

leomoon commented Oct 1, 2024

TOC = table of contents.

@ffiesta
Copy link
Contributor

ffiesta commented Oct 1, 2024

Please check if my location of UP button is good, otherwise send me better location to I try.

@Zavy86
Copy link
Owner Author

Zavy86 commented Oct 2, 2024

Hi @ffiesta, open a pull request so we can test it together, if necessary we can make the changes directly there!

Due to my basic PHP knowledge, it is preferable to be "someone" with more knowledge to add the back to top link to the wikidocs code.

ffiesta added a commit to ffiesta/ff-Wikidocs that referenced this issue Oct 3, 2024
Add **Go to top** green button.

Issue Zavy86#80
@leomoon
Copy link
Collaborator

leomoon commented Oct 4, 2024

This is added thanks to @ffiesta in version 1.0.60

@leomoon leomoon closed this as completed Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants