mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -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,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;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue