Page MenuHomePhabricator

Footnotes content should appear in a tooltip (add ReferenceTooltips to Cite as default/option)
Closed, ResolvedPublicFeature

Description

Author: le.korrigan

Description:
The content of a footnote (or the beginning of it, until XX characters) could
appear in a tooltip when the mouse pointer is over the reference link : this
way, short notes are visible while reading, which is better for the reader.


Version: unspecified
Severity: enhancement

Details

Reference
bz7908

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:29 PM
bzimport added a project: Cite.
bzimport set Reference to bz7908.
bzimport added a subscriber: Unknown Object (MLST).

Beetstra.wiki wrote:

I might have a look at this one, I'm busy revamping cite.php anyway (see
http://bugzilla.wikimedia.org/show_bug.cgi?id=423)!

robchur wrote:

When assigning bugs, please *do it right*. Thanks.

Beetstra.wiki wrote:

Reference in tooltip

Added a bit of javascript which adds a title to the id of the reference.

attachment cite tooltip.patch ignored as obsolete

Beetstra.wiki wrote:

new patch

This patch puts the text of the reference into the title-field of the tooltip.
In this way people will be able to see the text of the reference by hovering
over the reference, and they do not need to scroll all the way down (which is
distracting when reading the document).

A demo is running on chemistry.poolspares.com, though it is there combined with
the patch on bug 423.

attachment cite tooltip.patch ignored as obsolete

Beetstra.wiki wrote:

reference in tooltip

cleaner references, for comments see previous patch

attachment cite tooltip.patch ignored as obsolete

Beetstra.wiki wrote:

new patch

updated patch, remove an error

attachment cite tooltip.patch ignored as obsolete

Beetstra.wiki wrote:

tooltip patch

(previous patch was broken)

attachment cite tooltip.patch ignored as obsolete

Reverted; this needs work. A few notes:

  • Raw HTML code in messages seems rather... icky. Fragile and likely to fail due

to mistakes or customization gone awry. :)

  • When generating JavaScript literal strings, you should probably use

Xml::escapeJsString rather than trying to roll your own escape function; this
keeps things consistent and is probably safer (eg newlines and escapes are
already handled in a common place)

  • Don't forget to run the parser tests, and update them if necessary. This patch

breaks 10 test cases.

  • The use of JavaScript seems pretty weird here to begin with. Why use JS at

all? It harms compatibility and is probably more fragile than simply putting the
title attribute where it belongs in the first place.

Beetstra.wiki wrote:

I'll quick-reply to this.

  • Understood, they have to move to the main code. Don't need customisation, anyway.
  • I'll look into the documentation for that.
  • Ke, asked for testing, but will try to run them myself as well.
  • Nope, doesn't work, references are not by definition known at the moment the HTML of the inline

reference mark is generated, so have to be supplied later anyway. Another problem there is that it
is wikitext, which does not have the possibility to add a custom title.

Beetstra.wiki wrote:

refs in tooltip

Added tooltips and adapted citeparsertests.txt

Re previous comments:

  • Changed rendering of javatext title parameter
  • Parsertests.php does not give more errors than before.
  • internationalisation removed (these parameters do not require

customisation/internationalisation)

  • Added comment in code on why Java and why there

Please test and check, this is my first Javascript addition. Hope this is all
correct.

attachment cite tooltip.patch ignored as obsolete

mike wrote:

refs in tooltip updated

I updated the patch to make it working on the latest revision.

There's a big problem with this implementation : tooltip content is displayed in raw HTML. If there's a link, bold or anything in the ref tag, HTML tags are included in the tooltip.

I see two ways to avoid that :

  • Remove HTML tags and only display content (probably error prone).
  • Replace the tooltip with real HTML rendered by the browser (probably complex javascript code).

Attached:

Hmmmm, it might be cleaner to do a ful display in client-side JS. Since the reference's contents get rendered later on the page, they can be fairly straightforwardly retrieved at display time by JS and copied into a floating box which is shown on mouseover.

Using a trimmed and HTML-stripped text for a 'title' attribute might also be a little extra helper suitable for browsers with JS disabled or unavailable.

  • Bug 11515 has been marked as a duplicate of this bug. ***

folengo wrote:

I am not quite sure "tooltip" is the right wording. I would rather call it a "pop up". They have it on an internet site I know, for example on that page : http://www.nonfiction.fr/article-171-hobsbawm_et_le_bicentenaire_de_la_revolution.htm

I find it convenient and, well... "cool".

ncw33 wrote:

The Cite extension is not really the place to implement this. As user javascript, it is stable and well implemented (see [[Wikipedia:Tools/Navigation popups]]). If you have no intention of fixing the code, this could be closed on the basis of being already fixed there.

*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*

sumanah wrote:

Mike, thanks for the patch.

(In reply to comment #13)

Hmmmm, it might be cleaner to do a ful display in client-side JS. Since the
reference's contents get rendered later on the page, they can be fairly
straightforwardly retrieved at display time by JS and copied into a floating
box which is shown on mouseover.

Using a trimmed and HTML-stripped text for a 'title' attribute might also be a
little extra helper suitable for browsers with JS disabled or unavailable.

Per this review by Brion, I'm marking this patch as reviewed. Do you have time and/or interest in revising your patch? Thanks again!

Updating summary.
Should this become the new default or just an option?
Would making it the default save parsing time?
If default, does having the notes render in HTML in the same point where they are in wikitext save parsing time? From hearsay: the parser doesn't enjoy fetching the last chunk of the HTML from all over the wikitext of the page, right?

I like the idea of having the ReferenceTooltips as default. Maybe it should be integrated with Extension:Cite.

However, I'd like the title attribute of the <sup>'d reference links to be generated in HTML, for maximum compatibility and accessibility. These could then be removed by JS as it dynamically adds the rich tooltip (the progressive enhancement pattern). Interestingly, pure-html toolstips can even be slighly formatted with control characters such as line breaks and tabs (see http://stackoverflow.com/a/12486358/266309)

It looks like some experimental tooltip code was added to cite.php but recently removed.

We now have the experimental HoverCards which works pretty well for reference tooltips.

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:24 PM
Aklapper removed a subscriber: wikibugs-l-list.