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 if (Options.attributes.hasOwnProperty('show_busy_only')) { 92 data.show_busy_only = Options.attributes.show_busy_only; 93 } 94 return data; 95 } 96 }],
97 eventBackgroundColor: '#ccc', 98 loading: function (isLoading) { 99 if (isLoading) { 100 $('.bookly-ec-loading').show(); 101 } else { 102 $('.bookly-ec-loading').hide(); 103 } 104 }, 105 eventContent: function (arg) { 106 if (arg.event.display === 'background') { 107 return ''; 108 } 109 let event = arg.event; 110 let props = event.extendedProps; 111 let nodes = []; 112 let $time = $('<div class="ec-event-time"/>'); 113 let $title = $('<div class="ec-event-title"/>'); 114 115 $time.append(props.header_text || (arg.event.display !== 'pointer' ? moment(arg.event.start).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat) + ' - ' + moment(arg.event.end).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat) : moment(arg.event.start).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat))); 116 nodes.push($time.get(0)); 117 118 $title.append(event.title || ''); 119 nodes.push($title.get(0)); 120 121 switch (props.overall_status) { 122 case 'pending': 123 $time.addClass('text-muted'); 124 $title.addClass('text-muted'); 125 break; 126 case 'rejected': 127 case 'cancelled': 128 $time.addClass('text-muted').wrapInner('<s>'); 129 $title.addClass('text-muted'); 130 break; 131 } 132 133 return {domNodes: nodes}; 134 }, 135 theme: function (theme) { 136 theme.button = 'btn btn-default'; 137 theme.buttonGroup = 'btn-group'; 138 theme.active = 'active'; 139 return theme; 140 } 141 }; 142 let dateSetFromDatePicker = false; 143 144 // Init EventCalendar. 145 let calendar = EventCalendar.create($container.get(0), $.extend(true, {}, options, { 146 // General Display. 147 headerToolbar: { 148 start: 'prev,next today', 149 center: 'title', 150 end: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek' 151 }, 152 // Views. 153 view: !getCookie('bookly_cal_view') || getCookie('bookly_cal_view') === 'undefined' ? 'dayGridMonth' : getCookie('bookly_cal_view'), 154 views: { 155 resourceTimeGridDay: { 156 resources: [1], 157 filterResourcesWithEvents: BooklyL10nFrontendCalendar.filterResourcesWithEvents, 158 titleFormat: {year: 'numeric', month: 'short', day: 'numeric', weekday: 'short'} 159 } 160 }, 161 viewDidMount: function (info) { 162 calendar.setOption('height', heightEC(info.view.type)); 163 setCookie('bookly_cal_view', info.view.type); 164 }, 165 height: heightEC('dayGridMonth'), 166 eventTimeFormat: function (start, end) { 167 if (start.getTime() === end.getTime()) { 168 return moment(start).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat); 169 } else { 170 return moment(start).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat) + ' - ' + moment(end).locale('bookly').format(BooklyL10nFrontendCalendar.mjsTimeFormat); 171 } 172 }, 173 })); 174 175 $('.ec-toolbar .ec-title', $container).daterangepicker({ 176 parentEl: '.' + Options.calendar_js, 177 singleDatePicker: true, 178 showDropdowns: true, 179 autoUpdateInput: false, 180 locale: BooklyL10nFrontendCalendar.datePicker 181 }, function (start) { 182 dateSetFromDatePicker = true; 183 if (calendar.getView().type !== 'timeGridDay' && calendar.getView().type !== 'resourceTimeGridDay') { 184 calendar.setOption('highlightedDates', [start.toDate()]); 185 } 186 calendar.setOption('date', start.toDate()); 187 }); 188 189 function heightEC(view_type) { 190 let calendar_tools_height = 71, 191 day_head_height = 28, 192 slot_height = 17.85, 193 weeks_rows = 5, 194 day_slots_count = 5, 195 height = (calendar_tools_height + (day_slots_count * slot_height + day_head_height) * weeks_rows) 196 ; 197 if (view_type != 'dayGridMonth') { 198 if ($('.ec-content', $container).height() < height) { 199 height = 'auto'; 200 } 201 } 202 return height === 'auto' ? 'auto' : (calendar_tools_height + height) + 'px'; 203 } 204 205 $(window).on('resize', function () { 206 calendar.setOption('height', heightEC(calendar.getOption('view'))); 207 }); 208 209 /** 210 * Set cookie. 211 * 212 * @param key 213 * @param value 214 */ 215 function setCookie(key, value) { 216 var expires = new Date(); 217 expires.setFullYear(expires.getFullYear() + 3); 218 document.cookie = key + '=' + value + ';expires=' + expires.toUTCString(); 219 } 220 221 /** 222 * Get cookie. 223 * 224 * @param key 225 * @return {*} 226 */ 227 function getCookie(key) { 228 var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); 229 return keyValue ? keyValue[2] : null; 230 } 231 } 232})(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.