script.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 = $('.__slide');
  49. $slide.each(function() {
  50. $(this).flickity({
  51. cellAlign: 'left',
  52. })
  53. });
  54. }
  55. $( document ).ready(function() {
  56. notes();
  57. slide();
  58. });