// initialisation if (typeof home === "undefined"){$(".menuBar").addClass("fixed");} $(window).on("load resize", function(){ if ($(".menuItem.current").length > 0){thisItem = $(".menuItem.current");} else {thisItem = 0;} underlineMenuItem(thisItem, 0); if ($(document).height() <= $(window).height()){$(".ED").addClass("toBottom");} else {$(".ED").removeClass("toBottom");} }); if (mobile){ $("body").prepend('
'); $(".mobile").click(function(){$(this).toggleClass("open"); $(".menuBar").slideToggle(250);}); } else { if ($(document).height() > $(window).height()){$("body").append('
');} } // user-interaction if (!mobile){ $(".menuItem").hover(function(){ underlineMenuItem($(this)); }, function(){ if ($(".menuItem.current").length > 0){prevItem = $(".menuItem.current");} else {prevItem = 0;} underlineMenuItem(prevItem); }).click(function(e){ if ($(this).hasClass("current")){e.preventDefault();} }); $(document).scroll(function(){ if ($(window).scrollTop() > $(window).height() / 4){ $(".moreToSee").removeClass("down").addClass("up"); } else { $(".moreToSee").removeClass("up").addClass("down"); } }); $(".moreToSee").click(function(){ if ($(this).hasClass("up")){ $("body, html").animate({"scrollTop":0}, 1000, "easeOutCirc"); } else { $("body, html").animate({"scrollTop":$(window).height()}, 1000, "easeOutCirc"); } }); } $(".button.keepPosted").click(function(){ ask("Als u hieronder uw gegevens in zou willen vullen, dan sturen wij u een bericht zodra dit boek beschikbaar is!", "versturen,annuleren", "keepPosted"); }); // functions function underlineMenuItem(thisItem, speed = 500){ if (thisItem == 0){ $(".activeMenuItem").stop().animate({"left":0, "width":0}, speed, "easeOutQuint"); } else { $(".activeMenuItem").stop().animate({"left":$(thisItem).position().left, "width":$(thisItem).outerWidth()}, speed, "easeOutQuint"); } } function ask(question, answers, option1){ answers = answers.split(","); if (option1 == "keepPosted"){ answerButtons = '

'; $.each(answers, function(){ answerButtons += '
' + this + '
'; }); } else { artNr = option1; answerButtons = ""; $.each(answers, function(){ answerButtons += '
' + this + '
'; }); } $("body").append(' \
\
\
' + question + '
\ ' + answerButtons + ' \
\
'); $(".overlay").fadeIn(250, function(){$(this).find("input:first").focus();}); $(".ask.button").click(function(){ if ($(this).text() == "ja"){ artNr = $(this).data("artnr"); updateCart(artNr, "delete", true); } if ($(this).text() == "versturen"){ error = false; $(".overlay input").each(function(){ if ($(this).val() == ""){blink($(this)); if(error){return false;}} // nothing filled in if ($(this).val().split("@").length - 1 > 1){blink($(this)); if(error){return false;}} // multiple e-mail addresses filled in (e-mail injection? spam?) if ($(this).attr("type") == "email"){ atPos = $(this).val().indexOf("@"); dotPos = $(this).val().lastIndexOf("."); if (atPos < 1 || dotPos < atPos + 2 || dotPos + 2 >= $(this).val().length){blink($(this)); if(error){return false;}} // wrong notation for e-mail } }); if (!error){ $.post("inc/PHP/mailHandler.php", { "subject": "interesse in nieuw boek", "message": "Deze persoon wil graag een bericht krijgen zodra dit boek beschikbaar is:

naam: " + $(".overlay input[type=text]").val() + "
e-mail: " + $(".overlay input[type=email]").val() + "
boek: " + $(".bookDetails .title").text() }, function(){$(".button.keepPosted").text("Wij berichten u zodra dit boek er is!");}, "JSON"); } else {return;} function blink(elementToBlink){ orgColor = $(elementToBlink).css("backgroundColor"); $(elementToBlink).focus().css({"background-color": "#FF0000"}).stop().animate({"background-color": orgColor}, 750); error = true; } } $(".overlay").fadeOut(250, function(){$(this).remove();}); }); }