From 52c076e66743376a968a17fac85e8d01021fa1a6 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Wed, 8 Aug 2018 03:57:28 +0000 Subject: [PATCH] Default normal scrollbar unless theme param set --- webapp/titanembeds/constants.py | 4 ++-- webapp/titanembeds/static/js/embed.js | 33 ++++++++++++++++----------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/webapp/titanembeds/constants.py b/webapp/titanembeds/constants.py index 8d22fc8..758337f 100644 --- a/webapp/titanembeds/constants.py +++ b/webapp/titanembeds/constants.py @@ -74,7 +74,7 @@ QUERY_PARAMETERS = [ "options": [ { "name": "light", - "default": True, + "default": False, }, { "name": "dark", @@ -185,7 +185,7 @@ QUERY_PARAMETERS = [ { "name": "showscrollbar", "type": "boolean", - "description": "Shows the scrollbar permanently without autohiding.", + "description": "Shows the scrollbar permanently without autohiding. (Requires the scrollbar theme param to be set)", "example": "true", "options": [ { diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index a604dab..18470ef 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -328,7 +328,11 @@ if (!has_already_been_initially_resized) { has_already_been_initially_resized = true; if (has_handled_noscroll) { - $("main").mCustomScrollbar("scrollTo", "bottom", {scrollEasing:"easeOut"}); + if (getParameterByName("scrollbartheme")) { + $("main").mCustomScrollbar("scrollTo", "bottom", {scrollEasing:"easeOut"}); + } else { + $("main").animate({ scrollTop: $("#chatcontent").height() }, "slow"); + } } else { has_handled_noscroll = true; Materialize.toast('Continue scrolling to read on...', 5000); @@ -359,13 +363,12 @@ showScrollbar = 0; } var scrollbarTheme = getParameterByName("scrollbartheme"); - if (!scrollbarTheme) { - scrollbarTheme = "light"; + if (scrollbarTheme) { + $("main").mCustomScrollbar({ + autoHideScrollbar: !showScrollbar, + theme: scrollbarTheme + }); } - $("main").mCustomScrollbar({ - autoHideScrollbar: !showScrollbar, - theme: scrollbarTheme - }); if (disabled) { Materialize.toast('This server is currently disabled. If you are an administrator of this server, please get in touch with a TitanEmbeds team member to lift the ban.', 100000); @@ -1325,12 +1328,16 @@ has_handled_noscroll = true; Materialize.toast('Continue scrolling to read on...', 5000); } else { - if ($(window).height() < $("main .mCSB_container").height()) { - $("main .mCSB_container").animate({ - top: -1 * ($("main .mCSB_container").height() - $(window).height()) - }, "slow", function () { - $("main").mCustomScrollbar("update"); - }); + if (getParameterByName("scrollbartheme")) { + if ($(window).height() < $("main .mCSB_container").height()) { + $("main .mCSB_container").animate({ + top: -1 * ($("main .mCSB_container").height() - $(window).height()) + }, "slow", function () { + $("main").mCustomScrollbar("update"); + }); + } + } else { + $("main").animate({ scrollTop: $("#chatcontent").height() }, "slow"); } } }