123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- import 'slick-carousel';
- var mobile = false;
- var containers_id = ["projets-block_1","programmes-block_4","home_themes-block_1"];
- $(function(){
- console.log("$ ready !!");
-
- 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)){
- mobile = true;
- }
- if($(".path-frontpage").length > 0){
- // $("#"+).fadeIn();
-
- $('.last-news').slick({
- slidesToShow: 1,
- slidesToScroll: 1,
- centerMode: true,
- centerPadding: '300px',
- responsive: [
- {
- breakpoint: 800,
- settings: {
- centerPadding: '0',
- }
- }]
- });
- $('.last-ressources').slick({
- slidesToShow: 3,
- slidesToScroll: 1,
- centerMode: true,
- centerPadding: '60px',
- infinite: true,
- responsive: [
- {
- breakpoint: 800,
- settings: {
- slidesToShow: 2,
- centerPadding: '0',
- }
- },
- {
- breakpoint: 400,
- settings: {
- slidesToShow: 1,
- centerPadding: '0',
- }
- }]
- });
- }
- if($("#programme_toc-block_5").length > 0){
- $('#programme_toc-block_5>div>div').slick({
- slidesToShow: 1,
- slidesToScroll: 1,
- centerMode: true,
- centerPadding: '200px',
- responsive: [
- {
- breakpoint: 800,
- settings: {
- centerPadding: '0',
- adaptiveHeight: true
- }
- }]
- });
- }
-
- $('#centre_de_ressources-block_2>div>div').slick({
- slidesToShow: 3,
- slidesToScroll: 1,
- centerMode: false,
- centerPadding: '60px',
- infinite: true,
- responsive: [
- {
- breakpoint: 800,
- settings: {
- slidesToShow: 2,
- slidesToScroll: 1,
- centerPadding: '0',
- }
- }]
- });
- if($(".path-actus").length > 0){
- let elem = $("#actus_blocks-block_2").find("footer").detach();
- $("#actus_blocks-block_2").append(elem);
- $('#actus_blocks-block_2>div>div').slick({
- slidesToShow: 3,
- slidesToScroll: 1,
- centerMode: false,
- centerPadding: '60px',
- infinite: false,
- });
- elem = $("#actus_blocks-block_1").find("footer").detach();
- $("#actus_blocks-block_1").append(elem);
- $('#actus_blocks-block_1>div>div').slick({
- slidesToShow: 3,
- slidesToScroll: 1,
- centerMode: false,
- centerPadding: '60px',
- infinite: false,
-
- });
-
- $('#home_blocks-block_3>div>div').slick({
- slidesToShow: 3,
- slidesToScroll: 1,
- centerMode: false,
- centerPadding: '60px',
- infinite: false,
- });
-
- }
-
-
- if($('.path-centre-de-ressources').length > 0){
- let elem = $(".content_container").find(".views-element-container header>div");
- $(elem[0]).slick({
- slidesToShow: 1,
- slidesToScroll: 1,
- centerMode: true,
- centerPadding: '100px'
- });
- }
-
- $('.close-block').click(function(){
- $(this).parent().fadeOut();
- if(mobile == true){
- $("body").css("overflow","auto");
- }
- });
- $('.open-block').click(function(){
- $(this).prev().css("display","grid");
- if(mobile == true){
- $("body").css("overflow","hidden");
- }
- });
-
- $("body").on("click", ".header_container header", function(){
- $('.header_container').find("header").removeClass('active');
- $('.header_container').find("header .arrow").remove();
- $(this).append('<span class="arrow"><br>▼</span>');
- $(this).toggleClass('active');
-
- containers_id.forEach((element) => {
- $("#"+element).fadeOut();
- });
- var d = $(this).data("dom");
- $("#"+d).fadeIn(function(){
- if(d == "home_themes-block_1"){
-
- $("#home_themes-block_1>div>div").slick('refresh');
- }
- });
-
- });
- // HOME PAGE
- if($(".path-frontpage").length > 0){
-
- let elem = "<div class='main_logo'></div>";
- $(".about .views-row").prepend(elem);
- var header_container = "<div class='header_container'></div>";
-
- $('#home_blocks-block_2').after(header_container);
-
- //reconstruction header
- var header = $('.views-element-container').find("header");
- $(header).each((index , element) => {
-
- let parent_id = $(header[index]).parents().eq(2).attr("id");
- let words = $(header[index]).text().trim().split(" ");
- let newcontent = words.join('<br>');
- $(header[index]).empty();
- $(header[index]).append(newcontent);
- $(header[index]).attr('data-dom', parent_id);
- let h = $(header[index]).clone();
- if(index == 0){
- $(h).append('<span class="arrow"><br>▼</span>');
- $(h).addClass("active");
- }
- $('.header_container').append(h);
-
- });
- $("#home_themes-block_1 header").remove();
- $("#home_themes-block_1>div>div").slick({
- slidesToShow: 5,
- slidesToScroll: 4,
- centerMode: false,
- // centerPadding: '10%',
- infinite: false,
- responsive: [
- {
- breakpoint: 800,
- settings: {
- slidesToShow: 2,
- slidesToScroll: 1,
- centerPadding: '10px',
- }
- }]
- });
-
- containers_id.forEach((element) => {
- $("#"+element).fadeOut();
- });
- $("#"+$('.header_container').find(".active").data("dom")).fadeIn();
- }
-
-
- //ajout header motif in page static
- if($(".page-node-type-static").length > 0){
- let elem = "<div class='layout__region layout__region--top'></div>"
- $(".layout--threecol-25-50-25").prepend(elem);
- }
- //last-ressources empty item
- $(".last-ressources .views-field-field-programme .field-content").each(function(){
- if ($(this).children().length == 0) {
- $(this).append("POPSU")
- $(this).addClass("empty");
- }
-
- });
-
- //// PAGE POPSU ////
- if($(".page-node-type-programme").length > 0 || $(".page-node-type-projet").length > 0 || $(".page-node-type-theme").length > 0){
- $('.views-element-container header').click(function(){
- $(this).parent().find(".views-row").fadeToggle();
- });
- //test hauteur
- let hb = $(".block-region-second .body").height();
- let ttp = 0;
- $(".block-region-second .body p").each(function(){
- ttp = ttp + $(this).height() ;
- });
- if(hb < ttp + 30){
- $(".block-region-second .body").append('<footer><a class="more">Lire la suite</a></footer>');
- }else{
- $(".block-region-second .body").addClass("body_open");
- }
- //reteste on windows resize
- window.addEventListener('resize', function(){
- $(".block-region-second .body").removeClass("body_open");
- let hb = $(".block-region-second .body").height();
- let ttp = 0;
- $(".block-region-second .body p").each(function(){
- ttp = ttp + $(this).height() ;
- });
- if(hb < ttp+30){
-
- if($(".block-region-second .body footer").length == 0){
-
- $(".block-region-second .body").append('<footer><a class="more">Lire la suite</a></footer>');
- }
- }else{
- if($(".block-region-second .body footer").length > 0){
- $(".block-region-second .body footer").remove();
-
- }
- $(".block-region-second .body").addClass("body_open");
- }
-
- });
- let elem = "<div class='main_logo'></div>"
-
- if( $("body").hasClass("programme-6") || $("body").hasClass("programme-27") ){
- $('#projets-block_2').prepend(elem);
- }else{
- $('#projets-block_2').append(elem);
- $(".main_logo").css("position","relative")
-
- }
- // ouverture et fermeture des paragraphes
- $(".field_titre").on("click", function(){
- let e = $(this).parent().find(".field_texte");
- $(e).toggleClass("crop");
- $(this).toggleClass("rotate");
- });
- $(".field_equipes").parent().find("h2").on("click", function(){
- $(this).toggleClass("rotate");
- if($(".field_equipes").is(":visible")){
- $(".field_equipes").fadeOut("slow");
- }else{
- $(".field_equipes").fadeIn("slow");
- }
- });
- $(".field_partenaires").parent().find("h2").on("click", function(){
- $(this).toggleClass("rotate");
- if($(".field_partenaires").is(":visible")){
- $(".field_partenaires").fadeOut("slow");
- }else{
- $(".field_partenaires").fadeIn("slow", function(){
- $(this).css("display","grid")
- });
- }
- });
- $(".block-region-second .body").on("click", ".more", function(){
-
- $(".body").toggleClass("body_open");
- if($('.body_open').length > 0){
- $(this).empty().html("Fermer")
- }else{
- $(this).empty().html("Lire la suite")
- }
-
- });
- };
- //page about navigation :
- if($(".page-node-type-static").length > 0){
- $(".field_titre").on("click", function(){
- let elem = $(this).find('div:not([class])').html();
- console.log(elem);
- $(".block-region-second").find(".field_titre").each(function(){
- let title = $(this).html();
- if(title == elem){
- $('html,body').animate({
- scrollTop: $(this).offset().top
- }, 'slow');
- return false;
- }
- });
- });
- }
-
- });
|