diff options
Diffstat (limited to 'assets/js/components/calendar.js')
-rw-r--r-- | assets/js/components/calendar.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/assets/js/components/calendar.js b/assets/js/components/calendar.js new file mode 100644 index 00000000..d07c911d --- /dev/null +++ b/assets/js/components/calendar.js @@ -0,0 +1,48 @@ +KB.component('calendar', function (containerElement, options) { + + this.render = function () { + var calendar = $(containerElement); + + calendar.fullCalendar({ + locale: $("body").data("js-lang"), + editable: true, + eventLimit: true, + defaultView: "month", + header: { + left: 'prev,next today', + center: 'title', + right: 'month,agendaWeek,agendaDay' + }, + eventDrop: function(event) { + $.ajax({ + cache: false, + url: options.saveUrl, + contentType: "application/json", + type: "POST", + processData: false, + data: JSON.stringify({ + "task_id": event.id, + "date_due": event.start.format() + }) + }); + }, + viewRender: function() { + var url = options.checkUrl; + var params = { + "start": calendar.fullCalendar('getView').start.format(), + "end": calendar.fullCalendar('getView').end.format() + }; + + for (var key in params) { + url += "&" + key + "=" + params[key]; + } + + $.getJSON(url, function(events) { + calendar.fullCalendar('removeEvents'); + calendar.fullCalendar('addEventSource', events); + calendar.fullCalendar('rerenderEvents'); + }); + } + }); + }; +}); |