From 39280ea6bdfff518c572d7c5d2fc3c453fc9b84d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 31 Dec 2020 09:13:00 -0500 Subject: [PATCH 1/3] [showmore_dyn] Add support for 0 value to disable addon --- showmore_dyn/showmore_dyn.js | 15 +++++++-------- showmore_dyn/showmore_dyn.php | 9 +++------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index 4b32b2d31..74803d2d2 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -6,15 +6,14 @@ $(document).ready(function() { return; } - $("head").append(''); - var newStyleElement = $("head").children(':last'); - newStyleElement.html('.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden; }'); - - handleNewWallItemBodies(); - - document.addEventListener("postprocess_liveupdate", function() { + if (postLimitHeight) { + $('head').append(''); handleNewWallItemBodies(); - }); + + document.addEventListener('postprocess_liveupdate', function() { + handleNewWallItemBodies(); + }); + } }); function handleNewWallItemBodies() { diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index 32aedb080..ccb96bc65 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -41,10 +41,7 @@ function showmore_dyn_settings_post() } if (isset($_POST['showmore_dyn-submit'])) { - $limitHeight = $_POST['limitHeight']; - if ($limitHeight && is_numeric($limitHeight)) { - DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); - } + DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $_POST['limitHeight'] ?? 0); } } @@ -61,14 +58,14 @@ function showmore_dyn_settings(App &$a, &$o) $o .= Renderer::replaceMacros($t, [ '$submit' => DI::l10n()->t('Save Settings'), '$title' => 'Showmore Dynamic', - '$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, 'The maximal height of posts when collapsed', '', '', 'number'], + '$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, 'The maximal pixel height of posts, 0 to disable', '', '', 'number'], ]); } function showmore_dyn_script() { - $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight', 250); + $limitHeight = intval(DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight', 250)); $showmore_dyn_showmore_linktext = DI::l10n()->t('Show more ...'); DI::page()['htmlhead'] .= << From 14ebf55d56472c5abc3f14806b9830efe8e20f7b Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 31 Dec 2020 09:13:42 -0500 Subject: [PATCH 2/3] [showmore_dyn] Normalize addon use setting display with accordion behavior --- showmore_dyn/showmore_dyn.php | 2 +- showmore_dyn/templates/settings.tpl | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index ccb96bc65..da384faaf 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -57,7 +57,7 @@ function showmore_dyn_settings(App &$a, &$o) $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore_dyn/'); $o .= Renderer::replaceMacros($t, [ '$submit' => DI::l10n()->t('Save Settings'), - '$title' => 'Showmore Dynamic', + '$header' => 'Show More Dynamic', '$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, 'The maximal pixel height of posts, 0 to disable', '', '', 'number'], ]); diff --git a/showmore_dyn/templates/settings.tpl b/showmore_dyn/templates/settings.tpl index 5e8bc3f1e..ac37e937d 100644 --- a/showmore_dyn/templates/settings.tpl +++ b/showmore_dyn/templates/settings.tpl @@ -1,5 +1,10 @@ -
-

{{$title}}

+ +

{{$header}}

+
+