Viewing 1 post (of 1 total)
  • Author
    Posts
  • #8450
    permanyer
    Participant

    Hi again,

    On the calendar view, I was trying to style on past and today events so that they look different than future events.
    This is not possible with the default fullcalendar rendering, but i found this post which points out a solution.

    Then, in your file front-calendar.js i added the following script before calling fullcalendar:

    args['eventRender'] = function(event, element, view) {                   
        var ntoday = new Date().getTime();
        var eventEnd = moment( event.end ).valueOf();
        var eventStart = moment( event.start ).valueOf();
    
        if( moment( event.start ).diff(moment(ntoday),'days') == 0){
    		element.addClass("fc-today");
            element.children().addClass("fc-today");
    	}
    
        if (!event.end){
            if (eventStart < ntoday){
                element.addClass("fc-past");
                element.children().addClass("fc-past");
            }
    
        } else {
            if (eventEnd < ntoday){
                element.addClass("fc-past");
                element.children().addClass("fc-past");
            }
        }
    }

    This way, the according events will have an fc-past or fc-today class (as day-numbers and cell backgrounds already do), thus become easy to style.

    It’s first pass code, but i think it is a good feature to implement.
    I do not know if it would be possible to pass this funcion code via json in the em_get_full_calendar_script_args filter to leave your doc unchanged (i was not able).

    Moreover, i addded element.removeAttr(‘href’); to past events, so they are not clickable.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.