2013-02-23 20:42:15 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
define(['app', 'Calendar/CalendarItemView'], function (app) {
|
|
|
|
NzbDrone.Calendar.CalendarCollectionView = Backbone.Marionette.CompositeView.extend({
|
|
|
|
itemView: NzbDrone.Calendar.CalendarItemView,
|
2013-02-26 06:30:24 +03:00
|
|
|
itemViewContainer: '#upcomingContainer',
|
2013-02-23 20:42:15 +03:00
|
|
|
template: 'Calendar/CalendarCollectionTemplate',
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
calendar: '#calendar'
|
|
|
|
},
|
|
|
|
|
2013-02-28 07:48:31 +03:00
|
|
|
initialize: function (context, action, query, collection) {
|
2013-02-25 03:00:17 +03:00
|
|
|
this.collection = collection;
|
2013-02-26 06:30:24 +03:00
|
|
|
this.calendar = new NzbDrone.Calendar.CalendarCollection();
|
2013-02-23 20:42:15 +03:00
|
|
|
},
|
2013-02-26 06:30:24 +03:00
|
|
|
onCompositeCollectionRendered: function() {
|
2013-02-25 03:00:17 +03:00
|
|
|
$(this.ui.calendar).fullCalendar({
|
2013-02-26 06:30:24 +03:00
|
|
|
allDayDefault: false,
|
|
|
|
//ignoreTimezone: false,
|
|
|
|
weekMode: 'variable',
|
2013-02-23 20:42:15 +03:00
|
|
|
header: {
|
|
|
|
left: 'prev,next today',
|
|
|
|
center: 'title',
|
2013-02-26 06:30:24 +03:00
|
|
|
right: 'month,basicWeek'
|
2013-02-23 20:42:15 +03:00
|
|
|
},
|
2013-02-25 03:00:17 +03:00
|
|
|
buttonText: {
|
|
|
|
prev: '<i class="icon-arrow-left"></i>',
|
|
|
|
next: '<i class="icon-arrow-right"></i>'
|
2013-02-26 06:30:24 +03:00
|
|
|
},
|
|
|
|
events: this.getEvents
|
2013-02-23 20:42:15 +03:00
|
|
|
});
|
2013-02-25 03:00:17 +03:00
|
|
|
|
2013-02-26 06:30:24 +03:00
|
|
|
NzbDrone.Calendar.CalendarCollectionView.Instance = this;
|
|
|
|
$(this.ui.calendar).fullCalendar('addEventSource', this.calendar.toJSON());
|
2013-02-23 20:42:15 +03:00
|
|
|
},
|
2013-02-26 06:30:24 +03:00
|
|
|
getEvents: function(start, end, callback){
|
|
|
|
var bbView = NzbDrone.Calendar.CalendarCollectionView.Instance;
|
|
|
|
|
2013-02-26 09:47:30 +03:00
|
|
|
var startDate = Date.create(start).format(Date.ISO8601_DATETIME);
|
|
|
|
var endDate = Date.create(end).format(Date.ISO8601_DATETIME);
|
2013-02-26 06:30:24 +03:00
|
|
|
|
|
|
|
bbView.calendar.fetch({
|
2013-02-26 09:47:30 +03:00
|
|
|
data:{ start: startDate, end: endDate },
|
2013-02-26 06:30:24 +03:00
|
|
|
success:function (calendarCollection) {
|
|
|
|
callback(calendarCollection.toJSON());
|
|
|
|
}
|
|
|
|
});
|
2013-02-23 20:42:15 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|