1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-24 08:42:19 +02:00

everything should be moved to require.js

This commit is contained in:
kay.one 2013-02-14 10:01:30 -08:00
parent a2496530ca
commit 8ba29fde94
19 changed files with 253 additions and 232 deletions

View File

@ -220,7 +220,7 @@
<Content Include="_backboneApp\AddSeries\SearchResultCollection.js" />
<Content Include="_backboneApp\Content\Intelisense\bootstrap.css" />
<Content Include="_backboneApp\JsLibraries\jquery.dataTables.extensions.js" />
<Content Include="_backboneApp\JsLibraries\jquery.dataTables-1.10.0-dev.js" />
<Content Include="_backboneApp\JsLibraries\jquery.dataTables.js" />
<Content Include="_backboneApp\JsLibraries\jquery.dataTables.bootstrap.pagination.js" />
<Content Include="_backboneApp\JsLibraries\require-jquery.js" />
<Content Include="_backboneApp\Quality\qualityProfileModel.js" />
@ -416,18 +416,19 @@
<Content Include="_backboneApp\JsLibraries\backbone.js" />
<Content Include="_backboneApp\JsLibraries\backbone.marionette.js" />
<Content Include="_backboneApp\AddSeries\addSeriesLayoutTemplate.html" />
<Content Include="_backboneApp\Series\EditSeriesTemplate.html" />
<Content Include="_backboneApp\Series\EditSeriesView.js" />
<Content Include="_backboneApp\Series\SeriesCollectionView.js" />
<Content Include="_backboneApp\Series\Edit\EditSeriesTemplate.html" />
<Content Include="_backboneApp\Series\Edit\EditSeriesView.js" />
<Content Include="_backboneApp\Shared\NotificationCollection.js" />
<Content Include="_backboneApp\Shared\ModalRegion.js" />
<Content Include="_backboneApp\Series\DeleteSeriesTemplate.html" />
<Content Include="_backboneApp\Series\Index\SeriesCollectionTemplate.html" />
<Content Include="_backboneApp\Series\Index\IndexLayoutTemplate.html" />
<Content Include="_backboneApp\Series\Index\IndexLayout.js" />
<Content Include="_backboneApp\Series\Index\SeriesItemTemplate.html" />
<Content Include="_backboneApp\Series\Index\SeriesItemView.js" />
<Content Include="_backboneApp\Series\Delete\DeleteSeriesTemplate.html" />
<Content Include="_backboneApp\Series\SeriesCollectionTemplate.html" />
<Content Include="_backboneApp\Series\SeriesLayoutTemplate.html" />
<Content Include="_backboneApp\Series\SeriesLayout.js" />
<Content Include="_backboneApp\Series\SeriesItemTemplate.html" />
<Content Include="_backboneApp\Series\SeriesItemView.js" />
<Content Include="_backboneApp\Series\SeriesCollection.js" />
<Content Include="_backboneApp\Series\DeleteSeriesView.js" />
<Content Include="_backboneApp\Series\Delete\DeleteSeriesView.js" />
<Content Include="_backboneApp\Series\SeriesModel.js" />
<Content Include="_backboneApp\Shared\AutoComplete.js" />
<Content Include="_backboneApp\Shared\NotificationModel.js" />
@ -441,7 +442,6 @@
<Content Include="_backboneApp\JsLibraries\backbone.collectionbinder.js" />
<Content Include="_backboneApp\JsLibraries\backbone.debug.js" />
<Content Include="_backboneApp\JsLibraries\handlebars.js" />
<Content Include="_backboneApp\JsLibraries\jquery-ui-1.9.0.js" />
<Content Include="_backboneApp\JsLibraries\backbone.marionette.viewswapper.js" />
<Content Include="_backboneApp\JsLibraries\sugar.js" />
<Content Include="_backboneApp\JsLibraries\underscore.js" />

View File

@ -1,4 +1,4 @@
require(['app','Shared/NotificationView', 'AddSeries/AddSeriesLayout'], function () {
require(['app','Shared/NotificationView', 'AddSeries/AddSeriesLayout','Series/SeriesLayout'], function () {
NzbDrone.Controller = Backbone.Marionette.Controller.extend({
@ -7,7 +7,7 @@
},
series: function (action, query) {
NzbDrone.mainRegion.show(new NzbDrone.Series.IndexLayout(this, action, query));
NzbDrone.mainRegion.show(new NzbDrone.Series.SeriesLayout(this, action, query));
},
notFound: function () {

View File

@ -0,0 +1,29 @@
'use strict';
define(['app', 'Series/SeriesModel'], function () {
NzbDrone.Series.DeleteSeriesView = Backbone.Marionette.ItemView.extend({
template: 'Series/Delete/DeleteSeriesTemplate',
tagName: 'div',
className: "modal",
ui: {
'progressbar': '.progress .bar',
},
events: {
'click .x-confirm-delete': 'removeSeries',
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
removeSeries: function () {
//Todo: why the fuck doesn't destroy send the ID?
this.model.destroy({ wait: true, headers: { id: this.model.get('id'), deleteFiles: $('#delete-from-disk').prop('checked') } });
this.model.collection.remove(this.model);
this.$el.parent().modal('hide');
},
});
});

View File

@ -1,29 +0,0 @@
'use strict';
/*global NzbDrone, Backbone*/
/// <reference path="SeriesModel.js" />
NzbDrone.Series.DeleteSeriesView = Backbone.Marionette.ItemView.extend({
template: 'Series/DeleteSeriesTemplate',
tagName: 'div',
className: "modal",
ui: {
'progressbar': '.progress .bar',
},
events: {
'click .x-confirm-delete': 'removeSeries',
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
removeSeries: function () {
//Todo: why the fuck doesn't destroy send the ID?
this.model.destroy({ wait: true, headers: { id: this.model.get('id'), deleteFiles: $('#delete-from-disk').prop('checked') } });
this.model.collection.remove(this.model);
this.$el.parent().modal('hide');
},
});

View File

@ -0,0 +1,50 @@
'use strict';
define(['app', 'Series/SeriesModel', 'Series/Delete/DeleteSeriesView', 'Quality/QualityProfileCollection'], function () {
NzbDrone.Series.EditSeriesView = Backbone.Marionette.ItemView.extend({
template: 'Series/Edit/EditSeriesTemplate',
tagName: 'div',
className: "modal",
ui: {
progressbar: '.progress .bar',
qualityProfile: '.x-quality-profile',
backlogSettings: '.x-backlog-setting',
},
events: {
'click .x-save': 'saveSeries',
'click .x-remove': 'removeSeries'
},
initialize: function (options) {
this.qualityProfileCollection = options.qualityProfiles;
this.model.set('qualityProfiles', this.qualityProfileCollection);
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
saveSeries: function () {
//Todo: Get qualityProfile + backlog setting from UI
var qualityProfile = this.ui.qualityProfile.val();
var qualityProfileText = this.ui.qualityProfile.children('option:selected').text();
var backlogSetting = this.ui.backlogSettings.val();
this.model.set({ qualityProfileId: qualityProfile, backlogSetting: backlogSetting, qualityProfileName: qualityProfileText });
this.model.save();
this.trigger('saved');
this.$el.parent().modal('hide');
},
removeSeries: function () {
var view = new NzbDrone.Series.DeleteSeriesView({ model: this.model });
NzbDrone.modalRegion.show(view);
}
});
});

View File

@ -1,52 +0,0 @@
'use strict';
/*global NzbDrone, Backbone*/
/// <reference path="SeriesModel.js" />
/// <reference path="DeleteSeriesView.js" />
/// <reference path="../Quality/qualityProfileCollection.js" />
NzbDrone.Series.EditSeriesView = Backbone.Marionette.ItemView.extend({
template: 'Series/EditSeriesTemplate',
tagName: 'div',
className: "modal",
ui: {
progressbar: '.progress .bar',
qualityProfile: '.x-quality-profile',
backlogSettings: '.x-backlog-setting',
},
events: {
'click .x-save': 'saveSeries',
'click .x-remove': 'removeSeries'
},
initialize: function (options) {
this.qualityProfileCollection = options.qualityProfiles;
this.model.set('qualityProfiles', this.qualityProfileCollection);
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
saveSeries: function () {
//Todo: Get qualityProfile + backlog setting from UI
var qualityProfile = this.ui.qualityProfile.val();
var qualityProfileText = this.ui.qualityProfile.children('option:selected').text();
var backlogSetting = this.ui.backlogSettings.val();
this.model.set({ qualityProfileId: qualityProfile, backlogSetting: backlogSetting, qualityProfileName: qualityProfileText });
this.model.save();
this.trigger('saved');
this.$el.parent().modal('hide');
},
removeSeries: function () {
var view = new NzbDrone.Series.DeleteSeriesView({ model: this.model });
NzbDrone.modalRegion.show(view);
}
});

View File

@ -1,33 +0,0 @@
'use strict;'
/// <reference path="../SeriesCollection.js" />
/// <reference path="SeriesItemView.js" />
/// <reference path="../../JsLibraries/jquery.dataTables.bootstrap.pagination.js" />
NzbDrone.Series.IndexLayout = Backbone.Marionette.Layout.extend({
template: 'Series/Index/IndexLayoutTemplate',
className: "row",
route: 'Series/index',
ui: {
},
regions: {
seriesRegion: '#series'
},
collection: new NzbDrone.Series.SeriesCollection(),
initialize: function (options) {
},
onRender: function () {
console.log('binding auto complete');
this.collection.fetch();
this.seriesRegion.show(new NzbDrone.Series.Index.SeriesCollectionView({ collection: this.collection }));
},
});

View File

@ -1,98 +0,0 @@
'use strict';
/*global NzbDrone, Backbone*/
/// <reference path="../SeriesModel.js" />
/// <reference path="../SeriesCollection.js" />
/// <reference path="../EditSeriesView.js" />
/// <reference path="../DeleteSeriesView.js" />
/// <reference path="../../Quality/qualityProfileCollection.js" />
NzbDrone.Series.Index.SeriesItemView = Backbone.Marionette.ItemView.extend({
template: 'Series/Index/SeriesItemTemplate',
tagName: 'tr',
ui: {
'progressbar': '.progress .bar',
},
events: {
'click .x-edit': 'editSeries',
'click .x-remove': 'removeSeries'
},
initialize: function(options) {
this.qualityProfileCollection = options.qualityProfiles;
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
editSeries: function () {
var view = new NzbDrone.Series.EditSeriesView({ model: this.model, qualityProfiles: this.qualityProfileCollection });
view.on('saved', this.render, this);
NzbDrone.modalRegion.show(view);
},
removeSeries: function () {
var view = new NzbDrone.Series.DeleteSeriesView({ model: this.model });
NzbDrone.modalRegion.show(view);
},
onSave: function() {
alert("saved!");
}
});
NzbDrone.Series.Index.SeriesCollectionView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Series.Index.SeriesItemView,
itemViewOptions: {},
template: 'Series/Index/SeriesCollectionTemplate',
tagName: 'table',
className: 'table table-hover',
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
initialize: function() {
this.qualityProfileCollection.fetch();
this.itemViewOptions = { qualityProfiles: this.qualityProfileCollection };
},
onRender: function() {
$('.table').dataTable({
sDom: "<'row'<'span14'l><'span6'f>r>t<'row'<'span14'i><'span6'p>>",
sPaginationType: "bootstrap",
bLengthChange: false,
bPaginate: false,
bFilter: false,
aaSorting: [[1, 'asc']],
bStateSave: true,
iCookieDuration: 60 * 60 * 24 * 365, //1 year
oLanguage: {
sInfo: "_TOTAL_ series",
sEmptyTable: "No series have been added"
},
aoColumns: [
{
sType: "title-string",
sWidth: "13px"
},
null,
null,
null,
null,
{
sType: "best-date"
},
{
bSortable: false,
sWidth: "125px"
},
{
bSortable: false,
sWidth: "50px"
}
]
});
}
});

View File

@ -1,7 +1,6 @@

/// <reference path="SeriesModel.js" />
NzbDrone.Series.SeriesCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + '/series',
model: NzbDrone.Series.SeriesModel,
define(['app', 'Series/SeriesModel'], function () {
NzbDrone.Series.SeriesCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + '/series',
model: NzbDrone.Series.SeriesModel,
});
});

View File

@ -0,0 +1,57 @@
'use strict';
define(['app', 'Series/SeriesItemView', 'Quality/QualityProfileCollection','datatables'], function () {
NzbDrone.Series.SeriesCollectionView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Series.SeriesItemView,
itemViewOptions: {},
template: 'Series/SeriesCollectionTemplate',
tagName: 'table',
className: 'table table-hover',
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
initialize: function () {
this.qualityProfileCollection.fetch();
this.itemViewOptions = { qualityProfiles: this.qualityProfileCollection };
},
onRender: function () {
$('.table').dataTable({
sDom: "<'row'<'span14'l><'span6'f>r>t<'row'<'span14'i><'span6'p>>",
sPaginationType: "bootstrap",
bLengthChange: false,
bPaginate: false,
bFilter: true,
aaSorting: [[1, 'asc']],
bStateSave: true,
iCookieDuration: 60 * 60 * 24 * 365, //1 year
oLanguage: {
sInfo: "_TOTAL_ series",
sEmptyTable: "No series have been added"
},
aoColumns: [
{
sType: "title-string",
sWidth: "13px"
},
null,
null,
null,
null,
{
sType: "best-date"
},
{
bSortable: false,
sWidth: "125px"
},
{
bSortable: false,
sWidth: "50px"
}
]
});
}
});
});

View File

@ -0,0 +1,48 @@
'use strict';
define([
'app',
'Series/SeriesCollection',
'Series/Edit/EditSeriesView',
'Series/Delete/DeleteSeriesView',
'Quality/QualityProfileCollection'
], function () {
NzbDrone.Series.SeriesItemView = Backbone.Marionette.ItemView.extend({
template: 'Series/SeriesItemTemplate',
tagName: 'tr',
ui: {
'progressbar': '.progress .bar',
},
events: {
'click .x-edit': 'editSeries',
'click .x-remove': 'removeSeries'
},
initialize: function (options) {
this.qualityProfileCollection = options.qualityProfiles;
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
editSeries: function () {
var view = new NzbDrone.Series.EditSeriesView({ model: this.model, qualityProfiles: this.qualityProfileCollection });
view.on('saved', this.render, this);
NzbDrone.modalRegion.show(view);
},
removeSeries: function () {
var view = new NzbDrone.Series.DeleteSeriesView({ model: this.model });
NzbDrone.modalRegion.show(view);
},
onSave: function () {
alert("saved!");
}
});
});

View File

@ -0,0 +1,33 @@
'use strict;'
define(['app', 'Series/SeriesCollection', 'Series/SeriesCollectionView', 'bootstrap'], function () {
NzbDrone.Series.SeriesLayout = Backbone.Marionette.Layout.extend({
template: 'Series/SeriesLayoutTemplate',
className: "row",
route: 'Series/index',
ui: {
},
regions: {
seriesRegion: '#series'
},
collection: new NzbDrone.Series.SeriesCollection(),
initialize: function (options) {
},
onRender: function () {
console.log('binding auto complete');
this.collection.fetch();
this.seriesRegion.show(new NzbDrone.Series.SeriesCollectionView({ collection: this.collection }));
},
});
});

View File

@ -6,6 +6,9 @@
'marionette': 'JsLibraries/backbone.marionette',
'handlebars': 'JsLibraries/handlebars',
'bootstrap': 'JsLibraries/bootstrap',
'datatablesBase': 'JsLibraries/jquery.dataTables',
'datatablesExt': 'JsLibraries/jquery.dataTables.extensions',
'datatables': 'JsLibraries/jquery.dataTables.bootstrap.pagination',
},
shim: {
@ -25,7 +28,20 @@
},
handlebars: {
exports: "Handlebars"
},
dataTable: {
deps: ['jquery']
},
datatablesBase: {
depts: ['jquery']
},
datatablesExt: {
deps: ['datatablesBase'],
},
datatables: {
deps: ['datatablesExt']
}
}
});
@ -42,7 +58,8 @@ define('app', ['jquery', 'JsLibraries/backbone.modelbinder', 'marionette', 'hand
window.NzbDrone = new Backbone.Marionette.Application();
window.NzbDrone.Series = {};
window.NzbDrone.Series.Index = {};
window.NzbDrone.Series.Edit = {};
window.NzbDrone.Series.Delete = {};
window.NzbDrone.AddSeries = {};
window.NzbDrone.AddSeries.New = {};
window.NzbDrone.AddSeries.Existing = {};