@@ -26,6 +26,11 @@ oc.defaultOptions = {
2626 */
2727 editable : false ,
2828
29+ /*
30+ True if the calendar includes holidays
31+ */
32+ showHolidays : false ,
33+
2934 /*
3035 Url which returns all available resources in the following format:
3136 {
@@ -95,7 +100,8 @@ oc.getFullcalendarOptions = function(ocExtendOptions) {
95100 // the fullcalendar default options
96101 var options = {
97102 fc : {
98- allDaySlot : false ,
103+ allDaySlot : ocOptions . showHolidays ,
104+ allDayContent : '' ,
99105 height : 'auto' ,
100106 events : ocOptions . feed ,
101107 slotEventOverlap : false ,
@@ -174,6 +180,9 @@ oc.getFullcalendarOptions = function(ocExtendOptions) {
174180 fcOptions . selectMirror = true ;
175181 fcOptions . unselectCancel = '.popup' ;
176182 fcOptions . selectOverlap = function ( event ) {
183+ if ( event . extendedProps . kind === 'holiday' ) {
184+ return true ;
185+ }
177186 if ( event . display === 'background' ) {
178187 oc . overlappingEvents [ event . id ] = event ;
179188 return true ;
@@ -183,6 +192,9 @@ oc.getFullcalendarOptions = function(ocExtendOptions) {
183192 }
184193 } ;
185194 fcOptions . selectAllow = function ( info ) {
195+ if ( info . allDay ) {
196+ return false ;
197+ }
186198 // we only know what to do if we overlap a single valid allocation
187199 // we only allow to add blockers in the future
188200 var keys = Object . keys ( oc . overlappingEvents ) ;
@@ -236,14 +248,19 @@ oc.getFullcalendarOptions = function(ocExtendOptions) {
236248
237249 // edit events on drag&drop, resize
238250 fcOptions . eventOverlap = function ( stillEvent , movingEvent ) {
239- if ( stillEvent . extendedProps . resource !== movingEvent . extendedProps . resource ) {
240- // NOTE: This doesn't take into account the hierarchy, so it is a little bit
241- // too permissive right now. But the backend still covers us.
251+ if ( stillEvent . display === 'background' || stillEvent . extendedProps . kind === 'holiday' ) {
242252 return true ;
243253 }
244- return stillEvent . display === 'background' ;
254+ // NOTE: This doesn't take into account the hierarchy, so it is a little bit
255+ // too permissive right now. But the backend still covers us.
256+ return stillEvent . extendedProps . resource !== movingEvent . extendedProps . resource ;
245257 } ;
246258
259+ // disallow dropping events into the allDay slot
260+ fcOptions . eventAllow = function ( dropInfo , draggedEvent ) {
261+ return ! dropInfo . allDay ;
262+ }
263+
247264 fcOptions . eventDrop = fcOptions . eventResize = function ( info ) {
248265 var event = info . event ;
249266 var url = new Url ( event . extendedProps . editurl ) ;
@@ -340,6 +357,9 @@ oc.getFullcalendarOptions = function(ocExtendOptions) {
340357 var changed = false ;
341358 for ( var i = 0 ; i < events . length ; i ++ ) {
342359 var event = events [ i ] ;
360+ if ( event . extendedProps . kind === 'holiday' ) {
361+ continue ;
362+ }
343363 // snap to the start of the hour
344364 var start = moment ( event . start ) . startOf ( 'hour' ) . format ( 'HH:mm' ) ;
345365 if ( start < minTime ) {
0 commit comments