From f5a996a64ee38230f786c30f562483f2e2368691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sun, 9 Feb 2020 16:07:14 +0100 Subject: [PATCH] Highlight current anchor with css instead of js. The `:target` selector is supported by all browsers. --- .../jsdoc/api/template/static/scripts/main.js | 18 ------------------ .../api/template/static/styles/jaguar.css | 3 ++- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/config/jsdoc/api/template/static/scripts/main.js b/config/jsdoc/api/template/static/scripts/main.js index 97dfd0facf..6e609f9d01 100644 --- a/config/jsdoc/api/template/static/scripts/main.js +++ b/config/jsdoc/api/template/static/scripts/main.js @@ -137,22 +137,4 @@ $(function () { '' + textParts[1] + ''; }); - - // Highlighting current anchor - - var anchors = $('.anchor'); - var _onHashChange = function () { - var activeHash = window.document.location.hash - .replace(/\./g, '\\.') // Escape dot in element id - .replace(/\~/g, '\\~'); // Escape tilde in element id - - anchors.removeClass('highlighted'); - - if (activeHash.length > 0) { - anchors.filter(activeHash).addClass('highlighted'); - } - }; - - $(window).on('hashchange', _onHashChange); - _onHashChange(); }); diff --git a/config/jsdoc/api/template/static/styles/jaguar.css b/config/jsdoc/api/template/static/styles/jaguar.css index 1a677bfa93..88433f363f 100644 --- a/config/jsdoc/api/template/static/styles/jaguar.css +++ b/config/jsdoc/api/template/static/styles/jaguar.css @@ -51,7 +51,8 @@ body { width: 0px; height: 0px; } -.nameContainer .anchor.highlighted + h4 { +/* Highlighting current anchor */ +.nameContainer .anchor:target + h4 { background-color: #faebcc; } a {