script.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. (function ($) {
  2. function notes() {
  3. var $link = $('#presentation a');
  4. var allNotes = $ ('.notes > div');
  5. allNotes.hide();
  6. $link.each(function(){
  7. $(this).click(function(e) {
  8. $this = $(this);
  9. if ( $this.is('#ressource') || $this.is('#bibliographie') ) {
  10. e.preventDefault();
  11. var $url = $this.attr("href");
  12. if ($( ".side_notes" )[0]) {
  13. $( ".side_notes" ).fadeOut(200, function() {
  14. $(this).remove();
  15. });
  16. } else if ($('.notes > div')[0]) {
  17. $( ".notes > div" ).fadeOut(200);
  18. }
  19. content_type($url, $this);
  20. ajax($url, $this);
  21. } else if ($this.is('#note')) {
  22. e.preventDefault();
  23. var id_notes = $this.attr('href');
  24. var notes = $(".notes "+id_notes);
  25. if ($( ".side_notes" )[0]) {
  26. $( ".side_notes" ).fadeOut(200, function() {
  27. $(this).remove();
  28. });
  29. } else if ($('.notes > div')[0]) {
  30. $( ".notes > div" ).fadeOut(200);
  31. }
  32. notes.fadeIn(200);
  33. position_link($this, notes);
  34. $(window).resize(function() {
  35. position_link($this, notes);
  36. });
  37. close();
  38. }
  39. });
  40. })
  41. function content_type($url, $this) {
  42. if ($this.is('#ressource')) {
  43. $("<div class='side_notes'><div class='wrap'><a href="+$url+"></a></div> </div>").insertAfter(".__wrap_side .notes");
  44. } else if ( $this.is('#bibliographie') ) {
  45. $("<div class='side_notes'><div class='wrap'></div></>").insertAfter(".__wrap_side .notes");
  46. }
  47. }
  48. function ajax($url , $this) {
  49. $.ajax({
  50. url: $url + '#publicationAjax',
  51. method: "GET",
  52. dataType:'text',
  53. async: true,
  54. success: function(data) {
  55. if ($this.is('#ressource')) {
  56. var hero = 'article .__wrapper .__hero';
  57. var head = 'article .__wrapper .__head';
  58. $(data).find(hero +','+ head).appendTo('.side_notes > div a').hide().fadeIn(200);
  59. $("<div class='close'></div>").appendTo(".side_notes > div");
  60. }else if ($this.is('#bibliographie')) {
  61. $(data).find('article.bibliographie').appendTo('.side_notes > div');
  62. $("<div class='close'></div>").appendTo(".side_notes > div");
  63. }
  64. position_link($this);
  65. $(window).resize(function() {
  66. position_link($this);
  67. });
  68. close();
  69. },
  70. })
  71. }
  72. function position_link($this, id_notes) {
  73. var $top_link = $this.position().top;
  74. var width = $(window).width();
  75. if ( $this.is('#ressource') || $this.is('#bibliographie') ) {
  76. $('.side_notes').css("top", $top_link);
  77. }
  78. if ( $this.is('#note') ) {
  79. id_notes.css("top", $top_link);
  80. }
  81. if (width <= '754') {
  82. var $top_link = $this.offset().top;
  83. if ( $this.is('#ressource') || $this.is('#bibliographie') ) {
  84. $('.side_notes').css("top", $top_link);
  85. }
  86. if ( $this.is('#note') ) {
  87. id_notes.css("top", $top_link);
  88. }
  89. }
  90. }
  91. function close() {
  92. var $croix = $('.close');
  93. $croix.click(function(e) {
  94. $(this).parents('.side_notes').fadeOut(200, function() {
  95. $(this).remove();
  96. });
  97. $(this).parents('.notes > div').fadeOut(200);
  98. });
  99. }
  100. }
  101. function slide() {
  102. var $slide = $('main section .__slide');
  103. var thumbnails = $('.__slide article.programme.is-selected');
  104. var $head_date = $('#block-colloque2024-views-block-slide-programme-block-1 section.first:before');
  105. $slide.each(function() {
  106. $(this).flickity({
  107. cellAlign: 'left',
  108. pageDots: false,
  109. contain: true,
  110. on: {
  111. ready: function() {
  112. var dates = {},
  113. date;
  114. var $cells = this.cells;
  115. $('.__slide article.programme[data-date]').each(function(i, el){
  116. date = $(el).data('date');
  117. if (dates.hasOwnProperty(date)) {
  118. dates[date] += 1;
  119. $(this).addClass('last');
  120. }
  121. else {
  122. dates[date] = 1;
  123. $(this).addClass('first');
  124. var dateValue = $(this).data('date');
  125. $("<span>"+dateValue+"</span>").prependTo($(this));
  126. }
  127. });
  128. },
  129. }
  130. })
  131. });
  132. var $footer_slide = $('footer .__slide');
  133. $footer_slide.each(function() {
  134. $(this).flickity({
  135. cellAlign: 'left',
  136. pageDots: false,
  137. autoPlay: true,
  138. pauseAutoPlayOnHover: false,
  139. contain: true,
  140. prevNextButtons: false,
  141. })
  142. });
  143. var $slide_paragrpahe = $('main .paragraph .__slide');
  144. $slide_paragrpahe.each(function() {
  145. $(this).flickity({
  146. cellAlign: 'left',
  147. pageDots: false,
  148. prevNextButtons: false,
  149. contain: true,
  150. watchCSS: true,
  151. })
  152. });
  153. }
  154. function burger() {
  155. var hamburgers = document.querySelector(".hamburger");
  156. var nav = document.querySelector(".nav-main");
  157. hamburgers.addEventListener("click", function() {
  158. this.classList.toggle("is-active");
  159. nav.classList.toggle("is-active");
  160. $('html, body').toggleClass("is-active");
  161. $('#block-popsu-colloque-branding').toggleClass("is-active");
  162. });
  163. }
  164. function replaceAny(){
  165. var $selects = $(".js-form-type-select .form-select");
  166. $.each( $selects , function(i) {
  167. var selectOptionAll = $(this).find("option[value='All']");
  168. var optionContent = selectOptionAll.html();
  169. if ($(this).attr('id') == 'edit-field-theme-target-id') {
  170. var newhtml = optionContent.replace("- Any -", "Thèmes").replace("- Tout -", "Thèmes");
  171. } else if ($(this).attr('id') == 'edit-field-type-de-publication-target-id' ) {
  172. var newhtml = optionContent.replace("- Any -", "Publications").replace("- Tout -", "Publications");
  173. } else {
  174. // nothing
  175. }
  176. selectOptionAll.html(newhtml);
  177. });
  178. }
  179. function select_custom() {
  180. var x, i, j, l, ll, selElmnt, a, b, c;
  181. /* Look for any elements with the class "form-select": */
  182. x = document.querySelectorAll(".js-form-item-field-theme-target-id, .js-form-item-field-type-de-publication-target-id ");
  183. l = x.length;
  184. for (i = 0; i < l; i++) {
  185. selElmnt = x[i].getElementsByTagName("select")[0];
  186. ll = selElmnt.length;
  187. /* For each element, create a new DIV that will act as the selected item: */
  188. a = document.createElement("DIV");
  189. a.setAttribute("class", "select-selected");
  190. a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML;
  191. x[i].appendChild(a);
  192. /* For each element, create a new DIV that will contain the option list: */
  193. b = document.createElement("DIV");
  194. b.setAttribute("class", "select-items select-hide");
  195. for (j = 1; j < ll; j++) {
  196. /* For each option in the original select element,
  197. create a new DIV that will act as an option item: */
  198. c = document.createElement("DIV");
  199. c.innerHTML = selElmnt.options[j].innerHTML;
  200. c.addEventListener("click", function(e) {
  201. /* When an item is clicked, update the original select box,
  202. and the selected item: */
  203. var y, i, k, s, h, sl, yl;
  204. s = this.parentNode.parentNode.getElementsByTagName("select")[0];
  205. sl = s.length;
  206. h = this.parentNode.previousSibling;
  207. for (i = 0; i < sl; i++) {
  208. if (s.options[i].innerHTML == this.innerHTML) {
  209. s.selectedIndex = i;
  210. h.innerHTML = this.innerHTML;
  211. y = this.parentNode.getElementsByClassName("same-as-selected");
  212. yl = y.length;
  213. for (k = 0; k < yl; k++) {
  214. y[k].removeAttribute("class");
  215. }
  216. this.setAttribute("class", "same-as-selected");
  217. break;
  218. }
  219. }
  220. h.click();
  221. });
  222. b.appendChild(c);
  223. }
  224. x[i].appendChild(b);
  225. a.addEventListener("click", function(e) {
  226. /* When the select box is clicked, close any other select boxes,
  227. and open/close the current select box: */
  228. e.stopPropagation();
  229. closeAllSelect(this);
  230. this.nextSibling.classList.toggle("select-hide");
  231. this.classList.toggle("select-arrow-active");
  232. });
  233. }
  234. function closeAllSelect(elmnt) {
  235. /* A function that will close all select boxes in the document,
  236. except the current select box: */
  237. var x, y, i, xl, yl, arrNo = [];
  238. x = document.getElementsByClassName("select-items");
  239. y = document.getElementsByClassName("select-selected");
  240. xl = x.length;
  241. yl = y.length;
  242. for (i = 0; i < yl; i++) {
  243. if (elmnt == y[i]) {
  244. arrNo.push(i)
  245. } else {
  246. y[i].classList.remove("select-arrow-active");
  247. }
  248. }
  249. for (i = 0; i < xl; i++) {
  250. if (arrNo.indexOf(i)) {
  251. x[i].classList.add("select-hide");
  252. }
  253. }
  254. }
  255. /* If the user clicks anywhere outside the select box,
  256. then close all select boxes: */
  257. document.addEventListener("click", closeAllSelect);
  258. }
  259. function remove_isactive() {
  260. $( window ).resize(function() {
  261. var width = $(window).width();
  262. if (width <= '1185') {
  263. $('header .is-active').removeClass("is-active");
  264. $('body.is-active').removeClass("is-active");
  265. }
  266. });
  267. }
  268. function hidden_morelinkMoment(){
  269. TxtMomentHeght = $('#moments .__content').height();
  270. limitHeight = 16 * 8;
  271. $morelink = $('#moments .more_link');
  272. if(TxtMomentHeght <= limitHeight){
  273. $morelink.addClass('is_active');
  274. }
  275. $morelink.click(function(e) {
  276. e.preventDefault();
  277. $('#moments .__content').addClass('is_active');
  278. $morelink.addClass('is_active');
  279. })
  280. }
  281. function scrollReaveal(){
  282. const nodes = {
  283. hero : document.querySelectorAll('.__img-hero'),
  284. hero_participant : document.querySelectorAll('.participant_full .__img'),
  285. title_participant: document.querySelectorAll('.participant_full figcaption'),
  286. article : document.querySelectorAll('.home #txt_present, article#presentation'),
  287. blocs : document.querySelectorAll('#block-views-block-slide-programme-block-1, #block-views-block-dernieres-publications-block-1, .__ressources > *'),
  288. p : document.querySelectorAll('article#presentation p, .letter-sort, .participant_full .content > *'),
  289. programme: document.querySelectorAll('.programme.container'),
  290. thumbnails : document.querySelectorAll('.programme .thumbnails, .views.__publications .thumbnails, .les_intervenants .thumbnails_participants'),
  291. node_moment : document.querySelectorAll('#moments .__title, #moments .__wrapper, #moments .__wrap_content .__content > *, #moments .__wrap_side')
  292. }
  293. const showUp = {
  294. origin: 'bottom',
  295. delay: 100,
  296. duration: 600,
  297. distance: '50px',
  298. easing: 'cubic-bezier(0.5, 0, 0, 1)'
  299. }
  300. const Show = {
  301. delay: 100,
  302. duration: 600,
  303. easing: 'cubic-bezier(0.5, 0, 0, 1)'
  304. }
  305. const showleft = {
  306. origin: 'left',
  307. delay: 100,
  308. duration: 600,
  309. distance: '50px',
  310. easing: 'cubic-bezier(0.5, 0, 0, 1)'
  311. }
  312. console.log(nodes.front);
  313. ScrollReveal().reveal(nodes.hero, Show);
  314. ScrollReveal().reveal(nodes.hero_participant, showleft);
  315. ScrollReveal().reveal(nodes.article, showUp);
  316. ScrollReveal().reveal(nodes.blocs, showUp);
  317. ScrollReveal().reveal(nodes.p, showUp);
  318. ScrollReveal().reveal(nodes.programme, showUp);
  319. ScrollReveal().reveal(nodes.thumbnails, showUp);
  320. ScrollReveal().reveal(nodes.views, showUp);
  321. ScrollReveal().reveal(nodes.title_participant, Show);
  322. ScrollReveal().reveal(nodes.node_moment, showUp);
  323. }
  324. function pagination(){
  325. const $next = $('#block-views-block-gallerie-block-1 .pager a');
  326. $next.on("click",function(event){
  327. event.preventDefault();
  328. const $url = $(this).attr('href');
  329. var PageMax = $(this).attr('data-totalpages');
  330. var split = $url.split('=');
  331. var base_uri = split[0];
  332. var currentPage = split[1];
  333. currentPage++;
  334. ajaxPage(base_uri, currentPage, $url);
  335. if (currentPage > PageMax) {
  336. $(this).remove();
  337. }
  338. });
  339. function ajaxPage(base_uri, currentPage, $url) {
  340. $('.loader').addClass('show');
  341. $.ajax({
  342. method: "GET",
  343. url: $url,
  344. async: true,
  345. cache: false,
  346. dataType: "html",
  347. statusCode: {
  348. //traitement en cas de succès
  349. 200: function() {
  350. $('.loader').removeClass('show');
  351. },
  352. }
  353. })
  354. .done(function( data ) {
  355. let $data = $(data).find(".wrap--image");
  356. $( "#block-views-block-gallerie-block-1 section.d-flex" ).append($data);
  357. $next.attr('href', base_uri +'='+ currentPage);
  358. });
  359. }
  360. }
  361. function Light(){
  362. lightbox.option({
  363. 'resizeDuration': 200,
  364. 'wrapAround': true,
  365. 'alwaysShowNavOnTouchDevices':true,
  366. 'positionFromTop': 50,
  367. 'disableScrolling':true
  368. })
  369. }
  370. $( document ).ready(function() {
  371. // currenturl();
  372. scrollReaveal();
  373. notes();
  374. slide();
  375. burger();
  376. replaceAny();
  377. select_custom();
  378. remove_isactive();
  379. hidden_morelinkMoment();
  380. pagination();
  381. Light();
  382. });
  383. })(jQuery);