1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Calendar/CalendarView.js

82 lines
3.2 KiB
JavaScript
Raw Normal View History

'use strict';
2013-06-07 08:33:01 +03:00
define(['app', 'Calendar/Collection'], function () {
NzbDrone.Calendar.CalendarView = Backbone.Marionette.ItemView.extend({
2013-06-05 08:07:42 +03:00
initialize : function () {
2013-06-07 08:33:01 +03:00
this.collection = new NzbDrone.Calendar.Collection();
},
2013-06-07 08:33:01 +03:00
render: function () {
$(this.$el).empty().fullCalendar({
2013-06-07 04:46:16 +03:00
defaultView : 'basicWeek',
allDayDefault : false,
2013-02-28 19:34:18 +03:00
ignoreTimezone: false,
weekMode : 'variable',
timeFormat : 'h(:mm)tt',
header : {
left : 'prev,next today',
center: 'title',
right : 'month,basicWeek'
},
buttonText : {
2013-02-25 03:00:17 +03:00
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,
eventRender : function (event, element) {
$(element).addClass(event.statusLevel);
$(element).children('.fc-event-inner').addClass(event.statusLevel);
2013-02-28 09:48:25 +03:00
element.popover({
title : '{seriesTitle} - {season}x{episode} - {episodeTitle}'.assign({
2013-05-01 04:54:15 +03:00
seriesTitle : event.title,
season : event.seasonNumber,
episode : event.episodeNumber.pad(2),
2013-02-28 09:48:25 +03:00
episodeTitle: event.episodeTitle
}),
content : event.overview,
2013-02-28 09:48:25 +03:00
placement: 'bottom',
trigger : 'manual'
2013-02-28 09:48:25 +03:00
});
},
2013-03-30 22:30:00 +03:00
eventMouseover: function () {
2013-02-28 09:48:25 +03:00
$(this).popover('show');
},
2013-03-30 22:30:00 +03:00
eventMouseout : function () {
2013-02-28 09:48:25 +03:00
$(this).popover('hide');
}
});
2013-02-25 03:00:17 +03:00
2013-06-07 08:33:01 +03:00
NzbDrone.Calendar.CalendarView.Instance = this;
},
2013-05-29 09:24:45 +03:00
2013-06-05 08:07:42 +03:00
onShow: function () {
this.$('.fc-button-today').click();
},
getEvents: function (start, end, callback) {
2013-06-07 08:33:01 +03:00
var bbView = NzbDrone.Calendar.CalendarView.Instance;
2013-02-26 06:30:24 +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
2013-06-07 08:33:01 +03:00
bbView.collection.fetch({
data : { start: startDate, end: endDate },
success: function (calendarCollection) {
2013-06-05 08:07:42 +03:00
_.each(calendarCollection.models, function (element) {
2013-05-01 04:54:15 +03:00
var episodeTitle = element.get('title');
2013-06-10 05:10:15 +03:00
var seriesTitle = element.get('series').get('title');
var start = element.get('airDate');
2013-05-01 04:54:15 +03:00
element.set('title', seriesTitle);
element.set('episodeTitle', episodeTitle);
element.set('start', start);
element.set('allDay', false);
2013-05-01 04:54:15 +03:00
});
2013-02-26 06:30:24 +03:00
callback(calendarCollection.toJSON());
}
});
}
});
2013-06-05 08:07:42 +03:00
});