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
commit 663160c06a
230 changed files with 57 additions and 386 deletions

View file

@ -0,0 +1,11 @@
<div class="tab-pane" id="add-new">
<div class="row">
<div class="input-prepend nz-input-large search span11">
<i class="add-on icon-search"></i>
<input type="text" class="input-block-level" placeholder="Start typing the name of series you want to add ...">
</div>
</div>
<div class="row">
<div id="search-result" class="result-list span12" />
</div>
</div>

View file

@ -0,0 +1,60 @@
"use strict";
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'AddSeries/New/SearchResultView', 'Shared/SpinnerView'], function () {
NzbDrone.AddSeries.New.AddNewSeriesView = Backbone.Marionette.Layout.extend({
template: 'AddSeries/New/AddNewSeriesTemplate',
route: 'Series/add/new',
ui: {
seriesSearch: '.search input'
},
regions: {
searchResult: '#search-result'
},
collection: new NzbDrone.AddSeries.SearchResultCollection(),
onRender: function () {
console.log('binding auto complete');
var self = this;
this.ui.seriesSearch
.data('timeout', null)
.keyup(function () {
window.clearTimeout(self.$el.data('timeout'));
self.$el.data('timeout', window.setTimeout(self.search, 500, self));
});
this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection });
},
search: function (context) {
context.abortExistingRequest();
var term = context.ui.seriesSearch.val();
context.collection.reset();
if (term === '') {
context.searchResult.close();
} else {
context.searchResult.show(new NzbDrone.Shared.SpinnerView());
context.currentSearchRequest = context.collection.fetch({
data: { term: term },
success: function () {
context.searchResult.show(context.resultView);
}
});
}
},
abortExistingRequest: function () {
if (this.currentSearchRequest && this.currentSearchRequest.readyState > 0 && this.currentSearchRequest.readyState < 4) {
console.log('aborting previous pending search request.');
this.currentSearchRequest.abort();
}
}
});
});

View file

@ -0,0 +1,22 @@
<div class="accordion-group">
<div class="accordion-heading">
<a href="http://thetvdb.com/?tab=series&id={{tvDbId}}" target="_blank" class="icon-info-sign pull-left"></a>
<a class="accordion-toggle" data-toggle="collapse" href="#{{tvDbId}}">{{title}} {{seriesYear}}</a>
</div>
<div id="{{tvDbId}}" class="accordion-body collapse">
<div class="accordion-inner">
<select class="span7 x-root-folder">
{{#each rootFolders.models}}
<option value="{{id}}">{{attributes.path}}</option>
{{/each}}
</select>
<select class="span2 x-quality-profile">
{{#each qualityProfiles.models}}
<option value="{{id}}">{{attributes.name}}</option>
{{/each}}
</select>
<div class="btn btn-success pull-right icon-plus x-add">
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,70 @@
'use strict';
define(['app', 'Shared/NotificationCollection', 'AddSeries/SearchResultCollection', 'AddSeries/SearchResultModel', 'Series/SeriesCollection'], function (app, notificationCollection) {
NzbDrone.AddSeries.New.SearchItemView = Backbone.Marionette.ItemView.extend({
template: "AddSeries/New/SearchResultTemplate",
className: 'search-item',
ui: {
qualityProfile: '.x-quality-profile',
rootFolder: '.x-root-folder',
addButton: '.x-add'
},
events: {
'click .x-add': 'add'
},
onRender: function () {
this.listenTo(this.model, 'change', this.render);
},
add: function () {
var seriesId = this.model.get('tvDbId');
var title = this.model.get('title');
var quality = this.ui.qualityProfile.val();
var rootFolderId = this.ui.rootFolder.val();
//Todo: This will create an invalid path on linux...
var rootPath = this.model.get('rootFolders').get(rootFolderId).get('path');
var path = rootPath + "\\" + title;
var model = new NzbDrone.Series.SeriesModel({
tvdbId: seriesId,
title: title,
qualityProfileId: quality,
path: path
});
var self = this;
var seriesCollection = new NzbDrone.Series.SeriesCollection();
seriesCollection.push(model);
model.save(undefined, {
success: function () {
var notificationModel = new NzbDrone.Shared.NotificationModel({
title: 'Added',
message: title,
level: 'success'
});
notificationCollection.push(notificationModel);
self.close();
}
});
}
});
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
itemView: NzbDrone.AddSeries.New.SearchItemView,
className: 'accordion',
initialize: function () {
this.listenTo(this.collection, 'reset', this.render);
}
});
});