Skip to content

Commit

Permalink
Merge pull request #17 from ox-it/calendar-params
Browse files Browse the repository at this point in the history
Allow users to specify fullcalendar parameters
  • Loading branch information
martinfilliau committed Feb 4, 2015
2 parents fbfb9cd + 3dd5a34 commit 9b8c270
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
12 changes: 12 additions & 0 deletions widget/embed_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ <h1>Example of embedding</h1>
<div id="embedded-calendar" style="max-width:800px"></div>

<script>

// Optionally specify a set of parameters for initialising the fullcalendar, e.g. to customise appearance, timescale etc.
var calParams = {
//firstDay: 1, //sets the week to start on Monday, rather than Sunday
//contentHeight: 400, //override the height of the calendar
//eventColor: '#88ff88', //customise colouring
//eventTextColor: '#111111', //customise colouring
//defaultView: 'basicWeek', //start on the week view instead of the month view
// See http://fullcalendar.io/docs/ for a full list of possible parameters
};

var params =
{ from: "today", //Start date range - dd/mm/yy. Required
//to: null, //end date range, - dd/mm/yy
Expand All @@ -23,6 +34,7 @@ <h1>Example of embedding</h1>
//topics: [], //array of FAST topic URIs
//url: null, //url stem for the API request. Defaults to http://talks.ox.ac.uk/api/talks/search?
//page_size: 2 //optionally specify the page size for pagination of results.
calendarParams: calParams //optionally supply parameters for the fullCalendar plugin
};


Expand Down
32 changes: 18 additions & 14 deletions widget/embed_ox_talks.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ var oxtalks = {
};

return {
events: events.bind(this)
//TODO Customise colours, editability here
events: events.bind(this),
}
},

Expand Down Expand Up @@ -325,20 +324,25 @@ var oxtalks = {
params.page_size = 100;

//Create calendar
var eventSource = this.createEventSource(params);
$(selector).fullCalendar({
eventSources: [ eventSource ],
eventColor: '#002147',
textColor: 'white',
editable: false,
header: {
var fullCalendarParams = params.calendarParams? params.calendarParams : {};
fullCalendarParams.eventSources = [this.createEventSource(params)];
fullCalendarParams.eventDataTransform = this.ConvertToCalendarEvent;
fullCalendarParams.eventMouseover = this.onCalMouseOver;
fullCalendarParams.eventMouseout = this.onCalMouseOut;

//set some suitable default calendar params if none are specified
if(!fullCalendarParams.eventColor) { fullCalendarParams.eventColor='#002147'; }
if(!fullCalendarParams.textColor) { fullCalendarParams.textColor='white'; }
if(!fullCalendarParams.editable) { fullCalendarParams.editable=false; }
if(!fullCalendarParams.header) {
fullCalendarParams.header = {
left: 'title',
center: '',
right: 'prev,today,next month,basicWeek'
},
eventDataTransform: this.ConvertToCalendarEvent,
eventMouseover: this.onCalMouseOver,
eventMouseout: this.onCalMouseOut,
});
};
}

$(selector).fullCalendar(fullCalendarParams);

},
}

0 comments on commit 9b8c270

Please sign in to comment.