Last active
March 11, 2020 02:20
-
-
Save kutoi94/0fdae7b5db18bf536ca5cae3b20e45e2 to your computer and use it in GitHub Desktop.
Manager Hotel by Metabox and Fullcalendar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
type: 'post', | |
url: ajaxurl, | |
data: {action: 'feed_events'}, | |
error: function(err){ | |
console.log(err); | |
}, | |
success: function (data) | |
{ | |
init_calendar(data); | |
} | |
}) | |
function init_calendar(events){ | |
var calendarEl = document.getElementById('calendar'); | |
var calendar = new FullCalendar.Calendar(calendarEl, { | |
plugins: [ 'dayGrid' ], | |
defaultView: 'dayGridMonth', | |
header: { | |
left: 'prev,next today', | |
center: 'title', | |
right: '' | |
}, | |
events: events, | |
eventPositioned (view, element) { | |
displayBookings(); | |
}, | |
}); | |
calendar.render(); | |
} | |
$('.filter-bookings').on('click', function(event){ | |
event.stopPropagation(); | |
var room_id = $(this).attr('data-room'); | |
$('.wrap').attr('class', 'wrap ' + room_id); | |
displayBookings(); | |
}) | |
function displayBookings(){ | |
var classes = $('.wrap').attr('class'); | |
if (classes != 'wrap') { | |
room = classes.replace("wrap ", ""); | |
if (room == 'all') { | |
$('[class*="room-"]').show(); | |
} else { | |
$('[class*="room-"]').hide(); | |
$('.room-'+room).show(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment