From b5e9ff3b4ecb2fbf670b42cae155080b85987416 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sat, 27 Feb 2016 00:00:11 -0800 Subject: [PATCH] Add scrolling recently watched and added to user and library pages --- data/interfaces/default/css/plexpy.css | 3 +- data/interfaces/default/library.html | 86 ++++++++++---- .../default/library_recently_added.html | 106 +++++++++--------- data/interfaces/default/user.html | 44 ++++++-- .../default/user_recently_watched.html | 90 +++++++-------- 5 files changed, 200 insertions(+), 129 deletions(-) diff --git a/data/interfaces/default/css/plexpy.css b/data/interfaces/default/css/plexpy.css index c519aac6..8e43f251 100644 --- a/data/interfaces/default/css/plexpy.css +++ b/data/interfaces/default/css/plexpy.css @@ -2772,7 +2772,8 @@ a.no-highlight:hover { .nav-header > li > a:hover { background-color: transparent; } -#recently-added-row-scroller { +#recently-added-row-scroller, +#recently-watched-row-scroller { width: 8750px; position: relative; } \ No newline at end of file diff --git a/data/interfaces/default/library.html b/data/interfaces/default/library.html index 3333b53c..95026667 100644 --- a/data/interfaces/default/library.html +++ b/data/interfaces/default/library.html @@ -118,6 +118,14 @@ DOCUMENTATION :: END
+
Recently Watched
@@ -135,6 +143,14 @@ DOCUMENTATION :: END
+
Recently Added
@@ -460,22 +476,13 @@ DOCUMENTATION :: END }); function recentlyWatched() { - var widthVal = $("#library-recently-watched").width(); - var tmp = (widthVal-25) / 175; - - if (tmp > 0) { - var containerSize = parseInt(tmp); - } else { - var containerSize = 1; - } - // Populate recently watched $.ajax({ url: 'get_library_recently_watched', async: true, data: { section_id: section_id, - limit: containerSize + limit: 50 }, complete: function(xhr, status) { $("#library-recently-watched").html(xhr.responseText); @@ -484,22 +491,13 @@ DOCUMENTATION :: END } function recentlyAdded() { - var widthVal = $("#library-recently-added").width(); - var tmp = (widthVal-25) / 175; - - if (tmp > 0) { - var containerSize = parseInt(tmp); - } else { - var containerSize = 1; - } - // Populate recently added $.ajax({ url: 'get_library_recently_added', async: true, data: { section_id: section_id, - limit: containerSize + limit: 50 }, complete: function(xhr, status) { $("#library-recently-added").html(xhr.responseText); @@ -515,6 +513,54 @@ DOCUMENTATION :: END }); $('div.art-face').animate({ opacity: 0.2 }, { duration: 1000 }); + + var leftTotalWatched = 0; + $(".paginate-watched").click(function (e) { + e.preventDefault(); + var scroller = $("#recently-watched-row-scroller"); + var containerWidth = $("#library-recently-watched").width(); + var scrollAmount = $(this).data("id") * parseInt((containerWidth - 15) / 175) * 175; + var leftMax = -(parseInt(scroller.width()) + scrollAmount); + + leftTotalWatched = Math.max(Math.min(leftTotalWatched + scrollAmount, 0), leftMax); + scroller.animate({ left: leftTotalWatched }, 250); + + if (leftTotalWatched == 0) { + $("#recently-watched-page-left").addClass("disabled").blur(); + } else { + $("#recently-watched-page-left").removeClass("disabled"); + } + + if (leftTotalWatched == leftMax) { + $("#recently-watched-page-right").addClass("disabled").blur(); + } else { + $("#recently-watched-page-right").removeClass("disabled"); + } + }); + + var leftTotalAdded = 0; + $(".paginate-added").click(function (e) { + e.preventDefault(); + var scroller = $("#recently-added-row-scroller"); + var containerWidth = $("#library-recently-added").width(); + var scrollAmount = $(this).data("id") * parseInt((containerWidth - 15) / 175) * 175; + var leftMax = -(parseInt(scroller.width()) + scrollAmount); + + leftTotalAdded = Math.max(Math.min(leftTotalAdded + scrollAmount, 0), leftMax); + scroller.animate({ left: leftTotalAdded }, 250); + + if (leftTotalAdded == 0) { + $("#recently-added-page-left").addClass("disabled").blur(); + } else { + $("#recently-added-page-left").removeClass("disabled"); + } + + if (leftTotalAdded == leftMax) { + $("#recently-added-page-right").addClass("disabled").blur(); + } else { + $("#recently-added-page-right").removeClass("disabled"); + } + }); }); % endif diff --git a/data/interfaces/default/library_recently_added.html b/data/interfaces/default/library_recently_added.html index 69eea34f..12bd495f 100644 --- a/data/interfaces/default/library_recently_added.html +++ b/data/interfaces/default/library_recently_added.html @@ -32,63 +32,65 @@ DOCUMENTATION :: END % if data:
- + + % endif + + % endfor + +
% else:
No stats to show. diff --git a/data/interfaces/default/user.html b/data/interfaces/default/user.html index d8fb0bd5..7f4b6ce7 100644 --- a/data/interfaces/default/user.html +++ b/data/interfaces/default/user.html @@ -112,6 +112,14 @@ from plexpy import helpers
+
Recently Watched
@@ -471,22 +479,13 @@ from plexpy import helpers }); function recentlyWatched() { - var widthVal = $("#user-recently-watched").width(); - var tmp = (widthVal-25) / 175; - - if (tmp > 0) { - var containerSize = parseInt(tmp); - } else { - var containerSize = 1; - } - // Populate recently watched $.ajax({ url: 'get_user_recently_watched', async: true, data: { user_id: user_id, - limit: containerSize + limit: 50 }, complete: function(xhr, status) { $("#user-recently-watched").html(xhr.responseText); @@ -495,8 +494,29 @@ from plexpy import helpers } recentlyWatched(); - $(window).resize(function() { - recentlyWatched(); + + var leftTotal = 0; + $(".paginate").click(function (e) { + e.preventDefault(); + var scroller = $("#recently-watched-row-scroller"); + var containerWidth = $("#user-recently-watched").width(); + var scrollAmount = $(this).data("id") * parseInt((containerWidth - 15) / 175) * 175; + var leftMax = -(parseInt(scroller.width()) + scrollAmount); + + leftTotal = Math.max(Math.min(leftTotal + scrollAmount, 0), leftMax); + scroller.animate({ left: leftTotal }, 250); + + if (leftTotal == 0) { + $("#recently-watched-page-left").addClass("disabled").blur(); + } else { + $("#recently-watched-page-left").removeClass("disabled"); + } + + if (leftTotal == leftMax) { + $("#recently-watched-page-right").addClass("disabled").blur(); + } else { + $("#recently-watched-page-right").removeClass("disabled"); + } }); }); diff --git a/data/interfaces/default/user_recently_watched.html b/data/interfaces/default/user_recently_watched.html index d13652b9..23734bcf 100644 --- a/data/interfaces/default/user_recently_watched.html +++ b/data/interfaces/default/user_recently_watched.html @@ -28,56 +28,58 @@ DOCUMENTATION :: END % if data:
% else:
No stats to show.