From 1e42ae0d34ba296f8b2006d1132a3ce2798102e5 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 24 May 2017 00:02:49 -0400 Subject: [PATCH] header permalinks --- _layouts/article.html | 2 +- _layouts/default.html | 15 +++++++++++++++ _sass/_help.scss | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/_layouts/article.html b/_layouts/article.html index 9f9306a0..3d0f547f 100644 --- a/_layouts/article.html +++ b/_layouts/article.html @@ -63,7 +63,7 @@ layout: default // Append Rating-Widget JavaScript library. var rw, s = d.getElementsByTagName(e)[0], id = "rw-js", l = d.location, ck = "Y" + t.getFullYear() + - "M" + t.getMonth() + "D" + t.getDate(), p = l.protocol, + "M" + t.getMonth() + "D" + t.getDate(), p = l.protocol, f = ((l.search.indexOf("DBG=") > -1) ? "" : ".min"), a = ("https:" == p ? "secure." + m + "js/" : "js." + m); if (d.getElementById(id)) return; diff --git a/_layouts/default.html b/_layouts/default.html index 77cd32a3..13519045 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -173,6 +173,21 @@ $('a[rel="lightbox"]').trigger('close.fluidbox'); } }); + + $('.article .panel-body > h2, .article .panel-body > h3').filter('[id]').each(function () { + var header = $(this), + headerID = header.attr('id'), + anchorClass = 'header-link', + anchorIcon = ''; + + if (headerID) { + header.append($('') + .addClass(anchorClass) + .attr({ 'href': '#' + headerID, 'aria-hidden': 'true', title: 'Permalink' }) + .html(anchorIcon)); + } + return this; + }); }); diff --git a/_sass/_help.scss b/_sass/_help.scss index 3fecac37..d6f5ee70 100644 --- a/_sass/_help.scss +++ b/_sass/_help.scss @@ -323,6 +323,31 @@ footer { @extend .table-bordered; @extend .table-striped; } + + .header-link { + color: $text-muted; + text-decoration: none !important; + opacity: 0; + margin-left: 5px; + + @media (max-width: 767px) { + display: none !important; + } + } + + h2:hover > .header-link, + h3:hover > .header-link { + opacity: .5; + -webkit-transition: color .16s linear; + transition: color .16s linear; + } + + h2:hover > .header-link:hover, + h3:hover > .header-link:hover, + h2:hover > .header-link:focus, + h3:hover > .header-link:focus { + opacity: 1; + } } a[rel='lightbox'] {