script.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. (function($){
  2. //addclass
  3. function addclass() {
  4. $('.content > div:first-child').addClass('net');
  5. $('img:nth-child(2)').parent('p').addClass('slider');
  6. $(".slider img").wrap("<div></>")
  7. };
  8. //functionsscroll
  9. function scrollbar() {
  10. var $colum = $(".column:not('#recherche-artistique'), #recherche-artistique > div");
  11. $(window).on("load",function(){
  12. $colum.mCustomScrollbar({
  13. theme:"minimal",
  14. mouseWheelPixels: 200,
  15. scrollInertia: 1000,
  16. });
  17. });
  18. };
  19. function scrollW() {
  20. $('a[href^="#"]').on('click', function(evt){
  21. evt.preventDefault();
  22. var target = $(this).attr('href');
  23. var rclass = $('.net');
  24. $('.underline').removeClass('underline');
  25. $(this).parent().addClass('underline');
  26. $('.block').removeClass('block');
  27. $('.sous-menu .underline').parent().addClass('block');
  28. $(rclass).removeClass('net');
  29. $(target).addClass('net');
  30. $(' html, body')
  31. .stop()
  32. .animate({
  33. scrollLeft: $(target).offset().left - ( $('section > div').width() - $('section > div').outerWidth() + $('header').outerWidth() ) },1000, );
  34. });
  35. };
  36. //mediaquieries
  37. function scrollTop(){
  38. $('a[href^="#"]').on('click', function(evt){
  39. evt.preventDefault();
  40. var target = $(this).attr('href');
  41. var rclass = $('.net');
  42. $('.underline').removeClass('underline');
  43. $(this).parent().addClass('underline');
  44. $('.block').removeClass('block');
  45. $('.sous-menu .underline').parent().addClass('block');
  46. $(rclass).removeClass('net');
  47. $(target).addClass('net');
  48. $('html,body').animate({
  49. scrollTop: $(target).offset().top - $('header').outerHeight()},'slow');
  50. });
  51. }
  52. function clickd() {
  53. var $rclass = $('.net');
  54. $('.content > div:not(#recherche-artistique), #recherche-artistique > div ').on('click', function(e) {
  55. $rclass.removeClass('net');
  56. $(this).addClass('net');
  57. $(' html, body').stop().animate({
  58. scrollLeft: $(this).offset().left - ( $('section > div').width() - $('section > div').outerWidth() + $('header').outerWidth() ) },1000);
  59. });
  60. };
  61. function gallery() {
  62. $('.slider').bxSlider({
  63. mode: 'horizontal',
  64. captions: true,
  65. adaptiveHeight:true,
  66. slideWidth: 600,
  67. touchEnabled: true,
  68. responsive:true,
  69. preloadImages: 'visible',
  70. touchEnabled: false,
  71. pager: false,
  72. });
  73. };
  74. function Openfp() {
  75. var $divgal = $( "<div id='gallery'></div>");
  76. var $button = $( "<button class=button></button>");
  77. var $img = $("section img")
  78. $img.each(function(index) {
  79. $(this).on("click", function() {
  80. $('body').prepend( $divgal );
  81. $(this).clone().appendTo('#gallery');
  82. $('#gallery').fadeIn(400).prepend( $button );
  83. $('#gallery > img').wrap('<div class=content-img style=opacity:1></div>');
  84. $( '#gallery' ).click(function(e) {
  85. $(' #gallery, #gallery > .content-img').fadeOut(400, function() {
  86. $(this).remove();
  87. });
  88. });
  89. });
  90. });
  91. };
  92. function liclick() {
  93. var $ulf = $('section #recherche-artistique #commentaire-philosophe ul > li > p')
  94. var $olf = $('section #recherche-artistique #commentaire-philosophe ul > li > ol > li')
  95. var $mark = $('section #recherche-artistique #commentaire-philosophe ul > li > ol')
  96. $ulf.nextAll('ol').hide();
  97. $('#commentaire-philosophe ul > li:nth-child(1) ol').show();
  98. $mark.parent().children('p').css("text-decoration","underline");
  99. $ulf.on("click", function(event) {
  100. $(this).nextAll('ol').toggle(function() {
  101. $(this).css({
  102. "max-height" : "0",
  103. "opacity" : "0",
  104. "margin-left" : "0",
  105. });
  106. }, function() {
  107. $(this).css({
  108. "max-height" : "auto",
  109. "opacity" : "1",
  110. "margin-left" : "30px",
  111. });
  112. });
  113. });
  114. };
  115. function openmenu_ui() {
  116. $('.menu-ui').on("click", function(event) {
  117. $('.navigation').slideToggle('slow');
  118. });
  119. //bug here
  120. $('section').on("click", function(event) {
  121. $('.navigation').slideUp('slow');
  122. });
  123. };
  124. function redimensionnement() {
  125. var result = document.getElementById('result');
  126. if("matchMedia" in window) { // Détection
  127. if(window.matchMedia("(min-width: 955px)").matches) {
  128. scrollbar();
  129. scrollW();
  130. clickd();
  131. } else {
  132. openmenu_ui();
  133. scrollTop();
  134. }
  135. }
  136. }
  137. $(document).ready(function(){
  138. addclass();
  139. gallery();
  140. Openfp();
  141. liclick();
  142. redimensionnement();
  143. window.addEventListener('resize', redimensionnement, false);
  144. });
  145. })(jQuery);