Highlight current anchor with css instead of js.
The `:target` selector is supported by all browsers.
This commit is contained in:
@@ -137,22 +137,4 @@ $(function () {
|
|||||||
'<a href="' + link + textParts[1].replace('line ', '#L') + '">' +
|
'<a href="' + link + textParts[1].replace('line ', '#L') + '">' +
|
||||||
textParts[1] + '</a>';
|
textParts[1] + '</a>';
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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();
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ body {
|
|||||||
width: 0px;
|
width: 0px;
|
||||||
height: 0px;
|
height: 0px;
|
||||||
}
|
}
|
||||||
.nameContainer .anchor.highlighted + h4 {
|
/* Highlighting current anchor */
|
||||||
|
.nameContainer .anchor:target + h4 {
|
||||||
background-color: #faebcc;
|
background-color: #faebcc;
|
||||||
}
|
}
|
||||||
a {
|
a {
|
||||||
|
|||||||
Reference in New Issue
Block a user