PageSourceSearch

https://www.alt-opel.eu/wp-content/plugins/modern-events-calendar-lite/assets/js/frontend.js?ver=6.5.6

js alt-opel.eu collected 2026-09-25 01:48:03 UTC 244,659 bytes, 5,740 lines download raw bytes

1// MEC Single Event Displayer
2var mecSingleEventDisplayer =
3{
4    getSinglePage: function(id, occurrence, time, ajaxurl, layout, image_popup)
5    {
6        if(jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
7        jQuery('.mec-modal-result').addClass('mec-modal-preloader');
8
9        jQuery.ajax(
10        {
11            url: ajaxurl,
12            data: "action=mec_load_single_page&id=" + id + (occurrence != null ? "&occurrence=" + occurrence : "") + (time != null ? "&time=" + time : "") + "&layout=" + layout,
13            type: "get",
14            success: function(response)
15            {
16                jQuery('.mec-modal-result').removeClass("mec-modal-preloader");
17                jQuery.featherlight(response);
18
19                setTimeout(function()
20                {
21                    if(typeof grecaptcha !== 'undefined' && jQuery('#g-recaptcha').length > 0)
22                    {
23                        grecaptcha.render("g-recaptcha", {
24                            sitekey: mecdata.recapcha_key
25                        });
26                    }
27                }, 1000);
28
29                if(image_popup != 0)
30                {
31                    if(jQuery('.featherlight-content .mec-events-content a img').length > 0)
32                    {
33                        jQuery('.featherlight-content .mec-events-content a img').each(function()
34                        {
35                            jQuery(this).closest('a').attr('data-featherlight', 'image');
36                        });
37                    }
38                }
39                else
40                {
41                    jQuery('.featherlight-content .mec-events-content a img').remove();
42                    jQuery('.featherlight-content .mec-events-content img').remove();
43                }
44
45                if(typeof mecdata.enableSingleFluent != 'undefined' && mecdata.enableSingleFluent) mecFluentSinglePage();
46            },
47            error: function () { }
48        });
49    }
50};
51
52var mec_search_callback1;
53var mec_search_callback2;
54
55// MEC SEARCH FORM PLUGIN
56(function ($) {
57    $.fn.mecSearchForm = function (options) {
58        if(typeof settings != 'undefined') console.log(settings.callback);
59        // Default Options
60        var settings = $.extend({
61            // These are the defaults.
62            id: 0,
63            refine: 0,
64            ajax_url: '',
65            search_form_element: '',
66            atts: '',
67            callback: function () { }
68        }, options);
69
70        if(typeof mec_search_callback1 === 'undefined') mec_search_callback1 = settings.callback;
71        else if(typeof mec_search_callback2 === 'undefined') mec_search_callback2 = settings.callback;
72
73        var $event_cost_min = $("#mec_sf_event_cost_min_" + settings.id);
74        var $event_cost_max = $("#mec_sf_event_cost_max_" + settings.id);
75        var $time_start = $("#mec_sf_timepicker_start_" + settings.id);
76        var $time_end = $("#mec_sf_timepicker_end_" + settings.id);
77        var $s = $("#mec_sf_s_" + settings.id);
78        var $address = $("#mec_sf_address_s_" + settings.id);
79        var $date_start = $('#mec_sf_date_start_' + settings.id);
80        var $date_end = $('#mec_sf_date_end_' + settings.id);
81        var $event_type = $('#mec_sf_event_type_' + settings.id);
82        var $event_type_2 = $('#mec_sf_event_type_2_' + settings.id);
83        var $attribute = $('#mec_sf_attribute_' + settings.id);
84        var $reset = $("#mec_search_form_" + settings.id + '_reset');
85        var last_field;
86
87        // Trigger
88        trigger();
89
90        $s.on('change', function (e) {
91            last_field = 's';
92            search();
93        });
94
95        $address.on('change', function (e) {
96            last_field = 'address';
97            search();
98        });
99
100        $event_cost_min.on('change', function (e) {
101            last_field = 'cost-min';
102            $event_cost_max.attr('min', $(this).val());
103            search();
104        });
105
106        $event_cost_max.on('change', function (e) {
107            last_field = 'cost-max';
108            $event_cost_min.attr('max', $(this).val());
109            search();
110        });
111
112        // Timepicker
113        if ($time_start.length) {
114            var format = (($time_start.data('format') === 12) ? 'hh:mm p' : 'HH:mm');
115            $time_start.timepicker(
116            {
117                timeFormat: format,
118                minTime: new Date(0, 0, 0, 0, 0, 0),
119                maxTime: new Date(0, 0, 0, 23, 55, 0),
120                interval: 5,
121                dropdown: false,
122                change: function () {
123                    last_field = 'time-start';
124                    search();
125                }
126            });
127
128            $time_end.timepicker(
129            {
130                timeFormat: format,
131                minTime: new Date(0, 0, 0, 0, 0, 0),
132                maxTime: new Date(0, 0, 0, 23, 55, 0),
133                interval: 5,
134                dropdown: false,
135                change: function () {
136                    last_field = 'time-end';
137                    search();
138                }
139            });
140        }
141
142        var $month = $("#mec_sf_month_" + settings.id);
143        var $year = $("#mec_sf_year_" + settings.id);
144        var $month_or_year = $("#mec_sf_month_" + settings.id + ', ' + "#mec_sf_year_" + settings.id);
145
146        $month_or_year.on('change', function (e) {
147            last_field = 'date-dropdown';
148
149            var mec_month_val = $month.val();
150            var mec_year_val = $year.val();
151
152            if ((mec_month_val !== 'none' && mec_year_val !== 'none') || ((mec_month_val === 'none' && mec_year_val === 'none'))) search();
153        });
154
155        $date_end.on('change', function () {
156            last_field = 'date-end';
157            search();
158        });
159
160        $event_type.on('change', function (e) {
161            last_field = 'event-type';
162            search();
163        });
164
165        $event_type_2.on('change', function (e) {
166            last_field = 'event-type-2';
167            search();
168        });
169
170        $attribute.on('change', function (e) {
171            last_field = 'attribute';
172            search();
173        });
174
175        if (settings.fields && settings.fields.length > 0) {
176            for (var k in settings.fields) {
177                $("#mec_sf_" + settings.fields[k] + '_' + settings.id).on('change', function (e) {
178                    search();
179                });
180            }
181        }
182
183        // Reset
184        if ($reset.length) {
185            $reset.on('click', function (e) {
186                reset();
187            });
188        }
189
190        function get_fields(){
191
192            return [
193                'state',
194                'city',
195                'region',
196                'region',
197                'street',
198                'postal_code',
199            ];
200        }
201
202        function trigger() {
203            $("#mec_sf_category_" + settings.id).off('change').on('change', function (e) {
204                last_field = 'category';
205                search();
206            });
207
208            $("#mec_sf_location_" + settings.id).off('change').on('change', function (e) {
209                last_field = 'location';
210                search();
211            });
212
213            $("#mec_sf_organizer_" + settings.id).off('change').on('change', function (e) {
214                last_field = 'organizer';
215                search();
216            });
217
218            $("#mec_sf_speaker_" + settings.id).off('change').on('change', function (e) {
219                last_field = 'speaker';
220                search();
221            });
222
223            $("#mec_sf_tag_" + settings.id).off('change').on('change', function (e) {
224                last_field = 'tag';
225                search();
226            });
227
228            $("#mec_sf_label_" + settings.id).off('change').on('change', function (e) {
229                last_field = 'label';
230                search();
231            });
232
233            var fields = get_fields();
234            $.each(fields,function(i,field){
235
236                $("#mec_sf_"+ field +"_" + settings.id).off('change').on('change', function (e) {
237                    last_field = field;
238                    search();
239                });
240            });
241        }
242
243        function search() {
244            var $category = $("#mec_sf_category_" + settings.id);
245            var $location = $("#mec_sf_location_" + settings.id);
246            var $organizer = $("#mec_sf_organizer_" + settings.id);
247            var $speaker = $("#mec_sf_speaker_" + settings.id);
248            var $tag = $("#mec_sf_tag_" + settings.id);
249            var $label = $("#mec_sf_label_" + settings.id);
250
251            var s = $s.length ? $s.val() : '';
252            var address = $address.length ? $address.val() : '';
253            var location = $location.length ? $location.val() : '';
254            var organizer = $organizer.length ? $organizer.val() : '';
255            var speaker = $speaker.length ? $speaker.val() : '';
256            var tag = $tag.length ? $tag.val() : '';
257            var label = $label.length ? $label.val() : '';
258            var month = $month.length ? $month.val() : '';
259            var year = $year.length ? $year.val() : '';
260            var event_type = $event_type.length ? $event_type.val() : '';
261            var event_type_2 = $event_type_2.length ? $event_type_2.val() : '';
262            var attribute = $attribute.length ? $attribute.val() : '';
263
264            var start = $date_start.length ? $date_start.val() : '';
265            var end = $date_end.length ? $date_end.val() : '';
266
267            var cost_min = $event_cost_min.length ? $event_cost_min.val() : '';
268            var cost_max = $event_cost_max.length ? $event_cost_max.val() : '';
269
270            var time_start = $time_start.length ? $time_start.val() : '';
271            var time_end = $time_end.length ? $time_end.val() : '';
272
273            var category;
274            if ($category.prop('tagName') && $category.prop('tagName').toLowerCase() === 'div') {
275                category = [];
276                $category.find($('select')).each(function () {
277                    category.push( $(this).val() );
278                });
279                category = category.join(',');
280            }
281            else category = $category.length ? $category.val() : '';
282
283            if (year === 'none' && month === 'none') {
284                year = '';
285                month = '';
286            }
287
288            if(!year) year = '';
289
290            var addation_attr = '';
291            if (settings.fields && settings.fields.length > 0) {
292                for (var k in settings.fields) {
293                    var field = '#mec_sf_' + settings.fields[k] + '_' + settings.id;
294                    var val = $(field).length ? $(field).val() : '';
295
296                    addation_attr += '&sf[' + settings.fields[k] + ']=' + val;
297                }
298            }
299
300            // Search Parameters
301            var sf = 'sf[s]=' + s + '&sf[address]=' + address + '&sf[cost-min]=' + cost_min + '&sf[cost-max]=' + cost_max + '&sf[time-start]=' + time_start + '&sf[time-end]=' + time_end + '&sf[month]=' + month + '&sf[year]=' + year + '&sf[start]=' + start + '&sf[end]=' + end + '&sf[category]=' + category + '&sf[location]=' + location + '&sf[organizer]=' + organizer + '&sf[speaker]=' + speaker + '&sf[tag]=' + tag + '&sf[label]=' + label + '&sf[event_type]=' + event_type + '&sf[event_type_2]=' + event_type_2 + '&sf[attribute]=' + attribute + addation_attr;
302
303            var fields = get_fields();
304            $.each(fields, function(i, field)
305            {
306                if($("#mec_sf_"+ field +"_" + settings.id).length)
307                {
308                    v = $("#mec_sf_"+ field +"_" + settings.id).val();
309                    sf += '&sf['+ field +']=' + v;
310                }
311            });
312
313            // Refine Parameters
314            if(settings.refine) refine(sf);
315
316            // Attributes
317            var atts = settings.atts + '&' + sf;
318
319            // Search
320            if(typeof mec_search_callback1 !== 'undefined') mec_search_callback1(atts);
321            if(typeof mec_search_callback2 !== 'undefined') mec_search_callback2(atts);
322        }
323
324        function reset() {
325            var $category = $("#mec_sf_category_" + settings.id);
326            var $location = $("#mec_sf_location_" + settings.id);
327            var $organizer = $("#mec_sf_organizer_" + settings.id);
328            var $speaker = $("#mec_sf_speaker_" + settings.id);
329            var $tag = $("#mec_sf_tag_" + settings.id);
330            var $label = $("#mec_sf_label_" + settings.id);
331
332            if ($category.length && $category.prop('tagName') && $category.prop('tagName').toLowerCase() === 'div') {
333                $category.find('select').each(function () {
334                    $(this).val(null).trigger('change');
335                });
336                $category.find('select').select2();
337            }
338            else if ($category.length) {
339
340                $category.val(null);
341                if(jQuery().niceSelect) jQuery('.mec-fluent-wrap').find('.mec-filter-content').find('select').niceSelect('update');
342            }
343
344            if ($location.length) $location.val(null);
345            if ($organizer.length) $organizer.val(null);
346            if ($speaker.length) $speaker.val(null);
347            if ($tag.length) $tag.val(null);
348            if ($label.length) $label.val(null);
349            if ($s.length) $s.val(null);
350            if ($address.length) $address.val(null);
351            if ($month.length) $month.val(null);
352            if ($year.length) $year.val(null);
353            if ($event_cost_min.length) $event_cost_min.val(null);
354            if ($event_cost_max.length) $event_cost_max.val(null);
355            if ($date_start.length) $date_start.val(null);
356            if ($date_end.length) $date_end.val(null);
357            if ($time_start.length) $time_start.val(null);
358            if ($time_end.length) $time_end.val(null);
359
360            var fields = get_fields();
361            $.each(fields,function(i,field)
362            {
363                if($("#mec_sf_"+ field +"_" + settings.id).length)
364                {
365                    $("#mec_sf_"+ field +"_" + settings.id).val(null);
366                    if($("#mec_sf_"+ field +"_" + settings.id).is('select') && jQuery().niceSelect)
367                    {
368                        jQuery("#mec_sf_"+ field +"_" + settings.id).niceSelect('update');
369                    }
370                }
371            });
372
373            // Search Again
374            setTimeout(function () {
375                search();
376            }, 200);
377        }
378
379        function refine(sf) {
380            var $category = $("#mec_sf_category_" + settings.id);
381            var $location = $("#mec_sf_location_" + settings.id);
382            var $organizer = $("#mec_sf_organizer_" + settings.id);
383            var $speaker = $("#mec_sf_speaker_" + settings.id);
384            var $tag = $("#mec_sf_tag_" + settings.id);
385            var $label = $("#mec_sf_label_" + settings.id);
386
387            var category_type;
388            if ($category.length && $category.prop('tagName') && $category.prop('tagName').toLowerCase() === 'div') category_type = 'checkboxes';
389            else if ($category.length) category_type = 'dropdown';
390
391            $.ajax(
392            {
393                url: settings.ajax_url,
394                data: "action=mec_refine_search_items&" + sf + '&last_field=' + last_field + '&category_type=' + category_type + '&id=' + settings.id,
395                dataType: "json",
396                type: "post",
397                success: function (response) {
398                    // Categories
399                    if (typeof response.categories !== 'undefined' && response.categories !== '') {
400                        // Checkboxes
401                        if ($category.length && $category.prop('tagName') && $category.prop('tagName').toLowerCase() === 'div') {
402                            $category.html(response.categories);
403                        }
404                        // Dropdown
405                        else if ($category.length) {
406                            $category.replaceWith(response.categories)
407                        }
408
409                        // Categories Search bar
410                        if ( jQuery(".mec-searchbar-category-wrap select").length > 0 && jQuery().niceSelect) jQuery(".mec-searchbar-category-wrap select").niceSelect();
411                    }
412
413                    // Locations
414                    if (typeof response.locations !== 'undefined' && response.locations !== '') {
415                        $location.replaceWith(response.locations)
416                    }
417
418                    // Organizers
419                    if (typeof response.organizers !== 'undefined' && response.organizers !== '') {
420                        $organizer.replaceWith(response.organizers)
421                    }
422
423                    // Speakers
424                    if (typeof response.speakers !== 'undefined' && response.speakers !== '') {
425                        $speaker.replaceWith(response.speakers)
426                    }
427
428                    // Labels
429                    if (typeof response.labels !== 'undefined' && response.labels !== '') {
430                        $label.replaceWith(response.labels)
431                    }
432
433                    // Tags
434                    if (typeof response.tags !== 'undefined' && response.tags !== '') {
435                        $tag.replaceWith(response.tags)
436                    }
437
438                    // Trigger
439                    trigger();
440                },
441                error: function () { }
442            });
443        }
444    };
445}(jQuery));
446
447jQuery(document).ready(function ($) {
448    // Select2
449    if ( jQuery(".mec-fes-form-cntt #mec-location select").length > 0 ) jQuery(".mec-fes-form-cntt #mec-location select").select2();
450    if ( jQuery(".mec-fes-form-cntt #mec-organizer select").length > 0 ) jQuery(".mec-fes-form-cntt #mec-organizer select").select2();
451    // Location select2
452    if ( jQuery("#mec_location_id").length > 0 ) jQuery("#mec_location_id").select2();
453    // Organizer Select2
454    if ( jQuery("#mec_organizer_id").length > 0 ) jQuery("#mec_organizer_id").select2();
455    // Categories Search bar
456    if ( jQuery(".mec-searchbar-category-wrap select").length > 0 ) jQuery(".mec-searchbar-category-wrap select").select2();
457
458    jQuery(".mec-search-form.mec-totalcal-box").find(".mec-search-reset-button").parents().eq(2).addClass("mec-there-reset-button");
459
460    jQuery(".mec-search-form.mec-totalcal-box").find(".mec-minmax-event-cost").parent().find(".mec-text-address-search").addClass("with-mec-cost");
461    jQuery(".mec-search-form.mec-totalcal-box").find(".mec-text-address-search").parent().find(".mec-minmax-event-cost").addClass("with-mec-address");
462
463    /** New Searchbar JS */
464    jQuery(".mec-full-calendar-search-ends").find(".mec-text-input-search").parent().find(".mec-tab-loader").removeClass("col-md-12").addClass("col-md-6");
465    jQuery(".mec-search-form.mec-totalcal-box").find(".mec-text-input-search").parent().find(".mec-date-search").parent().find(".mec-text-input-search").addClass("col-md-6");
466    jQuery(".mec-search-form.mec-totalcal-box").find(".mec-text-input-search").parent().find(".mec-time-picker-search").parent().find(".mec-text-input-search").addClass("col-md-6");
467    jQuery(".mec-full-calendar-search-ends").find(".mec-text-input-search").addClass("col-md-12").parent().find(".mec-time-picker-search").addClass("col-md-6");
468    jQuery(".mec-search-form.mec-totalcal-box").find(".mec-date-search").parent().find(".mec-time-picker-search").addClass("with-mec-date-search");
469    jQuery(".mec-search-form.mec-totalcal-box").find(".mec-time-picker-search").parent().find(".mec-date-search").addClass("with-mec-time-picker");
470
471
472    jQuery('#mec-gCalendar-wrap .openMonthFilter').on('click', function(e){
473        jQuery(this).toggleClass('open');
474    });
475
476    jQuery('body').on('click', function(e){
477        jQuery('#mec-gCalendar-wrap .openMonthFilter').removeClass('open');
478    });
479
480});
481
482jQuery(window).on('load', function()
483{
484    jQuery(".single-mec-events").find(".mejs-controls button").addClass("mejs")
485});
486
487// MEC FULL CALENDAR PLUGIN
488(function ($) {
489    $.fn.mecFullCalendar = function (options) {
490        // Default Options
491        var settings = $.extend({
492            // These are the defaults.
493            id: 0,
494            atts: '',
495            ajax_url: '',
496            sf: {},
497            skin: '',
498        }, options);
499
500        // Set onclick Listeners
501        setListeners();
502
503        mecFluentCurrentTimePosition();
504        mecFluentCustomScrollbar();
505
506        var sf;
507
508        function setListeners() {
509            // Search Widget
510            if (settings.sf.container !== '') {
511                sf = $(settings.sf.container).mecSearchForm({
512                    id: settings.id,
513                    refine: settings.sf.refine,
514                    ajax_url: settings.ajax_url,
515                    atts: settings.atts,
516                    callback: function (atts) {
517                        settings.atts = atts;
518                        search();
519                    }
520                });
521            }
522
523            // Add the onclick event
524            $("#mec_skin_" + settings.id + " .mec-totalcal-box .mec-totalcal-view span:not(.mec-fluent-more-views-icon):not(.mec-fluent-more-views-content)").on('click', function (e) {
525                e.preventDefault();
526                var skin = $(this).data('skin');
527                var mec_month_select = $('#mec_sf_month_' + settings.id);
528                var mec_year_select = $('#mec_sf_year_' + settings.id);
529
530                if (mec_year_select.val() == 'none') {
531                    mec_year_select.find('option').each(function () {
532                        var option_val = $(this).val();
533                        if (option_val == mecdata.current_year) mec_year_select.val(option_val);
534                    });
535                }
536
537                if (mec_month_select.val() == 'none') {
538                    mec_month_select.find('option').each(function () {
539                        var option_val = $(this).val();
540                        if (option_val == mecdata.current_month) mec_month_select.val(option_val);
541                    });
542                }
543
544                if (skin == 'list' || skin == 'grid' || skin == 'agenda') {
545                    var mec_filter_none = '<option class="mec-none-item" value="none">' + $('#mec-filter-none').val() + '</option>';
546                    if (mec_month_select.find('.mec-none-item').length == 0) mec_month_select.prepend(mec_filter_none);
547                    if (mec_year_select.find('.mec-none-item').length == 0) mec_year_select.prepend(mec_filter_none);
548                }
549                else {
550                    if (mec_month_select.find('.mec-none-item').length != 0) mec_month_select.find('.mec-none-item').remove();
551                    if (mec_year_select.find('.mec-none-item').length != 0) mec_year_select.find('.mec-none-item').remove();
552                }
553
554                $("#mec_skin_" + settings.id + " .mec-totalcal-box .mec-totalcal-view span").removeClass('mec-totalcalview-selected')
555                $(this).addClass('mec-totalcalview-selected');
556                if ($(this).closest('.mec-fluent-more-views-content').length > 0) {
557                    $('.mec-fluent-more-views-icon').addClass('active');
558                    $('.mec-fluent-more-views-content').removeClass('active');
559                } else {
560                    $('.mec-fluent-more-views-icon').removeClass('active');
561                }
562
563                loadSkin(skin);
564            });
565        }
566
567        function loadSkin(skin) {
568            // Set new Skin
569            settings.skin = skin;
570
571            // Add Loading Class
572            if(jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
573            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
574
575            var $month_picker = $("#mec_sf_month_" + settings.id);
576            var $year_picker = $("#mec_sf_year_" + settings.id);
577
578            // Add Month & Year
579            if(settings.atts.indexOf('sf[month]') <= -1 && $month_picker.length && $year_picker.length)
580            {
581                settings.atts += '&sf[month]='+$month_picker.val()+'&sf[year]='+$year_picker.val();
582            }
583
584            $.ajax({
585                url: settings.ajax_url,
586                data: "action=mec_full_calendar_switch_skin&skin=" + skin + "&" + settings.atts + "&apply_sf_date=1&sed=" + settings.sed_method,
587                dataType: "json",
588                type: "post",
589                success: function (response) {
590                    $("#mec_full_calendar_container_" + settings.id).html(response);
591
592                    // Remove loader
593                    $('.mec-modal-result').removeClass("mec-month-navigator-loading");
594
595                    // Focus First Active Day
596                    mecFocusDay(settings);
597
598                    mecFluentCurrentTimePosition();
599                    mecFluentCustomScrollbar();
600
601                    jQuery(document).trigger( 'mec_load_skin_success', $("#mec_full_calendar_container_" + settings.id) );
602                },
603                error: function () { }
604            });
605        }
606
607        function search() {
608            // Add Loading Class
609            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
610            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
611
612            $.ajax({
613                url: settings.ajax_url,
614                data: "action=mec_full_calendar_switch_skin&skin=" + settings.skin + "&" + settings.atts + "&apply_sf_date=1",
615                dataType: "json",
616                type: "post",
617                success: function (response) {
618                    if( typeof response === 'string' ){
619
620                        $("#mec_full_calendar_container_" + settings.id).html(response);
621                    }
622
623                    // Remove loader
624                    $('.mec-modal-result').removeClass("mec-month-navigator-loading");
625
626                    // Focus First Active Day
627                    mecFocusDay(settings);
628
629                    // Focus First Active Week
630                    mec_focus_week(settings.id);
631
632                    mecFluentCurrentTimePosition();
633                    mecFluentCustomScrollbar();
634
635                    jQuery(document).trigger( 'mec_search_success', $("#mec_full_calendar_container_" + settings.id) );
636                },
637                error: function () { }
638            });
639        }
640    };
641
642}(jQuery));
643
644// MEC YEARLY VIEW PLUGIN
645(function ($) {
646    $.fn.mecYearlyView = function (options) {
647        var active_year;
648
649        // Default Options
650        var settings = $.extend({
651            // These are the defaults.
652            today: null,
653            id: 0,
654            events_label: 'Events',
655            event_label: 'Event',
656            year_navigator: 0,
657            atts: '',
658            next_year: {},
659            sf: {},
660            ajax_url: '',
661        }, options);
662
663        mecFluentYearlyUI(settings.id, settings.year_id);
664
665        // Initialize Year Navigator
666        if (settings.year_navigator) initYearNavigator();
667
668        // Set onclick Listeners
669        setListeners();
670
671        // load more
672        $(document).on("click", "#mec_skin_events_" + settings.id + " .mec-load-more-button", function () {
673            var year = $(this).parent().parent().parent().data('year-id');
674            loadMoreButton(year);
675        });
676
677        // Search Widget
678        if (settings.sf.container !== '') {
679            sf = $(settings.sf.container).mecSearchForm({
680                id: settings.id,
681                refine: settings.sf.refine,
682                ajax_url: settings.ajax_url,
683                atts: settings.atts,
684                callback: function (atts) {
685                    settings.atts = atts;
686                    active_year = $('.mec-yearly-view-wrap .mec-year-navigator').filter(function () {
687                        return $(this).css('display') == "block";
688                    });
689                    active_year = parseInt(active_year.find('h2').text());
690                    search(active_year);
691                }
692            });
693        }
694
695        function initYearNavigator() {
696            // Add onclick event
697            $("#mec_skin_" + settings.id + " .mec-load-year").off("click").on("click", function () {
698                var year = $(this).data("mec-year");
699                setYear(year);
700            });
701        }
702
703        function search(year) {
704            // Add Loading Class
705            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
706            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
707
708            $.ajax({
709                url: settings.ajax_url,
710                data: "action=mec_yearly_view_load_year&mec_year=" + year + "&" + settings.atts + "&apply_sf_date=1",
711                dataType: "json",
712                type: "post",
713                success: function (response) {
714                    active_year = response.current_year.year;
715
716                    // Append Year
717                    $("#mec_skin_events_" + settings.id).html('<div class="mec-year-container" id="mec_yearly_view_year_' + settings.id + '_' + response.current_year.id + '" data-year-id="' + response.current_year.id + '">' + response.year + '</div>');
718
719                    // Append Year Navigator
720                    $("#mec_skin_" + settings.id + " .mec-yearly-title-sec").append('<div class="mec-year-navigator" id="mec_year_navigator_' + settings.id + '_' + response.current_year.id + '">' + response.navigator + '</div>');
721
722                    // Re-initialize Year Navigator
723                    initYearNavigator();
724
725                    // Set onclick Listeners
726                    setListeners();
727
728                    // Toggle Year
729                    toggleYear(response.current_year.id);
730
731                    // Remove loading Class
732                    $('.mec-modal-result').removeClass("mec-month-navigator-loading");
733
734                    mecFluentYearlyUI(settings.id, active_year);
735                    mecFluentCustomScrollbar();
736
737                },
738                error: function () { }
739            });
740        }
741
742        function setYear(year, do_in_background) {
743            if (typeof do_in_background === "undefined") do_in_background = false;
744
745            var year_id = year;
746            active_year = year;
747
748            // Year exists so we just show it
749            if ($("#mec_yearly_view_year_" + settings.id + "_" + year_id).length) {
750                // Toggle Year
751                toggleYear(year_id);
752                mecFluentCustomScrollbar();
753            } else {
754                if (!do_in_background) {
755                    // Add Loading Class
756                    if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
757                    jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
758                }
759
760                $.ajax({
761                    url: settings.ajax_url,
762                    data: "action=mec_yearly_view_load_year&mec_year=" + year + "&" + settings.atts + "&apply_sf_date=0",
763                    dataType: "json",
764                    type: "post",
765                    success: function (response) {
766                        // Append Year
767                        $("#mec_skin_events_" + settings.id).append('<div class="mec-year-container" id="mec_yearly_view_year_' + settings.id + '_' + response.current_year.id + '" data-year-id="' + response.current_year.id + '">' + response.year + '</div>');
768
769                        // Append Year Navigator
770                        $("#mec_skin_" + settings.id + " .mec-yearly-title-sec").append('<div class="mec-year-navigator" id="mec_year_navigator_' + settings.id + '_' + response.current_year.id + '">' + response.navigator + '</div>');
771
772                        // Re-initialize Year Navigator
773                        initYearNavigator();
774
775                        // Set onclick Listeners
776                        setListeners();
777
778                        if (!do_in_background) {
779                            // Toggle Year
780                            toggleYear(response.current_year.id);
781
782                            // Remove loading Class
783                            $('.mec-modal-result').removeClass("mec-month-navigator-loading");
784
785                            // Set Year Filter values in search widget
786                            $("#mec_sf_year_" + settings.id).val(year);
787                        } else {
788                            $("#mec_yearly_view_year_" + settings.id + "_" + response.current_year.id).hide();
789                            $("#mec_year_navigator_" + settings.id + "_" + response.current_year.id).hide();
790                        }
791                        mecFluentYearlyUI(settings.id, year);
792                        if (!do_in_background) {
793                            mecFluentCustomScrollbar();
794                        }
795                    },
796                    error: function () { }
797                });
798            }
799        }
800
801        function toggleYear(year_id) {
802            // Toggle Year Navigator
803            $("#mec_skin_" + settings.id + " .mec-year-navigator").hide();
804            $("#mec_year_navigator_" + settings.id + "_" + year_id).show();
805
806            // Toggle Year
807            $("#mec_skin_" + settings.id + " .mec-year-container").hide();
808            $("#mec_yearly_view_year_" + settings.id + "_" + year_id).show();
809        }
810
811        var sf;
812
813        function setListeners() {
814            // Single Event Method
815            if (settings.sed_method != '0') {
816                sed();
817            }
818
819            // Yearly view
820            $("#mec_skin_" + settings.id + " .mec-has-event a").on('click', function (e) {
821                e.preventDefault();
822
823                var des = $(this).attr('href');
824                var visible = $(des).is(':visible');
825                if (!visible) {
826                    var year = $(des).parents('.mec-year-container').data('year-id');
827                    if (year) {
828
829                        while (!visible) {
830                            loadMoreButton(year);
831
832                            visible = $(des).is(':visible');
833                        }
834                    }
835                }
836
837                $('.mec-events-agenda').removeClass('mec-selected');
838                $(des).closest('.mec-events-agenda').addClass('mec-selected');
839
840                var scrollTopVal = $(des).closest('.mec-events-agenda').offset().top - 35;
841                if ($(this).closest('.mec-fluent-wrap').length > 0) {
842                    var parent = jQuery(this).closest('.mec-fluent-wrap').find('.mec-yearly-agenda-sec');
843                    scrollTopVal = parent.scrollTop() + ($(des).closest('.mec-events-agenda').offset().top - parent.offset().top);
844                    jQuery(this).closest('.mec-fluent-wrap').find('.mec-yearly-agenda-sec').getNiceScroll(0).doScrollTop(scrollTopVal - 15, 120);
845                }
846                else {
847                    $('html, body').animate({
848                        scrollTop: scrollTopVal
849                    }, 300);
850                }
851            });
852        }
853
854        function sed() {
855            // Single Event Display
856            $("#mec_skin_" + settings.id + " .mec-agenda-event-title a").off('click').on('click', function (e) {
857                var sed_method = $(this).attr('target');
858                if ('_blank' === sed_method) {
859
860                    return;
861                }
862                e.preventDefault();
863                var href = $(this).attr('href');
864
865                var id = $(this).data('event-id');
866                var occurrence = get_parameter_by_name('occurrence', href);
867                var time = get_parameter_by_name('time', href);
868
869                if( 'undefined' == typeof id ){
870                    return;
871                }
872
873                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
874            });
875        }
876
877        function loadMoreButton(year) {
878            var $max_count, $current_count = 0;
879            $max_count = $("#mec_yearly_view_year_" + settings.id + "_" + year + " .mec-yearly-max").data('count');
880            $current_count = $("#mec_yearly_view_year_" + settings.id + "_" + year + " .mec-util-hidden").length;
881
882            if ($current_count > 10) {
883                for (var i = 0; i < 10; i++) {
884                    $("#mec_yearly_view_year_" + settings.id + "_" + year + " .mec-util-hidden").slice(0, 2).each(function () {
885                        $(this).removeClass('mec-util-hidden');
886                    });
887                }
888            }
889
890            if ($current_count < 10 && $current_count != 0) {
891                for (var j = 0; j < $current_count; j++) {
892                    $("#mec_yearly_view_year_" + settings.id + "_" + year + " .mec-util-hidden").slice(0, 2).each(function () {
893                        $(this).removeClass('mec-util-hidden');
894                        $("#mec_yearly_view_year_" + settings.id + "_" + year + " .mec-load-more-wrap").css('display', 'none');
895                    });
896                }
897            }
898        }
899    };
900
901}(jQuery));
902
903
904// MEC GENERAL CALENDAR VIEW PLUGIN
905(function ($) {
906    $.fn.mecGeneralCalendarView = function (options) {
907        // Default Options
908        var settings = $.extend({
909            // These are the defaults.
910            id: 0,
911            atts: '',
912            ajax_url: '',
913            sf: {},
914        }, options);
915
916        // Set onclick Listeners
917        setListeners();
918
919        function setListeners() {
920            // Single Event Method
921            if (settings.sed_method != '0') {
922                sed();
923            }
924        }
925        function sed() {
926            // Single Event Display
927            $("#mec_skin_" + settings.id + " .fc-daygrid-event").off('click').on('click', function (e) {
928                e.preventDefault();
929                var sed_method = $(this).attr('target');
930                if ('_blank' === sed_method || '_self' === sed_method || 'no' === sed_method) {
931
932                    return;
933                }
934                e.preventDefault();
935                var href = $(this).attr('href');
936
937                var id = $(this).data('event-id');
938                var occurrence = get_parameter_by_name('occurrence', href);
939                var time = get_parameter_by_name('time', href);
940
941                if( 'undefined' == typeof id ){
942                    return;
943                }
944
945                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
946            });
947        }
948    };
949
950}(jQuery));
951
952// MEC MONTHLY VIEW PLUGIN
953(function ($) {
954    $.fn.mecMonthlyView = function (options) {
955        var active_month;
956        var active_year;
957
958        // Default Options
959        var settings = $.extend({
960            // These are the defaults.
961            today: null,
962            id: 0,
963            events_label: 'Events',
964            event_label: 'Event',
965            month_navigator: 0,
966            atts: '',
967            active_month: {},
968            next_month: {},
969            sf: {},
970            ajax_url: '',
971        }, options);
972
973        // Initialize Month Navigator
974        if (settings.month_navigator) initMonthNavigator();
975
976        active_month = settings.active_month.month;
977        active_year = settings.active_month.year;
978
979        // Set onclick Listeners
980        setListeners();
981
982        // Search Widget
983        if (settings.sf.container !== '') {
984            sf = $(settings.sf.container).mecSearchForm({
985                id: settings.id,
986                refine: settings.sf.refine,
987                ajax_url: settings.ajax_url,
988                atts: settings.atts,
989                callback: function (atts) {
990                    settings.atts = atts;
991                    search(active_year, active_month);
992                }
993            });
994        }
995
996        function initMonthNavigator() {
997            // Remove the onclick event
998            $("#mec_skin_" + settings.id + " .mec-load-month").off("click");
999
1000            // Add onclick event
1001            $("#mec_skin_" + settings.id + " .mec-load-month").on("click", function () {
1002                var year = $(this).data("mec-year");
1003                var month = $(this).data("mec-month");
1004
1005                setMonth(year, month, false, true);
1006            });
1007        }
1008
1009        function search(year, month)
1010        {
1011            // Modal
1012            var $modal = jQuery('.mec-modal-result');
1013
1014            // Add Loading Class
1015            if($modal.length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
1016            $modal.addClass('mec-month-navigator-loading');
1017
1018            $.ajax(
1019            {
1020                url: settings.ajax_url,
1021                data: "action=mec_monthly_view_load_month&mec_year=" + year + "&mec_month=" + month + "&" + settings.atts + "&apply_sf_date=1",
1022                dataType: "json",
1023                type: "post",
1024                success: function (response)
1025                {
1026                    // Append Month
1027                    $("#mec_skin_events_" + settings.id).html('<div class="mec-month-container" id="mec_monthly_view_month_' + settings.id + '_' + response.current_month.id + '" data-month-id="' + response.current_month.id + '">' + response.month + '</div>');
1028
1029                    // Append Month Navigator
1030                    $("#mec_skin_" + settings.id + " .mec-skin-monthly-view-month-navigator-container").html('<div class="mec-month-navigator" id="mec_month_navigator_' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
1031
1032                    // Append Events Side
1033                    $("#mec_skin_" + settings.id + " .mec-calendar-events-side").html('<div class="mec-month-side" id="mec_month_side_' + settings.id + '_' + response.current_month.id + '">' + response.events_side + '</div>');
1034
1035                    // Re-initialize Month Navigator
1036                    initMonthNavigator();
1037
1038                    // Set onclick Listeners
1039                    setListeners();
1040
1041                    // Toggle Month
1042                    toggleMonth(response.current_month.id);
1043
1044                    jQuery(document).trigger('load_calendar_data');
1045
1046                    // Remove loading Class
1047                    $('.mec-modal-result').removeClass("mec-month-navigator-loading");
1048
1049                },
1050                error: function () { }
1051            });
1052        }
1053
1054        function setMonth(year, month, do_in_background, navigator_click) {
1055            if (typeof do_in_background === "undefined") do_in_background = false;
1056            navigator_click = navigator_click || false;
1057            var month_id = year + "" + month;
1058
1059            if (!do_in_background) {
1060                active_month = month;
1061                active_year = year;
1062            }
1063
1064            // Month exists so we just show it
1065            if ($("#mec_monthly_view_month_" + settings.id + "_" + month_id).length)
1066            {
1067                // Set Month Filter values in search widget
1068                $("#mec_sf_month_" + settings.id).val(month);
1069                $("#mec_sf_year_" + settings.id).val(year);
1070
1071                // Toggle Month
1072                toggleMonth(month_id);
1073            } else {
1074                if (!do_in_background) {
1075
1076                    // Add Loading Class
1077                    if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
1078                    jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
1079                }
1080
1081                $.ajax({
1082                    url: settings.ajax_url,
1083                    data: "action=mec_monthly_view_load_month&mec_year=" + year + "&mec_month=" + month + "&" + settings.atts + "&apply_sf_date=0" + "&navigator_click=" + navigator_click,
1084                    dataType: "json",
1085                    type: "post",
1086                    success: function (response) {
1087                        // Append Month
1088                        $("#mec_skin_events_" + settings.id).append('<div class="mec-month-container" id="mec_monthly_view_month_' + settings.id + '_' + response.current_month.id + '" data-month-id="' + response.current_month.id + '">' + response.month + '</div>');
1089
1090                        // Append Month Navigator
1091                        $("#mec_skin_" + settings.id + " .mec-skin-monthly-view-month-navigator-container").append('<div class="mec-month-navigator" id="mec_month_navigator_' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
1092
1093                        // Append Events Side
1094                        $("#mec_skin_" + settings.id + " .mec-calendar-events-side").append('<div class="mec-month-side" id="mec_month_side_' + settings.id + '_' + response.current_month.id + '">' + response.events_side + '</div>');
1095
1096                        // Re-initialize Month Navigator
1097                        initMonthNavigator();
1098
1099                        // Set onclick Listeners
1100                        setListeners();
1101
1102                        if (!do_in_background) {
1103                            // Toggle Month
1104                            toggleMonth(response.current_month.id);
1105
1106                            // Remove loading Class
1107                            $('.mec-modal-result').removeClass("mec-month-navigator-loading");
1108
1109                            // Set Month Filter values in search widget
1110                            $("#mec_sf_month_" + settings.id).val(month);
1111                            $("#mec_sf_year_" + settings.id).val(year);
1112                        } else {
1113                            $("#mec_monthly_view_month_" + settings.id + "_" + response.current_month.id).hide();
1114                            $("#mec_month_navigator_" + settings.id + "_" + response.current_month.id).hide();
1115                            $("#mec_month_side_" + settings.id + "_" + response.current_month.id).hide();
1116                        }
1117                        if (typeof custom_month !== undefined) var custom_month;
1118                        if (typeof custom_month != undefined) {
1119                            if (custom_month == 'true') {
1120                                $(".mec-month-container .mec-calendar-day").removeClass('mec-has-event');
1121                                $(".mec-month-container .mec-calendar-day").removeClass('mec-selected-day');
1122                                $('.mec-calendar-day').unbind('click');
1123                            }
1124                        }
1125
1126                        jQuery(document).trigger('load_calendar_data');
1127
1128                    },
1129                    error: function () { }
1130                });
1131            }
1132        }
1133
1134        function toggleMonth(month_id) {
1135            var active_month = $("#mec_skin_" + settings.id + " .mec-month-container-selected").data("month-id");
1136            var active_day = $("#mec_monthly_view_month_" + settings.id + "_" + active_month + " .mec-selected-day").data("day");
1137
1138            if (active_day <= 9) active_day = "0" + active_day;
1139
1140            // Toggle Month Navigator
1141            $("#mec_skin_" + settings.id + " .mec-month-navigator").hide();
1142            $("#mec_month_navigator_" + settings.id + "_" + month_id).show();
1143
1144            // Toggle Month
1145            $("#mec_skin_" + settings.id + " .mec-month-container").hide();
1146            $("#mec_monthly_view_month_" + settings.id + "_" + month_id).show();
1147
1148            // Add selected class
1149            $("#mec_skin_" + settings.id + " .mec-month-container").removeClass("mec-month-container-selected");
1150            $("#mec_monthly_view_month_" + settings.id + "_" + month_id).addClass("mec-month-container-selected");
1151
1152            // Toggle Events Side
1153            $("#mec_skin_" + settings.id + " .mec-month-side").hide();
1154            $("#mec_month_side_" + settings.id + "_" + month_id).show();
1155
1156            jQuery(document).trigger('mec_toggle_month', [settings, month_id]);
1157        }
1158
1159        var sf;
1160
1161        function setListeners() {
1162            // Remove the onclick event
1163            $("#mec_skin_" + settings.id + " .mec-has-event").off("click");
1164
1165            // Add the onclick event
1166            $("#mec_skin_" + settings.id + " .mec-has-event").on('click', function (e) {
1167                // define variables
1168                var $this = $(this),
1169                    data_mec_cell = $this.data('mec-cell'),
1170                    month_id = $this.data('month');
1171
1172                if (settings.display_all == 0) {
1173                    e.preventDefault();
1174
1175                    $("#mec_monthly_view_month_" + settings.id + "_" + month_id + " .mec-calendar-day").removeClass('mec-selected-day');
1176                    $this.addClass('mec-selected-day');
1177
1178                    $('#mec_month_side_' + settings.id + '_' + month_id + ' .mec-calendar-events-sec:not([data-mec-cell=' + data_mec_cell + '])').slideUp();
1179                    $('#mec_month_side_' + settings.id + '_' + month_id + ' .mec-calendar-events-sec[data-mec-cell=' + data_mec_cell + ']').slideDown();
1180
1181                    $('#mec_monthly_view_month_' + settings.id + '_' + month_id + ' .mec-calendar-events-sec:not([data-mec-cell=' + data_mec_cell + '])').slideUp();
1182                    $('#mec_monthly_view_month_' + settings.id + '_' + month_id + ' .mec-calendar-events-sec[data-mec-cell=' + data_mec_cell + ']').slideDown();
1183                }
1184                else {
1185                    $("#mec_monthly_view_month_" + settings.id + "_" + month_id + " .mec-calendar-day").removeClass('mec-selected-day');
1186                    $this.addClass('mec-selected-day');
1187                }
1188            });
1189
1190            mec_tooltip();
1191
1192            // Single Event Method
1193            if (settings.sed_method != '0') {
1194                sed();
1195            }
1196
1197            if (settings.style == 'novel') {
1198                if ($('.mec-single-event-novel').length > 0) {
1199                    $('.mec-single-event-novel').colourBrightness();
1200                    $('.mec-single-event-novel').each(function () {
1201                        $(this).colourBrightness()
1202                    });
1203                }
1204            }
1205        }
1206
1207        function sed() {
1208            // Single Event Display
1209            $("#mec_skin_" + settings.id + " .mec-event-title a,#mec_skin_" + settings.id + " .event-single-link-novel,#mec_skin_" + settings.id + " .mec-monthly-tooltip").off('click').on('click', function (e) {
1210                var sed_method = $(this).attr('target');
1211                if ('_blank' === sed_method) {
1212
1213                    return;
1214                }
1215                e.preventDefault();
1216                var href = $(this).attr('href');
1217
1218                var id = $(this).data('event-id');
1219                var occurrence = get_parameter_by_name('occurrence', href);
1220                var time = get_parameter_by_name('time', href);
1221
1222                if( 'undefined' == typeof id ){
1223                    return;
1224                }
1225
1226                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
1227            });
1228
1229        }
1230
1231        function mec_tooltip() {
1232            if ($('.mec-monthly-tooltip').length >= 1) {
1233                if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 768) {
1234                    $('.mec-monthly-tooltip').tooltipster({
1235                        theme: 'tooltipster-shadow',
1236                        interactive: true,
1237                        delay: 100,
1238                        minWidth: 350,
1239                        maxWidth: 350
1240                    });
1241                    if (settings.sed_method != '0') {
1242                        sed();
1243                    }
1244                } else {
1245                    var touchtime = 0;
1246                    $(".mec-monthly-tooltip").on("click", function (event) {
1247                        event.preventDefault();
1248                        if (touchtime == 0) {
1249                            $('.mec-monthly-tooltip').tooltipster({
1250                                theme: 'tooltipster-shadow',
1251                                interactive: true,
1252                                delay: 100,
1253                                minWidth: 350,
1254                                maxWidth: 350,
1255                                trigger: "custom",
1256                                triggerOpen: {
1257                                    click: true,
1258                                    tap: true
1259                                },
1260                                triggerClose: {
1261                                    click: true,
1262                                    tap: true
1263                                }
1264                            });
1265                            touchtime = new Date().getTime();
1266                        } else {
1267                            if (((new Date().getTime()) - touchtime) < 200) {
1268                                var el = $(this);
1269                                var link = el.attr("href");
1270                                window.location = link;
1271                                touchtime = 0;
1272                            } else {
1273                                touchtime = new Date().getTime();
1274                            }
1275                        }
1276                    });
1277                }
1278            }
1279        }
1280    };
1281
1282}(jQuery));
1283
1284// MEC WEEKLY VIEW PLUGIN
1285(function ($) {
1286    $.fn.mecWeeklyView = function (options) {
1287        var active_year;
1288        var active_month;
1289        var active_week;
1290        var active_week_number;
1291
1292        // Default Options
1293        var settings = $.extend({
1294            // These are the defaults.
1295            today: null,
1296            week: 1,
1297            id: 0,
1298            current_year: null,
1299            current_month: null,
1300            changeWeekElement: '.mec-load-week',
1301            month_navigator: 0,
1302            atts: '',
1303            ajax_url: '',
1304            sf: {}
1305        }, options);
1306
1307        // Set Active Time
1308        active_year = settings.current_year;
1309        active_month = settings.current_month;
1310
1311        // Search Widget
1312        if (settings.sf.container !== '') {
1313            $(settings.sf.container).mecSearchForm({
1314                id: settings.id,
1315                refine: settings.sf.refine,
1316                ajax_url: settings.ajax_url,
1317                atts: settings.atts,
1318                callback: function (atts) {
1319                    settings.atts = atts;
1320                    search(active_year, active_month, active_week);
1321                }
1322            });
1323        }
1324
1325        // Set The Week
1326        setThisWeek(settings.month_id + settings.week);
1327
1328        // Set Listeners
1329        setListeners();
1330
1331        // Initialize Month Navigator
1332        if (settings.month_navigator) initMonthNavigator(settings.month_id);
1333
1334        function setListeners() {
1335            $(settings.changeWeekElement).off('click').on('click', function (e) {
1336                var week = $('#mec_skin_' + settings.id + ' .mec-weekly-view-week-active').data('week-id');
1337                var max_weeks = $('#mec_skin_' + settings.id + ' .mec-weekly-view-week-active').data('max-weeks');
1338                var new_week_number = active_week_number;
1339
1340                if ($(this).hasClass('mec-previous-month')) {
1341                    week = parseInt(week) - 1;
1342                    new_week_number--;
1343                } else {
1344                    week = parseInt(week) + 1;
1345                    new_week_number++;
1346                }
1347
1348                if (new_week_number <= 1 || new_week_number >= max_weeks) {
1349                    // Disable Next/Previous Button
1350                    $(this).css({
1351                        'opacity': .6,
1352                        'cursor': 'default'
1353                    });
1354                    $(this).find('i').css({
1355                        'opacity': .6,
1356                        'cursor': 'default'
1357                    });
1358                } else {
1359                    // Enable Next/Previous Buttons
1360                    $('#mec_skin_' + settings.id + ' .mec-load-week, #mec_skin_' + settings.id + ' .mec-load-week i').css({
1361                        'opacity': 1,
1362                        'cursor': 'pointer'
1363                    });
1364                }
1365
1366                // Week is not in valid range
1367                if (new_week_number === 0 || new_week_number > max_weeks) { } else {
1368                    setThisWeek(week);
1369                }
1370            });
1371
1372            // Single Event Method
1373            if (settings.sed_method != '0') {
1374                sed();
1375            }
1376        }
1377
1378        function setThisWeek(week, auto_focus) {
1379            if (typeof auto_focus === 'undefined') auto_focus = false;
1380
1381            // Week is not exists
1382            if (!$('#mec_weekly_view_week_' + settings.id + '_' + week).length) {
1383                return setThisWeek((parseInt(week) - 1));
1384            }
1385
1386            // Set week to active in week list
1387            $('#mec_skin_' + settings.id + ' .mec-weekly-view-week').removeClass('mec-weekly-view-week-active');
1388            $('#mec_weekly_view_week_' + settings.id + '_' + week).addClass('mec-weekly-view-week-active');
1389            $('#mec_weekly_view_top_week_' + settings.id + '_' + week).addClass('mec-weekly-view-week-active');
1390
1391            // Show related events
1392            $('#mec_skin_' + settings.id + ' .mec-weekly-view-date-events').addClass('mec-util-hidden');
1393            $('.mec-weekly-view-week-' + settings.id + '-' + week).removeClass('mec-util-hidden');
1394            $('#mec_skin_' + settings.id + ' .mec-calendar-row').addClass('mec-util-hidden');
1395            $('#mec_skin_' + settings.id + ' .mec-calendar-row[data-week=' + week % 10 + ']').removeClass('mec-util-hidden');
1396
1397            active_week = week;
1398            active_week_number = $('#mec_skin_' + settings.id + ' .mec-weekly-view-week-active').data('week-number');
1399
1400            $('#mec_skin_' + settings.id + ' .mec-calendar-d-top').find('.mec-current-week').find('span').remove();
1401            $('#mec_skin_' + settings.id + ' .mec-calendar-d-top').find('.mec-current-week').append('<span>' + active_week_number + '</span>');
1402
1403            if (active_week_number === 1) {
1404                // Disable Previous Button
1405                $('#mec_skin_' + settings.id + ' .mec-previous-month.mec-load-week').css({
1406                    'opacity': .6,
1407                    'cursor': 'default'
1408                });
1409                $('#mec_skin_' + settings.id + ' .mec-previous-month.mec-load-week').find('i').css({
1410                    'opacity': .6,
1411                    'cursor': 'default'
1412                });
1413            }
1414
1415            // Go To Event Week
1416            if (auto_focus) mec_focus_week(settings.id);
1417
1418            mecFluentCustomScrollbar();
1419        }
1420
1421        function initMonthNavigator(month_id) {
1422            $('#mec_month_navigator' + settings.id + '_' + month_id + ' .mec-load-month').off('click');
1423            $('#mec_month_navigator' + settings.id + '_' + month_id + ' .mec-load-month').on('click', function () {
1424                var year = $(this).data('mec-year');
1425                var month = $(this).data('mec-month');
1426
1427                setMonth(year, month, active_week, true);
1428            });
1429        }
1430
1431        function search(year, month, week, navigation_click) {
1432            var week_number = (String(week).slice(-1));
1433
1434            // Add Loading Class
1435            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
1436            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
1437
1438            $.ajax({
1439                url: settings.ajax_url,
1440                data: "action=mec_weekly_view_load_month&mec_year=" + year + "&mec_month=" + month + "&mec_week=" + week_number + "&" + settings.atts + "&apply_sf_date=1",
1441                dataType: "json",
1442                type: "post",
1443                success: function (response) {
1444                    // Remove Loading Class
1445                    $('.mec-modal-result').removeClass("mec-month-navigator-loading");
1446
1447                    // Append Month
1448                    $("#mec_skin_events_" + settings.id).html('<div class="mec-month-container" id="mec_weekly_view_month_' + settings.id + '_' + response.current_month.id + '">' + response.month + '</div>');
1449
1450                    // Append Month Navigator
1451                    $("#mec_skin_" + settings.id + " .mec-skin-weekly-view-month-navigator-container").html('<div class="mec-month-navigator" id="mec_month_navigator' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
1452
1453                    // Set Listeners
1454                    setListeners();
1455
1456                    // Toggle Month
1457                    toggleMonth(response.current_month.id);
1458
1459                    // Set active week
1460                    setThisWeek(response.week_id, true);
1461                    mecFluentCustomScrollbar();
1462                },
1463                error: function () { }
1464            });
1465        }
1466
1467        function setMonth(year, month, week, navigation_click) {
1468            var month_id = '' + year + month;
1469            var week_number = (String(week).slice(-1));
1470
1471            active_month = month;
1472            active_year = year;
1473            navigation_click = navigation_click || false;
1474
1475            // Month exists so we just show it
1476            if ($("#mec_weekly_view_month_" + settings.id + "_" + month_id).length)
1477            {
1478                // Set Month Filter values in search widget
1479                $("#mec_sf_month_" + settings.id).val(month);
1480                $("#mec_sf_year_" + settings.id).val(year);
1481
1482                // Toggle Month
1483                toggleMonth(month_id);
1484
1485                // Set active week
1486                setThisWeek('' + month_id + week_number);
1487                mecFluentCustomScrollbar();
1488            } else {
1489                // Add Loading Class
1490                if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
1491                jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
1492
1493                $.ajax({
1494                    url: settings.ajax_url,
1495                    data: "action=mec_weekly_view_load_month&mec_year=" + year + "&mec_month=" + month + "&mec_week=" + week_number + "&" + settings.atts + "&apply_sf_date=0" + "&navigator_click=" + navigation_click,
1496                    dataType: "json",
1497                    type: "post",
1498                    success: function (response) {
1499                        // Remove Loading Class
1500                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
1501
1502                        $('#mec_skin_' + settings.id + ' .mec-calendar-d-top h3').after(response.topWeeks);
1503
1504                        // Append Month
1505                        $("#mec_skin_events_" + settings.id).append('<div class="mec-month-container" id="mec_weekly_view_month_' + settings.id + '_' + response.current_month.id + '">' + response.month + '</div>');
1506
1507                        // Append Month Navigator
1508                        $("#mec_skin_" + settings.id + " .mec-skin-weekly-view-month-navigator-container").append('<div class="mec-month-navigator" id="mec_month_navigator' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
1509
1510                        // Set Listeners
1511                        setListeners();
1512
1513                        // Toggle Month
1514                        toggleMonth(response.current_month.id);
1515
1516                        // Set active week
1517                        setThisWeek(response.week_id, true);
1518
1519                        // Set Month Filter values in search widget
1520                        $("#mec_sf_month_" + settings.id).val(month);
1521                        $("#mec_sf_year_" + settings.id).val(year);
1522                        mecFluentCustomScrollbar();
1523                    },
1524                    error: function () { }
1525                });
1526            }
1527        }
1528
1529        function toggleMonth(month_id) {
1530            // Show related events
1531            $('#mec_skin_' + settings.id + ' .mec-month-container').addClass('mec-util-hidden');
1532            $('#mec_weekly_view_month_' + settings.id + '_' + month_id).removeClass('mec-util-hidden');
1533
1534            $('#mec_skin_' + settings.id + ' .mec-month-navigator').addClass('mec-util-hidden');
1535            $('#mec_month_navigator' + settings.id + '_' + month_id).removeClass('mec-util-hidden');
1536
1537            // Initialize Month Navigator
1538            if (settings.month_navigator) initMonthNavigator(month_id);
1539
1540            jQuery(document).trigger('mec_toggle_month', [settings, month_id]);
1541        }
1542
1543        function sed() {
1544            // Single Event Display
1545            $("#mec_skin_" + settings.id + " .mec-event-title a").off('click').on('click', function (e) {
1546                var sed_method = $(this).attr('target');
1547                if ('_blank' === sed_method) {
1548
1549                    return;
1550                }
1551                e.preventDefault();
1552                var href = $(this).attr('href');
1553
1554                var id = $(this).data('event-id');
1555                var occurrence = get_parameter_by_name('occurrence', href);
1556                var time = get_parameter_by_name('time', href);
1557
1558                if( 'undefined' == typeof id ){
1559                    return;
1560                }
1561
1562                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
1563            });
1564        }
1565    };
1566
1567}(jQuery));
1568
1569// MEC DAILY VIEW PLUGIN
1570(function ($) {
1571    $.fn.mecDailyView = function (options) {
1572        var active_month;
1573        var active_year;
1574        var active_day;
1575
1576        // Default Options
1577        var settings = $.extend({
1578            // These are the defaults.
1579            today: null,
1580            id: 0,
1581            changeDayElement: '.mec-daily-view-day',
1582            events_label: 'Events',
1583            event_label: 'Event',
1584            month_navigator: 0,
1585            atts: '',
1586            ajax_url: '',
1587            sf: {},
1588        }, options);
1589
1590        active_month = settings.month;
1591        active_year = settings.year;
1592        active_day = settings.day;
1593
1594        mecFluentCustomScrollbar();
1595
1596        // Set Today
1597        setToday(settings.today);
1598
1599        // Set Listeners
1600        setListeners();
1601
1602        // Initialize Month Navigator
1603        if (settings.month_navigator) initMonthNavigator(settings.month_i
1603d);
1604
1605        // Initialize Days Slider
1606        initDaysSlider(settings.month_id);
1607
1608        // Slider first event day focus when page load.
1609        mecFocusDay(settings);
1610
1611        // Search Widget
1612        if (settings.sf.container !== '') {
1613            $(settings.sf.container).mecSearchForm({
1614                id: settings.id,
1615                refine: settings.sf.refine,
1616                ajax_url: settings.ajax_url,
1617                atts: settings.atts,
1618                callback: function (atts) {
1619                    settings.atts = atts;
1620                    search(active_year, active_month, active_day);
1621                }
1622            });
1623        }
1624
1625        function setListeners() {
1626            $(settings.changeDayElement).on('click', function () {
1627                var today = $(this).data('day-id');
1628                setToday(today);
1629                mecFluentCustomScrollbar();
1630            });
1631
1632            // Single Event Method
1633            if (settings.sed_method != '0') {
1634                sed();
1635            }
1636        }
1637
1638        var current_monthday;
1639
1640        function setToday(today) {
1641            // For caring about 31st, 30th and 29th of some months
1642            if (!$('#mec_daily_view_day' + settings.id + '_' + today).length) {
1643                setToday(parseInt(today) - 1);
1644                return false;
1645            }
1646
1647            // Set day to active in day list
1648            $('.mec-daily-view-day').removeClass('mec-daily-view-day-active mec-color');
1649            $('#mec_daily_view_day' + settings.id + '_' + today).addClass('mec-daily-view-day-active mec-color');
1650
1651            // Show related events
1652            $('.mec-daily-view-date-events').addClass('mec-util-hidden');
1653            $('#mec_daily_view_date_events' + settings.id + '_' + today).removeClass('mec-util-hidden');
1654            $('.mec-daily-view-events').addClass('mec-util-hidden');
1655            $('#mec-daily-view-events' + settings.id + '_' + today).removeClass('mec-util-hidden');
1656
1657            // Set today label
1658            var weekday = $('#mec_daily_view_day' + settings.id + '_' + today).data('day-weekday');
1659            var monthday = $('#mec_daily_view_day' + settings.id + '_' + today).data('day-monthday');
1660            var count = $('#mec_daily_view_day' + settings.id + '_' + today).data('events-count');
1661            var month_id = $('#mec_daily_view_day' + settings.id + '_' + today).data('month-id');
1662
1663            $('#mec_today_container' + settings.id + '_' + month_id).html('<h2>' + monthday + '</h2><h3>' + weekday + '</h3><div class="mec-today-count">' + count + ' ' + (count > 1 ? settings.events_label : settings.event_label) + '</div>');
1664
1665            if (monthday <= 9) current_monthday = '0' + monthday;
1666            else current_monthday = monthday;
1667        }
1668
1669        function initMonthNavigator(month_id) {
1670            $('#mec_month_navigator' + settings.id + '_' + month_id + ' .mec-load-month').off('click');
1671            $('#mec_month_navigator' + settings.id + '_' + month_id + ' .mec-load-month').on('click', function () {
1672                var year = $(this).data('mec-year');
1673                var month = $(this).data('mec-month');
1674
1675                setMonth(year, month, current_monthday, true);
1676            });
1677        }
1678
1679        function initDaysSlider(month_id, day_id) {
1680            // Set Global Month Id
1681            mec_g_month_id = month_id;
1682
1683            // Check RTL website
1684            var owl_rtl = $('body').hasClass('rtl') ? true : false;
1685
1686            // Init Days slider
1687            var owl = $("#mec-owl-calendar-d-table-" + settings.id + "-" + month_id);
1688            owl.owlCarousel({
1689                responsiveClass: true,
1690                responsive: {
1691                    0: {
1692                        items: owl.closest('.mec-fluent-wrap').length > 0 ? 3 : 2,
1693                    },
1694                    479: {
1695                        items: 4,
1696                    },
1697                    767: {
1698                        items: 7,
1699                    },
1700                    960: {
1701                        items: 14,
1702                    },
1703                    1000: {
1704                        items: 19,
1705                    },
1706                    1200: {
1707                        items: 22,
1708                    }
1709                },
1710                dots: false,
1711                loop: false,
1712                rtl: owl_rtl,
1713            });
1714
1715            // Custom Navigation Events
1716            $("#mec_daily_view_month_" + settings.id + "_" + month_id + " .mec-table-d-next").click(function (e) {
1717                e.preventDefault();
1718                owl.trigger('next.owl.carousel');
1719            });
1720
1721            $("#mec_daily_view_month_" + settings.id + "_" + month_id + " .mec-table-d-prev").click(function (e) {
1722                e.preventDefault();
1723                owl.trigger('prev.owl.carousel');
1724            });
1725
1726            if (typeof day_id === 'undefined') day_id = $('.mec-daily-view-day-active').data('day-id');
1727
1728            var today_str = day_id.toString().substring(6, 8);
1729            var today_int = parseInt(today_str);
1730
1731            owl.trigger('owl.goTo', [today_int]);
1732        }
1733
1734        function search(year, month, day) {
1735            // Add Loading Class
1736            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
1737            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
1738
1739            $.ajax({
1740                url: settings.ajax_url,
1741                data: "action=mec_daily_view_load_month&mec_year=" + year + "&mec_month=" + month + "&mec_day=" + day + "&" + settings.atts + "&apply_sf_date=1",
1742                dataType: "json",
1743                type: "post",
1744                success: function (response) {
1745                    // Remove Loading Class
1746                    $('.mec-modal-result').removeClass("mec-month-navigator-loading");
1747
1748                    // Append Month
1749                    $("#mec_skin_events_" + settings.id).html('<div class="mec-month-container" id="mec_daily_view_month_' + settings.id + '_' + response.current_month.id + '">' + response.month + '</div>');
1750
1751                    // Append Month Navigator
1752                    $("#mec_skin_" + settings.id + " .mec-calendar-a-month.mec-clear").html('<div class="mec-month-navigator" id="mec_month_navigator' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
1753
1754                    // Set Listeners
1755                    setListeners();
1756
1757                    active_year = response.current_month.year;
1758                    active_month = response.current_month.month;
1759
1760                    // Toggle Month
1761                    toggleMonth(response.current_month.id, '' + active_year + active_month + active_day);
1762
1763                    // Set Today
1764                    setToday('' + active_year + active_month + active_day);
1765
1766                    // Focus First Active Day
1767                    mecFocusDay(settings);
1768                    mecFluentCustomScrollbar();
1769                },
1770                error: function () { }
1771            });
1772        }
1773
1774        function setMonth(year, month, day, navigation_click) {
1775            var month_id = '' + year + month;
1776
1777            active_month = month;
1778            active_year = year;
1779            active_day = day;
1780            navigation_click = navigation_click || false;
1781
1782            // Month exists so we just show it
1783            if ($("#mec_daily_view_month_" + settings.id + "_" + month_id).length)
1784            {
1785                // Set Month Filter values in search widget
1786                $("#mec_sf_month_" + settings.id).val(month);
1787                $("#mec_sf_year_" + settings.id).val(year);
1788
1789                // Toggle Month
1790                toggleMonth(month_id);
1791
1792                // Set Today
1793                setToday('' + month_id + day);
1794            } else {
1795                // Add Loading Class
1796                if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
1797                jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
1798
1799                $.ajax({
1800                    url: settings.ajax_url,
1801                    data: "action=mec_daily_view_load_month&mec_year=" + year + "&mec_month=" + month + "&mec_day=" + day + "&" + settings.atts + "&apply_sf_date=0" + "&navigator_click=" + navigation_click,
1802                    dataType: "json",
1803                    type: "post",
1804                    success: function (response) {
1805                        // Remove Loading Class
1806                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
1807
1808                        // Append Month
1809                        $("#mec_skin_events_" + settings.id).append('<div class="mec-month-container" id="mec_daily_view_month_' + settings.id + '_' + response.current_month.id + '">' + response.month + '</div>');
1810
1811                        // Append Month Navigator
1812                        $("#mec_skin_" + settings.id + " .mec-calendar-a-month.mec-clear").append('<div class="mec-month-navigator" id="mec_month_navigator' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
1813
1814                        // Set Listeners
1815                        setListeners();
1816
1817                        // Toggle Month
1818                        toggleMonth(response.current_month.id, '' + year + month + '01');
1819
1820                        // Set Today
1821                        setToday('' + year + month + '01');
1822
1823                        // Set Month Filter values in search widget
1824                        $("#mec_sf_month_" + settings.id).val(month);
1825                        $("#mec_sf_year_" + settings.id).val(year);
1826                        mecFluentCustomScrollbar();
1827                    },
1828                    error: function () { }
1829                });
1830            }
1831        }
1832
1833        function toggleMonth(month_id, day_id) {
1834            // Show related events
1835            $('#mec_skin_' + settings.id + ' .mec-month-container').addClass('mec-util-hidden');
1836            $('#mec_daily_view_month_' + settings.id + '_' + month_id).removeClass('mec-util-hidden');
1837
1838            $('#mec_skin_' + settings.id + ' .mec-month-navigator').addClass('mec-util-hidden');
1839            $('#mec_month_navigator' + settings.id + '_' + month_id).removeClass('mec-util-hidden');
1840
1841            // Initialize Month Navigator
1842            if (settings.month_navigator) initMonthNavigator(month_id);
1843
1844            // Initialize Days Slider
1845            initDaysSlider(month_id, day_id);
1846
1847            // Focus First Active Day
1848            mecFocusDay(settings);
1849
1850            jQuery(document).trigger('mec_toggle_month', [settings, month_id]);
1851        }
1852
1853        function sed() {
1854            // Single Event Display
1855            $("#mec_skin_" + settings.id + " .mec-event-title a").off('click').on('click', function (e) {
1856                var sed_method = $(this).attr('target');
1857                if ('_blank' === sed_method) {
1858
1859                    return;
1860                }
1861                e.preventDefault();
1862                var href = $(this).attr('href');
1863
1864                var id = $(this).data('event-id');
1865                var occurrence = get_parameter_by_name('occurrence', href);
1866                var time = get_parameter_by_name('time', href);
1867
1868                if( 'undefined' == typeof id ){
1869                    return;
1870                }
1871
1872                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
1873            });
1874        }
1875    };
1876
1877}(jQuery));
1878
1879// MEC TIMETABLE PLUGIN
1880(function ($) {
1881    $.fn.mecTimeTable = function (options) {
1882        var active_year;
1883        var active_month;
1884        var active_week;
1885        var active_week_number;
1886        var active_day;
1887
1888        // Default Options
1889        var settings = $.extend({
1890            // These are the defaults.
1891            today: null,
1892            week: 1,
1893            active_day: 1,
1894            id: 0,
1895            changeWeekElement: '.mec-load-week',
1896            month_navigator: 0,
1897            atts: '',
1898            ajax_url: '',
1899            sf: {}
1900        }, options);
1901
1902        // Search Widget
1903        if (settings.sf.container !== '') {
1904            $(settings.sf.container).mecSearchForm({
1905                id: settings.id,
1906                refine: settings.sf.refine,
1907                ajax_url: settings.ajax_url,
1908                atts: settings.atts,
1909                callback: function (atts) {
1910                    settings.atts = atts;
1911                    search(active_year, active_month, active_week, active_day);
1912                }
1913            });
1914        }
1915
1916        // Set The Week
1917        setThisWeek(settings.month_id + settings.week, settings.active_day);
1918
1919        // Set Listeners
1920        setListeners();
1921
1922        // Initialize Month Navigator
1923        if (settings.month_navigator) initMonthNavigator(settings.month_id);
1924
1925        function setListeners() {
1926            // Change Week Listener
1927            $(settings.changeWeekElement).off('click').on('click', function () {
1928                var week = $('#mec_skin_' + settings.id + ' .mec-weekly-view-week-active').data('week-id');
1929                var max_weeks = $('#mec_skin_' + settings.id + ' .mec-weekly-view-week-active').data('max-weeks');
1930                var new_week_number = active_week_number;
1931
1932                if ($(this).hasClass('mec-previous-month')) {
1933                    week = parseInt(week) - 1;
1934                    new_week_number--;
1935                } else {
1936                    week = parseInt(week) + 1;
1937                    new_week_number++;
1938                }
1939
1940                if (new_week_number <= 1 || new_week_number >= max_weeks) {
1941                    // Disable Next/Previous Button
1942                    $(this).css({
1943                        'opacity': .6,
1944                        'cursor': 'default'
1945                    });
1946                    $(this).find('i').css({
1947                        'opacity': .6,
1948                        'cursor': 'default'
1949                    });
1950                } else {
1951                    // Enable Next/Previous Buttons
1952                    $('#mec_skin_' + settings.id + ' .mec-load-week, #mec_skin_' + settings.id + ' .mec-load-week i').css({
1953                        'opacity': 1,
1954                        'cursor': 'pointer'
1955                    });
1956                }
1957
1958                // Week is not in valid range
1959                if (new_week_number === 0 || new_week_number > max_weeks) { } else {
1960                    setThisWeek(week);
1961                }
1962            });
1963
1964            // Change Day Listener
1965            $('#mec_skin_' + settings.id + ' .mec-weekly-view-week dt').not('.mec-timetable-has-no-event').off('click').on('click', function () {
1966                var day = $(this).data('date-id');
1967                setDay(day);
1968            });
1969
1970            // Single Event Method
1971            if (settings.sed_method != '0') {
1972                sed();
1973            }
1974        }
1975
1976        function setThisWeek(week, day) {
1977            // Week is not exists
1978            if (!$('#mec_weekly_view_week_' + settings.id + '_' + week).length) {
1979                return setThisWeek((parseInt(week) - 1), day);
1980            }
1981
1982            // Set week to active in week list
1983            $('#mec_skin_' + settings.id + ' .mec-weekly-view-week').removeClass('mec-weekly-view-week-active');
1984            $('#mec_weekly_view_week_' + settings.id + '_' + week).addClass('mec-weekly-view-week-active');
1985
1986            setDay(day);
1987
1988            active_week = week;
1989            active_week_number = $('#mec_skin_' + settings.id + ' .mec-weekly-view-week-active').data('week-number');
1990
1991            $('#mec_skin_' + settings.id + ' .mec-calendar-d-top').find('.mec-current-week').find('span').remove();
1992            $('#mec_skin_' + settings.id + ' .mec-calendar-d-top').find('.mec-current-week').append('<span>' + active_week_number + '</span>');
1993
1994            if (active_week_number === 1) {
1995                // Disable Previous Button
1996                $('#mec_skin_' + settings.id + ' .mec-previous-month.mec-load-week').css({
1997                    'opacity': .6,
1998                    'cursor': 'default'
1999                });
2000                $('#mec_skin_' + settings.id + ' .mec-previous-month.mec-load-week').find('i').css({
2001                    'opacity': .6,
2002                    'cursor': 'default'
2003                });
2004            }
2005        }
2006
2007        function setDay(day) {
2008            // Find the date automatically
2009            if (typeof day === 'undefined') {
2010                day = $('#mec_skin_' + settings.id + ' .mec-weekly-view-week-active dt').not('.mec-timetable-has-no-event').first().data('date-id');
2011            }
2012
2013            // Activate the date element
2014            $('#mec_skin_' + settings.id + ' dt').removeClass('mec-timetable-day-active');
2015            $('#mec_skin_' + settings.id + ' .mec-weekly-view-week-active dt[data-date-id="' + day + '"]').addClass('mec-timetable-day-active');
2016
2017            // Show related events
2018            $('#mec_skin_' + settings.id + ' .mec-weekly-view-date-events').addClass('mec-util-hidden');
2019            $('.mec_weekly_view_date_events' + settings.id + '_' + day).removeClass('mec-util-hidden').show();
2020        }
2021
2022        function initMonthNavigator(month_id) {
2023            $('#mec_month_navigator' + settings.id + '_' + month_id + ' .mec-load-month').off('click').on('click', function () {
2024                var year = $(this).data('mec-year');
2025                var month = $(this).data('mec-month');
2026
2027                setMonth(year, month, active_week);
2028            });
2029        }
2030
2031        function search(year, month, week) {
2032            var week_number = (String(week).slice(-1));
2033
2034            // Add Loading Class
2035            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
2036            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
2037
2038            // Set MEC Year And Month If Undefined
2039            year = typeof year == 'undefined' ? '' : year;
2040            month = typeof month == 'undefined' ? '' : month;
2041
2042            // Append current week to data body for used after filter.
2043            $('body').data('currentweek', $("#mec_skin_events_" + settings.id).find('.mec-current-week > span').html());
2044
2045            $.ajax({
2046                url: settings.ajax_url,
2047                data: "action=mec_timetable_load_month&mec_year=" + year + "&mec_month=" + month + "&mec_week=" + week_number + "&" + settings.atts + "&apply_sf_date=1",
2048                dataType: "json",
2049                type: "post",
2050                success: function (response) {
2051                    // Remove Loading Class
2052                    $('.mec-modal-result').removeClass("mec-month-navigator-loading");
2053
2054                    // Append Month
2055                    $("#mec_skin_events_" + settings.id).html('<div class="mec-month-container" id="mec_timetable_month_' + settings.id + '_' + response.current_month.id + '">' + response.month + '</div>');
2056
2057                    // Append Month Navigator
2058                    $("#mec_skin_" + settings.id + " .mec-skin-weekly-view-month-navigator-container").html('<div class="mec-month-navigator" id="mec_month_navigator' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
2059
2060                    // Set Listeners
2061                    setListeners();
2062
2063                    // Toggle Month
2064                    toggleMonth(response.current_month.id);
2065
2066                    // Set active week
2067                    setThisWeek(response.week_id);
2068
2069                    // Focus First Active Week
2070                    mec_focus_week(settings.id, 'timetable');
2071
2072                    mecFluentCustomScrollbar();
2073                },
2074                error: function () { }
2075            });
2076        }
2077
2078        function setMonth(year, month, week) {
2079            var month_id = '' + year + month;
2080            var week_number = (String(week).slice(-1));
2081
2082            active_month = month;
2083            active_year = year;
2084
2085            // Month exists so we just show it
2086            if ($("#mec_timetable_month_" + settings.id + "_" + month_id).length) {
2087                // Toggle Month
2088                toggleMonth(month_id);
2089
2090                // Set active week
2091                setThisWeek('' + month_id + week_number);
2092            } else {
2093                // Add Loading Class
2094                if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
2095                jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
2096
2097                $.ajax({
2098                    url: settings.ajax_url,
2099                    data: "action=mec_timetable_load_month&mec_year=" + year + "&mec_month=" + month + "&mec_week=" + week_number + "&" + settings.atts + "&apply_sf_date=0",
2100                    dataType: "json",
2101                    type: "post",
2102                    success: function (response) {
2103                        // Remove Loading Class
2104                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
2105
2106                        // Append Month
2107                        $("#mec_skin_events_" + settings.id).append('<div class="mec-month-container" id="mec_timetable_month_' + settings.id + '_' + response.current_month.id + '">' + response.month + '</div>');
2108
2109                        // Append Month Navigator
2110                        $("#mec_skin_" + settings.id + " .mec-skin-weekly-view-month-navigator-container").append('<div class="mec-month-navigator" id="mec_month_navigator' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
2111
2112                        // Set Listeners
2113                        setListeners();
2114
2115                        // Toggle Month
2116                        toggleMonth(response.current_month.id);
2117
2118                        // Set active week
2119                        setThisWeek(response.week_id);
2120
2121                        // Set Month Filter values in search widget
2122                        $("#mec_sf_month_" + settings.id).val(month);
2123                        $("#mec_sf_year_" + settings.id).val(year);
2124                    },
2125                    error: function () { }
2126                });
2127            }
2128        }
2129
2130        function toggleMonth(month_id) {
2131            // Show related events
2132            $('#mec_skin_' + settings.id + ' .mec-month-container').addClass('mec-util-hidden');
2133            $('#mec_timetable_month_' + settings.id + '_' + month_id).removeClass('mec-util-hidden');
2134
2135            $('#mec_skin_' + settings.id + ' .mec-month-navigator').addClass('mec-util-hidden');
2136            $('#mec_month_navigator' + settings.id + '_' + month_id).removeClass('mec-util-hidden');
2137
2138            // Initialize Month Navigator
2139            if (settings.month_navigator) initMonthNavigator(month_id);
2140
2141            jQuery(document).trigger('mec_toggle_month', [settings, month_id]);
2142        }
2143
2144        function sed() {
2145            // Single Event Display
2146            $("#mec_skin_" + settings.id + " .mec-timetable-event-title a").off('click').on('click', function (e) {
2147                e.preventDefault();
2148                var href = $(this).attr('href');
2149
2150                var id = $(this).data('event-id');
2151                var occurrence = get_parameter_by_name('occurrence', href);
2152                var time = get_parameter_by_name('time', href);
2153
2154                if( 'undefined' == typeof id ){
2155                    return;
2156                }
2157
2158                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
2159            });
2160        }
2161    };
2162
2163}(jQuery));
2164
2165// MEC WEEKLY PROGRAM PLUGIN
2166(function ($) {
2167    $.fn.mecWeeklyProgram = function (options) {
2168        // Default Options
2169        var settings = $.extend({
2170            // These are the defaults.
2171            id: 0,
2172            atts: '',
2173            sf: {}
2174        }, options);
2175
2176        // Search Widget
2177        if (settings.sf.container !== '') {
2178            $(settings.sf.container).mecSearchForm({
2179                id: settings.id,
2180                refine: settings.sf.refine,
2181                ajax_url: settings.ajax_url,
2182                atts: settings.atts,
2183                callback: function (atts) {
2184                    settings.atts = atts;
2185                    search();
2186                }
2187            });
2188        }
2189
2190        // Set Listeners
2191        setListeners();
2192
2193        function setListeners() {
2194            // Single Event Method
2195            if (settings.sed_method != '0') {
2196                sed();
2197            }
2198        }
2199
2200        function search() {
2201            var $modal = $('.mec-modal-result');
2202
2203            // Add Loading Class
2204            if ($modal.length === 0) $('.mec-wrap').append('<div class="mec-modal-result"></div>');
2205            $modal.addClass('mec-month-navigator-loading');
2206
2207            $.ajax({
2208                url: settings.ajax_url,
2209                data: "action=mec_weeklyprogram_load&" + settings.atts + "&apply_sf_date=1",
2210                dataType: "json",
2211                type: "post",
2212                success: function (response) {
2213                    // Remove Loading Class
2214                    $modal.removeClass("mec-month-navigator-loading");
2215
2216                    // Append Month
2217                    $("#mec_skin_events_" + settings.id).html(response.date_events);
2218
2219                    // Set Listeners
2220                    setListeners();
2221                },
2222                error: function () { }
2223            });
2224        }
2225
2226        function sed() {
2227            // Single Event Display
2228            $("#mec_skin_" + settings.id + " .mec-event-title a").off('click').on('click', function (e) {
2229                var sed_method = $(this).attr('target');
2230                if ('_blank' === sed_method) {
2231
2232                    return;
2233                }
2234                e.preventDefault();
2235                var href = $(this).attr('href');
2236
2237                var id = $(this).data('event-id');
2238                var occurrence = get_parameter_by_name('occurrence', href);
2239                var time = get_parameter_by_name('time', href);
2240
2241                if( 'undefined' == typeof id ){
2242                    return;
2243                }
2244
2245                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
2246            });
2247        }
2248    };
2249
2250}(jQuery));
2251
2252// MEC MASONRY VIEW PLUGIN
2253(function ($) {
2254    $.fn.mecMasonryView = function (options) {
2255        // Default Options
2256        var settings = $.extend({
2257            // These are the defaults.
2258            id: 0,
2259            atts: '',
2260            ajax_url: '',
2261            sf: {},
2262            end_date: '',
2263            offset: 0,
2264            start_date: '',
2265        }, options);
2266
2267        // Set onclick Listeners
2268        setListeners();
2269
2270        // Init Masonry
2271        initMasonry();
2272        if (typeof custom_dev !== undefined) var custom_dev;
2273        if (custom_dev == 'yes') {
2274            $(".mec-wrap").css("height", "1550");
2275            if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) < 768) {
2276                $(".mec-wrap").css("height", "5500");
2277            }
2278            if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) < 480) {
2279                $(".mec-wrap").css("height", "5000");
2280            }
2281            $(".mec-event-masonry .mec-masonry-item-wrap:nth-child(n+20)").css("display", "none");
2282            $(".mec-load-more-button").on("click", function () {
2283                $(".mec-event-masonry .mec-masonry-item-wrap:nth-child(n+20)").css("display", "block");
2284                $(".mec-wrap").css("height", "auto");
2285                initMasonry();
2286                $(".mec-load-more-button").hide();
2287            })
2288            $(".mec-events-masonry-cats a:first-child").on("click", function () {
2289                $(".mec-wrap").css("height", "auto");
2290                $(".mec-event-masonry .mec-masonry-item-wrap:nth-child(n+20)").css("display", "block");
2291                $(".mec-load-more-button").hide();
2292                initMasonry();
2293            })
2294            $(".mec-events-masonry-cats a:not(:first-child)").on("click", function () {
2295                $(".mec-load-more-button").hide();
2296                $(".mec-wrap").css("height", "auto");
2297                $(".mec-wrap").css("min-height", "400");
2298                $(".mec-event-masonry .mec-masonry-item-wrap").css("display", "block");
2299                var element = document.querySelector("#mec_skin_" + settings.id + " .mec-event-masonry");
2300                var selector = $(this).attr('data-group');
2301                var CustomShuffle = new Shuffle(element, {
2302                    itemSelector: '.mec-masonry-item-wrap',
2303                });
2304                CustomShuffle.sort({
2305                    by: element.getAttribute('data-created'),
2306                });
2307                CustomShuffle.filter(selector != '*' ? selector : Shuffle.ALL_ITEMS);
2308                $(".mec-event-masonry .mec-masonry-item-wrap").css("visibility", "visible");
2309            })
2310        }
2311
2312        // Fix Elementor Masonry
2313        if (mecdata.elementor_edit_mode != 'no') elementorFrontend.hooks.addAction('frontend/element_ready/global', initMasonry());
2314
2315        function initMasonry() {
2316            var $container = $("#mec_skin_" + settings.id + " .mec-event-masonry");
2317            var data_sortAscending = $("#mec_skin_" + settings.id).data('sortascending');
2318            $container.imagesLoaded(function () {
2319                var $grid = $container.isotope({
2320                    filter: '*',
2321                    itemSelector: '.mec-masonry-item-wrap',
2322                    getSortData: {
2323                        date: '[data-sort-masonry]',
2324                    },
2325                    sortBy: 'date',
2326                    sortAscending: data_sortAscending,
2327                    animationOptions: {
2328                        duration: 750,
2329                        easing: 'linear',
2330                        queue: false
2331                    },
2332                });
2333                if (settings.fit_to_row == 1) $grid.isotope({
2334                    layoutMode: 'fitRows',
2335                    sortAscending: data_sortAscending,
2336                });
2337                // Fix Elementor tab
2338                $('.elementor-tabs').find('.elementor-tab-title').click(function () {
2339                    $grid.isotope({
2340                        sortBy: 'date',
2341                        sortAscending: data_sortAscending,
2342                    });
2343                });
2344            })
2345
2346            $("#mec_skin_" + settings.id + " .mec-events-masonry-cats a").click(function () {
2347                var selector = $(this).attr('data-filter');
2348                var $grid_cat = $container.isotope({
2349                    filter: selector,
2350                    itemSelector: '.mec-masonry-item-wrap',
2351                    getSortData: {
2352                        date: '[data-sort-masonry]',
2353                    },
2354                    sortBy: 'date',
2355                    sortAscending: data_sortAscending,
2356                    animationOptions: {
2357                        duration: 750,
2358                        easing: 'linear',
2359                        queue: false
2360                    },
2361                });
2362                if (settings.masonry_like_grid == 1) $grid_cat.isotope({
2363                    sortBy: 'date',
2364                    sortAscending: data_sortAscending,
2365                });
2366                return false;
2367            });
2368
2369            var $optionSets = $("#mec_skin_" + settings.id + " .mec-events-masonry-cats"),
2370                $optionLinks = $optionSets.find('a');
2371
2372            $optionLinks.click(function () {
2373                var $this = $(this);
2374
2375                // don't proceed if already selected
2376                if ($this.hasClass('selected')) return false;
2377
2378                var $optionSet = $this.parents('.mec-events-masonry-cats');
2379                $optionSet.find('.mec-masonry-cat-selected').removeClass('mec-masonry-cat-selected');
2380                $this.addClass('mec-masonry-cat-selected');
2381            });
2382        }
2383
2384        function setListeners() {
2385            if (settings.sed_method != '0') {
2386                sed();
2387            }
2388
2389        }
2390
2391        $("#mec_skin_" + settings.id + " .mec-events-masonry-cats > a").click(function () {
2392            var mec_load_more_btn = $("#mec_skin_" + settings.id + " .mec-load-more-button");
2393            var mec_filter_value = $(this).data('filter').replace('.mec-t', '');
2394
2395            if (mec_load_more_btn.hasClass('mec-load-more-loading')) mec_load_more_btn.removeClass('mec-load-more-loading');
2396            if (mec_load_more_btn.hasClass("mec-hidden-" + mec_filter_value)) mec_load_more_btn.addClass("mec-util-hidden");
2397            else mec_load_more_btn.removeClass("mec-util-hidden");
2398        });
2399
2400        $("#mec_skin_" + settings.id + " .mec-load-more-button").on("click", function () {
2401            loadMore();
2402        });
2403
2404        function sed() {
2405            // Single Event Display
2406            $("#mec_skin_" + settings.id + " .mec-masonry-img a, #mec_skin_" + settings.id + " .mec-event-title a, #mec_skin_" + settings.id + " .mec-booking-button").off('click').on('click', function (e) {
2407                var sed_method = $(this).attr('target');
2408                if ('_blank' === sed_method) {
2409
2410                    return;
2411                }
2412                e.preventDefault();
2413                var href = $(this).attr('href');
2414
2415                var id = $(this).data('event-id');
2416                var occurrence = get_parameter_by_name('occurrence', href);
2417                var time = get_parameter_by_name('time', href);
2418
2419                if( 'undefined' == typeof id ){
2420                    return;
2421                }
2422
2423                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
2424            });
2425        }
2426
2427        function loadMore() {
2428            // Add loading Class
2429            $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-load-more-loading");
2430            var mec_cat_elem = $('#mec_skin_' + settings.id).find('.mec-masonry-cat-selected');
2431            var mec_filter_value = (mec_cat_elem && mec_cat_elem.data('filter') != undefined) ? mec_cat_elem.data('filter').replace('.mec-t', '') : '';
2432            var mec_filter_by = $('#mec_skin_' + settings.id).data('filterby');
2433
2434            $.ajax({
2435                url: settings.ajax_url,
2436                data: "action=mec_masonry_load_more&mec_filter_by=" + mec_filter_by + "&mec_filter_value=" + mec_filter_value + "&mec_start_date=" + settings.end_date + "&mec_offset=" + settings.offset + "&" + settings.atts + "&apply_sf_date=0",
2437                dataType: "json",
2438                type: "post",
2439                success: function (response) {
2440                    if (response.count == "0") {
2441                        // Remove loading Class
2442                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
2443
2444                        // Hide load more button
2445                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden mec-hidden-" + mec_filter_value);
2446                    } else {
2447                        // Show load more button
2448                        if (typeof response.has_more_event === 'undefined' || (typeof response.has_more_event !== 'undefined' && response.has_more_event)) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
2449                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
2450
2451                        // Append Items
2452                        var node = $("#mec_skin_" + settings.id + " .mec-event-masonry");
2453                        var markup = '',
2454                            newItems = $(response.html).find('.mec-masonry-item-wrap');
2455
2456                        newItems.each(function (index) {
2457                            node.isotope()
2458                                .append(newItems[index])
2459                                .isotope('appended', newItems[index]);
2460                        });
2461
2462                        // Remove loading Class
2463                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
2464
2465                        // Update the variables
2466                        settings.end_date = response.end_date;
2467                        settings.offset = response.offset;
2468
2469                        // Single Event Method
2470                        if (settings.sed_method != '0') {
2471                            sed();
2472                        }
2473                    }
2474                },
2475                error: function () { }
2476            });
2477        }
2478    };
2479}(jQuery));
2480
2481// MEC LIST VIEW PLUGIN
2482(function ($) {
2483    $.fn.mecListView = function (options) {
2484        // Default Options
2485        var settings = $.extend({
2486            // These are the defaults.
2487            id: 0,
2488            atts: '',
2489            ajax_url: '',
2490            sf: {},
2491            current_month_divider: '',
2492            end_date: '',
2493            offset: 0,
2494            limit: 0
2495        }, options);
2496
2497        // Set onclick Listeners
2498        setListeners();
2499
2500        var sf;
2501
2502        function setListeners() {
2503            // Search Widget
2504            if (settings.sf.container !== '') {
2505                sf = $(settings.sf.container).mecSearchForm({
2506                    id: settings.id,
2507                    refine: settings.sf.refine,
2508                    ajax_url: settings.ajax_url,
2509                    atts: settings.atts,
2510                    callback: function (atts) {
2511                        settings.atts = atts;
2512                        search();
2513                    }
2514                });
2515            }
2516
2517            $("#mec_skin_" + settings.id + " .mec-load-more-button").on("click", function () {
2518                loadMore();
2519            });
2520
2521            // Accordion Toggle
2522            if (settings.style === 'accordion') {
2523                if (settings.toggle_month_divider) {
2524                    $('#mec_skin_' + settings.id + ' .mec-month-divider:first-of-type').addClass('active');
2525                    $('#mec_skin_' + settings.id + ' .mec-month-divider:first-of-type').find('i').removeClass('mec-sl-arrow-down').addClass('mec-sl-arrow-up');
2526
2527                    toggle();
2528                }
2529
2530                accordion();
2531            }
2532
2533            // Single Event Method
2534            if (settings.sed_method != '0') {
2535                sed();
2536            }
2537        }
2538
2539        function toggle() {
2540            $('#mec_skin_' + settings.id + ' .mec-month-divider').off("click").on("click", function (event) {
2541                event.preventDefault();
2542
2543                var status = $(this).hasClass('active');
2544
2545                // Remove Active Style of Month Divider
2546                $('#mec_skin_' + settings.id + ' .mec-month-divider').removeClass('active');
2547
2548                // Hide All Events
2549                $('#mec_skin_' + settings.id + ' .mec-divider-toggle').slideUp('fast');
2550
2551                if (status) {
2552                    $(this).removeClass('active');
2553                    $('.mec-month-divider').find('i').removeClass('mec-sl-arrow-up').addClass('mec-sl-arrow-down');
2554                } else {
2555                    $(this).addClass('active');
2556                    $('.mec-month-divider').find('i').removeClass('mec-sl-arrow-up').addClass('mec-sl-arrow-down')
2557                    $(this).find('i').removeClass('mec-sl-arrow-down').addClass('mec-sl-arrow-up');
2558
2559                    var month = $(this).data('toggle-divider');
2560                    $('#mec_skin_' + settings.id + ' .' + month).slideDown('fast');
2561                }
2562            });
2563        }
2564
2565        function toggleLoadmore() {
2566            $('#mec_skin_' + settings.id + ' .mec-month-divider:not(:last)').each(function () {
2567                if ($(this).hasClass('active')) $(this).removeClass('active');
2568                var month = $(this).data('toggle-divider');
2569                $('#mec_skin_' + settings.id + ' .' + month).slideUp('fast');
2570            });
2571
2572            // Set Active Class For Last Article
2573            $('#mec_skin_' + settings.id + ' .mec-month-divider:last').addClass('active');
2574
2575            // Register Listeners
2576            toggle();
2577        }
2578
2579        function accordion() {
2580            // Accordion Toggle
2581            $("#mec_skin_" + settings.id + " .mec-toggle-item-inner").off("click").on("click", function (event) {
2582                event.preventDefault();
2583
2584                var $this = $(this);
2585                $(this).parent().find(".mec-content-toggle").slideToggle("fast", function () {
2586                    $this.children("i").toggleClass("mec-sl-arrow-down mec-sl-arrow-up");
2587                });
2588
2589                // Trigger Google Map
2590                var unique_id = $(this).parent().find(".mec-modal-wrap").data('unique-id');
2591
2592                if(typeof window['mec_init_gmap' + unique_id] === 'function') window['mec_init_gmap' + unique_id]();
2593            });
2594        }
2595
2596        function sed() {
2597            // Single Event Display
2598            $("#mec_skin_" + settings.id + " .mec-event-title > a, #mec_skin_" + settings.id + " .mec-booking-button, #mec_skin_" + settings.id + " .mec-detail-button").off('click').on('click', function (e) {
2599                e.preventDefault();
2600                var href = $(this).attr('href');
2601
2602                var id = $(this).data('event-id');
2603                var occurrence = get_parameter_by_name('occurrence', href);
2604                var time = get_parameter_by_name('time', href);
2605
2606                if( 'undefined' == typeof id ){
2607                    return;
2608                }
2609
2610                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
2611            });
2612
2613            $("#mec_skin_" + settings.id + " .mec-event-image a img").off('click').on('click', function (e) {
2614                e.preventDefault();
2615                var href = $(this).parent().attr('href');
2616
2617                var id = $(this).parent().data('event-id');
2618                var occurrence = get_parameter_by_name('occurrence', href);
2619                var time = get_parameter_by_name('time', href);
2620
2621                if( 'undefined' == typeof id ){
2622                    return;
2623                }
2624
2625                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
2626            });
2627        }
2628
2629        function loadMore() {
2630            // Add loading Class
2631            $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-load-more-loading");
2632
2633            $.ajax({
2634                url: settings.ajax_url,
2635                data: "action=mec_list_load_more&mec_start_date=" + settings.end_date + "&mec_offset=" + settings.offset + "&" + settings.atts + "&current_month_divider=" + settings.current_month_divider + "&apply_sf_date=0",
2636                dataType: "json",
2637                type: "post",
2638                success: function (response) {
2639                    if (response.count == '0') {
2640                        // Remove loading Class
2641                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
2642
2643                        // Hide load more button
2644                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
2645                    } else {
2646                        // Show load more button
2647                        if (typeof response.has_more_event === 'undefined' || (typeof response.has_more_event !== 'undefined' && response.has_more_event)) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
2648                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
2649
2650                        // Append Items
2651                        $("#mec_skin_events_" + settings.id).append(response.html);
2652
2653                        // Remove loading Class
2654                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
2655
2656                        // Update the variables
2657                        settings.end_date = response.end_date;
2658                        settings.offset = response.offset;
2659                        settings.current_month_divider = response.current_month_divider;
2660
2661                        // Single Event Method
2662                        if (settings.sed_method != '0') {
2663                            sed();
2664                        }
2665
2666                        // Accordion Toggle
2667                        if (settings.style === 'accordion') {
2668                            if (settings.toggle_month_divider) toggleLoadmore();
2669
2670                            accordion();
2671                        }
2672                    }
2673                },
2674                error: function () { }
2675            });
2676        }
2677
2678        function search() {
2679            // Hide no event message
2680            $("#mec_skin_no_events_" + settings.id).addClass("mec-util-hidden");
2681
2682            // Add loading Class
2683            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
2684            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
2685            jQuery("#gmap-data").val("");
2686
2687            $.ajax({
2688                url: settings.ajax_url,
2689                data: "action=mec_list_load_more&mec_start_date=" + settings.start_date + "&" + settings.atts + "&current_month_divider=0&apply_sf_date=1",
2690                dataType: "json",
2691                type: "post",
2692                success: function (response) {
2693                    if (response.count == "0") {
2694                        // Append Items
2695                        $("#mec_skin_events_" + settings.id).html('');
2696
2697                        // Remove loading Class
2698                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
2699
2700                        // Hide Map
2701                        $('.mec-skin-map-container').addClass("mec-util-hidden");
2702
2703                        // Hide it
2704                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
2705
2706                        // Show no event message
2707                        $("#mec_skin_no_events_" + settings.id).removeClass("mec-util-hidden");
2708                    } else {
2709                        // Append Items
2710                        $("#mec_skin_events_" + settings.id).html(response.html);
2711
2712                        // Remove loading Class
2713                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
2714
2715                        // Show Map
2716                        $('.mec-skin-map-container').removeClass("mec-util-hidden");
2717
2718                        // Show load more button
2719                        if (response.count >= settings.limit) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
2720                        // Hide load more button
2721                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
2722
2723                        // Update the variables
2724                        settings.end_date = response.end_date;
2725                        settings.offset = response.offset;
2726                        settings.current_month_divider = response.current_month_divider;
2727
2728                        // Single Event Method
2729                        if (settings.sed_method != '0') {
2730                            sed();
2731                        }
2732
2733                        // Accordion Toggle
2734                        if (settings.style === 'accordion') {
2735                            if (settings.toggle_month_divider) toggle();
2736
2737                            accordion();
2738                        }
2739                    }
2740                },
2741                error: function () { }
2742            });
2743        }
2744    };
2745
2746}(jQuery));
2747
2748// MEC GRID VIEW PLUGIN
2749(function ($) {
2750    $.fn.mecGridView = function (options) {
2751        // Default Options
2752        var settings = $.extend({
2753            // These are the defaults.
2754            id: 0,
2755            atts: '',
2756            ajax_url: '',
2757            sf: {},
2758            end_date: '',
2759            offset: 0,
2760            start_date: '',
2761        }, options);
2762
2763        // Set onclick Listeners
2764        setListeners();
2765
2766        var sf;
2767
2768        function setListeners() {
2769            // Search Widget
2770            if (settings.sf.container !== '') {
2771                sf = $(settings.sf.container).mecSearchForm({
2772                    id: settings.id,
2773                    refine: settings.sf.refine,
2774                    ajax_url: settings.ajax_url,
2775                    atts: settings.atts,
2776                    callback: function (atts) {
2777                        settings.atts = atts;
2778                        search();
2779                    }
2780                });
2781            }
2782
2783            $("#mec_skin_" + settings.id + " .mec-load-more-button").on("click", function () {
2784                loadMore();
2785            });
2786
2787            // Single Event Method
2788            if (settings.sed_method != '0') {
2789                sed();
2790            }
2791        }
2792
2793        function sed() {
2794            // Single Event Display
2795            $("#mec_skin_" + settings.id + " .mec-event-title a, #mec_skin_" + settings.id + " .mec-booking-button").off('click').on('click', function (e) {
2796                e.preventDefault();
2797                var href = $(this).attr('href');
2798
2799                var id = $(this).data('event-id');
2800                var occurrence = get_parameter_by_name('occurrence', href);
2801                var time = get_parameter_by_name('time', href);
2802
2803                if( 'undefined' == typeof id ){
2804                    return;
2805                }
2806
2807                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
2808            });
2809            $("#mec_skin_" + settings.id + " .mec-event-image a img").off('click').on('click', function (e) {
2810                e.preventDefault();
2811                var href = $(this).parent().attr('href');
2812
2813                var id = $(this).parent().data('event-id');
2814                var occurrence = get_parameter_by_name('occurrence', href);
2815                var time = get_parameter_by_name('time', href);
2816
2817                if( 'undefined' == typeof id ){
2818                    return;
2819                }
2820
2821                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
2822            });
2823        }
2824
2825        function loadMore() {
2826            // Add loading Class
2827            $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-load-more-loading");
2828
2829            $.ajax({
2830                url: settings.ajax_url,
2831                data: "action=mec_grid_load_more&mec_start_date=" + settings.end_date + "&mec_offset=" + settings.offset + "&" + settings.atts + "&apply_sf_date=0",
2832                dataType: "json",
2833                type: "post",
2834                success: function (response) {
2835                    if (response.count == "0") {
2836                        // Remove loading Class
2837                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
2838
2839                        // Hide load more button
2840                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
2841                    } else {
2842                        // Show load more button
2843                        if (typeof response.has_more_event === 'undefined' || (typeof response.has_more_event !== 'undefined' && response.has_more_event)) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
2844                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
2845
2846                        // Append Items
2847                        $("#mec_skin_events_" + settings.id).append(response.html);
2848
2849                        // Remove loading Class
2850                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
2851
2852                        // Update the variables
2853                        settings.end_date = response.end_date;
2854                        settings.offset = response.offset;
2855
2856                        // Single Event Method
2857                        if (settings.sed_method != '0') {
2858                            sed();
2859                        }
2860                    }
2861                },
2862                error: function () { }
2863            });
2864        }
2865
2866        function search() {
2867            // Hide no event message
2868            $("#mec_skin_no_events_" + settings.id).addClass("mec-util-hidden");
2869
2870            // Add loading Class
2871            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
2872            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
2873            jQuery("#gmap-data").val("");
2874
2875            $.ajax({
2876                url: settings.ajax_url,
2877                data: "action=mec_grid_load_more&mec_start_date=" + settings.start_date + "&" + settings.atts + "&apply_sf_date=1",
2878                dataType: "json",
2879                type: "post",
2880                success: function (response) {
2881                    if (response.count == "0") {
2882                        // Append Items
2883                        $("#mec_skin_events_" + settings.id).html('');
2884
2885                        // Remove loading Class
2886                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
2887
2888                        // Hide Map
2889                        $('.mec-skin-map-container').addClass("mec-util-hidden");
2890
2891                        // Hide it
2892                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
2893
2894                        // Show no event message
2895                        $("#mec_skin_no_events_" + settings.id).removeClass("mec-util-hidden");
2896                    } else {
2897                        // Append Items
2898                        $("#mec_skin_events_" + settings.id).html(response.html);
2899
2900                        // Remove loading Class
2901                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
2902
2903                        // Show Map
2904                        $('.mec-skin-map-container').removeClass("mec-util-hidden");
2905
2906                        // Show load more button
2907                        if (response.count >= settings.limit) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
2908                        // Hide load more button
2909                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
2910
2911                        // Update the variables
2912                        settings.end_date = response.end_date;
2913                        settings.offset = response.offset;
2914
2915                        // Single Event Method
2916                        if (settings.sed_method != '0') {
2917                            sed();
2918                        }
2919                    }
2920                },
2921                error: function () { }
2922            });
2923        }
2924    };
2925
2926}(jQuery));
2927
2928// MEC CUSTOM VIEW PLUGIN
2929(function ($) {
2930    $.fn.mecCustomView = function (options) {
2931        // Default Options
2932        var settings = $.extend({
2933            // These are the defaults.
2934            id: 0,
2935            atts: '',
2936            ajax_url: '',
2937            sf: {},
2938            end_date: '',
2939            offset: 0,
2940            start_date: '',
2941        }, options);
2942
2943        // Set onclick Listeners
2944        setListeners();
2945
2946        var sf;
2947
2948        function setListeners() {
2949            // Search Widget
2950            if (settings.sf.container !== '') {
2951                sf = $(settings.sf.container).mecSearchForm({
2952                    id: settings.id,
2953                    refine: settings.sf.refine,
2954                    ajax_url: settings.ajax_url,
2955                    atts: settings.atts,
2956                    callback: function (atts) {
2957                        settings.atts = atts;
2958                        search();
2959                    }
2960                });
2961            }
2962
2963            $("#mec_skin_" + settings.id + " .mec-load-more-button").on("click", function () {
2964                loadMore();
2965            });
2966
2967            // Single Event Method
2968            if (settings.sed_method != '0') {
2969                sed();
2970            }
2971        }
2972
2973        function sed() {
2974            // Single Event Display
2975            $("#mec_skin_" + settings.id + " .mec-event-title a, #mec_skin_" + settings.id + " .mec-booking-button").off('click').on('click', function (e) {
2976                e.preventDefault();
2977                var href = $(this).attr('href');
2978
2979                var id = $(this).data('event-id');
2980                var occurrence = get_parameter_by_name('occurrence', href);
2981                var time = get_parameter_by_name('time', href);
2982
2983                if( 'undefined' == typeof id ){
2984                    return;
2985                }
2986
2987                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
2988            });
2989            $("#mec_skin_" + settings.id + " .mec-event-image a img").off('click').on('click', function (e) {
2990                e.preventDefault();
2991                var href = $(this).parent().attr('href');
2992
2993                var id = $(this).parent().data('event-id');
2994                var occurrence = get_parameter_by_name('occurrence', href);
2995                var time = get_parameter_by_name('time', href);
2996
2997                if( 'undefined' == typeof id ){
2998                    return;
2999                }
3000
3001                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
3002            });
3003        }
3004
3005        function loadMore() {
3006            // Add loading Class
3007            $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-load-more-loading");
3008
3009            $.ajax({
3010                url: settings.ajax_url,
3011                data: "action=mec_custom_load_more&mec_start_date=" + settings.end_date + "&mec_offset=" + settings.offset + "&" + settings.atts + "&apply_sf_date=0",
3012                dataType: "json",
3013                type: "post",
3014                success: function (response) {
3015                    if (response.count == "0") {
3016                        // Remove loading Class
3017                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
3018
3019                        // Hide load more button
3020                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3021                    } else {
3022                        // Show load more button
3023                        if (typeof response.has_more_event === 'undefined' || (typeof response.has_more_event !== 'undefined' && response.has_more_event)) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
3024                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3025
3026                        var html = $(response.html);
3027                        if ($('.mec-month-divider', html).length) {
3028                            var df = $('.mec-month-divider:first', html).data('toggle-divider');
3029                            var dl = $("#mec_skin_events_" + settings.id + " .mec-month-divider:last").data('toggle-divider');
3030
3031                            if (df == dl) {
3032                                $(html).find('.mec-month-divider:first').remove();
3033                                response.html = html;
3034                            }
3035
3036                        }
3037
3038                        // Append Items
3039                        $("#mec_skin_events_" + settings.id).append(response.html);
3040
3041                        // Remove loading Class
3042                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
3043
3044                        // Update the variables
3045                        settings.end_date = response.end_date;
3046                        settings.offset = response.offset;
3047
3048                        if ($('.mec-event-sd-countdown').length > 0) {
3049                            $('.mec-event-sd-countdown').each(function (event) {
3050                                var dc = $(this).attr('data-date-custom');
3051                                $(this).mecCountDown(
3052                                    {
3053                                        date: dc,
3054                                        format: "off"
3055                                    },
3056                                    function () {
3057                                    });
3058                            })
3059                        }
3060                        // Single Event Method
3061                        if (settings.sed_method != '0') {
3062                            sed();
3063                        }
3064                    }
3065                },
3066                error: function () { }
3067            });
3068        }
3069
3070        function search() {
3071            // Hide no event message
3072            $("#mec_skin_no_events_" + settings.id).addClass("mec-util-hidden");
3073
3074            // Add loading Class
3075            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
3076            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
3077            jQuery("#gmap-data").val("");
3078
3079            $.ajax({
3080                url: settings.ajax_url,
3081                data: "action=mec_custom_load_more&mec_start_date=" + settings.start_date + "&" + settings.atts + "&apply_sf_date=1",
3082                dataType: "json",
3083                type: "post",
3084                success: function (response) {
3085                    if (response.count == "0") {
3086                        // Append Items
3087                        $("#mec_skin_events_" + settings.id).html('');
3088
3089                        // Remove loading Class
3090                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
3091
3092                        // Hide Map
3093                        $('.mec-skin-map-container').addClass("mec-util-hidden");
3094
3095                        // Hide it
3096                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3097
3098                        // Show no event message
3099                        $("#mec_skin_no_events_" + settings.id).removeClass("mec-util-hidden");
3100                    } else {
3101                        // Append Items
3102                        $("#mec_skin_events_" + settings.id).html(response.html);
3103
3104                        // Remove loading Class
3105                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
3106
3107                        // Show Map
3108                        $('.mec-skin-map-container').removeClass("mec-util-hidden");
3109
3110                        // Show load more button
3111                        if (response.count >= settings.limit) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
3112                        // Hide load more button
3113                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3114
3115                        // Update the variables
3116                        settings.end_date = response.end_date;
3117                        settings.offset = response.offset;
3118
3119                        // Single Event Method
3120                        if (settings.sed_method != '0') {
3121                            sed();
3122                        }
3123                    }
3124                },
3125                error: function () { }
3126            });
3127        }
3128    };
3129
3130}(jQuery));
3131
3132// MEC TIMELINE VIEW PLUGIN
3133(function ($) {
3134    $.fn.mecTimelineView = function (options) {
3135        // Default Options
3136        var settings = $.extend({
3137            // These are the defaults.
3138            id: 0,
3139            atts: '',
3140            ajax_url: '',
3141            sf: {},
3142            end_date: '',
3143            offset: 0,
3144            start_date: '',
3145        }, options);
3146
3147        // Set onclick Listeners
3148        setListeners();
3149
3150        var sf;
3151
3152        function setListeners() {
3153            // Search Widget
3154            if (settings.sf.container !== '') {
3155                sf = $(settings.sf.container).mecSearchForm({
3156                    id: settings.id,
3157                    refine: settings.sf.refine,
3158                    ajax_url: settings.ajax_url,
3159                    atts: settings.atts,
3160                    callback: function (atts) {
3161                        settings.atts = atts;
3162                        search();
3163                    }
3164                });
3165            }
3166
3167            $("#mec_skin_" + settings.id + " .mec-load-more-button").on("click", function () {
3168                loadMore();
3169            });
3170
3171            // Single Event Method
3172            if (settings.sed_method != '0') {
3173                sed();
3174            }
3175        }
3176
3177        function sed() {
3178            // Single Event Display
3179            $("#mec_skin_" + settings.id + " .mec-timeline-event-image a, #mec_skin_" + settings.id + " .mec-event-title a, #mec_skin_" + settings.id + " .mec-booking-button").off('click').on('click', function (e) {
3180                e.preventDefault();
3181                var href = $(this).attr('href');
3182
3183                var id = $(this).data('event-id');
3184                var occurrence = get_parameter_by_name('occurrence', href);
3185                var time = get_parameter_by_name('time', href);
3186
3187                if( 'undefined' == typeof id ){
3188                    return;
3189                }
3190
3191                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
3192            });
3193            $("#mec_skin_" + settings.id + " .mec-event-image a img").off('click').on('click', function (e) {
3194                e.preventDefault();
3195                var href = $(this).parent().attr('href');
3196
3197                var id = $(this).parent().data('event-id');
3198                var occurrence = get_parameter_by_name('occurrence', href);
3199                var time = get_parameter_by_name('time', href);
3200
3201                if( 'undefined' == typeof id ){
3202                    return;
3203                }
3204
3205                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
3206            });
3207        }
3208
3209        function loadMore() {
3210            // Add loading Class
3211            $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-load-more-loading");
3212
3213            $.ajax({
3214                url: settings.ajax_url,
3215                data: "action=mec_timeline_load_more&mec_start_date=" + settings.end_date + "&mec_offset=" + settings.offset + "&" + settings.atts + "&apply_sf_date=0",
3216                dataType: "json",
3217                type: "post",
3218                success: function (response) {
3219                    if (response.count == "0") {
3220                        // Remove loading Class
3221                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
3222
3223                        // Hide load more button
3224                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3225                    } else {
3226                        // Show load more button
3227                        if (typeof response.has_more_event === 'undefined' || (typeof response.has_more_event !== 'undefined' && response.has_more_event)) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
3228                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3229
3230                        // Append Items
3231                        $("#mec_skin_events_" + settings.id).append(response.html);
3232
3233                        // Remove loading Class
3234                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
3235
3236                        // Update the variables
3237                        settings.end_date = response.end_date;
3238                        settings.offset = response.offset;
3239
3240                        // Single Event Method
3241                        if (settings.sed_method != '0') {
3242                            sed();
3243                        }
3244
3245                    }
3246                },
3247                error: function () { }
3248            });
3249        }
3250
3251        function search() {
3252            // Hide no event message
3253            $("#mec_skin_no_events_" + settings.id).addClass("mec-util-hidden");
3254
3255            // Add loading Class
3256            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
3257            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
3258
3259            $.ajax({
3260                url: settings.ajax_url,
3261                data: "action=mec_timeline_load_more&mec_start_date=" + settings.start_date + "&" + settings.atts + "&apply_sf_date=1",
3262                dataType: "json",
3263                type: "post",
3264                success: function (response) {
3265                    if (response.count == "0") {
3266                        // Append Items
3267                        $("#mec_skin_events_" + settings.id).html('');
3268
3269                        // Remove loading Class
3270                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
3271
3272                        // Hide Map
3273                        $('.mec-skin-map-container').addClass("mec-util-hidden");
3274
3275                        // Hide it
3276                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3277
3278                        // Show no event message
3279                        $("#mec_skin_no_events_" + settings.id).removeClass("mec-util-hidden");
3280                    } else {
3281                        // Append Items
3282                        $("#mec_skin_events_" + settings.id).html(response.html);
3283
3284                        // Remove loading Class
3285                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
3286
3287                        // Show Map
3288                        $('.mec-skin-map-container').removeClass("mec-util-hidden");
3289
3290                        // Show load more button
3291                        if (response.count >= settings.limit) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
3292                        // Hide load more button
3293                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3294
3295                        // Update the variables
3296                        settings.end_date = response.end_date;
3297                        settings.offset = response.offset;
3298
3299                        // Single Event Method
3300                        if (settings.sed_method != '0') {
3301                            sed();
3302                        }
3303                    }
3304                },
3305                error: function () { }
3306            });
3307        }
3308    };
3309
3310}(jQuery));
3311
3312// MEC AGENDA VIEW PLUGIN
3313(function ($) {
3314    $.fn.mecAgendaView = function (options) {
3315        // Default Options
3316        var settings = $.extend({
3317            // These are the defaults.
3318            id: 0,
3319            atts: '',
3320            ajax_url: '',
3321            sf: {},
3322            current_month_divider: '',
3323            end_date: '',
3324            offset: 0,
3325        }, options);
3326
3327        // Set onclick Listeners
3328        setListeners();
3329
3330        var sf;
3331
3332        function setListeners() {
3333            // Search Widget
3334            if (settings.sf.container !== '') {
3335                sf = $(settings.sf.container).mecSearchForm({
3336                    id: settings.id,
3337                    refine: settings.sf.refine,
3338                    ajax_url: settings.ajax_url,
3339                    atts: settings.atts,
3340                    callback: function (atts) {
3341                        settings.atts = atts;
3342                        search();
3343                    }
3344                });
3345            }
3346
3347            $("#mec_skin_" + settings.id + " .mec-load-more-button").on("click", function () {
3348                loadMore();
3349            });
3350
3351            // Single Event Method
3352            if (settings.sed_method != '0') {
3353                sed();
3354            }
3355        }
3356
3357        function sed() {
3358            // Single Event Display
3359            $("#mec_skin_" + settings.id + " .mec-agenda-event-title a").off('click').on('click', function (e) {
3360                var sed_method = $(this).attr('target');
3361                if ('_blank' === sed_method) {
3362
3363                    return;
3364                }
3365                e.preventDefault();
3366                var href = $(this).attr('href');
3367
3368                var id = $(this).data('event-id');
3369                var occurrence = get_parameter_by_name('occurrence', href);
3370                var time = get_parameter_by_name('time', href);
3371
3372                if( 'undefined' == typeof id ){
3373                    return;
3374                }
3375
3376                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
3377            });
3378        }
3379
3380        function loadMore() {
3381            // Add loading Class
3382            $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-load-more-loading");
3383
3384            $.ajax({
3385                url: settings.ajax_url,
3386                data: "action=mec_agenda_load_more&mec_start_date=" + settings.end_date + "&mec_offset=" + settings.offset + "&" + settings.atts + "&current_month_divider=" + settings.current_month_divider + "&apply_sf_date=0",
3387                dataType: "json",
3388                type: "post",
3389                success: function (response) {
3390                    if (response.count == "0") {
3391                        // Remove loading Class
3392                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
3393
3394                        // Hide load more button
3395                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3396                    } else {
3397                        // Show load more button
3398                        if (typeof response.has_more_event === 'undefined' || (typeof response.has_more_event !== 'undefined' && response.has_more_event)) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
3399                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3400
3401                        // Append Items
3402                        $("#mec_skin_events_" + settings.id + " .mec-events-agenda-container").append(response.html);
3403
3404                        // Remove loading Class
3405                        $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-load-more-loading");
3406
3407                        // Update the variables
3408                        settings.end_date = response.end_date;
3409                        settings.offset = response.offset;
3410                        settings.current_month_divider = response.current_month_divider;
3411
3412                        // Single Event Method
3413                        if (settings.sed_method != '0') {
3414                            sed();
3415                        }
3416                        mecFluentCustomScrollbar();
3417                    }
3418                },
3419                error: function () { }
3420            });
3421        }
3422
3423        function search() {
3424            // Hide no event message
3425            $("#mec_skin_no_events_" + settings.id).addClass("mec-util-hidden");
3426
3427            // Add loading Class
3428            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
3429            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
3430            mecFluentCustomScrollbar();
3431
3432            $.ajax({
3433                url: settings.ajax_url,
3434                data: "action=mec_agenda_load_more&mec_start_date=" + settings.start_date + "&" + settings.atts + "&current_month_divider=0&apply_sf_date=1",
3435                dataType: "json",
3436                type: "post",
3437                success: function (response) {
3438                    if (response.count == "0") {
3439                        // Append Items
3440                        $("#mec_skin_events_" + settings.id + " .mec-events-agenda-container").html('');
3441
3442                        // Remove loading Class
3443                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
3444
3445                        // Hide it
3446                        $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3447
3448                        // Show no event message
3449                        $("#mec_skin_no_events_" + settings.id).removeClass("mec-util-hidden");
3450                    } else {
3451                        // Append Items
3452                        $("#mec_skin_events_" + settings.id + " .mec-events-agenda-container").html(response.html);
3453
3454                        // Remove loading Class
3455                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
3456
3457                        // Show load more button
3458                        if (response.count >= settings.limit) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
3459                        // Hide load more button
3460                        else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3461
3462                        // Update the variables
3463                        settings.end_date = response.end_date;
3464                        settings.offset = response.offset;
3465                        settings.current_month_divider = response.current_month_divider;
3466
3467                        // Single Event Method
3468                        if (settings.sed_method != '0') {
3469                            sed();
3470                        }
3471                    }
3472                    mecFluentCustomScrollbar();
3473                },
3474                error: function () { }
3475            });
3476        }
3477    };
3478}(jQuery));
3479
3480// MEC CAROUSEL VIEW PLUGIN
3481(function ($) {
3482    $.fn.mecCarouselView = function (options) {
3483        // Default Options
3484        var settings = $.extend({
3485            // These are the defaults.
3486            id: 0,
3487            atts: '',
3488            ajax_url: '',
3489            sf: {},
3490            items: 3,
3491            items_mobile: 1,
3492            items_tablet: 2,
3493            loop: true,
3494            autoplay_status: true,
3495            autoplay: '',
3496            style: 'type1',
3497            start_date: ''
3498        }, options);
3499
3500        // Init Sliders
3501        initSlider(settings);
3502
3503        // Single Event Method
3504        if (settings.sed_method != '0') {
3505            sed(settings);
3506        }
3507
3508        function initSlider(settings) {
3509            // Check RTL website
3510            if ($('body').hasClass('rtl')) {
3511                var owl_rtl = true;
3512            } else {
3513                var owl_rtl = false;
3514            }
3515
3516            if (settings.style === 'type1') {
3517                // Start carousel skin
3518                var owl = $("#mec_skin_" + settings.id + " .mec-event-carousel-type1 .mec-owl-carousel");
3519
3520                owl.owlCarousel({
3521                    autoplay: settings.autoplay_status,
3522                    autoplayTimeout: settings.autoplay, // Set AutoPlay to 3 seconds
3523                    loop: settings.loop,
3524                    items: settings.items,
3525                    dots: true,
3526                    nav: false,
3527                    autoplayHoverPause: true,
3528                    rtl: owl_rtl,
3529                    responsiveClass: true,
3530                    responsive: {
3531                        0: {
3532                            items: settings.items_mobile,
3533                        },
3534                        979: {
3535                            items: settings.items_tablet,
3536                        },
3537                        1199: {
3538                            items: settings.items,
3539                        }
3540                    },
3541                });
3542
3543                if (settings.autoplay_status) {
3544                    owl.bind(
3545                        "mouseleave",
3546                        function (event) {
3547                            $("#mec_skin_" + settings.id + " .mec-owl-carousel").trigger('play.owl.autoplay');
3548                        }
3549                    );
3550                }
3551            } else if (settings.style === 'type4') {
3552                $("#mec_skin_" + settings.id + " .mec-owl-carousel").owlCarousel({
3553                    autoplay: settings.autoplay_status,
3554                    loop: settings.loop,
3555                    autoplayTimeout: settings.autoplay,
3556                    items: settings.items,
3557                    dots: false,
3558                    nav: true,
3559                    autoplayHoverPause: true,
3560                    navText: ["<i class='mec-sl-arrow-left'></i>", " <i class='mec-sl-arrow-right'></i>"],
3561                    rtl: owl_rtl,
3562                    responsiveClass: true,
3563                    responsive: {
3564                        0: {
3565                            items: settings.items_mobile,
3566                            stagePadding: 50,
3567                        },
3568                        979: {
3569                            items: settings.items_tablet,
3570                        },
3571                        1199: {
3572                            items: settings.items,
3573                        }
3574                    },
3575                });
3576
3577                if (settings.autoplay_status) {
3578                    $("#mec_skin_" + settings.id + " .mec-owl-carousel").bind(
3579                        "mouseleave",
3580                        function (event) {
3581                            $("#mec_skin_" + settings.id + " .mec-owl-carousel").trigger('play.owl.autoplay');
3582                        }
3583                    );
3584                }
3585            } else {
3586                $("#mec_skin_" + settings.id + " .mec-owl-carousel").owlCarousel({
3587                    autoplay: settings.autoplay_status,
3588                    loop: settings.loop,
3589                    autoplayTimeout: settings.autoplay,
3590                    items: settings.items,
3591                    dots: typeof settings.dots_navigation != 'undefined' ? settings.dots_navigation : false,
3592                    nav: typeof settings.navigation != 'undefined' ? settings.navigation : true,
3593                    autoplayHoverPause: true,
3594                    navText: typeof settings.navText != 'undefined' ? settings.navText : ["<i class='mec-sl-arrow-left'></i>", " <i class='mec-sl-arrow-right'></i>"],
3595                    rtl: owl_rtl,
3596                    responsiveClass: true,
3597                    responsive: {
3598                        0: {
3599                            items: settings.items_mobile,
3600                        },
3601                        979: {
3602                            items: settings.items_tablet,
3603                        },
3604                        1199: {
3605                            items: settings.items,
3606                        }
3607                    },
3608                });
3609
3610                if (settings.autoplay_status) {
3611                    $("#mec_skin_" + settings.id + " .mec-owl-carousel").bind(
3612                        "mouseleave",
3613                        function (event) {
3614                            $("#mec_skin_" + settings.id + " .mec-owl-carousel").trigger('play.owl.autoplay');
3615                        }
3616                    );
3617                }
3618            }
3619        }
3620    };
3621
3622    function sed(settings) {
3623        // Single Event Display
3624        $("#mec_skin_" + settings.id + " .mec-event-carousel-title a, #mec_skin_" + settings.id + " .mec-event-image a, #mec_skin_" + settings.id + " .mec-booking-button, #mec_skin_" + settings.id + " .mec-event-button").off('click').on('click', function (e) {
3625            var sed_method = $(this).attr('target');
3626            if ('_blank' === sed_method) {
3627
3628                return;
3629            }
3630            e.preventDefault();
3631            var href = $(this).attr('href');
3632
3633            var id = $(this).data('event-id');
3634            var occurrence = get_parameter_by_name('occurrence', href);
3635            var time = get_parameter_by_name('time', href);
3636
3637            if( 'undefined' == typeof id ){
3638                return;
3639            }
3640
3641            mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
3642        });
3643    }
3644}(jQuery));
3645
3646// MEC SLIDER VIEW PLUGIN
3647(function ($) {
3648    $.fn.mecSliderView = function (options) {
3649        // Default Options
3650        var settings = $.extend({
3651            // These are the defaults.
3652            id: 0,
3653            atts: '',
3654            transition_time: 250,
3655            autoplay: false,
3656            ajax_url: '',
3657            sf: {},
3658            start_date: ''
3659        }, options);
3660
3661        var rtl = false;
3662
3663        // Init Sliders
3664        initSlider();
3665
3666        function initSlider() {
3667            // Check RTL website
3668            if ($('body').hasClass('rtl')) rtl = true;
3669
3670            $("#mec_skin_" + settings.id + " .mec-owl-carousel").owlCarousel(
3671                {
3672                    autoplay: true,
3673                    smartSpeed: settings.transition_time,
3674                    autoplayTimeout: settings.autoplay,
3675                    loop: true,
3676                    items: 1,
3677                    responsiveClass: true,
3678                    responsive: {
3679                        0: {
3680                            items: 1,
3681                        },
3682                        960: {
3683                            items: 1,
3684                        },
3685                        1200: {
3686                            items: 1,
3687                        }
3688                    },
3689                    dots: false,
3690                    nav: true,
3691                    autoplayHoverPause: true,
3692                    navText: typeof settings.navText != 'undefined' ? settings.navText : ["<i class='mec-sl-arrow-left'></i>", " <i class='mec-sl-arrow-right'></i>"],
3693                    rtl: rtl,
3694                });
3695        }
3696    };
3697}(jQuery));
3698
3699// MEC COUNTDOWN MODULE
3700(function ($) {
3701    $.fn.mecCountDown = function (options, callBack) {
3702        // Default Options
3703        var settings = $.extend({
3704            // These are the defaults.
3705            date: null,
3706            format: null
3707        }, options);
3708
3709        var callback = callBack;
3710        var selector = $(this);
3711
3712        startCountdown();
3713        var interval = setInterval(startCountdown, 1000);
3714
3715        function startCountdown() {
3716            var eventDate = Date.parse(settings.date) / 1000;
3717            var currentDate = Math.floor($.now() / 1000);
3718
3719            if (eventDate <= currentDate) {
3720                callback.call(this);
3721                clearInterval(interval);
3722            }
3723
3724            var seconds = eventDate - currentDate;
3725
3726            var days = Math.floor(seconds / (60 * 60 * 24));
3727            seconds -= days * 60 * 60 * 24;
3728
3729            var hours = Math.floor(seconds / (60 * 60));
3730            seconds -= hours * 60 * 60;
3731
3732            var minutes = Math.floor(seconds / 60);
3733            seconds -= minutes * 60;
3734
3735            if (days == 1) selector.find(".mec-timeRefDays").text(mecdata.day);
3736            else selector.find(".mec-timeRefDays").text(mecdata.days);
3737
3738            if (hours == 1) selector.find(".mec-timeRefHours").text(mecdata.hour);
3739            else selector.find(".mec-timeRefHours").text(mecdata.hours);
3740
3741            if (minutes == 1) selector.find(".mec-timeRefMinutes").text(mecdata.minute);
3742            else selector.find(".mec-timeRefMinutes").text(mecdata.minutes);
3743
3744            if (seconds == 1) selector.find(".mec-timeRefSeconds").text(mecdata.second);
3745            else selector.find(".mec-timeRefSeconds").text(mecdata.seconds);
3746
3747            if (settings.format === "on") {
3748                days = (String(days).length >= 2) ? days : "0" + days;
3749                hours = (String(hours).length >= 2) ? hours : "0" + hours;
3750                minutes = (String(minutes).length >= 2) ? minutes : "0" + minutes;
3751                seconds = (String(seconds).length >= 2) ? seconds : "0" + seconds;
3752            }
3753
3754            if (!isNaN(eventDate)) {
3755                selector.find(".mec-days").text(days);
3756                selector.find(".mec-hours").text(hours);
3757                selector.find(".mec-minutes").text(minutes);
3758                selector.find(".mec-seconds").text(seconds);
3759            } else {
3760                clearInterval(interval);
3761            }
3762        }
3763    };
3764
3765}(jQuery));
3766
3767// MEC TILE VIEW PLUGIN
3768(function ($) {
3769    $.fn.mecTileView = function (options) {
3770        var active_month;
3771        var active_year;
3772
3773        // Default Options
3774        var settings = $.extend({
3775            // These are the defaults.
3776            today: null,
3777            id: 0,
3778            events_label: 'Events',
3779            event_label: 'Event',
3780            month_navigator: 0,
3781            atts: '',
3782            active_month: {},
3783            next_month: {},
3784            sf: {},
3785            ajax_url: ''
3786        }, options);
3787
3788        // Initialize Month Navigator
3789        if (settings.month_navigator) initMonthNavigator();
3790
3791        // Load Next Month in background
3792        if (settings.load_method === 'month') setMonth(settings.next_month.year, settings.next_month.month, true);
3793
3794        active_month = settings.active_month.month;
3795        active_year = settings.active_month.year;
3796
3797        // Set onclick Listeners
3798        setListeners();
3799
3800        // Search Widget
3801        if (settings.sf.container !== '') {
3802            sf = $(settings.sf.container).mecSearchForm(
3803                {
3804                    id: settings.id,
3805                    refine: settings.sf.refine,
3806                    ajax_url: settings.ajax_url,
3807                    atts: settings.atts,
3808                    callback: function (atts) {
3809                        settings.atts = atts;
3810                        search(active_year, active_month);
3811                    }
3812                });
3813        }
3814
3815        function initMonthNavigator() {
3816            $("#mec_skin_" + settings.id + " .mec-load-month").off("click").on("click", function () {
3817                var year = $(this).data("mec-year");
3818                var month = $(this).data("mec-month");
3819
3820                setMonth(year, month, false, true);
3821            });
3822        }
3823
3824        function search(year, month) {
3825            // Add Loading Class
3826            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
3827            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
3828
3829            $.ajax(
3830                {
3831                    url: settings.ajax_url,
3832                    data: "action=mec_tile_load_month&mec_year=" + year + "&mec_month=" + month + "&" + settings.atts + "&apply_sf_date=1",
3833                    dataType: "json",
3834                    type: "post",
3835                    success: function (response) {
3836                        if (settings.load_method === 'month') {
3837                            active_month = response.current_month.month;
3838                            active_year = response.current_month.year;
3839
3840                            // Append Month
3841                            $("#mec_skin_events_" + settings.id).html('<div class="mec-month-container" id="mec_tile_month_' + settings.id + '_' + response.current_month.id + '" data-month-id="' + response.current_month.id + '">' + response.month + '</div>');
3842
3843                            // Append Month Navigator
3844                            $("#mec_skin_" + settings.id + " .mec-skin-tile-month-navigator-container").append('<div class="mec-month-navigator" id="mec_month_navigator_' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
3845
3846                            // Re-initialize Month Navigator
3847                            initMonthNavigator();
3848
3849                            // Set onclick Listeners
3850                            setListeners();
3851
3852                            // Toggle Month
3853                            toggleMonth(response.current_month.id);
3854                        }
3855                        else {
3856                            // Append Items
3857                            $("#mec_skin_events_" + settings.id).html(response.html);
3858
3859                            // Show load more button
3860                            if (response.count >= settings.limit) $("#mec_skin_" + settings.id + " .mec-load-more-button").removeClass("mec-util-hidden");
3861                            // Hide load more button
3862                            else $("#mec_skin_" + settings.id + " .mec-load-more-button").addClass("mec-util-hidden");
3863
3864                            // Update the variables
3865                            settings.end_date = response.end_date;
3866                            settings.offset = response.offset;
3867
3868                            // Set onclick Listeners
3869                            setListeners();
3870                        }
3871
3872                        // Remove loading Class
3873                        $('.mec-modal-result').removeClass("mec-month-navigator-loading");
3874                    },
3875                    error: function () { }
3876                });
3877        }
3878
3879        function setMonth(year, month, do_in_background, navigator_click) {
3880            if (typeof do_in_background === "undefined") do_in_background = false;
3881            navigator_click = navigator_click || false;
3882
3883            var month_id = year + "" + month;
3884
3885            if (!do_in_background) {
3886                active_month = month;
3887                active_year = year;
3888            }
3889
3890            // Month exists so we just show it
3891            if ($("#mec_tile_month_" + settings.id + "_" + month_id).length) {
3892                // Toggle Month
3893                toggleMonth(month_id);
3894            }
3895            else {
3896                if (!do_in_background) {
3897                    // Add Loading Class
3898                    if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
3899                    jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
3900                }
3901
3902                $.ajax(
3903                    {
3904                        url: settings.ajax_url,
3905                        data: "action=mec_tile_load_month&mec_year=" + year + "&mec_month=" + month + "&" + settings.atts + "&apply_sf_date=0" + "&navigator_click=" + navigator_click,
3906                        dataType: "json",
3907                        type: "post",
3908                        success: function (response) {
3909                            // Append Month
3910                            $("#mec_skin_events_" + settings.id).append('<div class="mec-month-container" id="mec_tile_month_' + settings.id + '_' + response.current_month.id + '" data-month-id="' + response.current_month.id + '">' + response.month + '</div>');
3911
3912                            // Append Month Navigator
3913                            $("#mec_skin_" + settings.id + " .mec-skin-tile-month-navigator-container").append('<div class="mec-month-navigator" id="mec_month_navigator_' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
3914
3915                            // Re-initialize Month Navigator
3916                            initMonthNavigator();
3917
3918                            // Set onclick Listeners
3919                            setListeners();
3920
3921                            if (!do_in_background) {
3922                                // Toggle Month
3923                                toggleMonth(response.current_month.id);
3924
3925                                // Remove loading Class
3926                                $('.mec-modal-result').removeClass("mec-month-navigator-loading");
3927
3928                                // Set Month Filter values in search widget
3929                                $("#mec_sf_month_" + settings.id).val(month);
3930                                $("#mec_sf_year_" + settings.id).val(year);
3931                            }
3932                            else {
3933                                $("#mec_tile_month_" + settings.id + "_" + response.current_month.id).hide();
3934                                $("#mec_month_navigator_" + settings.id + "_" + response.current_month.id).hide();
3935                            }
3936                        },
3937                        error: function () { }
3938                    });
3939            }
3940        }
3941
3942        function toggleMonth(month_id) {
3943            var active_month = $("#mec_skin_" + settings.id + " .mec-month-container-selected").data("month-id");
3944            var active_day = $("#mec_tile_month_" + settings.id + "_" + active_month + " .mec-selected-day").data("day");
3945
3946            if (active_day <= 9) active_day = "0" + active_day;
3947
3948            // Toggle Month Navigator
3949            $("#mec_skin_" + settings.id + " .mec-month-navigator").hide();
3950            $("#mec_month_navigator_" + settings.id + "_" + month_id).show();
3951
3952            // Toggle Month
3953            $("#mec_skin_" + settings.id + " .mec-month-container").hide().removeClass("mec-month-container-selected");
3954            $("#mec_tile_month_" + settings.id + "_" + month_id).show().addClass("mec-month-container-selected");
3955
3956            jQuery(document).trigger('mec_toggle_month', [settings, month_id]);
3957        }
3958
3959        var sf;
3960
3961        function setListeners() {
3962            $("#mec_skin_" + settings.id + " .mec-load-more-button").off("click").on("click", function () {
3963                loadMore();
3964            });
3965
3966            $("#mec_skin_" + settings.id + " article").off("click").on("click", function (e) {
3967                // Link Clicked
3968                if (e.target.nodeName.toLowerCase() === 'a') return;
3969
3970                var href = $(this).data('href');
3971                if (!href) return;
3972
3973                var target = $(this).data('target');
3974
3975                if (target === 'blank') window.open(href, '_blank');
3976                else if (target !== 'm1') document.location.href = href;
3977            });
3978
3979            // Add the onclick event
3980            $("#mec_skin_" + settings.id + " .mec-has-event").off("click").on('click', function (e) {
3981                e.preventDefault();
3982
3983                // define variables
3984                var $this = $(this),
3985                    data_mec_cell = $this.data('mec-cell'),
3986                    month_id = $this.data('month');
3987
3988                $("#mec_monthly_view_month_" + settings.id + "_" + month_id + " .mec-calendar-day").removeClass('mec-selected-day');
3989                $this.addClass('mec-selected-day');
3990
3991                $('#mec_month_side_' + settings.id + '_' + month_id + ' .mec-calendar-events-sec:not([data-mec-cell=' + data_mec_cell + '])').slideUp();
3992                $('#mec_month_side_' + settings.id + '_' + month_id + ' .mec-calendar-events-sec[data-mec-cell=' + data_mec_cell + ']').slideDown();
3993
3994                $('#mec_monthly_view_month_' + settings.id + '_' + month_id + ' .mec-calendar-events-sec:not([data-mec-cell=' + data_mec_cell + '])').slideUp();
3995                $('#mec_monthly_view_month_' + settings.id + '_' + month_id + ' .mec-calendar-events-sec[data-mec-cell=' + data_mec_cell + ']').slideDown();
3996            });
3997
3998            // Single Event Method
3999            if (settings.sed_method != '0') {
4000                sed();
4001            }
4002        }
4003
4004        function sed() {
4005            // Single Event Display
4006            $("#mec_skin_" + settings.id + " .mec-event-content").off('click').on('click', function (e) {
4007
4008                var sed_method = $(this).parent().data('target');
4009                if ('_blank' === sed_method) {
4010                    return;
4011                }
4012                e.preventDefault();
4013                var href = $(this).parent().data('href');
4014
4015                var id = $(this).find('.mec-event-title a').data('event-id');
4016                var occurrence = get_parameter_by_name('occurrence', href);
4017                var time = get_parameter_by_name('time', href);
4018
4019                if( 'undefined' == typeof id ){
4020                    return;
4021                }
4022
4023                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
4024            });
4025        }
4026
4027        function loadMore() {
4028            // Load More Button
4029            var $load_more_button = $("#mec_skin_" + settings.id + " .mec-load-more-button");
4030
4031            // Add loading Class
4032            $load_more_button.addClass("mec-load-more-loading");
4033
4034            $.ajax(
4035                {
4036                    url: settings.ajax_url,
4037                    data: "action=mec_tile_load_more&mec_start_date=" + settings.end_date + "&mec_offset=" + settings.offset + "&" + settings.atts + "&current_month_divider=" + settings.current_month_divider + "&apply_sf_date=0",
4038                    dataType: "json",
4039                    type: "post",
4040                    success: function (response) {
4041                        if (response.count == '0') {
4042                            // Remove loading Class
4043                            $load_more_button.removeClass("mec-load-more-loading");
4044
4045                            // Hide load more button
4046                            $load_more_button.addClass("mec-util-hidden");
4047                        }
4048                        else {
4049                            // Show load more button
4050                            if (typeof response.has_more_event === 'undefined' || (typeof response.has_more_event !== 'undefined' && response.has_more_event)) $load_more_button.removeClass("mec-util-hidden");
4051                            else $load_more_button.addClass("mec-util-hidden");
4052
4053                            // Append Items
4054                            $("#mec_skin_events_" + settings.id).append(response.html);
4055
4056                            // Remove loading Class
4057                            $load_more_button.removeClass("mec-load-more-loading");
4058
4059                            // Update the variables
4060                            settings.end_date = response.end_date;
4061                            settings.offset = response.offset;
4062                            settings.current_month_divider = response.current_month_divider;
4063
4064                            // Single Event Method
4065                            if (settings.sed_method != '0') {
4066                                sed();
4067                            }
4068                        }
4069                    },
4070                    error: function () { }
4071                });
4072        }
4073    };
4074}(jQuery));
4075
4076function mec_gateway_selected(gateway_id) {
4077    // Hide all gateway forms
4078    jQuery('.mec-book-form-gateway-checkout').addClass('mec-util-hidden');
4079
4080    // Show selected gateway form
4081    jQuery('#mec_book_form_gateway_checkout' + gateway_id).removeClass('mec-util-hidden');
4082}
4083
4084function mec_wrap_resize() {
4085    var $mec_wrap = jQuery('.mec-wrap'),
4086        mec_width = $mec_wrap.width();
4087    if (mec_width < 959) {
4088        $mec_wrap.addClass('mec-sm959');
4089    } else {
4090        $mec_wrap.removeClass('mec-sm959');
4091    }
4092}
4093
4094function get_parameter_by_name(name, url) {
4095    if (!url) {
4096        url = window.location.href;
4097    }
4098
4099    name = name.replace(/[\[\]]/g, "\\$&");
4100    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
4101        results = regex.exec(url);
4102
4103    if (!results) return null;
4104    if (!results[2]) return '';
4105
4106    return decodeURIComponent(results[2].replace(/\+/g, " "));
4107}
4108
4109// Focus events day
4110var mec_g_month_id = null;
4111
4112function mecFocusDay(settings) {
4113    if (mec_g_month_id != null) {
4114        setTimeout(function () {
4115            var id = settings.id,
4116                date = new Date(),
4117                mec_owl_year = mec_g_month_id.substr(0, 4),
4118                mec_current_year = date.getFullYear(),
4119                mec_owl_month = mec_g_month_id.substr(4, 6),
4120                mec_current_month = date.getMonth() + 1,
4121                mec_current_day = date.getDate(),
4122                mec_owl_go = jQuery("#mec-owl-calendar-d-table-" + id + "-" + mec_g_month_id),
4123                mec_day_exist = false;
4124            mec_owl_go.find('.owl-stage > div').each(function (index) {
4125                if (parseInt(jQuery(this).children('div').data("events-count")) > 0) {
4126                    if ((((mec_owl_year != mec_current_year) && (mec_owl_month != mec_current_month)) || (mec_owl_year == mec_current_year) && (mec_owl_month != mec_current_month)) || parseInt(jQuery(this).children('div').text()) > mec_current_day) {
4127                        var index_plus = index + 1;
4128                        jQuery('#mec_daily_view_day' + id + '_' + mec_g_month_i
4128d + (index < 10 ? '0' + index_plus : index_plus)).trigger('click');
4129                        mec_owl_go.trigger('to.owl.carousel', index_plus);
4130                        mec_day_exist = true;
4131                        return false;
4132                    }
4133                    else {
4134                        jQuery('#mec_daily_view_day' + id + '_' + mec_g_month_id + mec_current_day).trigger('click');
4135                        mec_owl_go.trigger('to.owl.carousel', mec_current_day);
4136                        mec_day_exist = true;
4137                        return false;
4138                    }
4139                }
4140            });
4141
4142            if (!mec_day_exist && ((mec_owl_year == mec_current_year) && (mec_owl_month == mec_current_month))) {
4143                jQuery('#mec_daily_view_day' + id + '_' + mec_g_month_id + mec_current_day).trigger('click');
4144                mec_owl_go.trigger('to.owl.carousel', mec_current_day);
4145            }
4146        }, 1000);
4147    }
4148}
4149
4150// Focus events week
4151function mec_focus_week(id, skin) {
4152    skin = skin || 'weekly';
4153    var wrap_elem = jQuery('.mec-weeks-container .mec-weekly-view-week-active').parent();
4154    var days = wrap_elem.find('dt');
4155    var week = wrap_elem.find('dl').length;
4156    var focus_week = false;
4157    var i = j = 1;
4158
4159    for (i = 1; i < week; i++) {
4160        setTimeout(function () {
4161            var event = new Event('click');
4162            jQuery('#mec_skin_' + id + ' .mec-previous-month.mec-load-week')[0].dispatchEvent(event);
4163        }, 33);
4164    }
4165
4166    days.each(function (i) {
4167        if (jQuery(this).data('events-count') > 0) {
4168            if (focus_week === false) {
4169                focus_week = parseInt(jQuery(this).parent().data('week-number'));
4170            }
4171
4172            if (skin == 'timetable') {
4173                if (parseInt(jQuery(this).parent().data('week-number')) == parseInt(jQuery('body').data('currentweek'))) {
4174                    focus_week = parseInt(jQuery(this).parent().data('week-number'));
4175                    return false;
4176                }
4177            }
4178            else {
4179                return false;
4180            }
4181        }
4182    });
4183
4184    if (focus_week !== false) {
4185        for (j = 1; j < focus_week; j++) {
4186            setTimeout(function () {
4187                var event = new Event('click');
4188                jQuery('#mec_skin_' + id + ' .mec-next-month.mec-load-week')[0].dispatchEvent(event);
4189            }, 33);
4190        }
4191    }
4192}
4193
4194// TODO must be cleaned JS codes
4195(function ($) {
4196    $(document).ready(function () {
4197        // Check RTL website
4198        if ($('body').hasClass('rtl')) {
4199            var owl_rtl = true;
4200        } else {
4201            var owl_rtl = false;
4202        }
4203
4204        // MEC WIDGET CAROUSEL
4205        $(".mec-widget .mec-event-grid-classic").each(function () {
4206            var loop_status = $(this).data('widget-loop');
4207            if (typeof loop_status === 'undefined') loop_status = 1;
4208
4209            var autoplay_status = $(this).data('widget-autoplay');
4210            if (typeof autoplay_status === 'undefined') autoplay_status = 1;
4211
4212            var autoplay_time = $(this).data('widget-autoplay-time');
4213            if (typeof autoplay_time === 'undefined') autoplay_time = 3000;
4214
4215            $(this).addClass('mec-owl-carousel mec-owl-theme');
4216            $(this).owlCarousel(
4217                {
4218                    autoplay: (autoplay_status ? true : false),
4219                    autoplayTimeout: autoplay_time,
4220                    autoplayHoverPause: true,
4221                    loop: (loop_status ? true : false),
4222                    dots: false,
4223                    nav: true,
4224                    navText: ["<i class='mec-sl-arrow-left'></i>", " <i class='mec-sl-arrow-right'></i>"],
4225                    items: 1,
4226                    autoHeight: true,
4227                    responsiveClass: true,
4228                    rtl: owl_rtl,
4229                });
4230        });
4231
4232        // add mec-sm959 class if mec-wrap div size < 959
4233        mec_wrap_resize();
4234
4235        jQuery(window).bind('resize', function () {
4236            mec_wrap_resize();
4237        });
4238
4239        // Fixed: social hover in iphone
4240        $('.mec-event-sharing-wrap').hover(function () {
4241            $(this).find('.mec-event-sharing').show(0);
4242        },
4243            function () {
4244                $(this).find('.mec-event-sharing').hide(0);
4245            });
4246
4247        // Register Booking Smooth Scroll
4248        $('a.simple-booking[href^="#mec-events-meta-group-booking"]').click(function () {
4249            if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
4250                var target = $(this.hash);
4251                target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
4252
4253                if (target.length) {
4254                    var scrollTopVal = target.offset().top - 30;
4255
4256                    $('html, body').animate({
4257                        scrollTop: scrollTopVal
4258                    }, 600);
4259
4260                    return false;
4261                }
4262            }
4263        });
4264
4265        // Load Information widget under title in mobile/tablet
4266        if ($('.single-mec-events .mec-single-event:not(".mec-single-modern")').length > 0) {
4267            if ($('.single-mec-events .mec-event-info-desktop.mec-event-meta.mec-color-before.mec-frontbox').length > 0) {
4268                var html = $('.single-mec-events .mec-event-info-desktop.mec-event-meta.mec-color-before.mec-frontbox')[0].outerHTML;
4269                if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) < 960) {
4270                    $('.single-mec-events .col-md-4 .mec-event-info-desktop.mec-event-meta.mec-color-before.mec-frontbox').remove();
4271                    $('.single-mec-events .mec-event-info-mobile').html(html)
4272                }
4273            }
4274        }
4275    });
4276})(jQuery);
4277
4278// Weather
4279(function ($) {
4280    // Convart fahrenheit to centigrade
4281    function convertToC(value) {
4282        return Math.round(((parseFloat(value) - 32) * 5 / 9));
4283    }
4284
4285    // Convert centigrade to fahrenheit
4286    function convertToF(value) {
4287        return Math.round(((1.8 * parseFloat(value)) + 32));
4288    }
4289
4290    // Convert miles to kilometers
4291    function MPHToKPH(value) {
4292        return Math.round(1.609344 * parseFloat(value));
4293    }
4294
4295    // Convert kilometers to miles
4296    function KPHToMPH(value) {
4297        return Math.round((0.6214 * parseFloat(value)));
4298    }
4299
4300    $(document).ready(function ($) {
4301        var degree = $('.mec-weather-summary-temp');
4302        var weather_extra = $('.mec-weather-extras');
4303        var wind = weather_extra.children('.mec-weather-wind');
4304        var visibility = weather_extra.children('.mec-weather-visibility');
4305        var feelslike = weather_extra.children('.mec-weather-feels-like');
4306
4307        //  Events
4308        $('.degrees-mode').on('click', function () {
4309            var degree_mode = degree.children('var').text().trim();
4310            var wind_text = wind.text().substring(5);
4311            var visibility_text = visibility.text().substring(11);
4312            var feelslike_text = feelslike.text().substring(12);
4313
4314            if (degree_mode == degree.data('c').trim()) {
4315                degree.html(convertToF(parseInt(degree.text())) + ' <var>' + degree.data('f') + '</var>');
4316                feelslike.html('<span>Feels Like:</span> ' + convertToF(parseInt(feelslike_text)) + ' <var>' + feelslike.data('f') + '</var>');
4317                wind.html('<span>Wind:</span> ' + KPHToMPH(parseInt(wind_text)) + '<var>' + wind.data('mph') + '</var>');
4318                visibility.html('<span>Visibility:</span> ' + KPHToMPH(parseInt(visibility_text)) + '<var>' + visibility.data('mph') + '</var>');
4319                $(this).text($(this).data('metric'));
4320            }
4321            else if (degree_mode == degree.data('f').trim()) {
4322                degree.html(convertToC(parseInt(degree.text())) + ' <var>' + degree.data('c') + '</var>');
4323                feelslike.html('<span>Feels Like:</span> ' + convertToC(parseInt(feelslike_text)) + ' <var>' + feelslike.data('c') + '</var>');
4324                wind.html('<span>Wind:</span> ' + MPHToKPH(parseInt(wind_text)) + '<var>' + wind.data('kph') + '</var>');
4325                visibility.html('<span>Visibility:</span> ' + MPHToKPH(parseInt(visibility_text)) + '<var>' + visibility.data('kph') + '</var>');
4326                $(this).text($(this).data('imperial'));
4327            }
4328        });
4329
4330        $('a').on('click', function () { });
4331
4332        // FES Speakers Adding
4333        $('#mec_add_speaker_button').on('click', function () {
4334            var $this = this;
4335            var content = $($this).parent().find('input');
4336            var list = $('#mec-fes-speakers-list');
4337            var key = list.find('.mec-error').length;
4338
4339            $($this).prop("disabled", true).css('cursor', 'wait');
4340            $.post(ajaxurl, {
4341                action: "speaker_adding",
4342                content: content.val(),
4343                key: key
4344            })
4345                .done(function (data) {
4346                    if ($(data).hasClass('mec-error')) {
4347                        list.prepend(data);
4348                        setTimeout(function () {
4349                            $('#mec-speaker-error-${key}').remove();
4350                        }, 1500);
4351                    } else {
4352                        list.html(data);
4353                        content.val('');
4354                    }
4355
4356                    $($this).prop("disabled", false).css('cursor', 'pointer');
4357                });
4358        });
4359
4360        // Check RTL website
4361        var owl_rtl = $('body').hasClass('rtl') ? true : false;
4362
4363        // MEC FES Date Wrappers
4364        var fes_export_list = $('.mec-export-list-wrapper');
4365
4366        // MEC FES Date Item Event
4367        fes_export_list.find('.mec-export-list-item').click(function () {
4368            $('.mec-export-list-item').removeClass('fes-export-date-active');
4369            $(this).addClass('fes-export-date-active');
4370        });
4371
4372        // MEC BuddyPress Integration Attendees Modules
4373        var mec_bd_attendees_modules = $('.mec-attendees-list-details > ul > li');
4374        mec_bd_attendees_modules.click(function () {
4375            $(this).find('.mec-attendees-toggle').toggle();
4376        });
4377
4378        // MEC FES export csv
4379        $('.mec-event-export-csv, .mec-event-export-excel').click(function () {
4380            var mec_event_id = $(this).parent().parent().data('event-id');
4381
4382            var time = $(this).parent().parent().find($('.fes-export-date-active')).data('time');
4383            if (typeof time === 'undefined') time = 0;
4384
4385            var type = $(this).hasClass('mec-event-export-excel') ? 'ms-excel' : 'csv';
4386
4387            var url = mecdata.ajax_url + "?action=mec_fes_csv_export&fes_nonce=" + mecdata.fes_nonce + "&mec_event_id=" + mec_event_id + "&timestamp=" + time + "&type=" + type;
4388
4389            window.location = url;
4390        });
4391    });
4392})(jQuery);
4393
4394function mec_book_form_submit(event, unique_id) {
4395    event.preventDefault();
4396    window["mec_book_form_submit" + unique_id]();
4397}
4398
4399function mec_book_form_back_btn_cache(context, unique_id) {
4400    var id = jQuery(context).attr('id');
4401    var mec_form_data = jQuery('#mec_book_form' + unique_id).serializeArray();
4402
4403    if (id == "mec-book-form-btn-step-1") jQuery('body').data('mec-book-form-step-1', jQuery('#mec_booking' + unique_id).html()).data('unique-id', unique_id).data('mec-book-form-data-step-1', mec_form_data);
4404    else if (id == "mec-book-form-btn-step-2") jQuery('body').data('mec-book-form-step-2', jQuery('#mec_booking' + unique_id).html()).data('mec-book-form-data-step-2', mec_form_data);
4405}
4406
4407function mec_agreement_change(context) {
4408    var status = jQuery(context).is(":checked");
4409
4410    if (status) jQuery(context).prop("checked", "checked");
4411    else jQuery(context).removeProp("checked");
4412}
4413
4414function mec_book_form_back_btn_click(context, unique_id) {
4415    var id = jQuery(context).attr('id');
4416    unique_id = jQuery('body').data('unique-id');
4417
4418    jQuery('#mec_booking_message' + unique_id).hide();
4419    if (id == "mec-book-form-back-btn-step-2") {
4420        var mec_form_data_step_1 = jQuery('body').data('mec-book-form-data-step-1');
4421        console.log(mec_form_data_step_1);
4422
4423        jQuery('#mec_booking' + unique_id).html(jQuery('body').data('mec-book-form-step-1'));
4424        jQuery.each(mec_form_data_step_1, function(index, object_item)
4425        {
4426            if(object_item.name === 'book[date][]')
4427            {
4428                jQuery('[value="' + object_item.value + '"]').prop('checked', true);
4429            }
4430            else jQuery('[name="' + object_item.name + '"]').val(object_item.value);
4431        });
4432
4433        // Booking Refresh Recaptcha When Back Button Click.
4434        var recaptcha_check = jQuery('#mec_booking' + unique_id).find('#g-recaptcha').length;
4435        if (recaptcha_check != 0) {
4436            jQuery('#g-recaptcha').html('');
4437            grecaptcha.render("g-recaptcha", {
4438                sitekey: mecdata.recapcha_key
4439            });
4440        }
4441
4442        var event_id = jQuery('input[name="event_id"]').val();
4443        var date = jQuery('#mec_book_form_date' + unique_id).val();
4444
4445        // Update Availability
4446        window['mec_get_tickets_availability' + unique_id](event_id, date);
4447    }
4448    else if (id == "mec-book-form-back-btn-step-3") {
4449        var mec_form_data_step_2 = jQuery('body').data('mec-book-form-data-step-2');
4450
4451        jQuery('#mec_booking' + unique_id).html(jQuery('body').data('mec-book-form-step-2'));
4452        jQuery.each(mec_form_data_step_2, function (index, object_item) {
4453            var mec_elem = jQuery('[name="' + object_item.name + '"]');
4454            var mec_type = mec_elem.attr('type');
4455
4456            if ((mec_type == 'checkbox' || mec_type == 'radio')) {
4457                var mec_elem_len = jQuery('[name="' + object_item.name + '"]').length;
4458
4459                if (mec_elem_len > 1) {
4460                    var id = '#' + mec_elem.attr('id').match(/mec_book_reg_field_reg.*_/g) + object_item.value.toLowerCase();
4461                    jQuery(id).prop('checked', true);
4462                }
4463                else {
4464                    mec_elem.prop('checked', true);
4465                }
4466            }
4467
4468            mec_elem.val(object_item.value);
4469        });
4470    }
4471}
4472
4473// Google map Skin
4474function gmapSkin(NewJson) {
4475    var gmap_temp = jQuery("#gmap-data");
4476    var beforeJson = gmap_temp.val();
4477    if (typeof beforeJson === 'undefined') beforeJson = '';
4478
4479    var newJson = NewJson;
4480    var jsonPush = (typeof beforeJson != 'undefined' && beforeJson.trim() == "") ? [] : JSON.parse(beforeJson);
4481    var pushState = jsonPush.length < 1 ? false : true;
4482
4483    for (var key in newJson) {
4484        if (pushState) {
4485            jsonPush.forEach(function (Item, Index) {
4486                var render_location = jsonPush[Index].latitude + "," + jsonPush[Index].longitude;
4487                if (key.trim() == render_location.trim()) {
4488                    // LightBox Count Update
4489                    newJson[key].count = newJson[key].count + jsonPush[Index].count;
4490
4491                    // LightBox Ids Update
4492                    newJson[key].event_ids = newJson[key].event_ids.concat(jsonPush[Index].event_ids);
4493
4494                    // LightBox Initialize
4495                    var dom = jQuery(newJson[key].lightbox).find("div:nth-child(2)");
4496                    var main_items = dom.html();
4497                    var new_items = jQuery(jsonPush[Index].lightbox).find("div:nth-child(2)").html();
4498
4499                    var render_items = dom.html(main_items + new_items).html();
4500                    var new_info_lightbox = '<div><div class="mec-event-detail mec-map-view-event-detail"><i class="mec-sl-map-marker"></i> ' + newJson[key].name + '</div><div>' + render_items + '</div></div>';
4501                    newJson[key].lightbox = new_info_lightbox;
4502
4503                    // LightBox info
4504                    var new_info_window = '<div class="mec-marker-infowindow-wp"><div class="mec-marker-infowindow-count">' + newJson[key].count + '</div><div class="mec-marker-infowindow-content"><span>Event at this location</span><span>' + newJson[key].name + '</span></div></div>';
4505                    newJson[key].infowindow = new_info_window;
4506
4507                    // Remove before values of this location
4508                    jsonPush.splice(Index, 1);
4509                }
4510            });
4511        }
4512
4513        jsonPush.push(newJson[key]);
4514    }
4515
4516    gmap_temp.val(JSON.stringify(jsonPush));
4517    return jsonPush;
4518}
4519
4520// Fluent Scripts
4521jQuery(document).ready(function () {
4522    if (jQuery('.mec-fluent-wrap').length < 0) {
4523        return;
4524    }
4525    // Events
4526    jQuery(window).on('resize', mecFluentToggoleDisplayValueFilterContent);
4527    jQuery(document).on('click', '.mec-fluent-wrap .mec-filter-icon', mecFluentToggleFilterContent);
4528    jQuery(document).on('click', '.mec-fluent-wrap .mec-more-events-icon', mecFluentToggleMoreEvents);
4529    jQuery(document).on('click', '.mec-fluent-wrap .mec-yearly-calendar', mecFluentYearlyCalendar);
4530    jQuery(document).on('click', mecFluentOutsideEvent);
4531    jQuery(document).on('click', '.mec-fluent-more-views-icon', mecFluentMoreViewsContent);
4532    jQuery(document).on('change', '.mec-fluent-wrap .mec-filter-content select, .mec-fluent-wrap .mec-filter-content input', mecFluentSmartFilterIcon);
4533    // Run
4534    mecFluentTimeTableUI();
4535    mecFluentUI();
4536    mecFluentNiceSelect();
4537    mecFluentWrapperFullScreenWidth();
4538    jQuery(window).on('load', mecFluentWrapperFullScreenWidth);
4539    jQuery(window).on('load', mecFluentCurrentTimePosition);
4540    jQuery(window).on('resize', mecFluentWrapperFullScreenWidth);
4541    jQuery(window).on('resize', mecFluentTimeTableUI);
4542    mecFluentSliderUI();
4543    mecFluentFullCalendar();
4544    jQuery(window).on('resize', mecFluentFullCalendar);
4545    mecFluentCustomScrollbar();
4546});
4547
4548function mecFluentSinglePage() {
4549    if (jQuery().niceScroll) {
4550        jQuery('.mec-single-fluent-body .featherlight .mec-single-fluent-wrap').niceScroll({
4551            horizrailenabled: false,
4552            cursorcolor: '#C1C5C9',
4553            cursorwidth: '4px',
4554            cursorborderradius: '4px',
4555            cursorborder: 'none',
4556            railoffset: {
4557                left: 10,
4558            }
4559        });
4560    }
4561}
4562
4563function mecFluentFullCalendar() {
4564    if (jQuery('.mec-fluent-wrap.mec-skin-full-calendar-container').length > 0) {
4565        var widowWidth = jQuery(window).innerWidth();
4566        if (widowWidth <= 767) {
4567            jQuery('.mec-fluent-wrap.mec-skin-full-calendar-container .mec-skin-monthly-view-month-navigator-container, .mec-fluent-wrap.mec-skin-full-calendar-container .mec-calendar-a-month, .mec-fluent-wrap.mec-skin-full-calendar-container .mec-yearly-title-sec').css({
4568                paddingTop: jQuery('.mec-fluent-wrap.mec-skin-full-calendar-container').children('.mec-totalcal-box').height() + 40,
4569            });
4570        } else {
4571            jQuery('.mec-fluent-wrap.mec-skin-full-calendar-container .mec-skin-monthly-view-month-navigator-container, .mec-fluent-wrap.mec-skin-full-calendar-container .mec-calendar-a-month, .mec-fluent-wrap.mec-skin-full-calendar-container .mec-yearly-title-sec').css({
4572                paddingTop: 32,
4573            });
4574        }
4575    }
4576}
4577
4578function mecFluentSmartFilterIcon() {
4579    var filterContent = jQuery(this).closest('.mec-filter-content');
4580    var hasValue = false;
4581    if (jQuery(this).closest('.mec-date-search').length > 0) {
4582        var yearValue = jQuery(this).closest('.mec-date-search').find('select[id*="mec_sf_year"]').val();
4583        var monthValue = jQuery(this).closest('.mec-date-search').find('select[id*="mec_sf_month"]').val();
4584        if ((yearValue == 'none' && monthValue == 'none') || (yearValue != 'none' && monthValue != 'none')) {
4585            filterContent.hide();
4586            if ((yearValue != 'none' && monthValue != 'none')) {
4587                hasValue = true;
4588            } else {
4589                hasValue = false;
4590            }
4591        } else {
4592            return false;
4593        }
4594    } else {
4595        filterContent.hide();
4596    }
4597    if (!hasValue) {
4598        filterContent.find(':not(.mec-date-search)').find('select, input:not([type="hidden"])').each(function () {
4599            if (jQuery(this).val()) {
4600                hasValue = true;
4601                return false;
4602            }
4603        });
4604    }
4605    if (hasValue) {
4606        jQuery(this).closest('.mec-search-form').find('.mec-filter-icon').addClass('active');
4607    } else {
4608        jQuery(this).closest('.mec-search-form').find('.mec-filter-icon').removeClass('active');
4609    }
4610}
4611
4612function mecFluentMoreViewsContent() {
4613    jQuery(this).find('.mec-fluent-more-views-content').toggleClass('active');
4614}
4615
4616function mecFluentWrapperFullScreenWidth() {
4617    if (jQuery('.mec-fluent-bg-wrap').length > 0) {
4618        jQuery('.mec-fluent-bg-wrap').css({
4619            maxWidth: jQuery('body').width() + 8,
4620        });
4621    }
4622}
4623
4624function mecFluentUI() {
4625    if (typeof mecdata != 'undefined' && typeof mecdata.enableSingleFluent != 'undefined' && mecdata.enableSingleFluent) {
4626        jQuery('body').addClass('mec-single-fluent-body');
4627    }
4628    // Set filter content position
4629    jQuery(window).on('load resize', function () {
4630        if (jQuery('.mec-filter-content').length > 0) {
4631            jQuery('.mec-filter-content').css({
4632                right: -(jQuery('.mec-calendar').width() - jQuery('.mec-search-form.mec-totalcal-box').position().left - jQuery('.mec-search-form.mec-totalcal-box').width() + 40),
4633                left: -jQuery('.mec-search-form.mec-totalcal-box').position().left + 40,
4634            });
4635        }
4636        if (jQuery('.mec-filter-icon').is(':visible')) {
4637            var filterIconLeftPosition = parseInt(jQuery('.mec-search-form.mec-totalcal-box').position().left) + parseInt(jQuery('.mec-filter-icon').position().left) - 25;
4638            jQuery('head').find('style[title="mecFluentFilterContentStyle"]').remove().end().append('<style title="mecFluentFilterContentStyle">.mec-fluent-wrap .mec-filter-content:before{left: ' + filterIconLeftPosition + 'px;}.mec-fluent-wrap .mec-filter-content:after{left: ' + (filterIconLeftPosition + 1) + 'px;}</style>');
4639        }
4640    });
4641    // Hide empty filter content
4642    if (jQuery('.mec-filter-content').is(':empty')) {
4643        jQuery('.mec-filter-icon').hide();
4644    }
4645    // Prevend Default For Event Share Icon
4646    jQuery(document).on('click', '.mec-event-share-icon', function (e) {
4647        e.preventDefault();
4648    });
4649}
4650
4651function mecFluentCurrentTimePosition() {
4652    if (jQuery('.mec-fluent-wrap').length > 0) {
4653        jQuery('.mec-fluent-current-time').each(function () {
4654            var currentTimeMinutes = jQuery(this).data('time');
4655            var height = jQuery(this).closest('.mec-fluent-current-time-cell').height();
4656            jQuery(this).css({
4657                top: (currentTimeMinutes / 60) * height,
4658            });
4659        });
4660    }
4661}
4662
4663function mecFluentNiceSelect() {
4664    if (jQuery('.mec-fluent-wrap').length < 0) {
4665        return;
4666    }
4667
4668    if (jQuery().niceSelect) {
4669        jQuery('.mec-fluent-wrap').find('.mec-filter-content').find('select').niceSelect();
4670    }
4671}
4672
4673function mecFluentCustomScrollbar(y) {
4674    if (jQuery('.mec-fluent-wrap').length < 0) {
4675        return;
4676    }
4677
4678    if (jQuery().niceScroll) {
4679        jQuery('.mec-custom-scrollbar').niceScroll({
4680            cursorcolor: '#C7EBFB',
4681            cursorwidth: '4px',
4682            cursorborderradius: '4px',
4683            cursorborder: 'none',
4684            railoffset: {
4685                left: -2,
4686            }
4687        });
4688        jQuery('.mec-custom-scrollbar').getNiceScroll().resize();
4689        jQuery('.mec-custom-scrollbar').each(function () {
4690            if (jQuery(this).find('.mec-fluent-current-time-cell').length > 0) {
4691                var parentTopOffset = jQuery(this).offset().top;
4692                var currentTimeCellOffset = jQuery(this).find('.mec-fluent-current-time-cell').offset().top;
4693                jQuery(this).getNiceScroll(0).doScrollTop(currentTimeCellOffset - parentTopOffset - 16, 120);
4694                jQuery(this).on('scroll', function () {
4695                    if (jQuery(this).getNiceScroll(0).scroll.y != 0) {
4696                        jQuery(this).addClass('mec-scrolling');
4697                    } else {
4698                        jQuery(this).removeClass('mec-scrolling');
4699                    }
4700                });
4701            }
4702            if (typeof y != 'undefined') {
4703                if (jQuery(this).closest('.mec-skin-list-wrap').length > 0 || jQuery(this).closest('.mec-skin-grid-wrap').length > 0) {
4704                    jQuery(this).getNiceScroll(0).doScrollTop(0, 120);
4705                }
4706            }
4707        });
4708    }
4709}
4710
4711function mecFluentTimeTableUI() {
4712    jQuery('.mec-fluent-wrap.mec-timetable-wrap .mec-cell').css('min-height', 0);
4713    var maxHeight = Math.max.apply(null, jQuery('.mec-fluent-wrap.mec-timetable-wrap .mec-cell').map(function () {
4714        return jQuery(this).height();
4715    }).get());
4716    maxHeight = maxHeight > 87 ? maxHeight : 87;
4717    jQuery('.mec-fluent-wrap.mec-timetable-wrap .mec-cell').css('min-height', maxHeight + 2);
4718}
4719
4720function mecFluentSliderUI() {
4721    jQuery(window).on('load', function () {
4722        jQuery('.mec-fluent-wrap.mec-skin-slider-container .owl-next').prepend('<span>Next</span>');
4723        jQuery('.mec-fluent-wrap.mec-skin-slider-container .owl-prev').append('<span>Prev</span>');
4724    });
4725}
4726
4727function mecFluentToggleFilterContent(e) {
4728    e.preventDefault();
4729    if (jQuery('.mec-filter-content').is(':visible')) {
4730        jQuery('.mec-filter-content').css({
4731            display: 'none',
4732        });
4733    } else {
4734        const displayValue = jQuery(window).width() <= 790 ? 'block' : 'flex';
4735        jQuery('.mec-filter-content').css({
4736            display: displayValue,
4737        });
4738    }
4739}
4740
4741function mecFluentToggoleDisplayValueFilterContent() {
4742    const displayValue = jQuery(window).width() <= 767 ? 'block' : 'flex';
4743    if (jQuery('.mec-filter-content').is(':visible')) {
4744        jQuery('.mec-filter-content').css({
4745            display: displayValue,
4746        });
4747    }
4748}
4749
4750function mecFluentToggleMoreEvents(e) {
4751    e.preventDefault();
4752    const moreEventsWrap = jQuery(this).siblings('.mec-more-events-wrap');
4753    const moreEvents = moreEventsWrap.children('.mec-more-events');
4754    jQuery('.mec-more-events-wrap').removeClass('active');
4755    moreEventsWrap.addClass('active');
4756    jQuery('.mec-more-events-wrap:not(.active)').hide();
4757    if (moreEventsWrap.is(':visible')) {
4758        moreEventsWrap.hide();
4759    } else {
4760        topElement = moreEventsWrap.closest('.mec-more-events-inner-controller').length > 0 ? moreEventsWrap.closest('.mec-more-events-inner-controller') : moreEventsWrap.closest('.mec-more-events-controller');
4761        moreEventsWrap.show().css({
4762            top: topElement.offset().top - window.scrollY,
4763            left: moreEventsWrap.closest('.mec-more-events-controller').offset().left,
4764            width: moreEventsWrap.closest('.mec-more-events-controller').width(),
4765        });
4766        if (moreEventsWrap.width() > 400) {
4767            moreEvents.css({
4768                left: (moreEventsWrap.width() / 2) - (moreEvents.width() / 2),
4769                width: 400,
4770            });
4771        } else {
4772            moreEvents.css({
4773                width: moreEventsWrap.width(),
4774                left: 0,
4775            });
4776        }
4777    }
4778}
4779
4780function mecFluentOutsideEvent(e) {
4781    if (!jQuery(e.target).is('.mec-more-events-icon') && !jQuery(e.target).closest('.mec-more-events-wrap').length) {
4782        jQuery('.mec-more-events-wrap').hide();
4783    }
4784    if (!jQuery(e.target).is('.mec-filter-icon') && !jQuery(e.target).closest('.mec-filter-content').length) {
4785        jQuery('.mec-filter-content').hide();
4786    }
4787    if (!jQuery(e.target).is('.mec-fluent-more-views-icon') && !jQuery(e.target).closest('.mec-fluent-more-views-content').length) {
4788        jQuery('.mec-fluent-more-views-content').removeClass('active');
4789    }
4790}
4791
4792function mecFluentYearlyCalendar() {
4793    const monthNum = jQuery(this).data('month');
4794    const monthName = jQuery(this).find('.mec-calendar-table-title').text();
4795    jQuery('.mec-fluent-wrap').find('.mec-yearly-calendar').removeClass('active');
4796    jQuery(this).addClass('active')
4797        .closest('.mec-year-container')
4798        .find('.mec-yearly-agenda-sec-title span').text(monthName).end()
4799        .find('.mec-events-agenda').addClass('mec-util-hidden').end()
4800        .find('.mec-events-agenda[data-month=' + monthNum + ']').removeClass('mec-util-hidden');
4801    mecFluentCustomScrollbar();
4802}
4803
4804function mecFluentYearlyUI(eventID, yearID) {
4805    var fluentWrap = jQuery('#mec_skin_' + eventID + '.mec-fluent-wrap');
4806    if (fluentWrap.length < 0) {
4807        return;
4808    }
4809    var monthNum = fluentWrap.find('.mec-year-container[data-year-id=' + yearID + ']').find('.mec-events-agenda:not(.mec-util-hidden)').data('month');
4810    var activeMonth = fluentWrap.find('.mec-year-container[data-year-id=' + yearID + ']').find('.mec-yearly-calendar[data-month=' + monthNum + ']');
4811    var activeMonthName = activeMonth.find('.mec-calendar-table-title').text();
4812    activeMonth.addClass('active');
4813}
4814
4815// MEC LIST VIEW Fluent PLUGIN
4816(function ($) {
4817    $.fn.mecListViewFluent = function (options) {
4818        var active_month;
4819        var active_year;
4820
4821        // Default Options
4822        var settings = $.extend({
4823            // These are the defaults.
4824            today: null,
4825            id: 0,
4826            events_label: 'Events',
4827            event_label: 'Event',
4828            month_navigator: 0,
4829            atts: '',
4830            active_month: {},
4831            next_month: {},
4832            sf: {},
4833            ajax_url: '',
4834        }, options);
4835
4836        mecFluentCustomScrollbar();
4837
4838        initLoadMore('#mec_list_view_month_' + settings.id + '_' + settings.month_id);
4839
4840        function initLoadMore(monthID) {
4841            $(monthID).off().on('click', '.mec-load-more-button', function () {
4842                loadMore(this);
4843            });
4844        }
4845
4846        function loadMore(This) {
4847            // Add loading Class
4848            var currentLoadMore = $(This);
4849            currentLoadMore.addClass("mec-load-more-loading");
4850            var endDate = currentLoadMore.data('end-date');
4851            var maximumDate = currentLoadMore.data('maximum-date');
4852            var nextOffset = currentLoadMore.data('next-offset');
4853            var year = currentLoadMore.data('year');
4854            var month = currentLoadMore.data('month');
4855
4856            $.ajax({
4857                url: settings.ajax_url,
4858                data: "action=mec_list_load_more&mec_year=" + year + "&mec_month=" + month + "&mec_maximum_date=" + maximumDate + "&mec_start_date=" + endDate + "&mec_offset=" + nextOffset + "&" + settings.atts + "&current_month_divider=0&apply_sf_date=0",
4859                dataType: "json",
4860                type: "post",
4861                success: function (response) {
4862                    currentLoadMore.parent().remove();
4863                    if (response.count != '0') {
4864                        // Append Items
4865                        $('#mec_list_view_month_' + settings.id + '_' + response.current_month.id).append(response.month);
4866
4867                        // Single Event Method
4868                        if (settings.sed_method != '0') {
4869                            sed();
4870                        }
4871
4872                        mecFluentCustomScrollbar();
4873                        initLoadMore('#mec_list_view_month_' + settings.id + '_' + response.current_month.id);
4874                    }
4875                },
4876                error: function () { }
4877            });
4878        }
4879
4880        // Initialize Month Navigator
4881        if (settings.month_navigator) initMonthNavigator();
4882
4883        // Load Next Month in background
4884        setMonth(settings.next_month.year, settings.next_month.month, true);
4885
4886        var initMonth;
4887        var initYear;
4888        active_month = initMonth = settings.active_month.month;
4889        active_year = initYear = settings.active_month.year;
4890
4891        // Search Widget
4892        if (settings.sf.container !== '') {
4893            sf = $(settings.sf.container).mecSearchForm({
4894                id: settings.id,
4895                refine: settings.sf.refine,
4896                ajax_url: settings.ajax_url,
4897                atts: settings.atts,
4898                callback: function (atts) {
4899                    settings.atts = atts;
4900                    search(active_year, active_month);
4901                }
4902            });
4903        }
4904
4905        // Single Event Method
4906        if (settings.sed_method != '0') {
4907            sed();
4908        }
4909
4910        function initMonthNavigator() {
4911            $("#mec_skin_" + settings.id + " .mec-load-month").off().on("click", function () {
4912                var year = $(this).data("mec-year");
4913                var month = $(this).data("mec-month");
4914                setMonth(year, month, false, true);
4915            });
4916        }
4917
4918        function parseQuery(queryString) {
4919            var query = {};
4920            var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
4921            for (var i = 0; i < pairs.length; i++) {
4922                var pair = pairs[i].split('=');
4923                query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
4924            }
4925            return query;
4926        }
4927
4928        function updateQueryStringParameter(uri, key, val) {
4929            return uri
4930                .replace(RegExp("([?&]" + key + "(?=[=&#]|$)[^#&]*|(?=#|$))"), "&" + key + "=" + encodeURIComponent(val))
4931                .replace(/^([^?&]+)&/, "$1?");
4932        }
4933
4934        function search(year, month) {
4935            // Add Loading Class
4936            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
4937            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
4938
4939            var ObjAtts = parseQuery(settings.atts);
4940            if (!(ObjAtts['sf[month'] || ObjAtts['sf[year]'])) {
4941                settings.atts = updateQueryStringParameter(settings.atts.trim(), 'sf[year]', initYear);
4942                settings.atts = updateQueryStringParameter(settings.atts.trim(), 'sf[month]', initMonth);
4943            }
4944
4945            $.ajax({
4946                url: settings.ajax_url,
4947                data: "action=mec_list_load_month&mec_year=" + year + "&mec_month=" + month + "&" + settings.atts + "&apply_sf_date=1",
4948                dataType: "json",
4949                type: "post",
4950                success: function (response) {
4951                    active_month = response.current_month.month;
4952                    active_year = response.current_month.year;
4953
4954                    // Append Month
4955                    $("#mec_skin_events_" + settings.id).html('<div class="mec-month-container" id="mec_list_view_month_' + settings.id + '_' + response.current_month.id + '" data-month-id="' + response.current_month.id + '">' + response.month + '</div>');
4956
4957                    // Append Month Navigator
4958                    $("#mec_skin_" + settings.id + " .mec-skin-list-view-month-navigator-container").html('<div class="mec-month-navigator" id="mec_month_navigator_' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
4959
4960                    // Re-initialize Month Navigator
4961                    initMonthNavigator();
4962
4963                    // Toggle Month
4964                    toggleMonth(response.current_month.id);
4965
4966                    initLoadMore('#mec_list_view_month_' + settings.id + '_' + response.current_month.id);
4967
4968                    // Remove loading Class
4969                    $('.mec-modal-result').removeClass("mec-month-navigator-loading");
4970
4971                    mecFluentCustomScrollbar();
4972
4973                    $(document).trigger('mec_search_process_end', {r:response, settings_id: settings.id});
4974                },
4975                error: function () { }
4976            });
4977        }
4978
4979        function setMonth(year, month, do_in_background, navigator_click) {
4980            if (typeof do_in_background === "undefined") do_in_background = false;
4981            navigator_click = navigator_click || false;
4982            var month_id = year + "" + month;
4983
4984            if (!do_in_background) {
4985                active_month = month;
4986                active_year = year;
4987            }
4988
4989            // Month exists so we just show it
4990            if ($("#mec_list_view_month_" + settings.id + "_" + month_id).length) {
4991                // Toggle Month
4992                toggleMonth(month_id);
4993                mecFluentCustomScrollbar(0);
4994            } else {
4995                if (!do_in_background) {
4996                    // Add Loading Class
4997                    if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
4998                    jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
4999                }
5000
5001                $.ajax({
5002                    url: settings.ajax_url,
5003                    data: "action=mec_list_load_month&mec_year=" + year + "&mec_month=" + month + "&" + settings.atts + "&apply_sf_date=0" + "&navigator_click=" + navigator_click,
5004                    dataType: "json",
5005                    type: "post",
5006                    success: function (response) {
5007                        // Append Month
5008                        $("#mec_skin_events_" + settings.id).append('<div class="mec-month-container" id="mec_list_view_month_' + settings.id + '_' + response.current_month.id + '" data-month-id="' + response.current_month.id + '">' + response.month + '</div>');
5009
5010                        // Append Month Navigator
5011                        $("#mec_skin_" + settings.id + " .mec-skin-list-view-month-navigator-container").append('<div class="mec-month-navigator" id="mec_month_navigator_' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
5012
5013                        // Re-initialize Month Navigator
5014                        initMonthNavigator();
5015                        initLoadMore('#mec_list_view_month_' + settings.id + '_' + response.current_month.id);
5016
5017                        if (!do_in_background) {
5018                            // Toggle Month
5019                            toggleMonth(response.current_month.id);
5020
5021                            // Remove loading Class
5022                            $('.mec-modal-result').removeClass("mec-month-navigator-loading");
5023
5024
5025                            // Set Month Filter values in search widget
5026                            $("#mec_sf_month_" + settings.id).val(month);
5027                            $("#mec_sf_year_" + settings.id).val(year);
5028                        } else {
5029                            $("#mec_list_view_month_" + settings.id + "_" + response.current_month.id).hide();
5030                            $("#mec_month_navigator_" + settings.id + "_" + response.current_month.id).hide();
5031                        }
5032                        if (typeof custom_month !== undefined) var custom_month;
5033                        if (typeof custom_month != undefined) {
5034                            if (custom_month == 'true') {
5035                                $(".mec-month-container .mec-calendar-day").removeClass('mec-has-event');
5036                                $(".mec-month-container .mec-calendar-day").removeClass('mec-selected-day');
5037                                $('.mec-calendar-day').unbind('click');
5038                            }
5039                        }
5040                        if (!do_in_background) {
5041                            mecFluentCustomScrollbar(0);
5042                        }
5043
5044                        if(jQuery().niceSelect) jQuery('.mec-fluent-wrap').find('.mec-filter-content').find('select').niceSelect();
5045
5046                        $(document).trigger('mec_set_month_process_end', {r:response, settings_id: settings.id});
5047                    },
5048                    error: function () { }
5049                });
5050            }
5051        }
5052
5053        function toggleMonth(month_id) {
5054            var active_month = $("#mec_skin_" + settings.id + " .mec-month-container-selected").data("month-id");
5055            var active_day = $("#mec_list_view_month_" + settings.id + "_" + active_month + " .mec-selected-day").data("day");
5056
5057            if (active_day <= 9) active_day = "0" + active_day;
5058
5059            // Toggle Month Navigator
5060            $("#mec_skin_" + settings.id + " .mec-month-navigator").hide();
5061            $("#mec_month_navigator_" + settings.id + "_" + month_id).show();
5062
5063            // Toggle Month
5064            $("#mec_skin_" + settings.id + " .mec-month-container").hide();
5065            $("#mec_list_view_month_" + settings.id + "_" + month_id).show();
5066
5067            // Add selected class
5068            $("#mec_skin_" + settings.id + " .mec-month-container").removeClass("mec-month-container-selected");
5069            $("#mec_list_view_month_" + settings.id + "_" + month_id).addClass("mec-month-container-selected");
5070
5071            jQuery(document).trigger('mec_toggle_month', [settings, month_i
5071d]);
5072        }
5073
5074        var sf;
5075
5076        function sed() {
5077            // Single Event Display
5078            $(".mec-skin-list-wrap#mec_skin_" + settings.id).off('click').on('click', '[data-event-id]', function (e) {
5079                e.preventDefault();
5080                var href = $(this).attr('href');
5081
5082                var id = $(this).data('event-id');
5083                var occurrence = get_parameter_by_name('occurrence', href);
5084                var time = get_parameter_by_name('time', href);
5085
5086                if( 'undefined' == typeof id ){
5087                    return;
5088                }
5089
5090                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
5091            });
5092        }
5093    };
5094}(jQuery));
5095
5096// MEC Grid VIEW Fluent PLUGIN
5097(function ($) {
5098    $.fn.mecGridViewFluent = function (options) {
5099        var active_month;
5100        var active_year;
5101
5102        // Default Options
5103        var settings = $.extend({
5104            // These are the defaults.
5105            today: null,
5106            id: 0,
5107            events_label: 'Events',
5108            event_label: 'Event',
5109            month_navigator: 0,
5110            atts: '',
5111            active_month: {},
5112            next_month: {},
5113            sf: {},
5114            ajax_url: '',
5115        }, options);
5116
5117        initLoadMore('#mec_grid_view_month_' + settings.id + '_' + settings.month_id);
5118
5119        function initLoadMore(monthID) {
5120            $(monthID).off().on('click', '.mec-load-more-button', function () {
5121                loadMore(this);
5122            });
5123        }
5124
5125        function loadMore(This) {
5126            // Add loading Class
5127            var currentLoadMore = $(This);
5128            currentLoadMore.addClass("mec-load-more-loading");
5129            var endDate = currentLoadMore.data('end-date');
5130            var maximumDate = currentLoadMore.data('maximum-date');
5131            var nextOffset = currentLoadMore.data('next-offset');
5132            var year = currentLoadMore.data('year');
5133            var month = currentLoadMore.data('month');
5134
5135            $.ajax({
5136                url: settings.ajax_url,
5137                data: "action=mec_grid_load_more&mec_year=" + year + "&mec_month=" + month + "&mec_maximum_date=" + maximumDate + "&mec_start_date=" + endDate + "&mec_offset=" + nextOffset + "&" + settings.atts + "&current_month_divider=0&apply_sf_date=0",
5138                dataType: "json",
5139                type: "post",
5140                success: function (response) {
5141                    currentLoadMore.parent().remove();
5142                    if (response.count != '0') {
5143                        // Append Items
5144                        $('#mec_grid_view_month_' + settings.id + '_' + response.current_month.id).append(response.month);
5145
5146                        // Single Event Method
5147                        if (settings.sed_method != '0') {
5148                            sed();
5149                        }
5150
5151                        mecFluentCustomScrollbar();
5152                        initLoadMore('#mec_grid_view_month_' + settings.id + '_' + response.current_month.id);
5153                    }
5154                },
5155                error: function () { }
5156            });
5157        }
5158
5159        // Initialize Month Navigator
5160        if (settings.month_navigator) initMonthNavigator();
5161
5162        // Load Next Month in background
5163        setMonth(settings.next_month.year, settings.next_month.month, true);
5164
5165        var initMonth;
5166        var initYear;
5167        active_month = initMonth = settings.active_month.month;
5168        active_year = initYear = settings.active_month.year;
5169
5170        // Search Widget
5171        if (settings.sf.container !== '') {
5172            sf = $(settings.sf.container).mecSearchForm({
5173                id: settings.id,
5174                refine: settings.sf.refine,
5175                ajax_url: settings.ajax_url,
5176                atts: settings.atts,
5177                callback: function (atts) {
5178                    settings.atts = atts;
5179                    search(active_year, active_month);
5180                }
5181            });
5182        }
5183
5184        // Single Event Method
5185        if (settings.sed_method != '0') {
5186            sed();
5187        }
5188
5189        function initMonthNavigator() {
5190            $("#mec_skin_" + settings.id + " .mec-load-month").off().on("click", function () {
5191                var year = $(this).data("mec-year");
5192                var month = $(this).data("mec-month");
5193                setMonth(year, month, false, true);
5194            });
5195        }
5196
5197        function parseQuery(queryString) {
5198            var query = {};
5199            var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
5200            for (var i = 0; i < pairs.length; i++) {
5201                var pair = pairs[i].split('=');
5202                query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
5203            }
5204            return query;
5205        }
5206
5207        function updateQueryStringParameter(uri, key, val) {
5208            return uri
5209                .replace(RegExp("([?&]" + key + "(?=[=&#]|$)[^#&]*|(?=#|$))"), "&" + key + "=" + encodeURIComponent(val))
5210                .replace(/^([^?&]+)&/, "$1?");
5211        }
5212
5213        function search(year, month) {
5214            // Add Loading Class
5215            if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
5216            jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
5217
5218            var ObjAtts = parseQuery(settings.atts);
5219            if (!(ObjAtts['sf[month'] || ObjAtts['sf[year]'])) {
5220                settings.atts = updateQueryStringParameter(settings.atts.trim(), 'sf[year]', initYear);
5221                settings.atts = updateQueryStringParameter(settings.atts.trim(), 'sf[month]', initMonth);
5222            }
5223
5224            $.ajax({
5225                url: settings.ajax_url,
5226                data: "action=mec_grid_load_month&mec_year=" + year + "&mec_month=" + month + "&" + settings.atts + "&apply_sf_date=1",
5227                dataType: "json",
5228                type: "post",
5229                success: function (response) {
5230                    active_month = response.current_month.month;
5231                    active_year = response.current_month.year;
5232
5233                    // Append Month
5234                    $("#mec_skin_events_" + settings.id).html('<div class="mec-month-container" id="mec_grid_view_month_' + settings.id + '_' + response.current_month.id + '" data-month-id="' + response.current_month.id + '">' + response.month + '</div>');
5235
5236                    // Append Month Navigator
5237                    $("#mec_skin_" + settings.id + " .mec-skin-grid-view-month-navigator-container").html('<div class="mec-month-navigator" id="mec_month_navigator_' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
5238
5239                    // Re-initialize Month Navigator
5240                    initMonthNavigator();
5241
5242                    // Toggle Month
5243                    toggleMonth(response.current_month.id);
5244
5245                    initLoadMore('#mec_grid_view_month_' + settings.id + '_' + response.current_month.id);
5246
5247                    // Remove loading Class
5248                    $('.mec-modal-result').removeClass("mec-month-navigator-loading");
5249
5250                    mecFluentCustomScrollbar();
5251                },
5252                error: function () { }
5253            });
5254        }
5255
5256        function setMonth(year, month, do_in_background, navigator_click) {
5257            if (typeof do_in_background === "undefined") do_in_background = false;
5258            navigator_click = navigator_click || false;
5259            var month_id = year + "" + month;
5260
5261            if (!do_in_background) {
5262                active_month = month;
5263                active_year = year;
5264            }
5265
5266            // Month exists so we just show it
5267            if ($("#mec_grid_view_month_" + settings.id + "_" + month_id).length) {
5268                // Toggle Month
5269                toggleMonth(month_id);
5270                mecFluentCustomScrollbar();
5271            } else {
5272                if (!do_in_background) {
5273                    // Add Loading Class
5274                    if (jQuery('.mec-modal-result').length === 0) jQuery('.mec-wrap').append('<div class="mec-modal-result"></div>');
5275                    jQuery('.mec-modal-result').addClass('mec-month-navigator-loading');
5276                }
5277
5278                $.ajax({
5279                    url: settings.ajax_url,
5280                    data: "action=mec_grid_load_month&mec_year=" + year + "&mec_month=" + month + "&" + settings.atts + "&apply_sf_date=0" + "&navigator_click=" + navigator_click,
5281                    dataType: "json",
5282                    type: "post",
5283                    success: function (response) {
5284                        // Append Month
5285                        $("#mec_skin_events_" + settings.id).append('<div class="mec-month-container" id="mec_grid_view_month_' + settings.id + '_' + response.current_month.id + '" data-month-id="' + response.current_month.id + '">' + response.month + '</div>');
5286
5287                        // Append Month Navigator
5288                        $("#mec_skin_" + settings.id + " .mec-skin-grid-view-month-navigator-container").append('<div class="mec-month-navigator" id="mec_month_navigator_' + settings.id + '_' + response.current_month.id + '">' + response.navigator + '</div>');
5289
5290                        // Re-initialize Month Navigator
5291                        initMonthNavigator();
5292                        initLoadMore('#mec_grid_view_month_' + settings.id + '_' + response.current_month.id);
5293
5294                        if (!do_in_background) {
5295                            // Toggle Month
5296                            toggleMonth(response.current_month.id);
5297
5298                            // Remove loading Class
5299                            $('.mec-modal-result').removeClass("mec-month-navigator-loading");
5300
5301
5302                            // Set Month Filter values in search widget
5303                            $("#mec_sf_month_" + settings.id).val(month);
5304                            $("#mec_sf_year_" + settings.id).val(year);
5305                        } else {
5306                            $("#mec_grid_view_month_" + settings.id + "_" + response.current_month.id).hide();
5307                            $("#mec_month_navigator_" + settings.id + "_" + response.current_month.id).hide();
5308                        }
5309                        if (typeof custom_month !== undefined) var custom_month;
5310                        if (typeof custom_month != undefined) {
5311                            if (custom_month == 'true') {
5312                                $(".mec-month-container .mec-calendar-day").removeClass('mec-has-event');
5313                                $(".mec-month-container .mec-calendar-day").removeClass('mec-selected-day');
5314                                $('.mec-calendar-day').unbind('click');
5315                            }
5316                        }
5317                        if (!do_in_background) {
5318                            mecFluentCustomScrollbar();
5319                        }
5320                    },
5321                    error: function () { }
5322                });
5323            }
5324        }
5325
5326        function toggleMonth(month_id) {
5327            var active_month = $("#mec_skin_" + settings.id + " .mec-month-container-selected").data("month-id");
5328            var active_day = $("#mec_grid_view_month_" + settings.id + "_" + active_month + " .mec-selected-day").data("day");
5329
5330            if (active_day <= 9) active_day = "0" + active_day;
5331
5332            // Toggle Month Navigator
5333            $("#mec_skin_" + settings.id + " .mec-month-navigator").hide();
5334            $("#mec_month_navigator_" + settings.id + "_" + month_id).show();
5335
5336            // Toggle Month
5337            $("#mec_skin_" + settings.id + " .mec-month-container").hide();
5338            $("#mec_grid_view_month_" + settings.id + "_" + month_id).show();
5339
5340            // Add selected class
5341            $("#mec_skin_" + settings.id + " .mec-month-container").removeClass("mec-month-container-selected");
5342            $("#mec_grid_view_month_" + settings.id + "_" + month_id).addClass("mec-month-container-selected");
5343
5344            jQuery(document).trigger('mec_toggle_month', [settings, month_id]);
5345        }
5346
5347        var sf;
5348
5349        function sed() {
5350            // Single Event Display
5351            $(".mec-skin-grid-wrap#mec_skin_" + settings.id).off('click').on('click', '[data-event-id]', function (e) {
5352                e.preventDefault();
5353                var href = $(this).attr('href');
5354
5355                var id = $(this).data('event-id');
5356                var occurrence = get_parameter_by_name('occurrence', href);
5357                var time = get_parameter_by_name('time', href);
5358
5359                if( 'undefined' == typeof id ){
5360                    return;
5361                }
5362
5363                mecSingleEventDisplayer.getSinglePage(id, occurrence, time, settings.ajax_url, settings.sed_method, settings.image_popup);
5364            });
5365        }
5366    };
5367}(jQuery));
5368
5369// MEC Booking Calendar
5370(function($)
5371{
5372    $.fn.mecBookingCalendar = function(options)
5373    {
5374        var active_month;
5375        var active_year;
5376
5377        // Default Options
5378        var settings = $.extend({
5379            // These are the defaults.
5380            active_month: {},
5381            next_month: {},
5382            ajax_url: '',
5383            event_id: '',
5384        }, options);
5385
5386        // Initialize Month Navigator
5387        initMonthNavigator();
5388
5389        active_month = settings.active_month.month;
5390        active_year = settings.active_month.year;
5391
5392        // Set onclick Listeners
5393        setListeners();
5394
5395        function initMonthNavigator()
5396        {
5397            // Add onclick event
5398            $("#mec_booking_calendar_" + settings.id + " .mec-load-month").off('click').on('click', function()
5399            {
5400                var year = $(this).data('mec-year');
5401                var month = $(this).data('mec-month');
5402
5403                setMonth(year, month);
5404            });
5405        }
5406
5407        function setMonth(year, month)
5408        {
5409            active_month = month;
5410            active_year = year;
5411
5412            var $modal = $('.mec-modal-result');
5413
5414            // Add Loading Class
5415            if ($modal.length === 0) $('.mec-wrap').append('<div class="mec-modal-result"></div>');
5416            $modal.addClass('mec-month-navigator-loading');
5417
5418            $.ajax(
5419            {
5420                url: settings.ajax_url,
5421                data: "action=mec_booking_calendar_load_month&event_id=" + settings.event_id + "&uniqueid=" + settings.id + "&year=" + year + "&month=" + month,
5422                dataType: "json",
5423                type: "post",
5424                success: function(response)
5425                {
5426                    // HTML
5427                    $('#mec_booking_calendar_wrapper' + settings.id).html(response.html);
5428
5429                    // Hide Message
5430                    $('#mec_book_form' + settings.id + ' .mec-ticket-unavailable-spots').addClass('mec-util-hidden');
5431
5432                    // Empty the Date
5433                    $('#mec_book_form_date' + settings.id).val('').trigger('change');
5434
5435                    // Remove loading Class
5436                    $modal.removeClass("mec-month-navigator-loading");
5437                },
5438                error: function()
5439                {
5440                    // Remove loading Class
5441                    $modal.removeClass("mec-month-navigator-loading");
5442                }
5443            });
5444        }
5445
5446        function setListeners()
5447        {
5448            // Add the onclick event
5449            $("#mec_booking_calendar_" + settings.id + " .mec-booking-calendar-date").off('click').on('click', function(e)
5450            {
5451                e.preventDefault();
5452
5453                // Activate
5454                $("#mec_booking_calendar_" + settings.id + " .mec-booking-calendar-date").removeClass('mec-active');
5455                $("#mec_booking_calendar_" + settings.id + " .mec-calendar-day").removeClass('mec-wrap-active');
5456                $(this).addClass('mec-active');
5457                $(this).parents('.mec-calendar-day').addClass('mec-wrap-active');
5458
5459                // Set Data
5460                var timestamp = $(this).data('timestamp');
5461                $('#mec_book_form_date' + settings.id).val(timestamp).trigger('change');
5462            });
5463
5464            // Add the onclick event on calendar date
5465            $("#mec_booking_calendar_" + settings.id + " .mec-has-one-repeat-in-day").off('click').on('click', function(e)
5466            {
5467                e.preventDefault();
5468
5469                var mec_date_value = $(this).attr('data-timestamp');
5470
5471                // Activate
5472                $("#mec_booking_calendar_" + settings.id + " .mec-has-one-repeat-in-day").removeClass('mec-active');
5473                $("#mec_booking_calendar_" + settings.id + " [data-timestamp=\"" + mec_date_value + "\"]").addClass('mec-active');
5474
5475                // Set Data
5476                var timestamp = $(this).data('timestamp');
5477                $('#mec_book_form_date' + settings.id).val(timestamp).trigger('change');
5478            });
5479
5480            // If day has some time slot
5481            $("#mec_booking_calendar_" + settings.id + " .mec-has-time-repeat .mec-calendar-novel-selected-day").off('click').on('click', function(e)
5482            {
5483                $("#mec_booking_calendar_" + settings.id + " .mec-has-time-repeat").removeClass('mec-wrap-active').removeClass('mec-active');
5484                $(".mec-has-time-repeat").find('.mec-booking-calendar-date').hide();
5485                $(this).parents(".mec-has-time-repeat").find('.mec-booking-calendar-date').toggle();
5486                $(this).parents(".mec-has-time-repeat").addClass('mec-active');
5487            });
5488
5489            // Find more time in tooltip to set button
5490            $("#mec_booking_calendar_" + settings.id + " .mec-has-time-repeat").on('mouseenter', function()
5491            {
5492                var moreTimeFinder = $(this).find(".mec-booking-calendar-date");
5493                if(moreTimeFinder.length >= 1)
5494                {
5495                    $(this).find(".mec-booking-tooltip").removeClass("multiple-time");
5496                    $(this).find(".mec-booking-tooltip").addClass("multiple-time");
5497                }
5498
5499                $(this).find(".mec-booking-calendar-date").css("display", "block");
5500            });
5501
5502            $("#mec_booking_calendar_" + settings.id + " .mec-has-time-repeat").off('click').on('click', function()
5503            {
5504                $("#mec_booking_calendar_" + settings.id + " .mec-has-time-repeat").removeClass('mec-wrap-active').removeClass('mec-active');
5505                $(this).addClass("mec-active");
5506
5507                // Send message under the calendar for multiple time in one day
5508                var sendTimeToMessage = $(this).find(".multiple-time .mec-booking-calendar-date.mec-active").text();
5509
5510                $(this).parents().eq(3).find(".mec-choosen-time-message").removeClass("disable");
5511                $(this).parents().eq(3).find(".mec-choosen-time-message .mec-choosen-time").empty();
5512                $(this).parents().eq(3).find(".mec-choosen-time-message .mec-choosen-time").append(sendTimeToMessage);
5513            });
5514        }
5515    };
5516}(jQuery));
5517
5518// MEC Cart
5519(function($)
5520{
5521    $.fn.mecCart = function(options)
5522    {
5523        // Default Options
5524        var settings = $.extend({
5525            // These are the defaults.
5526            ajax_url: '',
5527        }, options);
5528
5529        // Set DOM Listeners
5530        setListeners();
5531
5532        function setListeners()
5533        {
5534            // Add the onclick event
5535            $(".mec-cart-remove-transactions").off('click').on('click', function(e)
5536            {
5537                e.preventDefault();
5538
5539                var transaction_id = $(this).data('transaction-id');
5540                remove(transaction_id);
5541            });
5542
5543            $('#mec_cart_coupon_form').off('submit').on('submit', function(e)
5544            {
5545                e.preventDefault();
5546                coupon();
5547            });
5548        }
5549
5550        function remove(transaction_id)
5551        {
5552            var $wrapper = $('.mec-cart');
5553
5554            // Add loading Class
5555            $wrapper.addClass('mec-loading');
5556
5557            $.ajax(
5558            {
5559                url: settings.ajax_url,
5560                data: "action=mec_cart_remove_transaction&transaction_id=" + transaction_id,
5561                dataType: "json",
5562                type: "post",
5563                success: function(response)
5564                {
5565                    // Remove Loading Class
5566                    $wrapper.removeClass('mec-loading');
5567
5568                    if(response.success)
5569                    {
5570                        // Remove Transaction Row
5571                        $('#mec_cart_transactions_'+transaction_id).remove();
5572
5573                        if(!$('#mec_cart_transactions_table>tbody>tr').length)
5574                        {
5575                            $('#mec_cart_transactions_table').remove();
5576                            $('.mec-cart-coupon-checkout-action').remove();
5577                            $('.mec-cart-empty-wrapper').removeClass('mec-util-hidden');
5578                        }
5579
5580                        // Update Total Payable Price
5581                        $('#mec_cart_total_payable').html(response.total);
5582                    }
5583                },
5584                error: function(){}
5585            });
5586        }
5587
5588        function coupon()
5589        {
5590            var $wrapper = $('.mec-cart');
5591            var $message = $('#mec_cart_message');
5592
5593            // Add loading Class
5594            $wrapper.addClass('mec-loading');
5595
5596            // Empty Message
5597            $message.html('');
5598
5599            var coupon = $('#mec_cart_coupon_input').val();
5600
5601            $.ajax(
5602            {
5603                url: settings.ajax_url,
5604                data: "action=mec_cart_coupon&coupon=" + coupon,
5605                dataType: "json",
5606                type: "post",
5607                success: function(response)
5608                {
5609                    // Remove Loading Class
5610                    $wrapper.removeClass('mec-loading');
5611
5612                    if(response.success)
5613                    {
5614                        $message.html('<p class="mec-success">'+response.message+'</p>');
5615
5616                        setTimeout(function()
5617                        {
5618                            location.reload();
5619                        }, 2000);
5620                    }
5621                    else
5622                    {
5623                        $message.html('<p class="mec-error">'+response.message+'</p>');
5624                    }
5625                },
5626                error: function(){}
5627            });
5628        }
5629    };
5630}(jQuery));
5631
5632// MEC Checkout
5633(function($)
5634{
5635    $.fn.mecCheckout = function(options)
5636    {
5637        // Default Options
5638        var settings = $.extend({
5639            // These are the defaults.
5640            ajax_url: '',
5641        }, options);
5642
5643        // Set DOM Listeners
5644        setListeners();
5645
5646        function setListeners()
5647        {
5648            // Add the onclick event
5649            $(".mec-checkout-gateways-radio").off('change').on('change', function(e)
5650            {
5651                e.preventDefault();
5652
5653                var gateway_id = $('.mec-checkout-gateways-radio:checked').val();
5654
5655                // Hide all gateway forms
5656                jQuery(".mec-checkout-form-gateway-checkout").addClass("mec-util-hidden");
5657                jQuery(".mec-checkout-price-details-wrapper").addClass("mec-util-hidden");
5658                jQuery(".mec-checkout-price-wrapper").addClass("mec-util-hidden");
5659
5660                // Show selected gateway form
5661                jQuery("#mec_checkout_form_gateway_checkout" + gateway_id).removeClass("mec-util-hidden");
5662                jQuery("#mec-checkout-price-details-wrapper-" + gateway_id).removeClass("mec-util-hidden");
5663                jQuery("#mec-checkout-price-wrapper-" + gateway_id).removeClass("mec-util-hidden");
5664            });
5665
5666            if( $(".mec-checkout-gateways-radio:first").length ){
5667
5668                $(".mec-checkout-gateways-radio:first").prop('checked',true).change();
5669            }else{
5670
5671                jQuery(".mec-checkout-price-details-wrapper:first").removeClass("mec-util-hidden");
5672            }
5673
5674            $('#mec_checkout_form_free_booking').off('submit').on('submit', function(e)
5675            {
5676                e.preventDefault();
5677                free();
5678            });
5679        }
5680
5681        function free()
5682        {
5683            var $wrapper = $('.mec-checkout');
5684            var $message = $('#mec_checkout_message');
5685
5686            // Add loading Class
5687            $wrapper.addClass('mec-loading');
5688
5689            // Empty Message
5690            $message.html('');
5691
5692            var data = $('#mec_checkout_form_free_booking').serialize();
5693
5694            $.ajax(
5695            {
5696                url: settings.ajax_url,
5697                data: data,
5698                dataType: "json",
5699                type: "post",
5700                success: function(response)
5701                {
5702                    // Remove Loading Class
5703                    $wrapper.removeClass('mec-loading');
5704
5705                    if(response.success)
5706                    {
5707                        $message.html('<p class="mec-success">'+response.message+'</p>');
5708                        $wrapper.slideUp().html('');
5709                    }
5710                    else
5711                    {
5712                        $message.html('<p class="mec-error">'+response.message+'</p>');
5713                    }
5714                },
5715                error: function(){}
5716            });
5717        }
5718    };
5719}(jQuery));
5720
5721// Booking Shortcode Scripts
5722jQuery(document).ready(function () {
5723    if (jQuery('.mec-booking-shortcode').length < 0) {
5724        return;
5725    }
5726    // Events
5727    if (jQuery().niceSelect) {
5728        jQuery('.mec-booking-shortcode').find('.mec-book-first').find('select').niceSelect();
5729    }
5730
5731    // General Calendar
5732    if ( jQuery("#gCalendarMonthFilterButton").length > 0 ) {
5733        jQuery("#gCalendarMonthFilterButton").datepicker({
5734            format: "yyyy-mm",
5735            viewMode: "months",
5736            minViewMode: "months"
5737        })
5738        jQuery("#gCalendarMonthFilterButton").datepicker('hide')
5739    }
5740});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.