//total number of slides
var tdi_2_nr_of_slides = 8;
jQuery(document).ready(function() {
//magnific popup
jQuery("#tdi_1_4a7 .td-slide-popup-gallery").magnificPopup({
delegate: "a.slide-gallery-image-link",
type: "image",
tLoading: "Loading image #%curr%...",
mainClass: "mfp-img-mobile",
gallery: {
enabled: true,
navigateByImgClick: true,
preload: [0,1],
tCounter: '%curr% of %total%'
},
image: {
tError: "The image #%curr% could not be loaded.",
titleSrc: function(item) {
r = item.el.attr("data-caption") +
+ '
' +
item.el.attr("data-description") +
'
';
return r;
}
},
zoom: {
enabled: true,
duration: 300,
opener: function(element) {
return element.find("img");
}
},
callbacks: {
change: function() {
// Will fire when popup is closed
jQuery("#tdi_1_4a7 .td-doubleSlider-1").iosSlider("goToSlide", this.currItem.index + 1 );
}
}
});
jQuery("#tdi_1_4a7 .td-doubleSlider-1").iosSlider({
scrollbar: true,
snapToChildren: true,
desktopClickDrag: true,
infiniteSlider: true,
responsiveSlides: true,
navPrevSelector: jQuery("#tdi_1_4a7 .doubleSliderPrevButton"),
navNextSelector: jQuery("#tdi_1_4a7 .doubleSliderNextButton"),
scrollbarHeight: "2",
scrollbarBorderRadius: "0",
scrollbarOpacity: "0.5",
onSliderResize: td_gallery_resize_update_vars_tdi_2,
onSliderLoaded: doubleSlider2Load_tdi_2,
onSlideChange: doubleSlider2Load_tdi_2,
keyboardControls: true
});
//small image slide
jQuery("#tdi_1_4a7 .td-doubleSlider-2 .td-button").each(function(i) {
jQuery(this).bind("click", function() {
jQuery("#tdi_1_4a7 .td-doubleSlider-1").iosSlider("goToSlide", i+1);
});
});
// Create slider_2 only when the content elements are wider than the wrapper
var $gallery_slider_unique_id = jQuery("#tdi_1_4a7");
if ( $gallery_slider_unique_id.length ) {
var sliderWidth = $gallery_slider_unique_id.width(),
elementsWidth = 0;
$gallery_slider_unique_id.find( ".td-button").each(function(index, el) {
elementsWidth += jQuery(el).outerWidth( true );
});
//check the number of slides
//if( parseInt(tdi_2_nr_of_slides) > $td_double_slider2_no_js_limit) {
if( elementsWidth > sliderWidth ) {
jQuery("#tdi_1_4a7 .td-doubleSlider-2").iosSlider({
desktopClickDrag: true,
snapToChildren: true,
snapSlideCenter: true,
infiniteSlider: true
});
} else {
jQuery("#tdi_1_4a7 .td-doubleSlider-2").addClass("td_center_slide2");
}
}
function doubleSlider2Load_tdi_2(args) {
//var currentSlide = args.currentSlideNumber;
jQuery("#tdi_1_4a7 .td-doubleSlider-2").iosSlider("goToSlide", args.currentSlideNumber);
//put a transparent border around all small sliders
jQuery("#tdi_1_4a7 .td-doubleSlider-2 .td-button .td-border").css("border", "3px solid #ffffff").css("opacity", "0.5");
jQuery("#tdi_1_4a7 .td-doubleSlider-2 .td-button").css("border", "0");
//put a white border around the focused small slide
jQuery("#tdi_1_4a7 .td-doubleSlider-2 .td-button:eq(" + (args.currentSlideNumber-1) + ") .td-border").css("border", "3px solid #ffffff").css("opacity", "1");
//jQuery("#tdi_1_4a7 .td-doubleSlider-2 .td-button:eq(" + (args.currentSlideNumber-1) + ")").css("border", "3px solid #ffffff");
//write the current slide number
td_gallery_write_current_slide_tdi_2(args.currentSlideNumber);
}
//writes the current slider beside to prev and next buttons
function td_gallery_write_current_slide_tdi_2(slide_nr) {
jQuery("#tdi_1_4a7 .td-gallery-slide-item-focus").html(slide_nr);
}
/*
* Resize the iosSlider when the page is resided (fixes bug on Android devices)
*/
function td_gallery_resize_update_vars_tdi_2(args) {
if(tdDetect.isAndroid || tdDetect.isIos) {
setTimeout(function(){
jQuery("#tdi_2 .td-doubleSlider-1").iosSlider("update");
}, 1500);
}
}
});