1
Fork 0

Add waitfor function to await mermaid existing

This commit is contained in:
Jake Howard 2018-12-01 17:42:13 +00:00
parent d9b53e3316
commit 1c7785957e
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 16 additions and 3 deletions

View file

@ -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>

View file

@ -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) {