From a9d2e73c1a249bc3e62886ff85f5c32decc43573 Mon Sep 17 00:00:00 2001 From: Saivann Date: Fri, 28 Nov 2014 20:38:27 -0500 Subject: [PATCH] Allow links in anchor affordance titles --- Makefile | 8 -------- _less/screen.less | 4 ++-- js/main.js | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 8b7fe4af..a53a898e 100644 --- a/Makefile +++ b/Makefile @@ -128,11 +128,3 @@ check-for-duplicate-header-ids: ## report a false positive if we legitimately have an id ending in '-1', ## but that should be easy to work around if it ever happens. $S grep ']\+id="[^"]\+-1"' _site/en/developer-* | eval $(ERROR_ON_OUTPUT) - -check-for-headers-with-hrefs: -## Subheadings with Kramdown-generated id tags break anchor link -## affordance if their text includes any links (hrefs), so error if any -## links are detectd between and header tags. If we -## ever do need a header with a link, we can revise the pattern below to -## only match Kramdown-generated id tags - $S grep '<\(h[2-6]\).*\?>[^>]\+href=.*' _site/en/developer-* | eval $(ERROR_ON_OUTPUT) diff --git a/_less/screen.less b/_less/screen.less index 76b68260..6f015877 100644 --- a/_less/screen.less +++ b/_less/screen.less @@ -833,7 +833,7 @@ table td,table th{ .anchorAf{ position:relative; } -.anchorAf a{ +.anchorAf a:first-child{ display:none; position:absolute; width:24px; @@ -842,7 +842,7 @@ table td,table th{ top:0; background:url(/img/icons/mini_ico_anchor.svg) no-repeat center center; } -.anchorAf:hover a{ +.anchorAf:hover a:first-child{ display:block; } diff --git a/js/main.js b/js/main.js index 84c33f78..66ad9d96 100644 --- a/js/main.js +++ b/js/main.js @@ -408,7 +408,7 @@ for (var i = 0, n = tags.length; i < n; i++) { } for (var i = 0, n = nodes.length; i < n; i++) { if (!nodes[i].id) continue; - if (nodes[i].getElementsByTagName('A').length > 0) return; + if (nodes[i].getElementsByTagName('A').length > 0 && nodes[i].getElementsByTagName('A')[0].innerHTML == '') return; addClass(nodes[i], 'anchorAf'); var anc = document.createElement('A'); anc.href = '#' + nodes[i].id;