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: 1,
slidesToScroll: 1,
centerPadding: '40px',
centerMode: true,
}
}]
});
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,
responsive: [
{
breakpoint: 800,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
centerMode: true,
centerPadding: '30px',
}
}]
});
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,
responsive: [
{
breakpoint: 800,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
centerMode: true,
centerPadding: '30px',
}
}]
});
$('#home_blocks-block_3>div>div').slick({
slidesToShow: 3,
slidesToScroll: 1,
centerMode: false,
centerPadding: '60px',
infinite: false,
responsive: [
{
breakpoint: 800,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
centerPadding: '0',
}
}]
});
}
if($('.path-centre-de-ressources').length > 0){
let elem = $(".content_container").find(".views-element-container header>div");
$(elem[0]).slick({
slidesToShow: 3,
slidesToScroll: 1,
centerMode: false,
centerPadding: '60px',
responsive: [
{
breakpoint: 800,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
centerMode: true,
centerPadding: '30px',
}
}]
});
}
$('.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('
▼');
$(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 = $(".field_logo").clone();
let elem = "
";
$(".about .views-row").prepend(elem);
var header_container = "";
$('#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('
');
$(header[index]).empty();
$(header[index]).append(newcontent);
$(header[index]).attr('data-dom', parent_id);
let h = $(header[index]).clone();
if(index == 0){
$(h).append('
▼');
$(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 = ""
$(".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");
}
});
//menu ouvertur sur page event et actu
if($(".page-node-type-evenement").length > 0 || $(".page-node-type-actualite").length > 0){
$('.views-element-container header').on('click', function(){
$(this).parent().find(".view-grouping").fadeToggle();
$(this).parent().find(".views-row").fadeToggle();
});
$('.view-grouping-header').on('click', function(){
$(this).parent().find(".view-grouping-content").slideToggle();
});
}
if($(".page-node-type-programme").length > 0 || $(".page-node-type-projet").length > 0 || $(".page-node-type-theme").length > 0 ){
$(".field_ressources_liees article").each(function(){
let title = $(this).find("h2").clone();
$(this).find("h2").remove();
$(this).find("div").first().append(title);
})
$('.views-element-container header').on("click", function(){
//$(this).parent().find(".view-grouping").fadeToggle();
console.log($(this).parent().find("h3"));
if($(this).parent().children("h3").length > 0){
// for territoires which are grouped by regions
$(this).parent().find("h3").fadeToggle();
}else{
$(this).parent().find(".views-row").fadeToggle();
}
});
// popsu 1
// $('')
$('#programme_toc-block_9 header').on('click', function(){
$(this).parent().find(".view-grouping").fadeToggle();
$(this).parent().find(".views-row").fadeToggle();
});
//page projet
$("#programme_toc-block_10 h3").on('click', function(){
// pour territoire
$(this).nextUntil("h3").fadeToggle();
});
//page programme
// pour territoire (h3 are regions)
$("#programme_toc-block_4 h3").on('click', function(){
console.log(this);
$(this).nextUntil("h3").fadeToggle();
});
$('.view-grouping-header').on('click', function(){
$(this).parent().find(".view-grouping-content").slideToggle();
});
//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('');
}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('');
}
}else{
if($(".block-region-second .body footer").length > 0){
$(".block-region-second .body footer").remove();
}
$(".block-region-second .body").addClass("body_open");
}
});
let url = $(".block-region-second .field_logo img").attr("src");
console.log(url)
let elem = "";
elem = $(elem).css("background","50%/contain no-repeat url("+url+")");
///let elem = ""
if( $("body").hasClass("programme-7") || $("body").hasClass("programme-6") || $("body").hasClass("programme-27") ){
if(mobile != true){
$('#projets-block_2').prepend(elem);
}else{
$('#projets-block_2').append(elem);
$(".main_logo").css("position","relative");
}
}else{
//block-region-second
if($('#projets-block_2').length > 0){
$('#projets-block_2').append(elem);
}else{
//ici retiré $( ".path-node.programme-878").length > 0 || $( ".path-node.programme-883").length > 0
//remplacé par page nodetype programme -> à tester
if( $(".page-node-type-projet").length == undefined || $(".page-node-type-theme").length == undefined || $( ".page-node-type-programme").length > 0){
$('.block-region-second').prepend(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_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")
});
}
});
$(".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", 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")
}
});
$(".layout__region--bottom .field_ressources_liees>div:nth-of-type(2)").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',
}
}]
});
};
//page about navigation :
if($(".page-node-type-static").length > 0){
$(".field_titre").on("click", function(){
let elem = $(this).find('div:not([class])').html();
$(".block-region-second").find(".field_titre").each(function(){
let title = $(this).html();
if($(".field_groupe_documents").length > 0){
title = $($(title)[2]).html();
}
if(title == elem){
$('html,body').animate({
scrollTop: $(this).offset().top
}, 'slow');
return false;
}
});
});
}
//hide empty or unclickable sidebar
if($(".block-region-first").find("a").length == 0 ){
if($(".page-node-type-static").length == 0 ){
$(".block-region-first").hide();
}
};
//spec ressources video
if($(".page-node-type-ressource").find(".ressources-video").length > 0){
let vid = $(".field_videos").parents().eq(0);
let prog = $(".field_programme").parents().eq(0);
$(vid).clone().insertAfter(prog);
$(vid).remove();
}
//spec ressources diaporama
if($(".page-node-type-ressource").find(".ressources-reportage-photographique").length > 0){
let diapo = $("#node\\:field_diaporama");
let prog = $("#node\\:field_programme");
$(diapo).clone().insertAfter(prog);
$(diapo).remove();
let elem = $(".content_container").find("#node\\:field_diaporama>div.field_diaporama");
console.log('elem', elem);
$(elem[0]).slick({
slidesToShow: 1,
slidesToScroll: 1,
centerMode: false,
centerPadding: '60px',
responsive: [
{
breakpoint: 800,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
centerMode: true,
centerPadding: '30px',
}
}]
});
}
//ressources page projet
if($(".page-node-type-projet").length > 0){
let art = $(".views-field-field-ressources-liees article");
art.each(function(){
let t = $(this).find("h2");
$(t).clone().insertAfter($(this).find(".field_image"));
$(t).remove();
});
}
//crop text for collection
// $(".block-region-third .views-field-description__value").addClass("hidden_text");
// $(".block-region-third .views-field-description__value").on("click", function(){
// $(this).removeClass('hidden_text');
// })
// patch exode urbain partenaire //
if($(".programme-878").length > 0){
let title = $(".programme-878 .field_partenaires div").first()[0];
$(title).addClass("field_titre");
let paragraphe = $(".programme-878 .field_partenaires div")[1];
$(paragraphe).addClass("field_texte crop");
$(".field_partenaires").on("click",".field_titre", function(){
let e = $(this).parent().find(".field_texte");
$(e).toggleClass("crop");
$(this).toggleClass("rotate");
});
}
});
////////// disable click droit souris
jQuery(document).ready(function () {
//Disable cut copy paste
jQuery('body').bind('cut copy paste', function (e) {
e.preventDefault();
});
//Disable mouse right click
jQuery("img").on("contextmenu",function(e){
return false;
});
});