|
|
|
@ -40,6 +40,40 @@ Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
|
|
|
|
|
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 if (this.direction() === "descending") {
|
|
|
|
|
this.sort(columnName, "ascending");
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_convertDirectionToIcon: function (dir) {
|
|
|
|
|
if (dir === 'ascending') {
|
|
|
|
|
return 'icon-sort-up';
|
|
|
|
@ -47,4 +81,69 @@ Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
|
|
|
|
|
|
|
|
|
|
return 'icon-sort-down';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Backgrid.NzbDronePaginator = Backgrid.Extension.Paginator.extend({
|
|
|
|
|
|
|
|
|
|
events: {
|
|
|
|
|
"click a": "changePage",
|
|
|
|
|
"click i": "preventLinkClick"
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
windowSize: 1,
|
|
|
|
|
|
|
|
|
|
fastForwardHandleLabels: {
|
|
|
|
|
first: '<i class="icon-fast-backward"></i>',
|
|
|
|
|
prev: '<i class="icon-backward"></i>',
|
|
|
|
|
next: '<i class="icon-forward"></i>',
|
|
|
|
|
last: '<i class="icon-fast-forward"></i>'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
changePage: function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
var target = $(e.target);
|
|
|
|
|
|
|
|
|
|
if (target.closest('li').hasClass('disabled')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$(target).is('a')){
|
|
|
|
|
target = target.parent('a');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var label = target.html();
|
|
|
|
|
var ffLabels = this.fastForwardHandleLabels;
|
|
|
|
|
|
|
|
|
|
var collection = this.collection;
|
|
|
|
|
|
|
|
|
|
if (ffLabels) {
|
|
|
|
|
switch (label) {
|
|
|
|
|
case ffLabels.first:
|
|
|
|
|
collection.getFirstPage();
|
|
|
|
|
return;
|
|
|
|
|
case ffLabels.prev:
|
|
|
|
|
if (collection.hasPrevious()) {
|
|
|
|
|
collection.getPreviousPage();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
case ffLabels.next:
|
|
|
|
|
if (collection.hasNext()) {
|
|
|
|
|
collection.getNextPage();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
case ffLabels.last:
|
|
|
|
|
collection.getLastPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var state = collection.state;
|
|
|
|
|
var pageIndex = $(e.target).text() * 1;
|
|
|
|
|
collection.getPage(state.firstPage === 0 ? pageIndex - 1 : pageIndex);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
preventLinkClick: function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
});
|