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

View File

@@ -1,41 +1,29 @@
define(
[
'moment',
'backgrid',
'Shared/UiSettingsModel',
'Shared/FormatHelpers'
], function (moment, Backgrid, UiSettings) {
return Backgrid.Cell.extend({
var moment = require('moment');
var Backgrid = require('backgrid');
var UiSettings = require('../Shared/UiSettingsModel');
require('../Shared/FormatHelpers');
className: 'age-cell',
render: function () {
var age = this.model.get('age');
var ageHours = this.model.get('ageHours');
var published = moment(this.model.get('publishDate'));
var publishedFormatted = published.format('{0} {1}'.format(UiSettings.get('shortDateFormat'), UiSettings.time(true, true)));
var formatted = age;
var suffix = this.plural(age, 'day');
if (age === 0) {
formatted = ageHours.toFixed(1);
suffix = this.plural(Math.round(ageHours), 'hour');
}
this.$el.html('<div title="{2}">{0} {1}</div>'.format(formatted, suffix, publishedFormatted));
this.delegateEvents();
return this;
},
plural: function (input, unit) {
if (input === 1) {
return unit;
}
return unit + 's';
}
});
});
'use strict';
module.exports = Backgrid.Cell.extend({
className : 'age-cell',
render : function(){
var age = this.model.get('age');
var ageHours = this.model.get('ageHours');
var published = moment(this.model.get('publishDate'));
var publishedFormatted = published.format('{0} {1}'.format(UiSettings.get('shortDateFormat'), UiSettings.time(true, true)));
var formatted = age;
var suffix = this.plural(age, 'day');
if(age === 0) {
formatted = ageHours.toFixed(1);
suffix = this.plural(Math.round(ageHours), 'hour');
}
this.$el.html('<div title="{2}">{0} {1}</div>'.format(formatted, suffix, publishedFormatted));
this.delegateEvents();
return this;
},
plural : function(input, unit){
if(input === 1) {
return unit;
}
return unit + 's';
}
});

View File

@@ -1,52 +1,31 @@
'use strict';
var Backgrid = require('backgrid');
define(
[
'backgrid'
], function (Backgrid) {
return Backgrid.Cell.extend({
className: 'download-report-cell',
events: {
'click': '_onClick'
},
_onClick: function () {
if (!this.model.get('downloadAllowed'))
{
return;
}
var self = this;
this.$el.html('<i class="icon-spinner icon-spin" />');
//Using success callback instead of promise so it
//gets called before the sync event is triggered
this.model.save(null, { success: function () {
self.model.set('queued', true);
}});
},
render: function () {
this.$el.empty();
if (this.model.get('queued')) {
this.$el.html('<i class="icon-nd-downloading" title="Added to downloaded queue" />');
}
else if (this.model.get('downloadAllowed'))
{
this.$el.html('<i class="icon-download-alt" title="Add to download queue" />');
}
else {
this.className = 'no-download-report-cell';
}
return this;
module.exports = Backgrid.Cell.extend({
className : 'download-report-cell',
events : {click : '_onClick'},
_onClick : function(){
if(!this.model.get('downloadAllowed')) {
return;
}
var self = this;
this.$el.html('<i class="icon-spinner icon-spin" />');
this.model.save(null, {
success : function(){
self.model.set('queued', true);
}
});
});
},
render : function(){
this.$el.empty();
if(this.model.get('queued')) {
this.$el.html('<i class="icon-nd-downloading" title="Added to downloaded queue" />');
}
else if(this.model.get('downloadAllowed')) {
this.$el.html('<i class="icon-download-alt" title="Add to download queue" />');
}
else {
this.className = 'no-download-report-cell';
}
return this;
}
});

View File

@@ -1,34 +1,24 @@
'use strict';
var Backgrid = require('backgrid');
define(['backgrid'], function (Backgrid) {
return Backgrid.Cell.extend({
className : 'peers-cell',
render : function () {
if (this.model.get('protocol') === 'torrent') {
var seeders = this.model.get('seeders') || 0;
var leechers = this.model.get('leechers') || 0;
var level = 'danger';
if(seeders > 0){
level='warning';
}
if(seeders > 10){
level = 'info';
}
if(seeders > 50){
level = 'primary';
}
this.$el.html('<div class="label label-{2}" title="{0} seeders, {1} leechers">{0} / {1}</div>'.format(seeders, leechers, level));
module.exports = Backgrid.Cell.extend({
className : 'peers-cell',
render : function(){
if(this.model.get('protocol') === 'torrent') {
var seeders = this.model.get('seeders') || 0;
var leechers = this.model.get('leechers') || 0;
var level = 'danger';
if(seeders > 0) {
level = 'warning';
}
this.delegateEvents();
return this;
if(seeders > 10) {
level = 'info';
}
if(seeders > 50) {
level = 'primary';
}
this.$el.html('<div class="label label-{2}" title="{0} seeders, {1} leechers">{0} / {1}</div>'.format(seeders, leechers, level));
}
});
this.delegateEvents();
return this;
}
});

View File

@@ -1,28 +1,20 @@
'use strict';
var Backgrid = require('backgrid');
define(['backgrid'], function (Backgrid) {
return Backgrid.Cell.extend({
className : 'protocol-cell',
render : function () {
var protocol = this.model.get('protocol') || 'Unknown';
var label = '??';
if (protocol) {
if (protocol === 'torrent') {
label = 'torrent';
}
else if (protocol === 'usenet') {
label = 'nzb';
}
this.$el.html('<div class="label label-default protocol-{0}" title="{0}">{1}</div>'.format(protocol, label));
module.exports = Backgrid.Cell.extend({
className : 'protocol-cell',
render : function(){
var protocol = this.model.get('protocol') || 'Unknown';
var label = '??';
if(protocol) {
if(protocol === 'torrent') {
label = 'torrent';
}
this.delegateEvents();
return this;
else if(protocol === 'usenet') {
label = 'nzb';
}
this.$el.html('<div class="label label-default protocol-{0}" title="{0}">{1}</div>'.format(protocol, label));
}
});
this.delegateEvents();
return this;
}
});

View File

@@ -1,52 +1,43 @@
'use strict';
define(
[
'backbone.pageable',
'Release/ReleaseModel',
'Mixins/AsSortedCollection'
], function (PagableCollection, ReleaseModel, AsSortedCollection) {
var Collection = PagableCollection.extend({
url : window.NzbDrone.ApiRoot + '/release',
model: ReleaseModel,
var PagableCollection = require('backbone.pageable');
var ReleaseModel = require('./ReleaseModel');
var AsSortedCollection = require('../Mixins/AsSortedCollection');
state: {
pageSize : 2000,
sortKey : 'download',
order : -1
module.exports = (function(){
var Collection = PagableCollection.extend({
url : window.NzbDrone.ApiRoot + '/release',
model : ReleaseModel,
state : {
pageSize : 2000,
sortKey : 'download',
order : -1
},
mode : 'client',
sortMappings : {
quality : {sortKey : 'qualityWeight'},
rejections : {
sortValue : function(model){
var rejections = model.get('rejections');
var releaseWeight = model.get('releaseWeight');
if(rejections.length !== 0) {
return releaseWeight + 1000000;
}
return releaseWeight;
}
},
mode: 'client',
sortMappings: {
'quality' : { sortKey: 'qualityWeight' },
'rejections' : { sortValue: function (model) {
var rejections = model.get('rejections');
var releaseWeight = model.get('releaseWeight');
if (rejections.length !== 0) {
return releaseWeight + 1000000;
}
return releaseWeight;
}
},
'download' : { sortKey: 'releaseWeight' },
'seeders' : { sortValue: function(model) {
var seeders = model.get('seeders') || 0;
var leechers = model.get('leechers') || 0;
return seeders * 1000000 + leechers;
}
},
'age' : { sortKey: 'ageMinutes' }
download : {sortKey : 'releaseWeight'},
seeders : {
sortValue : function(model){
var seeders = model.get('seeders') || 0;
var leechers = model.get('leechers') || 0;
return seeders * 1000000 + leechers;
}
},
fetchEpisodeReleases: function (episodeId) {
return this.fetch({ data: { episodeId: episodeId }});
}
});
Collection = AsSortedCollection.call(Collection);
return Collection;
age : {sortKey : 'ageMinutes'}
},
fetchEpisodeReleases : function(episodeId){
return this.fetch({data : {episodeId : episodeId}});
}
});
Collection = AsSortedCollection.call(Collection);
return Collection;
}).call(this);

View File

@@ -1,82 +1,65 @@
'use strict';
define(
[
'marionette',
'backgrid',
'Release/ReleaseCollection',
'Cells/IndexerCell',
'Cells/EpisodeNumberCell',
'Cells/FileSizeCell',
'Cells/QualityCell',
'Cells/ApprovalStatusCell',
'Shared/LoadingView'
], function (Marionette, Backgrid, ReleaseCollection, IndexerCell, EpisodeNumberCell, FileSizeCell, QualityCell, ApprovalStatusCell, LoadingView) {
return Marionette.Layout.extend({
template: 'Release/ReleaseLayoutTemplate',
var Marionette = require('marionette');
var Backgrid = require('backgrid');
var ReleaseCollection = require('./ReleaseCollection');
var IndexerCell = require('../Cells/IndexerCell');
var EpisodeNumberCell = require('../Cells/EpisodeNumberCell');
var FileSizeCell = require('../Cells/FileSizeCell');
var QualityCell = require('../Cells/QualityCell');
var ApprovalStatusCell = require('../Cells/ApprovalStatusCell');
var LoadingView = require('../Shared/LoadingView');
regions: {
grid : '#x-grid',
toolbar: '#x-toolbar'
},
columns:
[
{
name : 'indexer',
label : 'Indexer',
sortable: true,
cell : IndexerCell
},
{
name : 'title',
label : 'Title',
sortable: true,
cell : Backgrid.StringCell
},
{
name : 'episodeNumbers',
episodes: 'episodeNumbers',
label : 'season',
cell : EpisodeNumberCell
},
{
name : 'size',
label : 'Size',
sortable: true,
cell : FileSizeCell
},
{
name : 'quality',
label : 'Quality',
sortable: true,
cell : QualityCell
},
{
name : 'rejections',
label: '',
cell : ApprovalStatusCell
}
],
initialize: function () {
this.collection = new ReleaseCollection();
this.listenTo(this.collection, 'sync', this._showTable);
},
onRender: function () {
this.grid.show(new LoadingView());
this.collection.fetch();
},
_showTable: function () {
if (!this.isClosed) {
this.grid.show(new Backgrid.Grid({
row : Backgrid.Row,
columns : this.columns,
collection: this.collection,
className : 'table table-hover'
}));
}
}
});
});
module.exports = Marionette.Layout.extend({
template : 'Release/ReleaseLayoutTemplate',
regions : {
grid : '#x-grid',
toolbar : '#x-toolbar'
},
columns : [{
name : 'indexer',
label : 'Indexer',
sortable : true,
cell : IndexerCell
}, {
name : 'title',
label : 'Title',
sortable : true,
cell : Backgrid.StringCell
}, {
name : 'episodeNumbers',
episodes : 'episodeNumbers',
label : 'season',
cell : EpisodeNumberCell
}, {
name : 'size',
label : 'Size',
sortable : true,
cell : FileSizeCell
}, {
name : 'quality',
label : 'Quality',
sortable : true,
cell : QualityCell
}, {
name : 'rejections',
label : '',
cell : ApprovalStatusCell
}],
initialize : function(){
this.collection = new ReleaseCollection();
this.listenTo(this.collection, 'sync', this._showTable);
},
onRender : function(){
this.grid.show(new LoadingView());
this.collection.fetch();
},
_showTable : function(){
if(!this.isClosed) {
this.grid.show(new Backgrid.Grid({
row : Backgrid.Row,
columns : this.columns,
collection : this.collection,
className : 'table table-hover'
}));
}
}
});

View File

@@ -1,8 +1,3 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});
var Backbone = require('backbone');
module.exports = Backbone.Model.extend({});