diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index e255677a3..94e560ed9 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -1338,7 +1338,7 @@ var AIRTIME = (function(AIRTIME) { click: function () { var podcast = mod.podcastTableWidget.getSelectedRows()[0]; mod.podcastEpisodeTableWidget.reload(podcast.id); - mod.podcastTableWidget._clearSelection(); + mod.podcastTableWidget.clearSelection(); mod.setCurrentTable(mod.DataTableTypeEnum.PODCAST_EPISODES); } }, @@ -1376,9 +1376,9 @@ var AIRTIME = (function(AIRTIME) { // On double click, open a table showing the selected podcast's episodes // in the left-hand pane. mod.podcastTableWidget.assignDblClickHandler(function () { - var podcast = mod.podcastDataTable.fnGetData($(this).index()); + var podcast = mod.podcastDataTable.fnGetData(this); mod.podcastEpisodeTableWidget.reload(podcast.id); - mod.podcastTableWidget._clearSelection(); + mod.podcastTableWidget.clearSelection(); mod.setCurrentTable(mod.DataTableTypeEnum.PODCAST_EPISODES); }); @@ -1494,6 +1494,7 @@ var AIRTIME = (function(AIRTIME) { } }, validateConstraints: function () { + // TODO: change text + behaviour for playlists, smart blocks, etc. return checkSelectedEpisodeImportStatus.call(this, true); } }, @@ -1541,7 +1542,7 @@ var AIRTIME = (function(AIRTIME) { mod.podcastEpisodeDataTable = $datatables[mod.DataTableTypeEnum.PODCAST_EPISODES] = mod.podcastEpisodeTableWidget.getDatatable(); mod.podcastEpisodeTableWidget.assignDblClickHandler(function () { - var data = mod.podcastEpisodeDataTable.fnGetData($(this).index()); + var data = mod.podcastEpisodeDataTable.fnGetData(this); if (!$.isEmptyObject(data.file)) { mod.dblClickAdd(data.file, data.file.ftype); } else { diff --git a/airtime_mvc/public/js/airtime/library/podcast.js b/airtime_mvc/public/js/airtime/library/podcast.js index 867ff7004..61dd16868 100644 --- a/airtime_mvc/public/js/airtime/library/podcast.js +++ b/airtime_mvc/public/js/airtime/library/podcast.js @@ -607,9 +607,9 @@ var AIRTIME = (function (AIRTIME) { var self = this; $(nRow).draggable({ helper: function () { - var $row = $(this); - $row.data("aData", self._datatable.fnGetData($(nRow).index()).file); - self.selectRow(this, self._datatable.fnGetData($row.index()), self.SELECTION_MODE.SINGLE, $row.index()); + var $row = $(this), data = self._datatable.fnGetData(nRow); + $row.data("aData", data.file); + self.selectRow(this, data, self.SELECTION_MODE.SINGLE, $row.index()); var selected = self.getSelectedRows().length, container, width = self._$wrapperDOMNode.closest(".dataTables_wrapper").outerWidth(), message; diff --git a/airtime_mvc/public/js/airtime/widgets/table.js b/airtime_mvc/public/js/airtime/widgets/table.js index 090810ca0..18b0b4227 100644 --- a/airtime_mvc/public/js/airtime/widgets/table.js +++ b/airtime_mvc/public/js/airtime/widgets/table.js @@ -114,8 +114,8 @@ var AIRTIME = (function(AIRTIME) { */ if (bItemSelection) { $(self._datatable, 'tbody tr').on('click contextmenu', self._SELECTORS.SELECTION_TABLE_ROW, function (e) { - var aData = self._datatable.fnGetData($(this).index()); - var iDisplayIndex = $(this).index(); //The index of the row in the current page in the table. + var aData = self._datatable.fnGetData(this); + var iDisplayIndex = $(this).index(); // The index of the row in the current page in the table. var nRow = this; e.stopPropagation(); @@ -148,6 +148,11 @@ var AIRTIME = (function(AIRTIME) { e.stopPropagation(); return true; }); + + // Clear selection when switching pages + $(self._datatable).on('page', function () { + self.clearSelection(); + }); } // On filter, display the number of total and filtered results in the search bar @@ -254,7 +259,7 @@ var AIRTIME = (function(AIRTIME) { return outerDiv; }; - Table.prototype._clearSelection = function() { + Table.prototype.clearSelection = function() { this._selectedRows = []; //self._selectedRowVisualIdxMap = []; this._selectedRowVisualIdxMin = self.HUGE_INT; @@ -283,8 +288,7 @@ var AIRTIME = (function(AIRTIME) { //Regular single left-click mode if (selectionMode == self.SELECTION_MODE.SINGLE) { - - self._clearSelection(); + self.clearSelection(); self._selectedRows.push(aData); self._selectedRowVisualIdxMin = iVisualRowIdx;