/*! * 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.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 = '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 = `
${btype}
`; 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 = `${item.title}`; } else { if(item.file_name) { thumbnail = `${item.title}`; } else { thumbnail = `
${JSON.parse(item.trailer)}
` } } 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 } 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("
  • " + "<" + "
  • "); } 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("
  • " + ">>" + "
  • "); } 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('

    '+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(){ $(".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(); });