script.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. import 'slick-carousel';
  2. var mobile = false;
  3. var containers_id = ["projets-block_1","programmes-block_4","home_themes-block_1"];
  4. $(function(){
  5. console.log("$ ready !!");
  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. if($(".path-frontpage").length > 0){
  10. // $("#"+).fadeIn();
  11. $('.last-news').slick({
  12. slidesToShow: 1,
  13. slidesToScroll: 1,
  14. centerMode: true,
  15. centerPadding: '300px',
  16. responsive: [
  17. {
  18. breakpoint: 800,
  19. settings: {
  20. centerPadding: '0',
  21. }
  22. }]
  23. });
  24. $('.last-ressources').slick({
  25. slidesToShow: 3,
  26. slidesToScroll: 1,
  27. centerMode: true,
  28. centerPadding: '60px',
  29. infinite: true,
  30. responsive: [
  31. {
  32. breakpoint: 800,
  33. settings: {
  34. slidesToShow: 2,
  35. centerPadding: '0',
  36. }
  37. },
  38. {
  39. breakpoint: 400,
  40. settings: {
  41. slidesToShow: 1,
  42. centerPadding: '0',
  43. }
  44. }]
  45. });
  46. }
  47. if($("#programme_toc-block_5").length > 0){
  48. $('#programme_toc-block_5>div>div').slick({
  49. slidesToShow: 1,
  50. slidesToScroll: 1,
  51. centerMode: true,
  52. centerPadding: '200px',
  53. responsive: [
  54. {
  55. breakpoint: 800,
  56. settings: {
  57. centerPadding: '0',
  58. adaptiveHeight: true
  59. }
  60. }]
  61. });
  62. }
  63. $('#centre_de_ressources-block_2>div>div').slick({
  64. slidesToShow: 3,
  65. slidesToScroll: 1,
  66. centerMode: false,
  67. centerPadding: '60px',
  68. infinite: true,
  69. responsive: [
  70. {
  71. breakpoint: 800,
  72. settings: {
  73. slidesToShow: 2,
  74. slidesToScroll: 1,
  75. centerPadding: '0',
  76. }
  77. }]
  78. });
  79. if($(".path-actus").length > 0){
  80. let elem = $("#actus_blocks-block_2").find("footer").detach();
  81. $("#actus_blocks-block_2").append(elem);
  82. $('#actus_blocks-block_2>div>div').slick({
  83. slidesToShow: 3,
  84. slidesToScroll: 1,
  85. centerMode: false,
  86. centerPadding: '60px',
  87. infinite: false,
  88. });
  89. elem = $("#actus_blocks-block_1").find("footer").detach();
  90. $("#actus_blocks-block_1").append(elem);
  91. $('#actus_blocks-block_1>div>div').slick({
  92. slidesToShow: 3,
  93. slidesToScroll: 1,
  94. centerMode: false,
  95. centerPadding: '60px',
  96. infinite: false,
  97. });
  98. $('#home_blocks-block_3>div>div').slick({
  99. slidesToShow: 3,
  100. slidesToScroll: 1,
  101. centerMode: false,
  102. centerPadding: '60px',
  103. infinite: false,
  104. });
  105. }
  106. if($('.path-centre-de-ressources').length > 0){
  107. let elem = $(".content_container").find(".views-element-container header>div");
  108. $(elem[0]).slick({
  109. slidesToShow: 1,
  110. slidesToScroll: 1,
  111. centerMode: true,
  112. centerPadding: '100px'
  113. });
  114. }
  115. $('.close-block').click(function(){
  116. $(this).parent().fadeOut();
  117. if(mobile == true){
  118. $("body").css("overflow","auto");
  119. }
  120. });
  121. $('.open-block').click(function(){
  122. $(this).prev().css("display","grid");
  123. if(mobile == true){
  124. $("body").css("overflow","hidden");
  125. }
  126. });
  127. $("body").on("click", ".header_container header", function(){
  128. $('.header_container').find("header").removeClass('active');
  129. $('.header_container').find("header .arrow").remove();
  130. $(this).append('<span class="arrow"><br>▼</span>');
  131. $(this).toggleClass('active');
  132. containers_id.forEach((element) => {
  133. $("#"+element).fadeOut();
  134. });
  135. var d = $(this).data("dom");
  136. $("#"+d).fadeIn(function(){
  137. if(d == "home_themes-block_1"){
  138. $("#home_themes-block_1>div>div").slick('refresh');
  139. }
  140. });
  141. });
  142. // HOME PAGE
  143. if($(".path-frontpage").length > 0){
  144. let elem = "<div class='main_logo'></div>";
  145. $(".about .views-row").prepend(elem);
  146. var header_container = "<div class='header_container'></div>";
  147. $('#home_blocks-block_2').after(header_container);
  148. //reconstruction header
  149. var header = $('.views-element-container').find("header");
  150. $(header).each((index , element) => {
  151. let parent_id = $(header[index]).parents().eq(2).attr("id");
  152. let words = $(header[index]).text().trim().split(" ");
  153. let newcontent = words.join('<br>');
  154. $(header[index]).empty();
  155. $(header[index]).append(newcontent);
  156. $(header[index]).attr('data-dom', parent_id);
  157. let h = $(header[index]).clone();
  158. if(index == 0){
  159. $(h).append('<span class="arrow"><br>▼</span>');
  160. $(h).addClass("active");
  161. }
  162. $('.header_container').append(h);
  163. });
  164. $("#home_themes-block_1 header").remove();
  165. $("#home_themes-block_1>div>div").slick({
  166. slidesToShow: 5,
  167. slidesToScroll: 4,
  168. centerMode: false,
  169. // centerPadding: '10%',
  170. infinite: false,
  171. responsive: [
  172. {
  173. breakpoint: 800,
  174. settings: {
  175. slidesToShow: 2,
  176. slidesToScroll: 1,
  177. centerPadding: '10px',
  178. }
  179. }]
  180. });
  181. containers_id.forEach((element) => {
  182. $("#"+element).fadeOut();
  183. });
  184. $("#"+$('.header_container').find(".active").data("dom")).fadeIn();
  185. }
  186. //ajout header motif in page static
  187. if($(".page-node-type-static").length > 0){
  188. let elem = "<div class='layout__region layout__region--top'></div>"
  189. $(".layout--threecol-25-50-25").prepend(elem);
  190. }
  191. //last-ressources empty item
  192. $(".last-ressources .views-field-field-programme .field-content").each(function(){
  193. if ($(this).children().length == 0) {
  194. $(this).append("POPSU")
  195. $(this).addClass("empty");
  196. }
  197. });
  198. //// PAGE POPSU ////
  199. if($(".page-node-type-programme").length > 0 || $(".page-node-type-projet").length > 0 || $(".page-node-type-theme").length > 0){
  200. $('.views-element-container header').click(function(){
  201. $(this).parent().find(".views-row").fadeToggle();
  202. });
  203. //test hauteur
  204. let hb = $(".block-region-second .body").height();
  205. let ttp = 0;
  206. $(".block-region-second .body p").each(function(){
  207. ttp = ttp + $(this).height() ;
  208. });
  209. if(hb < ttp + 30){
  210. $(".block-region-second .body").append('<footer><a class="more">Lire la suite</a></footer>');
  211. }else{
  212. $(".block-region-second .body").addClass("body_open");
  213. }
  214. //reteste on windows resize
  215. window.addEventListener('resize', function(){
  216. $(".block-region-second .body").removeClass("body_open");
  217. let hb = $(".block-region-second .body").height();
  218. let ttp = 0;
  219. $(".block-region-second .body p").each(function(){
  220. ttp = ttp + $(this).height() ;
  221. });
  222. if(hb < ttp+30){
  223. if($(".block-region-second .body footer").length == 0){
  224. $(".block-region-second .body").append('<footer><a class="more">Lire la suite</a></footer>');
  225. }
  226. }else{
  227. if($(".block-region-second .body footer").length > 0){
  228. $(".block-region-second .body footer").remove();
  229. }
  230. $(".block-region-second .body").addClass("body_open");
  231. }
  232. });
  233. let elem = "<div class='main_logo'></div>"
  234. if( $("body").hasClass("programme-6") || $("body").hasClass("programme-27") ){
  235. $('#projets-block_2').prepend(elem);
  236. }else{
  237. $('#projets-block_2').append(elem);
  238. $(".main_logo").css("position","relative")
  239. }
  240. // ouverture et fermeture des paragraphes
  241. $(".field_titre").on("click", function(){
  242. let e = $(this).parent().find(".field_texte");
  243. $(e).toggleClass("crop");
  244. $(this).toggleClass("rotate");
  245. });
  246. $(".field_equipes").parent().find("h2").on("click", function(){
  247. $(this).toggleClass("rotate");
  248. if($(".field_equipes").is(":visible")){
  249. $(".field_equipes").fadeOut("slow");
  250. }else{
  251. $(".field_equipes").fadeIn("slow");
  252. }
  253. });
  254. $(".field_partenaires").parent().find("h2").on("click", function(){
  255. $(this).toggleClass("rotate");
  256. if($(".field_partenaires").is(":visible")){
  257. $(".field_partenaires").fadeOut("slow");
  258. }else{
  259. $(".field_partenaires").fadeIn("slow", function(){
  260. $(this).css("display","grid")
  261. });
  262. }
  263. });
  264. $(".block-region-second .body").on("click", ".more", function(){
  265. $(".body").toggleClass("body_open");
  266. if($('.body_open').length > 0){
  267. $(this).empty().html("Fermer")
  268. }else{
  269. $(this).empty().html("Lire la suite")
  270. }
  271. });
  272. };
  273. //page about navigation :
  274. if($(".page-node-type-static").length > 0){
  275. $(".field_titre").on("click", function(){
  276. let elem = $(this).find('div:not([class])').html();
  277. console.log(elem);
  278. $(".block-region-second").find(".field_titre").each(function(){
  279. let title = $(this).html();
  280. if(title == elem){
  281. $('html,body').animate({
  282. scrollTop: $(this).offset().top
  283. }, 'slow');
  284. return false;
  285. }
  286. });
  287. });
  288. }
  289. });