Skip to content

Commit

Permalink
Fixed saving status of history table
Browse files Browse the repository at this point in the history
* Fixes the automatic hiding of table when results are refreshed. Now it saves the status. If user toggles the history page to show, it keeps showing.
  • Loading branch information
p0psicles authored and fernandog committed Apr 26, 2016
1 parent 5b55fa4 commit 403161d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions gui/slick/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2505,13 +2505,24 @@ var SICKRAGE = {
$(spinner).empty().html(message);
}
};

$.fn.loadContainer = function(path, loadingTxt, errorTxt) {

// Check the previous status of the history table, for hidden or shown, through the data attribute
// data-history-toggle-hidden
function toggleHistoryTable() {
// Get previous state which was saved on the wrapper
var showOrHide = $('#wrapper').attr('data-history-toggle');
$('#historydata').collapse(showOrHide);
}

$.fn.loadContainer = function(path, loadingTxt, errorTxt, callback) {
updateSpinner(spinner, loadingTxt);
$(this).load(srRoot + path + ' #container', function(response, status) {
if (status === "error") {
updateSpinner(spinner, errorTxt, false);
}
if (typeof callback !== 'undefined') {
callback();
}
});

};
Expand Down Expand Up @@ -2561,7 +2572,8 @@ var SICKRAGE = {
$('#wrapper').loadContainer(
'/home/snatchSelection?show=' + show + '&season=' + season + '&episode=' + episode + '&manual_search_type=' + manualSearchType + '&perform_search=0',
'Loading new search results...',
'Time out, refresh page to try again'
'Time out, refresh page to try again',
toggleHistoryTable // This is a callback function
);
};

Expand Down Expand Up @@ -2643,11 +2655,13 @@ var SICKRAGE = {
// Moved and rewritten this from displayShow. This changes the button when clicked for collapsing/expanding the
// "Show History" button to show or hide the snatch/download/failed history for a manual searched episode or pack.
$(function() {
$('.collapse.toggle').on('hide.bs.collapse', function () {
$('body').on('hide.bs.collapse', '.collapse.toggle', function () {
$('#showhistory').text('Show History');
$('#wrapper').attr('data-history-toggle', 'hide');
});
$('.collapse.toggle').on('show.bs.collapse', function () {
$('body').on('show.bs.collapse', '.collapse.toggle' , function () {
$('#showhistory').text('Hide History');
$('#wrapper').attr('data-history-toggle', 'show');
});
});
},
Expand Down
2 changes: 1 addition & 1 deletion gui/slick/views/snatchSelection.mako
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
<div id="searchNotification"></div>
<div class="clearfix"></div>
<div id="wrapper">
<div id="wrapper" data-history-toggle="hide">
<div id="container">
<table id="history" class="displayShowTable display_show tablesorter tablesorter-default hasSaveSort hasStickyHeaders" cellspacing="1" border="0" cellpadding="0">
Expand Down

0 comments on commit 403161d

Please sign in to comment.