Skip to content

Instantly share code, notes, and snippets.

@kartikparmar
Created February 9, 2021 08:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
jQuery( document ).ready(function($) {
const calendarEl = document.getElementById( 'calendar' );
var cal = new FullCalendar.Calendar(calendarEl, {
noEventsMessage: 'No Events',
timeZone: 'Europe/London',
plugins: [ 'rrule', 'dayGrid','list' ],
header: {"left":"title","center":"","right":"prev,next"},
defaultView: 'listWeek',
loading: function (isLoading) {
bkapListing.loading( isLoading, false )
},
events: [
{
"id": 15586,
"title": "Sunday Reopen",
"url": "https://localhost/rental/product/sunday-reopen-2/",
"allDay": false,
"rrule": {
"dtstart": "2021-02-09",
"freq": "daily",
"interval": 1,
"until": "2021-09-12 23:59:00",
"byweekday": [
"su"
],
"byhour": [
"23"
],
"byminute": [
"30"
]
},
"extendedProps": {
"productType": "simple",
"bookingType": "date_time",
"view": "list",
"greyOutBooked": "true",
"showQuantity": "false",
"holidays": [
""
],
"showTime": true,
"price": "0",
"sort": 0,
"timeslot_value": "23:30 - 00:30"
},
"duration": "01:00"
}
],
eventOrder: 'sort, start,-duration,allDay,title',
eventRender: function(info) {
bkapListing.eventRender( info, false );
},
allDayText: 'All Day',
datesRender: function( info ) {
let start = info.view.currentStart;
if ( moment() >= start ) {
$(".fc-prev-button").prop('disabled', true);
$(".fc-prev-button").addClass('fc-state-disabled');
} else {
$(".fc-prev-button").removeClass('fc-state-disabled');
$(".fc-prev-button").prop('disabled', false);
}
},
firstDay: 0,
eventClick: function( info ) { // Adding date param to url when Calendar view
info.jsEvent.preventDefault(); // don't let the browser navigate
let cal_view = [ 'dayGridMonth', 'dayGridWeek', 'dayGridDay' ];
let view_type = info.view.type;
let clicked_date = moment( info.event.start ).format( 'YYYY-MM-DD' );
if ( info.event.url ) {
if( cal_view.includes( view_type ) ) {
window.open( info.event.url + '?bkap_date=' + clicked_date );
}
}
},
locale: 'hi',
});
cal.render();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment