Fullcalendar nowIndicator sits at midnight, unless calendar is started with resourceTimelineDay - fullcalendar

When I try to initialize a calendar with anything other than resourceTimelineDay, the nowIndicator doesn't show up in the right place. If I start it with resourceTimelineMonth, it sticks at midnight. If I start it with resourceTimelineWeek, it sticks at the beginning of the hour. If I start it with resourceTimelineDay though, it starts with the correct time, and holds, even if I change the view to week or month view.
I would like to start with month view, and have the nowIndicator show where it is supposed to. This used to work with V3, but now, with V5, it isn't working.
Here is it started with resourceTimelineMonth:
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
timeZone: 'America/Phoenix',
nowIndicator: true,
initialView: 'resourceTimelineMonth',
aspectRatio: 1.5,
headerToolbar: {
left: 'prev,next',
center: 'title',
right: 'resourceTimelineDay,resourceTimelineWeek,resourceTimelineMonth'
},
editable: true,
resourceAreaHeaderContent: 'Rooms',
resources: 'https://fullcalendar.io/api/demo-feeds/resources.json?with-nesting&with-colors',
events: 'https://fullcalendar.io/api/demo-feeds/events.json?single-day&for-resource-timeline'
});
calendar.render();
});
html, body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 14px;
}
#calendar {
max-width: 1100px;
margin: 40px auto;
}
<script src="https://cdn.jsdelivr.net/npm/fullcalendar-scheduler#5.11.3/main.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/fullcalendar-scheduler#5.11.3/main.min.css" rel="stylesheet"/>
<div id='calendar'></div>
Here it is started with resourceTimelineDay:
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
timeZone: 'America/Phoenix',
nowIndicator: true,
initialView: 'resourceTimelineDay',
aspectRatio: 1.5,
headerToolbar: {
left: 'prev,next',
center: 'title',
right: 'resourceTimelineDay,resourceTimelineWeek,resourceTimelineMonth'
},
editable: true,
resourceAreaHeaderContent: 'Rooms',
resources: 'https://fullcalendar.io/api/demo-feeds/resources.json?with-nesting&with-colors',
events: 'https://fullcalendar.io/api/demo-feeds/events.json?single-day&for-resource-timeline'
});
calendar.render();
});
html, body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 14px;
}
#calendar {
max-width: 1100px;
margin: 40px auto;
}
<script src="https://cdn.jsdelivr.net/npm/fullcalendar-scheduler#5.11.3/main.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/fullcalendar-scheduler#5.11.3/main.min.css" rel="stylesheet"/>
<div id='calendar'></div>
Neither resourceTimelineWeek, nor resourceTimelineMonth work as expected, even if you switch to day view.

This is not how it should be done, in my opinion, but it appears there is no official way to change the behavior of the nowIndicator. In lieu of that, the hack is to start in resourceTimelineDay view and change the view to resourceTimelineWeek or resourceTimelineMonth view immediately after the calendar is rendered.
calendar.render();
calendar.changeView('resourceTimelineMonth');
This is a hack, and hopefully there will be a fix for this in some future release.
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
timeZone: 'America/Phoenix',
nowIndicator: true,
initialView: 'resourceTimelineDay',
aspectRatio: 1.5,
headerToolbar: {
left: 'prev,next',
center: 'title',
right: 'resourceTimelineDay,resourceTimelineWeek,resourceTimelineMonth'
},
editable: true,
resourceAreaHeaderContent: 'Rooms',
resources: 'https://fullcalendar.io/api/demo-feeds/resources.json?with-nesting&with-colors',
events: 'https://fullcalendar.io/api/demo-feeds/events.json?single-day&for-resource-timeline'
});
calendar.render();
calendar.changeView('resourceTimelineMonth');
});
html, body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 14px;
}
#calendar {
max-width: 1100px;
margin: 40px auto;
}
<script src="https://cdn.jsdelivr.net/npm/fullcalendar-scheduler#5.11.3/main.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/fullcalendar-scheduler#5.11.3/main.min.css" rel="stylesheet"/>
<div id='calendar'></div>

Related

vue-simple-calendar "classes" item properties not working

I am using vue-simple-calendar as npm calendar package for my vuejs project and I want to implement dynamic classes for each event items. Ex. background-color, etc. But the classes property is not working.
Reference: https://github.com/richardtallent/vue-simple-calendar#calendar-item-properties
Live demo: https://tallent.us/vue-simple-calendar/ (seems to be ok in demo)
Demo (App.vue file): https://github.com/richardtallent/vue-simple-calendar-sample/blob/main/src/App.vue (classes property is implemented)
style property is working:
var app = new Vue({
el: '#app',
data: function() {
return {
showDate: new Date('10/15/2018'),
events: [
{
startDate: '2018-10-06',
endDate: '2018-10-13',
title: 'Sample event 2',
style: 'background-color: red'
}
]
}
},
component: {
"calendar-view": window.CalendarView,
},
methods: {
setShowDate(d) {
this.showDate = d;
},
onClickEvent() { alert('event clicked') }
}
})
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
color: #2c3e50;
height: 67vh;
width: 90vw;
margin-left: auto;
margin-right: auto;
}
<script src="https://unpkg.com/vue#2.5.17/dist/vue.js" ></script>
<script src="https://unpkg.com/vue-simple-calendar#4.1.0/dist/CalendarView.umd.js" ></script>
<div id="app">
<h1>My Calendar</h1>
<calendar-view
:show-date="showDate" :events="events" display-period-uom="month" :display-period-count="4"
class="theme-default holiday-us-traditional holiday-us-official"
#click-event="onClickEvent">
<calendar-view-header
slot="header"
slot-scope="t"
:header-props="t.headerProps"
#input="setShowDate" />
</calendar-view>
</div>
on the other side, classes property is not working:
var app = new Vue({
el: '#app',
data: function() {
return {
showDate: new Date('10/15/2018'),
events: [
{
startDate: '2018-10-06',
endDate: '2018-10-13',
title: 'Sample event 2',
classes: 'bg-red'
}
]
}
},
component: {
"calendar-view": window.CalendarView,
},
methods: {
setShowDate(d) {
this.showDate = d;
},
onClickEvent() { alert('event clicked') }
}
})
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
color: #2c3e50;
height: 67vh;
width: 90vw;
margin-left: auto;
margin-right: auto;
}
.bg-red {
background-color: red
}
<script src="https://unpkg.com/vue#2.5.17/dist/vue.js" ></script>
<script src="https://unpkg.com/vue-simple-calendar#4.1.0/dist/CalendarView.umd.js" ></script>
<div id="app">
<h1>My Calendar</h1>
<calendar-view
:show-date="showDate" :events="events" display-period-uom="month" :display-period-count="4"
class="theme-default holiday-us-traditional holiday-us-official"
#click-event="onClickEvent">
<calendar-view-header
slot="header"
slot-scope="t"
:header-props="t.headerProps"
#input="setShowDate" />
</calendar-view>
</div>
This was a bug in the documentation, now fixed! The classes property is actually expected to be an array of strings, not a single string. *E.g.:
classes: ['bg-red']

ability to add event location to FullCalendarIO

What to know if it is possible to add locations to events in the fullcalendar.io. as nothing in the demo for meeting locations or in documentation?
The document of Event Object mentions that you can include your own fields in the Event Object. FullCalendar will not modify or delete them but also won't render them.
So you can add locations to your events, but you have to find your own way to render them.
You can find the document of eventRender here.
And here is an example for showing the event location:
$(function() {
$('#calendar').fullCalendar({
defaultView: 'month',
defaultDate: '2018-10-07',
header: {
left: 'prev,next',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
events: [{
title: 'Meeting',
start: '2018-10-12T14:30:00',
location: 'Conference Room'
}],
eventRender: function(event, element) {
element.text(element.text() + ' ' + event.location)
}
});
});
html,
body {
margin: 0;
padding: 0;
font-family: "Lucida Grande", Helvetica, Arial, Verdana, sans-serif;
font-size: 14px;
}
#calendar {
max-width: 900px;
margin: 40px auto;
}
<link href="https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.css" rel="stylesheet" />
<script src="https://fullcalendar.io/releases/fullcalendar/3.9.0/lib/jquery.min.js"></script>
<script src="https://fullcalendar.io/releases/fullcalendar/3.9.0/lib/moment.min.js"></script>
<script src="https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.js"></script>
<div id='calendar'></div>
If you want to add fields that aren't included in what FullCalendar will render you can check the doc https://fullcalendar.io/docs/v4/eventRender first of all.
In my case I've done this using the eventRender function to add the location after the already existing text, ofc you need to add the additional fields to the extendedProps:
eventRender: function(info) {
info.el.innerText = info.el.outerText + ' ' + info.event._def.extendedProps.location;
}

fullcalendar, can i add location from gcal and can i give different colors based on different location events (from the same calendar)

this is my code, the calendar and events display correctly but i want to give them more color and a location, can somebody please help?
<!DOCTYPE html> <html> <head> <meta charset='utf-8' />
<link href='fullcalendar-3.8.0/fullcalendar.min.css' rel='stylesheet' />
<link href='fullcalendar-3.8.0/fullcalendar.print.min.css' rel='stylesheet' media='print' />
<script src='fullcalendar-3.8.0/lib/moment.min.js'></script>
<script src='fullcalendar-3.8.0/lib/jquery.min.js'></script>
<script src='fullcalendar-3.8.0/fullcalendar.min.js'></script>
<script src='fullcalendar-3.8.0/gcal.min.js'></script>
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
displayEventTime: true, // don't show the time column in list view
editable: true, defaultView: 'agendaWeek',
googleCalendarApiKey: 'private',
// Key van de google calender
events: { url:'private' },
eventClick: function(event) {
// opens events in a popup window
window.open(event.url, 'gcalevent', 'width=700,height=600');
return false;
},
loading: function(bool) {
$('#loading').toggle(bool);
}
});
});
</script>
<style>
body {
margin: 40px 10px;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
font-size: 14px;
}
#loading {
display: none;
position: absolute;
top: 10px;
right: 10px;
}
#calendar {
max-width: 900px;
margin: 0 auto; }
</style>
</head>
<body>
<div id='loading'>loading...</div>
<div id='calendar'></div>
</body>
</html>

fullcalendar get event details on event click

I created a calendar using fullcalender all the events (tasks) are displaying on it.
Now i want to open a form which display the event's details, how can i taking the event details by clicking on it?
my code:
<script>
$(document).ready(function () {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-09-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'Meeting',
start: '2014-09-12T10:30:00',
end: '2014-09-12T12:30:00'
}
]
});
});
</script>
<style>
body {
margin-top: 40px;
text-align: center;
font-size: 13px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
#calendar {
width: 900px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
</body>
Check the full calendar documentation. Here is the link.
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-09-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'Meeting',
start: '2014-09-12T10:30:00',
end: '2014-09-12T12:30:00'
}
],
eventClick: function(event) {
if (event.title) {
alert(event.title);
}
}
});

my fullcalendar page works fine with Chrome,But not in IE6 and Firefox

I have made a PHP script with fullcalendar, It works fine with Chrome,But not in IE6 and Firefox, actually I just follow the documents and demo, I'm puzzled what's wrong ?
The page's URL is http://jiangzuokong.com/cal.php
script like follows:
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
editable: false,
events: [
{
title : '资本主义作为一种历史现象',
start : '2011-3-7',
url : 'http://jiangzuokong.com/forum.php?mod=viewthread&tid=80&from=portal'
},
title : '【在文学馆听讲座】关仁山:乡村社会转型中的文学[北京]',
start : '2011-3-13',
url : 'http://jiangzuokong.com/forum.php?mod=viewthread&tid=104&from=portal'
}, {
title : 'Survival Chinese:Ordering Food[北京]',
start : '2011-3-13',
url : 'http://jiangzuokong.com/forum.php?mod=viewthread&tid=105&from=portal'
}, {
title : '',
start : '',
url : ''
} ]
});
});
</script>
<style type='text/css'>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
#calendar {
width: 900px;
margin: 0 auto;
}
</style>
</head>

Resources