mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-23 22:13:40 +00:00
f2613d589c
Bug: T315872 Depends-On: I605a24c708e60ccffde9dce524485f61fd5c7b06 Change-Id: I48c1aaf56ccea232dca7cb52f24a29a421b94d86
29 lines
567 B
JavaScript
29 lines
567 B
JavaScript
$( function () {
|
|
|
|
var lastLine;
|
|
|
|
function onHashChange() {
|
|
var line = mw.util.getTargetFromFragment();
|
|
|
|
if ( lastLine ) {
|
|
lastLine.classList.remove( 'hll' );
|
|
}
|
|
|
|
// Support IE 11, Edge 14, Safari 7: Can't use unprefixed Element.matches('… *') yet.
|
|
if ( !line || !$( line ).closest( '.mw-highlight' ).length ) {
|
|
// Matched ID wasn't in a highlight block
|
|
lastLine = null;
|
|
return;
|
|
}
|
|
|
|
line.classList.add( 'hll' );
|
|
lastLine = line;
|
|
}
|
|
|
|
window.addEventListener( 'hashchange', onHashChange );
|
|
|
|
// Check hash on load
|
|
onHashChange();
|
|
|
|
}() );
|