116 lines
5.3 KiB
Plaintext
116 lines
5.3 KiB
Plaintext
|
<%
|
||
|
data = action_data
|
||
|
%>
|
||
|
<style type="text/css">
|
||
|
.carousel_images_slide {
|
||
|
padding: 0 2.5em;
|
||
|
}
|
||
|
</style>
|
||
|
<%= render_view %>
|
||
|
|
||
|
<script>
|
||
|
(function($) {
|
||
|
function calculate_video_carousel(skip_images_slide)
|
||
|
{
|
||
|
var cycle_slideshow = $(".carousel_images .cycle-slideshow");
|
||
|
var video_carousel_slide = $(".video_program_carousel_slide");
|
||
|
var carousel_images_slide = $('.carousel_images_slide');
|
||
|
if (!skip_images_slide) {
|
||
|
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(window.active_slide);
|
||
|
if(carousel_images_slide_first_child.length > 0){
|
||
|
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
|
||
|
content_size = Math.max(content_size,1);
|
||
|
carousel_images_slide.find(">li").css("display","none");
|
||
|
var active_count = carousel_images_slide.find(">li").length - window.active_slide;
|
||
|
if(active_count < content_size){
|
||
|
window.active_slide -= (content_size - active_count);
|
||
|
}
|
||
|
window.active_slide = Math.max(window.active_slide,0);
|
||
|
for(var i = window.active_slide; i < window.active_slide + content_size;i++){
|
||
|
carousel_images_slide.find(">li").eq(i).css("display","block");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
cycle_slideshow.cycle('pause');
|
||
|
var carousel_image_block_width = $('.carousel_images').width();
|
||
|
video_carousel_slide.css('height', '');
|
||
|
var heights = video_carousel_slide.map(function(i,v){
|
||
|
return $(v).height() * carousel_image_block_width / $(v).width();
|
||
|
})
|
||
|
var max_height = Math.max.apply(null,heights);
|
||
|
video_carousel_slide.each(function(i,v){
|
||
|
$(v).height(max_height);
|
||
|
})
|
||
|
cycle_slideshow.cycle('resume');
|
||
|
}
|
||
|
|
||
|
$("img[src='']").remove();
|
||
|
$('.pause-slide').click(function(){
|
||
|
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('pause');
|
||
|
$(this).addClass('active');
|
||
|
$(this).parents('.carousel_images').find('.resume-slide').removeClass('active');
|
||
|
});
|
||
|
$('.resume-slide').click(function(){
|
||
|
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('resume');
|
||
|
$(this).addClass('active');
|
||
|
$(this).parents('.carousel_images').find('.pause-slide').removeClass('active');
|
||
|
});
|
||
|
$('.next-button').off('click').on('click',function(){
|
||
|
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("next");
|
||
|
})
|
||
|
$('.prev-button').off('click').on('click',function(){
|
||
|
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("prev");
|
||
|
})
|
||
|
window.active_slide = 0;
|
||
|
$('.prev_img').off('click').on('click',function(){
|
||
|
var carousel_images_slide = $('.carousel_images_slide');
|
||
|
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(window.active_slide);
|
||
|
if(carousel_images_slide_first_child.length > 0){
|
||
|
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
|
||
|
content_size = Math.max(content_size,1);
|
||
|
if(carousel_images_slide.find(">li").length > content_size && window.active_slide > 0){
|
||
|
window.active_slide -= content_size;
|
||
|
window.active_slide = Math.max(window.active_slide, 0);
|
||
|
carousel_images_slide.find(">li").css("display","none");
|
||
|
for(var i = window.active_slide; i < window.active_slide + content_size;i++){
|
||
|
carousel_images_slide.find(">li").eq(i).css("display","block");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
$('.next_img').off('click').on('click',function(){
|
||
|
var carousel_images_slide = $('.carousel_images_slide');
|
||
|
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(window.active_slide);
|
||
|
if(carousel_images_slide_first_child.length > 0){
|
||
|
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
|
||
|
content_size = Math.max(content_size,1);
|
||
|
var li_length = carousel_images_slide.find(">li").length;
|
||
|
if(li_length > content_size && (window.active_slide + content_size) < li_length){
|
||
|
window.active_slide += content_size;
|
||
|
window.active_slide = Math.min(window.active_slide,li_length - 1);
|
||
|
carousel_images_slide.find(">li").css("display","none");
|
||
|
for(var i = window.active_slide; i < window.active_slide + content_size;i++){
|
||
|
carousel_images_slide.find(">li").eq(i).css("display","block");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
})
|
||
|
$(".carousel_img_item img").off("click").on("click",function(){
|
||
|
$(".carousel_images .cycle-slideshow").cycle($(this).index(".carousel_img_item img"));
|
||
|
})
|
||
|
$(document).ready(function(){
|
||
|
calculate_video_carousel();
|
||
|
$('.carousel_images .resume-slide').addClass('active');
|
||
|
$('.cycle-slideshow').on('cycle-after',function(ev, opts, old_el, new_el){
|
||
|
$(".active_slide").text($(new_el).index());
|
||
|
})
|
||
|
})
|
||
|
$(window).on("load",function(){
|
||
|
calculate_video_carousel();
|
||
|
})
|
||
|
$(window).resize(function(){
|
||
|
calculate_video_carousel();
|
||
|
})
|
||
|
}(jQuery));
|
||
|
</script>
|