Merge pull request #426 from bitcoin/devel-anchors
Provide "GitHub-like" anchor links affordance
This commit is contained in:
commit
cc03f390bc
@ -783,6 +783,22 @@ table td,table th{
|
||||
color:#646464;
|
||||
}
|
||||
|
||||
.anchorAf{
|
||||
position:relative;
|
||||
}
|
||||
.anchorAf a{
|
||||
display:none;
|
||||
position:absolute;
|
||||
width:24px;
|
||||
left:-24px;
|
||||
bottom:0;
|
||||
top:0;
|
||||
background:url(/img/mini_ico_anchor.svg) no-repeat center center;
|
||||
}
|
||||
.anchorAf:hover a{
|
||||
display:block;
|
||||
}
|
||||
|
||||
.develdocdisclaimer{
|
||||
padding:30px 0;
|
||||
background:#fff;
|
||||
|
||||
@ -56,3 +56,4 @@ of the following file. -->
|
||||
</div>
|
||||
|
||||
<script>updateToc();</script>
|
||||
<script>addAnchorLinks();</script>
|
||||
|
||||
@ -59,3 +59,4 @@ untrusted source.
|
||||
</div>
|
||||
|
||||
<script>updateToc();</script>
|
||||
<script>addAnchorLinks();</script>
|
||||
|
||||
BIN
img/mini_ico_anchor.png
Normal file
BIN
img/mini_ico_anchor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 394 B |
BIN
img/mini_ico_anchor.svg
Normal file
BIN
img/mini_ico_anchor.svg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
19
js/main.js
19
js/main.js
@ -361,6 +361,25 @@ addEvent(window,'load',evtimestamp);
|
||||
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){
|
||||
//Update GitHub issue link with pre-filled with current page location
|
||||
var t=getEventTarget(e);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user