Skip to content

Commit 0b82563

Browse files
committed
add a hover link at section anchor.
1 parent a1a318f commit 0b82563

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

_includes/themes/twitter/default.html

+18
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<link href="{{ ASSET_PATH }}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
1717
<link href="{{ ASSET_PATH }}/css/style.css?body=1" rel="stylesheet" type="text/css" media="all">
1818
<link href="{{ ASSET_PATH }}/css/enju.css" rel="stylesheet" type="text/css" media="all">
19+
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
1920

2021
<!-- Le fav and touch icons -->
2122
<!-- Update these with your own images
@@ -24,6 +25,10 @@
2425
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
2526
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
2627
-->
28+
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
29+
<script type="text/javascript">
30+
google.load("jquery", "1.5.1");
31+
</script>
2732
</head>
2833

2934
<body>
@@ -53,5 +58,18 @@
5358
</div> <!-- /container -->
5459

5560
{% include JB/analytics %}
61+
<script language="JavaScript" type="application/javascript">
62+
$(function() {
63+
return $("h2, h3, h4, h5, h6").each(function(i, el) {
64+
var $el, icon, id;
65+
$el = $(el);
66+
id = $el.attr('id');
67+
icon = '<span class="fa fa-link"></span>';
68+
if (id) {
69+
return $el.prepend($("<a />").addClass("header-link").attr("href", "#" + id).html(icon));
70+
}
71+
});
72+
});
73+
</script>
5674
</body>
5775
</html>

assets/themes/twitter/css/enju.css

+23
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,26 @@ div.memo {
1111
margin-left: 2em;
1212
margin-right: 2em;
1313
}
14+
15+
/* http://ben.balter.com/2014/03/13/pages-anchor-links/ */
16+
.header-link {
17+
position: absolute;
18+
left: -1em;
19+
opacity: 0;
20+
21+
-webkit-transition: opacity 0.2s ease-in-out 0.1s;
22+
-moz-transition: opacity 0.2s ease-in-out 0.1s;
23+
-ms-transition: opacity 0.2s ease-in-out 0.1s;
24+
}
25+
26+
h2, h3, h4, h5, h6 {
27+
position: relative;
28+
}
29+
h2:hover .header-link,
30+
h3:hover .header-link,
31+
h4:hover .header-link,
32+
h5:hover .header-link,
33+
h6:hover .header-link {
34+
opacity: 1;
35+
}
36+

0 commit comments

Comments
 (0)