| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- $(document).ready(function(){
- // ******* Navbars & dropdowns *******
- // delay in ms before dropdown collapse after the cursor leave
- var collapsingDelay = 400;
- // hide the dropdown element and its children
- var hideDropdownsFor = function(elt, delay=0) {
- if (delay === 0) {
- elt.children('ul.dropdown-menu').removeClass('dropdown-displayed');
- elt.removeClass('dropdown-displayed');
- elt.children('ul.dropdown-menu').hide();
- } else {
- elt.delay(delay).queue(function(next) {
- elt.children('ul.dropdown-menu').removeClass('dropdown-displayed');
- elt.removeClass('dropdown-displayed');
- next();
- });
- elt.children('ul.dropdown-menu').delay(delay).hide(1);
- }
- }
- // stop any delayed commands on elt and its children
- var stopDelayedHidingFor = function(elt) {
- elt.stop(true);
- elt.children('ul.dropdown-menu').stop(true);
- }
- $('.dropdown').on('mouseenter', function(e) {
- // stop any delayed hiding on this since the cursor went back on it
- stopDelayedHidingFor($(this));
- // hide every other dropdown in the page
- $('.dropdown.dropdown-displayed').not($(this).parents()).each(function() {
- hideDropdownsFor($(this));
- });
- // display the dropdown
- dropdown = $(this).find('ul.dropdown-menu:first');
- if (dropdown.length !== 0) {
- $(this).addClass('dropdown-displayed');
- dropdown.addClass('dropdown-displayed');
- dropdown.show();
- // if this is a second level dropdown
- if ($(this).parents('.dropdown').length !== 0) {
- // move it on the right or left according to its current position
- dropdown.removeClass('dropdown-left').removeClass('dropdown-right');
- if (($(this).offset().left + $(this).width() + dropdown.width()) > $(window).width()) {
- dropdown.addClass('dropdown-left');
- } else {
- dropdown.addClass('dropdown-right');
- }
- }
- }
- }).on('mouseleave', function(e) {
- if ($(this).hasClass('delayed-collapsing')) {
- hideDropdownsFor($(this), collapsingDelay);
- } else {
- hideDropdownsFor($(this));
- }
- });
- // **** Login Pop-Up and Auth
- $('#login-btn').on('click', function(e) {
- e.preventDefault();
- $('#login-popup .popup-form').toggleClass("show");
- });
- if ($('#login-popup').find('.alert').length) {
- $('#login-popup .popup-form').toggleClass("show");
- console.log('')
- }
- // **** Forms ****
- $('.datepicker').datepicker({
- minDate: new Date(),
- maxDate: "+2y",
- dayNames: [ "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" ],
- dayNamesMin: [ "Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa" ],
- dayNamesShort: [ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam" ],
- monthNames: [ "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" ],
- monthNamesShort: [ "Jan", "Fev", "Mar", "Avr", "Mai", "Jui", "Juil", "Aou", "Sep", "Oct", "Nov", "Dec" ],
- dateFormat: "dd/mm/yy"
- });
- // **** Carousel *****
- // uses the slick lib, see https://kenwheeler.github.io/slick/
- $('.carousel').slick({
- arrows: false,
- dots: false,
- autoplay: true,
- autoplaySpeed: 3600,
- draggable: false,
- speed: 700,
- adaptiveHeight: false
- });
- // **** Leaflet: maps *****
- function showEventMap(mapDiv) {
- // Collect the data from th map children <i>
- var events = [];
- mapDiv.children('.event-geodata').each(function () {
- let event_ = {
- id: $(this).data('id'),
- long: $(this).data('long'),
- lat: $(this).data('lat'),
- label: $(this).data('label')
- };
- events.push(event_);
- });
- if (events.length === 0) {
- return;
- }
- // Instanciate the map object @see https://leafletjs.com/reference-1.6.0.html#map-factory
- var mapOptions = {scrollWheelZoom: false};
- var initialZoom = 13;
- var eventMap = L.map('event-map', mapOptions);
- eventMap.setView([events[0].lat, events[0].long], initialZoom);
- console.log([events[0].lat, events[0].long]);
- // Add the tile layer
- L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
- maxZoom: 18,
- id: 'mapbox/streets-v11',
- tileSize: 512,
- zoomOffset: -1,
- attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
- accessToken: 'pk.eyJ1Ijoib2xpdmllci1tYXNzb3QiLCJhIjoiY2s5OGl1M2cxMWNpajNscnV4Zm5maWY3eSJ9.YDESFgB-JuAhplTzXI6hGQ',
- }).addTo(eventMap);
- // Collect the event geodata to create the markers
- var markers = []
- events.forEach(function (event_) {
- var marker = L.marker([event_.lat, event_.long]).addTo(eventMap);
- marker.bindPopup(event_.label);
- markers.push(marker);
- });
- // Set the view
- var markersGroup = new L.featureGroup(markers);
- eventMap.fitBounds(markersGroup.getBounds());
- eventMap.zoomSnap = 1;
- eventMap.zoomOut();
- }
- if ($('.ot-all-events #event-map').length) {
- showEventMap($('#event-map').first());
- }
- if ($('.ot-show-event #event-map').length) {
- showEventMap($('#event-map').first());
- }
- });
|