You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

756 lines
40 KiB

/*!
* jQuery.ellipsis
* https://github.com/jjenzz/jquery.ellipsis
* --------------------------------------------------------------------------
* Copyright (c) 2013 J. Smith (@jjenzz)
* Dual licensed under the MIT and GPL licenses:
* https://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* adds a class to the last 'allowed' line of text so you can apply
* text-overflow: ellipsis;
*/
(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{a(jQuery)}}(function(d){var c="ellipsis",b='<span style="white-space: nowrap;">',e={lines:"auto",ellipClass:"ellip",responsive:false};function a(h,q){var m=this,w=0,g=[],k,p,i,f,j,n,s;m.$cont=d(h);m.opts=d.extend({},e,q);function o(){m.text=m.$cont.text();m.opts.ellipLineClass=m.opts.ellipClass+"-line";m.$el=d('<span class="'+m.opts.ellipClass+'" />');m.$el.text(m.text);m.$cont.empty().append(m.$el);t()}function t(){if(typeof m.opts.lines==="number"&&m.opts.lines<2){m.$el.addClass(m.opts.ellipLineClass);return}n=m.$cont.height();if(m.opts.lines==="auto"&&m.$el.prop("scrollHeight")<=n){return}if(!k){return}s=d.trim(m.text).split(/\s+/);m.$el.html(b+s.join("</span> "+b)+"</span>");m.$el.find("span").each(k);if(p!=null){u(p)}}function u(x){s[x]='<span class="'+m.opts.ellipLineClass+'">'+s[x];s.push("</span>");m.$el.html(s.join(" "))}if(m.opts.lines==="auto"){var r=function(y,A){var x=d(A),z=x.position().top;j=j||x.height();if(z===f){g[w].push(x)}else{f=z;w+=1;g[w]=[x]}if(z+j>n){p=y-g[w-1].length;return false}};k=r}if(typeof m.opts.lines==="number"&&m.opts.lines>1){var l=function(y,A){var x=d(A),z=x.position().top;if(z!==f){f=z;w+=1}if(w===m.opts.lines){p=y;return false}};k=l}if(m.opts.responsive){var v=function(){g=[];w=0;f=null;p=null;m.$el.html(m.text);clearTimeout(i);i=setTimeout(t,100)};d(window).on("resize."+c,v)}o()}d.fn[c]=function(f){return this.each(function(){try{d(this).data(c,(new a(this,f)))}catch(g){if(window.console){console.error(c+": "+g)}}})}}));
var events = (function ($, window, jQuery) {
var _vars_ = {};
var guest_max;
var guest_number = 0;
var reserved_seats;
return {
"set_vars": function (options) {
$.extend(_vars_, options || {});
},
"get_vars" : function(){
return _vars_;
},
"filter" : function(page, filter='') {
if($(window).width() > 568){
var month = $('.filter-box.desktop #filter-month').val();
var type = $('.filter-box.desktop #filter-type').val();
var city = $('.filter-box.desktop #filter-city').val();
} else {
var month = $('.filter-box.mobile #filter-month').val();
var type = $('.filter-box.mobile #filter-type').val();
var city = $('.filter-box.mobile #filter-city').val();
}
$.ajax({
url : app.get_vars().baseurl+"events/homepage/filter_events" + filter, // filter should be like '?event_category=1'
type : "GET",
cache: false,
data : {
month : month,
type : type,
city : city,
page : page
},
beforeSend : function () {
// $("#events_list").append('<p class="text-center"><i class="fa fa-spin fa-spinner"/> '+app.get_vars()._app.notif.loading+'</p>');
},
success : function(result) {
if(app.isalive(result)) {
// if ($(window).width() >= 992) {
// if (result.mdata.result_count <= 3) $('#events-list').height(620);
// else $('#events-list').height(1240);
// }
$("#events-list").empty();
$('#paginate').empty();
events._format._event(page, result);
}
}
});
},
"_format" : {
"_event" : function(page, result){
//start listing events
var page = parseInt(page);
var count = 1;
var events_list = $("#events-list");
var page_link = $("#paginate");
events_list.empty();
page_link.empty();
if(typeof result.mdata != "undefined") {
if ($.isEmptyObject(result.mdata.details)) {
// events_list.height(200);
if (result.mdata.logged_in) {
events_list.append(
"<div class='col-md-12 events-list-empty'>" +
"<h2 class='text-center'>" + app.get_vars()._app.no_match_found + "</h2>" +
"</div>"
);
} else {
events_list.append(
"<div class='col-md-12 events-list-empty'>" +
"<h2 class='text-center'>" + app.get_vars()._app.no_results_found + "</h2>" +
"</div>"
);
}
} else {
var row_items = [], records_count = (result.mdata.details).length;
let first_encounter = 0; // set first favorite event to display only in homepage.
$.each(result.mdata.details, function (i, item) {
item.images.forEach(element => {
if(element.display=== 0){
item.file_name = element.file_name
}
});
eventDetails = result.mdata.details;
var imges = "";
var fav="";
var fav_text="";
var favlink=""
var event_schedule_id = item.bostatus.split("_");
var annule = "";
let minute = 0
let hour = 0
const ws = item.workshop_session
if(ws === 'ENLIGNE' || ws === 'DISTANCE') {
if(item.event_videos.length) {
let videos = item.event_videos
let h = 0
let m = 0
let s = 0
for(let i=0; i<videos.length; i++) {
let hms = null
hms = videos[i].duration.split(':')
h += parseInt(hms[0])
m += parseInt(hms[1])
s += parseInt(hms[2])
}
m = m + Math.floor(s/60)
hour = h + Math.floor(m/60)
minute = m % 60
}
} else {
// Convert decimal to time format
let totalH = Math.round((item.hours_per_session) * 100) / 100;
hour = Math.floor(totalH);
var decimal = totalH - hour;
var min = 1 / 60;
// Round to nearest minute
decimal = min * Math.round(decimal / min);
minute = Math.floor(decimal * 60);
}
// $("#w-startTime").text(item.start_date_hour)
//paid event
if(item.event_category=="PAID_EVENT"&&item.event_favorite ==""){
favlink="favlink";
}
// favorites
if (item.event_favorite != null && item.event_favorite !="") {
// favlink="favlink";
// fav="<img id='favorite-img' src='" + app.get_vars().baseurl + "resources/images/M.jpg" + "' alt='" + item.title + "' class='img-responsive'> " ;
fav_text='En partenariat avec <i>Company For Madagascar</i>';
}
if ( (item.event_status[0]['event_status']=='CANCEL' && item.date_feature == 1) || (item.date_feature==2 && item.event_count == item.cancel_count) ) {
annule = "<a href='"+app.get_vars().baseurl+item.workshop_author.split(" ").join("-").replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '')+"/"+item.event_id+"' class='event-link'><span style='position: absolute; color: #fff; height: 100%; background-color: #00000094; text-align: center; width: 100%; padding-top: 4.5rem; font-size: 2.5rem; font-family: Arial !important;'>ANNULÉ</span></a>";
}
// row_items.push({"event" : `<div class="col-md-4 col-sm-6 col-12 mt-5 mb-5" style="align-items: initial; display: -webkit-flex; display: flex;">
// <div class="card `+favlink+`" data-eventid='${item.event_id}'>
// <div class="wrapperimg">
// <a href='${app.get_vars().baseurl}${item.workshop_author}/${item.event_id}' class='event-link'>
// <img src='${app.get_vars().baseurl}resources/images/frontoffice/events/${item.file_name}' alt='${item.title}' class='card-img-top'>
// <p class="eventcat-overlay"><span class="eventcat event-type" id='hp-event-type-city${event_schedule_id[2]}'>${item.event_type ? item.event_type.toUpperCase() : ''}</span></p>
// </a>
// `+ annule +`
// </div>
// <div class="card-body">
// <br/>
// <div><h5 class="card-title"><p class='event-card-title'>`+ fav +` ${item.title}</p></h5></div>
// <!-- <hr class="line"/> -->
// <p class="eventdate" id='hp-event-date${event_schedule_id[2]}'></p>
// <div class="eventcontent">
// <span class="favorites">`+fav_text+`</span>
// <div class="event-desc">
// <p class="card-text" >${item.description}</p>
// </div>
// </div>
// </div>
// <div class="card-footer `+favlink+` h-8" id='event-box-${i}'>
// <div style="line-height:3;" class="`+favlink+`"><p class="mb-2"><a class='event-link' href="${app.get_vars().baseurl}${item.workshop_author}/${item.event_id}">${app.get_vars()._app.read_more} »</a></p></div>
// </div>
// </div>
// </div>`, "row" : [i, parseInt(event_schedule_id[2])]});
//For masterclass events display
if(item.event_status[0].is_favorite === '1' && first_encounter !== 1) {
var atelierLink = app.get_vars().baseurl+item.workshop_author.split(" ").join("-").replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '')+"/"+item.event_id;
var atelierTitle = item.title;
$( "#link-atelier" ).wrap(`<a href="${atelierLink}"></a>`);
$("#title-atelier").text(atelierTitle);
// $(".mc-banner-container" ).css('display', 'none');
// var featured_item = `
// <div class="mc-banner-container">
// <div class="row h-100" data-eventid='${item.event_id}'>
// <div class="col-md-4 col-sm-12 d-inline d-sm-inline d-md-none d-lg-none">
// <img class="mc-mobile-banner-img" src="${app.get_vars().baseurl}resources/images/frontoffice/events/${item.file_name}" alt='${item.title}'">
// </div>
// <div class="col-md-8 col-sm-12">
// <div class="container mc-mobile-banner">
// <div class="mc-featured-content">
// <div class="mc-moment-text">ATELIER DU MOMENT</div>
// <div class="mc-featured-title">${item.title}</div>
// <div class="mc-workshop-link">
// <a href='${app.get_vars().baseurl}${item.workshop_author}/${item.event_id}'><span>Réserver</span> <img src="${app.get_vars().baseurl}resources/images/frontoffice/icons/Arrow.svg"/></a>
// </div>
// </div>
// </div>
// </div>
// </div>
// <img class="mc-banner-bg d-none d-sm-none d-md-inline d-lg-inline" src="${app.get_vars().baseurl}resources/images/frontoffice/events/${item.file_name}" alt='${item.title}'">
// </div>`;
// Append featured event to homepage.
// $( "#featured-list" ).append(featured_item);
// Add one to counter to stop loop
first_encounter = first_encounter + 1;
}
// let btype = 'Date à venir';
// let buttonLabel = 'Reserver';
// let wtype = 3;
// let wlabel = "Atelier en présentiel";
// let whtm = "";
// let dn = "d-none";
// if(item.workshop_session == "PRESENTIEL"){
// wtype = 3;
// wlabel = "Atelier en présentiel";
// }
// if(item.workshop_session == "ENLIGNE"){
// wtype = 2;
// wlabel = "Cours en ligne";
// if(item.remaining_combined_seat !== '0' && item.status_of_event !=='FULL' && item.status_of_event ==='AVAILABLE'){
// buttonLabel = 'Acheter';
// }
// }
// if(item.workshop_session == "DISTANCE"){
// wtype = 1;
// wlabel = "Atelier à distance";
// buttonLabel = "Acheter";
// }
// if(moment().isAfter(moment(item.reservation_end_date))) {
// buttonLabel = "Détails atelier";
// btype = '';
// } else {
// btype = (item.remaining_combined_seat === '0' || item.status_of_event ==='FULL')? 'Complet' : (item.status_of_event ==='AVAILABLE'?'':'Date à venir')
// }
// if(btype !== '')
// whtm = `<div class="w-status">${btype}</div>`;
let btype = '';
let buttonLabel = 'Détails atelier';
if(item.status_of_event ==="SOON" || moment(item.reservation_start_date).isBefore(moment())) {
buttonLabel = "S'inscrire";
btype = "Date à venir"
} else if(moment(item._now).isAfter(moment(item.reservation_end_date))) {
buttonLabel = "Détails atelier";
} else if(item.status_of_event === "AVAILABLE" && moment().range(item.reservation_start_date, item.reservation_end_date)) {
buttonLabel = 'Reserver';
btype = item.remaining_combined_seat === '0' || item.status_of_event ==='FULL' ? 'Complet': '';
} else if(item.remaining_combined_seat === '0' && item.status_of_event ==='FULL') {
buttonLabel = "Reserver";
btype = "Complet"
}
// $("#w-startTime").text(result[0].start_date_hour)
// console.log(item.event_status[0].start_date_hour)
let thumbnail = '';
if(item.workshop_session == null || item.workshop_session == 'PRESENTIEL') {
thumbnail = `<img src='${app.get_vars().baseurl}resources/images/frontoffice/events/${item.file_name}' class="card-img-top" alt='${item.title}'></img>`;
} else {
if(item.file_name) {
thumbnail = `<img src='${app.get_vars().baseurl}resources/images/frontoffice/events/${item.file_name}' class="card-img-top" alt='${item.title}'></img>`;
} else {
thumbnail = `<div align="center" class="embed-responsive embed-responsive-16by9" id="trailer_video">${JSON.parse(item.trailer)}</div>`
}
}
row_items.push({"event" : `
<div class="col-md-6" data-eventid='${item.event_id}'>
<a href='${app.get_vars().baseurl}${item.workshop_author.split(" ").join("-").replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '')}/${item.event_id}'>
<div class="mc-workshop-card card">
<div class="mc-workshop-img-card">
<div class="mc-card-img">
${thumbnail}
</div>
<div class="mc-card-content">
<h2 class="mc-workshop-speaker ${item.event_id !== '31' ? '': 'd-none'}">${item.workshop_author !== null ? item.workshop_author : ''}</h2>
<h3 class="mc-workshop-title">${item.title !== null ? item.title : ''}</h3>
</div>
</div>
<div class="w-card-details">
<div class="d-flex justify-content-between">
<div class="mc-workshop-session text-dark ${item.event_id !== '31' ? '': 'd-none'}"><span class="font-weight-bold">${(item.workshop_session === 'ENLIGNE' || item.workshop_session === 'DISTANCE')? item.event_videos.length + ' vidéo'+ ((item.event_videos.length > 1) ? 's' : '') : item.number_of_sessions+ ' séance'+ ((item.number_of_sessions > 1) ? 's' : '')}</span> ${hour}h${minute == 0 ? '' : minute < 10 ? '0' + minute : minute } d’atelier</div>
<div class="w-link">
${item.workshop_session === "ENLIGNE" ? 'Acheter': item.workshop_session == "DISTANCE"? 'Détails atelier' : buttonLabel}
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6 11.762V13.238H15.44L13.056 15.938L14 17L18 12.5L14 8L13.056 9.062L15.44 11.762H6Z" fill="#464F5F"/>
</svg>
</div>
</div>
<div class="w-card-status">
<div class="w-selection-type w-type${item.workshop_session === "ENLIGNE"?'2': item.workshop_session === "DISTANCE"?'1': '3'}">
${item.workshop_session === "ENLIGNE"?'Cours en ligne': item.workshop_session === "DISTANCE"?'Atelier à distance': 'Atelier en présentiel'}
</div>
<div class="w-status ${item.workshop_session === "ENLIGNE" || btype === ''? 'd-none':''}">${item.workshop_session === "ENLIGNE" ?'': btype}</div>
<!--div class="mc-workshop-partner d-flex align-items-center flex-nowrap">
<span class="">Avec l’aide de</span>
<img class="ml-2" src="/resources/images/frontoffice/logo/logo-sud.svg?v=1627373976">
</div-->
</div>
</div>
</div>
</a>
</div>`, "row" : [i, parseInt(event_schedule_id[2])]});
if(events._format._margin(records_count, (i+1))){
events_list.append(`<div class='card-deck mark${i}'> </div>`);
var detailsIndex = 0;
$.map(row_items, function(row_item, key){
$(".mark"+i).append(row_item.event);
$('.event-desc').ellipsis({ lines: 3 });
subscribe.button.setButtonStatus(row_item.row[1], 1, $("#event-box-"+row_item.row[0]), eventDetails[detailsIndex]);
detailsIndex++;
});
row_items = []; // reset
}
count++;
});
/* Just to insert Jerome Ferrari on events DELETE AFTER */
var jerome_item = `
<div class="col-md-6">
<a href="${app.get_vars().baseurl}event_details3">
<div class="mc-workshop-card card no-sponsor">
<div class="mc-workshop-img-card">
<div class="mc-card-img">
<img src="${app.get_vars().baseurl}resources/images/frontoffice/card/Jerome.png" class="card-img-top" alt="...">
</div>
<div class="mc-card-content">
<div class="mc-workshop-speaker">Jérôme Ferrari</div>
<div class="mc-workshop-title">La réalité romancée</div>
</div>
</div>
<div class="pt-3 d-flex align-items-center flex-wrap">
<div class="flex-item">
<div class="mc-workshop-session text-dark"><span class="font-weight-bold">6 séances</span> 18h d’atelier</div>
</div>
<div class="flex-item">
<div class="mc-workshop-status">date à venir</div>
</div>
<div class="flex-item mc-dot"><i class="fas fa-circle"></i></div>
<div class="flex-item">
<div class="mc-workshop-partner d-flex align-items-center flex-nowrap">
<span class="">Avec l’aide de</span>
<img class="ml-2" src="${app.get_vars().baseurl}resources/images/frontoffice/logo/logo-sud.svg" />
</div>
</div>
</div>
</div>
</a>
</div>`;
//$( ".card-deck.mark4" ).append(jerome_item);
// End jerome ferrari custom insert item
// Pagination Links below
var totalpages = result.mdata.pages;
var range = 3;
if (page > 1) {
var previous = page - 1;
page_link.append("<li class='page-item'><a href='"+app.get_vars().baseurl+"./#1' class='page-link' data-page='1'>" + "<<" + "</a></li>");
page_link.append("<li class='page-item'><a href='"+app.get_vars().baseurl+"./#" + previous + "' class='page-link' data-page='" + previous + "'>" + "<" + "</a></li>");
}
for (x = (page - range); x <= (page + range); x++) {
if ((x > 0) && (x <= totalpages)) {
if (x == page) page_link.append("<li class='page-item'><a href='"+app.get_vars().baseurl+"./#" + x + "' class='page-link pagination-active' data-page='" + x + "'>" + x + "</a></li>");
else page_link.append("<li class='page-item'><a href='"+app.get_vars().baseurl+"./#" + x + "' class='page-link' data-page='" + x + "'>" + x + "</a></li>");
}
}
if (page >= 1 && page < totalpages) {
var next = page + 1;
page_link.append("<li class='page-item'><a href='"+app.get_vars().baseurl+"./#" + next + "' class='page-link' data-page='" + next + "'>" + ">" + "</a></li>");
page_link.append("<li class='page-item'><a href='"+app.get_vars().baseurl+"./#" + totalpages + "' class='page-link' data-page='" + next + "'>" + ">>" + "</a></li>");
}
if(totalpages <= 1) {
page_link.css('display', 'none')
} else {
page_link.css('display', '')
}
}
} //end of if result.mdata is defined
},
"_margin" : function(records_count, i) {
if(i%12 === 0 || records_count === i)
return true;
else
return false;
},
"strip_tags" : function(element){
var whitelist = "p,a";
$(element).not(whitelist).each(function() {
var content = $(this).contents();
$(this).replaceWith(content);
});
}
},
"_change_hash" : function() {
var page = (location.hash).trim().replace("#", "");
if(parseInt(page)) {
window.location.hash = '';
} else {
events.filter(1);
$('#filter-month').val();
}
},
"getCookie" : function(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
},
"clear_cookie" : function() {
$.ajax({
url : app.get_vars().baseurl+"events/subscribe/clear_link_cookie",
type : "GET",
success : function(result) {
}
});
},
"moderation_notif" : function() {
/*Get my reservations info */
$.ajax({
url : app.get_vars().baseurl+"getModerationInfoForFirstLogin/",
type : "GET",
cache: false,
async:false,
data : {
},
beforeSend : function () {
// $("#events_list").append('<p class="text-center"><i class="fa fa-spin fa-spinner"/> '+app.get_vars()._app.notif.loading+'</p>');
},
success : function(result1) {
if(app.isalive(result1)) {
try {
if (result1.res_period) {
$('.remaining_res_based_on_mod').html(`${result1.remaining_res} ${result1.res_period}`);
/*Set dynamic data*/
$('span.max_res').html(result1.max_res);
$('span.res_period').html(result1.res_period);
$('span.mod_nr_count').html(result1.mod_nr_count);
$('span.res_period2').html(result1.res_period2);
$('span.when_can_reserve').html(result1.when_can_reserve);
if (result1.remaining_res == 0) {
$('.nr_exceeded_msg').removeAttr('hidden');
}
}
} catch (e) {}
finally {}
}
}
});
$('#moderation-notif-user').modal('show');
}
};
// Pass in jQuery.
})(jQuery, this);
$(function() {
$(window).on("orientationchange",function(){
if(window.orientation==0){
var m = $('.filter-box.desktop #filter-month').val();
var month = $('.filter-box.mobile #filter-month').val(m);
var t = $('.filter-box.desktop #filter-type').val();
var type = $('.filter-box.mobile #filter-type').val(t);
var c = $('.filter-box.desktop #filter-city').val();
var city = $('.filter-box.mobile #filter-city').val(c);
}else{
var m = $('.filter-box.mobile #filter-month').val();
var month = $('.filter-box.desktop #filter-month').val(m);
var t = $('.filter-box.mobile #filter-type').val();
var type = $('.filter-box.desktop #filter-type').val(t);
var c = $('.filter-box.mobile #filter-city').val();
var city = $('.filter-box.desktop #filter-city').val(c);
}
});
// Check Link Cookie
events.clear_cookie();
// events.show_session();
$('.hr-style').removeProp('border');
$("#collapse").on("hide.bs.collapse", function(){
$(".btn-filter-mobile").html('<i class="fa fa-plus"></i>');
});
$("#collapse").on("show.bs.collapse", function(){
$(".btn-filter-mobile").html('<i class="fa fa-minus"></i>');
});
$(window).on('hashchange', function(e) {
e.preventDefault();
var page = (location.hash).trim().replace("#", "");
page = (parseInt(page))?page:1;
if(page) {
events.filter(page);
}
return false;
}).trigger('hashchange');
// Scroll to top
$(document).on('click', '.page-link', function(){
$(".filter-view:visible")[0].scrollIntoView(true);
}).on('change', '.filter-select', function(){
$(".filter-view:visible")[0].scrollIntoView(true);
});
$(document).on('click', '#filter-box-mobile-toggle', function() {
$('#filter-box-mobile-toggle .plus').toggle();
$('#filter-box-mobile-toggle .minus').toggle();
});
// send events on filter change
$(document).on('change','#filter-month',function(){
dataLayer.push({'fo_filter': undefined});
dataLayer.push({'fo_filter': this.value});
});
$(document).on('change','#filter-type',function(){
dataLayer.push({'fo_filter': undefined});
dataLayer.push({'fo_filter': this.value});
});
$(document).on('change','#filter-city',function(){
dataLayer.push({'fo_filter': undefined});
dataLayer.push({'fo_filter': this.value});
});
if(notifyUserABoutModerationFeature == 'true') {
events.moderation_notif();
$('#agree-terms').on('click', function(event) {
/* Act on the event */
if (this.checked) {
$('.moderation-notif-modal-btn').removeClass('disabled');
} else {
$('.moderation-notif-modal-btn').addClass('disabled');
}
});
$('.moderation-notif-modal-btn').on('click', function(event) {
event.preventDefault();
/* Act on the event */
if ($('#agree-terms').prop('checked')) {
$.ajax({
url : app.get_vars().baseurl+"events/homepage/notif_moderation_feature",
data : {
notif : true
},
type: "POST"
});
$('#moderation-notif-user').modal('hide');
}
});
}
/* Filter options*/
$('.filter-events-options').on('change', function(event) {
event.preventDefault();
/* Act on the event */
events._change_hash();
});
if($('#workshop-ecriture').data('workshop-ecriture')===0){
$('#workshop-ecriture').attr('disabled', true)
}
if($('#workshop-oenologie').data('workshop-oenologie')===0){
$('#workshop-oenologie').attr('disabled', true)
}
/*let oenologie = false;
let ecriture = false;
$('#workshop-ecriture').on('click', function () {
oenologie = false
if(!ecriture) {
const filter = '?type=1'
events.filter(1, filter)
ecriture = true
} else {
events.filter(1, '')
ecriture = false
}
})
$('#workshop-oenologie').on('click', function () {
ecriture = false
if(!oenologie) {
const filter = '?type=2'
events.filter(1, filter)
oenologie = true
} else {
events.filter(1, '')
oenologie = false
}
})
*/
/* Implement dynamic atelier type filter */
$('.workshop-type-btn').click(function() {
if ($(this).is(':checked')) {
$("#filter .workshop-type-btn").removeClass("active");
//events.filter(1, '');
$(this).removeClass("active");
} else {
$("#filter .workshop-type-btn.active").removeClass("active");
$(this).addClass("active");
const filter = `?type=${$(this).attr("data-workshop-type")}`;
//events.filter(1, filter)
}
let btnChk = [];
$('.workshop-type-btn').each(function (){
if ($(this).is(':checked')) {
btnChk.push($(this).attr("data-workshop-type"));
// events.filter(1, '');
}
})
let workshop_s = '&workshop_session=';
let t_w = [];
if($('.presentiel input[type="checkbox"]').is(':checked'))
t_w.push("PRESENTIEL");
if($('.distance input[type="checkbox"]').is(':checked'))
t_w.push("DISTANCE");
if($('.enligne input[type="checkbox"]').is(':checked'))
t_w.push("ENLIGNE");
workshop_s += t_w.join(",");
const filter = `?type=${btnChk.join(",")}`;
event_update();
})
$( ".presentiel" ).click(function() {
$('.presentiel').toggleClass('active');
let btnChk = [];
$('.workshop-type-btn').each(function (){
if ($(this).is(':checked')) {
btnChk.push($(this).attr("data-workshop-type"));
// events.filter(1, '');
}
})
if ($('.presentiel input[type="checkbox"]').is(':checked')) {
$('.presentiel').addClass('w-type1');
let distance = '';
let enligne = '';
if($(".distance").hasClass('active'))distance = ',DISTANCE';
if($(".enligne").hasClass('active'))enligne = ',ENLIGNE';
event_update();
$('.presentiel input[type="checkbox"]').attr('checked', true);
} else {
$('.presentiel').removeClass('w-type1');
event_update();
$('.presentiel input[type="checkbox"]').attr('checked', false);
}
});
$( ".distance" ).click(function() {
let btnChk = [];
$('.workshop-type-btn').each(function (){
if ($(this).is(':checked')) {
btnChk.push($(this).attr("data-workshop-type"));
// events.filter(1, '');
}
})
$('.distance').toggleClass('active');
if ($('.distance input[type="checkbox"]').is(':checked')) {
$('.distance').addClass('w-type1');
let presentiel = '';
let enligne = '';
if($(".presentiel").hasClass('active'))presentiel = ',PRESENTIEL';
if($(".enligne").hasClass('active'))enligne = ',ENLIGNE';
event_update();
$('.distance input[type="checkbox"]').attr('checked', true);
} else {
$('.distance').removeClass('w-type1');
event_update();
$('.distance input[type="checkbox"]').attr('checked', false);
}
});
$( ".enligne" ).click(function() {
let btnChk = [];
$('.workshop-type-btn').each(function (){
if ($(this).is(':checked')) {
btnChk.push($(this).attr("data-workshop-type"));
// events.filter(1, '');
}
})
$('.enligne').toggleClass('active');
if ($('.enligne input[type="checkbox"]').is(':checked')) {
$('.enligne').addClass('w-type1');
let presentiel = '';
let distance = '';
if($(".presentiel").hasClass('active'))presentiel = ',PRESENTIEL';
if($(".distance").hasClass('active'))distance = ',DISTANCE';
event_update();
$('.enligne input[type="checkbox"]').attr('checked', true);
} else {
$('.enligne').removeClass('w-type1');
event_update();
$('.enligne input[type="checkbox"]').attr('checked', false);
}
});
function event_update(){
let btnChk = [];
$('.workshop-type-btn').each(function (){
if ($(this).is(':checked')) {
btnChk.push($(this).attr("data-workshop-type"));
// events.filter(1, '');
}
})
let workshop_s = '&workshop_session=';
let t_w = [];
if($('.presentiel input[type="checkbox"]').is(':checked'))
t_w.push("PRESENTIEL");
if($('.distance input[type="checkbox"]').is(':checked'))
t_w.push("DISTANCE");
if($('.enligne input[type="checkbox"]').is(':checked'))
t_w.push("ENLIGNE");
workshop_s += t_w.join(",");
let filter = `?type=${btnChk.join(",")}`;
if(btnChk.join(",") == ''){
filter = '';
if(t_w.join(",") != '')
workshop_s = workshop_s.replace("&","?")
}
if(t_w.join(",") == '')
workshop_s = '';
events.filter(1, filter + workshop_s);
}
event_update();
});