// This function primarily watches the Bootstrap Carousel and interacts
// with a side thumbnail menu. The object instantiation is due to the
// possibility that more than one carousel maybe active at a time.
// other features include
// • auto-resizing of the thumbnail menu
// • All images being a background-image to allow for auto-centering and cropping
// • Automatic text redaction based on dynamic re-sizing of the container
// this object is instatiated as window.OCU.carousels[x];
var OCUCarousel = function(index, element) {
this.childCarousel = index;
this.element = element;
this.carousel = this.element.querySelector('.carousel').Carousel;
this.carouselImages = this.element.getElementsByClassName('carousel-image');
this.carouselText = this.element.getElementsByClassName('carousel-text');
this.thumbnailTextP = this.element.querySelectorAll('.thumbnail-text > p');
this.carouselInner = this.element.querySelectorAll('.carousel-inner');
this.thumbnails = this.element.querySelectorAll('.thumbnail');
this.carouselItems = this.element.querySelectorAll('.carousel-item');
this.marker = this.element.querySelector('.thumbnail-marker');
this.ratio = .7322; // the Ratio is used to determine the height vs width of the image
this.init = function() {
console.log('There is an OCUCarousel on page. ' + this.childCarousel);
this.matchHeights();
window.addEventListener("resize", this);
this.addCLickEvents(this.thumbnails);
this.startObservation();
};
this.eventReport = function(el) {
el.name;
}
// all events pass through this case system when the event is passed the object:this
// object:this refers to the OCU.carousels[x];
this.handleEvent = function(event) {
switch (event.type) {
case "resize":
// on resize all the heights need to adjust to even out across div blocks
// .carousel.slide total height is divided by the number of thumbnails
// each div.thumbnail-image then...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.