diff --git a/static/css/hugo-theme.css b/static/css/hugo-theme.css index 4b5502f56f..2aabaa7fe8 100644 --- a/static/css/hugo-theme.css +++ b/static/css/hugo-theme.css @@ -136,3 +136,18 @@ .btn-default:active { background-image: none !important; } + +/* anchors */ +.anchor { + color: #00bdf3; + font-size: 0.5em; + cursor:pointer; + visibility:hidden; + margin-left: 0.5em; + position: absolute; + margin-top:0.1em; +} + +h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, h5:hover .anchor, h6:hover .anchor { + visibility:visible; +} diff --git a/static/js/hugo-learn.js b/static/js/hugo-learn.js index ece22f287f..0c61702cbe 100644 --- a/static/js/hugo-learn.js +++ b/static/js/hugo-learn.js @@ -55,4 +55,31 @@ images.each(function(index){ } }); +// Stick the top to the top of the screen when scrolling $("#top-bar").stick_in_parent(); + + +jQuery(document).ready(function() { + // Add link button for every + var text, clip = new Clipboard('.anchor'); + $("h1~h2,h1~h3,h1~h4,h1~h5,h1~h6").append(function(index, html){ + var element = $(this); + var url = document.location.origin + document.location.pathname; + var link = url + "#"+element[0].id; + console.log(link); + return " " + + "" + + "" + ; + }); + + $(".anchor").on('mouseleave', function(e) { + $(this).attr('aria-label', null).removeClass('tooltipped tooltipped-s tooltipped-w'); + }); + + clip.on('success', function(e) { + e.clearSelection(); + $(e.trigger).attr('aria-label', 'Link copied to clipboard!').addClass('tooltipped tooltipped-s'); + }); + +});