Team:Heidelberg/Templates/carousel-special-js
From 2013.igem.org
(Difference between revisions)
Nils.kurzawa (Talk | contribs) m |
Nils.kurzawa (Talk | contribs) m |
||
(4 intermediate revisions not shown) | |||
Line 2: | Line 2: | ||
$('#myCarousel').carousel({interval: 0}).on('slide.bs.carousel', function(e) { | $('#myCarousel').carousel({interval: 0}).on('slide.bs.carousel', function(e) { | ||
var active_month = $('.month_tab.active'); | var active_month = $('.month_tab.active'); | ||
- | var prev_month = $('.month_tab.active').prev() | + | var prev_month = $('.month_tab.active').prev(); |
- | var next_month = $('.month_tab.active').next() | + | var next_month = $('.month_tab.active').next(); |
- | if ($('.item:visible').hasClass('first') == true && $('.item:visible').hasClass('july') == false) { | + | if ($('#myCarousel .item:visible').hasClass('first') == true && $('#myCarousel .item:visible').hasClass('july') == false) { |
if (e.direction == "right") { | if (e.direction == "right") { | ||
active_month.removeClass('active'); | active_month.removeClass('active'); | ||
Line 12: | Line 12: | ||
} | } | ||
} | } | ||
- | if ($('.item:visible').hasClass('first') == true && $('.item:visible').hasClass('july') == true) { | + | if ($('#myCarousel .item:visible').hasClass('first') == true && $('#myCarousel .item:visible').hasClass('july') == true) { |
if (e.direction == "right") { | if (e.direction == "right") { | ||
active_month.removeClass('active'); | active_month.removeClass('active'); | ||
- | $($('.item:visible').hasClass('august')).addClass('active'); | + | $($('#myCarousel .item:visible').hasClass('august')).addClass('active'); |
$('#august').addClass('active'); | $('#august').addClass('active'); | ||
$('.labjournal-weekly:visible').hide(); | $('.labjournal-weekly:visible').hide(); | ||
Line 22: | Line 22: | ||
} | } | ||
} | } | ||
- | if ($('.item:visible').hasClass('last') == true && $('.item:visible').hasClass('august') == false){ | + | if ($('#myCarousel .item:visible').hasClass('last') == true && $('#myCarousel .item:visible').hasClass('august') == false){ |
if (e.direction == "left") { | if (e.direction == "left") { | ||
- | |||
next_month.addClass('active'); | next_month.addClass('active'); | ||
+ | active_month.removeClass('active'); | ||
} | } | ||
} | } | ||
- | if ($('.item:visible').hasClass('last') == true && $('.item:visible').hasClass('august') == true){ | + | if ($('#myCarousel .item:visible').hasClass('last') == true && $('#myCarousel .item:visible').hasClass('august') == true){ |
if (e.direction == "left") { | if (e.direction == "left") { | ||
active_month.removeClass('active'); | active_month.removeClass('active'); | ||
- | $($('.item:visible').hasClass('july')).addClass('active'); | + | $($('#myCarousel .item:visible').hasClass('july')).addClass('active'); |
$('#july').addClass('active'); | $('#july').addClass('active'); | ||
$('.labjournal-weekly:visible').hide(); | $('.labjournal-weekly:visible').hide(); |
Latest revision as of 08:52, 18 October 2013
//stop carousel running automatically
$('#myCarousel').carousel({interval: 0}).on('slide.bs.carousel', function(e) { var active_month = $('.month_tab.active'); var prev_month = $('.month_tab.active').prev(); var next_month = $('.month_tab.active').next();
if ($('#myCarousel .item:visible').hasClass('first') == true && $('#myCarousel .item:visible').hasClass('july') == false) { if (e.direction == "right") { active_month.removeClass('active'); prev_month.addClass('active');
} } if ($('#myCarousel .item:visible').hasClass('first') == true && $('#myCarousel .item:visible').hasClass('july') == true) { if (e.direction == "right") { active_month.removeClass('active'); $($('#myCarousel .item:visible').hasClass('august')).addClass('active'); $('#august').addClass('active'); $('.labjournal-weekly:visible').hide(); $($('.labjournal-weekly')[9]).show();
} } if ($('#myCarousel .item:visible').hasClass('last') == true && $('#myCarousel .item:visible').hasClass('august') == false){ if (e.direction == "left") { next_month.addClass('active'); active_month.removeClass('active'); }
} if ($('#myCarousel .item:visible').hasClass('last') == true && $('#myCarousel .item:visible').hasClass('august') == true){ if (e.direction == "left") { active_month.removeClass('active'); $($('#myCarousel .item:visible').hasClass('july')).addClass('active'); $('#july').addClass('active'); $('.labjournal-weekly:visible').hide(); $($('.labjournal-weekly')[0]).show(); }
}
var current = $('.labjournal-weekly:visible'); current.hide(); if (e.direction == "left") { current.next().show(); } else { current.prev().show(); } }); $($('.labjournal-weekly').hide()[0]).show();