script.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. $(document).ready(function() {
  2. $(window).on("resize", hideMobileMenu);
  3. $('.flags').on("click", selectLanguage);
  4. $('#menu_icon_button').on("click", showMobileMenu);
  5. $('#menu ul li, .menu_mobile_button').on("click", goTo);
  6. $('.external_link').on("click", externalLink);
  7. $(window).on("load resize", function() {
  8. equalheight('.box');
  9. });
  10. });
  11. function externalLink(){
  12. var link = $(this).attr("data-target");
  13. window.open(link, '_blank');
  14. }
  15. function goTo() {
  16. var target = $(this).attr("data-target");
  17. var link = $(target);
  18. var margin = 100;
  19. var width = $(window).width();
  20. if (width > 749 && width < 1301){
  21. margin = 130;
  22. }
  23. $('html, body').animate({
  24. scrollTop: (link.offset().top) - margin
  25. }, 500);
  26. $('#menu_mobile').css("display", "none");
  27. }
  28. function selectLanguage(){
  29. var lng = $(this).attr('id');
  30. $.getJSON("lng/"+lng+".json", function(x){
  31. $('#menu ul li').each(function(i){
  32. $(this).text(x.menu[i]);
  33. });
  34. $('#menu_mobile button').each(function(i){
  35. $(this).text(x.menu[i]);
  36. });
  37. $('#headline').text(x.banner.headline);
  38. $('#headline_text').text(x.banner.headline_text);
  39. $('#visualization').text(x.section_visualization.visualization);
  40. $('#headlines_button_item').text(x.section_visualization.headlines_button_item);
  41. $('#about').text(x.section_about.about);
  42. $('#about_texts p').each(function(i){
  43. $(this).text(x.section_about.about_texts[i]);
  44. });
  45. $('#contribution').text(x.section_contribution.contribution);
  46. $('#contribution_boxes h4').each(function(i){
  47. $(this).text(x.section_contribution.contribution_boxes_h[i]);
  48. });
  49. $('#contribution_boxes p').each(function(i){
  50. $(this).text(x.section_contribution.contribution_boxes_p[i]);
  51. });
  52. $('#links').text(x.section_links.links);
  53. $('#links_boxes h4').each(function(i){
  54. $(this).text(x.section_links.links_boxes_h[i]);
  55. });
  56. $('#links_boxes p.to_fill').each(function(i){
  57. $(this).text(x.section_links.links_boxes_p[i]);
  58. });
  59. $('#contact').text(x.section_contact.contact);
  60. });
  61. $('.flags').css("opacity", 0.3);
  62. $('#'+lng).css("opacity",1);
  63. }
  64. function showMobileMenu() {
  65. var elm = $('#menu_mobile');
  66. if (elm.css("display") == "block") {
  67. elm.css("display", "none");
  68. } else {
  69. elm.css("display", "block");
  70. }
  71. }
  72. function hideMobileMenu() {
  73. $("#menu_mobile").css("display","none");
  74. }
  75. // set the equal height of desired elements
  76. function equalheight (container){
  77. var tallest = 0;
  78. if ($(window).width() > 748){
  79. $(container).each(function() {
  80. $(this).css("height","auto");
  81. var height = $(this).height();
  82. if (height > tallest){
  83. tallest = height;
  84. }
  85. });
  86. $(container).each(function() {
  87. $(this).css("height",tallest+"px");
  88. });
  89. }
  90. else {
  91. $(container).each(function() {
  92. $(this).css("height","auto");
  93. });
  94. }
  95. }