2013-02-23 17:42:15 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
|
2013-06-14 23:18:37 +00:00
|
|
|
|
define(['app', 'Calendar/Collection','fullcalendar'], function () {
|
2013-06-07 05:33:01 +00:00
|
|
|
|
NzbDrone.Calendar.CalendarView = Backbone.Marionette.ItemView.extend({
|
2013-06-05 05:07:42 +00:00
|
|
|
|
initialize : function () {
|
2013-06-07 05:33:01 +00:00
|
|
|
|
this.collection = new NzbDrone.Calendar.Collection();
|
2013-02-23 17:42:15 +00:00
|
|
|
|
},
|
2013-06-07 05:33:01 +00:00
|
|
|
|
render: function () {
|
|
|
|
|
$(this.$el).empty().fullCalendar({
|
2013-06-07 01:46:16 +00:00
|
|
|
|
defaultView : 'basicWeek',
|
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-06-22 06:24:24 +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({
|
2013-05-01 01:54:15 +00:00
|
|
|
|
seriesTitle : event.title,
|
2013-03-29 23:28:58 +00:00
|
|
|
|
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-06-07 05:33:01 +00:00
|
|
|
|
NzbDrone.Calendar.CalendarView.Instance = this;
|
2013-03-29 23:28:58 +00:00
|
|
|
|
},
|
2013-05-29 06:24:45 +00:00
|
|
|
|
|
2013-06-05 05:07:42 +00:00
|
|
|
|
onShow: function () {
|
|
|
|
|
this.$('.fc-button-today').click();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getEvents: function (start, end, callback) {
|
2013-06-07 05:33:01 +00:00
|
|
|
|
var bbView = NzbDrone.Calendar.CalendarView.Instance;
|
2013-02-26 03:30:24 +00:00
|
|
|
|
|
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
|
|
|
|
|
2013-06-07 05:33:01 +00:00
|
|
|
|
bbView.collection.fetch({
|
2013-03-29 23:28:58 +00:00
|
|
|
|
data : { start: startDate, end: endDate },
|
|
|
|
|
success: function (calendarCollection) {
|
2013-06-05 05:07:42 +00:00
|
|
|
|
_.each(calendarCollection.models, function (element) {
|
2013-05-01 01:54:15 +00:00
|
|
|
|
var episodeTitle = element.get('title');
|
2013-06-10 02:10:15 +00:00
|
|
|
|
var seriesTitle = element.get('series').get('title');
|
2013-05-01 07:33:34 +00:00
|
|
|
|
var start = element.get('airDate');
|
2013-05-01 01:54:15 +00:00
|
|
|
|
|
|
|
|
|
element.set('title', seriesTitle);
|
|
|
|
|
element.set('episodeTitle', episodeTitle);
|
2013-05-01 07:33:34 +00:00
|
|
|
|
element.set('start', start);
|
|
|
|
|
element.set('allDay', false);
|
2013-05-01 01:54:15 +00:00
|
|
|
|
});
|
|
|
|
|
|
2013-02-26 03:30:24 +00:00
|
|
|
|
callback(calendarCollection.toJSON());
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-02-23 17:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-06-05 05:07:42 +00:00
|
|
|
|
});
|