javascript.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. function Navigate(url){
  2. window.location=url;
  3. }
  4. function CreateCookie(name, value, days) {
  5. var expires;
  6. if (days) {
  7. var date = new Date();
  8. date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
  9. expires = "; expires=" + date.toGMTString();
  10. }
  11. else {
  12. expires = "";
  13. }
  14. document.cookie = name + "=" + value + expires + "; path=/";
  15. }
  16. $(function(){
  17. var panels=$("nav > dl > .sub-pages");
  18. var goIndicators=$("nav > dl > dt .go");
  19. var expandIndicators=$("nav > dl > dt .expand");
  20. panels.hide();
  21. expandIndicators.show();
  22. $("nav > dl > dt").click(function(e){
  23. var next=$(this).next();
  24. if (!next.hasClass("sub-pages") || next.is(":visible")){
  25. Navigate($(this).children("a").attr("href"));
  26. return;
  27. }
  28. panels.slideUp();
  29. goIndicators.hide();
  30. expandIndicators.show();
  31. next.slideDown();
  32. $(this).children(".go").show();
  33. $(this).children(".expand").hide();
  34. });
  35. $("nav > dl > dt").each(function(){
  36. if ($(this).next().hasClass("sub-pages"))
  37. $(this).attr("title", "Click once to expand, click again to go");
  38. });
  39. $("nav dd").click(function(e){
  40. Navigate($(this).children("a").attr("href"));
  41. });
  42. $("nav a").click(function(e){
  43. $(this).parent().click();
  44. return false;
  45. });
  46. $("#content").css("margin-bottom",window.innerHeight-$("#buttons").offset().top);
  47. $("#cookiePopup button").click(function(){
  48. $("#cookiePopup").fadeOut();
  49. CreateCookie("cookiePopupConfirmed",true,0);
  50. });
  51. $("#menu-button").click(function(e){
  52. $("#menu").show("slide", {direction: "left", easing:'easeOutCirc'});
  53. $("body>.backdrop").fadeIn();
  54. });
  55. $("body>.backdrop").click(function(e){
  56. $("#menu").hide("slide", {direction: "left", easing:'easeInCirc'});
  57. $("body>.backdrop").fadeOut();
  58. });
  59. });
  60. $(window).resize(function(e){
  61. if (window.innerWidth>1023){
  62. $("#menu").attr("style","");
  63. $("#menu-button").attr("style","");
  64. $("body>.backdrop").hide();
  65. }
  66. });