Skip to content

Commit

Permalink
Merge pull request magento#350 from magento/jc_2542_add-permalinks
Browse files Browse the repository at this point in the history
Add permalinks to headers
  • Loading branch information
jcalcaben authored Sep 30, 2016
2 parents 57993c0 + d7c4961 commit a6056fc
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 2 deletions.
3 changes: 3 additions & 0 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">

<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
var baseUrl = "{{site.baseurl}}";
</script>

</head>
<body>
Expand Down
34 changes: 34 additions & 0 deletions common/js/devdocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,40 @@ $(document).ready(function(){
$("#searchbox").submit();
});

// Prepend link anchor to content headers
$(".content-wrap :header").each(function(){
var link = $("<a>",{
href: "#"+$(this).attr("id"),
class: "anchor"
});
var img = $("<img>",{
src: baseUrl+"i/icons/ico-link-grey.png",
width: 25
});

link.prepend(img);
$(this).prepend(link);

$(this).hover(function(){
img.show();
},
function(){
img.hide();
});
});

// Fix anchor jumps hiding headers
$(window).on("hashchange",function(){
$(document).scrollTop($(document).scrollTop()-86);
});

});

$(window).load(function(){
// Fix headers hiding behind nav when loading on anchor link
if(window.location.hash) {
$(document).scrollTop($(document).scrollTop()-43);
}
});

//Allows for sticky menu
Expand Down
4 changes: 2 additions & 2 deletions css/app.css

Large diffs are not rendered by default.

Binary file added i/icons/ico-link-grey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions scss/_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,5 @@ body.offcanvas-active {
width: 100%;
text-align: right;
}


21 changes: 21 additions & 0 deletions scss/partials/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,24 @@ html,body {
float: left;
}
}

.content-wrap {
h1,h2,h3,h4,h5{
line-height: 1.25em;
}
.anchor {
line-height: 1;
float: left;
margin-left: -35px;
clear: both;
font-size:inherit;
padding-right: 10px;

img {
display: inline-block;
vertical-align: middle;
display: none;
}
}

}

0 comments on commit a6056fc

Please sign in to comment.