Merge pull request #1066 from MrPetovan/task/9568-showmore_dyn-improvements

[showmore_dyn] Various addon improvements
This commit is contained in:
Michael Vogel 2020-12-31 17:38:14 +01:00 committed by GitHub
commit 559c85775e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 23 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-15 21:20+0100\n"
"POT-Creation-Date: 2020-12-31 09:16-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,14 +17,24 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: showmore_dyn.php:62
#: showmore_dyn.php:59
msgid "Save Settings"
msgstr ""
#: showmore_dyn.php:64 showmore_dyn.php:65
#: showmore_dyn.php:60
msgid "Show More Dynamic"
msgstr ""
#: showmore_dyn.php:61
msgid "Limit Height"
msgstr ""
#: showmore_dyn.php:73
msgid "Show more ..."
#: showmore_dyn.php:61
msgid ""
"The maximal pixel height of posts before the Show More link is added, 0 to "
"disable"
msgstr ""
#: showmore_dyn.php:69
msgid "Show more..."
msgstr ""

View File

@ -6,15 +6,14 @@ $(document).ready(function() {
return;
}
$("head").append('<style type="text/css"></style>');
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('<style type="text/css">.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden; }</style>');
handleNewWallItemBodies();
});
document.addEventListener('postprocess_liveupdate', function() {
handleNewWallItemBodies();
});
}
});
function handleNewWallItemBodies() {

View File

@ -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);
}
}
@ -60,16 +57,16 @@ 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',
'$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, 'The maximal height of posts when collapsed', '', '', 'number'],
'$header' => DI::l10n()->t('Show More Dynamic'),
'$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, DI::l10n()->t('The maximal pixel height of posts before the Show More link is added, 0 to disable'), '', '', 'number'],
]);
}
function showmore_dyn_script()
{
$limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight', 250);
$showmore_dyn_showmore_linktext = DI::l10n()->t('Show more ...');
$limitHeight = intval(DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight', 250));
$showmore_dyn_showmore_linktext = DI::l10n()->t('Show more...');
DI::page()['htmlhead'] .= <<<EOT
<script>
var postLimitHeight = $limitHeight;

View File

@ -1,5 +1,10 @@
<div class="settings-block">
<h3 class="settings-heading">{{$title}}</h3>
<span id="settings_showmore_dyn_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_showmore_dyn_expanded'); openClose('settings_showmore_dyn_inflated');">
<h3>{{$header}}</h3>
</span>
<div id="settings_showmore_dyn_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_showmore_dyn_expanded'); openClose('settings_showmore_dyn_inflated');">
<h3>{{$header}}</h3>
</span>
{{include file="field_input.tpl" field=$limitHeight}}
<div class="settings-submit-wrapper">