theme: ensure IE11 compatiblity #89

This commit is contained in:
Sören Weber 2021-09-13 21:09:44 +02:00
parent 82b7477c0c
commit b5e90f03dd
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
3 changed files with 5 additions and 5 deletions

View file

@ -42,7 +42,7 @@
{{- $.Scratch.Set "mermaidInitialize" "{ \"startOnLoad\": true }" }} {{- $.Scratch.Set "mermaidInitialize" "{ \"startOnLoad\": true }" }}
{{- end }} {{- end }}
<script> <script>
if (mermaid) { if (typeof mermaid != 'undefined') {
mermaid.mermaidAPI.initialize( Object.assign( { "securityLevel": "antiscript" }, JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}), { startOnLoad: false } ) ); mermaid.mermaidAPI.initialize( Object.assign( { "securityLevel": "antiscript" }, JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}), { startOnLoad: false } ) );
} }
</script> </script>

View file

@ -104,7 +104,7 @@ function initMermaid() {
$(element).parent().replaceWith('<div class="mermaid" align="center">' + content + '</div>'); $(element).parent().replaceWith('<div class="mermaid" align="center">' + content + '</div>');
}); });
if (mermaid) { if (typeof mermaid != 'undefined') {
mermaid.mermaidAPI.initialize( Object.assign( {}, mermaid.mermaidAPI.getSiteConfig(), { startOnLoad: true } ) ); mermaid.mermaidAPI.initialize( Object.assign( {}, mermaid.mermaidAPI.getSiteConfig(), { startOnLoad: true } ) );
mermaid.contentLoaded(); mermaid.contentLoaded();
$(".mermaid svg").svgPanZoom({}) $(".mermaid svg").svgPanZoom({})
@ -538,7 +538,7 @@ jQuery(function() {
jQuery.extend({ jQuery.extend({
highlight: function(node, re, nodeName, className) { highlight: function(node, re, nodeName, className) {
if (node.nodeType === 3 && node.parentElement.namespaceURI == 'http://www.w3.org/1999/xhtml') { // text nodes if (node.nodeType === 3 && node.parentElement && node.parentElement.namespaceURI == 'http://www.w3.org/1999/xhtml') { // text nodes
var match = node.data.match(re); var match = node.data.match(re);
if (match) { if (match) {
var highlight = document.createElement(nodeName || 'span'); var highlight = document.createElement(nodeName || 'span');

View file

@ -45,7 +45,7 @@ function initLunr() {
function search(term) { function search(term) {
// Find the item in our index corresponding to the lunr one to have more info // Find the item in our index corresponding to the lunr one to have more info
// Remove Lunr special search characters: https://lunrjs.com/guides/searching.html // Remove Lunr special search characters: https://lunrjs.com/guides/searching.html
var searchTerm = lunr.tokenizer(term.replace(/[*:^~+-]/, ' ')).flatMap(token => searchPatterns(token.str)).join(' '); var searchTerm = lunr.tokenizer(term.replace(/[*:^~+-]/, ' ')).reduce( function(a,token){return a.concat(searchPatterns(token.str))}, []).join(' ');
return !searchTerm ? [] : lunrIndex.search(searchTerm).map(function(result) { return !searchTerm ? [] : lunrIndex.search(searchTerm).map(function(result) {
return { index: result.ref, matches: Object.keys(result.matchData.metadata) } return { index: result.ref, matches: Object.keys(result.matchData.metadata) }
}); });
@ -75,7 +75,7 @@ $(function() {
var page = pagesIndex[item.index]; var page = pagesIndex[item.index];
var numContextWords = 2; var numContextWords = 2;
var contextPattern = '(?:\\S+ +){0,' + numContextWords + '}\\S*\\b(?:' + var contextPattern = '(?:\\S+ +){0,' + numContextWords + '}\\S*\\b(?:' +
item.matches.map(match => match.replace(/\W/g, '\\$&')).join('|') + item.matches.map( function(match){return match.replace(/\W/g, '\\$&')} ).join('|') +
')\\b\\S*(?: +\\S+){0,' + numContextWords + '}'; ')\\b\\S*(?: +\\S+){0,' + numContextWords + '}';
var context = page.content.match(new RegExp(contextPattern, 'i')); var context = page.content.match(new RegExp(contextPattern, 'i'));
var divcontext = document.createElement('div'); var divcontext = document.createElement('div');