Move inline js

This commit is contained in:
hiro 2019-04-04 18:03:49 +02:00
parent 372d415279
commit 1f88f22c35
2 changed files with 39 additions and 41 deletions

View File

@ -0,0 +1,38 @@
if (Modernizr.addTest('svgasimg', document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1'))) {
a = $('[class*="-png"]');
a.each(function(i, obj) {
var iterator = obj.classList.entries();
for(var value of iterator) {
if(/-png/.test(value)) {
cl = value[1];
$(obj).removeClass(cl);
ej = cl.replace(/-png/,"");
$(obj).addClass(ej)
console.log(obj);
}
}
});
}
$('.side-nav').click(function(){
if ($('.side-nav.active').length > 0) {
$('.side-nav.active').removeClass('active')
}
$(this).addClass('active');
});
if($('.show').length !== 1 ) {
$('.show').collapse();
}
// Coming from search result page click
if(window.location.hash !== "") {
// Somehow collapse is not working sync and calling show directly after
// yields no effect and there is no callback when it is ready
setTimeout(() => {
// Folds out the answer manually
$(window.location.hash).collapse('show')
// Avoids the answer being hidden by the floating header
window.scrollTo(0, $(window.location.hash).position().top)
}, 500)
}

View File

@ -88,46 +88,6 @@
<script src="{{ '/static/js/bootstrap.bundle.min.js'|asseturl }}" ></script>
<script src="{{ '/static/js/scrollspy.min.js'|asseturl }}" ></script>
<script src="{{ '/static/js/modernizr.js'|asseturl }}" ></script>
<script type="text/javascript">
if (Modernizr.addTest('svgasimg', document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1'))) {
a = $('[class*="-png"]');
a.each(function(i, obj) {
var iterator = obj.classList.entries();
for(var value of iterator) {
if(/-png/.test(value)) {
cl = value[1];
$(obj).removeClass(cl);
ej = cl.replace(/-png/,"");
$(obj).addClass(ej)
console.log(obj);
}
}
});
}
$('.side-nav').click(function(){
if ($('.side-nav.active').length > 0) {
$('.side-nav.active').removeClass('active')
}
$(this).addClass('active');
});
if($('.show').length !== 1 ) {
$('.show').collapse();
}
// Coming from search result page click
if(window.location.hash !== "") {
// Somehow collapse is not working sync and calling show directly after
// yields no effect and there is no callback when it is ready
setTimeout(() => {
// Folds out the answer manually
$(window.location.hash).collapse('show')
// Avoids the answer being hidden by the floating header
window.scrollTo(0, $(window.location.hash).position().top)
}, 500)
}
</script>
<script src="{{ '/static/js/fallback.js'|asseturl }}" ></script>
{% include 'script-download.html' %}
</div>