removed backbone from VS solution,

renamed NzbDrone.Backbone to UI
This commit is contained in:
kay.one
2013-03-29 12:18:44 -07:00
parent c7776f74e1
commit 663160c06a
230 changed files with 57 additions and 386 deletions
+9
View File
@@ -0,0 +1,9 @@
define(['app', 'Calendar/CalendarModel'], function () {
NzbDrone.Calendar.CalendarCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + '/calendar',
model: NzbDrone.Calendar.CalendarModel,
comparator: function(model) {
return model.get('start');
}
});
});
@@ -0,0 +1,6 @@
<div id="events" class="span3">
<h4>Upcoming</h4>
</div>
<div class=span9>
<div id="calendar"></div>
</div>
+75
View File
@@ -0,0 +1,75 @@
'use strict';
define(['app', 'Calendar/CalendarItemView'], function (app) {
NzbDrone.Calendar.CalendarCollectionView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Calendar.CalendarItemView,
itemViewContainer: '#events',
template: 'Calendar/CalendarCollectionTemplate',
className: 'row',
ui: {
calendar: '#calendar'
},
initialize: function (context, action, query, collection) {
this.collection = collection;
this.calendar = new NzbDrone.Calendar.CalendarCollection();
},
onCompositeCollectionRendered: function() {
$(this.ui.calendar).fullCalendar({
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);
element.popover({
title: '{seriesTitle} - {season}x{episode} - {episodeTitle}'.assign({
seriesTitle: event.seriesTitle,
season: event.seasonNumber,
episode: event.episodeNumber.pad(2),
episodeTitle: event.episodeTitle
}),
content: event.overview,
placement: 'bottom',
trigger: 'manual'
});
},
eventMouseover: function(event, jsEvent, view){
$(this).popover('show');
},
eventMouseout: function(event, jsEvent, view){
$(this).popover('hide');
}
});
NzbDrone.Calendar.CalendarCollectionView.Instance = this;
$(this.ui.calendar).fullCalendar('addEventSource', this.calendar.toJSON());
},
getEvents: function(start, end, callback){
var bbView = NzbDrone.Calendar.CalendarCollectionView.Instance;
var startDate = Date.create(start).format(Date.ISO8601_DATETIME);
var endDate = Date.create(end).format(Date.ISO8601_DATETIME);
bbView.calendar.fetch({
data:{ start: startDate, end: endDate },
success:function (calendarCollection) {
callback(calendarCollection.toJSON());
}
});
}
});
});
+6
View File
@@ -0,0 +1,6 @@
<div class="date {{statusLevel}}">
<h1>{{day}}</h1>
<h4>{{month}}</h4>
</div>
<h4>{{seriesTitle}}</h4>
<p>{{startTime}} {{bestDateString}}<span class="pull-right">{{seasonNumber}}x{{paddedEpisodeNumber}}</span><br>{{episodeTitle}}</p>
+17
View File
@@ -0,0 +1,17 @@
'use strict';
define([
'app',
'Calendar/CalendarCollection'
], function () {
NzbDrone.Calendar.CalendarItemView = Backbone.Marionette.ItemView.extend({
template: 'Calendar/CalendarItemTemplate',
tagName: 'div',
className: 'event',
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
}
})
})
+51
View File
@@ -0,0 +1,51 @@
define(['app'], function (app) {
NzbDrone.Calendar.CalendarModel = Backbone.Model.extend({
mutators: {
title: function () {
return this.get('seriesTitle');
},
allDay: function(){
return false;
},
day: function() {
return Date.create(this.get('start')).format('{dd}');
},
month: function(){
return Date.create(this.get('start')).format('{MON}');
},
startTime: function(){
var start = Date.create(this.get('start'));
if (start.format('{mm}') === '00')
return start.format('{h}{tt}');
return start.format('{h}.{mm}{tt}');
},
paddedEpisodeNumber: function(){
return this.get('episodeNumber');
},
statusLevel: function() {
var status = this.get('status');
var currentTime = Date.create();
var start = Date.create(this.get('start'));
var end = Date.create(this.get('end'));
if (currentTime.isBetween(start, end))
return 'warning';
if (start.isBefore(currentTime) || status === 'Missing')
return 'danger';
if (status === 'Ready') return 'success';
return 'primary';
},
bestDateString: function () {
return bestDateString(this.get('start'));
},
},
defaults: {
status: 0
}
});
});