Team:LMU-Munich/iGEM.tour.js
From 2014.igem.org
var tourActive = false; var tourWasStarted = false; var currentTourItem = 0;
function updateTourItems() {
var items = $(".tour-item"); for (var i = 0; i< items.length; i++) { if (i == currentTourItem){ $(items[i]).show(); }else{ $(items[i]).hide(); } }
}
$( document ).ready(function() {
//$("#tour-overlay").hide();
if (localStorage["igem-lmu-currentTourItem"]){ console.log("lS read"); currentTourItem = localStorage["igem-lmu-currentTourItem"]; }
$( '#tour-toggle, #tour-toggle-m' ).click(function(e) { console.log("click!"); updateTourItems();
if (!tourWasStarted) { tourWasStarted = true; localStorage["igem-lmu-tourWasStartted"] = true; localStorage["igem-lmu-currentTourItem"] = currentTourItem; }
if (!tourActive){ $("#tour-overlay").fadeIn("slow",function() { tourActive = true; });
} });
$( ".tour-button-next").click(function(e) { var items = $(".tour-item"); console.log(currentTourItem); currentTourItem++; currentTourItem = currentTourItem < items.length ? currentTourItem : items.length -1; localStorage["igem-lmu-currentTourItem"] = currentTourItem;
updateTourItems();
});
$( ".tour-button-prev").click(function(e) { var items = $(".tour-item"); console.log(currentTourItem); currentTourItem--; currentTourItem = currentTourItem >= 0 ? currentTourItem : 0; localStorage["igem-lmu-currentTourItem"] = currentTourItem;
updateTourItems(); });
$( ".tour-button-close").click(function(e) { $('#tour-overlay').fadeOut("slow"); tourActive = false; });
$(document).click(function(event) { console.log([event.target]); if(tourActive) { if(!$(event.target).closest('#tour-box').length) {
$('#tour-overlay').fadeOut("slow"); tourActive = false; } }
})
});