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.
775 lines
41 KiB
775 lines
41 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.html("");
|
|
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 = '';
|
|
let buttonLabel = 'Détails atelier';
|
|
if(moment(item._now).isBefore(moment(item.event_status[0].reservation_start_date))) {
|
|
buttonLabel = "S'inscrire";
|
|
btype = "Date à venir"
|
|
} else if(moment(item._now).isAfter(moment(item.reservation_end_date))) {
|
|
buttonLabel = item.workshop_session === 'DISTANCE-PRESENTIEL'? 'Détails du cours':'Détails atelier';
|
|
if(item.workshop_session === 'DISTANCE-PRESENTIEL') {
|
|
btype = events.set_workshop_button_label(item)
|
|
} else {
|
|
btype = item.remaining_combined_seat === '0' ? 'Complet': '';
|
|
}
|
|
} else if(moment().isBetween(item.event_status[0].reservation_start_date, item.reservation_end_date, null ,'[]')) {
|
|
buttonLabel = 'Reserver';
|
|
if(item.workshop_session === 'DISTANCE-PRESENTIEL') {
|
|
btype = events.set_workshop_button_label(item)
|
|
} else {
|
|
btype = item.remaining_combined_seat === '0' ? 'Complet': '';
|
|
}
|
|
} else {
|
|
buttonLabel = item.workshop_session === 'DISTANCE-PRESENTIEL'? 'Détails du cours':'Détails atelier';
|
|
if(item.workshop_session === 'DISTANCE-PRESENTIEL') {
|
|
btype = events.set_workshop_button_label(item)
|
|
} else {
|
|
btype = '';
|
|
}
|
|
}
|
|
|
|
|
|
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>`
|
|
}
|
|
}
|
|
// Remove from list event number 42
|
|
//Ticket Dev #44739 prod - hide URL : https://ateliers.lemonde.fr/Alain-Frachon/53
|
|
|
|
if(item.event_id !== '53') {
|
|
let event_url = app.get_vars().baseurl + item.workshop_author.split(" ").join("-").replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '')+'/'+item.event_id
|
|
if(item.video_reserved) {
|
|
event_url = app.get_vars().baseurl+ 'cours-en-ligne-achat/'+item.event_id
|
|
}
|
|
row_items.push({"event" : `<div class="col-md-6" data-eventid='${item.event_id}'>
|
|
<a href='${event_url}'>
|
|
<div class="mc-workshop-card card no-sponsor">
|
|
<div class="mc-workshop-img-card">
|
|
<div class="cancel-overlay ${item.status_of_event == 'CANCEL' ? '': 'd-none'}">
|
|
<div class="cancelled-label">ANNULE</div>
|
|
</div>
|
|
<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 class="mc-overlay-workshop"></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 + ' Leçon' + ((item.event_videos.length > 1) ? 's' : '') + ' vidéo'+ ((item.event_videos.length > 1) ? 's' : '') : item.number_of_sessions+ ' séance'+ ((item.number_of_sessions > 1) ? 's' : '')}</span> ${(item.workshop_session === 'ENLIGNE' || item.workshop_session === 'DISTANCE') ? '-':''} ${hour}h${minute == 0 ? '' : minute < 10 ? '0' + minute : minute } ${(item.workshop_session === 'ENLIGNE' || item.workshop_session === 'DISTANCE') ? 'de cours':'d’atelier'}</div>
|
|
<div class="w-link">
|
|
${item.workshop_session === "ENLIGNE" ? 'Acheter': 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-PRESENTIEL" || item.workshop_session === "DISTANCE") ?'3': '1'}">
|
|
${item.workshop_session === "ENLIGNE"?'Cours en ligne': (item.workshop_session === "DISTANCE-PRESENTIEL" || item.workshop_session === "DISTANCE") ?'Cours du soir': 'Atelier'}
|
|
</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
|
|
$('#workshop-count-per-page').html(count)
|
|
}
|
|
|
|
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='./#1' class='page-link' data-page='1'>" + "<<" + "</a></li>");
|
|
page_link.append("<li class='page-item'><a href='./#" + previous + "' class='page-link-previous' data-page='" + previous + "'>" + "<" + "</a></li>");
|
|
|
|
} else {
|
|
page_link.append("<li class='page-item'><a href='./#1' class='page-link-previous disabled' data-page='1'>" + "<" + "</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='./#" + x + "' class='page-link pagination-active' data-page='" + x + "'>" + x + "</a></li>");
|
|
else page_link.append("<li class='page-item'><a href='./#" + 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='./#" + next + "' class='page-link-next' data-page='" + next + "'>" + ">" + "</a></li>");
|
|
// page_link.append("<li class='page-item'><a href='./#" + totalpages + "' class='page-link' data-page='" + next + "'>" + ">>" + "</a></li>");
|
|
} else {
|
|
page_link.append("<li class='page-item'><a href='./#" + next + "' class='page-link-next disabled' 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%8 === 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);
|
|
});
|
|
}
|
|
},
|
|
"set_workshop_button_label": function(item) {
|
|
let btype = item.presentiel.p_remaining_combined_seat == 0 ? 'Complet': '';
|
|
if(item.presentiel.p_remaining_combined_seat == 0) {
|
|
/** distance workshop always available */
|
|
btype = '';
|
|
// btype = item.distance.d_remaining_combined_seat == 0 ? 'Complet': '';
|
|
}
|
|
return btype
|
|
},
|
|
"_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(e){
|
|
e.preventDefault();
|
|
$(".page-link").removeClass("pagination-active");
|
|
$(this).addClass("pagination-active");
|
|
event_update($(this).attr("data-page"));
|
|
$('html, body').animate({ scrollTop: $('.mc-workshop-list').offset().top }, 'slow');
|
|
//$(".filter-view:visible")[0].scrollIntoView(true);
|
|
}).on('change', '.filter-select', function(){
|
|
event_update($(this).attr("data-page"));
|
|
$('html, body').animate({ scrollTop: $('.mc-workshop-list').offset().top }, 'slow');
|
|
//$(".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)
|
|
}
|
|
|
|
/* Implement dynamic atelier type filter */
|
|
|
|
// FILTER BUTTON
|
|
// Categories button
|
|
$('.filter-cat.workshop-type-btn').click(function() {
|
|
$('.select-all').removeClass('active');
|
|
if ($(this).is(':checked')) {
|
|
$(".filter-cat.workshop-type-btn").removeClass("active");
|
|
$(this).removeClass("active");
|
|
} else {
|
|
$(".filter-cat.workshop-type-btn.active").removeClass("active");
|
|
$(this).addClass("active");
|
|
const filter = `?type=${$(this).attr("data-workshop-type")}`;
|
|
}
|
|
let btnChk = [];
|
|
$('.filter-cat.workshop-type-btn').each(function (){
|
|
if ($(this).is(':checked')) {
|
|
btnChk.push($(this).attr("data-workshop-type"));
|
|
}
|
|
});
|
|
|
|
event_update();
|
|
})
|
|
|
|
// Tous button
|
|
$( ".select-all" ).click(function() {
|
|
$('.select-all').toggleClass('active');
|
|
$('input[type="checkbox"]').prop('checked', false);
|
|
$('.atelier').removeClass('active');
|
|
$('.soir').removeClass('active');
|
|
$('.enligne').removeClass('active');
|
|
$('.dropdown button').removeClass('active');
|
|
if($(this).hasClass('active')){
|
|
event_update();
|
|
} else {
|
|
event_update();
|
|
}
|
|
});
|
|
|
|
// Atelier Presentiel button
|
|
$( ".atelier" ).click(function() {
|
|
let btnChk = [];
|
|
$('.atelier').toggleClass('active');
|
|
|
|
$('.workshop-type-btn').each(function (){
|
|
if ($(this).is(':checked')) {
|
|
btnChk.push($(this).attr("data-workshop-type"));
|
|
// events.filter(1, '');
|
|
}
|
|
});
|
|
|
|
$('.atelier input[type="checkbox"]').prop('checked', true);
|
|
|
|
if($(this).hasClass('active')){
|
|
$('.select-all').removeClass('active');
|
|
$('.presentiel').addClass('w-type1');
|
|
let distance = '';
|
|
let enligne = '';
|
|
if($(".soir").hasClass('active')) { distance = ',DISTANCE-PRESENTIEL,DISTANCE'; }
|
|
if($(".enligne").hasClass('active')) { enligne = ',ENLIGNE'; }
|
|
|
|
event_update();
|
|
}
|
|
|
|
if(!$(this).hasClass('active')){
|
|
$('.atelier input[type="checkbox"]').prop('checked', false);
|
|
$('.atelier').removeClass('w-type1');
|
|
event_update();
|
|
}
|
|
});
|
|
|
|
// Atelier Distance button
|
|
$( ".soir" ).click(function() {
|
|
let btnChk = [];
|
|
$('.workshop-type-btn').each(function (){
|
|
if ($(this).is(':checked')) {
|
|
btnChk.push($(this).attr("data-workshop-type"));
|
|
}
|
|
})
|
|
$('.soir').toggleClass('active');
|
|
$('.soir input[type="checkbox"]').prop('checked', true);
|
|
if($(this).hasClass('active')){
|
|
$('.select-all').removeClass('active');
|
|
$('.soir').addClass('w-type1');
|
|
let presentiel = '';
|
|
let enligne = '';
|
|
if($(".atelier").hasClass('active')) { presentiel = ',PRESENTIEL,DISTANCIEL' };
|
|
if($(".enligne").hasClass('active')) { enligne = ',ENLIGNE'};
|
|
|
|
event_update();
|
|
}
|
|
if(!$(this).hasClass('active')){
|
|
$('.soir input[type="checkbox"]').prop('checked', false);
|
|
$('.soir').removeClass('w-type1');
|
|
event_update();
|
|
}
|
|
});
|
|
|
|
// Cours en ligne button
|
|
$( ".enligne" ).click(function() {
|
|
let btnChk = [];
|
|
$('.workshop-type-btn').each(function (){
|
|
|
|
if ($(this).is(':checked')) {
|
|
btnChk.push($(this).attr("data-workshop-type"));
|
|
}
|
|
})
|
|
$('.enligne').toggleClass('active');
|
|
|
|
$('.enligne input[type="checkbox"]').prop('checked', true);
|
|
if($(this).hasClass('active')){
|
|
$('.select-all').removeClass('active');
|
|
$('.enligne').addClass('w-type1');
|
|
let presentiel = '';
|
|
let distance = '';
|
|
if($(".atelier").hasClass('active')) { presentiel = ',PRESENTIEL,DISTANCIEL'; }
|
|
if($(".soir").hasClass('active')) { distance = ',DISTANCE-PRESENTIEL,DISTANCE'; }
|
|
|
|
event_update();
|
|
}
|
|
if(!$(this).hasClass('active')){
|
|
$('.enligne input[type="checkbox"]').prop('checked', false);
|
|
$('.enligne').removeClass('w-type1');
|
|
event_update();
|
|
}
|
|
});
|
|
function event_update(page = '1'){
|
|
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($('.atelier input[type="checkbox"]').is(':checked')){
|
|
t_w.push("PRESENTIEL");
|
|
t_w.push("DISTANCIEL");
|
|
}
|
|
|
|
if($('.soir input[type="checkbox"]').is(':checked')){
|
|
t_w.push("DISTANCE-PRESENTIEL");
|
|
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(page, filter + workshop_s);
|
|
}
|
|
event_update();
|
|
|
|
|
|
});
|
|
|