mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
removed NzbDrone. namespace, everything is done using require.
This commit is contained in:
parent
ef62af75df
commit
b0bd3f34f1
121 changed files with 2570 additions and 2587 deletions
|
@ -1,37 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
define(['app'], function () {
|
||||
NzbDrone.Shared.FormatHelpers.FileSizeHelper = function (sourceSize) {
|
||||
var size = Number(sourceSize);
|
||||
return size.bytes(1);
|
||||
};
|
||||
define(
|
||||
[
|
||||
'sugar'
|
||||
], {
|
||||
FileSizeHelper: function (sourceSize) {
|
||||
var size = Number(sourceSize);
|
||||
return size.bytes(1);
|
||||
},
|
||||
|
||||
NzbDrone.Shared.FormatHelpers.DateHelper = function (sourceDate) {
|
||||
if (!sourceDate) {
|
||||
return '';
|
||||
}
|
||||
DateHelper: function (sourceDate) {
|
||||
if (!sourceDate) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var date = Date.create(sourceDate);
|
||||
var date = Date.create(sourceDate);
|
||||
|
||||
if (date.isYesterday()) {
|
||||
return 'Yesterday';
|
||||
}
|
||||
if (date.isToday()) {
|
||||
return 'Today';
|
||||
}
|
||||
if (date.isTomorrow()) {
|
||||
return 'Tomorrow';
|
||||
}
|
||||
if (date.isAfter(Date.create('tomorrow')) && date.isBefore(Date.create().addDays(7))) {
|
||||
return date.format('{Weekday}');
|
||||
}
|
||||
if (date.isYesterday()) {
|
||||
return 'Yesterday';
|
||||
}
|
||||
if (date.isToday()) {
|
||||
return 'Today';
|
||||
}
|
||||
if (date.isTomorrow()) {
|
||||
return 'Tomorrow';
|
||||
}
|
||||
if (date.isAfter(Date.create('tomorrow')) && date.isBefore(Date.create().addDays(7))) {
|
||||
return date.format('{Weekday}');
|
||||
}
|
||||
|
||||
if (date.isAfter(Date.create().addDays(6))) {
|
||||
return date.relative().replace(' from now', '');
|
||||
if (date.isAfter(Date.create().addDays(6))) {
|
||||
return date.relative().replace(' from now', '');
|
||||
}
|
||||
|
||||
return date.format('{MM}/{dd}/{yyyy}');
|
||||
}
|
||||
|
||||
return date.format('{MM}/{dd}/{yyyy}');
|
||||
};
|
||||
|
||||
return NzbDrone.Shared.FormatHelpers;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,100 +1,102 @@
|
|||
'use strict';
|
||||
|
||||
define(['app','backgrid'], function () {
|
||||
define(
|
||||
[
|
||||
'backgrid'
|
||||
], function (Backgrid) {
|
||||
|
||||
Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
|
||||
Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
this.$el.append(this.column.get('label'));
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
this.$el.append(this.column.get('label'));
|
||||
if (this.column.get('sortable')) {
|
||||
this.$el.addClass('clickable');
|
||||
this.$el.append(' <i class="pull-right"></i>');
|
||||
|
||||
if (this.column.get('sortable')) {
|
||||
this.$el.addClass('clickable');
|
||||
this.$el.append(' <i class="pull-right"></i>');
|
||||
if (this.collection.state) {
|
||||
var sortKey = this.collection.state.sortKey;
|
||||
var sortDir = this._convertIntToDirection(this.collection.state.order);
|
||||
|
||||
if (this.collection.state) {
|
||||
var sortKey = this.collection.state.sortKey;
|
||||
var sortDir = this._convertIntToDirection(this.collection.state.order);
|
||||
|
||||
if (sortKey === this.column.get('name')) {
|
||||
this.$el.children('i').addClass(this._convertDirectionToIcon(sortDir));
|
||||
this._direction = sortDir;
|
||||
if (sortKey === this.column.get('name')) {
|
||||
this.$el.children('i').addClass(this._convertDirectionToIcon(sortDir));
|
||||
this._direction = sortDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
|
||||
direction: function (dir) {
|
||||
if (arguments.length) {
|
||||
if (this._direction) {
|
||||
this.$el.children('i').removeClass(this._convertDirectionToIcon(this._direction));
|
||||
direction: function (dir) {
|
||||
if (arguments.length) {
|
||||
if (this._direction) {
|
||||
this.$el.children('i').removeClass(this._convertDirectionToIcon(this._direction));
|
||||
}
|
||||
if (dir) {
|
||||
this.$el.children('i').addClass(this._convertDirectionToIcon(dir));
|
||||
}
|
||||
this._direction = dir;
|
||||
}
|
||||
if (dir) {
|
||||
this.$el.children('i').addClass(this._convertDirectionToIcon(dir));
|
||||
|
||||
return this._direction;
|
||||
},
|
||||
|
||||
onClick: function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var columnName = this.column.get('name');
|
||||
|
||||
if (this.column.get('sortable')) {
|
||||
if (this.direction() === 'ascending') {
|
||||
this.sort(columnName, 'descending', function (left, right) {
|
||||
var leftVal = left.get(columnName);
|
||||
var rightVal = right.get(columnName);
|
||||
if (leftVal === rightVal) {
|
||||
return 0;
|
||||
}
|
||||
else if (leftVal > rightVal) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.sort(columnName, 'ascending', function (left, right) {
|
||||
var leftVal = left.get(columnName);
|
||||
var rightVal = right.get(columnName);
|
||||
if (leftVal === rightVal) {
|
||||
return 0;
|
||||
}
|
||||
else if (leftVal < rightVal) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
this._direction = dir;
|
||||
}
|
||||
},
|
||||
|
||||
return this._direction;
|
||||
},
|
||||
|
||||
onClick: function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var columnName = this.column.get('name');
|
||||
|
||||
if (this.column.get('sortable')) {
|
||||
if (this.direction() === 'ascending') {
|
||||
this.sort(columnName, 'descending', function (left, right) {
|
||||
var leftVal = left.get(columnName);
|
||||
var rightVal = right.get(columnName);
|
||||
if (leftVal === rightVal) {
|
||||
return 0;
|
||||
}
|
||||
else if (leftVal > rightVal) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
_convertDirectionToIcon: function (dir) {
|
||||
if (dir === 'ascending') {
|
||||
return 'icon-sort-up';
|
||||
}
|
||||
else {
|
||||
this.sort(columnName, 'ascending', function (left, right) {
|
||||
var leftVal = left.get(columnName);
|
||||
var rightVal = right.get(columnName);
|
||||
if (leftVal === rightVal) {
|
||||
return 0;
|
||||
}
|
||||
else if (leftVal < rightVal) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
|
||||
return 'icon-sort-down';
|
||||
},
|
||||
|
||||
_convertIntToDirection: function (dir) {
|
||||
if (dir === '-1') {
|
||||
return 'ascending';
|
||||
}
|
||||
|
||||
return 'descending';
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
_convertDirectionToIcon: function (dir) {
|
||||
if (dir === 'ascending') {
|
||||
return 'icon-sort-up';
|
||||
}
|
||||
|
||||
return 'icon-sort-down';
|
||||
},
|
||||
|
||||
_convertIntToDirection: function (dir) {
|
||||
if (dir === '-1') {
|
||||
return 'ascending';
|
||||
}
|
||||
|
||||
return 'descending';
|
||||
}
|
||||
return Backgrid.NzbDroneHeaderCell;
|
||||
});
|
||||
|
||||
return Backgrid.NzbDroneHeaderCell;
|
||||
});
|
||||
|
|
|
@ -1,146 +1,145 @@
|
|||
'use strict';
|
||||
define([
|
||||
'app',
|
||||
'backgrid',
|
||||
'backgrid.paginator'
|
||||
], function () {
|
||||
define(
|
||||
[
|
||||
'backgrid.paginator'
|
||||
], function (Paginator) {
|
||||
|
||||
NzbDrone.Shared.Grid.Pager = Backgrid.Extension.Paginator.extend({
|
||||
return Paginator.extend({
|
||||
|
||||
template: 'Shared/Grid/PagerTemplate',
|
||||
template: 'Shared/Grid/PagerTemplate',
|
||||
|
||||
events: {
|
||||
'click .pager-btn': 'changePage'
|
||||
},
|
||||
events: {
|
||||
'click .pager-btn': 'changePage'
|
||||
},
|
||||
|
||||
windowSize: 1,
|
||||
windowSize: 1,
|
||||
|
||||
fastForwardHandleLabels: {
|
||||
first: 'icon-fast-backward',
|
||||
prev : 'icon-backward',
|
||||
next : 'icon-forward',
|
||||
last : 'icon-fast-forward'
|
||||
},
|
||||
fastForwardHandleLabels: {
|
||||
first: 'icon-fast-backward',
|
||||
prev : 'icon-backward',
|
||||
next : 'icon-forward',
|
||||
last : 'icon-fast-forward'
|
||||
},
|
||||
|
||||
changePage: function (e) {
|
||||
e.preventDefault();
|
||||
changePage: function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var target = $(e.target);
|
||||
var target = $(e.target);
|
||||
|
||||
if (target.closest('li').hasClass('disabled')) {
|
||||
return;
|
||||
if (target.closest('li').hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var label = target.attr('data-action');
|
||||
var ffLabels = this.fastForwardHandleLabels;
|
||||
|
||||
var collection = this.collection;
|
||||
|
||||
if (ffLabels) {
|
||||
switch (label) {
|
||||
case 'first':
|
||||
collection.getFirstPage();
|
||||
return;
|
||||
case 'prev':
|
||||
if (collection.hasPrevious()) {
|
||||
collection.getPreviousPage();
|
||||
}
|
||||
return;
|
||||
case 'next':
|
||||
if (collection.hasNext()) {
|
||||
collection.getNextPage();
|
||||
}
|
||||
return;
|
||||
case 'last':
|
||||
collection.getLastPage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var state = collection.state;
|
||||
var pageIndex = $(e.target).text() * 1;
|
||||
collection.getPage(state.firstPage === 0 ? pageIndex - 1 :pageIndex);
|
||||
},
|
||||
|
||||
makeHandles: function () {
|
||||
|
||||
var handles =
|
||||
[
|
||||
];
|
||||
var collection = this.collection;
|
||||
var state = collection.state;
|
||||
|
||||
// convert all indices to 0-based here
|
||||
var firstPage = state.firstPage;
|
||||
var lastPage = +state.lastPage;
|
||||
lastPage = Math.max(0, firstPage ? lastPage - 1 :lastPage);
|
||||
var currentPage = Math.max(state.currentPage, state.firstPage);
|
||||
currentPage = firstPage ? currentPage - 1 :currentPage;
|
||||
var windowStart = Math.floor(currentPage / this.windowSize) * this.windowSize;
|
||||
var windowEnd = Math.min(lastPage + 1, windowStart + this.windowSize);
|
||||
|
||||
if (collection.mode !== 'infinite') {
|
||||
for (var i = windowStart; i < windowEnd; i++) {
|
||||
handles.push({
|
||||
label : i + 1,
|
||||
title : 'No. ' + (i + 1),
|
||||
className : currentPage === i ? 'active' :undefined,
|
||||
pageNumber: i + 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var ffLabels = this.fastForwardHandleLabels;
|
||||
if (ffLabels) {
|
||||
|
||||
if (ffLabels.prev) {
|
||||
handles.unshift({
|
||||
label : ffLabels.prev,
|
||||
className: collection.hasPrevious() ? void 0 :'disabled',
|
||||
action : 'prev'
|
||||
});
|
||||
}
|
||||
|
||||
if (ffLabels.first) {
|
||||
handles.unshift({
|
||||
label : ffLabels.first,
|
||||
className: collection.hasPrevious() ? void 0 :'disabled',
|
||||
action : 'first'
|
||||
});
|
||||
}
|
||||
|
||||
if (ffLabels.next) {
|
||||
handles.push({
|
||||
label : ffLabels.next,
|
||||
className: collection.hasNext() ? void 0 :'disabled',
|
||||
action : 'next'
|
||||
});
|
||||
}
|
||||
|
||||
if (ffLabels.last) {
|
||||
handles.push({
|
||||
label : ffLabels.last,
|
||||
className: collection.hasNext() ? void 0 :'disabled',
|
||||
action : 'last'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return handles;
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
var templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
|
||||
this.$el.html(templateFunction({
|
||||
handles: this.makeHandles()
|
||||
}));
|
||||
|
||||
this.delegateEvents();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
var label = target.attr('data-action');
|
||||
var ffLabels = this.fastForwardHandleLabels;
|
||||
|
||||
var collection = this.collection;
|
||||
|
||||
if (ffLabels) {
|
||||
switch (label) {
|
||||
case 'first':
|
||||
collection.getFirstPage();
|
||||
return;
|
||||
case 'prev':
|
||||
if (collection.hasPrevious()) {
|
||||
collection.getPreviousPage();
|
||||
}
|
||||
return;
|
||||
case 'next':
|
||||
if (collection.hasNext()) {
|
||||
collection.getNextPage();
|
||||
}
|
||||
return;
|
||||
case 'last':
|
||||
collection.getLastPage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var state = collection.state;
|
||||
var pageIndex = $(e.target).text() * 1;
|
||||
collection.getPage(state.firstPage === 0 ? pageIndex - 1 :pageIndex);
|
||||
},
|
||||
|
||||
makeHandles: function () {
|
||||
|
||||
var handles = [];
|
||||
var collection = this.collection;
|
||||
var state = collection.state;
|
||||
|
||||
// convert all indices to 0-based here
|
||||
var firstPage = state.firstPage;
|
||||
var lastPage = +state.lastPage;
|
||||
lastPage = Math.max(0, firstPage ? lastPage - 1 :lastPage);
|
||||
var currentPage = Math.max(state.currentPage, state.firstPage);
|
||||
currentPage = firstPage ? currentPage - 1 :currentPage;
|
||||
var windowStart = Math.floor(currentPage / this.windowSize) * this.windowSize;
|
||||
var windowEnd = Math.min(lastPage + 1, windowStart + this.windowSize);
|
||||
|
||||
if (collection.mode !== 'infinite') {
|
||||
for (var i = windowStart; i < windowEnd; i++) {
|
||||
handles.push({
|
||||
label : i + 1,
|
||||
title : 'No. ' + (i + 1),
|
||||
className : currentPage === i ? 'active' :undefined,
|
||||
pageNumber: i + 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var ffLabels = this.fastForwardHandleLabels;
|
||||
if (ffLabels) {
|
||||
|
||||
if (ffLabels.prev) {
|
||||
handles.unshift({
|
||||
label : ffLabels.prev,
|
||||
className: collection.hasPrevious() ? void 0 :'disabled',
|
||||
action : 'prev'
|
||||
});
|
||||
}
|
||||
|
||||
if (ffLabels.first) {
|
||||
handles.unshift({
|
||||
label : ffLabels.first,
|
||||
className: collection.hasPrevious() ? void 0 :'disabled',
|
||||
action : 'first'
|
||||
});
|
||||
}
|
||||
|
||||
if (ffLabels.next) {
|
||||
handles.push({
|
||||
label : ffLabels.next,
|
||||
className: collection.hasNext() ? void 0 :'disabled',
|
||||
action : 'next'
|
||||
});
|
||||
}
|
||||
|
||||
if (ffLabels.last) {
|
||||
handles.push({
|
||||
label : ffLabels.last,
|
||||
className: collection.hasNext() ? void 0 :'disabled',
|
||||
action : 'last'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return handles;
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
var templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
|
||||
this.$el.html(templateFunction({
|
||||
handles: this.makeHandles()
|
||||
}));
|
||||
|
||||
this.delegateEvents();
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return NzbDrone.Shared.Grid.Pager;
|
||||
});
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
define(['app'], function () {
|
||||
NzbDrone.Shared.LoadingView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Shared/LoadingTemplate',
|
||||
className: 'nz-loading row'
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Shared/LoadingTemplate',
|
||||
className: 'nz-loading row'
|
||||
});
|
||||
});
|
||||
|
||||
return NzbDrone.Shared.LoadingView;
|
||||
});
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
'use strict';
|
||||
define(['app'], function () {
|
||||
NzbDrone.Shared.NotFoundView = Backbone.Marionette.ItemView.extend({
|
||||
template: 'Shared/notfoundtemplate'
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Shared/notfoundtemplate'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
'use strict';
|
||||
define(['app', 'Shared/NotificationModel'], function () {
|
||||
|
||||
var notificationCollection = Backbone.Collection.extend({
|
||||
model: NzbDrone.Shared.NotificationModel
|
||||
});
|
||||
|
||||
return new notificationCollection();
|
||||
});
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
'use strict';
|
||||
define(['app'], function () {
|
||||
|
||||
NzbDrone.Shared.NotificationModel = Backbone.Model.extend({
|
||||
mutators: {
|
||||
|
||||
preFormattedMessage: function () {
|
||||
return this.get('message').replace(/\\r\\n/g, '<br>');
|
||||
},
|
||||
|
||||
isPreFormatted: function () {
|
||||
return this.get('message').indexOf('\\r\\n') !== -1;
|
||||
},
|
||||
|
||||
iconClass: function () {
|
||||
|
||||
if (this.has('icon')) {
|
||||
return 'icon';
|
||||
}
|
||||
|
||||
if (this.get('level') === 'info') {
|
||||
return 'icon-info-sign';
|
||||
} else if (this.get('level') === 'success') {
|
||||
return 'icon-ok-sign';
|
||||
} else if (this.get('level') === 'error') {
|
||||
return 'icon-warning-sign';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
defaults: {
|
||||
'level' : 'info',
|
||||
'title' : '',
|
||||
'message': ''
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,10 +0,0 @@
|
|||
<div class="alert alert-{{level}}">
|
||||
<button type="button" class="close x-close icon-remove-sign"></button>
|
||||
<i class="{{iconClass}}"/><strong>{{title}}</strong>
|
||||
{{#if isPreFormatted}}
|
||||
<pre>{{{preFormattedMessage}}}</pre>
|
||||
{{else}}
|
||||
{{message}}
|
||||
{{/if}}
|
||||
|
||||
</div>
|
|
@ -1,42 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
define(['app', 'Shared/NotificationCollection'], function (app, notificationCollection) {
|
||||
|
||||
var notificationItemView = Backbone.Marionette.ItemView.extend({
|
||||
template: 'Shared/NotificationTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-close': 'kill'
|
||||
},
|
||||
|
||||
kill: function () {
|
||||
|
||||
var self = this;
|
||||
|
||||
$.Deferred(function () {
|
||||
self.$el.slideUp('slow');
|
||||
}).done(function () {
|
||||
self.model.destroy();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var collectionView = Backbone.Marionette.CollectionView.extend({
|
||||
|
||||
itemView: notificationItemView,
|
||||
|
||||
initialize: function () {
|
||||
this.collection = notificationCollection;
|
||||
}
|
||||
});
|
||||
|
||||
NzbDrone.addInitializer(function () {
|
||||
console.log('initializing notification view');
|
||||
NzbDrone.notificationRegion.show(new collectionView());
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
'use strict';
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'app'
|
||||
], function () {
|
||||
NzbDrone.Shared.SpinnerView = Backbone.Marionette.ItemView.extend({
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Shared/SpinnerTemplate',
|
||||
className: 'nz-spinner row'
|
||||
});
|
||||
|
||||
return NzbDrone.Shared.SpinnerView;
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.card {
|
||||
.card() {
|
||||
margin :10px;
|
||||
background-color: #ffffff;
|
||||
padding: 10px;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
.clickable {
|
||||
.clickable() {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'handlebars',
|
||||
'Shared/FormatHelpers'
|
||||
], function (App, Handlebars) {
|
||||
], function (Handlebars, FormatHelpers) {
|
||||
Handlebars.registerHelper('partial', function (templateName) {
|
||||
//TODO: We should be able to pass in the context, either an object or a property
|
||||
|
||||
|
@ -26,7 +25,7 @@ define(
|
|||
});
|
||||
|
||||
Handlebars.registerHelper('fileSize', function (size) {
|
||||
return new Handlebars.SafeString(NzbDrone.Shared.FormatHelpers.FileSizeHelper(size));
|
||||
return new Handlebars.SafeString(FormatHelpers.FileSizeHelper(size));
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('date', function (date) {
|
||||
|
@ -36,7 +35,7 @@ define(
|
|||
}
|
||||
|
||||
var shortDate = Date.create(date).short();
|
||||
var formattedDate = NzbDrone.Shared.FormatHelpers.DateHelper(date);
|
||||
var formattedDate = FormatHelpers.DateHelper(date);
|
||||
var result = '<span title="' + shortDate + '">' + formattedDate + '</span>';
|
||||
|
||||
return new Handlebars.SafeString(result);
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
'use strict';
|
||||
define(['app', 'Shared/Toolbar/Button/ButtonView', 'Config'], function (App, ButtonView, Config) {
|
||||
return Backbone.Marionette.CollectionView.extend({
|
||||
className: 'btn-group',
|
||||
itemView : ButtonView
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Shared/Toolbar/Button/ButtonView'
|
||||
], function (Marionette, ButtonView) {
|
||||
return Marionette.CollectionView.extend({
|
||||
className: 'btn-group',
|
||||
itemView : ButtonView
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,102 +1,113 @@
|
|||
'use strict';
|
||||
define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'],
|
||||
function (App,
|
||||
Config,
|
||||
CommandController,
|
||||
Messenger) {
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'marionette',
|
||||
'Commands/CommandController',
|
||||
'Shared/Messenger'
|
||||
], function (App, Marionette, CommandController, Messenger) {
|
||||
|
||||
return Backbone.Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
|
||||
ui: {
|
||||
icon: '.x-icon'
|
||||
},
|
||||
ui: {
|
||||
icon: '.x-icon'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
this.idle = true;
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
this.invokeCallback();
|
||||
}
|
||||
},
|
||||
initialize: function () {
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
this.idle = true;
|
||||
},
|
||||
|
||||
onClick: function () {
|
||||
if (this.idle) {
|
||||
this.invokeCallback();
|
||||
this.invokeRoute();
|
||||
this.invokeCommand();
|
||||
}
|
||||
},
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
this.invokeCallback();
|
||||
}
|
||||
},
|
||||
|
||||
invokeCommand: function () {
|
||||
var command = this.model.get('command');
|
||||
if (command) {
|
||||
this.idle = false;
|
||||
this.$el.addClass('disabled');
|
||||
this.ui.icon.addClass('icon-spinner icon-spin');
|
||||
onClick: function () {
|
||||
if (this.idle) {
|
||||
this.invokeCallback();
|
||||
this.invokeRoute();
|
||||
this.invokeCommand();
|
||||
}
|
||||
},
|
||||
|
||||
var self = this;
|
||||
var commandPromise = CommandController.Execute(command);
|
||||
commandPromise.done(function () {
|
||||
if (self.model.get('successMessage')) {
|
||||
Messenger.show({
|
||||
message: self.model.get('successMessage')
|
||||
|
||||
invokeCommand: function () {
|
||||
var command = this.model.get('command');
|
||||
if (command) {
|
||||
this.idle = false;
|
||||
this.$el.addClass('disabled');
|
||||
this.ui.icon.addClass('icon-spinner icon-spin');
|
||||
|
||||
var self = this;
|
||||
var commandPromise = CommandController.Execute(command);
|
||||
commandPromise.done(function () {
|
||||
if (self.model.get('successMessage')) {
|
||||
Messenger.show({
|
||||
message: self.model.get('successMessage')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
commandPromise.fail(function (options) {
|
||||
if (options.readyState === 0 || options.status === 0) {
|
||||
return;
|
||||
}
|
||||
if (self.model.get('errorMessage')) {
|
||||
Messenger.show({
|
||||
message: self.model.get('errorMessage'),
|
||||
type : 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
commandPromise.always(function () {
|
||||
if (!self.isClosed) {
|
||||
self.$el.removeClass('disabled');
|
||||
self.ui.icon.removeClass('icon-spinner icon-spin');
|
||||
self.idle = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
invokeRoute: function () {
|
||||
var route = this.model.get('route');
|
||||
if (route) {
|
||||
|
||||
require(
|
||||
[
|
||||
'Router'
|
||||
], function () {
|
||||
App.Router.navigate(route, {trigger: true});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
commandPromise.fail(function (options) {
|
||||
if (options.readyState === 0 || options.status === 0) {
|
||||
return;
|
||||
}
|
||||
if (self.model.get('errorMessage')) {
|
||||
Messenger.show({
|
||||
message: self.model.get('errorMessage'),
|
||||
type : 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
invokeCallback: function () {
|
||||
|
||||
commandPromise.always(function () {
|
||||
if (!self.isClosed) {
|
||||
self.$el.removeClass('disabled');
|
||||
self.ui.icon.removeClass('icon-spinner icon-spin');
|
||||
self.idle = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
}
|
||||
|
||||
invokeRoute: function () {
|
||||
var route = this.model.get('route');
|
||||
if (route) {
|
||||
NzbDrone.Router.navigate(route, {trigger: true});
|
||||
}
|
||||
},
|
||||
|
||||
invokeCallback: function () {
|
||||
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
'use strict';
|
||||
define(['app', 'Shared/Toolbar/ButtonModel'], function () {
|
||||
return Backbone.Collection.extend({
|
||||
model: NzbDrone.Shared.Toolbar.ButtonModel
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Shared/Toolbar/ButtonModel'
|
||||
], function (Backbone, ButtonModel) {
|
||||
return Backbone.Collection.extend({
|
||||
model: ButtonModel
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
'use strict';
|
||||
define(['app'], function () {
|
||||
|
||||
NzbDrone.Shared.Toolbar.ActionTypes =
|
||||
{
|
||||
RouteTrigger: 'RouteTrigger',
|
||||
CallBack : 'CallBack'
|
||||
};
|
||||
|
||||
return Backbone.Model.extend({
|
||||
defaults: {
|
||||
'target' : '/nzbdrone/route',
|
||||
'title' : '',
|
||||
'active' : false,
|
||||
'tooltip': undefined }
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
defaults: {
|
||||
'target' : '/nzbdrone/route',
|
||||
'title' : '',
|
||||
'active' : false,
|
||||
'tooltip': undefined }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'marionette',
|
||||
'Shared/Toolbar/Radio/RadioButtonView',
|
||||
'Config'
|
||||
], function (App, RadioButtonView, Config) {
|
||||
return Backbone.Marionette.CollectionView.extend({
|
||||
], function (Marionette, RadioButtonView, Config) {
|
||||
return Marionette.CollectionView.extend({
|
||||
className: 'btn-group',
|
||||
itemView : NzbDrone.Shared.Toolbar.RadioButtonView,
|
||||
itemView : RadioButtonView,
|
||||
|
||||
attributes: {
|
||||
'data-toggle': 'buttons-radio'
|
||||
|
|
|
@ -1,48 +1,52 @@
|
|||
'use strict';
|
||||
define(['app', 'Config'], function () {
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Config'
|
||||
], function (Marionette, Config) {
|
||||
|
||||
NzbDrone.Shared.Toolbar.RadioButtonView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
|
||||
|
||||
initialize: function () {
|
||||
initialize: function () {
|
||||
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
},
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
this.invokeCallback();
|
||||
}
|
||||
},
|
||||
|
||||
onClick: function () {
|
||||
|
||||
Config.SetValue(this.model.get('menuKey'), this.model.get('key'));
|
||||
this.invokeCallback();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
onClick: function () {
|
||||
invokeCallback: function () {
|
||||
|
||||
NzbDrone.Config.SetValue(this.model.get('menuKey'), this.model.get('key'));
|
||||
this.invokeCallback();
|
||||
},
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
}
|
||||
|
||||
invokeCallback: function () {
|
||||
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'Shared/Toolbar/Radio/RadioButtonCollectionView',
|
||||
'Shared/Toolbar/Button/ButtonCollectionView',
|
||||
'marionette',
|
||||
'Shared/Toolbar/ButtonCollection',
|
||||
'Shared/Toolbar/ButtonModel'
|
||||
],
|
||||
function (App,
|
||||
RadioButtonCollectionView,
|
||||
ButtonCollectionView,
|
||||
ButtonCollection,
|
||||
ButtonModel) {
|
||||
NzbDrone.Shared.Toolbar.ToolbarLayout = Backbone.Marionette.Layout.extend({
|
||||
'Shared/Toolbar/ButtonModel',
|
||||
'Shared/Toolbar/Radio/RadioButtonCollectionView',
|
||||
'Shared/Toolbar/Button/ButtonCollectionView'
|
||||
], function (Marionette, ButtonCollection, ButtonModel, RadioButtonCollectionView, ButtonCollectionView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Shared/Toolbar/ToolbarLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
|
@ -38,6 +33,7 @@ define(
|
|||
|
||||
},
|
||||
|
||||
|
||||
onShow: function () {
|
||||
if (this.left) {
|
||||
_.each(this.left, this._showToolbarLeft, this);
|
||||
|
@ -79,17 +75,17 @@ define(
|
|||
case 'radio':
|
||||
{
|
||||
buttonGroupView = new RadioButtonCollectionView({
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
buttonGroupView = new ButtonCollectionView({
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -97,9 +93,6 @@ define(
|
|||
this[position + '_' + (index + 1).toString()].show(buttonGroupView);
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Shared.Toolbar.ToolbarLayout;
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue