Team:LMU-Munich/iGEM.tour.js
From 2014.igem.org
(Difference between revisions)
(Created page with " var tourActive = false; var tourWasStarted = false; var currentTourItem = 0; function updateTourItems() { var items = $(".tour-item"); for (i = 0; i< items.length; i++) ...") |
Hoerldavid (Talk | contribs) |
||
Line 1: | Line 1: | ||
- | |||
var tourActive = false; | var tourActive = false; | ||
var tourWasStarted = false; | var tourWasStarted = false; | ||
Line 7: | Line 6: | ||
{ | { | ||
var items = $(".tour-item"); | var items = $(".tour-item"); | ||
- | for (i = 0; i< items.length; i++) | + | for (var i = 0; i< items.length; i++) |
{ | { | ||
if (i == currentTourItem){ | if (i == currentTourItem){ | ||
Line 26: | Line 25: | ||
} | } | ||
- | $( | + | $( '#tour-toggle, #tour-toggle-m' ).click(function(e) { |
console.log("click!"); | console.log("click!"); | ||
updateTourItems(); | updateTourItems(); | ||
Line 44: | Line 43: | ||
} | } | ||
}); | }); | ||
+ | |||
$( ".tour-button-next").click(function(e) { | $( ".tour-button-next").click(function(e) { | ||
Line 73: | Line 73: | ||
$(document).click(function(event) { | $(document).click(function(event) { | ||
+ | console.log([event.target]); | ||
if(tourActive) { | if(tourActive) { | ||
if(!$(event.target).closest('#tour-box').length) { | if(!$(event.target).closest('#tour-box').length) { |
Revision as of 20:51, 17 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"]; }
$( '#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; } }
})
});