Provide "GitHub-like" anchor links affordance (thanks @cbeams)

This commit is contained in:
Saivann 2014-05-24 21:56:08 -04:00
parent 5015b34f77
commit c4a8c26465
6 changed files with 110 additions and 0 deletions

View file

@ -783,6 +783,22 @@ table td,table th{
color:#646464; color:#646464;
} }
.anchorAf{
position:relative;
}
.anchorAf a{
display:none;
}
.anchorAf:hover a{
display:block;
position:absolute;
width:24px;
left:-24px;
bottom:0;
top:0;
background:url(/img/mini_ico_anchor.png) no-repeat center center;
}
.develdocdisclaimer{ .develdocdisclaimer{
padding:30px 0; padding:30px 0;
background:#fff; background:#fff;

View file

@ -56,3 +56,4 @@ of the following file. -->
</div> </div>
<script>updateToc();</script> <script>updateToc();</script>
<script>addAnchorLinks();</script>

View file

@ -59,3 +59,4 @@ untrusted source.
</div> </div>
<script>updateToc();</script> <script>updateToc();</script>
<script>addAnchorLinks();</script>

BIN
img/mini_ico_anchor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

73
img/mini_ico_anchor.svg Normal file
View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16px"
height="16px"
id="svg2985"
version="1.1"
inkscape:version="0.48.4 r9939"
sodipodi:docname="mini_ico_anchor.svg"
inkscape:export-filename="/media/X/bitcoin.org/current/img/mini_ico_anchor.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs2987" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.197802"
inkscape:cx="-7.4053957"
inkscape:cy="17.987535"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="1615"
inkscape:window-height="1026"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata2990">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<rect
style="fill:#000000;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect2993"
width="10.811881"
height="10.811881"
x="1.4866337"
y="3.2509902"
ry="1.8470297" />
<path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:2;stroke-opacity:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans;stroke-miterlimit:4;stroke-dasharray:none"
d="M 8.563468,0.19785398 C 8.1290051,0.26495273 7.8341908,0.60084798 7.7215633,0.93873015 7.6089361,1.2766123 7.649985,1.7020113 7.9572966,2.0163682 L 8.8328775,2.9256251 5.1621733,6.3605961 C 4.7397897,6.767268 4.711073,7.3990336 5.094821,7.8423484 l 0,0.033675 2.6604186,2.8287996 c 0.4135514,0.467287 1.0965564,0.496983 1.5491048,0.06735 l 3.6707036,-3.4349722 1.010286,0.9766095 c 0.334627,0.3172934 0.803376,0.3075559 1.14499,0.1683812 0.341613,-0.1391747 0.655898,-0.4484522 0.673524,-0.9092566 l 0,-0.033675 -0.06735,-6.2637706 C 15.736437,0.6665883 15.267759,0.19791233 14.65886,0.19785136 l -6.0280385,0 -0.033675,0 z"
id="path3763"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cscccccccccsccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -361,6 +361,25 @@ addEvent(window,'load',evtimestamp);
init(); init();
} }
function addAnchorLinks(){
//Apply anchor links icon on each title displayed on CSS hover
var nodes=[];
var tags=['H2','H3','H4','H5','H6'];
for(var i=0,n=tags.length;i<n;i++){
for(var ii=0,t=document.getElementsByTagName(tags[i]),nn=t.length;ii<nn;ii++)nodes.push(t[ii]);
}
for(var i=0,n=nodes.length;i<n;i++){
if(!nodes[i].id)continue;
if(nodes[i].getElementsByTagName('A').length>0)return;
var cl=nodes[i].className.split(' ');
cl.push('anchorAf')
nodes[i].className=cl.join(' ');
var anc=document.createElement('A');
anc.href='#'+nodes[i].id;
nodes[i].insertBefore(anc,nodes[i].firstChild);
}
}
function updateIssue(e){ function updateIssue(e){
//Update GitHub issue link with pre-filled with current page location //Update GitHub issue link with pre-filled with current page location
var t=getEventTarget(e); var t=getEventTarget(e);