MediaWiki:Gadget-vector-headanchor

From Noisebridge
Revision as of 22:02, 3 June 2023 by Mcint (talk | contribs) (Created page with "<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en">

 <siteinfo>
   <sitename>MediaWiki</sitename>
   <dbname>mediawikiwiki</dbname>
   <base>https://www.mediawiki.org/wiki/MediaWiki</base>
   <generator>MediaWiki 1.41.0-wmf.11</generator>
   <case>first-letter</case>
   <namespaces>
     <namespace key="-2" case="first-letter">Media</namespace>
     <namespace key="-1" case="first-letter">Special</namespace>
     <namespace key="0" case="first-letter" />
     <namespace key="1" case="first-letter">Talk</namespace>
     <namespace key="2" case="first-letter">User</namespace>
     <namespace key="3" case="first-letter">User talk</namespace>
     <namespace key="4" case="first-letter">Project</namespace>
     <namespace key="5" case="first-letter">Project talk</namespace>
     <namespace key="6" case="first-letter">File</namespace>
     <namespace key="7" case="first-letter">File talk</namespace>
     <namespace key="8" case="first-letter">MediaWiki</namespace>
     <namespace key="9" case="first-letter">MediaWiki talk</namespace>
     <namespace key="10" case="first-letter">Template</namespace>
     <namespace key="11" case="first-letter">Template talk</namespace>
     <namespace key="12" case="first-letter">Help</namespace>
     <namespace key="13" case="first-letter">Help talk</namespace>
     <namespace key="14" case="first-letter">Category</namespace>
     <namespace key="15" case="first-letter">Category talk</namespace>
     <namespace key="90" case="first-letter">Thread</namespace>
     <namespace key="91" case="first-letter">Thread talk</namespace>
     <namespace key="92" case="first-letter">Summary</namespace>
     <namespace key="93" case="first-letter">Summary talk</namespace>
     <namespace key="100" case="first-letter">Manual</namespace>
     <namespace key="101" case="first-letter">Manual talk</namespace>
     <namespace key="102" case="first-letter">Extension</namespace>
     <namespace key="103" case="first-letter">Extension talk</namespace>
     <namespace key="104" case="first-letter">API</namespace>
     <namespace key="105" case="first-letter">API talk</namespace>
     <namespace key="106" case="first-letter">Skin</namespace>
     <namespace key="107" case="first-letter">Skin talk</namespace>
     <namespace key="486" case="first-letter">Data</namespace>
     <namespace key="487" case="first-letter">Data talk</namespace>
     <namespace key="710" case="first-letter">TimedText</namespace>
     <namespace key="711" case="first-letter">TimedText talk</namespace>
     <namespace key="828" case="first-letter">Module</namespace>
     <namespace key="829" case="first-letter">Module talk</namespace>
     <namespace key="1198" case="first-letter">Translations</namespace>
     <namespace key="1199" case="first-letter">Translations talk</namespace>
     <namespace key="2300" case="case-sensitive">Gadget</namespace>
     <namespace key="2301" case="case-sensitive">Gadget talk</namespace>
     <namespace key="2302" case="case-sensitive">Gadget definition</namespace>
     <namespace key="2303" case="case-sensitive">Gadget definition talk</namespace>
     <namespace key="2600" case="first-letter">Topic</namespace>
     <namespace key="5500" case="first-letter">Newsletter</namespace>
     <namespace key="5501" case="first-letter">Newsletter talk</namespace>
   </namespaces>
 </siteinfo>
 <page>
   <title>MediaWiki:Gadget-vector-headanchor</title>
   <ns>8</ns>
   <id>121515</id>
   <revision>
     <id>4378926</id>
     <parentid>675411</parentid>
     <timestamp>2021-01-30T00:01:26Z</timestamp>
     <contributor>
       <username>Krinkle</username>
       <id>135822</id>
     </contributor>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="116" xml:space="preserve">Heading Anchor: Adds section anchors to each wiki page heading. They become visible on hover. (Vector skin only)</text>
     <sha1>qz911omc00kn21963zmeqbjnkyh6s9q</sha1>
   </revision>
 </page>
 <page>
   <title>MediaWiki:Gadget-vector-headanchor.js</title>
   <ns>8</ns>
   <id>121513</id>
   <revision>
     <id>4823026</id>
     <parentid>4629150</parentid>
     <timestamp>2021-09-24T21:14:28Z</timestamp>
     <contributor>
       <username>Krinkle</username>
       <id>135822</id>
     </contributor>
     <model>javascript</model>
     <format>text/javascript</format>
     <text bytes="829" xml:space="preserve">/*!

// Revision as of 2021-01-29

mw.hook( 'wikipage.content' ).add( function ( $content ) { $content.find( 'span.mw-headline' ).each( function ( i, el ) { var heading = el.parentNode; if ( !el.id || heading.querySelector( '.tpl-vheadanchor') ) { // No anchor possible, or anchor already inserted return; }

heading.classList.add('tpl-vheadanchor-heading');

// Insert anchor. anchor = document.createElement( 'a' ); anchor.href = '#' + el.id; anchor.textContent = '#'; anchor.title = 'Link to this section'; anchor.className = 'tpl-vheadanchor'; heading.insertBefore( anchor, el.nextSibling ); } ); } );</text>

     <sha1>79alm3uiubjox1huog2xkkkgakbqnxx</sha1>
   </revision>
 </page>
 <page>
   <title>MediaWiki:Gadget-vector-headanchor.css</title>
   <ns>8</ns>
   <id>121514</id>
   <revision>
     <id>4903211</id>
     <parentid>4903210</parentid>
     <timestamp>2021-11-11T23:48:15Z</timestamp>
     <contributor>
       <username>Krinkle</username>
       <id>135822</id>
     </contributor>
     <model>css</model>
     <format>text/css</format>
     <text bytes="2203" xml:space="preserve">/*!
* Vector HeadAnchors gadget, from <https://mediawiki.org/wiki/MediaWiki:Gadget-vector-headanchor.js>
*
* Copyright 2013 Timo Tijhof
* @license MIT <https://opensource.org/licenses/MIT>
*/

/* Revision as of 2021-10-11 */

.tpl-vheadanchor-heading { position: relative; /* Disable Vector's `overflow: hidden` because otherwise our negatively positioned anchor won't be visible.

By itself, showing overflow would cause two problems:

1. We normally hide overflow for a reason. Namely, to ensure that infoboxes and thumbnails retain their margins and thus things like heading bottom borders will stay away from the edge of these floated boxes.

   2. Headanchor needs `position: relative`, which affects stacking
      context (like z-index). If we don't hide overflow, that means
      the heading and its border etc will render over top and
      strike-through any content in the thumbnail and infobox.
   
   We solve both of these by bringing back the "create block-formatting
   context" behaviour of `overflow: hidden` with `display: flex-root`.
   This isn't supported in all Basic browsers, but good enough for
   this gadget.
   
   Thanks User:Tgr!
   */

overflow: visible; display: flow-root; }

.tpl-vheadanchor { position: absolute; /* consistent font and size, regardless of heading level */ font-family: serif; font-size: 24px; font-weight: normal; /* reset any bolding from H3-H6 styles */ line-height: 1.3; /* Based on Vector mw-body padding being 16px */ left: -16px; /* Use padding instead of margin. Two reasons: 1. With margin, there would be a pointer gap between headline and anchor, and thus flickering because :hover would not match in-between 2. With padding, we get a bigger tap/hover area. */ padding: 0 3px; } h3 .tpl-vheadanchor { line-height: 1.1; } h4 .tpl-vheadanchor, h6 .tpl-vheadanchor, h6 .tpl-vheadanchor { line-height: 1.0; } /* Based on Vector wide viewport using mw-body padding of 24px */ @media screen and (min-width: 982px) { .tpl-vheadanchor { left: -24px; padding: 0 7px; } }

.tpl-vheadanchor-heading:not(:hover) .mw-headline:not(:target) ~ .tpl-vheadanchor { color: #c8ccd1; }</text>

     <sha1>o6wuok3yapw9q70bbigi2seclcqp6g0</sha1>
   </revision>
 </page>

</mediawiki>