main.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var jQuery = require('jquery');
  2. var $ = jQuery;
  3. // var foundation = require('foundation-sites');
  4. let mobile = false;
  5. $(document).ready(function(){
  6. if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i)){
  7. mobile = true;
  8. }
  9. //
  10. $(".main a").attr("target","_blank");
  11. //adjust menu grid :
  12. let ni = $(".nav li").length;
  13. $(".nav").css('grid-template-columns','repeat('+ni+', 1fr)');
  14. $(".subnav").css('grid-template-columns','repeat('+ni+', 1fr)')
  15. //nav behavior
  16. if (mobile != true ) {
  17. $(".navigation").on("mouseover", function(){
  18. $(".subnav").addClass("grid");
  19. });
  20. $(".navigation").on("mouseout", function(){
  21. $(".subnav").removeClass("grid");
  22. });
  23. }
  24. //QD solution
  25. if (mobile == true ) {
  26. $('.nav').slideToggle();
  27. }
  28. $(".show_menu").click(function(){
  29. $('.nav').slideToggle();
  30. });
  31. $(window).on('load', function() {
  32. var url = window.location.href;
  33. var hash = url.split("#");
  34. let h = hash[hash.length - 1];
  35. if(h == "newsletter"){
  36. let elem = $(".header .newsletter").find("a");
  37. $(elem).click();
  38. }
  39. });
  40. });