SAAS-1188 - add empty placeholder for podcast episodes table

This commit is contained in:
Duncan Sommerville 2015-11-12 14:14:42 -05:00
parent 26c9a19836
commit 0951afcbb3
3 changed files with 28 additions and 17 deletions

View File

@ -70,8 +70,9 @@ var AIRTIME = (function(AIRTIME) {
};
/**
* Draw a placeholder for the given table to show if it has no data.
*
* @param {jQuery} table
* @param {jQuery} table jQuery object containing the table DOM node
*/
mod.drawEmptyPlaceholder = function (table) {
var emptyRow = table.find('tr:has(td.dataTables_empty)'),
@ -82,11 +83,18 @@ var AIRTIME = (function(AIRTIME) {
emptyRow.hide();
var mediaType = parseInt($('.media_type_selector.selected').data('selection-id')),
img = wrapper.find('.empty_placeholder_image');
if (isNaN(mediaType)) { return; }
// Remove all classes for when we change between empty media types
img.removeClass(function() {
return $(this).attr("class");
});
img.removeClass(function() { return $(this).attr("class"); });
if (table[0] == AIRTIME.library.podcastEpisodeDataTable[0]) {
img.addClass("empty_placeholder_image icon-white icon-th-list");
wrapper.find('.empty_placeholder_text').html(
$.i18n._("This podcast doesn't have any episodes!")
+ "<br/>" + $.i18n._("Make sure the RSS feed contains audio items (with enclosure tags).")
+ "<br/><a target='_blank' href='http://www.apple.com/ca/itunes/podcasts/specs.html'>" + $.i18n._("Learn about podcasts") + "</a>"
);
} else {
var opts = AIRTIME.library.placeholder(mediaType);
img.addClass("empty_placeholder_image icon-white " + opts.icon);
wrapper.find('.empty_placeholder_text').html(
@ -94,6 +102,7 @@ var AIRTIME = (function(AIRTIME) {
+ "<br/>" + $.i18n._(opts.subtext)
+ "<br/><a target='_blank' href='" + opts.href + "'>" + $.i18n._("Learn about " + opts.media) + "</a>"
);
}
libEmpty.show();
} else {

View File

@ -1558,6 +1558,9 @@ var AIRTIME = (function(AIRTIME) {
},
oColReorder: {
iFixedColumns: 3 // Checkbox + imported
},
fnDrawCallback: function () {
AIRTIME.library.drawEmptyPlaceholder($(this));
}
},
buttons,

View File

@ -341,12 +341,13 @@ var AIRTIME = (function (AIRTIME) {
* @private
*/
PodcastEpisodeTable.prototype._datatablesCheckboxDataDelegate = function(rowData, callType, dataToSave) {
var importIcon = "<span class='sp-checked-icon checked-icon imported-flag'></span>",
var defaultIcon = "<span class='icon-white icon-import'></span>",
importIcon = "<span class='sp-checked-icon checked-icon imported-flag'></span>",
pendingIcon = "<span class='loading-icon'></span>";
if (this.config.hideIngestCheckboxes && rowData.ingested && rowData.ingested != 0) {
return rowData.ingested > 0 ? importIcon : pendingIcon;
}
rowData.importIcon = (rowData.ingested != 0) ? (rowData.ingested > 0 ? importIcon : pendingIcon) : null;
rowData.importIcon = (rowData.ingested != 0) ? (rowData.ingested > 0 ? importIcon : pendingIcon) : defaultIcon;
return AIRTIME.widgets.Table.prototype._datatablesCheckboxDataDelegate.call(this, rowData, callType, dataToSave);
};
@ -368,10 +369,8 @@ var AIRTIME = (function (AIRTIME) {
applyPlatformOpacityRules: false
});
$.get(endpoint + self.config.podcastId + '/episodes', function (json) {
dt.fnClearTable();
self.clearSelection();
dt.fnClearTable(false);
dt.fnAddData(JSON.parse(json));
// dt.fnDraw();
}).done(function () {
dt.unblock();
});
@ -417,7 +416,7 @@ var AIRTIME = (function (AIRTIME) {
if (delta) { // Has there been a change?
// We already have the data, so there's no reason to call
// reload() here; this also provides a smoother transition
dt.fnClearTable();
dt.fnClearTable(false);
dt.fnAddData(data);
}
});