removed mutators from series.

pull/4/head
Keivan Beigi 12 years ago
parent 50718ae94e
commit 83fe07524a

@ -16,7 +16,9 @@ define(
var icon;
var tooltip;
if (this.model.get('episodeFile')) {
var hasAired = Date.create(this.model.get('airDate')).isBefore(Date.create());
if (hasAired) {
icon = 'icon-ok';
tooltip = 'Episode downloaded';
}

@ -0,0 +1,21 @@
'use strict';
define(
[
'handlebars',
'Quality/QualityProfileCollection',
'underscore'
], function (Handlebars, QualityProfileCollection, _) {
Handlebars.registerHelper('qualityProfile', function (profileId) {
var profile = QualityProfileCollection.get(profileId);
if (profile) {
return new Handlebars.SafeString('<span class="label quality-profile-lable">' + profile.get("name") + '</span>');
}
return undefined;
});
});

@ -0,0 +1,44 @@
'use strict';
define(
[
'handlebars',
'underscore'
], function (Handlebars, _) {
Handlebars.registerHelper('poster', function () {
var poster = _.where(this.images, {coverType: 'poster'});
if (poster[0]) {
return poster[0].url;
}
return undefined;
});
Handlebars.registerHelper('traktUrl', function () {
return 'http://trakt.tv/show/' + this.titleSlug;
});
Handlebars.registerHelper('imdbUrl', function () {
return 'http://imdb.com/title/' + this.imdbId;
});
Handlebars.registerHelper('route', function () {
return '/series/' + this.titleSlug;
});
Handlebars.registerHelper('percentOfEpisodes', function () {
var episodeCount = this.episodeCount;
var episodeFileCount = this.episodeFileCount;
var percent = 100;
if (episodeCount > 0) {
percent = episodeFileCount / episodeCount * 100;
}
return percent;
});
});

@ -6,7 +6,9 @@ define(
'Handlebars/Helpers/DateTime',
'Handlebars/Helpers/Html',
'Handlebars/Helpers/Numbers',
'Handlebars/Helpers/EpisodeNumber',
'Handlebars/Helpers/Episode',
'Handlebars/Helpers/Series',
'Handlebars/Helpers/Quality',
'Handlebars/Debug'
], function (Templates) {
return function () {

@ -1 +0,0 @@
<span class="label quality-profile-lable">{{name}}</span>

@ -44,8 +44,10 @@ define(
onShow: function () {
var self = this;
if (this.model.has('fanArt')) {
$.backstretch(this.model.get('fanArt'));
var fanArt = this._getFanArt();
if (fanArt) {
$.backstretch(fanArt);
}
else {
$('body').removeClass('backdrop');
@ -67,6 +69,16 @@ define(
this._setMonitoredState();
},
_getFanArt: function () {
var fanArt = _.where(this.model.get('images'), {coverType: 'fanart'});
if(fanArt && fanArt[0]){
return fanArt[0].url;
}
return undefined;
},
onClose: function () {
$('.backstretch').remove();
$('body').removeClass('backdrop');
@ -81,7 +93,7 @@ define(
var promise = this.model.save();
promise.always(function (){
promise.always(function () {
self._setMonitoredState();
});
},

@ -14,7 +14,7 @@
{{overview}}
</div>
<div class="row">
{{> QualityProfilePartial qualityProfile}}
{{qualityProfile qualityProfileId}}
<span class="label label-info">{{network}}</span>
<span class="label label-info">{{runtime}} minutes</span>
<span class="label label-info">{{path}}</span>

@ -29,17 +29,15 @@ define(
saveSeries: function () {
//Todo: Get qualityProfile
var qualityProfile = this.ui.qualityProfile.val();
var qualityProfileText = this.ui.qualityProfile.children('option:selected').text();
this.model.set({ qualityProfileId: qualityProfile, qualityProfileName: qualityProfileText });
var qualityProfileId = this.ui.qualityProfile.val();
this.model.set({ qualityProfileId: qualityProfileId});
this.model.save();
this.trigger('saved');
App.modalRegion.closeModal();
},
},
onRender: function () {
this.ui.path.autoComplete('/directories');

@ -55,9 +55,6 @@ define(
}
return 'primary';
},
hasAired : function () {
return Date.create(this.get('airDate')).isBefore(Date.create());
}
},

@ -29,7 +29,7 @@
<div class="row">&nbsp;</div>
<div class="row">
<div class="span8">
{{#if isContinuing}}
{{#if_eq status compare="continuing"}}
{{#if nextAiring}}
<span class="label">{{ShortDate nextAiring}}</span>
{{/if}}
@ -37,9 +37,9 @@
{{else}}
<span class="label label-important">Ended</span>
<span class="label label-info">{{seasonCount}} Seasons</span>
{{/if}}
{{/if_eq}}
{{> QualityProfilePartial qualityProfile}}
{{qualityProfile qualityProfileId}}
</div>
<div class="span2">
<div class="progress">

@ -7,9 +7,9 @@
<i class="icon-cog x-edit" title="Edit Series"/>
<i class="icon-remove x-remove" title="Delete Series"/>
</div>
{{#unless isContinuing}}
{{#unless_eq status compare="continuing"}}
<div class="ended-banner">Ended</div>
{{/unless}}
{{/unless_eq}}
<a href="{{route}}">
<img class="series-poster" src="{{poster}}" {{defaultImg}}>
</a>

@ -2,71 +2,13 @@
define(
[
'backbone',
'Quality/QualityProfileCollection',
'underscore'
], function (Backbone, QualityProfileCollection,_) {
], function (Backbone, _) {
return Backbone.Model.extend({
urlRoot: ApiRoot + '/series',
mutators: {
percentOfEpisodes: function () {
var episodeCount = this.get('episodeCount');
var episodeFileCount = this.get('episodeFileCount');
var percent = 100;
if (episodeCount > 0) {
percent = episodeFileCount / episodeCount * 100;
}
return percent;
},
poster : function () {
var poster = _.find(this.get('images'), function (image) {
return image.coverType === 'poster';
});
if (poster) {
return poster.url;
}
return undefined;
},
fanArt : function () {
var poster = _.find(this.get('images'), function (image) {
return image.coverType === 'fanart';
});
if (poster) {
return poster.url;
}
return undefined;
},
traktUrl : function () {
return 'http://trakt.tv/show/' + this.get('titleSlug');
},
imdbUrl : function () {
return 'http://imdb.com/title/' + this.get('imdbId');
},
isContinuing : function () {
return this.get('status') === 'continuing';
},
route : function () {
return '/series/' + this.get('titleSlug');
},
qualityProfile: function () {
var profile = QualityProfileCollection.get(this.get('qualityProfileId'));
if (profile) {
return profile.toJSON();
}
return undefined;
}
},
defaults: {
episodeFileCount: 0,
episodeCount : 0,

Loading…
Cancel
Save