1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-25 17:17:02 +00:00
Lidarr/UI/Calendar/CalendarView.js

88 lines
3.4 KiB
JavaScript
Raw Normal View History

'use strict';
define(
[
'marionette',
'Calendar/Collection',
'fullcalendar'
], function (Marionette, CalendarCollection) {
var _instance;
2013-02-25 00:00:17 +00:00
return Marionette.ItemView.extend({
initialize: function () {
this.collection = new CalendarCollection();
},
render : function () {
$(this.$el).empty().fullCalendar({
defaultView : 'basicWeek',
allDayDefault : false,
ignoreTimezone: false,
weekMode : 'variable',
timeFormat : 'h(:mm)tt',
header : {
left : 'prev,next today',
center: 'title',
right : 'month,basicWeek'
},
buttonText : {
prev: '<i class="icon-arrow-left"></i>',
next: '<i class="icon-arrow-right"></i>'
},
events : this.getEvents,
eventRender : function (event, element) {
$(element).addClass(event.statusLevel);
$(element).children('.fc-event-inner').addClass(event.statusLevel);
2013-05-29 06:24:45 +00:00
element.popover({
title : '{seriesTitle} - {season}x{episode} - {episodeTitle}'.assign({
seriesTitle : event.title,
season : event.seasonNumber,
episode : event.episodeNumber.pad(2),
episodeTitle: event.episodeTitle
}),
content : event.overview,
placement: 'bottom',
trigger : 'manual'
});
},
eventMouseover: function () {
$(this).popover('show');
},
eventMouseout : function () {
$(this).popover('hide');
}
});
2013-06-05 05:07:42 +00:00
_instance = this;
},
2013-02-26 03:30:24 +00:00
onShow: function () {
this.$('.fc-button-today').click();
},
2013-02-26 03:30:24 +00:00
getEvents: function (start, end, callback) {
var startDate = Date.create(start).format(Date.ISO8601_DATETIME);
var endDate = Date.create(end).format(Date.ISO8601_DATETIME);
2013-05-01 01:54:15 +00:00
_instance.collection.fetch({
data : { start: startDate, end: endDate },
success: function (calendarCollection) {
_.each(calendarCollection.models, function (element) {
var episodeTitle = element.get('title');
var seriesTitle = element.get('series').get('title');
var start = element.get('airDate');
2013-05-01 01:54:15 +00:00
element.set('title', seriesTitle);
element.set('episodeTitle', episodeTitle);
element.set('start', start);
element.set('allDay', false);
});
callback(calendarCollection.toJSON());
}
});
}
});
});