mirror of
https://github.com/torproject/tpo.git
synced 2024-10-07 07:53:37 +00:00
Move inline js
This commit is contained in:
parent
372d415279
commit
1f88f22c35
38
assets/static/js/fallback.js
Normal file
38
assets/static/js/fallback.js
Normal 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)
|
||||
}
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user