Team:LMU-Munich/iGEM.tour.js
From 2014.igem.org
(Difference between revisions)
Hoerldavid (Talk | contribs) |
Hoerldavid (Talk | contribs) |
||
Line 61: | Line 61: | ||
localStorage["igem-lmu-currentTourItem"] = currentTourItem; | localStorage["igem-lmu-currentTourItem"] = currentTourItem; | ||
- | if (currentTourItem == items.length- | + | if (currentTourItem == items.length-2){ |
localStorage["igem-lmu-tourWasStartted"] = false; | localStorage["igem-lmu-tourWasStartted"] = false; | ||
} | } |
Revision as of 02:00, 18 October 2014
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"]; }
if(localStorage["igem-lmu-tourWasStartted"]){ tourWasStarted = localStorage["igem-lmu-tourWasStartted"]; }
if (tourWasStarted) { $("#tour-toggle").html("CONTINUE TOUR");
}
$( '#tour-toggle, #tour-toggle-m' ).click(function(e) { console.log("click!"); updateTourItems();
if (!tourWasStarted) { $("#tour-toggle").html("CONTINUE TOUR"); 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;
if (currentTourItem == items.length-2){ localStorage["igem-lmu-tourWasStartted"] = false; }
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; } }
})
});