Skip to content

Commit

Permalink
Fix carousel javascript error
Browse files Browse the repository at this point in the history
  • Loading branch information
npentrel committed Sep 8, 2023
1 parent 37cfca4 commit f942238
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions static/js/carousel.js → assets/js/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ document.addEventListener('DOMContentLoaded', function() {
});
const scrolllength = carousel.querySelector('ul li:nth-child(2)').offsetLeft - carousel.querySelector('ul li:nth-child(1)').offsetLeft;
const nthchild = (Math.round((ele.scrollLeft/scrolllength)+1));
carousel.querySelector('ol li:nth-child('+nthchild+')').classList.add('selected');
carousel.querySelector('ul li:nth-child('+nthchild+')').classList.add('selected');
let ol_elem = carousel.querySelector('ol li:nth-child('+nthchild+')');
let ul_elem = carousel.querySelector('ul li:nth-child('+nthchild+')');
if (ol_elem) { ol_elem.classList.add('selected'); }
if (ul_elem) { ul_elem.classList.add('selected'); }
if(carousel.parentElement.parentElement.querySelector('.dynamictitle')) {
const title = carousel.querySelector('ul li:nth-child('+nthchild+') img').getAttribute('title');
if(title) carousel.parentElement.parentElement.querySelector('.dynamictitle').innerHTML = title;
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,6 @@ sitemap:
</div>
</div>

<script type="text/javascript" src="js/carousel-min.js"></script>
{{ $jsCarousel := resources.Get "js/carousel.js" }}
{{ $jsCarousel := $jsCarousel | minify }}
<script type="text/javascript" src="{{ $jsCarousel.RelPermalink }}" crossorigin="anonymous"></script>
5 changes: 4 additions & 1 deletion layouts/docs/tutorials.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ <h4 class="alert-heading">Javascript</h4>
<script src="https://cdn.jsdelivr.net/npm/typesense-instantsearch-adapter@2/dist/typesense-instantsearch-adapter.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="../js/tutorials.js"></script>

{{ $jsTutorials := resources.Get "js/tutorials.js" }}
{{ $jsTutorials := $jsTutorials | minify }}
<script type="text/javascript" src="{{ $jsTutorials.RelPermalink }}" crossorigin="anonymous"></script>

</body>
</html>
1 change: 0 additions & 1 deletion static/js/carousel-min.js

This file was deleted.

0 comments on commit f942238

Please sign in to comment.