2013-02-23 17:42:15 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
|
2013-03-30 19:30:00 +00:00
|
|
|
|
define(['app', 'Calendar/CalendarItemView'], function () {
|
2013-02-23 17:42:15 +00:00
|
|
|
|
NzbDrone.Calendar.CalendarCollectionView = Backbone.Marionette.CompositeView.extend({
|
2013-03-29 23:28:58 +00:00
|
|
|
|
itemView : NzbDrone.Calendar.CalendarItemView,
|
2013-02-28 16:34:18 +00:00
|
|
|
|
itemViewContainer: '#events',
|
2013-03-29 23:28:58 +00:00
|
|
|
|
template : 'Calendar/CalendarCollectionTemplate',
|
2013-02-23 17:42:15 +00:00
|
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
|
calendar: '#calendar'
|
|
|
|
|
},
|
|
|
|
|
|
2013-04-18 23:14:08 +00:00
|
|
|
|
initialize : function () {
|
|
|
|
|
//should use this.collection?
|
2013-02-26 03:30:24 +00:00
|
|
|
|
this.calendar = new NzbDrone.Calendar.CalendarCollection();
|
2013-02-23 17:42:15 +00:00
|
|
|
|
},
|
2013-03-29 23:28:58 +00:00
|
|
|
|
onCompositeCollectionRendered: function () {
|
2013-04-18 15:11:11 +00:00
|
|
|
|
$(this.ui.calendar).empty().fullCalendar({
|
2013-03-29 23:28:58 +00:00
|
|
|
|
allDayDefault : false,
|
2013-02-28 16:34:18 +00:00
|
|
|
|
ignoreTimezone: false,
|
2013-03-29 23:28:58 +00:00
|
|
|
|
weekMode : 'variable',
|
|
|
|
|
timeFormat : 'h(:mm)tt',
|
|
|
|
|
header : {
|
|
|
|
|
left : 'prev,next today',
|
2013-02-23 17:42:15 +00:00
|
|
|
|
center: 'title',
|
2013-03-29 23:28:58 +00:00
|
|
|
|
right : 'month,basicWeek'
|
2013-02-23 17:42:15 +00:00
|
|
|
|
},
|
2013-03-29 23:28:58 +00:00
|
|
|
|
buttonText : {
|
2013-02-25 00:00:17 +00:00
|
|
|
|
prev: '<i class="icon-arrow-left"></i>',
|
|
|
|
|
next: '<i class="icon-arrow-right"></i>'
|
2013-02-26 03:30:24 +00:00
|
|
|
|
},
|
2013-03-29 23:28:58 +00:00
|
|
|
|
events : this.getEvents,
|
|
|
|
|
eventRender : function (event, element) {
|
2013-03-01 04:59:06 +00:00
|
|
|
|
$(element).addClass(event.statusLevel);
|
|
|
|
|
$(element).children('.fc-event-inner').addClass(event.statusLevel);
|
|
|
|
|
|
2013-02-28 06:48:25 +00:00
|
|
|
|
element.popover({
|
2013-03-29 23:28:58 +00:00
|
|
|
|
title : '{seriesTitle} - {season}x{episode} - {episodeTitle}'.assign({
|
|
|
|
|
seriesTitle : event.seriesTitle,
|
|
|
|
|
season : event.seasonNumber,
|
|
|
|
|
episode : event.episodeNumber.pad(2),
|
2013-02-28 06:48:25 +00:00
|
|
|
|
episodeTitle: event.episodeTitle
|
|
|
|
|
}),
|
2013-03-29 23:28:58 +00:00
|
|
|
|
content : event.overview,
|
2013-02-28 06:48:25 +00:00
|
|
|
|
placement: 'bottom',
|
2013-03-29 23:28:58 +00:00
|
|
|
|
trigger : 'manual'
|
2013-02-28 06:48:25 +00:00
|
|
|
|
});
|
|
|
|
|
},
|
2013-03-30 19:30:00 +00:00
|
|
|
|
eventMouseover: function () {
|
2013-02-28 06:48:25 +00:00
|
|
|
|
$(this).popover('show');
|
|
|
|
|
},
|
2013-03-30 19:30:00 +00:00
|
|
|
|
eventMouseout : function () {
|
2013-02-28 06:48:25 +00:00
|
|
|
|
$(this).popover('hide');
|
|
|
|
|
}
|
2013-02-23 17:42:15 +00:00
|
|
|
|
});
|
2013-02-25 00:00:17 +00:00
|
|
|
|
|
2013-02-26 03:30:24 +00:00
|
|
|
|
NzbDrone.Calendar.CalendarCollectionView.Instance = this;
|
|
|
|
|
$(this.ui.calendar).fullCalendar('addEventSource', this.calendar.toJSON());
|
2013-03-29 23:28:58 +00:00
|
|
|
|
},
|
|
|
|
|
getEvents : function (start, end, callback) {
|
2013-02-26 03:30:24 +00:00
|
|
|
|
var bbView = NzbDrone.Calendar.CalendarCollectionView.Instance;
|
|
|
|
|
|
2013-02-26 06:47:30 +00:00
|
|
|
|
var startDate = Date.create(start).format(Date.ISO8601_DATETIME);
|
|
|
|
|
var endDate = Date.create(end).format(Date.ISO8601_DATETIME);
|
2013-02-26 03:30:24 +00:00
|
|
|
|
|
|
|
|
|
bbView.calendar.fetch({
|
2013-03-29 23:28:58 +00:00
|
|
|
|
data : { start: startDate, end: endDate },
|
|
|
|
|
success: function (calendarCollection) {
|
2013-02-26 03:30:24 +00:00
|
|
|
|
callback(calendarCollection.toJSON());
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-02-23 17:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|