script.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. function notes() {
  2. var $link = $('#presentation a');
  3. $link.each(function(){
  4. $(this).click(function(e) {
  5. $this = $(this);
  6. if ( $this.is('#ressource') || $this.is('#publication') ) {
  7. e.preventDefault();
  8. var $url = $this.attr("href");
  9. if ($( ".side_notes" )[0]) {
  10. $( ".side_notes" ).remove();
  11. }
  12. content_type($url, $this);
  13. ajax($url, $this);
  14. }
  15. });
  16. })
  17. function content_type($url, $this) {
  18. if ($this.is('#ressource')) {
  19. $("<div class='side_notes'><a href="+$url+"></a> </div>").insertAfter("article");
  20. }else if ( $this.is('#publication') ) {
  21. console.log('clcik');
  22. $("<div class='side_notes'></>").insertAfter("article");
  23. }
  24. }
  25. function ajax($url , $this) {
  26. $.ajax({
  27. url: $url,
  28. method: "GET",
  29. dataType:'html',
  30. async: true,
  31. success: function(data) {
  32. if ($this.is('#ressource')) {
  33. $(data).find('article > div:not(.__wrap_side) .__wrapper').appendTo('.side_notes a');
  34. }else if ($this.is('#publication')) {
  35. $(data).find('article > div:not(.__wrap_side) .__wrapper').appendTo('.side_notes');
  36. }
  37. position_link($this);
  38. },
  39. })
  40. }
  41. function position_link($this) {
  42. var $top_link = $this.position().top;
  43. console.log($top_link);
  44. $('.side_notes > *').css("top", $top_link);
  45. }
  46. }
  47. function slide() {
  48. var $slide = $('main .__slide');
  49. $slide.each(function() {
  50. $(this).flickity({
  51. cellAlign: 'left',
  52. pageDots: false,
  53. contain: true
  54. })
  55. });
  56. var $footer_slide = $('footer .__slide');
  57. $footer_slide.each(function() {
  58. $(this).flickity({
  59. cellAlign: 'left',
  60. pageDots: false,
  61. autoPlay: true,
  62. pauseAutoPlayOnHover: false,
  63. contain: true,
  64. prevNextButtons: false,
  65. })
  66. });
  67. }
  68. function burger() {
  69. var hamburgers = document.querySelector(".hamburger");
  70. var nav = document.querySelector(".nav-main");
  71. hamburgers.addEventListener("click", function() {
  72. this.classList.toggle("is-active");
  73. nav.classList.toggle("is-active");
  74. $('html, body').toggleClass("is-active");
  75. $('#block-popsu-colloque-branding').toggleClass("is-active");
  76. });
  77. }
  78. $( document ).ready(function() {
  79. notes();
  80. slide();
  81. burger();
  82. });