/**
 * @file
 * quartiers_de_demain behaviors.
 */
 (function (Drupal) {

    'use strict';
  
    Drupal.behaviors.quartiers_de_demain = {
      attach: function (context, settings) {
        console.log('It works!');
      }
    };
  } (Drupal));

  
  jQuery(document).ready(function($){

    $('.open-block').click(function(){
      $(this).toggleClass('opened');

      $('.header_nav_container').toggleClass('display-nav-opened');
    
      if(mobile == true){
        $("body").css("overflow","hidden");
      }

    });
  
    // Hide the header_nav_container when a link inside it is clicked
    $('.header_nav_container li').click(function() {
        $('.header_nav_container').fadeOut();
    });



//////////// agrandissement du shema

  $('#paragraph-id--9 img').click(function() {
    $(this).toggleClass('zoom_in');
  });


});


// /////////////////
//// ancre dans texte au click parragraphe correspondant arrive en dessous du header 


(function($, window) {
  var adjustAnchor = function() {
      var $anchor = $('.sidebar_first_container'),
              fixedElementHeight = 500;
      if ($anchor.length > 0) {
          $('html, body').stop().animate({scrollTop: $anchor.offset().top - fixedElementHeight }, 0);
      }
  };

  $(window).on('hashchange', function() {
      adjustAnchor();
  });


//////////////////////////////////////////// smooth apparition des textes


function scrollReaveal(){

  const nodes = {
    logo : document.querySelectorAll('#logo-animated-container'),
    chapeau :  document.querySelectorAll('.field_body'),
    paragraph: document.querySelectorAll('.field_field_textes .paragraph--type--static-parts'),
  }

  const showUp = {
      origin: 'bottom',
      delay: 100,
      duration: 1000,
      distance: '50px',
      easing: 'cubic-bezier(0.5, 0, 0, 1)'
  }

  const Show = {
    delay: 100,
    duration: 600,
    easing: 'cubic-bezier(0.5, 0, 0, 1)'
  }

  console.log(nodes);

  ScrollReveal().reveal(nodes.logo, Show);
  ScrollReveal().reveal(nodes.chapeau, showUp);
  ScrollReveal().reveal(nodes.paragraph, showUp);
}


$( document ).ready(function() {
  scrollReaveal();
});

})(jQuery);