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

75 lines
2.6 KiB
JavaScript
Raw Normal View History

2013-03-21 06:02:57 +03:00
'use strict';
define(['app', 'Missing/MissingItemView'], function (app) {
NzbDrone.Missing.MissingCollectionView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Missing.MissingItemView,
itemViewContainer: 'tbody',
template: 'Missing/MissingCollectionTemplate',
ui:{
table : '.x-missing-table'
},
initialize: function (context, action, query, collection) {
this.collection = collection;
},
onCompositeCollectionRendered: function() {
this.ui.table.trigger('update');
if(!this.tableSorter && this.collection.length > 0)
{
this.tableSorter = this.ui.table.tablesorter({
textExtraction: function (node) {
return node.innerHTML;
},
sortList: [[3,1]],
headers: {
0: {
sorter: 'innerHtml'
},
1: {
sorter: false
},
2: {
sorter: false
},
3: {
sorter: 'date'
},
4: {
sorter: false
}
}
});
//Todo: We should extract these common settings out
this.ui.table.find('th.header').each(function(){
$(this).append('<i class="icon-sort pull-right">');
});
this.ui.table.bind("sortEnd", function() {
$(this).find('th.header i').each(function(){
$(this).remove();
});
$(this).find('th.header').each(function () {
if (!$(this).hasClass('headerSortDown') && !$(this).hasClass('headerSortUp'))
$(this).append('<i class="icon-sort pull-right">');
});
$(this).find('th.headerSortDown').each(function(){
$(this).append('<i class="icon-sort-up pull-right">');
});
$(this).find('th.headerSortUp').each(function(){
$(this).append('<i class="icon-sort-down pull-right">');
});
});
}
else
{
this.ui.table.trigger('update');
}
}
});
});