Team:LMU-Munich/iGEM.tour.js
From 2014.igem.org
(Difference between revisions)
Hoerldavid (Talk | contribs) |
Hoerldavid (Talk | contribs) |
||
Line 25: | Line 25: | ||
} | } | ||
+ | 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) { | $( '#tour-toggle, #tour-toggle-m' ).click(function(e) { | ||
console.log("click!"); | console.log("click!"); | ||
Line 31: | Line 39: | ||
if (!tourWasStarted) | if (!tourWasStarted) | ||
{ | { | ||
+ | $("#tour-toggle").html("CONTINUE TOUR"); | ||
tourWasStarted = true; | tourWasStarted = true; | ||
localStorage["igem-lmu-tourWasStartted"] = true; | localStorage["igem-lmu-tourWasStartted"] = true; |
Revision as of 01:53, 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;
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; } }
})
});