PageSourceSearch

https://holtriem.de/wp-content/plugins/bookly-addon-pro/frontend/m…/resources/js/frontend-calendar.js?ver=25.9

js holtriem.de collected 2026-10-02 18:21:09 UTC 8,426 bytes, 199 lines download raw bytes

1(function ($) {
2    window.booklyFrontendCalendar = function (Options) {
3        let $container = $('.' + Options.calendar_js);
4        if (!$container.length) {
5            return;
6        }
7        // Special locale for moment
8        moment.locale('bookly', {
9            months: BooklyL10nFrontendCalendar.datePicker.monthNames,
10            monthsShort: BooklyL10nFrontendCalendar.datePicker.monthNamesShort,
11            weekdays: BooklyL10nFrontendCalendar.datePicker.dayNames,
12            weekdaysShort: BooklyL10nFrontendCalendar.datePicker.dayNamesShort,
13            meridiem: function (hours, minutes, isLower) {
14                return hours < 12
15                    ? BooklyL10nFrontendCalendar.datePicker.meridiem[isLower ? 'am' : 'AM']
16                    : BooklyL10nFrontendCalendar.datePicker.meridiem[isLower ? 'pm' : 'PM'];
17            },
18        });
19        let options = {
20            view: 'timeGridWeek',
21            views: {
22                dayGridMonth: {
23                    dayHeaderFormat: function (date) {
24                        return moment(date).locale('bookly').format('ddd');
25                    },
26                    displayEventEnd: true,
27                    dayMaxEvents: true
28                },
29                timeGridDay: {
30                    dayHeaderFormat: function (date) {
31                        return moment(date).locale('bookly').format('dddd');
32                    },
33                    pointer: true
34                },
35                timeGridWeek: {pointer: true},
36                resourceTimeGridDay: {pointer: true}
37            },
38            hiddenDays: BooklyL10nFrontendCalendar.hiddenDays,
39            slotDuration: BooklyL10nFrontendCalendar.slotDuration,
40            slotMinTime: BooklyL10nFrontendCalendar.slotMinTime,
41            slotMaxTime: BooklyL10nFrontendCalendar.slotMaxTime,
42            scrollTime: BooklyL10nFrontendCalendar.scrollTime,
43            moreLinkContent: function (arg) {
44                return BooklyL10nFrontendCalendar.more.replace('%d', arg.num)
45            },
46            flexibleSlotTimeLimits: true,
47            eventStartEditable: false,
48            eventDurationEditable: false,
49            allDaySlot: false,
50
51            slotLabelFormat: function (date) {
52                return moment(date).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat);
53            },
54            eventTimeFormat: function (date) {
55                return moment(date).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat);
56            },
57            dayHeaderFormat: function (date) {
58                return moment(date).locale('bookly').format('ddd, D');
59            },
60            listDayFormat: function (date) {
61                return moment(date).locale('bookly').format('dddd');
62            },
63            firstDay: BooklyL10nFrontendCalendar.datePicker.firstDay,
64            locale: BooklyL10nFrontendCalendar.locale.replace('_', '-'),
65            buttonText: {
66                today: BooklyL10nFrontendCalendar.today,
67                dayGridMonth: BooklyL10nFrontendCalendar.month,
68                timeGridWeek: BooklyL10nFrontendCalendar.week,
69                timeGridDay: BooklyL10nFrontendCalendar.day,
70                resourceTimeGridDay: BooklyL10nFrontendCalendar.day,
71                listWeek: BooklyL10nFrontendCalendar.list
72            },
73            noEventsContent: BooklyL10nFrontendCalendar.noEvents,
74            eventSources: [{
75                url: ajaxurl,
76                method: 'POST',
77                extraParams: function () {
78                    let data = {
79                        action: 'bookly_pro_get_calendar_appointments',
80                        csrf_token: BooklyL10nGlobal.csrf_token,
81                    };
82                    if (Options.attributes.hasOwnProperty('location_id')) {
83                        data.location_id = Options.attributes.location_id;
84                    }
85                    if (Options.attributes.hasOwnProperty('staff_id')) {
86                        data.staff_id = Options.attributes.staff_id;
87                    }
88                    if (Options.attributes.hasOwnProperty('service_id')) {
89                        data.service_id = Options.attributes.service_id;
90                    }
91                    return data;
92                }
93            }],
94            eventBackgroundColor: '#ccc',
95            loading: function (isLoading) {
96                if (isLoading) {
97                    $('.bookly-ec-loading').show();
98                } else {
99                    $('.bookly-ec-loading').hide();
100                }
101            },
102            theme: function (theme) {
103                theme.button = 'btn btn-default';
104                theme.buttonGroup = 'btn-group';
105                theme.active = 'active';
106                return theme;
107            }
108        };
109        let dateSetFromDatePicker = false;
110
111        // Init EventCalendar.
112        let calendar = EventCalendar.create($container.get(0), $.extend(true, {}, options, {
113            // General Display.
114            headerToolbar: {
115                start: 'prev,next today',
116                center: 'title',
117                end: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
118            },
119            // Views.
120            view: getCookie('bookly_cal_view') ? getCookie('bookly_cal_view') : 'dayGridMonth',
121            views: {
122                resourceTimeGridDay: {
123                    resources: [1],
124                    filterResourcesWithEvents: BooklyL10nFrontendCalendar.filterResourcesWithEvents,
125                    titleFormat: {year: 'numeric', month: 'short', day: 'numeric', weekday: 'short'}
126                }
127            },
128            viewDidMount: function (view) {
129                calendar.setOption('height', heightEC(view.type));
130                setCookie('bookly_cal_view', view.type);
131            },
132            height: heightEC('dayGridMonth'),
133            eventTimeFormat: function (start, end) {
134                if (start.getTime() === end.getTime()) {
135                    return moment(start).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat);
136                } else {
137                    return moment(start).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat) + ' - ' + moment(end).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat);
138                }
139            },
140        }));
141
142        $('.ec-toolbar .ec-title', $container).daterangepicker({
143            parentEl: '.' + Options.calendar_js,
144            singleDatePicker: true,
145            showDropdowns: true,
146            autoUpdateInput: false,
147            locale: BooklyL10nFrontendCalendar.datePicker
148        }, function (start) {
149            dateSetFromDatePicker = true;
150            if (calendar.getView().type !== 'timeGridDay' && calendar.getView().type !== 'resourceTimeGridDay') {
151                calendar.setOption('highlightedDates', [start.toDate()]);
152            }
153            calendar.setOption('date', start.toDate());
154        });
155
156        function heightEC(view_type) {
157            let calendar_tools_height = 71,
158                day_head_height = 28,
159                slot_height = 17.85,
160                weeks_rows = 5,
161                day_slots_count = 5,
162                height = (calendar_tools_height + (day_slots_count * slot_height + day_head_height) * weeks_rows)
163            ;
164            if (view_type != 'dayGridMonth') {
165                if ($('.ec-content', $container).height() < height) {
166                    height = 'auto';
167                }
168            }
169            return height === 'auto' ? 'auto' : (calendar_tools_height + height) + 'px';
170        }
171
172        $(window).on('resize', function () {
173            calendar.setOption('height', heightEC(calendar.getOption('view')));
174        });
175
176        /**
177         * Set cookie.
178         *
179         * @param key
180         * @param value
181         */
182        function setCookie(key, value) {
183            var expires = new Date();
184            expires.setFullYear(expires.getFullYear() + 3);
185            document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
186        }
187
188        /**
189         * Get cookie.
190         *
191         * @param key
192         * @return {*}
193         */
194        function getCookie(key) {
195            var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
196            return keyValue ? keyValue[2] : null;
197        }
198    }
199})(jQuery);

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.