-
Notifications
You must be signed in to change notification settings - Fork 480
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
On Hover Footnote Preview #2522
base: master
Are you sure you want to change the base?
Changes from all commits
c5bdf16
ee0aaf5
2dc0a61
ab6e936
df18139
e0b3442
7643c7e
b493790
30b4dbe
aae6718
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// libraries: jquery | ||
// arguments: $ | ||
|
||
$(document).ready(function() { | ||
$('.footnote-ref').hover(function() { | ||
var id = $(this).attr('href'); | ||
var footnoteContent = $(id).clone().find('a').remove().end().html(); | ||
$(this).next('.footnote-preview').html(footnoteContent); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
@import "docstring"; | ||
@import "example"; | ||
@import "warner"; | ||
@import "footnote" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.footnote-reference { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe name these, e.g., There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for now until jQuery is being used we can only use this for footnotes but if can we use Julia for adding content then it will be better to change this to global use for preview features in all parts! |
||
position: relative; | ||
} | ||
|
||
.footnote-preview { | ||
display: none; | ||
position: absolute; | ||
z-index: 1; | ||
max-width: 300px; | ||
width: max-content; | ||
background-color: $body-background-color; | ||
border: 1px solid $link-hover; | ||
padding: 10px; | ||
margin-top: 10px; | ||
border-radius: 5px; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
top: calc(100% + 10px); | ||
} | ||
|
||
.footnote-preview::before { | ||
content: ""; | ||
position: absolute; | ||
top: -10px; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
border-left: 10px solid transparent; | ||
border-right: 10px solid transparent; | ||
border-bottom: 10px solid $link-hover; | ||
} | ||
|
||
.footnote-ref:hover+.footnote-preview, | ||
.footnote-ref:focus+.footnote-preview { | ||
display: block; | ||
} |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is where it actually sets the preview text that will be shown on hover, right?
Can you elaborate a little on what assumptions this makes on the HTML of the footnote? I'm trying to figure out if these assumptions hold / could be made to hold for bibliographic references as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is used to get the footnote content in hidden span for preview! This jQuery code takes the footnote definitions from the end of the page and puts it into the hidden spans just under the footnotes based on their footnote IDs!
For bibliographic references, we will need another way because the references are in another file and not on same page!
We can add a hidden span in Julia part like this:
We can add a small julia function which stores bibliographic reference on pages its being used on and then add them in span! This way we can use this method for all things that require hover preview feature whether it is footnotes, bibliographic references or docstring references!
We will just need those small julia functions for storing content and put them in span and similar css can be used for all, No Javascript or JQuery will be needed and this is most efficient way!
I used JQuery because I was not able to fetch content using Julia (lack of my expertise)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably not that much of an issue: I wouldn't mind adding (hidden) bibliography items on each page for anything that's being referenced on that page, just for the hover to be able to pick up the text for there. But there should be some existing JS to hook into (i.e., this PR) for showing the hover: I'd like to avoid having to instruct people using the plugin to manually set up JS.