rjs -> webpack

This commit is contained in:
Keivan Beigi
2015-02-02 17:18:45 -08:00
parent 344f3d66ef
commit 428a1439e5
399 changed files with 11591 additions and 16139 deletions
@@ -1,14 +1,9 @@
'use strict';
var ThingyAddCollectionView = require('../../ThingyAddCollectionView');
var ThingyHeaderGroupView = require('../../ThingyHeaderGroupView');
var AddItemView = require('./DownloadClientAddItemView');
define([
'Settings/ThingyAddCollectionView',
'Settings/ThingyHeaderGroupView',
'Settings/DownloadClient/Add/DownloadClientAddItemView'
], function (ThingyAddCollectionView, ThingyHeaderGroupView, AddItemView) {
return ThingyAddCollectionView.extend({
itemView : ThingyHeaderGroupView.extend({ itemView: AddItemView }),
itemViewContainer: '.add-download-client .items',
template : 'Settings/DownloadClient/Add/DownloadClientAddCollectionViewTemplate'
});
});
module.exports = ThingyAddCollectionView.extend({
itemView : ThingyHeaderGroupView.extend({itemView : AddItemView}),
itemViewContainer : '.add-download-client .items',
template : 'Settings/DownloadClient/Add/DownloadClientAddCollectionViewTemplate'
});
@@ -1,56 +1,46 @@
'use strict';
var _ = require('underscore');
var $ = require('jquery');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var EditView = require('../Edit/DownloadClientEditView');
define([
'underscore',
'jquery',
'AppLayout',
'marionette',
'Settings/DownloadClient/Edit/DownloadClientEditView'
], function (_, $, AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template : 'Settings/DownloadClient/Add/DownloadClientAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events: {
'click .x-preset': '_addPreset',
'click' : '_add'
},
initialize: function (options) {
this.targetCollection = options.targetCollection;
},
_addPreset: function (e) {
var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), {name: presetName})[0];
this.model.set(presetData);
this.model.set({
id : undefined,
enable : true
});
var editView = new EditView({ model: this.model, targetCollection: this.targetCollection });
AppLayout.modalRegion.show(editView);
},
_add: function (e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return;
}
this.model.set({
id : undefined,
enable : true
});
var editView = new EditView({ model: this.model, targetCollection: this.targetCollection });
AppLayout.modalRegion.show(editView);
module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/Add/DownloadClientAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events : {
"click .x-preset" : '_addPreset',
"click" : '_add'
},
initialize : function(options){
this.targetCollection = options.targetCollection;
},
_addPreset : function(e){
var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), {name : presetName})[0];
this.model.set(presetData);
this.model.set({
id : undefined,
enable : true
});
var editView = new EditView({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
},
_add : function(e){
if($(e.target).closest('.btn,.btn-group').length !== 0) {
return;
}
});
});
this.model.set({
id : undefined,
enable : true
});
var editView = new EditView({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
}
});
@@ -1,36 +1,33 @@
'use strict';
var _ = require('underscore');
var AppLayout = require('../../../AppLayout');
var Backbone = require('backbone');
var SchemaCollection = require('../DownloadClientCollection');
var AddCollectionView = require('./DownloadClientAddCollectionView');
define([
'underscore',
'AppLayout',
'backbone',
'Settings/DownloadClient/DownloadClientCollection',
'Settings/DownloadClient/Add/DownloadClientAddCollectionView'
], function (_, AppLayout, Backbone, SchemaCollection, AddCollectionView) {
return ({
open: function (collection) {
var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch();
schemaCollection.url = originalUrl;
var groupedSchemaCollection = new Backbone.Collection();
schemaCollection.on('sync', function() {
var groups = schemaCollection.groupBy(function(model, iterator) { return model.get('protocol'); });
var modelCollection = _.map(groups, function(values, key, list) {
return { 'header': key, collection: values };
});
groupedSchemaCollection.reset(modelCollection);
module.exports = {
open : function(collection){
var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch();
schemaCollection.url = originalUrl;
var groupedSchemaCollection = new Backbone.Collection();
schemaCollection.on('sync', function(){
var groups = schemaCollection.groupBy(function(model, iterator){
return model.get('protocol');
});
var view = new AddCollectionView({ collection: groupedSchemaCollection, targetCollection: collection });
AppLayout.modalRegion.show(view);
}
});
});
var modelCollection = _.map(groups, function(values, key, list){
return {
"header" : key,
collection : values
};
});
groupedSchemaCollection.reset(modelCollection);
});
var view = new AddCollectionView({
collection : groupedSchemaCollection,
targetCollection : collection
});
AppLayout.modalRegion.show(view);
}
};
@@ -1,23 +1,15 @@
'use strict';
var vent = require('../../../vent');
var Marionette = require('marionette');
define([
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/DownloadClient/Delete/DownloadClientDeleteViewTemplate',
events: {
'click .x-confirm-delete': '_delete'
},
_delete: function () {
this.model.destroy({
wait : true,
success: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/Delete/DownloadClientDeleteViewTemplate',
events : {'click .x-confirm-delete' : '_delete'},
_delete : function(){
this.model.destroy({
wait : true,
success : function(){
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
@@ -1,31 +1,20 @@
'use strict';
var Backbone = require('backbone');
var DownloadClientModel = require('./DownloadClientModel');
define([
'backbone',
'Settings/DownloadClient/DownloadClientModel'
], function (Backbone, DownloadClientModel) {
return Backbone.Collection.extend({
model: DownloadClientModel,
url : window.NzbDrone.ApiRoot + '/downloadclient',
comparator : function(left, right, collection) {
var result = 0;
if (left.get('protocol')) {
result = -left.get('protocol').localeCompare(right.get('protocol'));
}
if (result === 0 && left.get('name')) {
result = left.get('name').localeCompare(right.get('name'));
}
if (result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation'));
}
return result;
module.exports = Backbone.Collection.extend({
model : DownloadClientModel,
url : window.NzbDrone.ApiRoot + '/downloadclient',
comparator : function(left, right, collection){
var result = 0;
if(left.get('protocol')) {
result = -left.get('protocol').localeCompare(right.get('protocol'));
}
});
});
if(result === 0 && left.get('name')) {
result = left.get('name').localeCompare(right.get('name'));
}
if(result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation'));
}
return result;
}
});
@@ -1,29 +1,17 @@
'use strict';
var Marionette = require('marionette');
var ItemView = require('./DownloadClientItemView');
var SchemaModal = require('./Add/DownloadClientSchemaModal');
define([
'marionette',
'Settings/DownloadClient/DownloadClientItemView',
'Settings/DownloadClient/Add/DownloadClientSchemaModal'
], function (Marionette, ItemView, SchemaModal) {
return Marionette.CompositeView.extend({
itemView : ItemView,
itemViewContainer: '.download-client-list',
template : 'Settings/DownloadClient/DownloadClientCollectionViewTemplate',
ui: {
'addCard': '.x-add-card'
},
events: {
'click .x-add-card': '_openSchemaModal'
},
appendHtml: function (collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_openSchemaModal: function () {
SchemaModal.open(this.collection);
}
});
});
module.exports = Marionette.CompositeView.extend({
itemView : ItemView,
itemViewContainer : '.download-client-list',
template : 'Settings/DownloadClient/DownloadClientCollectionViewTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_openSchemaModal'},
appendHtml : function(collectionView, itemView, index){
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_openSchemaModal : function(){
SchemaModal.open(this.collection);
}
});
@@ -1,26 +1,19 @@
'use strict';
var AppLayout = require('../../AppLayout');
var Marionette = require('marionette');
var EditView = require('./Edit/DownloadClientEditView');
define([
'AppLayout',
'marionette',
'Settings/DownloadClient/Edit/DownloadClientEditView'
], function (AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template: 'Settings/DownloadClient/DownloadClientItemViewTemplate',
tagName : 'li',
events: {
'click' : '_edit'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_edit: function () {
var view = new EditView({ model: this.model, targetCollection: this.model.collection});
AppLayout.modalRegion.show(view);
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DownloadClientItemViewTemplate',
tagName : 'li',
events : {"click" : '_edit'},
initialize : function(){
this.listenTo(this.model, 'sync', this.render);
},
_edit : function(){
var view = new EditView({
model : this.model,
targetCollection : this.model.collection
});
AppLayout.modalRegion.show(view);
}
});
@@ -1,37 +1,29 @@
'use strict';
var Marionette = require('marionette');
var DownloadClientCollection = require('./DownloadClientCollection');
var DownloadClientCollectionView = require('./DownloadClientCollectionView');
var DownloadHandlingView = require('./DownloadHandling/DownloadHandlingView');
var DroneFactoryView = require('./DroneFactory/DroneFactoryView');
var RemotePathMappingCollection = require('./RemotePathMapping/RemotePathMappingCollection');
var RemotePathMappingCollectionView = require('./RemotePathMapping/RemotePathMappingCollectionView');
define([
'marionette',
'Settings/DownloadClient/DownloadClientCollection',
'Settings/DownloadClient/DownloadClientCollectionView',
'Settings/DownloadClient/DownloadHandling/DownloadHandlingView',
'Settings/DownloadClient/DroneFactory/DroneFactoryView',
'Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollection',
'Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionView'
], function (Marionette, DownloadClientCollection, DownloadClientCollectionView, DownloadHandlingView, DroneFactoryView, RemotePathMappingCollection, RemotePathMappingCollectionView) {
return Marionette.Layout.extend({
template : 'Settings/DownloadClient/DownloadClientLayoutTemplate',
regions: {
downloadClients : '#x-download-clients-region',
downloadHandling : '#x-download-handling-region',
droneFactory : '#x-dronefactory-region',
remotePathMappings : '#x-remotepath-mapping-region'
},
initialize: function () {
this.downloadClientsCollection = new DownloadClientCollection();
this.downloadClientsCollection.fetch();
this.remotePathMappingCollection = new RemotePathMappingCollection();
this.remotePathMappingCollection.fetch();
},
onShow: function () {
this.downloadClients.show(new DownloadClientCollectionView({ collection: this.downloadClientsCollection }));
this.downloadHandling.show(new DownloadHandlingView({ model: this.model }));
this.droneFactory.show(new DroneFactoryView({ model: this.model }));
this.remotePathMappings.show(new RemotePathMappingCollectionView({ collection: this.remotePathMappingCollection }));
}
});
module.exports = Marionette.Layout.extend({
template : 'Settings/DownloadClient/DownloadClientLayoutTemplate',
regions : {
downloadClients : '#x-download-clients-region',
downloadHandling : '#x-download-handling-region',
droneFactory : '#x-dronefactory-region',
remotePathMappings : '#x-remotepath-mapping-region'
},
initialize : function(){
this.downloadClientsCollection = new DownloadClientCollection();
this.downloadClientsCollection.fetch();
this.remotePathMappingCollection = new RemotePathMappingCollection();
this.remotePathMappingCollection.fetch();
},
onShow : function(){
this.downloadClients.show(new DownloadClientCollectionView({collection : this.downloadClientsCollection}));
this.downloadHandling.show(new DownloadHandlingView({model : this.model}));
this.droneFactory.show(new DroneFactoryView({model : this.model}));
this.remotePathMappings.show(new RemotePathMappingCollectionView({collection : this.remotePathMappingCollection}));
}
});
@@ -1,9 +1,3 @@
'use strict';
var ProviderSettingsModelBase = require('../ProviderSettingsModelBase');
define([
'Settings/ProviderSettingsModelBase'
], function (ProviderSettingsModelBase) {
return ProviderSettingsModelBase.extend({
});
});
module.exports = ProviderSettingsModelBase.extend({});
@@ -1,11 +1,7 @@
'use strict';
var SettingsModelBase = require('../SettingsModelBase');
define([
'Settings/SettingsModelBase'
], function (SettingsModelBase) {
return SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/downloadclient',
successMessage: 'Download client settings saved',
errorMessage : 'Failed to save download client settings'
});
});
module.exports = SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/downloadclient',
successMessage : 'Download client settings saved',
errorMessage : 'Failed to save download client settings'
});
@@ -1,60 +1,48 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (Marionette, AsModelBoundView, AsValidatedView) {
var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var view = Marionette.ItemView.extend({
template: 'Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate',
ui: {
completedDownloadHandlingCheckbox : '.x-completed-download-handling',
completedDownloadOptions : '.x-completed-download-options',
failedAutoRedownladCheckbox : '.x-failed-auto-redownload',
failedDownloadOptions : '.x-failed-download-options'
},
events: {
'change .x-completed-download-handling' : '_setCompletedDownloadOptionsVisibility',
'change .x-failed-auto-redownload' : '_setFailedDownloadOptionsVisibility'
},
onRender: function () {
if (!this.ui.completedDownloadHandlingCheckbox.prop('checked')) {
this.ui.completedDownloadOptions.hide();
}
if (!this.ui.failedAutoRedownladCheckbox.prop('checked')) {
this.ui.failedDownloadOptions.hide();
}
},
_setCompletedDownloadOptionsVisibility: function () {
var checked = this.ui.completedDownloadHandlingCheckbox.prop('checked');
if (checked) {
this.ui.completedDownloadOptions.slideDown();
}
else {
this.ui.completedDownloadOptions.slideUp();
}
},
_setFailedDownloadOptionsVisibility: function () {
var checked = this.ui.failedAutoRedownladCheckbox.prop('checked');
if (checked) {
this.ui.failedDownloadOptions.slideDown();
}
else {
this.ui.failedDownloadOptions.slideUp();
}
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate',
ui : {
completedDownloadHandlingCheckbox : '.x-completed-download-handling',
completedDownloadOptions : '.x-completed-download-options',
failedAutoRedownladCheckbox : '.x-failed-auto-redownload',
failedDownloadOptions : '.x-failed-download-options'
},
events : {
"change .x-completed-download-handling" : '_setCompletedDownloadOptionsVisibility',
"change .x-failed-auto-redownload" : '_setFailedDownloadOptionsVisibility'
},
onRender : function(){
if(!this.ui.completedDownloadHandlingCheckbox.prop('checked')) {
this.ui.completedDownloadOptions.hide();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
if(!this.ui.failedAutoRedownladCheckbox.prop('checked')) {
this.ui.failedDownloadOptions.hide();
}
},
_setCompletedDownloadOptionsVisibility : function(){
var checked = this.ui.completedDownloadHandlingCheckbox.prop('checked');
if(checked) {
this.ui.completedDownloadOptions.slideDown();
}
else {
this.ui.completedDownloadOptions.slideUp();
}
},
_setFailedDownloadOptionsVisibility : function(){
var checked = this.ui.failedAutoRedownladCheckbox.prop('checked');
if(checked) {
this.ui.failedDownloadOptions.slideDown();
}
else {
this.ui.failedDownloadOptions.slideUp();
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
}).call(this);
@@ -1,26 +1,17 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/FileBrowser'
], function (Marionette, AsModelBoundView, AsValidatedView) {
var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
require('../../../Mixins/FileBrowser');
var view = Marionette.ItemView.extend({
template: 'Settings/DownloadClient/DroneFactory/DroneFactoryViewTemplate',
ui: {
droneFactory : '.x-path'
},
onShow: function () {
this.ui.droneFactory.fileBrowser();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DroneFactory/DroneFactoryViewTemplate',
ui : {droneFactory : '.x-path'},
onShow : function(){
this.ui.droneFactory.fileBrowser();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
}).call(this);
@@ -1,66 +1,49 @@
'use strict';
define([
'underscore',
'vent',
'AppLayout',
'marionette',
'Settings/DownloadClient/Delete/DownloadClientDeleteView',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AsEditModalView',
'Form/FormBuilder',
'Mixins/FileBrowser',
'bootstrap'
], function (_, vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, AsValidatedView, AsEditModalView) {
var _ = require('underscore');
var vent = require('../../../vent');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var DeleteView = require('../Delete/DownloadClientDeleteView');
var CommandController = require('../../../Commands/CommandController');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Form/FormBuilder');
require('../../../Mixins/FileBrowser');
require('bootstrap');
require('../Add/DownloadClientSchemaModal');
module.exports = (function(){
var view = Marionette.ItemView.extend({
template: 'Settings/DownloadClient/Edit/DownloadClientEditViewTemplate',
ui: {
template : 'Settings/DownloadClient/Edit/DownloadClientEditViewTemplate',
ui : {
path : '.x-path',
modalBody : '.modal-body'
},
events: {
'click .x-back' : '_back'
},
_deleteView: DeleteView,
initialize: function (options) {
events : {"click .x-back" : '_back'},
_deleteView : DeleteView,
initialize : function(options){
this.targetCollection = options.targetCollection;
},
onShow: function () {
//Hack to deal with modals not overflowing
if (this.ui.path.length > 0) {
onShow : function(){
if(this.ui.path.length > 0) {
this.ui.modalBody.addClass('modal-overflow');
}
this.ui.path.fileBrowser();
},
_onAfterSave: function () {
this.targetCollection.add(this.model, { merge: true });
_onAfterSave : function(){
this.targetCollection.add(this.model, {merge : true});
vent.trigger(vent.Commands.CloseModalCommand);
},
_onAfterSaveAndAdd: function () {
this.targetCollection.add(this.model, { merge: true });
require('Settings/DownloadClient/Add/DownloadClientSchemaModal').open(this.targetCollection);
_onAfterSaveAndAdd : function(){
this.targetCollection.add(this.model, {merge : true});
require('../Add/DownloadClientSchemaModal').open(this.targetCollection);
},
_back: function () {
require('Settings/DownloadClient/Add/DownloadClientSchemaModal').open(this.targetCollection);
_back : function(){
require('../Add/DownloadClientSchemaModal').open(this.targetCollection);
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
return view;
});
}).call(this);
@@ -1,11 +1,7 @@
'use strict';
define([
'backbone',
'Settings/DownloadClient/RemotePathMapping/RemotePathMappingModel'
], function (Backbone, RemotePathMappingModel) {
var Backbone = require('backbone');
var RemotePathMappingModel = require('./RemotePathMappingModel');
return Backbone.Collection.extend({
model : RemotePathMappingModel,
url : window.NzbDrone.ApiRoot + '/remotePathMapping'
});
});
module.exports = Backbone.Collection.extend({
model : RemotePathMappingModel,
url : window.NzbDrone.ApiRoot + '/remotePathMapping'
});
@@ -1,28 +1,22 @@
'use strict';
define([
'AppLayout',
'marionette',
'Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemView',
'Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditView',
'Settings/DownloadClient/RemotePathMapping/RemotePathMappingModel',
'bootstrap'
], function (AppLayout, Marionette, RemotePathMappingItemView, EditView, RemotePathMappingModel) {
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var RemotePathMappingItemView = require('./RemotePathMappingItemView');
var EditView = require('./RemotePathMappingEditView');
var RemotePathMappingModel = require('./RemotePathMappingModel');
require('bootstrap');
return Marionette.CompositeView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionViewTemplate',
itemViewContainer : '.x-rows',
itemView : RemotePathMappingItemView,
events: {
'click .x-add' : '_addMapping'
},
_addMapping: function() {
var model = new RemotePathMappingModel();
model.collection = this.collection;
var view = new EditView({ model: model, targetCollection: this.collection});
AppLayout.modalRegion.show(view);
}
});
});
module.exports = Marionette.CompositeView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionViewTemplate',
itemViewContainer : '.x-rows',
itemView : RemotePathMappingItemView,
events : {"click .x-add" : '_addMapping'},
_addMapping : function(){
var model = new RemotePathMappingModel();
model.collection = this.collection;
var view = new EditView({
model : model,
targetCollection : this.collection
});
AppLayout.modalRegion.show(view);
}
});
@@ -1,23 +1,15 @@
'use strict';
var vent = require('../../../vent');
var Marionette = require('marionette');
define([
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteViewTemplate',
events: {
'click .x-confirm-delete': '_delete'
},
_delete: function () {
this.model.destroy({
wait : true,
success: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
_delete : function(){
this.model.destroy({
wait : true,
success : function(){
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
@@ -1,51 +1,39 @@
'use strict';
define([
'underscore',
'vent',
'AppLayout',
'marionette',
'Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteView',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AsEditModalView',
'Mixins/FileBrowser',
'bootstrap'
], function (_, vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, AsValidatedView, AsEditModalView) {
var _ = require('underscore');
var vent = require('../../../vent');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var DeleteView = require('./RemotePathMappingDeleteView');
var CommandController = require('../../../Commands/CommandController');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Mixins/FileBrowser');
require('bootstrap');
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditViewTemplate',
ui : {
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditViewTemplate',
ui : {
path : '.x-path',
modalBody : '.modal-body'
},
_deleteView: DeleteView,
initialize : function (options) {
_deleteView : DeleteView,
initialize : function(options){
this.targetCollection = options.targetCollection;
},
onShow : function () {
//Hack to deal with modals not overflowing
if (this.ui.path.length > 0) {
onShow : function(){
if(this.ui.path.length > 0) {
this.ui.modalBody.addClass('modal-overflow');
}
this.ui.path.fileBrowser();
},
_onAfterSave : function () {
this.targetCollection.add(this.model, { merge : true });
_onAfterSave : function(){
this.targetCollection.add(this.model, {merge : true});
vent.trigger(vent.Commands.CloseModalCommand);
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
return view;
});
}).call(this);
@@ -1,26 +1,19 @@
'use strict';
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var EditView = require('./RemotePathMappingEditView');
define([
'AppLayout',
'marionette',
'Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditView'
], function (AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemViewTemplate',
className : 'row',
events: {
'click .x-edit' : '_editMapping'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_editMapping: function() {
var view = new EditView({ model: this.model, targetCollection: this.model.collection});
AppLayout.modalRegion.show(view);
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemViewTemplate',
className : 'row',
events : {"click .x-edit" : '_editMapping'},
initialize : function(){
this.listenTo(this.model, 'sync', this.render);
},
_editMapping : function(){
var view = new EditView({
model : this.model,
targetCollection : this.model.collection
});
AppLayout.modalRegion.show(view);
}
});
@@ -1,10 +1,4 @@
'use strict';
var $ = require('jquery');
var DeepModel = require('backbone.deepmodel');
define([
'jquery',
'backbone.deepmodel'
], function ($, DeepModel) {
return DeepModel.DeepModel.extend({
});
});
module.exports = DeepModel.DeepModel.extend({});
@@ -1,12 +1,7 @@
'use strict';
define(
[
'Settings/SettingsModelBase'
], function (SettingsModelBase) {
return SettingsModelBase.extend({
var SettingsModelBase = require('../SettingsModelBase');
url : window.NzbDrone.ApiRoot + '/config/host',
successMessage: 'General settings saved',
errorMessage : 'Failed to save general settings'
});
});
module.exports = SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/host',
successMessage : 'General settings saved',
errorMessage : 'Failed to save general settings'
});
@@ -1,14 +1,9 @@
'use strict';
var ThingyAddCollectionView = require('../../ThingyAddCollectionView');
var ThingyHeaderGroupView = require('../../ThingyHeaderGroupView');
var AddItemView = require('./IndexerAddItemView');
define([
'Settings/ThingyAddCollectionView',
'Settings/ThingyHeaderGroupView',
'Settings/Indexers/Add/IndexerAddItemView'
], function (ThingyAddCollectionView, ThingyHeaderGroupView, AddItemView) {
return ThingyAddCollectionView.extend({
itemView : ThingyHeaderGroupView.extend({ itemView: AddItemView }),
itemViewContainer: '.add-indexer .items',
template : 'Settings/Indexers/Add/IndexerAddCollectionViewTemplate'
});
});
module.exports = ThingyAddCollectionView.extend({
itemView : ThingyHeaderGroupView.extend({itemView : AddItemView}),
itemViewContainer : '.add-indexer .items',
template : 'Settings/Indexers/Add/IndexerAddCollectionViewTemplate'
});
@@ -1,54 +1,42 @@
'use strict';
var _ = require('underscore');
var $ = require('jquery');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var EditView = require('../Edit/IndexerEditView');
define([
'underscore',
'jquery',
'AppLayout',
'marionette',
'Settings/Indexers/Edit/IndexerEditView'
], function (_, $, AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template : 'Settings/Indexers/Add/IndexerAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events: {
'click .x-preset': '_addPreset',
'click' : '_add'
},
initialize: function (options) {
this.targetCollection = options.targetCollection;
},
_addPreset: function (e) {
var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), {name: presetName})[0];
this.model.set(presetData);
this._openEdit();
},
_add: function (e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return;
}
this._openEdit();
},
_openEdit: function () {
this.model.set({
id : undefined,
enableRss : this.model.get('supportsRss'),
enableSearch : this.model.get('supportsSearch')
});
var editView = new EditView({ model: this.model, targetCollection: this.targetCollection });
AppLayout.modalRegion.show(editView);
module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Add/IndexerAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events : {
"click .x-preset" : '_addPreset',
"click" : '_add'
},
initialize : function(options){
this.targetCollection = options.targetCollection;
},
_addPreset : function(e){
var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), {name : presetName})[0];
this.model.set(presetData);
this._openEdit();
},
_add : function(e){
if($(e.target).closest('.btn,.btn-group').length !== 0) {
return;
}
});
});
this._openEdit();
},
_openEdit : function(){
this.model.set({
id : undefined,
enableRss : this.model.get('supportsRss'),
enableSearch : this.model.get('supportsSearch')
});
var editView = new EditView({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
}
});
@@ -1,36 +1,33 @@
'use strict';
var _ = require('underscore');
var AppLayout = require('../../../AppLayout');
var Backbone = require('backbone');
var SchemaCollection = require('../IndexerCollection');
var AddCollectionView = require('./IndexerAddCollectionView');
define([
'underscore',
'AppLayout',
'backbone',
'Settings/Indexers/IndexerCollection',
'Settings/Indexers/Add/IndexerAddCollectionView'
], function (_, AppLayout, Backbone, SchemaCollection, AddCollectionView) {
return ({
open: function (collection) {
var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch();
schemaCollection.url = originalUrl;
var groupedSchemaCollection = new Backbone.Collection();
schemaCollection.on('sync', function() {
var groups = schemaCollection.groupBy(function(model, iterator) { return model.get('protocol'); });
var modelCollection = _.map(groups, function(values, key, list) {
return { 'header': key, collection: values };
});
groupedSchemaCollection.reset(modelCollection);
module.exports = {
open : function(collection){
var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch();
schemaCollection.url = originalUrl;
var groupedSchemaCollection = new Backbone.Collection();
schemaCollection.on('sync', function(){
var groups = schemaCollection.groupBy(function(model, iterator){
return model.get('protocol');
});
var view = new AddCollectionView({ collection: groupedSchemaCollection, targetCollection: collection });
AppLayout.modalRegion.show(view);
}
});
});
var modelCollection = _.map(groups, function(values, key, list){
return {
"header" : key,
collection : values
};
});
groupedSchemaCollection.reset(modelCollection);
});
var view = new AddCollectionView({
collection : groupedSchemaCollection,
targetCollection : collection
});
AppLayout.modalRegion.show(view);
}
};
@@ -1,23 +1,15 @@
'use strict';
var vent = require('../../../vent');
var Marionette = require('marionette');
define([
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Indexers/Delete/IndexerDeleteViewTemplate',
events: {
'click .x-confirm-delete': '_delete'
},
_delete: function () {
this.model.destroy({
wait : true,
success: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Delete/IndexerDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
_delete : function(){
this.model.destroy({
wait : true,
success : function(){
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
@@ -1,55 +1,41 @@
'use strict';
define([
'vent',
'AppLayout',
'marionette',
'Settings/Indexers/Delete/IndexerDeleteView',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AsEditModalView',
'Form/FormBuilder',
'Mixins/AutoComplete',
'bootstrap'
], function (vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, AsValidatedView, AsEditModalView) {
var vent = require('../../../vent');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var DeleteView = require('../Delete/IndexerDeleteView');
var CommandController = require('../../../Commands/CommandController');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Form/FormBuilder');
require('../../../Mixins/AutoComplete');
require('bootstrap');
require('../Add/IndexerSchemaModal');
module.exports = (function(){
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/Edit/IndexerEditViewTemplate',
events: {
'click .x-back' : '_back'
},
_deleteView: DeleteView,
initialize: function (options) {
template : 'Settings/Indexers/Edit/IndexerEditViewTemplate',
events : {"click .x-back" : '_back'},
_deleteView : DeleteView,
initialize : function(options){
this.targetCollection = options.targetCollection;
},
_onAfterSave: function () {
this.targetCollection.add(this.model, { merge: true });
_onAfterSave : function(){
this.targetCollection.add(this.model, {merge : true});
vent.trigger(vent.Commands.CloseModalCommand);
},
_onAfterSaveAndAdd: function () {
this.targetCollection.add(this.model, { merge: true });
require('Settings/Indexers/Add/IndexerSchemaModal').open(this.targetCollection);
_onAfterSaveAndAdd : function(){
this.targetCollection.add(this.model, {merge : true});
require('../Add/IndexerSchemaModal').open(this.targetCollection);
},
_back: function () {
if (this.model.isNew()) {
_back : function(){
if(this.model.isNew()) {
this.model.destroy();
}
require('Settings/Indexers/Add/IndexerSchemaModal').open(this.targetCollection);
require('../Add/IndexerSchemaModal').open(this.targetCollection);
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
return view;
});
}).call(this);
+18 -29
View File
@@ -1,31 +1,20 @@
'use strict';
var Backbone = require('backbone');
var IndexerModel = require('./IndexerModel');
define([
'backbone',
'Settings/Indexers/IndexerModel'
], function (Backbone, IndexerModel) {
return Backbone.Collection.extend({
model: IndexerModel,
url : window.NzbDrone.ApiRoot + '/indexer',
comparator : function(left, right, collection) {
var result = 0;
if (left.get('protocol')) {
result = -left.get('protocol').localeCompare(right.get('protocol'));
}
if (result === 0 && left.get('name')) {
result = left.get('name').localeCompare(right.get('name'));
}
if (result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation'));
}
return result;
module.exports = Backbone.Collection.extend({
model : IndexerModel,
url : window.NzbDrone.ApiRoot + '/indexer',
comparator : function(left, right, collection){
var result = 0;
if(left.get('protocol')) {
result = -left.get('protocol').localeCompare(right.get('protocol'));
}
});
});
if(result === 0 && left.get('name')) {
result = left.get('name').localeCompare(right.get('name'));
}
if(result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation'));
}
return result;
}
});
@@ -1,29 +1,17 @@
'use strict';
var Marionette = require('marionette');
var ItemView = require('./IndexerItemView');
var SchemaModal = require('./Add/IndexerSchemaModal');
define([
'marionette',
'Settings/Indexers/IndexerItemView',
'Settings/Indexers/Add/IndexerSchemaModal'
], function (Marionette, ItemView, SchemaModal) {
return Marionette.CompositeView.extend({
itemView : ItemView,
itemViewContainer: '.indexer-list',
template : 'Settings/Indexers/IndexerCollectionViewTemplate',
ui: {
'addCard': '.x-add-card'
},
events: {
'click .x-add-card': '_openSchemaModal'
},
appendHtml: function (collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_openSchemaModal: function () {
SchemaModal.open(this.collection);
}
});
});
module.exports = Marionette.CompositeView.extend({
itemView : ItemView,
itemViewContainer : '.indexer-list',
template : 'Settings/Indexers/IndexerCollectionViewTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_openSchemaModal'},
appendHtml : function(collectionView, itemView, index){
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_openSchemaModal : function(){
SchemaModal.open(this.collection);
}
});
+18 -25
View File
@@ -1,26 +1,19 @@
'use strict';
var AppLayout = require('../../AppLayout');
var Marionette = require('marionette');
var EditView = require('./Edit/IndexerEditView');
define([
'AppLayout',
'marionette',
'Settings/Indexers/Edit/IndexerEditView'
], function (AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template: 'Settings/Indexers/IndexerItemViewTemplate',
tagName : 'li',
events: {
'click' : '_edit'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_edit: function () {
var view = new EditView({ model: this.model, targetCollection: this.model.collection });
AppLayout.modalRegion.show(view);
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/IndexerItemViewTemplate',
tagName : 'li',
events : {"click" : '_edit'},
initialize : function(){
this.listenTo(this.model, 'sync', this.render);
},
_edit : function(){
var view = new EditView({
model : this.model,
targetCollection : this.model.collection
});
AppLayout.modalRegion.show(view);
}
});
+25 -34
View File
@@ -1,35 +1,26 @@
'use strict';
var Marionette = require('marionette');
var IndexerCollection = require('./IndexerCollection');
var CollectionView = require('./IndexerCollectionView');
var OptionsView = require('./Options/IndexerOptionsView');
var RestrictionCollection = require('./Restriction/RestrictionCollection');
var RestrictionCollectionView = require('./Restriction/RestrictionCollectionView');
define([
'marionette',
'Settings/Indexers/IndexerCollection',
'Settings/Indexers/IndexerCollectionView',
'Settings/Indexers/Options/IndexerOptionsView',
'Settings/Indexers/Restriction/RestrictionCollection',
'Settings/Indexers/Restriction/RestrictionCollectionView'
], function (Marionette, IndexerCollection, CollectionView, OptionsView, RestrictionCollection, RestrictionCollectionView) {
return Marionette.Layout.extend({
template: 'Settings/Indexers/IndexerLayoutTemplate',
regions: {
indexers : '#x-indexers-region',
indexerOptions : '#x-indexer-options-region',
restriction : '#x-restriction-region'
},
initialize: function () {
this.indexersCollection = new IndexerCollection();
this.indexersCollection.fetch();
this.restrictionCollection = new RestrictionCollection();
this.restrictionCollection.fetch();
},
onShow: function () {
this.indexers.show(new CollectionView({ collection: this.indexersCollection }));
this.indexerOptions.show(new OptionsView({ model: this.model }));
this.restriction.show(new RestrictionCollectionView({ collection: this.restrictionCollection }));
}
});
});
module.exports = Marionette.Layout.extend({
template : 'Settings/Indexers/IndexerLayoutTemplate',
regions : {
indexers : '#x-indexers-region',
indexerOptions : '#x-indexer-options-region',
restriction : '#x-restriction-region'
},
initialize : function(){
this.indexersCollection = new IndexerCollection();
this.indexersCollection.fetch();
this.restrictionCollection = new RestrictionCollection();
this.restrictionCollection.fetch();
},
onShow : function(){
this.indexers.show(new CollectionView({collection : this.indexersCollection}));
this.indexerOptions.show(new OptionsView({model : this.model}));
this.restriction.show(new RestrictionCollectionView({collection : this.restrictionCollection}));
}
});
+2 -8
View File
@@ -1,9 +1,3 @@
'use strict';
var ProviderSettingsModelBase = require('../ProviderSettingsModelBase');
define([
'Settings/ProviderSettingsModelBase'
], function (ProviderSettingsModelBase) {
return ProviderSettingsModelBase.extend({
});
});
module.exports = ProviderSettingsModelBase.extend({});
@@ -1,11 +1,7 @@
'use strict';
var SettingsModelBase = require('../SettingsModelBase');
define([
'Settings/SettingsModelBase'
], function (SettingsModelBase) {
return SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/indexer',
successMessage: 'Indexer settings saved',
errorMessage : 'Failed to save indexer settings'
});
});
module.exports = SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/indexer',
successMessage : 'Indexer settings saved',
errorMessage : 'Failed to save indexer settings'
});
@@ -1,17 +1,10 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (Marionette, AsModelBoundView, AsValidatedView) {
var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/Options/IndexerOptionsViewTemplate'
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
});
module.exports = (function(){
var view = Marionette.ItemView.extend({template : 'Settings/Indexers/Options/IndexerOptionsViewTemplate'});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
}).call(this);
@@ -1,11 +1,7 @@
'use strict';
define([
'backbone',
'Settings/Indexers/Restriction/RestrictionModel'
], function (Backbone, RestrictionModel) {
var Backbone = require('backbone');
var RestrictionModel = require('./RestrictionModel');
return Backbone.Collection.extend({
model : RestrictionModel,
url : window.NzbDrone.ApiRoot + '/Restriction'
});
});
module.exports = Backbone.Collection.extend({
model : RestrictionModel,
url : window.NzbDrone.ApiRoot + '/Restriction'
});
@@ -1,27 +1,21 @@
'use strict';
define([
'AppLayout',
'marionette',
'Settings/Indexers/Restriction/RestrictionItemView',
'Settings/Indexers/Restriction/RestrictionEditView',
'Tags/TagHelpers',
'bootstrap'
], function (AppLayout, Marionette, RestrictionItemView, EditView) {
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var RestrictionItemView = require('./RestrictionItemView');
var EditView = require('./RestrictionEditView');
require('../../../Tags/TagHelpers');
require('bootstrap');
return Marionette.CompositeView.extend({
template : 'Settings/Indexers/Restriction/RestrictionCollectionViewTemplate',
itemViewContainer : '.x-rows',
itemView : RestrictionItemView,
events: {
'click .x-add' : '_addMapping'
},
_addMapping: function() {
var model = this.collection.create({ tags: [] });
var view = new EditView({ model: model, targetCollection: this.collection});
AppLayout.modalRegion.show(view);
}
});
});
module.exports = Marionette.CompositeView.extend({
template : 'Settings/Indexers/Restriction/RestrictionCollectionViewTemplate',
itemViewContainer : '.x-rows',
itemView : RestrictionItemView,
events : {"click .x-add" : '_addMapping'},
_addMapping : function(){
var model = this.collection.create({tags : []});
var view = new EditView({
model : model,
targetCollection : this.collection
});
AppLayout.modalRegion.show(view);
}
});
@@ -1,23 +1,15 @@
'use strict';
var vent = require('../../../vent');
var Marionette = require('marionette');
define([
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Indexers/Restriction/RestrictionDeleteViewTemplate',
events: {
'click .x-confirm-delete': '_delete'
},
_delete: function () {
this.model.destroy({
wait : true,
success: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Restriction/RestrictionDeleteViewTemplate',
events : {'click .x-confirm-delete' : '_delete'},
_delete : function(){
this.model.destroy({
wait : true,
success : function(){
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
@@ -1,61 +1,49 @@
'use strict';
define([
'underscore',
'vent',
'AppLayout',
'marionette',
'Settings/Indexers/Restriction/RestrictionDeleteView',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AsEditModalView',
'Mixins/TagInput',
'bootstrap',
'bootstrap.tagsinput'
], function (_, vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, AsValidatedView, AsEditModalView) {
var _ = require('underscore');
var vent = require('../../../vent');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var DeleteView = require('./RestrictionDeleteView');
var CommandController = require('../../../Commands/CommandController');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Mixins/TagInput');
require('bootstrap');
require('bootstrap.tagsinput');
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/Indexers/Restriction/RestrictionEditViewTemplate',
ui : {
template : 'Settings/Indexers/Restriction/RestrictionEditViewTemplate',
ui : {
required : '.x-required',
ignored : '.x-ignored',
tags : '.x-tags'
},
_deleteView: DeleteView,
initialize : function (options) {
_deleteView : DeleteView,
initialize : function(options){
this.targetCollection = options.targetCollection;
},
onRender : function () {
onRender : function(){
this.ui.required.tagsinput({
trimValue : true,
tagClass : 'label label-success'
});
this.ui.ignored.tagsinput({
trimValue : true,
tagClass : 'label label-danger'
});
this.ui.tags.tagInput({
model : this.model,
property : 'tags'
});
},
_onAfterSave : function () {
this.targetCollection.add(this.model, { merge : true });
_onAfterSave : function(){
this.targetCollection.add(this.model, {merge : true});
vent.trigger(vent.Commands.CloseModalCommand);
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
return view;
});
}).call(this);
@@ -1,30 +1,20 @@
'use strict';
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var EditView = require('./RestrictionEditView');
define([
'AppLayout',
'marionette',
'Settings/Indexers/Restriction/RestrictionEditView'
], function (AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template : 'Settings/Indexers/Restriction/RestrictionItemViewTemplate',
className : 'row',
ui: {
tags: '.x-tags'
},
events: {
'click .x-edit' : '_edit'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_edit: function() {
var view = new EditView({ model: this.model, targetCollection: this.model.collection});
AppLayout.modalRegion.show(view);
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Restriction/RestrictionItemViewTemplate',
className : 'row',
ui : {tags : '.x-tags'},
events : {"click .x-edit" : '_edit'},
initialize : function(){
this.listenTo(this.model, 'sync', this.render);
},
_edit : function(){
var view = new EditView({
model : this.model,
targetCollection : this.model.collection
});
AppLayout.modalRegion.show(view);
}
});
@@ -1,10 +1,4 @@
'use strict';
var $ = require('jquery');
var DeepModel = require('backbone.deepmodel');
define([
'jquery',
'backbone.deepmodel'
], function ($, DeepModel) {
return DeepModel.DeepModel.extend({
});
});
module.exports = DeepModel.DeepModel.extend({});
@@ -1,28 +1,19 @@
'use strict';
define(
[
'vent',
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/DirectoryAutoComplete',
'Mixins/FileBrowser'
], function (vent, Marionette, AsModelBoundView, AsValidatedView) {
var vent = require('../../../vent');
var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
require('../../../Mixins/DirectoryAutoComplete');
require('../../../Mixins/FileBrowser');
var view = Marionette.ItemView.extend({
template: 'Settings/MediaManagement/FileManagement/FileManagementViewTemplate',
ui: {
recyclingBin : '.x-path'
},
onShow: function () {
this.ui.recyclingBin.fileBrowser();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/MediaManagement/FileManagement/FileManagementViewTemplate',
ui : {recyclingBin : '.x-path'},
onShow : function(){
this.ui.recyclingBin.fileBrowser();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
}).call(this);
@@ -1,34 +1,25 @@
'use strict';
define(
[
'marionette',
'Settings/MediaManagement/Naming/NamingView',
'Settings/MediaManagement/Sorting/SortingView',
'Settings/MediaManagement/FileManagement/FileManagementView',
'Settings/MediaManagement/Permissions/PermissionsView'
], function (Marionette, NamingView, SortingView, FileManagementView, PermissionsView) {
return Marionette.Layout.extend({
template: 'Settings/MediaManagement/MediaManagementLayoutTemplate',
regions: {
episodeNaming : '#episode-naming',
sorting : '#sorting',
fileManagement : '#file-management',
permissions : '#permissions'
},
initialize: function (options) {
this.settings = options.settings;
this.namingSettings = options.namingSettings;
},
onShow: function () {
this.episodeNaming.show(new NamingView({ model: this.namingSettings }));
this.sorting.show(new SortingView({ model: this.settings }));
this.fileManagement.show(new FileManagementView({ model: this.settings }));
this.permissions.show(new PermissionsView({ model: this.settings }));
}
});
});
var Marionette = require('marionette');
var NamingView = require('./Naming/NamingView');
var SortingView = require('./Sorting/SortingView');
var FileManagementView = require('./FileManagement/FileManagementView');
var PermissionsView = require('./Permissions/PermissionsView');
module.exports = Marionette.Layout.extend({
template : 'Settings/MediaManagement/MediaManagementLayoutTemplate',
regions : {
episodeNaming : '#episode-naming',
sorting : '#sorting',
fileManagement : '#file-management',
permissions : '#permissions'
},
initialize : function(options){
this.settings = options.settings;
this.namingSettings = options.namingSettings;
},
onShow : function(){
this.episodeNaming.show(new NamingView({model : this.namingSettings}));
this.sorting.show(new SortingView({model : this.settings}));
this.fileManagement.show(new FileManagementView({model : this.settings}));
this.permissions.show(new PermissionsView({model : this.settings}));
}
});
@@ -1,11 +1,7 @@
'use strict';
define(
[
'Settings/SettingsModelBase'
], function (SettingsModelBase) {
return SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/mediamanagement',
successMessage: 'Media management settings saved',
errorMessage : 'Failed to save media managemnent settings'
});
});
var SettingsModelBase = require('../SettingsModelBase');
module.exports = SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/mediamanagement',
successMessage : 'Media management settings saved',
errorMessage : 'Failed to save media managemnent settings'
});
@@ -1,9 +1,3 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
var Backbone = require('backbone');
});
});
module.exports = Backbone.Model.extend({});
@@ -1,133 +1,105 @@
'use strict';
define(
[
'underscore',
'marionette',
'Config',
'Settings/MediaManagement/Naming/NamingSampleModel',
'Settings/MediaManagement/Naming/Basic/BasicNamingModel',
'Mixins/AsModelBoundView'
], function (_, Marionette, Config, NamingSampleModel, BasicNamingModel, AsModelBoundView) {
var _ = require('underscore');
var Marionette = require('marionette');
var Config = require('../../../../Config');
var NamingSampleModel = require('../NamingSampleModel');
var BasicNamingModel = require('./BasicNamingModel');
var AsModelBoundView = require('../../../../Mixins/AsModelBoundView');
var view = Marionette.ItemView.extend({
template: 'Settings/MediaManagement/Naming/Basic/BasicNamingViewTemplate',
ui: {
namingOptions : '.x-naming-options',
singleEpisodeExample : '.x-single-episode-example',
multiEpisodeExample : '.x-multi-episode-example',
dailyEpisodeExample : '.x-daily-episode-example'
},
initialize: function (options) {
this.namingModel = options.model;
this.model = new BasicNamingModel();
this._parseNamingModel();
this.listenTo(this.model, 'change', this._buildFormat);
this.listenTo(this.namingModel, 'sync', this._parseNamingModel);
},
_parseNamingModel: function () {
var standardFormat = this.namingModel.get('standardEpisodeFormat');
var includeSeriesTitle = standardFormat.match(/\{Series[-_. ]Title\}/i);
var includeEpisodeTitle = standardFormat.match(/\{Episode[-_. ]Title\}/i);
var includeQuality = standardFormat.match(/\{Quality[-_. ]Title\}/i);
var numberStyle = standardFormat.match(/s?\{season(?:\:0+)?\}[ex]\{episode(?:\:0+)?\}/i);
var replaceSpaces = standardFormat.indexOf(' ') === -1;
var separator = standardFormat.match(/\}( - |\.-\.|\.| )|( - |\.-\.|\.| )\{/i);
if (separator === null || separator[1] === '.-.') {
separator = ' - ';
}
else {
separator = separator[1];
}
if (numberStyle === null) {
numberStyle = 'S{season:00}E{episode:00}';
}
else {
numberStyle = numberStyle[0];
}
this.model.set({
includeSeriesTitle: includeSeriesTitle !== null,
includeEpisodeTitle: includeEpisodeTitle !== null,
includeQuality: includeQuality !== null,
numberStyle: numberStyle,
replaceSpaces: replaceSpaces,
separator: separator
}, { silent: true });
},
_buildFormat: function () {
if (Config.getValueBoolean(Config.Keys.AdvancedSettings)) {
return;
}
var standardEpisodeFormat = '';
var dailyEpisodeFormat = '';
if (this.model.get('includeSeriesTitle')) {
if (this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Series.Title}';
dailyEpisodeFormat += '{Series.Title}';
}
else {
standardEpisodeFormat += '{Series Title}';
dailyEpisodeFormat += '{Series Title}';
}
standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator');
}
standardEpisodeFormat += this.model.get('numberStyle');
dailyEpisodeFormat += '{Air-Date}';
if (this.model.get('includeEpisodeTitle')) {
standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator');
if (this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Episode.Title}';
dailyEpisodeFormat += '{Episode.Title}';
}
else {
standardEpisodeFormat += '{Episode Title}';
dailyEpisodeFormat += '{Episode Title}';
}
}
if (this.model.get('includeQuality')) {
if (this.model.get('replaceSpaces')) {
standardEpisodeFormat += ' {Quality.Title}';
dailyEpisodeFormat += ' {Quality.Title}';
}
else {
standardEpisodeFormat += ' {Quality Title}';
dailyEpisodeFormat += ' {Quality Title}';
}
}
if (this.model.get('replaceSpaces')) {
standardEpisodeFormat = standardEpisodeFormat.replace(/\s/g, '.');
dailyEpisodeFormat = dailyEpisodeFormat.replace(/\s/g, '.');
}
this.namingModel.set('standardEpisodeFormat', standardEpisodeFormat);
this.namingModel.set('dailyEpisodeFormat', dailyEpisodeFormat);
this.namingModel.set('animeEpisodeFormat', standardEpisodeFormat);
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/MediaManagement/Naming/Basic/BasicNamingViewTemplate',
ui : {
namingOptions : '.x-naming-options',
singleEpisodeExample : '.x-single-episode-example',
multiEpisodeExample : '.x-multi-episode-example',
dailyEpisodeExample : '.x-daily-episode-example'
},
initialize : function(options){
this.namingModel = options.model;
this.model = new BasicNamingModel();
this._parseNamingModel();
this.listenTo(this.model, 'change', this._buildFormat);
this.listenTo(this.namingModel, 'sync', this._parseNamingModel);
},
_parseNamingModel : function(){
var standardFormat = this.namingModel.get('standardEpisodeFormat');
var includeSeriesTitle = standardFormat.match(/\{Series[-_. ]Title\}/i);
var includeEpisodeTitle = standardFormat.match(/\{Episode[-_. ]Title\}/i);
var includeQuality = standardFormat.match(/\{Quality[-_. ]Title\}/i);
var numberStyle = standardFormat.match(/s?\{season(?:\:0+)?\}[ex]\{episode(?:\:0+)?\}/i);
var replaceSpaces = standardFormat.indexOf(' ') === -1;
var separator = standardFormat.match(/\}( - |\.-\.|\.| )|( - |\.-\.|\.| )\{/i);
if(separator === null || separator[1] === '.-.') {
separator = ' - ';
}
});
return AsModelBoundView.call(view);
else {
separator = separator[1];
}
if(numberStyle === null) {
numberStyle = 'S{season:00}E{episode:00}';
}
else {
numberStyle = numberStyle[0];
}
this.model.set({
includeSeriesTitle : includeSeriesTitle !== null,
includeEpisodeTitle : includeEpisodeTitle !== null,
includeQuality : includeQuality !== null,
numberStyle : numberStyle,
replaceSpaces : replaceSpaces,
separator : separator
}, {silent : true});
},
_buildFormat : function(){
if(Config.getValueBoolean(Config.Keys.AdvancedSettings)) {
return;
}
var standardEpisodeFormat = '';
var dailyEpisodeFormat = '';
if(this.model.get('includeSeriesTitle')) {
if(this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Series.Title}';
dailyEpisodeFormat += '{Series.Title}';
}
else {
standardEpisodeFormat += '{Series Title}';
dailyEpisodeFormat += '{Series Title}';
}
standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator');
}
standardEpisodeFormat += this.model.get('numberStyle');
dailyEpisodeFormat += '{Air-Date}';
if(this.model.get('includeEpisodeTitle')) {
standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator');
if(this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Episode.Title}';
dailyEpisodeFormat += '{Episode.Title}';
}
else {
standardEpisodeFormat += '{Episode Title}';
dailyEpisodeFormat += '{Episode Title}';
}
}
if(this.model.get('includeQuality')) {
if(this.model.get('replaceSpaces')) {
standardEpisodeFormat += ' {Quality.Title}';
dailyEpisodeFormat += ' {Quality.Title}';
}
else {
standardEpisodeFormat += ' {Quality Title}';
dailyEpisodeFormat += ' {Quality Title}';
}
}
if(this.model.get('replaceSpaces')) {
standardEpisodeFormat = standardEpisodeFormat.replace(/\s/g, '.');
dailyEpisodeFormat = dailyEpisodeFormat.replace(/\s/g, '.');
}
this.namingModel.set('standardEpisodeFormat', standardEpisodeFormat);
this.namingModel.set('dailyEpisodeFormat', dailyEpisodeFormat);
this.namingModel.set('animeEpisodeFormat', standardEpisodeFormat);
}
});
return AsModelBoundView.call(view);
}).call(this);
@@ -1,11 +1,7 @@
'use strict';
define(
[
'Settings/SettingsModelBase'
], function (ModelBase) {
return ModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/naming',
successMessage: 'MediaManagement settings saved',
errorMessage : 'Couldn\'t save naming settings'
});
});
var ModelBase = require('../../SettingsModelBase');
module.exports = ModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/naming',
successMessage : 'MediaManagement settings saved',
errorMessage : 'Couldn\'t save naming settings'
});
@@ -1,9 +1,3 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
url: window.NzbDrone.ApiRoot + '/config/naming/samples'
});
});
var Backbone = require('backbone');
module.exports = Backbone.Model.extend({url : window.NzbDrone.ApiRoot + '/config/naming/samples'});
@@ -1,111 +1,87 @@
'use strict';
define(
[
'underscore',
'marionette',
'Settings/MediaManagement/Naming/NamingSampleModel',
'Settings/MediaManagement/Naming/Basic/BasicNamingView',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (_, Marionette, NamingSampleModel, BasicNamingView, AsModelBoundView, AsValidatedView) {
var _ = require('underscore');
var Marionette = require('marionette');
var NamingSampleModel = require('./NamingSampleModel');
var BasicNamingView = require('./Basic/BasicNamingView');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var view = Marionette.Layout.extend({
template: 'Settings/MediaManagement/Naming/NamingViewTemplate',
ui: {
namingOptions : '.x-naming-options',
renameEpisodesCheckbox : '.x-rename-episodes',
singleEpisodeExample : '.x-single-episode-example',
multiEpisodeExample : '.x-multi-episode-example',
dailyEpisodeExample : '.x-daily-episode-example',
animeEpisodeExample : '.x-anime-episode-example',
animeMultiEpisodeExample : '.x-anime-multi-episode-example',
namingTokenHelper : '.x-naming-token-helper',
multiEpisodeStyle : '.x-multi-episode-style',
seriesFolderExample : '.x-series-folder-example',
seasonFolderExample : '.x-season-folder-example'
},
events: {
'change .x-rename-episodes' : '_setFailedDownloadOptionsVisibility',
'click .x-show-wizard' : '_showWizard',
'click .x-naming-token-helper a' : '_addToken',
'change .x-multi-episode-style' : '_multiEpisodeFomatChanged'
},
regions: {
basicNamingRegion: '.x-basic-naming'
},
onRender: function () {
if (!this.model.get('renameEpisodes')) {
this.ui.namingOptions.hide();
}
var basicNamingView = new BasicNamingView({ model: this.model });
this.basicNamingRegion.show(basicNamingView);
this.namingSampleModel = new NamingSampleModel();
this.listenTo(this.model, 'change', this._updateSamples);
this.listenTo(this.namingSampleModel, 'sync', this._showSamples);
this._updateSamples();
},
_setFailedDownloadOptionsVisibility: function () {
var checked = this.ui.renameEpisodesCheckbox.prop('checked');
if (checked) {
this.ui.namingOptions.slideDown();
}
else {
this.ui.namingOptions.slideUp();
}
},
_updateSamples: function () {
this.namingSampleModel.fetch({ data: this.model.toJSON() });
},
_showSamples: function () {
this.ui.singleEpisodeExample.html(this.namingSampleModel.get('singleEpisodeExample'));
this.ui.multiEpisodeExample.html(this.namingSampleModel.get('multiEpisodeExample'));
this.ui.dailyEpisodeExample.html(this.namingSampleModel.get('dailyEpisodeExample'));
this.ui.animeEpisodeExample.html(this.namingSampleModel.get('animeEpisodeExample'));
this.ui.animeMultiEpisodeExample.html(this.namingSampleModel.get('animeMultiEpisodeExample'));
this.ui.seriesFolderExample.html(this.namingSampleModel.get('seriesFolderExample'));
this.ui.seasonFolderExample.html(this.namingSampleModel.get('seasonFolderExample'));
},
_addToken: function (e) {
e.preventDefault();
e.stopPropagation();
var target = e.target;
var token = '';
var input = this.$(target).closest('.x-helper-input').children('input');
if (this.$(target).attr('data-token')) {
token = '{{0}}'.format(this.$(target).attr('data-token'));
}
else {
token = this.$(target).attr('data-separator');
}
input.val(input.val() + token);
input.change();
this.ui.namingTokenHelper.removeClass('open');
input.focus();
},
multiEpisodeFormatChanged: function () {
this.model.set('multiEpisodeStyle', this.ui.multiEpisodeStyle.val());
module.exports = (function(){
var view = Marionette.Layout.extend({
template : 'Settings/MediaManagement/Naming/NamingViewTemplate',
ui : {
namingOptions : '.x-naming-options',
renameEpisodesCheckbox : '.x-rename-episodes',
singleEpisodeExample : '.x-single-episode-example',
multiEpisodeExample : '.x-multi-episode-example',
dailyEpisodeExample : '.x-daily-episode-example',
animeEpisodeExample : '.x-anime-episode-example',
animeMultiEpisodeExample : '.x-anime-multi-episode-example',
namingTokenHelper : '.x-naming-token-helper',
multiEpisodeStyle : '.x-multi-episode-style',
seriesFolderExample : '.x-series-folder-example',
seasonFolderExample : '.x-season-folder-example'
},
events : {
"change .x-rename-episodes" : '_setFailedDownloadOptionsVisibility',
"click .x-show-wizard" : '_showWizard',
"click .x-naming-token-helper a" : '_addToken',
"change .x-multi-episode-style" : '_multiEpisodeFomatChanged'
},
regions : {basicNamingRegion : '.x-basic-naming'},
onRender : function(){
if(!this.model.get('renameEpisodes')) {
this.ui.namingOptions.hide();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
var basicNamingView = new BasicNamingView({model : this.model});
this.basicNamingRegion.show(basicNamingView);
this.namingSampleModel = new NamingSampleModel();
this.listenTo(this.model, 'change', this._updateSamples);
this.listenTo(this.namingSampleModel, 'sync', this._showSamples);
this._updateSamples();
},
_setFailedDownloadOptionsVisibility : function(){
var checked = this.ui.renameEpisodesCheckbox.prop('checked');
if(checked) {
this.ui.namingOptions.slideDown();
}
else {
this.ui.namingOptions.slideUp();
}
},
_updateSamples : function(){
this.namingSampleModel.fetch({data : this.model.toJSON()});
},
_showSamples : function(){
this.ui.singleEpisodeExample.html(this.namingSampleModel.get('singleEpisodeExample'));
this.ui.multiEpisodeExample.html(this.namingSampleModel.get('multiEpisodeExample'));
this.ui.dailyEpisodeExample.html(this.namingSampleModel.get('dailyEpisodeExample'));
this.ui.animeEpisodeExample.html(this.namingSampleModel.get('animeEpisodeExample'));
this.ui.animeMultiEpisodeExample.html(this.namingSampleModel.get('animeMultiEpisodeExample'));
this.ui.seriesFolderExample.html(this.namingSampleModel.get('seriesFolderExample'));
this.ui.seasonFolderExample.html(this.namingSampleModel.get('seasonFolderExample'));
},
_addToken : function(e){
e.preventDefault();
e.stopPropagation();
var target = e.target;
var token = '';
var input = this.$(target).closest('.x-helper-input').children('input');
if(this.$(target).attr('data-token')) {
token = '{{0}}'.format(this.$(target).attr('data-token'));
}
else {
token = this.$(target).attr('data-separator');
}
input.val(input.val() + token);
input.change();
this.ui.namingTokenHelper.removeClass('open');
input.focus();
},
multiEpisodeFormatChanged : function(){
this.model.set('multiEpisodeStyle', this.ui.multiEpisodeStyle.val());
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
}).call(this);
@@ -1,17 +1,10 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (Marionette, AsModelBoundView, AsValidatedView) {
var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var view = Marionette.ItemView.extend({
template: 'Settings/MediaManagement/Permissions/PermissionsViewTemplate'
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
});
module.exports = (function(){
var view = Marionette.ItemView.extend({template : 'Settings/MediaManagement/Permissions/PermissionsViewTemplate'});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
}).call(this);
@@ -1,17 +1,10 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (Marionette, AsModelBoundView, AsValidatedView) {
var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var view = Marionette.ItemView.extend({
template: 'Settings/MediaManagement/Sorting/SortingViewTemplate'
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
});
module.exports = (function(){
var view = Marionette.ItemView.extend({template : 'Settings/MediaManagement/Sorting/SortingViewTemplate'});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
}).call(this);
+6 -11
View File
@@ -1,12 +1,7 @@
'use strict';
define(
[
'backbone',
'Settings/Metadata/MetadataModel'
], function (Backbone, MetadataModel) {
var Backbone = require('backbone');
var MetadataModel = require('./MetadataModel');
return Backbone.Collection.extend({
model: MetadataModel,
url : window.NzbDrone.ApiRoot + '/metadata'
});
});
module.exports = Backbone.Collection.extend({
model : MetadataModel,
url : window.NzbDrone.ApiRoot + '/metadata'
});
@@ -1,13 +1,9 @@
'use strict';
define(
[
'AppLayout',
'marionette',
'Settings/Metadata/MetadataItemView'
], function (AppLayout, Marionette, MetadataItemView) {
return Marionette.CompositeView.extend({
itemView : MetadataItemView,
itemViewContainer: '#x-metadata',
template : 'Settings/Metadata/MetadataCollectionViewTemplate'
});
});
var AppLayout = require('../../AppLayout');
var Marionette = require('marionette');
var MetadataItemView = require('./MetadataItemView');
module.exports = Marionette.CompositeView.extend({
itemView : MetadataItemView,
itemViewContainer : '#x-metadata',
template : 'Settings/Metadata/MetadataCollectionViewTemplate'
});
+16 -23
View File
@@ -1,25 +1,18 @@
'use strict';
var vent = require('../../vent');
var Marionette = require('marionette');
var AsModelBoundView = require('../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../Mixins/AsValidatedView');
var AsEditModalView = require('../../Mixins/AsEditModalView');
define(
[
'vent',
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AsEditModalView'
], function (vent, Marionette, AsModelBoundView, AsValidatedView, AsEditModalView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Metadata/MetadataEditViewTemplate',
_onAfterSave: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
return view;
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/Metadata/MetadataEditViewTemplate',
_onAfterSave : function(){
vent.trigger(vent.Commands.CloseModalCommand);
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
return view;
}).call(this);
+18 -28
View File
@@ -1,30 +1,20 @@
'use strict';
var AppLayout = require('../../AppLayout');
var Marionette = require('marionette');
var EditView = require('./MetadataEditView');
var AsModelBoundView = require('../../Mixins/AsModelBoundView');
define(
[
'AppLayout',
'marionette',
'Settings/Metadata/MetadataEditView',
'Mixins/AsModelBoundView'
], function (AppLayout, Marionette, EditView, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Metadata/MetadataItemViewTemplate',
tagName : 'li',
events: {
'click' : '_edit'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_edit: function () {
var view = new EditView({ model: this.model});
AppLayout.modalRegion.show(view);
}
});
return AsModelBoundView.call(view);
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/Metadata/MetadataItemViewTemplate',
tagName : 'li',
events : {"click" : '_edit'},
initialize : function(){
this.listenTo(this.model, 'sync', this.render);
},
_edit : function(){
var view = new EditView({model : this.model});
AppLayout.modalRegion.show(view);
}
});
return AsModelBoundView.call(view);
}).call(this);
+15 -26
View File
@@ -1,27 +1,16 @@
'use strict';
define(
[
'marionette',
'Settings/Metadata/MetadataCollection',
'Settings/Metadata/MetadataCollectionView'
], function (Marionette, MetadataCollection, MetadataCollectionView) {
return Marionette.Layout.extend({
template: 'Settings/Metadata/MetadataLayoutTemplate',
regions: {
metadata : '#x-metadata-providers'
},
initialize: function (options) {
this.settings = options.settings;
this.metadataCollection = new MetadataCollection();
this.metadataCollection.fetch();
},
onShow: function () {
this.metadata.show(new MetadataCollectionView({collection: this.metadataCollection}));
}
});
});
var Marionette = require('marionette');
var MetadataCollection = require('./MetadataCollection');
var MetadataCollectionView = require('./MetadataCollectionView');
module.exports = Marionette.Layout.extend({
template : 'Settings/Metadata/MetadataLayoutTemplate',
regions : {metadata : '#x-metadata-providers'},
initialize : function(options){
this.settings = options.settings;
this.metadataCollection = new MetadataCollection();
this.metadataCollection.fetch();
},
onShow : function(){
this.metadata.show(new MetadataCollectionView({collection : this.metadataCollection}));
}
});
+2 -9
View File
@@ -1,10 +1,3 @@
'use strict';
define([
'Settings/ProviderSettingsModelBase'
], function (ProviderSettingsModelBase) {
return ProviderSettingsModelBase.extend({
});
});
var ProviderSettingsModelBase = require('../ProviderSettingsModelBase');
module.exports = ProviderSettingsModelBase.extend({});
@@ -1,13 +1,8 @@
'use strict';
var ThingyAddCollectionView = require('../../ThingyAddCollectionView');
var AddItemView = require('./NotificationAddItemView');
define([
'Settings/ThingyAddCollectionView',
'Settings/Notifications/Add/NotificationAddItemView'
], function (ThingyAddCollectionView, AddItemView) {
return ThingyAddCollectionView.extend({
itemView : AddItemView,
itemViewContainer: '.add-notifications .items',
template : 'Settings/Notifications/Add/NotificationAddCollectionViewTemplate'
});
});
module.exports = ThingyAddCollectionView.extend({
itemView : AddItemView,
itemViewContainer : '.add-notifications .items',
template : 'Settings/Notifications/Add/NotificationAddCollectionViewTemplate'
});
@@ -1,60 +1,50 @@
'use strict';
var _ = require('underscore');
var $ = require('jquery');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var EditView = require('../Edit/NotificationEditView');
define([
'underscore',
'jquery',
'AppLayout',
'marionette',
'Settings/Notifications/Edit/NotificationEditView'
], function (_, $, AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template : 'Settings/Notifications/Add/NotificationAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events: {
'click .x-preset': '_addPreset',
'click' : '_add'
},
initialize: function (options) {
this.targetCollection = options.targetCollection;
},
_addPreset: function (e) {
var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), {name: presetName})[0];
this.model.set(presetData);
this.model.set({
id : undefined,
onGrab : true,
onDownload : true,
onUpgrade : true
});
var editView = new EditView({ model: this.model, targetCollection: this.targetCollection });
AppLayout.modalRegion.show(editView);
},
_add: function (e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return;
}
this.model.set({
id : undefined,
onGrab : true,
onDownload : true,
onUpgrade : true
});
var editView = new EditView({ model: this.model, targetCollection: this.targetCollection });
AppLayout.modalRegion.show(editView);
module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/Add/NotificationAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events : {
"click .x-preset" : '_addPreset',
"click" : '_add'
},
initialize : function(options){
this.targetCollection = options.targetCollection;
},
_addPreset : function(e){
var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), {name : presetName})[0];
this.model.set(presetData);
this.model.set({
id : undefined,
onGrab : true,
onDownload : true,
onUpgrade : true
});
var editView = new EditView({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
},
_add : function(e){
if($(e.target).closest('.btn,.btn-group').length !== 0) {
return;
}
});
});
this.model.set({
id : undefined,
onGrab : true,
onDownload : true,
onUpgrade : true
});
var editView = new EditView({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
}
});
@@ -1,21 +1,18 @@
'use strict';
var AppLayout = require('../../../AppLayout');
var SchemaCollection = require('../NotificationCollection');
var AddCollectionView = require('./NotificationAddCollectionView');
define([
'AppLayout',
'Settings/Notifications/NotificationCollection',
'Settings/Notifications/Add/NotificationAddCollectionView'
], function (AppLayout, SchemaCollection, AddCollectionView) {
return ({
open: function (collection) {
var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch();
schemaCollection.url = originalUrl;
var view = new AddCollectionView({ collection: schemaCollection, targetCollection: collection});
AppLayout.modalRegion.show(view);
}
});
});
module.exports = {
open : function(collection){
var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch();
schemaCollection.url = originalUrl;
var view = new AddCollectionView({
collection : schemaCollection,
targetCollection : collection
});
AppLayout.modalRegion.show(view);
}
};
@@ -1,23 +1,15 @@
'use strict';
var vent = require('../../../vent');
var Marionette = require('marionette');
define([
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/Delete/NotificationDeleteViewTemplate',
events: {
'click .x-confirm-delete': '_delete'
},
_delete: function () {
this.model.destroy({
wait : true,
success: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/Delete/NotificationDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
_delete : function(){
this.model.destroy({
wait : true,
success : function(){
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
@@ -1,83 +1,65 @@
'use strict';
define([
'underscore',
'vent',
'AppLayout',
'marionette',
'Settings/Notifications/Delete/NotificationDeleteView',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AsEditModalView',
'Form/FormBuilder',
'Mixins/TagInput'
], function (_, vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, AsValidatedView, AsEditModalView) {
var _ = require('underscore');
var vent = require('../../../vent');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var DeleteView = require('../Delete/NotificationDeleteView');
var CommandController = require('../../../Commands/CommandController');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Form/FormBuilder');
require('../../../Mixins/TagInput');
require('../Add/NotificationSchemaModal');
module.exports = (function(){
var view = Marionette.ItemView.extend({
template: 'Settings/Notifications/Edit/NotificationEditViewTemplate',
ui: {
template : 'Settings/Notifications/Edit/NotificationEditViewTemplate',
ui : {
onDownloadToggle : '.x-on-download',
onUpgradeSection : '.x-on-upgrade',
tags : '.x-tags'
},
events: {
'click .x-back' : '_back',
'change .x-on-download': '_onDownloadChanged'
events : {
"click .x-back" : '_back',
"change .x-on-download" : '_onDownloadChanged'
},
_deleteView: DeleteView,
initialize: function (options) {
_deleteView : DeleteView,
initialize : function(options){
this.targetCollection = options.targetCollection;
},
onRender: function () {
onRender : function(){
this._onDownloadChanged();
this.ui.tags.tagInput({
model : this.model,
property : 'tags'
});
},
_onAfterSave: function () {
this.targetCollection.add(this.model, { merge: true });
_onAfterSave : function(){
this.targetCollection.add(this.model, {merge : true});
vent.trigger(vent.Commands.CloseModalCommand);
},
_onAfterSaveAndAdd: function () {
this.targetCollection.add(this.model, { merge: true });
require('Settings/Notifications/Add/NotificationSchemaModal').open(this.targetCollection);
_onAfterSaveAndAdd : function(){
this.targetCollection.add(this.model, {merge : true});
require('../Add/NotificationSchemaModal').open(this.targetCollection);
},
_back: function () {
if (this.model.isNew()) {
_back : function(){
if(this.model.isNew()) {
this.model.destroy();
}
require('Settings/Notifications/Add/NotificationSchemaModal').open(this.targetCollection);
require('../Add/NotificationSchemaModal').open(this.targetCollection);
},
_onDownloadChanged: function () {
_onDownloadChanged : function(){
var checked = this.ui.onDownloadToggle.prop('checked');
if (checked) {
if(checked) {
this.ui.onUpgradeSection.show();
}
else {
this.ui.onUpgradeSection.hide();
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
return view;
});
}).call(this);
@@ -1,13 +1,7 @@
'use strict';
var Backbone = require('backbone');
var NotificationModel = require('./NotificationModel');
define([
'backbone',
'Settings/Notifications/NotificationModel'
], function (Backbone, NotificationModel) {
return Backbone.Collection.extend({
model: NotificationModel,
url : window.NzbDrone.ApiRoot + '/notification'
});
});
module.exports = Backbone.Collection.extend({
model : NotificationModel,
url : window.NzbDrone.ApiRoot + '/notification'
});
@@ -1,29 +1,17 @@
'use strict';
var Marionette = require('marionette');
var ItemView = require('./NotificationItemView');
var SchemaModal = require('./Add/NotificationSchemaModal');
define([
'marionette',
'Settings/Notifications/NotificationItemView',
'Settings/Notifications/Add/NotificationSchemaModal'
], function (Marionette, ItemView, SchemaModal) {
return Marionette.CompositeView.extend({
itemView : ItemView,
itemViewContainer: '.notification-list',
template : 'Settings/Notifications/NotificationCollectionViewTemplate',
ui: {
'addCard': '.x-add-card'
},
events: {
'click .x-add-card': '_openSchemaModal'
},
appendHtml: function (collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_openSchemaModal: function () {
SchemaModal.open(this.collection);
}
});
});
module.exports = Marionette.CompositeView.extend({
itemView : ItemView,
itemViewContainer : '.notification-list',
template : 'Settings/Notifications/NotificationCollectionViewTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_openSchemaModal'},
appendHtml : function(collectionView, itemView, index){
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_openSchemaModal : function(){
SchemaModal.open(this.collection);
}
});
@@ -1,26 +1,19 @@
'use strict';
var AppLayout = require('../../AppLayout');
var Marionette = require('marionette');
var EditView = require('./Edit/NotificationEditView');
define([
'AppLayout',
'marionette',
'Settings/Notifications/Edit/NotificationEditView'
], function (AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/NotificationItemViewTemplate',
tagName : 'li',
events: {
'click' : '_edit'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_edit: function () {
var view = new EditView({ model: this.model, targetCollection: this.model.collection});
AppLayout.modalRegion.show(view);
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/NotificationItemViewTemplate',
tagName : 'li',
events : {"click" : '_edit'},
initialize : function(){
this.listenTo(this.model, 'sync', this.render);
},
_edit : function(){
var view = new EditView({
model : this.model,
targetCollection : this.model.collection
});
AppLayout.modalRegion.show(view);
}
});
@@ -1,9 +1,3 @@
'use strict';
var ProviderSettingsModelBase = require('../ProviderSettingsModelBase');
define([
'Settings/ProviderSettingsModelBase'
], function (ProviderSettingsModelBase) {
return ProviderSettingsModelBase.extend({
});
});
module.exports = ProviderSettingsModelBase.extend({});
+16 -20
View File
@@ -1,24 +1,20 @@
'use strict';
define(
[
'handlebars',
'underscore'
], function (Handlebars, _) {
Handlebars.registerHelper('allowedLabeler', function () {
var ret = '';
var cutoff = this.cutoff;
var Handlebars = require('handlebars');
var _ = require('underscore');
_.each(this.items, function (item) {
if (item.allowed) {
if (item.quality.id === cutoff.id) {
ret += '<li><span class="label label-info" title="Cutoff">' + item.quality.name + '</span></li>';
}
else {
ret += '<li><span class="label label-default">' + item.quality.name + '</span></li>';
}
module.exports = (function(){
Handlebars.registerHelper('allowedLabeler', function(){
var ret = '';
var cutoff = this.cutoff;
_.each(this.items, function(item){
if(item.allowed) {
if(item.quality.id === cutoff.id) {
ret += '<li><span class="label label-info" title="Cutoff">' + item.quality.name + '</span></li>';
}
});
return new Handlebars.SafeString(ret);
else {
ret += '<li><span class="label label-default">' + item.quality.name + '</span></li>';
}
}
});
return new Handlebars.SafeString(ret);
});
}).call(this);
@@ -1,12 +1,7 @@
'use strict';
define(
[
'backbone',
'Settings/Profile/Delay/DelayProfileModel'
], function (Backbone, DelayProfileModel) {
var Backbone = require('backbone');
var DelayProfileModel = require('./DelayProfileModel');
return Backbone.Collection.extend({
model: DelayProfileModel,
url : window.NzbDrone.ApiRoot + '/delayprofile'
});
});
module.exports = Backbone.Collection.extend({
model : DelayProfileModel,
url : window.NzbDrone.ApiRoot + '/delayprofile'
});
@@ -1,17 +1,12 @@
'use strict';
define([
'backbone.collectionview',
'Settings/Profile/Delay/DelayProfileItemView'
], function (BackboneSortableCollectionView, DelayProfileItemView) {
var BackboneSortableCollectionView = require('backbone.collectionview');
var DelayProfileItemView = require('./DelayProfileItemView');
return BackboneSortableCollectionView.extend({
className : 'delay-profiles',
modelView : DelayProfileItemView,
events: {
'click li, td' : '_listItem_onMousedown',
'dblclick li, td' : '_listItem_onDoubleClick',
'keydown' : '_onKeydown'
}
});
});
module.exports = BackboneSortableCollectionView.extend({
className : 'delay-profiles',
modelView : DelayProfileItemView,
events : {
"click li, td" : '_listItem_onMousedown',
"dblclick li, td" : '_listItem_onDoubleClick',
"keydown" : '_onKeydown'
}
});
@@ -1,27 +1,20 @@
'use strict';
var $ = require('jquery');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var EditView = require('./Edit/DelayProfileEditView');
define([
'jquery',
'AppLayout',
'marionette',
'Settings/Profile/Delay/Edit/DelayProfileEditView'
], function ($, AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template : 'Settings/Profile/Delay/DelayProfileItemViewTemplate',
className : 'row',
events: {
'click .x-edit' : '_edit'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_edit: function() {
var view = new EditView({ model: this.model, targetCollection: this.model.collection});
AppLayout.modalRegion.show(view);
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/Delay/DelayProfileItemViewTemplate',
className : 'row',
events : {"click .x-edit" : '_edit'},
initialize : function(){
this.listenTo(this.model, 'sync', this.render);
},
_edit : function(){
var view = new EditView({
model : this.model,
targetCollection : this.model.collection
});
AppLayout.modalRegion.show(view);
}
});
@@ -1,111 +1,75 @@
'use strict';
define(
[
'jquery',
'underscore',
'vent',
'AppLayout',
'marionette',
'backbone',
'Settings/Profile/Delay/DelayProfileCollectionView',
'Settings/Profile/Delay/Edit/DelayProfileEditView',
'Settings/Profile/Delay/DelayProfileModel'
], function ($,
_,
vent,
AppLayout,
Marionette,
Backbone,
DelayProfileCollectionView,
EditView,
Model) {
var $ = require('jquery');
var _ = require('underscore');
var vent = require('../../../vent');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var Backbone = require('backbone');
var DelayProfileCollectionView = require('./DelayProfileCollectionView');
var EditView = require('./Edit/DelayProfileEditView');
var Model = require('./DelayProfileModel');
return Marionette.Layout.extend({
template: 'Settings/Profile/Delay/DelayProfileLayoutTemplate',
regions: {
delayProfiles : '.x-rows'
},
events: {
'click .x-add' : '_add'
},
initialize: function (options) {
this.collection = options.collection;
this._updateOrderedCollection();
this.listenTo(this.collection, 'sync', this._updateOrderedCollection);
this.listenTo(this.collection, 'add', this._updateOrderedCollection);
this.listenTo(this.collection, 'remove', function () {
this.collection.fetch();
});
},
onRender: function () {
this.sortableListView = new DelayProfileCollectionView({
sortable : true,
collection : this.orderedCollection,
sortableOptions : {
handle: '.x-drag-handle'
},
sortableModelsFilter : function( model ) {
return model.get('id') !== 1;
}
});
this.delayProfiles.show(this.sortableListView);
this.listenTo(this.sortableListView, 'sortStop', this._updateOrder);
},
_updateOrder: function() {
var self = this;
this.collection.forEach(function (model) {
if (model.get('id') === 1) {
return;
}
var orderedModel = self.orderedCollection.get(model);
var order = self.orderedCollection.indexOf(orderedModel) + 1;
if (model.get('order') !== order) {
model.set('order', order);
model.save();
}
});
},
_add: function() {
var model = new Model({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'usenet',
usenetDelay : 0,
torrentDelay : 0,
order : this.collection.length,
tags : []
});
model.collection = this.collection;
var view = new EditView({ model: model, targetCollection: this.collection});
AppLayout.modalRegion.show(view);
},
_updateOrderedCollection: function () {
if (!this.orderedCollection) {
this.orderedCollection = new Backbone.Collection();
}
this.orderedCollection.reset(_.sortBy(this.collection.models, function (model) {
return model.get('order');
}));
module.exports = Marionette.Layout.extend({
template : 'Settings/Profile/Delay/DelayProfileLayoutTemplate',
regions : {delayProfiles : '.x-rows'},
events : {"click .x-add" : '_add'},
initialize : function(options){
this.collection = options.collection;
this._updateOrderedCollection();
this.listenTo(this.collection, 'sync', this._updateOrderedCollection);
this.listenTo(this.collection, 'add', this._updateOrderedCollection);
this.listenTo(this.collection, 'remove', function(){
this.collection.fetch();
});
},
onRender : function(){
this.sortableListView = new DelayProfileCollectionView({
sortable : true,
collection : this.orderedCollection,
sortableOptions : {handle : '.x-drag-handle'},
sortableModelsFilter : function(model){
return model.get('id') !== 1;
}
});
});
this.delayProfiles.show(this.sortableListView);
this.listenTo(this.sortableListView, 'sortStop', this._updateOrder);
},
_updateOrder : function(){
var self = this;
this.collection.forEach(function(model){
if(model.get('id') === 1) {
return;
}
var orderedModel = self.orderedCollection.get(model);
var order = self.orderedCollection.indexOf(orderedModel) + 1;
if(model.get('order') !== order) {
model.set('order', order);
model.save();
}
});
},
_add : function(){
var model = new Model({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'usenet',
usenetDelay : 0,
torrentDelay : 0,
order : this.collection.length,
tags : []
});
model.collection = this.collection;
var view = new EditView({
model : model,
targetCollection : this.collection
});
AppLayout.modalRegion.show(view);
},
_updateOrderedCollection : function(){
if(!this.orderedCollection) {
this.orderedCollection = new Backbone.Collection();
}
this.orderedCollection.reset(_.sortBy(this.collection.models, function(model){
return model.get('order');
}));
}
});
@@ -1,8 +1,3 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});
var Backbone = require('backbone');
module.exports = Backbone.Model.extend({});
@@ -1,25 +1,16 @@
'use strict';
var vent = require('../../../../vent');
var Marionette = require('marionette');
define([
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Profile/Delay/Delete/DelayProfileDeleteViewTemplate',
events: {
'click .x-confirm-delete': '_delete'
},
_delete: function () {
var collection = this.model.collection;
this.model.destroy({
wait : true,
success: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
});
module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/Delay/Delete/DelayProfileDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
_delete : function(){
var collection = this.model.collection;
this.model.destroy({
wait : true,
success : function(){
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
@@ -1,127 +1,100 @@
'use strict';
define([
'vent',
'AppLayout',
'marionette',
'Settings/Profile/Delay/Delete/DelayProfileDeleteView',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AsEditModalView',
'Mixins/TagInput',
'bootstrap'
], function (vent, AppLayout, Marionette, DeleteView, AsModelBoundView, AsValidatedView, AsEditModalView) {
var vent = require('../../../../vent');
var AppLayout = require('../../../../AppLayout');
var Marionette = require('marionette');
var DeleteView = require('../Delete/DelayProfileDeleteView');
var AsModelBoundView = require('../../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../../Mixins/AsValidatedView');
var AsEditModalView = require('../../../../Mixins/AsEditModalView');
require('../../../../Mixins/TagInput');
require('bootstrap');
module.exports = (function(){
var view = Marionette.ItemView.extend({
template: 'Settings/Profile/Delay/Edit/DelayProfileEditViewTemplate',
_deleteView: DeleteView,
ui: {
template : 'Settings/Profile/Delay/Edit/DelayProfileEditViewTemplate',
_deleteView : DeleteView,
ui : {
tags : '.x-tags',
usenetDelay : '.x-usenet-delay',
torrentDelay : '.x-torrent-delay',
protocol : '.x-protocol'
},
events: {
'change .x-protocol' : '_updateModel'
},
initialize: function (options) {
events : {"change .x-protocol" : '_updateModel'},
initialize : function(options){
this.targetCollection = options.targetCollection;
},
onRender: function () {
if (this.model.id !== 1) {
onRender : function(){
if(this.model.id !== 1) {
this.ui.tags.tagInput({
model : this.model,
property : 'tags'
});
}
this._toggleControls();
},
_onAfterSave: function () {
this.targetCollection.add(this.model, { merge: true });
_onAfterSave : function(){
this.targetCollection.add(this.model, {merge : true});
vent.trigger(vent.Commands.CloseModalCommand);
},
_updateModel: function () {
_updateModel : function(){
var protocol = this.ui.protocol.val();
if (protocol === 'preferUsenet') {
if(protocol === 'preferUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'usenet'
});
}
if (protocol === 'preferTorrent') {
if(protocol === 'preferTorrent') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
if (protocol === 'onlyUsenet') {
if(protocol === 'onlyUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : false,
enableUsenet : true,
enableTorrent : false,
preferredProtocol : 'usenet'
});
}
if (protocol === 'onlyTorrent') {
if(protocol === 'onlyTorrent') {
this.model.set({
enableUsenet : false,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
this._toggleControls();
},
_toggleControls: function () {
_toggleControls : function(){
var enableUsenet = this.model.get('enableUsenet');
var enableTorrent = this.model.get('enableTorrent');
var preferred = this.model.get('preferredProtocol');
if (preferred === 'usenet') {
if(preferred === 'usenet') {
this.ui.protocol.val('preferUsenet');
}
else {
this.ui.protocol.val('preferTorrent');
}
if (enableUsenet) {
if(enableUsenet) {
this.ui.usenetDelay.show();
}
else {
this.ui.protocol.val('onlyTorrent');
this.ui.usenetDelay.hide();
}
if (enableTorrent) {
if(enableTorrent) {
this.ui.torrentDelay.show();
}
else {
this.ui.protocol.val('onlyUsenet');
this.ui.torrentDelay.hide();
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
return view;
});
}).call(this);
+10 -22
View File
@@ -1,24 +1,12 @@
'use strict';
define(
[
'vent',
'marionette'
], function (vent, Marionette) {
var vent = require('../../vent');
var Marionette = require('marionette');
return Marionette.ItemView.extend({
template: 'Settings/Profile/DeleteProfileViewTemplate',
events: {
'click .x-confirm-delete': '_removeProfile'
},
_removeProfile: function () {
this.model.destroy({
wait: true
}).done(function () {
vent.trigger(vent.Commands.CloseModalCommand);
});
}
module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/DeleteProfileViewTemplate',
events : {"click .x-confirm-delete" : '_removeProfile'},
_removeProfile : function(){
this.model.destroy({wait : true}).done(function(){
vent.trigger(vent.Commands.CloseModalCommand);
});
});
}
});
@@ -1,9 +1,3 @@
'use strict';
define(
[
'marionette'
], function (Marionette) {
return Marionette.ItemView.extend({
template : 'Settings/Profile/Edit/EditProfileItemViewTemplate'
});
});
var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({template : 'Settings/Profile/Edit/EditProfileItemViewTemplate'});
+92 -127
View File
@@ -1,130 +1,95 @@
'use strict';
define(
[
'underscore',
'vent',
'AppLayout',
'marionette',
'backbone',
'Settings/Profile/Edit/EditProfileItemView',
'Settings/Profile/Edit/QualitySortableCollectionView',
'Settings/Profile/Edit/EditProfileView',
'Settings/Profile/DeleteProfileView',
'Series/SeriesCollection',
'Config',
'Mixins/AsEditModalView'
], function (_,
vent,
AppLayout,
Marionette,
Backbone,
EditProfileItemView,
QualitySortableCollectionView,
EditProfileView,
DeleteView,
SeriesCollection,
Config,
AsEditModalView) {
var _ = require('underscore');
var vent = require('../../../vent');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var Backbone = require('backbone');
var EditProfileItemView = require('./EditProfileItemView');
var QualitySortableCollectionView = require('./QualitySortableCollectionView');
var EditProfileView = require('./EditProfileView');
var DeleteView = require('../DeleteProfileView');
var SeriesCollection = require('../../../Series/SeriesCollection');
var Config = require('../../../Config');
var AsEditModalView = require('../../../Mixins/AsEditModalView');
var view = Marionette.Layout.extend({
template: 'Settings/Profile/Edit/EditProfileLayoutTemplate',
regions: {
fields : '#x-fields',
qualities: '#x-qualities'
},
ui: {
deleteButton: '.x-delete'
},
_deleteView: DeleteView,
initialize: function (options) {
this.profileCollection = options.profileCollection;
this.itemsCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse());
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus);
},
onRender: function () {
this._updateDisableStatus();
},
onShow: function () {
this.fieldsView = new EditProfileView({ model: this.model });
this._showFieldsView();
var advancedShown = Config.getValueBoolean(Config.Keys.AdvancedSettings, false);
this.sortableListView = new QualitySortableCollectionView({
selectable : true,
selectMultiple : true,
clickToSelect : true,
clickToToggle : true,
sortable : advancedShown,
sortableOptions : {
handle: '.x-drag-handle'
},
visibleModelsFilter : function (model) {
return model.get('quality').id !== 0 || advancedShown;
},
collection: this.itemsCollection,
model : this.model
});
this.sortableListView.setSelectedModels(this.itemsCollection.filter(function(item) { return item.get('allowed') === true; }));
this.qualities.show(this.sortableListView);
this.listenTo(this.sortableListView, 'selectionChanged', this._selectionChanged);
this.listenTo(this.sortableListView, 'sortStop', this._updateModel);
},
_onBeforeSave: function () {
var cutoff = this.fieldsView.getCutoff();
this.model.set('cutoff', cutoff);
},
_onAfterSave: function () {
this.profileCollection.add(this.model, { merge: true });
vent.trigger(vent.Commands.CloseModalCommand);
},
_selectionChanged: function(newSelectedModels, oldSelectedModels) {
var addedModels = _.difference(newSelectedModels, oldSelectedModels);
var removeModels = _.difference(oldSelectedModels, newSelectedModels);
_.each(removeModels, function(item) { item.set('allowed', false); });
_.each(addedModels, function(item) { item.set('allowed', true); });
this._updateModel();
},
_updateModel: function() {
this.model.set('items', this.itemsCollection.toJSON().reverse());
this._showFieldsView();
},
_showFieldsView: function () {
this.fields.show(this.fieldsView);
},
_updateDisableStatus: function () {
if (this._isQualityInUse()) {
this.ui.deleteButton.addClass('disabled');
this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a series.');
}
else {
this.ui.deleteButton.removeClass('disabled');
}
},
_isQualityInUse: function () {
return SeriesCollection.where({'profileId': this.model.id}).length !== 0;
module.exports = (function(){
var view = Marionette.Layout.extend({
template : 'Settings/Profile/Edit/EditProfileLayoutTemplate',
regions : {
fields : '#x-fields',
qualities : '#x-qualities'
},
ui : {deleteButton : '.x-delete'},
_deleteView : DeleteView,
initialize : function(options){
this.profileCollection = options.profileCollection;
this.itemsCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse());
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus);
},
onRender : function(){
this._updateDisableStatus();
},
onShow : function(){
this.fieldsView = new EditProfileView({model : this.model});
this._showFieldsView();
var advancedShown = Config.getValueBoolean(Config.Keys.AdvancedSettings, false);
this.sortableListView = new QualitySortableCollectionView({
selectable : true,
selectMultiple : true,
clickToSelect : true,
clickToToggle : true,
sortable : advancedShown,
sortableOptions : {handle : '.x-drag-handle'},
visibleModelsFilter : function(model){
return model.get('quality').id !== 0 || advancedShown;
},
collection : this.itemsCollection,
model : this.model
});
this.sortableListView.setSelectedModels(this.itemsCollection.filter(function(item){
return item.get('allowed') === true;
}));
this.qualities.show(this.sortableListView);
this.listenTo(this.sortableListView, 'selectionChanged', this._selectionChanged);
this.listenTo(this.sortableListView, 'sortStop', this._updateModel);
},
_onBeforeSave : function(){
var cutoff = this.fieldsView.getCutoff();
this.model.set('cutoff', cutoff);
},
_onAfterSave : function(){
this.profileCollection.add(this.model, {merge : true});
vent.trigger(vent.Commands.CloseModalCommand);
},
_selectionChanged : function(newSelectedModels, oldSelectedModels){
var addedModels = _.difference(newSelectedModels, oldSelectedModels);
var removeModels = _.difference(oldSelectedModels, newSelectedModels);
_.each(removeModels, function(item){
item.set('allowed', false);
});
_.each(addedModels, function(item){
item.set('allowed', true);
});
this._updateModel();
},
_updateModel : function(){
this.model.set('items', this.itemsCollection.toJSON().reverse());
this._showFieldsView();
},
_showFieldsView : function(){
this.fields.show(this.fieldsView);
},
_updateDisableStatus : function(){
if(this._isQualityInUse()) {
this.ui.deleteButton.addClass('disabled');
this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a series.');
}
});
return AsEditModalView.call(view);
else {
this.ui.deleteButton.removeClass('disabled');
}
},
_isQualityInUse : function(){
return SeriesCollection.where({"profileId" : this.model.id}).length !== 0;
}
});
return AsEditModalView.call(view);
}).call(this);
+20 -32
View File
@@ -1,34 +1,22 @@
'use strict';
define(
[
'underscore',
'marionette',
'Settings/Profile/Language/LanguageCollection',
'Config',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (_, Marionette, LanguageCollection, Config, AsModelBoundView, AsValidatedView) {
var _ = require('underscore');
var Marionette = require('marionette');
var LanguageCollection = require('../Language/LanguageCollection');
var Config = require('../../../Config');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var view = Marionette.ItemView.extend({
template: 'Settings/Profile/Edit/EditProfileViewTemplate',
ui: {
cutoff : '.x-cutoff'
},
templateHelpers: function () {
return {
languages : LanguageCollection.toJSON()
};
},
getCutoff: function () {
var self = this;
return _.findWhere(_.pluck(this.model.get('items'), 'quality'), { id: parseInt(self.ui.cutoff.val(), 10)});
}
});
AsValidatedView.call(view);
return AsModelBoundView.call(view);
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/Profile/Edit/EditProfileViewTemplate',
ui : {cutoff : '.x-cutoff'},
templateHelpers : function(){
return {languages : LanguageCollection.toJSON()};
},
getCutoff : function(){
var self = this;
return _.findWhere(_.pluck(this.model.get('items'), 'quality'), {id : parseInt(self.ui.cutoff.val(), 10)});
}
});
AsValidatedView.call(view);
return AsModelBoundView.call(view);
}).call(this);
@@ -1,22 +1,13 @@
'use strict';
define(
[
'backbone.collectionview',
'Settings/Profile/Edit/EditProfileItemView'
], function (BackboneSortableCollectionView, EditProfileItemView) {
return BackboneSortableCollectionView.extend({
var BackboneSortableCollectionView = require('backbone.collectionview');
var EditProfileItemView = require('./EditProfileItemView');
className: 'qualities',
modelView: EditProfileItemView,
attributes: {
'validation-name': 'items'
},
events: {
'click li, td' : '_listItem_onMousedown',
'dblclick li, td' : '_listItem_onDoubleClick',
'keydown' : '_onKeydown'
}
});
});
module.exports = BackboneSortableCollectionView.extend({
className : 'qualities',
modelView : EditProfileItemView,
attributes : {"validation-name" : 'items'},
events : {
"click li, td" : '_listItem_onMousedown',
"dblclick li, td" : '_listItem_onDoubleClick',
"keydown" : '_onKeydown'
}
});
@@ -1,18 +1,12 @@
'use strict';
define(
[
'backbone',
'Settings/Profile/Language/LanguageModel'
], function (Backbone, LanguageModel) {
var Backbone = require('backbone');
var LanguageModel = require('./LanguageModel');
var LanuageCollection = Backbone.Collection.extend({
model: LanguageModel,
url : window.NzbDrone.ApiRoot + '/language'
});
var languages = new LanuageCollection();
languages.fetch();
return languages;
module.exports = (function(){
var LanuageCollection = Backbone.Collection.extend({
model : LanguageModel,
url : window.NzbDrone.ApiRoot + '/language'
});
var languages = new LanuageCollection();
languages.fetch();
return languages;
}).call(this);
@@ -1,10 +1,3 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});
var Backbone = require('backbone');
module.exports = Backbone.Model.extend({});
+11 -17
View File
@@ -1,20 +1,14 @@
'use strict';
define(
[
'underscore',
'handlebars',
'Settings/Profile/Language/LanguageCollection'
], function (_, Handlebars, LanguageCollection) {
Handlebars.registerHelper('languageLabel', function () {
var _ = require('underscore');
var Handlebars = require('handlebars');
var LanguageCollection = require('./Language/LanguageCollection');
var wantedLanguage = this.language;
var language = LanguageCollection.find(function (lang) {
return lang.get('nameLower') === wantedLanguage;
});
var result = '<span class="label label-primary">' + language.get('name') + '</span>';
return new Handlebars.SafeString(result);
module.exports = (function(){
Handlebars.registerHelper('languageLabel', function(){
var wantedLanguage = this.language;
var language = LanguageCollection.find(function(lang){
return lang.get('nameLower') === wantedLanguage;
});
var result = '<span class="label label-primary">' + language.get('name') + '</span>';
return new Handlebars.SafeString(result);
});
}).call(this);
@@ -1,44 +1,34 @@
'use strict';
var AppLayout = require('../../AppLayout');
var Marionette = require('marionette');
var ProfileView = require('./ProfileView');
var EditProfileView = require('./Edit/EditProfileLayout');
var ProfileCollection = require('./ProfileSchemaCollection');
var _ = require('underscore');
define(['AppLayout',
'marionette',
'Settings/Profile/ProfileView',
'Settings/Profile/Edit/EditProfileLayout',
'Settings/Profile/ProfileSchemaCollection',
'underscore'
], function (AppLayout, Marionette, ProfileView, EditProfileView, ProfileCollection, _) {
return Marionette.CompositeView.extend({
itemView : ProfileView,
itemViewContainer: '.profiles',
template : 'Settings/Profile/ProfileCollectionTemplate',
ui: {
'addCard': '.x-add-card'
},
events: {
'click .x-add-card': '_addProfile'
},
appendHtml: function(collectionView, itemView, index){
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_addProfile: function () {
var self = this;
var schemaCollection = new ProfileCollection();
schemaCollection.fetch({
success: function (collection) {
var model = _.first(collection.models);
model.set('id', undefined);
model.set('name', '');
model.collection = self.collection;
var view = new EditProfileView({ model: model, profileCollection: self.collection});
AppLayout.modalRegion.show(view);
}
});
}
});
});
module.exports = Marionette.CompositeView.extend({
itemView : ProfileView,
itemViewContainer : '.profiles',
template : 'Settings/Profile/ProfileCollectionTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_addProfile'},
appendHtml : function(collectionView, itemView, index){
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_addProfile : function(){
var self = this;
var schemaCollection = new ProfileCollection();
schemaCollection.fetch({
success : function(collection){
var model = _.first(collection.models);
model.set('id', undefined);
model.set('name', '');
model.collection = self.collection;
var view = new EditProfileView({
model : model,
profileCollection : self.collection
});
AppLayout.modalRegion.show(view);
}
});
}
});
+23 -33
View File
@@ -1,34 +1,24 @@
'use strict';
define(
[
'marionette',
'Profile/ProfileCollection',
'Settings/Profile/ProfileCollectionView',
'Settings/Profile/Delay/DelayProfileLayout',
'Settings/Profile/Delay/DelayProfileCollection',
'Settings/Profile/Language/LanguageCollection'
], function (Marionette, ProfileCollection, ProfileCollectionView, DelayProfileLayout, DelayProfileCollection, LanguageCollection) {
return Marionette.Layout.extend({
template: 'Settings/Profile/ProfileLayoutTemplate',
regions: {
profile : '#profile',
delayProfile : '#delay-profile'
},
initialize: function (options) {
this.settings = options.settings;
ProfileCollection.fetch();
this.delayProfileCollection = new DelayProfileCollection();
this.delayProfileCollection.fetch();
},
onShow: function () {
this.profile.show(new ProfileCollectionView({collection: ProfileCollection}));
this.delayProfile.show(new DelayProfileLayout({collection: this.delayProfileCollection}));
}
});
});
var Marionette = require('marionette');
var ProfileCollection = require('../../Profile/ProfileCollection');
var ProfileCollectionView = require('./ProfileCollectionView');
var DelayProfileLayout = require('./Delay/DelayProfileLayout');
var DelayProfileCollection = require('./Delay/DelayProfileCollection');
var LanguageCollection = require('./Language/LanguageCollection');
module.exports = Marionette.Layout.extend({
template : 'Settings/Profile/ProfileLayoutTemplate',
regions : {
profile : '#profile',
delayProfile : '#delay-profile'
},
initialize : function(options){
this.settings = options.settings;
ProfileCollection.fetch();
this.delayProfileCollection = new DelayProfileCollection();
this.delayProfileCollection.fetch();
},
onShow : function(){
this.profile.show(new ProfileCollectionView({collection : ProfileCollection}));
this.delayProfile.show(new DelayProfileLayout({collection : this.delayProfileCollection}));
}
});
@@ -1,13 +1,7 @@
'use strict';
var Backbone = require('backbone');
var ProfileModel = require('../../Profile/ProfileModel');
define(
[
'backbone',
'Profile/ProfileModel'
], function (Backbone, ProfileModel) {
return Backbone.Collection.extend({
model: ProfileModel,
url : window.NzbDrone.ApiRoot + '/profile/schema'
});
});
module.exports = Backbone.Collection.extend({
model : ProfileModel,
url : window.NzbDrone.ApiRoot + '/profile/schema'
});
+28 -36
View File
@@ -1,38 +1,30 @@
'use strict';
var AppLayout = require('../../AppLayout');
var Marionette = require('marionette');
var EditProfileView = require('./Edit/EditProfileLayout');
var AsModelBoundView = require('../../Mixins/AsModelBoundView');
require('./AllowedLabeler');
require('./LanguageLabel');
require('bootstrap');
define(
[
'AppLayout',
'marionette',
'Settings/Profile/Edit/EditProfileLayout',
'Mixins/AsModelBoundView',
'Settings/Profile/AllowedLabeler',
'Settings/Profile/LanguageLabel',
'bootstrap'
], function (AppLayout, Marionette, EditProfileView, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Profile/ProfileViewTemplate',
tagName : 'li',
ui: {
'progressbar' : '.progress .bar',
'deleteButton': '.x-delete'
},
events: {
'click' : '_editProfile'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_editProfile: function () {
var view = new EditProfileView({ model: this.model, profileCollection: this.model.collection });
AppLayout.modalRegion.show(view);
}
});
return AsModelBoundView.call(view);
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/Profile/ProfileViewTemplate',
tagName : 'li',
ui : {
"progressbar" : '.progress .bar',
"deleteButton" : '.x-delete'
},
events : {"click" : '_editProfile'},
initialize : function(){
this.listenTo(this.model, 'sync', this.render);
},
_editProfile : function(){
var view = new EditProfileView({
model : this.model,
profileCollection : this.model.collection
});
AppLayout.modalRegion.show(view);
}
});
return AsModelBoundView.call(view);
}).call(this);
+25 -37
View File
@@ -1,38 +1,26 @@
'use strict';
var $ = require('jquery');
var DeepModel = require('backbone.deepmodel');
var Messenger = require('../Shared/Messenger');
define([
'jquery',
'backbone.deepmodel',
'Shared/Messenger'
], function ($, DeepModel, Messenger) {
return DeepModel.DeepModel.extend({
test: function () {
var self = this;
this.trigger('validation:sync');
var params = {};
params.url = this.collection.url + '/test';
params.contentType = 'application/json';
params.data = JSON.stringify(this.toJSON());
params.type = 'POST';
params.isValidatedCall = true;
var promise = $.ajax(params);
Messenger.monitor({
promise : promise,
successMessage : 'Testing \'{0}\' completed'.format(this.get('name')),
errorMessage : 'Testing \'{0}\' failed'.format(this.get('name'))
});
promise.fail(function (response) {
self.trigger('validation:failed', response);
});
return promise;
}
});
});
module.exports = DeepModel.DeepModel.extend({
test : function(){
var self = this;
this.trigger('validation:sync');
var params = {};
params.url = this.collection.url + '/test';
params.contentType = 'application/json';
params.data = JSON.stringify(this.toJSON());
params.type = 'POST';
params.isValidatedCall = true;
var promise = $.ajax(params);
Messenger.monitor({
promise : promise,
successMessage : 'Testing \'{0}\' completed'.format(this.get('name')),
errorMessage : 'Testing \'{0}\' failed'.format(this.get('name'))
});
promise.fail(function(response){
self.trigger('validation:failed', response);
});
return promise;
}
});
@@ -1,16 +1,8 @@
'use strict';
var Marionette = require('marionette');
var QualityDefinitionItemView = require('./QualityDefinitionItemView');
define(
[
'marionette',
'Settings/Quality/Definition/QualityDefinitionItemView'
], function (Marionette, QualityDefinitionItemView) {
return Marionette.CompositeView.extend({
template: 'Settings/Quality/Definition/QualityDefinitionCollectionTemplate',
itemViewContainer: '.x-rows',
itemView: QualityDefinitionItemView
});
});
module.exports = Marionette.CompositeView.extend({
template : 'Settings/Quality/Definition/QualityDefinitionCollectionTemplate',
itemViewContainer : '.x-rows',
itemView : QualityDefinitionItemView
});
@@ -1,92 +1,64 @@
'use strict';
var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var fileSize = require('filesize');
require('jquery-ui');
define(
[
'marionette',
'Mixins/AsModelBoundView',
'filesize',
'jquery-ui'
], function (Marionette, AsModelBoundView, fileSize) {
var view = Marionette.ItemView.extend({
template: 'Settings/Quality/Definition/QualityDefinitionItemViewTemplate',
className: 'row',
ui: {
sizeSlider : '.x-slider',
thirtyMinuteMinSize: '.x-min-thirty',
sixtyMinuteMinSize : '.x-min-sixty',
thirtyMinuteMaxSize: '.x-max-thirty',
sixtyMinuteMaxSize : '.x-max-sixty'
},
events: {
'slide .x-slider': '_updateSize'
},
initialize: function (options) {
this.profileCollection = options.profiles;
this.filesize = fileSize;
},
onRender: function () {
if (this.model.get('quality').id === 0) {
this.$el.addClass('row advanced-setting');
}
this.ui.sizeSlider.slider({
range : true,
min : 0,
max : 200,
values : [ this.model.get('minSize'), this.model.get('maxSize') ]
});
this._changeSize();
},
_updateSize: function (event, ui) {
this.model.set('minSize', ui.values[0]);
this.model.set('maxSize', ui.values[1]);
this._changeSize();
},
_changeSize: function () {
var minSize = this.model.get('minSize');
var maxSize = this.model.get('maxSize');
{
var minBytes = minSize * 1024 * 1024;
var minThirty = fileSize(minBytes * 30, 1, false);
var minSixty = fileSize(minBytes * 60, 1, false);
this.ui.thirtyMinuteMinSize.html(minThirty);
this.ui.sixtyMinuteMinSize.html(minSixty);
}
{
if (maxSize === 0)
{
this.ui.thirtyMinuteMaxSize.html('Unlimited');
this.ui.sixtyMinuteMaxSize.html('Unlimited');
return;
}
var maxBytes = maxSize * 1024 * 1024;
var maxThirty = fileSize(maxBytes * 30, 1, false);
var maxSixty = fileSize(maxBytes * 60, 1, false);
this.ui.thirtyMinuteMaxSize.html(maxThirty);
this.ui.sixtyMinuteMaxSize.html(maxSixty);
}
/*if (parseInt(maxSize, 10) === 0) {
thirty = 'No Limit';
sixty = 'No Limit';
}*/
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/Quality/Definition/QualityDefinitionItemViewTemplate',
className : 'row',
ui : {
sizeSlider : '.x-slider',
thirtyMinuteMinSize : '.x-min-thirty',
sixtyMinuteMinSize : '.x-min-sixty',
thirtyMinuteMaxSize : '.x-max-thirty',
sixtyMinuteMaxSize : '.x-max-sixty'
},
events : {"slide .x-slider" : '_updateSize'},
initialize : function(options){
this.profileCollection = options.profiles;
this.filesize = fileSize;
},
onRender : function(){
if(this.model.get('quality').id === 0) {
this.$el.addClass('row advanced-setting');
}
});
return AsModelBoundView.call(view);
this.ui.sizeSlider.slider({
range : true,
min : 0,
max : 200,
values : [this.model.get('minSize'), this.model.get('maxSize')]
});
this._changeSize();
},
_updateSize : function(event, ui){
this.model.set('minSize', ui.values[0]);
this.model.set('maxSize', ui.values[1]);
this._changeSize();
},
_changeSize : function(){
var minSize = this.model.get('minSize');
var maxSize = this.model.get('maxSize');
{
var minBytes = minSize * 1024 * 1024;
var minThirty = fileSize(minBytes * 30, 1, false);
var minSixty = fileSize(minBytes * 60, 1, false);
this.ui.thirtyMinuteMinSize.html(minThirty);
this.ui.sixtyMinuteMinSize.html(minSixty);
}
{
if(maxSize === 0) {
this.ui.thirtyMinuteMaxSize.html('Unlimited');
this.ui.sixtyMinuteMaxSize.html('Unlimited');
return;
}
var maxBytes = maxSize * 1024 * 1024;
var maxThirty = fileSize(maxBytes * 30, 1, false);
var maxSixty = fileSize(maxBytes * 60, 1, false);
this.ui.thirtyMinuteMaxSize.html(maxThirty);
this.ui.sixtyMinuteMaxSize.html(maxSixty);
}
}
});
return AsModelBoundView.call(view);
}).call(this);
+15 -26
View File
@@ -1,27 +1,16 @@
'use strict';
define(
[
'marionette',
'Quality/QualityDefinitionCollection',
'Settings/Quality/Definition/QualityDefinitionCollectionView'
], function (Marionette, QualityDefinitionCollection, QualityDefinitionCollectionView) {
return Marionette.Layout.extend({
template: 'Settings/Quality/QualityLayoutTemplate',
regions: {
qualityDefinition : '#quality-definition'
},
initialize: function (options) {
this.settings = options.settings;
this.qualityDefinitionCollection = new QualityDefinitionCollection();
this.qualityDefinitionCollection.fetch();
},
onShow: function () {
this.qualityDefinition.show(new QualityDefinitionCollectionView({collection: this.qualityDefinitionCollection}));
}
});
});
var Marionette = require('marionette');
var QualityDefinitionCollection = require('../../Quality/QualityDefinitionCollection');
var QualityDefinitionCollectionView = require('./Definition/QualityDefinitionCollectionView');
module.exports = Marionette.Layout.extend({
template : 'Settings/Quality/QualityLayoutTemplate',
regions : {qualityDefinition : '#quality-definition'},
initialize : function(options){
this.settings = options.settings;
this.qualityDefinitionCollection = new QualityDefinitionCollection();
this.qualityDefinitionCollection.fetch();
},
onShow : function(){
this.qualityDefinition.show(new QualityDefinitionCollectionView({collection : this.qualityDefinitionCollection}));
}
});
+219 -284
View File
@@ -1,287 +1,222 @@
'use strict';
define(
[
'jquery',
'underscore',
'vent',
'marionette',
'backbone',
'Settings/General/GeneralSettingsModel',
'Settings/MediaManagement/Naming/NamingModel',
'Settings/MediaManagement/MediaManagementLayout',
'Settings/MediaManagement/MediaManagementSettingsModel',
'Settings/Profile/ProfileLayout',
'Settings/Quality/QualityLayout',
'Settings/Indexers/IndexerLayout',
'Settings/Indexers/IndexerCollection',
'Settings/Indexers/IndexerSettingsModel',
'Settings/DownloadClient/DownloadClientLayout',
'Settings/DownloadClient/DownloadClientSettingsModel',
'Settings/Notifications/NotificationCollectionView',
'Settings/Notifications/NotificationCollection',
'Settings/Metadata/MetadataLayout',
'Settings/General/GeneralView',
'Settings/UI/UiView',
'Settings/UI/UiSettingsModel',
'Shared/LoadingView',
'Config'
], function ($,
_,
vent,
Marionette,
Backbone,
GeneralSettingsModel,
NamingModel,
MediaManagementLayout,
MediaManagementSettingsModel,
ProfileLayout,
QualityLayout,
IndexerLayout,
IndexerCollection,
IndexerSettingsModel,
DownloadClientLayout,
DownloadClientSettingsModel,
NotificationCollectionView,
NotificationCollection,
MetadataLayout,
GeneralView,
UiView,
UiSettingsModel,
LoadingView,
Config) {
return Marionette.Layout.extend({
template: 'Settings/SettingsLayoutTemplate',
var $ = require('jquery');
var _ = require('underscore');
var vent = require('../vent');
var Marionette = require('marionette');
var Backbone = require('backbone');
var GeneralSettingsModel = require('./General/GeneralSettingsModel');
var NamingModel = require('./MediaManagement/Naming/NamingModel');
var MediaManagementLayout = require('./MediaManagement/MediaManagementLayout');
var MediaManagementSettingsModel = require('./MediaManagement/MediaManagementSettingsModel');
var ProfileLayout = require('./Profile/ProfileLayout');
var QualityLayout = require('./Quality/QualityLayout');
var IndexerLayout = require('./Indexers/IndexerLayout');
var IndexerCollection = require('./Indexers/IndexerCollection');
var IndexerSettingsModel = require('./Indexers/IndexerSettingsModel');
var DownloadClientLayout = require('./DownloadClient/DownloadClientLayout');
var DownloadClientSettingsModel = require('./DownloadClient/DownloadClientSettingsModel');
var NotificationCollectionView = require('./Notifications/NotificationCollectionView');
var NotificationCollection = require('./Notifications/NotificationCollection');
var MetadataLayout = require('./Metadata/MetadataLayout');
var GeneralView = require('./General/GeneralView');
var UiView = require('./UI/UiView');
var UiSettingsModel = require('./UI/UiSettingsModel');
var LoadingView = require('../Shared/LoadingView');
var Config = require('../Config');
regions: {
mediaManagement : '#media-management',
profiles : '#profiles',
quality : '#quality',
indexers : '#indexers',
downloadClient : '#download-client',
notifications : '#notifications',
metadata : '#metadata',
general : '#general',
uiRegion : '#ui',
loading : '#loading-region'
},
ui: {
mediaManagementTab : '.x-media-management-tab',
profilesTab : '.x-profiles-tab',
qualityTab : '.x-quality-tab',
indexersTab : '.x-indexers-tab',
downloadClientTab : '.x-download-client-tab',
notificationsTab : '.x-notifications-tab',
metadataTab : '.x-metadata-tab',
generalTab : '.x-general-tab',
uiTab : '.x-ui-tab',
advancedSettings : '.x-advanced-settings'
},
events: {
'click .x-media-management-tab' : '_showMediaManagement',
'click .x-profiles-tab' : '_showProfiles',
'click .x-quality-tab' : '_showQuality',
'click .x-indexers-tab' : '_showIndexers',
'click .x-download-client-tab' : '_showDownloadClient',
'click .x-notifications-tab' : '_showNotifications',
'click .x-metadata-tab' : '_showMetadata',
'click .x-general-tab' : '_showGeneral',
'click .x-ui-tab' : '_showUi',
'click .x-save-settings' : '_save',
'change .x-advanced-settings' : '_toggleAdvancedSettings'
},
initialize: function (options) {
if (options.action) {
this.action = options.action.toLowerCase();
}
this.listenTo(vent, vent.Hotkeys.SaveSettings, this._save);
},
onRender: function () {
this.loading.show(new LoadingView());
var self = this;
this.mediaManagementSettings = new MediaManagementSettingsModel();
this.namingSettings = new NamingModel();
this.indexerSettings = new IndexerSettingsModel();
this.downloadClientSettings = new DownloadClientSettingsModel();
this.notificationCollection = new NotificationCollection();
this.generalSettings = new GeneralSettingsModel();
this.uiSettings = new UiSettingsModel();
Backbone.$.when(
this.mediaManagementSettings.fetch(),
this.namingSettings.fetch(),
this.indexerSettings.fetch(),
this.downloadClientSettings.fetch(),
this.notificationCollection.fetch(),
this.generalSettings.fetch(),
this.uiSettings.fetch()
).done(function () {
if(!self.isClosed)
{
self.loading.$el.hide();
self.mediaManagement.show(new MediaManagementLayout({ settings: self.mediaManagementSettings, namingSettings: self.namingSettings }));
self.profiles.show(new ProfileLayout());
self.quality.show(new QualityLayout());
self.indexers.show(new IndexerLayout({ model: self.indexerSettings }));
self.downloadClient.show(new DownloadClientLayout({ model: self.downloadClientSettings }));
self.notifications.show(new NotificationCollectionView({ collection: self.notificationCollection }));
self.metadata.show(new MetadataLayout());
self.general.show(new GeneralView({ model: self.generalSettings }));
self.uiRegion.show(new UiView({ model: self.uiSettings }));
}
});
this._setAdvancedSettingsState();
},
onShow: function () {
switch (this.action) {
case 'profiles':
this._showProfiles();
break;
case 'quality':
this._showQuality();
break;
case 'indexers':
this._showIndexers();
break;
case 'downloadclient':
this._showDownloadClient();
break;
case 'connect':
this._showNotifications();
break;
case 'notifications':
this._showNotifications();
break;
case 'metadata':
this._showMetadata();
break;
case 'general':
this._showGeneral();
break;
case 'ui':
this._showUi();
break;
default:
this._showMediaManagement();
}
},
_showMediaManagement: function (e) {
if (e) {
e.preventDefault();
}
this.ui.mediaManagementTab.tab('show');
this._navigate('settings/mediamanagement');
},
_showProfiles: function (e) {
if (e) {
e.preventDefault();
}
this.ui.profilesTab.tab('show');
this._navigate('settings/profiles');
},
_showQuality: function (e) {
if (e) {
e.preventDefault();
}
this.ui.qualityTab.tab('show');
this._navigate('settings/quality');
},
_showIndexers: function (e) {
if (e) {
e.preventDefault();
}
this.ui.indexersTab.tab('show');
this._navigate('settings/indexers');
},
_showDownloadClient: function (e) {
if (e) {
e.preventDefault();
}
this.ui.downloadClientTab.tab('show');
this._navigate('settings/downloadclient');
},
_showNotifications: function (e) {
if (e) {
e.preventDefault();
}
this.ui.notificationsTab.tab('show');
this._navigate('settings/connect');
},
_showMetadata: function (e) {
if (e) {
e.preventDefault();
}
this.ui.metadataTab.tab('show');
this._navigate('settings/metadata');
},
_showGeneral: function (e) {
if (e) {
e.preventDefault();
}
this.ui.generalTab.tab('show');
this._navigate('settings/general');
},
_showUi: function (e) {
if (e) {
e.preventDefault();
}
this.ui.uiTab.tab('show');
this._navigate('settings/ui');
},
_navigate: function (route) {
Backbone.history.navigate(route, { trigger: false, replace: true });
},
_save: function () {
vent.trigger(vent.Commands.SaveSettings);
},
_setAdvancedSettingsState: function () {
var checked = Config.getValueBoolean(Config.Keys.AdvancedSettings);
this.ui.advancedSettings.prop('checked', checked);
if (checked) {
$('body').addClass('show-advanced-settings');
}
},
_toggleAdvancedSettings: function () {
var checked = this.ui.advancedSettings.prop('checked');
Config.setValue(Config.Keys.AdvancedSettings, checked);
if (checked) {
$('body').addClass('show-advanced-settings');
}
else {
$('body').removeClass('show-advanced-settings');
}
module.exports = Marionette.Layout.extend({
template : 'Settings/SettingsLayoutTemplate',
regions : {
mediaManagement : '#media-management',
profiles : '#profiles',
quality : '#quality',
indexers : '#indexers',
downloadClient : '#download-client',
notifications : '#notifications',
metadata : '#metadata',
general : '#general',
uiRegion : '#ui',
loading : '#loading-region'
},
ui : {
mediaManagementTab : '.x-media-management-tab',
profilesTab : '.x-profiles-tab',
qualityTab : '.x-quality-tab',
indexersTab : '.x-indexers-tab',
downloadClientTab : '.x-download-client-tab',
notificationsTab : '.x-notifications-tab',
metadataTab : '.x-metadata-tab',
generalTab : '.x-general-tab',
uiTab : '.x-ui-tab',
advancedSettings : '.x-advanced-settings'
},
events : {
"click .x-media-management-tab" : '_showMediaManagement',
"click .x-profiles-tab" : '_showProfiles',
"click .x-quality-tab" : '_showQuality',
"click .x-indexers-tab" : '_showIndexers',
"click .x-download-client-tab" : '_showDownloadClient',
"click .x-notifications-tab" : '_showNotifications',
"click .x-metadata-tab" : '_showMetadata',
"click .x-general-tab" : '_showGeneral',
"click .x-ui-tab" : '_showUi',
"click .x-save-settings" : '_save',
"change .x-advanced-settings" : '_toggleAdvancedSettings'
},
initialize : function(options){
if(options.action) {
this.action = options.action.toLowerCase();
}
this.listenTo(vent, vent.Hotkeys.SaveSettings, this._save);
},
onRender : function(){
this.loading.show(new LoadingView());
var self = this;
this.mediaManagementSettings = new MediaManagementSettingsModel();
this.namingSettings = new NamingModel();
this.indexerSettings = new IndexerSettingsModel();
this.downloadClientSettings = new DownloadClientSettingsModel();
this.notificationCollection = new NotificationCollection();
this.generalSettings = new GeneralSettingsModel();
this.uiSettings = new UiSettingsModel();
Backbone.$.when(this.mediaManagementSettings.fetch(), this.namingSettings.fetch(), this.indexerSettings.fetch(), this.downloadClientSettings.fetch(), this.notificationCollection.fetch(), this.generalSettings.fetch(), this.uiSettings.fetch()).done(function(){
if(!self.isClosed) {
self.loading.$el.hide();
self.mediaManagement.show(new MediaManagementLayout({
settings : self.mediaManagementSettings,
namingSettings : self.namingSettings
}));
self.profiles.show(new ProfileLayout());
self.quality.show(new QualityLayout());
self.indexers.show(new IndexerLayout({model : self.indexerSettings}));
self.downloadClient.show(new DownloadClientLayout({model : self.downloadClientSettings}));
self.notifications.show(new NotificationCollectionView({collection : self.notificationCollection}));
self.metadata.show(new MetadataLayout());
self.general.show(new GeneralView({model : self.generalSettings}));
self.uiRegion.show(new UiView({model : self.uiSettings}));
}
});
});
this._setAdvancedSettingsState();
},
onShow : function(){
switch (this.action) {
case 'profiles':
this._showProfiles();
break;
case 'quality':
this._showQuality();
break;
case 'indexers':
this._showIndexers();
break;
case 'downloadclient':
this._showDownloadClient();
break;
case 'connect':
this._showNotifications();
break;
case 'notifications':
this._showNotifications();
break;
case 'metadata':
this._showMetadata();
break;
case 'general':
this._showGeneral();
break;
case 'ui':
this._showUi();
break;
default:
this._showMediaManagement();
}
},
_showMediaManagement : function(e){
if(e) {
e.preventDefault();
}
this.ui.mediaManagementTab.tab('show');
this._navigate('settings/mediamanagement');
},
_showProfiles : function(e){
if(e) {
e.preventDefault();
}
this.ui.profilesTab.tab('show');
this._navigate('settings/profiles');
},
_showQuality : function(e){
if(e) {
e.preventDefault();
}
this.ui.qualityTab.tab('show');
this._navigate('settings/quality');
},
_showIndexers : function(e){
if(e) {
e.preventDefault();
}
this.ui.indexersTab.tab('show');
this._navigate('settings/indexers');
},
_showDownloadClient : function(e){
if(e) {
e.preventDefault();
}
this.ui.downloadClientTab.tab('show');
this._navigate('settings/downloadclient');
},
_showNotifications : function(e){
if(e) {
e.preventDefault();
}
this.ui.notificationsTab.tab('show');
this._navigate('settings/connect');
},
_showMetadata : function(e){
if(e) {
e.preventDefault();
}
this.ui.metadataTab.tab('show');
this._navigate('settings/metadata');
},
_showGeneral : function(e){
if(e) {
e.preventDefault();
}
this.ui.generalTab.tab('show');
this._navigate('settings/general');
},
_showUi : function(e){
if(e) {
e.preventDefault();
}
this.ui.uiTab.tab('show');
this._navigate('settings/ui');
},
_navigate : function(route){
Backbone.history.navigate(route, {
trigger : false,
replace : true
});
},
_save : function(){
vent.trigger(vent.Commands.SaveSettings);
},
_setAdvancedSettingsState : function(){
var checked = Config.getValueBoolean(Config.Keys.AdvancedSettings);
this.ui.advancedSettings.prop('checked', checked);
if(checked) {
$('body').addClass('show-advanced-settings');
}
},
_toggleAdvancedSettings : function(){
var checked = this.ui.advancedSettings.prop('checked');
Config.setValue(Config.Keys.AdvancedSettings, checked);
if(checked) {
$('body').addClass('show-advanced-settings');
}
else {
$('body').removeClass('show-advanced-settings');
}
}
});
+26 -37
View File
@@ -1,40 +1,29 @@
'use strict';
define(
[
'vent',
'backbone.deepmodel',
'Mixins/AsChangeTrackingModel',
'Shared/Messenger'
], function (vent, DeepModel, AsChangeTrackingModel, Messenger) {
var model = DeepModel.DeepModel.extend({
var vent = require('../vent');
var DeepModel = require('backbone.deepmodel');
var AsChangeTrackingModel = require('../Mixins/AsChangeTrackingModel');
var Messenger = require('../Shared/Messenger');
initialize: function () {
this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings);
this.listenTo(this, 'destroy', this._stopListening);
},
saveSettings: function () {
if (!this.isSaved) {
var savePromise = this.save();
Messenger.monitor({
promise : savePromise,
successMessage: this.successMessage,
errorMessage : this.errorMessage
});
return savePromise;
}
return undefined;
},
_stopListening: function () {
this.stopListening(vent, vent.Commands.SaveSettings);
module.exports = (function(){
var model = DeepModel.DeepModel.extend({
initialize : function(){
this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings);
this.listenTo(this, 'destroy', this._stopListening);
},
saveSettings : function(){
if(!this.isSaved) {
var savePromise = this.save();
Messenger.monitor({
promise : savePromise,
successMessage : this.successMessage,
errorMessage : this.errorMessage
});
return savePromise;
}
});
return AsChangeTrackingModel.call(model);
return undefined;
},
_stopListening : function(){
this.stopListening(vent, vent.Commands.SaveSettings);
}
});
return AsChangeTrackingModel.call(model);
}).call(this);
+9 -17
View File
@@ -1,18 +1,10 @@
'use strict';
var Marionette = require('marionette');
define([
'marionette'
], function (Marionette) {
return Marionette.CompositeView.extend({
itemViewOptions : function () {
return {
targetCollection: this.targetCollection || this.options.targetCollection
};
},
initialize: function (options) {
this.targetCollection = options.targetCollection;
}
});
});
module.exports = Marionette.CompositeView.extend({
itemViewOptions : function(){
return {targetCollection : this.targetCollection || this.options.targetCollection};
},
initialize : function(options){
this.targetCollection = options.targetCollection;
}
});
+13 -22
View File
@@ -1,23 +1,14 @@
'use strict';
var Backbone = require('backbone');
var Marionette = require('marionette');
define([
'backbone',
'marionette'
], function (Backbone, Marionette) {
return Marionette.CompositeView.extend({
itemViewContainer: '.item-list',
template: 'Settings/ThingyHeaderGroupViewTemplate',
tagName : 'div',
itemViewOptions: function () {
return {
targetCollection: this.targetCollection || this.options.targetCollection
};
},
initialize: function () {
this.collection = new Backbone.Collection(this.model.get('collection'));
}
});
});
module.exports = Marionette.CompositeView.extend({
itemViewContainer : '.item-list',
template : 'Settings/ThingyHeaderGroupViewTemplate',
tagName : 'div',
itemViewOptions : function(){
return {targetCollection : this.targetCollection || this.options.targetCollection};
},
initialize : function(){
this.collection = new Backbone.Collection(this.model.get('collection'));
}
});
+6 -11
View File
@@ -1,12 +1,7 @@
'use strict';
define(
[
'Settings/SettingsModelBase'
], function (SettingsModelBase) {
return SettingsModelBase.extend({
var SettingsModelBase = require('../SettingsModelBase');
url : window.NzbDrone.ApiRoot + '/config/ui',
successMessage: 'UI settings saved',
errorMessage : 'Failed to save UI settings'
});
});
module.exports = SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/ui',
successMessage : 'UI settings saved',
errorMessage : 'Failed to save UI settings'
});
+18 -25
View File
@@ -1,27 +1,20 @@
'use strict';
define(
[
'vent',
'marionette',
'Shared/UiSettingsModel',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (vent, Marionette, UiSettingsModel, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Settings/UI/UiViewTemplate',
var vent = require('../../vent');
var Marionette = require('marionette');
var UiSettingsModel = require('../../Shared/UiSettingsModel');
var AsModelBoundView = require('../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../Mixins/AsValidatedView');
initialize: function () {
this.listenTo(this.model, 'sync', this._reloadUiSettings);
},
_reloadUiSettings: function() {
UiSettingsModel.fetch();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/UI/UiViewTemplate',
initialize : function(){
this.listenTo(this.model, 'sync', this._reloadUiSettings);
},
_reloadUiSettings : function(){
UiSettingsModel.fetch();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
}).call(this);