make scrollbars configurable

This commit is contained in:
Mike Macgirvin 2023-10-08 22:06:10 +11:00
parent a256981fc6
commit 2a473dac2b
10 changed files with 34 additions and 7 deletions

View file

@ -503,11 +503,13 @@ class Channel extends Controller
// because browser prefetching might change it on us. We have to deliver it with the page.
$maxheight = get_pconfig(App::$profile['profile_uid'], 'system', 'channel_divmore_height',400);
$item_scroll = get_pconfig(local_channel(), 'system', 'item_scroll');
$o .= '<div id="live-channel"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . App::$profile['profile_uid']
. "; var netargs = '?f='; var profile_page = " . App::$pager['page']
. "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
. "; divmore_height = " . intval($maxheight)
. "; itemScroll = '" . (($item_scroll) ? 'auto' : 'hidden' ) . "' ;</script>\r\n";
App::$page['htmlhead'] .= replace_macros(Theme::get_template("build_query.tpl"), [
'$baseurl' => z_root(),

View file

@ -158,7 +158,12 @@ class Communities extends Controller
killme();
}
else {
$output = "<script> var page_query = '" . escape_tags(urlencode($_GET['req'])) . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
$maxheight = 94;
$item_scroll = get_pconfig(local_channel(), 'system', 'item_scroll');
$output = "<script> var page_query = '" . escape_tags(urlencode($_GET['req'])) . "'; var extra_args = '" . extra_query_args() . "' ; divmore_height = " . intval($maxheight)
. "; itemScroll = '" . (($item_scroll) ? 'auto' : 'hidden' ) . "' ;</script>\r\n";
$output .= replace_macros(Theme::get_template('sitentry_header.tpl'), [
'$dirlbl' => t('Communities'),

View file

@ -515,8 +515,12 @@ class Directory extends Controller
$maxheight = 94;
$dirtitle = (($globaldir) ? t('Directory') : t('Local Directory'));
$item_scroll = get_pconfig(local_channel(), 'system', 'item_scroll');
$o .= "<script> let page_query = '" . escape_tags(urlencode($_GET['req'])) . "'; let extra_args = '" . extra_query_args() . "' ; divmore_height = " . intval($maxheight)
. "; itemScroll = '" . (($item_scroll) ? 'auto' : 'hidden' ) . "' ;</script>\r\n";
$o .= "<script> let page_query = '" . escape_tags(urlencode($_GET['req'])) . "'; let extra_args = '" . extra_query_args() . "' ; divmore_height = " . intval($maxheight) . "; </script>";
$o .= replace_macros($tpl, [
'$search' => $search,
'$desc' => t('Find'),

View file

@ -221,9 +221,12 @@ class Display extends Controller
$mid = gen_link_id($mid);
$max_height = local_channel() ? get_pconfig(local_channel(), 'system', 'stream_divmore_height', 400) : 400;
$item_scroll = get_pconfig(local_channel(), 'system', 'item_scroll');
$o .= '<div id="live-display"></div>' . "\r\n";
$o .= "<script> let profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1))
. "; let netargs = '?f='; let profile_page = " . App::$pager['page'] . "; divmore_height = " . intval($max_height) . "; </script>\r\n";
. "; let netargs = '?f='; let profile_page = " . App::$pager['page'] . "; divmore_height = " . intval($max_height)
. "; itemScroll = '" . (($item_scroll) ? 'auto' : 'hidden' ) . "' ;</script>\r\n";
App::$page['htmlhead'] .= replace_macros(Theme::get_template("build_query.tpl"), [
'$baseurl' => z_root(),

View file

@ -106,11 +106,13 @@ class Pubstream extends Controller
$static = ((local_channel()) ? Channel::manual_conv_update(local_channel()) : 1);
$maxheight = get_config('system', 'home_divmore_height', 400);
$item_scroll = get_pconfig(local_channel(), 'system', 'item_scroll');
$o .= '<div id="live-pubstream"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1))
. "; var profile_page = " . App::$pager['page']
. "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
. "; divmore_height = " . intval($maxheight)
. "; itemScroll = '" . (($item_scroll) ? 'auto' : 'hidden' ) . "' ;</script>\r\n";
// if we got a decoded hash we must encode it again before handing to javascript
$mid = gen_link_id($mid);

View file

@ -211,13 +211,15 @@ class Search extends Controller
if ((!$this->updating) && (!$this->loading)) {
$static = ((local_channel()) ? Channel::manual_conv_update(local_channel()) : 0);
$item_scroll = get_pconfig(local_channel(), 'system', 'item_scroll');
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.
$output .= '<div id="live-search"></div>' . "\r\n";
$output .= "<script> let profile_uid = " . intval($this->search_channel['channel_id'])
. "; let netargs = '?f='; let profile_page = " . App::$pager['page'] . "; divmore_height = 400; </script>\r\n";
. "; let netargs = '?f='; let profile_page = " . App::$pager['page'] . "; divmore_height = 400;"
. " itemScroll = '" . (($item_scroll) ? 'auto' : 'hidden' ) . "' ;</script>\r\n";
App::$page['htmlhead'] .= replace_macros(Theme::get_template("build_query.tpl"), [
'$baseurl' => z_root(),

View file

@ -42,6 +42,8 @@ class Display
$channel_divmore_height = ((x($_POST, 'channel_divmore_height')) ? intval($_POST['channel_divmore_height']) : 400);
$stream_divmore_height = ((x($_POST, 'stream_divmore_height')) ? intval($_POST['stream_divmore_height']) : 400);
$item_scroll = ((x($_POST, 'item_scroll')) ? intval($_POST['item_scroll']) : 0);
$browser_update = ((x($_POST, 'browser_update')) ? intval($_POST['browser_update']) : 0);
$browser_update = $browser_update * 1000;
@ -68,6 +70,7 @@ class Display
set_pconfig(local_channel(), 'system', 'no_smilies', 1 - intval($nosmile));
set_pconfig(local_channel(), 'system', 'channel_divmore_height', $channel_divmore_height);
set_pconfig(local_channel(), 'system', 'stream_divmore_height', $stream_divmore_height);
set_pconfig(local_channel(), 'system', 'item_scroll', $item_scroll);
set_pconfig(local_channel(), 'system', 'channel_menu', $channel_menu);
set_pconfig(local_channel(), 'system', 'thread_indent_px', $indentpx);
set_pconfig(local_channel(), 'system', 'filter_menu_open', $filter_menu_open);
@ -221,6 +224,7 @@ class Display
'$expert' => Features::enabled(local_channel(), 'advanced_theming'),
'$channel_divmore_height' => ['channel_divmore_height', t('Channel page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'channel_divmore_height', 400), t('click to expand content exceeding this height, or 0 to display full height')],
'$stream_divmore_height' => ['stream_divmore_height', t('Stream page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'stream_divmore_height', 400), t('click to expand content exceeding this height, or 0 to display full height')],
'$item_scroll' => ['item_scroll', t('Add scrollbars for long content'), get_pconfig(local_channel(), 'system', 'item_scroll'), '', $yes_no ],
'$indentpx' => ['indentpx', t('Indent threaded comments this many pixels from the parent'), intval(get_pconfig(local_channel(), 'system', 'thread_indent_px', get_config('system', 'thread_indent_px', 0))), t('0-20')],
]);

View file

@ -377,6 +377,7 @@ class Stream extends Controller
if (!$this->updating) {
$maxheight = get_pconfig(local_channel(), 'system', 'stream_divmore_height', 400);
$item_scroll = get_pconfig(local_channel(), 'system', 'item_scroll');
// The special div is needed for liveUpdate to kick in for this page.
// We only launch liveUpdate if you aren't filtering in some incompatible
@ -385,7 +386,8 @@ class Stream extends Controller
$o .= '<div id="live-stream"></div>' . "\r\n";
$o .= "<script> let profile_uid = " . local_channel()
. "; let profile_page = " . App::$pager['page']
. "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
. "; divmore_height = " . intval($maxheight)
. "; itemScroll = '" . (($item_scroll) ? 'auto' : 'hidden' ) . "' ;</script>\r\n";
App::$page['htmlhead'] .= replace_macros(Theme::get_template('build_query.tpl'), [
'$baseurl' => z_root(),

View file

@ -20,6 +20,7 @@ let page_load = true;
let loadingPage = false;
let pageHasMoreContent = true;
let divmore_height = 400;
let itemScroll = 'hidden';
let last_filestorage_id = null;
let mediaPlaying = false;
let contentHeightDiff = 0;
@ -932,6 +933,7 @@ function collapseHeight() {
if (scrollable) {
$(this).addClass('scrollable');
$(this).css('max-height', divmore_height + 'px');
$(this).css('overflow-y', itemScroll);
$("#wall-item-scroll-" + scrollid).show();
$("#directory-scroll-" + scrollid).show();
}

View file

@ -63,6 +63,7 @@
{{include file="field_input.tpl" field=$indentpx}}
{{include file="field_input.tpl" field=$channel_divmore_height}}
{{include file="field_input.tpl" field=$stream_divmore_height}}
{{include file="field_checkbox.tpl" field=$item_scroll}}
{{include file="field_checkbox.tpl" field=$nosmile}}
{{include file="field_checkbox.tpl" field=$channel_menu}}
{{include file="field_checkbox.tpl" field=$filter_menu_open}}