From 8ff88b2eee0001ea6ff29bf92709aefe7905fc98 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Thu, 12 Mar 2020 23:24:54 +0100 Subject: [PATCH 01/19] #8374: Initial implementation as addon --- showmore_dyn/showmore_dyn.css | 39 ++++++++++++++++++ showmore_dyn/showmore_dyn.js | 78 +++++++++++++++++++++++++++++++++++ showmore_dyn/showmore_dyn.php | 34 +++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 showmore_dyn/showmore_dyn.css create mode 100644 showmore_dyn/showmore_dyn.js create mode 100644 showmore_dyn/showmore_dyn.php diff --git a/showmore_dyn/showmore_dyn.css b/showmore_dyn/showmore_dyn.css new file mode 100644 index 00000000..6f9d59bc --- /dev/null +++ b/showmore_dyn/showmore_dyn.css @@ -0,0 +1,39 @@ +.limit-height { + max-height: 250px; + overflow: hidden; +} + +.wall-item-body-toggle { + width: 100%; + text-align: center; + background-image: linear-gradient(rgba(0,0,0,0), #f6f6f6); + cursor: pointer; + height: 50px; + position: absolute; + top: auto; + bottom: 0; + z-index: 11; + left: 0; + display: none; +} +.wall-item-body-toggle-text { + width: 100%; + position: absolute; + top: auto; + bottom: 0; + z-index: 12; + left: 0; + text-shadow: 0 0 5px #f6f6f6; + font-weight: bold; +} +.wall-item-body { + position: relative; + width: 100%; +} +.wall-item-body-wrapper { + position: relative; + width: 100%; + display: inline-block; +} + + diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js new file mode 100644 index 00000000..29368e7d --- /dev/null +++ b/showmore_dyn/showmore_dyn.js @@ -0,0 +1,78 @@ +$(document).ready(function(){ + handleNewWallItemBodies(); + + var mutationObserver = new MutationObserver(function(mutations) { + handleNewWallItemBodies(); + }); + mutationObserver.observe($("#content")[0], { attributes: false, characterData: false, childList: true, subtree: true, attributeOldValue: false, characterDataOldValue: false }); +}); + +function handleNewWallItemBodies() { + $('.wall-item-body:not(.showmore-done)').each(function(i, el) { + $(el).addClass('showmore-done'); + if ($(el).has('button.content-filter-button').length > 0) { + $(el).removeClass('limitable'); + return; + } + + var itemId = $(el).attr('id'); + addHeightToggleHandler(itemId); + var limited = processHeightLimit(itemId); + + if (!limited) { + var mutationObserver = new MutationObserver(function(mutations) { + var limited = processHeightLimit(itemId); + if (limited) { + mutationObserver.disconnect() + } + }); + mutationObserver.observe(el, { attributes: true, characterData: true, childList: true, subtree: true, attributeOldValue: true, characterDataOldValue: true }); + + $(el).imagesLoaded().then(function(){ + processHeightLimit(itemId); + }); + } + }); +} + +function addHeightToggleHandler(id) { + var itemIdSel = "#" + id; + var itemId = parseInt(id.replace("wall-item-body-", "")); + $(itemIdSel).data("item-id", itemId); + var wrapperId = "wall-item-body-wrapper-" + itemId; + var wrapperIdSel = "#" + wrapperId; + var toggleId = "wall-item-body-toggle-" + itemId; + var toggleIdSel = "#" + toggleId; + + $(itemIdSel).wrap('
'); + $(wrapperIdSel).append('
Show more ...
'); + + $(toggleIdSel).show(); + $(toggleIdSel).click(function(el) { + $(itemIdSel).toggleClass("limit-height"); + $(this).hide(); + $(itemIdSel).removeClass("limitable"); + }); +} + +function processHeightLimit(id) { + var idSel = "#" + id; + + if (!$(idSel).hasClass("limitable")) { + return false; + } + + var itemId = $(idSel).data("item-id"); + var toggleSelector = "#wall-item-body-toggle-" + itemId; + if ($(idSel).height() < 250) { + $(idSel).removeClass("limit-height"); + $(toggleSelector).hide(); + return false; + } else { + $(idSel).addClass("limit-height"); + $(toggleSelector).show(); + return true; + } +} + + diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php new file mode 100644 index 00000000..9b0ec24e --- /dev/null +++ b/showmore_dyn/showmore_dyn.php @@ -0,0 +1,34 @@ +registerStylesheet(__DIR__ . '/showmore_dyn.css'); +} + +function showmore_dyn_footer(App $a, &$b) +{ + DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js'); +} + -- 2.43.5 From 858904090ea88eea00fd370a4af1e7a234630b39 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Thu, 12 Mar 2020 23:38:20 +0100 Subject: [PATCH 02/19] #8374: Adding missing classes to body div --- showmore_dyn/showmore_dyn.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index 29368e7d..b6746660 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -46,6 +46,8 @@ function addHeightToggleHandler(id) { $(itemIdSel).wrap('
'); $(wrapperIdSel).append(''); + $(itemIdSel).addClass("limitable"); + $(itemIdSel).addClass("limit-height"); $(toggleIdSel).show(); $(toggleIdSel).click(function(el) { @@ -60,7 +62,8 @@ function processHeightLimit(id) { if (!$(idSel).hasClass("limitable")) { return false; - } + } + var itemId = $(idSel).data("item-id"); var toggleSelector = "#wall-item-body-toggle-" + itemId; -- 2.43.5 From ab24c621b2a9f809f5d52dae8a3743cd61f733eb Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Fri, 13 Mar 2020 22:09:21 +0100 Subject: [PATCH 03/19] #8374: Addessing review comments --- showmore_dyn/showmore_dyn.js | 117 ++++++++++++++++------------------ showmore_dyn/showmore_dyn.php | 8 +-- 2 files changed, 59 insertions(+), 66 deletions(-) diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index b6746660..7d91c337 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -1,81 +1,74 @@ $(document).ready(function(){ - handleNewWallItemBodies(); + handleNewWallItemBodies(); - var mutationObserver = new MutationObserver(function(mutations) { - handleNewWallItemBodies(); - }); - mutationObserver.observe($("#content")[0], { attributes: false, characterData: false, childList: true, subtree: true, attributeOldValue: false, characterDataOldValue: false }); + document.addEventListener("postprocess_liveupdate", function() { + handleNewWallItemBodies(); + }); }); function handleNewWallItemBodies() { - $('.wall-item-body:not(.showmore-done)').each(function(i, el) { - $(el).addClass('showmore-done'); - if ($(el).has('button.content-filter-button').length > 0) { - $(el).removeClass('limitable'); - return; - } + $('.wall-item-body:not(.showmore-done)').each(function() { + var $el = $(this); + $el.addClass('showmore-done'); + if ($el.has('button.content-filter-button').length > 0) { + $el.removeClass('limitable'); + return; + } - var itemId = $(el).attr('id'); - addHeightToggleHandler(itemId); - var limited = processHeightLimit(itemId); + addHeightToggleHandler($el); + var limited = processHeightLimit($el); - if (!limited) { - var mutationObserver = new MutationObserver(function(mutations) { - var limited = processHeightLimit(itemId); - if (limited) { - mutationObserver.disconnect() - } - }); - mutationObserver.observe(el, { attributes: true, characterData: true, childList: true, subtree: true, attributeOldValue: true, characterDataOldValue: true }); + if (!limited) { + var mutationObserver = new MutationObserver(function(mutations) { + var limited = processHeightLimit($el); + if (limited) { + mutationObserver.disconnect() + } + }); + mutationObserver.observe($el[0], { attributes: true, characterData: true, childList: true, subtree: true, attributeOldValue: true, characterDataOldValue: true }); - $(el).imagesLoaded().then(function(){ - processHeightLimit(itemId); - }); - } - }); + $el.imagesLoaded().then(function(){ + processHeightLimit($el); + }); + } + }); } -function addHeightToggleHandler(id) { - var itemIdSel = "#" + id; - var itemId = parseInt(id.replace("wall-item-body-", "")); - $(itemIdSel).data("item-id", itemId); - var wrapperId = "wall-item-body-wrapper-" + itemId; - var wrapperIdSel = "#" + wrapperId; - var toggleId = "wall-item-body-toggle-" + itemId; - var toggleIdSel = "#" + toggleId; +function addHeightToggleHandler($item) { + var itemId = parseInt($item.attr("id").replace("wall-item-body-", "")); + $item.data("item-id", itemId); + var wrapperId = "wall-item-body-wrapper-" + itemId; + var toggleId = "wall-item-body-toggle-" + itemId; - $(itemIdSel).wrap('
'); - $(wrapperIdSel).append(''); - $(itemIdSel).addClass("limitable"); - $(itemIdSel).addClass("limit-height"); + $item.wrap('
'); + $("#" + wrapperId).append(''); + $item.addClass("limitable limit-height"); - $(toggleIdSel).show(); - $(toggleIdSel).click(function(el) { - $(itemIdSel).toggleClass("limit-height"); - $(this).hide(); - $(itemIdSel).removeClass("limitable"); - }); + var $toggle = $("#" + toggleId); + $toggle.show(); + $toggle.click(function(el) { + $item.toggleClass("limit-height"); + $(this).hide(); + $item.removeClass("limitable"); + }); } -function processHeightLimit(id) { - var idSel = "#" + id; - - if (!$(idSel).hasClass("limitable")) { - return false; +function processHeightLimit($item) { + if (!$item.hasClass("limitable")) { + return false; } - - var itemId = $(idSel).data("item-id"); - var toggleSelector = "#wall-item-body-toggle-" + itemId; - if ($(idSel).height() < 250) { - $(idSel).removeClass("limit-height"); - $(toggleSelector).hide(); - return false; - } else { - $(idSel).addClass("limit-height"); - $(toggleSelector).show(); - return true; - } + var itemId = $item.data("item-id"); + var $toggle = $("#wall-item-body-toggle-" + itemId); + if ($item.height() < 250) { + $item.removeClass("limit-height"); + $toggle.hide(); + return false; + } else { + $item.addClass("limit-height"); + $toggle.show(); + return true; + } } diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index 9b0ec24e..4840201d 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -13,22 +13,22 @@ use Friendica\DI; function showmore_dyn_install() { Hook::register('head' , __FILE__, 'showmore_dyn_head'); - Hook::register('footer', __FILE__, 'showmore_dyn_footer'); + Hook::register('footer', __FILE__, 'showmore_dyn_footer'); } function showmore_dyn_uninstall() { Hook::unregister('head' , __FILE__, 'showmore_dyn_head'); - Hook::unregister('footer', __FILE__, 'showmore_dyn_footer'); + Hook::unregister('footer', __FILE__, 'showmore_dyn_footer'); } function showmore_dyn_head(App $a, &$b) { - DI::page()->registerStylesheet(__DIR__ . '/showmore_dyn.css'); + DI::page()->registerStylesheet(__DIR__ . '/showmore_dyn.css'); } function showmore_dyn_footer(App $a, &$b) { - DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js'); + DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js'); } -- 2.43.5 From ed45145415b2789f06632a9b75b53aa87c5e377e Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sat, 14 Mar 2020 22:09:30 +0100 Subject: [PATCH 04/19] #8374: Making postLimitHeight an addon parameter --- showmore_dyn/showmore_dyn.css | 5 ---- showmore_dyn/showmore_dyn.js | 6 ++++- showmore_dyn/showmore_dyn.php | 50 +++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/showmore_dyn/showmore_dyn.css b/showmore_dyn/showmore_dyn.css index 6f9d59bc..76bb7555 100644 --- a/showmore_dyn/showmore_dyn.css +++ b/showmore_dyn/showmore_dyn.css @@ -1,8 +1,3 @@ -.limit-height { - max-height: 250px; - overflow: hidden; -} - .wall-item-body-toggle { width: 100%; text-align: center; diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index 7d91c337..d60529d9 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -1,4 +1,8 @@ $(document).ready(function(){ + $("head").append(''); + var newStyleElement = $("head").children(':last'); + newStyleElement.html('.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden;}'); + handleNewWallItemBodies(); document.addEventListener("postprocess_liveupdate", function() { @@ -60,7 +64,7 @@ function processHeightLimit($item) { var itemId = $item.data("item-id"); var $toggle = $("#wall-item-body-toggle-" + itemId); - if ($item.height() < 250) { + if ($item.height() < postLimitHeight) { $item.removeClass("limit-height"); $toggle.hide(); return false; diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index 4840201d..b38231fa 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -9,17 +9,27 @@ use Friendica\App; use Friendica\Core\Hook; +use Friendica\Core\L10n; +use Friendica\Core\Logger; +use Friendica\Core\Renderer; +use Friendica\Database\DBA; use Friendica\DI; function showmore_dyn_install() { + Hook::register('page_end', 'addon/showmore_dyn.php/showmore_dyn.php', 'showmore_dyn_script'); Hook::register('head' , __FILE__, 'showmore_dyn_head'); Hook::register('footer', __FILE__, 'showmore_dyn_footer'); + Hook::register('addon_settings', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings'); + Hook::register('addon_settings_post', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings_post'); } function showmore_dyn_uninstall() { + Hook::unregister('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script'); Hook::unregister('head' , __FILE__, 'showmore_dyn_head'); Hook::unregister('footer', __FILE__, 'showmore_dyn_footer'); + Hook::unregister('addon_settings', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings'); + Hook::unregister('addon_settings_post', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings_post'); } function showmore_dyn_head(App $a, &$b) @@ -32,3 +42,43 @@ function showmore_dyn_footer(App $a, &$b) DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js'); } +function showmore_dyn_settings_post(){ + if(! local_user()) + return; + if (isset($_POST['showmore_dyn-submit'])){ + $limitHeight = $_POST['showmore_dyn_height']; + DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); + +/* + $str=file_get_contents('addon/showmore_dyn/showmore_dyn.css'); + $str=preg_replace("/(max-height: )\d+(px;)/i", "max-height: " . $limitHeight . "px;" ,$str); + file_put_contents('addon/showmore_dyn/showmore_dyn.css', $str); + + $str=file_get_contents('addon/showmore_dyn/showmore_dyn.js'); + $str=preg_replace('/if \(\$item.height\(\) \< \d+\) \{/i', 'if ($item.height() < ' . $limitHeight . ') {' ,$str); + file_put_contents('addon/showmore_dyn/showmore_dyn2.js', $str);*/ + } +} + +function showmore_dyn_settings(&$a,&$o) { + if(! local_user()) + return; + + + $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight' ); + if ($limitHeight=='') { $limitHeight = 250; DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); } + + $t = Renderer::getMarkupTemplate("settings.tpl", "addon/showmore_dyn/"); + $o .= Renderer::replaceMacros($t, [ + '$submit' => DI::l10n()->t('Save Settings'), + '$title' => "Showmore Dynamic", + '$label' => DI::l10n()->t('Limit Height'), + '$limitHeight' => $limitHeight, + ]); + +} + +function showmore_dyn_script() { + $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight' ); + DI::page()['htmlhead'] .= ''; +} -- 2.43.5 From b46a23eab3c37a50b109406167493a3a2414ab25 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sat, 14 Mar 2020 22:14:53 +0100 Subject: [PATCH 05/19] #8374: Adding missing settings template file; cleaning up addon code --- showmore_dyn/showmore_dyn.php | 9 --------- showmore_dyn/templates/settings.tpl | 12 ++++++++++++ 2 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 showmore_dyn/templates/settings.tpl diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index b38231fa..cfc8e937 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -48,15 +48,6 @@ function showmore_dyn_settings_post(){ if (isset($_POST['showmore_dyn-submit'])){ $limitHeight = $_POST['showmore_dyn_height']; DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); - -/* - $str=file_get_contents('addon/showmore_dyn/showmore_dyn.css'); - $str=preg_replace("/(max-height: )\d+(px;)/i", "max-height: " . $limitHeight . "px;" ,$str); - file_put_contents('addon/showmore_dyn/showmore_dyn.css', $str); - - $str=file_get_contents('addon/showmore_dyn/showmore_dyn.js'); - $str=preg_replace('/if \(\$item.height\(\) \< \d+\) \{/i', 'if ($item.height() < ' . $limitHeight . ') {' ,$str); - file_put_contents('addon/showmore_dyn/showmore_dyn2.js', $str);*/ } } diff --git a/showmore_dyn/templates/settings.tpl b/showmore_dyn/templates/settings.tpl new file mode 100644 index 00000000..2ef79c0a --- /dev/null +++ b/showmore_dyn/templates/settings.tpl @@ -0,0 +1,12 @@ +
+

{{$title}}

+
+ + +
+ +
+ +
+
+ -- 2.43.5 From 0ea84cfb66366edbbe333e9fe3db6a35d07a9c17 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sat, 14 Mar 2020 22:29:11 +0100 Subject: [PATCH 06/19] #8374: Using l10n --- showmore_dyn/showmore_dyn.js | 2 +- showmore_dyn/showmore_dyn.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index d60529d9..4442da76 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -45,7 +45,7 @@ function addHeightToggleHandler($item) { var toggleId = "wall-item-body-toggle-" + itemId; $item.wrap('
'); - $("#" + wrapperId).append(''); + $("#" + wrapperId).append(''); $item.addClass("limitable limit-height"); var $toggle = $("#" + toggleId); diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index cfc8e937..664049c6 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -71,5 +71,6 @@ function showmore_dyn_settings(&$a,&$o) { function showmore_dyn_script() { $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight' ); - DI::page()['htmlhead'] .= ''; + $showmore_dyn_showmore_linktext = DI::l10n()->t('Show more ...'); + DI::page()['htmlhead'] .= ''; } -- 2.43.5 From 28b9a8323d37ffc251ace8c3e572d34aa36db90a Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sat, 14 Mar 2020 22:31:13 +0100 Subject: [PATCH 07/19] #8374: Adding l10n strings --- showmore_dyn/lang/de/strings.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 showmore_dyn/lang/de/strings.php diff --git a/showmore_dyn/lang/de/strings.php b/showmore_dyn/lang/de/strings.php new file mode 100644 index 00000000..c35ec337 --- /dev/null +++ b/showmore_dyn/lang/de/strings.php @@ -0,0 +1,8 @@ +strings["Show more ..."] = "Mehr zeigen ..."; -- 2.43.5 From dd09acffbdc02b39d32d24cbc3a70b37b50cd294 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sat, 14 Mar 2020 22:58:25 +0100 Subject: [PATCH 08/19] #8374: Making link a button --- showmore_dyn/showmore_dyn.css | 8 ++++++++ showmore_dyn/showmore_dyn.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/showmore_dyn/showmore_dyn.css b/showmore_dyn/showmore_dyn.css index 76bb7555..e351594f 100644 --- a/showmore_dyn/showmore_dyn.css +++ b/showmore_dyn/showmore_dyn.css @@ -20,6 +20,14 @@ left: 0; text-shadow: 0 0 5px #f6f6f6; font-weight: bold; + + background: none!important; + border: none; + padding: 0!important; + cursor: pointer; +} +.wall-item-body-toggle-text:hover { + text-decoration:underline; } .wall-item-body { position: relative; diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index 4442da76..e03e34ae 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -45,7 +45,7 @@ function addHeightToggleHandler($item) { var toggleId = "wall-item-body-toggle-" + itemId; $item.wrap('
'); - $("#" + wrapperId).append(''); + $("#" + wrapperId).append('
'); $item.addClass("limitable limit-height"); var $toggle = $("#" + toggleId); -- 2.43.5 From 58030804cbd9b83e980af912e6c3a488335b532e Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sat, 14 Mar 2020 23:34:09 +0100 Subject: [PATCH 09/19] #8374: Fixing css indent; Making addon work with Vier theme --- showmore_dyn/showmore_dyn.css | 59 +++++++++++++++++------------------ showmore_dyn/showmore_dyn.js | 7 ++++- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/showmore_dyn/showmore_dyn.css b/showmore_dyn/showmore_dyn.css index e351594f..0e082e10 100644 --- a/showmore_dyn/showmore_dyn.css +++ b/showmore_dyn/showmore_dyn.css @@ -1,42 +1,41 @@ .wall-item-body-toggle { - width: 100%; - text-align: center; - background-image: linear-gradient(rgba(0,0,0,0), #f6f6f6); - cursor: pointer; - height: 50px; - position: absolute; - top: auto; - bottom: 0; - z-index: 11; - left: 0; - display: none; + width: 100%; + text-align: center; + background-image: linear-gradient(rgba(0,0,0,0), #f6f6f6); + cursor: pointer; + height: 50px; + position: absolute; + top: auto; + bottom: 0; + z-index: 11; + left: 0; + display: none; } .wall-item-body-toggle-text { - width: 100%; - position: absolute; - top: auto; - bottom: 0; - z-index: 12; - left: 0; - text-shadow: 0 0 5px #f6f6f6; - font-weight: bold; - - background: none!important; - border: none; - padding: 0!important; - cursor: pointer; + width: 100%; + position: absolute; + top: auto; + bottom: 0; + z-index: 12; + left: 0; + text-shadow: 0 0 5px #f6f6f6; + font-weight: bold; + background: none!important; + border: none; + padding: 0!important; + cursor: pointer; } .wall-item-body-toggle-text:hover { - text-decoration:underline; + text-decoration:underline; } .wall-item-body { - position: relative; - width: 100%; + position: relative; + width: 100%; } .wall-item-body-wrapper { - position: relative; - width: 100%; - display: inline-block; + position: relative; + width: 100%; + display: inline-block; } diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index e03e34ae..576d03f3 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -1,7 +1,9 @@ +var nextBodyIdx = 0; + $(document).ready(function(){ $("head").append(''); var newStyleElement = $("head").children(':last'); - newStyleElement.html('.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden;}'); + newStyleElement.html('.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden; display:inline-block;}'); handleNewWallItemBodies(); @@ -19,6 +21,9 @@ function handleNewWallItemBodies() { return; } + if (!$el.attr("id")) { + $el.attr("id", nextBodyIdx++); + } addHeightToggleHandler($el); var limited = processHeightLimit($el); -- 2.43.5 From c12e1256e4fa7c3758c69bc2e1d6e97a28652e5d Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sun, 15 Mar 2020 13:34:51 +0100 Subject: [PATCH 10/19] 8374: Addressing review comments --- showmore_dyn/showmore_dyn.css | 14 +++--- showmore_dyn/showmore_dyn.js | 17 ++++--- showmore_dyn/showmore_dyn.php | 76 +++++++++++++++-------------- showmore_dyn/templates/settings.tpl | 15 +++--- 4 files changed, 66 insertions(+), 56 deletions(-) diff --git a/showmore_dyn/showmore_dyn.css b/showmore_dyn/showmore_dyn.css index 0e082e10..3e41fd3d 100644 --- a/showmore_dyn/showmore_dyn.css +++ b/showmore_dyn/showmore_dyn.css @@ -1,7 +1,7 @@ .wall-item-body-toggle { width: 100%; text-align: center; - background-image: linear-gradient(rgba(0,0,0,0), #f6f6f6); + background-image: linear-gradient(rgba(0, 0, 0, 0), #f6f6f6); cursor: pointer; height: 50px; position: absolute; @@ -11,6 +11,7 @@ left: 0; display: none; } + .wall-item-body-toggle-text { width: 100%; position: absolute; @@ -20,22 +21,23 @@ left: 0; text-shadow: 0 0 5px #f6f6f6; font-weight: bold; - background: none!important; + background: none !important; border: none; - padding: 0!important; + padding: 0 !important; cursor: pointer; } + .wall-item-body-toggle-text:hover { - text-decoration:underline; + text-decoration: underline; } + .wall-item-body { position: relative; width: 100%; } + .wall-item-body-wrapper { position: relative; width: 100%; display: inline-block; } - - diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index 576d03f3..9864f24a 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -1,6 +1,6 @@ var nextBodyIdx = 0; -$(document).ready(function(){ +$(document).ready(function() { $("head").append(''); var newStyleElement = $("head").children(':last'); newStyleElement.html('.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden; display:inline-block;}'); @@ -28,15 +28,22 @@ function handleNewWallItemBodies() { var limited = processHeightLimit($el); if (!limited) { - var mutationObserver = new MutationObserver(function(mutations) { + var mutationObserver = new MutationObserver(function() { var limited = processHeightLimit($el); if (limited) { mutationObserver.disconnect() } }); - mutationObserver.observe($el[0], { attributes: true, characterData: true, childList: true, subtree: true, attributeOldValue: true, characterDataOldValue: true }); + mutationObserver.observe($el[0], { + attributes: true, + characterData: true, + childList: true, + subtree: true, + attributeOldValue: true, + characterDataOldValue: true + }); - $el.imagesLoaded().then(function(){ + $el.imagesLoaded().then(function() { processHeightLimit($el); }); } @@ -79,5 +86,3 @@ function processHeightLimit($item) { return true; } } - - diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index 664049c6..7e499bea 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -15,21 +15,13 @@ use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; -function showmore_dyn_install() { - Hook::register('page_end', 'addon/showmore_dyn.php/showmore_dyn.php', 'showmore_dyn_script'); - Hook::register('head' , __FILE__, 'showmore_dyn_head'); - Hook::register('footer', __FILE__, 'showmore_dyn_footer'); - Hook::register('addon_settings', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings'); - Hook::register('addon_settings_post', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings_post'); -} - -function showmore_dyn_uninstall() +function showmore_dyn_install() { - Hook::unregister('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script'); - Hook::unregister('head' , __FILE__, 'showmore_dyn_head'); - Hook::unregister('footer', __FILE__, 'showmore_dyn_footer'); - Hook::unregister('addon_settings', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings'); - Hook::unregister('addon_settings_post', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings_post'); + Hook::register('page_end', __FILE__, 'showmore_dyn_script'); + Hook::register('head', __FILE__, 'showmore_dyn_head'); + Hook::register('footer', __FILE__, 'showmore_dyn_footer'); + Hook::register('addon_settings', __FILE__, 'showmore_dyn_settings'); + Hook::register('addon_settings_post', __FILE__, 'showmore_dyn_settings_post'); } function showmore_dyn_head(App $a, &$b) @@ -42,35 +34,47 @@ function showmore_dyn_footer(App $a, &$b) DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js'); } -function showmore_dyn_settings_post(){ - if(! local_user()) - return; - if (isset($_POST['showmore_dyn-submit'])){ +function showmore_dyn_settings_post() +{ + if(!local_user()) { + return; + } + + if (isset($_POST['showmore_dyn-submit'])) { $limitHeight = $_POST['showmore_dyn_height']; - DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); - } + if ($limitHeight && is_numeric($limitHeight)) { + DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); + } + } } -function showmore_dyn_settings(&$a,&$o) { - if(! local_user()) - return; +function showmore_dyn_settings(&$a, &$o) +{ + if(!local_user()) { + return; + } + $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight', 250); + DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); - $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight' ); - if ($limitHeight=='') { $limitHeight = 250; DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); } - - $t = Renderer::getMarkupTemplate("settings.tpl", "addon/showmore_dyn/"); - $o .= Renderer::replaceMacros($t, [ - '$submit' => DI::l10n()->t('Save Settings'), - '$title' => "Showmore Dynamic", - '$label' => DI::l10n()->t('Limit Height'), - '$limitHeight' => $limitHeight, - ]); + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore_dyn/'); + $o .= Renderer::replaceMacros($t, [ + '$submit' => DI::l10n()->t('Save Settings'), + '$title' => 'Showmore Dynamic', + '$label' => DI::l10n()->t('Limit Height'), + '$limitHeight' => $limitHeight, + ]); } -function showmore_dyn_script() { - $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight' ); +function showmore_dyn_script() +{ + $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight', 250); $showmore_dyn_showmore_linktext = DI::l10n()->t('Show more ...'); - DI::page()['htmlhead'] .= ''; + DI::page()['htmlhead'] .= << + var postLimitHeight = $limitHeight; + var showmore_dyn_showmore_linktext = "$showmore_dyn_showmore_linktext"; + +EOT; } diff --git a/showmore_dyn/templates/settings.tpl b/showmore_dyn/templates/settings.tpl index 2ef79c0a..782d1fdf 100644 --- a/showmore_dyn/templates/settings.tpl +++ b/showmore_dyn/templates/settings.tpl @@ -1,12 +1,11 @@
-

{{$title}}

-
- +

{{$title}}

+
+ -
+
-
- -
+
+ +
- -- 2.43.5 From 30d35b835e3b289146fb47d58222620e264b9c31 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sun, 15 Mar 2020 13:38:57 +0100 Subject: [PATCH 11/19] #8374: Added function type hint --- showmore_dyn/showmore_dyn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index 7e499bea..41de11a3 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -48,7 +48,7 @@ function showmore_dyn_settings_post() } } -function showmore_dyn_settings(&$a, &$o) +function showmore_dyn_settings(App &$a, &$o) { if(!local_user()) { return; -- 2.43.5 From f4c141f2e79a3a5bd91af1282b3239aba12a3944 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sun, 15 Mar 2020 15:58:26 +0100 Subject: [PATCH 12/19] #8374: Added missing lang/C/messages.po file --- showmore_dyn/lang/C/messages.po | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 showmore_dyn/lang/C/messages.po diff --git a/showmore_dyn/lang/C/messages.po b/showmore_dyn/lang/C/messages.po new file mode 100644 index 00000000..ddd54701 --- /dev/null +++ b/showmore_dyn/lang/C/messages.po @@ -0,0 +1,30 @@ +# ADDON showmore_dyn +# Copyright (C) +# This file is distributed under the same license as the Friendica showmore_dyn addon package. +# +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-03-15 15:54+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: showmore_dyn.php:62 +msgid "Save Settings" +msgstr "" + +#: showmore_dyn.php:64 +msgid "Limit Height" +msgstr "" + +#: showmore_dyn.php:73 +msgid "Show more ..." +msgstr "" -- 2.43.5 From 1360efc93084c4f5ad087964e2dbce156514c2f7 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sun, 15 Mar 2020 21:18:29 +0100 Subject: [PATCH 13/19] #8374: Removed incorrect strings.php file --- showmore_dyn/lang/de/strings.php | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 showmore_dyn/lang/de/strings.php diff --git a/showmore_dyn/lang/de/strings.php b/showmore_dyn/lang/de/strings.php deleted file mode 100644 index c35ec337..00000000 --- a/showmore_dyn/lang/de/strings.php +++ /dev/null @@ -1,8 +0,0 @@ -strings["Show more ..."] = "Mehr zeigen ..."; -- 2.43.5 From 4d3aed3095767e56307613e2d43d59b95595096e Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sun, 15 Mar 2020 21:19:42 +0100 Subject: [PATCH 14/19] #8374: Using sub-templates for input field --- showmore_dyn/showmore_dyn.php | 4 ++-- showmore_dyn/templates/settings.tpl | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index 41de11a3..73eb7b17 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -41,7 +41,7 @@ function showmore_dyn_settings_post() } if (isset($_POST['showmore_dyn-submit'])) { - $limitHeight = $_POST['showmore_dyn_height']; + $limitHeight = $_POST['limitHeight']; if ($limitHeight && is_numeric($limitHeight)) { DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); } @@ -62,7 +62,7 @@ function showmore_dyn_settings(App &$a, &$o) '$submit' => DI::l10n()->t('Save Settings'), '$title' => 'Showmore Dynamic', '$label' => DI::l10n()->t('Limit Height'), - '$limitHeight' => $limitHeight, + '$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, 'The maximal height of posts when collapsed', '', '', 'number'], ]); } diff --git a/showmore_dyn/templates/settings.tpl b/showmore_dyn/templates/settings.tpl index 782d1fdf..5e8bc3f1 100644 --- a/showmore_dyn/templates/settings.tpl +++ b/showmore_dyn/templates/settings.tpl @@ -1,9 +1,6 @@

{{$title}}

-
- - -
+ {{include file="field_input.tpl" field=$limitHeight}}
-- 2.43.5 From 959f98e4763e907a05d4bddb3424b885e51d2aab Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Sun, 15 Mar 2020 21:21:39 +0100 Subject: [PATCH 15/19] #8374: Updating messages.po --- showmore_dyn/lang/C/messages.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/showmore_dyn/lang/C/messages.po b/showmore_dyn/lang/C/messages.po index ddd54701..0dc4d11c 100644 --- a/showmore_dyn/lang/C/messages.po +++ b/showmore_dyn/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-03-15 15:54+0100\n" +"POT-Creation-Date: 2020-03-15 21:20+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -21,7 +21,7 @@ msgstr "" msgid "Save Settings" msgstr "" -#: showmore_dyn.php:64 +#: showmore_dyn.php:64 showmore_dyn.php:65 msgid "Limit Height" msgstr "" -- 2.43.5 From b5056b11efaabca96b5b570e237b325ce7be5032 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Mon, 16 Mar 2020 16:20:32 +0100 Subject: [PATCH 16/19] #8374: Removed unnecessary template variable --- showmore_dyn/showmore_dyn.php | 1 - 1 file changed, 1 deletion(-) diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index 73eb7b17..32aedb08 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -61,7 +61,6 @@ function showmore_dyn_settings(App &$a, &$o) $o .= Renderer::replaceMacros($t, [ '$submit' => DI::l10n()->t('Save Settings'), '$title' => 'Showmore Dynamic', - '$label' => DI::l10n()->t('Limit Height'), '$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, 'The maximal height of posts when collapsed', '', '', 'number'], ]); -- 2.43.5 From f9e74a3c3427c4b4b93149e27f94e8b9eb1df5f5 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Tue, 17 Mar 2020 21:50:00 +0100 Subject: [PATCH 17/19] #8374: Removed wrapper and unnecessary css --- showmore_dyn/showmore_dyn.css | 25 ------------------------- showmore_dyn/showmore_dyn.js | 4 +--- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/showmore_dyn/showmore_dyn.css b/showmore_dyn/showmore_dyn.css index 3e41fd3d..f8c052a8 100644 --- a/showmore_dyn/showmore_dyn.css +++ b/showmore_dyn/showmore_dyn.css @@ -1,24 +1,11 @@ .wall-item-body-toggle { - width: 100%; text-align: center; background-image: linear-gradient(rgba(0, 0, 0, 0), #f6f6f6); cursor: pointer; height: 50px; - position: absolute; - top: auto; - bottom: 0; - z-index: 11; - left: 0; display: none; } - .wall-item-body-toggle-text { - width: 100%; - position: absolute; - top: auto; - bottom: 0; - z-index: 12; - left: 0; text-shadow: 0 0 5px #f6f6f6; font-weight: bold; background: none !important; @@ -26,18 +13,6 @@ padding: 0 !important; cursor: pointer; } - .wall-item-body-toggle-text:hover { text-decoration: underline; } - -.wall-item-body { - position: relative; - width: 100%; -} - -.wall-item-body-wrapper { - position: relative; - width: 100%; - display: inline-block; -} diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index 9864f24a..956ba2c1 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -53,11 +53,9 @@ function handleNewWallItemBodies() { function addHeightToggleHandler($item) { var itemId = parseInt($item.attr("id").replace("wall-item-body-", "")); $item.data("item-id", itemId); - var wrapperId = "wall-item-body-wrapper-" + itemId; var toggleId = "wall-item-body-toggle-" + itemId; - $item.wrap('
'); - $("#" + wrapperId).append('
'); + $item.append('
'); $item.addClass("limitable limit-height"); var $toggle = $("#" + toggleId); -- 2.43.5 From 15d3c2f78e3685a990db35794dbda0a9c81ad9ac Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Tue, 17 Mar 2020 22:27:48 +0100 Subject: [PATCH 18/19] #8374: Not triggering post height limit when showing individual post under /display --- showmore_dyn/showmore_dyn.css | 25 +++++++++++++++++++++++++ showmore_dyn/showmore_dyn.js | 7 ++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/showmore_dyn/showmore_dyn.css b/showmore_dyn/showmore_dyn.css index f8c052a8..3e41fd3d 100644 --- a/showmore_dyn/showmore_dyn.css +++ b/showmore_dyn/showmore_dyn.css @@ -1,11 +1,24 @@ .wall-item-body-toggle { + width: 100%; text-align: center; background-image: linear-gradient(rgba(0, 0, 0, 0), #f6f6f6); cursor: pointer; height: 50px; + position: absolute; + top: auto; + bottom: 0; + z-index: 11; + left: 0; display: none; } + .wall-item-body-toggle-text { + width: 100%; + position: absolute; + top: auto; + bottom: 0; + z-index: 12; + left: 0; text-shadow: 0 0 5px #f6f6f6; font-weight: bold; background: none !important; @@ -13,6 +26,18 @@ padding: 0 !important; cursor: pointer; } + .wall-item-body-toggle-text:hover { text-decoration: underline; } + +.wall-item-body { + position: relative; + width: 100%; +} + +.wall-item-body-wrapper { + position: relative; + width: 100%; + display: inline-block; +} diff --git a/showmore_dyn/showmore_dyn.js b/showmore_dyn/showmore_dyn.js index 956ba2c1..4b32b2d3 100644 --- a/showmore_dyn/showmore_dyn.js +++ b/showmore_dyn/showmore_dyn.js @@ -1,9 +1,14 @@ var nextBodyIdx = 0; $(document).ready(function() { + loc = window.location.pathname; + if (loc.startsWith('/display')) { + return; + } + $("head").append(''); var newStyleElement = $("head").children(':last'); - newStyleElement.html('.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden; display:inline-block;}'); + newStyleElement.html('.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden; }'); handleNewWallItemBodies(); -- 2.43.5 From 9497a598bbff935f60a804bcefdfea517891d7d7 Mon Sep 17 00:00:00 2001 From: Christian Wiwie Date: Tue, 17 Mar 2020 22:34:34 +0100 Subject: [PATCH 19/19] #8374: Removed wrapper from css --- showmore_dyn/showmore_dyn.css | 6 ------ 1 file changed, 6 deletions(-) diff --git a/showmore_dyn/showmore_dyn.css b/showmore_dyn/showmore_dyn.css index 3e41fd3d..93cc87a5 100644 --- a/showmore_dyn/showmore_dyn.css +++ b/showmore_dyn/showmore_dyn.css @@ -35,9 +35,3 @@ position: relative; width: 100%; } - -.wall-item-body-wrapper { - position: relative; - width: 100%; - display: inline-block; -} -- 2.43.5