Add filter string to generic Table object; add call to refetch podcast episode table data

This commit is contained in:
Duncan Sommerville 2015-09-28 14:14:01 -04:00
parent 375d83ab43
commit c1a16d7973
5 changed files with 58 additions and 35 deletions

View file

@ -141,10 +141,32 @@ var AIRTIME = (function(AIRTIME) {
});
}
// On filter, display the number of total and filtered results in the search bar
$(self._datatable).on('filter', function() {
var dt = self._datatable, f = dt.closest(".dataTables_wrapper").find(".filter-message"),
totalRecords = dt.fnSettings().fnRecordsTotal(),
totalDisplayRecords = dt.fnSettings().fnRecordsDisplay();
if (f.length === 0) {
var el = document.createElement("span");
el.setAttribute("class", "filter-message");
f = dt.closest(".dataTables_wrapper").find(".dataTables_filter").append(el).find(".filter-message");
}
f.text(totalRecords > totalDisplayRecords ?
$.i18n._("Filtering out ") + (totalRecords - totalDisplayRecords)
+ $.i18n._(" of ") + totalRecords
+ $.i18n._(" records") : ""
);
dt.closest(".dataTables_wrapper").find('.dataTables_filter input[type="text"]')
.css('padding-right', f.outerWidth());
});
$(self._datatable).on('init', function(e) {
self._setupToolbarButtons(self._toolbarButtons);
});
}
};
/**
@ -252,12 +274,6 @@ var AIRTIME = (function(AIRTIME) {
var foundAtIdx = $.inArray(aData, self._selectedRows);
console.log('checkbox mouse', iVisualRowIdx, foundAtIdx);
//XXX: Debugging -- Bug here-ish
if (foundAtIdx >= 0) {
console.log(aData, self._selectedRows[foundAtIdx]);
} else {
console.log("clicked row not detected as already selected");
}
//If the clicked row is already selected, deselect it.
if (foundAtIdx >= 0 && self._selectedRows.length >= 1) {
@ -370,22 +386,6 @@ var AIRTIME = (function(AIRTIME) {
fnCallback(json);
},
"error": self._handleAjaxError
}).done(function (data) {
/*
if (data.iTotalRecords > data.iTotalDisplayRecords) {
$('#filter_message').text(
$.i18n._("Filtering out ") + (data.iTotalRecords - data.iTotalDisplayRecords)
+ $.i18n._(" of ") + data.iTotalRecords
+ $.i18n._(" records")
);
$('#library_empty').hide();
$('#library_display').find('tr:has(td.dataTables_empty)').show();
} else {
$('#filter_message').text("");
}
$('#library_content').find('.dataTables_filter input[type="text"]')
.css('padding-right', $('#advanced-options').find('button').outerWidth());
*/
});
};