mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-30 03:03:09 +00:00
theme: ensure IE11 compatiblity #89
This commit is contained in:
parent
82b7477c0c
commit
b5e90f03dd
3 changed files with 5 additions and 5 deletions
|
@ -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>
|
||||||
|
|
|
@ -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');
|
||||||
|
|
|
@ -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');
|
||||||
|
|
Loading…
Reference in a new issue