Dynamically adjust user recently watched items

Only show one row of recently watched items which adjusts to the window
size, similar to recently added items.
This commit is contained in:
JonnyWong16 2015-08-19 00:51:27 -07:00
parent c98505038a
commit 317a9f0b8e

View file

@ -240,6 +240,33 @@ from plexpy import helpers
<script src="interfaces/default/js/tables/user_ips.js"></script>
<script src="interfaces/default/js/tables/sync_table.js"></script>
<script>
function recentlyWatched() {
var widthVal = $('body').find("#user-recently-watched").width();
var tmp = (widthVal-32) / 180;
if (tmp > 0) {
containerSize = parseInt(tmp);
} else {
containerSize = 1;
}
% if data['user_id']:
var user_id = ${data['user_id']};
% else:
var user_id = null;
% endif
// Populate recently watched
$.ajax({
url: 'get_user_recently_watched',
async: true,
data: { user_id: user_id, user: '${data['username']}', limit: containerSize },
complete: function(xhr, status) {
$("#user-recently-watched").html(xhr.responseText);
}
});
}
$(document).ready(function () {
% if data['user_id']:
@ -270,16 +297,6 @@ from plexpy import helpers
}
});
// Populate recently watched
$.ajax({
url: 'get_user_recently_watched',
async: true,
data: { user_id: user_id, user: '${data['username']}' },
complete: function(xhr, status) {
$("#user-recently-watched").html(xhr.responseText);
}
});
$( "#history-tab-btn" ).one( "click", function() {
// Build watch history table
history_table_options.ajax = {
@ -356,6 +373,11 @@ from plexpy import helpers
});
}
});
recentlyWatched();
$(window).resize(function() {
recentlyWatched();
});
});
</script>
</%def>