1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Missing/MissingCollectionView.js

87 lines
3.1 KiB
JavaScript
Raw Normal View History

2013-03-21 06:02:57 +03:00
'use strict';
2013-03-30 22:33:41 +03:00
define(['app', 'Missing/MissingItemView'], function () {
2013-03-21 06:02:57 +03:00
NzbDrone.Missing.MissingCollectionView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Missing.MissingItemView,
2013-03-21 06:02:57 +03:00
itemViewContainer: 'tbody',
template : 'Missing/MissingCollectionTemplate',
2013-03-21 06:02:57 +03:00
ui: {
table: '.x-missing-table',
pager: '.x-missing-table-pager'
2013-03-21 06:02:57 +03:00
},
onCompositeCollectionRendered: function () {
2013-03-21 06:02:57 +03:00
this.ui.table.trigger('update');
if (!this.tableSorter && this.collection.length > 0) {
2013-03-21 06:02:57 +03:00
this.tableSorter = this.ui.table.tablesorter({
textExtraction: function (node) {
return node.innerHTML;
},
sortList : [
[3, 1]
],
headers : {
2013-03-21 06:02:57 +03:00
0: {
sorter: 'innerHtml'
},
1: {
sorter: false
},
2: {
sorter: false
},
3: {
sorter: 'date'
},
4: {
sorter: false
}
}
});
this.ui.table.bind('pagerComplete pagerInitialized', function (event, c) {
2013-03-22 09:43:23 +03:00
c.container.find('.page-number').text(c.page + 1);
2013-03-21 06:02:57 +03:00
});
2013-03-22 09:43:23 +03:00
this.ui.table.tablesorterPager({
container: this.ui.pager,
output : 'Displaying {startRow} to {endRow} of {totalRows} episodes'
2013-03-22 09:43:23 +03:00
});
2013-03-21 06:02:57 +03:00
2013-03-22 09:43:23 +03:00
this.applySortIcons();
2013-03-21 06:02:57 +03:00
this.ui.table.bind("sortEnd", function () {
2013-03-22 09:43:23 +03:00
this.applySortIcons();
2013-03-21 06:02:57 +03:00
});
}
else {
2013-03-21 06:02:57 +03:00
this.ui.table.trigger('update');
}
},
2013-03-22 09:43:23 +03:00
//Todo: Remove this from each view that requires it
applySortIcons : function () {
$(this.ui.table).find('th.tablesorter-header .tablesorter-header-inner i').each(function () {
2013-03-22 09:43:23 +03:00
$(this).remove();
});
$(this.ui.table).find('th.tablesorter-header').each(function () {
if ($(this).hasClass('tablesorter-headerDesc')) {
2013-03-22 09:43:23 +03:00
$(this).children('.tablesorter-header-inner').append('<i class="icon-sort-up pull-right">');
}
2013-03-22 09:43:23 +03:00
else if ($(this).hasClass('tablesorter-headerAsc')) {
2013-03-22 09:43:23 +03:00
$(this).children('.tablesorter-header-inner').append('<i class="icon-sort-down pull-right">');
}
2013-03-22 09:43:23 +03:00
else if (!$(this).hasClass('sorter-false')) {
2013-03-22 09:43:23 +03:00
$(this).children('.tablesorter-header-inner').append('<i class="icon-sort pull-right">');
}
2013-03-22 09:43:23 +03:00
});
},
updatePageNumber : function (event, stuff) {
2013-03-22 09:43:23 +03:00
}
2013-03-21 06:02:57 +03:00
});
});