Merge pull request #426 from bitcoin/devel-anchors

Provide "GitHub-like" anchor links affordance
This commit is contained in:
saivann 2014-05-26 10:37:55 -04:00
commit cc03f390bc
6 changed files with 37 additions and 0 deletions

View File

@ -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;

View File

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

View File

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

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -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);