Skip to content

Commit 245dbdf

Browse files
committed
Use classes and proper data attributes for tooltips, closes #1899
1 parent fdace93 commit 245dbdf

File tree

12 files changed

+23
-23
lines changed

12 files changed

+23
-23
lines changed

assets/css/print-cheatsheet.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
}
131131

132132
/* Remove hover tooltip from inline code references */
133-
.page-cheatmd .content-inner div#tooltip {
133+
.page-cheatmd .content-inner div.tooltip {
134134
display: none;
135135
}
136136

assets/css/tooltips.css

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#tooltip {
1+
.tooltip {
22
box-shadow: 0 0 10px var(--black-opacity-10);
33
max-height: 300px;
44
max-width: 500px;
@@ -21,41 +21,41 @@ Show-up animation
2121
Note: it's fine to hide the tooltip with `visibility: hidden` (rather than `display: none`)
2222
as it has absolute positioning, so doesn't impact the layout and click events pass through.
2323
*/
24-
#tooltip.tooltip-shown {
24+
.tooltip.tooltip-shown {
2525
visibility: visible;
2626
transform: translateY(0);
2727
opacity: 1;
2828
}
2929

30-
#tooltip .tooltip-body {
30+
.tooltip .tooltip-body {
3131
border: 1px solid var(--codeBorder);
3232
}
3333

34-
#tooltip .tooltip-body .signature {
34+
.tooltip .tooltip-body .signature {
3535
min-width: 320px;
3636
width: 100%;
3737
}
3838

39-
#tooltip .tooltip-body .detail-header {
39+
.tooltip .tooltip-body .detail-header {
4040
border-left: 0;
4141
margin-bottom: 0;
4242
margin-top: 0;
4343
}
4444

45-
#tooltip .tooltip-body .docstring {
45+
.tooltip .tooltip-body .docstring {
4646
background-color: var(--background);
4747
padding: 1.2em;
4848
margin: 0;
4949
width: 498px; /* Taking 2 * 1px of border into account */
5050
}
5151

5252
/* Used for simple tooltips having only description. */
53-
#tooltip .tooltip-body .docstring-plain {
53+
.tooltip .tooltip-body .docstring-plain {
5454
max-width: 498px;
5555
width: auto;
5656
}
5757

58-
#tooltip .tooltip-body .version-info {
58+
.tooltip .tooltip-body .version-info {
5959
float: right;
6060
line-height: 1.6rem;
6161
font-family: var(--monoFontFamily);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div id="tooltip">
1+
<div class="tooltip">
22
<div class="tooltip-body"></div>
33
</div>

assets/js/tooltips/tooltips.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { cancelHintFetchingIfAny, getHint, HINT_KIND, isValidHintHref } from './
55
// Elements that can activate the tooltip.
66
const TOOLTIP_ACTIVATORS_SELECTOR = '.content a'
77
// Tooltip root element.
8-
const TOOLTIP_SELECTOR = '#tooltip'
8+
const TOOLTIP_SELECTOR = '.tooltip'
99
// Tooltip content element.
10-
const TOOLTIP_BODY_SELECTOR = '#tooltip .tooltip-body'
10+
const TOOLTIP_BODY_SELECTOR = '.tooltip .tooltip-body'
1111
// Element containing the documentation text.
1212
const CONTENT_INNER_SELECTOR = 'body .content-inner'
1313

@@ -65,7 +65,7 @@ function addEventListeners () {
6565
*/
6666
function linkElementEligibleForTooltip (linkElement) {
6767
// Skip tooltips on the permalink icon (the on-hover one next to the function name).
68-
if (linkElement.classList.contains('detail-link')) { return false }
68+
if (linkElement.getAttribute('data-no-tooltip') !== null) { return false }
6969

7070
// Skip link to the module page we are already on.
7171
if (isHrefToSelf(linkElement.href)) { return false }

formatters/html/dist/handlebars.templates-IHH6HKET.js formatters/html/dist/handlebars.templates-2MV2EWES.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

formatters/html/dist/html-GXQ6W6IF.js formatters/html/dist/html-KWQGJMTO.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

formatters/html/dist/html-elixir-2C5PUTIB.css formatters/html/dist/html-elixir-CDEHVNM4.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

formatters/html/dist/html-erlang-X76CAHZ3.css formatters/html/dist/html-erlang-EBZIIHAS.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ex_doc/formatter/html/templates/detail_template.eex

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<span id="<%=enc "#{default_name}/#{default_arity}" %>"></span>
44
<% end %>
55
<div class="detail-header">
6-
<a href="#<%=enc node.id %>" class="detail-link" title="Link to this <%= pretty_type(node) %>">
6+
<a href="#<%=enc node.id %>" class="detail-link" data-no-tooltip title="Link to this <%= pretty_type(node) %>">
77
<i class="ri-link-m" aria-hidden="true"></i>
88
<span class="sr-only">Link to this <%= pretty_type(node) %></span>
99
</a>

lib/ex_doc/formatter/html/templates/summary_template.eex

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<%= for node <- nodes do %>
66
<div class="summary-row">
77
<div class="summary-signature">
8-
<a href="#<%=enc node.id %>" translate="no"><%=h node.signature %></a>
8+
<a href="#<%=enc node.id %>" data-no-tooltip translate="no"><%=h node.signature %></a>
99
<%= if deprecated = node.deprecated do %>
1010
<span class="deprecated" title="<%= h(deprecated) %>">deprecated</span>
1111
<% end %>

test/ex_doc/formatter/epub/templates_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ defmodule ExDoc.Formatter.EPUB.TemplatesTest do
145145
content = get_module_page([CompiledWithDocs])
146146

147147
assert content =~
148-
~r{<div class="summary-signature">\s*<a href="#example_1/0" translate="no">}
148+
~r{<div class="summary-signature">\s*<a href="#example_1/0" data-no-tooltip translate="no">}
149149
end
150150

151151
test "contains links to summary sections when those exist" do

test/ex_doc/formatter/html/templates_test.exs

+3-3
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
501501
assert content =~ ~s{example(foo, bar \\\\ Baz)}
502502

503503
assert content =~
504-
~r{<a href="#example/2" class="detail-link" title="Link to this function">\s*<i class="ri-link-m" aria-hidden="true"></i>\s*<span class="sr-only">Link to this function</span>\s*</a>}ms
504+
~r{<a href="#example/2" class="detail-link" data-no-tooltip title="Link to this function">\s*<i class="ri-link-m" aria-hidden="true"></i>\s*<span class="sr-only">Link to this function</span>\s*</a>}ms
505505
end
506506

507507
test "outputs function groups", context do
@@ -542,7 +542,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
542542
~S[<a href="TypesAndSpecs.Sub.html#t:t/0">TypesAndSpecs.Sub.t</a>(), ] <>
543543
~S[<a href="#t:opaque/0">opaque</a>(), :ok | :error}]
544544

545-
assert content =~ ~s[<a href="#t:public/1" translate="no">public(t)</a>]
545+
assert content =~ ~s[<a href="#t:public/1" data-no-tooltip translate="no">public(t)</a>]
546546
refute content =~ ~s[<a href="#t:private/0">private</a>]
547547
assert content =~ public_html
548548
refute content =~ ~s[<strong>private\(t\)]
@@ -561,7 +561,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
561561
content = get_module_page([CompiledWithDocs], context)
562562

563563
assert content =~
564-
~r{<div class="summary-signature">\s*<a href="#example_1/0" translate="no">}
564+
~r{<div class="summary-signature">\s*<a href="#example_1/0" data-no-tooltip translate="no">}
565565
end
566566

567567
test "contains links to summary sections when those exist", context do

0 commit comments

Comments
 (0)