From 016a5a822f6d6ac80f61612292ea42d9c8518c94 Mon Sep 17 00:00:00 2001 From: Daniel Wilkowski Date: Tue, 10 Oct 2023 22:38:54 +0200 Subject: [PATCH] Add timeline switch --- resources/js/pages/homepage.js | 15 ++- resources/views/home.twig | 195 +++++++++++++++++++++++---------- 2 files changed, 150 insertions(+), 60 deletions(-) diff --git a/resources/js/pages/homepage.js b/resources/js/pages/homepage.js index ccc9ee32f..eb5599737 100644 --- a/resources/js/pages/homepage.js +++ b/resources/js/pages/homepage.js @@ -64,12 +64,20 @@ function switchForumTab(index) { axios.post('/User/Settings/Ajax', {'homepage_mode': index}); } +function switchTimeline(index) { + axios.post('/User/Settings/Ajax', {'homepage_timeline': index}) + .finally(() => window.location.reload()); +} + function switchReputationTab(index) { axios.post('/User/Settings/Ajax', {'homepage_reputation': index}); } (function () { - new PerfectScrollbar(document.getElementById('stream')); + const stream = document.getElementById('stream'); + if (stream) { + new PerfectScrollbar(stream); + } const forumTabs = document.querySelectorAll('#forum-tabs .nav-link'); for (let i = 0; i < forumTabs.length; i++) { @@ -80,4 +88,9 @@ function switchReputationTab(index) { for (let i = 0; i < reputationTabs.length; i++) { reputationTabs[i].addEventListener('click', () => switchReputationTab(i)); } + + const timelineTabs = document.querySelectorAll('#timeline-switch .nav-item'); + for (let i = 0; i < timelineTabs.length; i++) { + timelineTabs[i].addEventListener('click', () => switchTimeline(i)); + } })(); diff --git a/resources/views/home.twig b/resources/views/home.twig index 644902607..d2a5016ab 100644 --- a/resources/views/home.twig +++ b/resources/views/home.twig @@ -13,18 +13,70 @@ -
-
-
-

- - Co nowego na forum? -

-
-
-
+
+
+
+

+ + Co nowego na forum? +

+ +
+
+
+ + {% if settings['homepage.timeline'] == 1 %} + + {% endif %} +
@@ -53,8 +105,10 @@
{% for topic in interesting %}
- - {{ topic.views }} + + + {{ topic.views }} + {{ declination(topic.views, ['wyświetlenie', 'wyświetlenia', 'wyświetleń'], true) }} @@ -80,8 +134,10 @@
{% for topic in newest %}
- - {{ topic.views }} + + + {{ topic.views }} + {{ declination(topic.views, ['wyświetlenie', 'wyświetlenia', 'wyświetleń'], true) }} @@ -107,31 +163,33 @@
-
-
-
- {% for activity in activities %} -
- - + {% if settings['homepage.timeline'] == 0 %} +
+
+
+ {% for activity in activities %} +
+ + -
- - activity.user.name - -
-
-

{{ activity.headline|raw }}

- {{ activity.created_at }} - {{ activity.excerpt }} +
+ + activity.user.name + +
+
+

{{ activity.headline|raw }}

+ {{ activity.created_at }} + {{ activity.excerpt }} +
-
- {% endfor %} + {% endfor %} +
-
+ {% endif %}
@@ -139,34 +197,53 @@
-

- - Oś czasu -

-
-
-
- - - -
-
- - +
-
+ {% else %} +

+ + + Popularne wpisy na mikroblogu + +

+
+ +
+
+ + +
+ {% endif %}