/*! * 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='',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('');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(" "+b)+"");m.$el.find("span").each(k);if(p!=null){u(p)}}function u(x){s[x]=''+s[x];s.push("");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('

'+app.get_vars()._app.notif.loading+'

'); }, 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( "
" + "

" + app.get_vars()._app.no_match_found + "

" + "
" ); } else { events_list.append( "
" + "

" + app.get_vars()._app.no_results_found + "

" + "
" ); } } 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 " ; fav_text='En partenariat avec Company For Madagascar'; } if ( (item.event_status[0]['event_status']=='CANCEL' && item.date_feature == 1) || (item.date_feature==2 && item.event_count == item.cancel_count) ) { annule = "{}]/g, '')+"/"+item.event_id+"' class='event-link'>ANNULÉ"; } // row_items.push({"event" : `
//
// //
//
//

`+ fav +` ${item.title}

// //

//
// `+fav_text+` //
//

${item.description}

//
//
//
// //
//
`, "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(``); $("#title-atelier").text(atelierTitle); // $(".mc-banner-container" ).css('display', 'none'); // var featured_item = ` //
//
//
// ${item.title} //
//
//
// //
//
//
// ${item.title} //
`; // 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 = `${item.title}`; } else { if(item.file_name) { thumbnail = `${item.title}`; } else { thumbnail = `
${JSON.parse(item.trailer)}
` } } // 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" : ``, "row" : [i, parseInt(event_schedule_id[2])]}); } if(events._format._margin(records_count, (i+1))){ events_list.append(`
`); 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 = ` `; //$( ".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("
  • " + "<<" + "
  • "); page_link.append("
  • " + "<" + "
  • "); } else { page_link.append("
  • " + "<" + "
  • "); } for (x = (page - range); x <= (page + range); x++) { if ((x > 0) && (x <= totalpages)) { if (x == page) page_link.append("
  • " + x + "
  • "); else page_link.append("
  • " + x + "
  • "); } } if (page >= 1 && page < totalpages) { var next = page + 1; page_link.append("
  • " + ">" + "
  • "); // page_link.append("
  • " + ">>" + "
  • "); } else { page_link.append("
  • " + ">" + "
  • "); } 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('

    '+app.get_vars()._app.notif.loading+'

    '); }, 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(''); }); $("#collapse").on("show.bs.collapse", function(){ $(".btn-filter-mobile").html(''); }); $(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(); });