Add waitfor function to await mermaid existing
This commit is contained in:
parent
d9b53e3316
commit
1c7785957e
2 changed files with 16 additions and 3 deletions
|
@ -1,2 +1,2 @@
|
|||
{{ $script := resources.Get . | minify | fingerprint }}
|
||||
<script type="text/javascript" async defer src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>
|
||||
<script type="text/javascript" async src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>
|
||||
|
|
|
@ -2,6 +2,16 @@
|
|||
|
||||
var Clipboard = require('clipboard');
|
||||
|
||||
function waitFor(global, callback) {
|
||||
// Wait for a property to exist on window before runnig callback
|
||||
var intervalId = setInterval(function () {
|
||||
if (window[global]) {
|
||||
clearInterval(intervalId);
|
||||
callback();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
||||
$('.image').each(function () { // setup div-image hybrids
|
||||
var ele = $(this);
|
||||
|
@ -32,9 +42,12 @@ $(document).ready(function () {
|
|||
}
|
||||
});
|
||||
|
||||
waitFor('mermaid', function () {
|
||||
mermaid.initialize({
|
||||
startOnLoad: true
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('.navbar-brand').on('click', function (event) {
|
||||
|
|
Loading…
Reference in a new issue