From 245dbdf80c0da384eabd5a389c900d1e8c0e31c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 May 2024 15:47:22 +0200 Subject: [PATCH] Use classes and proper data attributes for tooltips, closes #1899 --- assets/css/print-cheatsheet.css | 2 +- assets/css/tooltips.css | 16 ++++++++-------- .../templates/tooltip-layout.handlebars | 2 +- assets/js/tooltips/tooltips.js | 6 +++--- ...6HKET.js => handlebars.templates-2MV2EWES.js} | 2 +- .../dist/{html-GXQ6W6IF.js => html-KWQGJMTO.js} | 2 +- ...xir-2C5PUTIB.css => html-elixir-CDEHVNM4.css} | 2 +- ...ang-X76CAHZ3.css => html-erlang-EBZIIHAS.css} | 2 +- .../formatter/html/templates/detail_template.eex | 2 +- .../html/templates/summary_template.eex | 2 +- test/ex_doc/formatter/epub/templates_test.exs | 2 +- test/ex_doc/formatter/html/templates_test.exs | 6 +++--- 12 files changed, 23 insertions(+), 23 deletions(-) rename formatters/html/dist/{handlebars.templates-IHH6HKET.js => handlebars.templates-2MV2EWES.js} (99%) rename formatters/html/dist/{html-GXQ6W6IF.js => html-KWQGJMTO.js} (91%) rename formatters/html/dist/{html-elixir-2C5PUTIB.css => html-elixir-CDEHVNM4.css} (99%) rename formatters/html/dist/{html-erlang-X76CAHZ3.css => html-erlang-EBZIIHAS.css} (99%) diff --git a/assets/css/print-cheatsheet.css b/assets/css/print-cheatsheet.css index 0bbeda73f..38b2d17ce 100644 --- a/assets/css/print-cheatsheet.css +++ b/assets/css/print-cheatsheet.css @@ -130,7 +130,7 @@ } /* Remove hover tooltip from inline code references */ - .page-cheatmd .content-inner div#tooltip { + .page-cheatmd .content-inner div.tooltip { display: none; } diff --git a/assets/css/tooltips.css b/assets/css/tooltips.css index 2820e0662..c61952f22 100644 --- a/assets/css/tooltips.css +++ b/assets/css/tooltips.css @@ -1,4 +1,4 @@ -#tooltip { +.tooltip { box-shadow: 0 0 10px var(--black-opacity-10); max-height: 300px; max-width: 500px; @@ -21,28 +21,28 @@ Show-up animation Note: it's fine to hide the tooltip with `visibility: hidden` (rather than `display: none`) as it has absolute positioning, so doesn't impact the layout and click events pass through. */ -#tooltip.tooltip-shown { +.tooltip.tooltip-shown { visibility: visible; transform: translateY(0); opacity: 1; } -#tooltip .tooltip-body { +.tooltip .tooltip-body { border: 1px solid var(--codeBorder); } -#tooltip .tooltip-body .signature { +.tooltip .tooltip-body .signature { min-width: 320px; width: 100%; } -#tooltip .tooltip-body .detail-header { +.tooltip .tooltip-body .detail-header { border-left: 0; margin-bottom: 0; margin-top: 0; } -#tooltip .tooltip-body .docstring { +.tooltip .tooltip-body .docstring { background-color: var(--background); padding: 1.2em; margin: 0; @@ -50,12 +50,12 @@ as it has absolute positioning, so doesn't impact the layout and click events pa } /* Used for simple tooltips having only description. */ -#tooltip .tooltip-body .docstring-plain { +.tooltip .tooltip-body .docstring-plain { max-width: 498px; width: auto; } -#tooltip .tooltip-body .version-info { +.tooltip .tooltip-body .version-info { float: right; line-height: 1.6rem; font-family: var(--monoFontFamily); diff --git a/assets/js/handlebars/templates/tooltip-layout.handlebars b/assets/js/handlebars/templates/tooltip-layout.handlebars index f4d150925..095894d9e 100644 --- a/assets/js/handlebars/templates/tooltip-layout.handlebars +++ b/assets/js/handlebars/templates/tooltip-layout.handlebars @@ -1,3 +1,3 @@ -
+
diff --git a/assets/js/tooltips/tooltips.js b/assets/js/tooltips/tooltips.js index 0edc9e713..f7a38d82f 100644 --- a/assets/js/tooltips/tooltips.js +++ b/assets/js/tooltips/tooltips.js @@ -5,9 +5,9 @@ import { cancelHintFetchingIfAny, getHint, HINT_KIND, isValidHintHref } from './ // Elements that can activate the tooltip. const TOOLTIP_ACTIVATORS_SELECTOR = '.content a' // Tooltip root element. -const TOOLTIP_SELECTOR = '#tooltip' +const TOOLTIP_SELECTOR = '.tooltip' // Tooltip content element. -const TOOLTIP_BODY_SELECTOR = '#tooltip .tooltip-body' +const TOOLTIP_BODY_SELECTOR = '.tooltip .tooltip-body' // Element containing the documentation text. const CONTENT_INNER_SELECTOR = 'body .content-inner' @@ -65,7 +65,7 @@ function addEventListeners () { */ function linkElementEligibleForTooltip (linkElement) { // Skip tooltips on the permalink icon (the on-hover one next to the function name). - if (linkElement.classList.contains('detail-link')) { return false } + if (linkElement.getAttribute('data-no-tooltip') !== null) { return false } // Skip link to the module page we are already on. if (isHrefToSelf(linkElement.href)) { return false } diff --git a/formatters/html/dist/handlebars.templates-IHH6HKET.js b/formatters/html/dist/handlebars.templates-2MV2EWES.js similarity index 99% rename from formatters/html/dist/handlebars.templates-IHH6HKET.js rename to formatters/html/dist/handlebars.templates-2MV2EWES.js index 41a1ba3c6..29aaf1e0d 100644 --- a/formatters/html/dist/handlebars.templates-IHH6HKET.js +++ b/formatters/html/dist/handlebars.templates-2MV2EWES.js @@ -207,7 +207,7 @@ `+((o=s(a,"if").call(l??(e.nullContext||{}),(o=l!=null?s(l,"hint"):l)!=null?s(o,"description"):o,{name:"if",hash:{},fn:e.program(4,u,0),inverse:e.noop,data:u,loc:{start:{line:12,column:2},end:{line:16,column:9}}}))!=null?o:"")},4:function(e,l,a,p,u){var o,n=e.lookupProperty||function(r,s){if(Object.prototype.hasOwnProperty.call(r,s))return r[s]};return`
`+((o=e.lambda((o=l!=null?n(l,"hint"):l)!=null?n(o,"description"):o,l))!=null?o:"")+`
-`},compiler:[8,">= 4.3.0"],main:function(e,l,a,p,u){var o,n=e.lookupProperty||function(r,s){if(Object.prototype.hasOwnProperty.call(r,s))return r[s]};return(o=n(a,"if").call(l??(e.nullContext||{}),l!=null?n(l,"isPlain"):l,{name:"if",hash:{},fn:e.program(1,u,0),inverse:e.program(3,u,0),data:u,loc:{start:{line:1,column:0},end:{line:17,column:7}}}))!=null?o:""},useData:!0}),y["tooltip-layout"]=d({compiler:[8,">= 4.3.0"],main:function(e,l,a,p,u){return`
+`},compiler:[8,">= 4.3.0"],main:function(e,l,a,p,u){var o,n=e.lookupProperty||function(r,s){if(Object.prototype.hasOwnProperty.call(r,s))return r[s]};return(o=n(a,"if").call(l??(e.nullContext||{}),l!=null?n(l,"isPlain"):l,{name:"if",hash:{},fn:e.program(1,u,0),inverse:e.program(3,u,0),data:u,loc:{start:{line:1,column:0},end:{line:17,column:7}}}))!=null?o:""},useData:!0}),y["tooltip-layout"]=d({compiler:[8,">= 4.3.0"],main:function(e,l,a,p,u){return`
`},useData:!0}),y["versions-dropdown"]=d({1:function(e,l,a,p,u){var o,n,r=l??(e.nullContext||{}),s=e.hooks.helperMissing,i="function",c=e.escapeExpression,t=e.lookupProperty||function(f,m){if(Object.prototype.hasOwnProperty.call(f,m))return f[m]};return'