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