12345678910111213141516171819202122232425262728293031 |
- (function(document) {
- document.addEventListener("DOMContentLoaded", function(event) {
- var carouselButtons = document.getElementsByClassName("image-carousel");
- for(var i = 0, button = carouselButtons[i]; button = carouselButtons[i]; i++) {
- //button.addEventListener("click", cycleImages);
- button.addEventListener("click", cycleVideos);
- }
- });
- function cycleImages(event) {
- var parent = event.currentTarget.parentNode;
- var images = parent.getElementsByTagName('img');
- var button = parent.getElementsByTagName('button')[0];
- var firstImage = images[0];
- firstImage.style.display = "none";
- var nextImage = images[1];
- nextImage.style.display = "inline-block";
- parent.insertBefore(firstImage, button);
- }
- function cycleVideos(event) {
- var parent = event.currentTarget.parentNode;
- var videos = parent.getElementsByTagName('video');
- var button = parent.getElementsByTagName('button')[0];
- var firstVideo = videos[0];
- firstVideo.style.display = "none";
- var nextVideo = videos[1];
- nextVideo.style.display = "inline-block";
- parent.insertBefore(firstVideo, button);
- }
- })(document);
|