summaryrefslogtreecommitdiff
path: root/plugins/shorten_expanded
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-16 08:31:24 +0300
committerAndrew Dolgov <[email protected]>2021-02-16 08:31:24 +0300
commit6e06fe2885f2250d446d613215dbadf63d08a766 (patch)
tree29e47a2e9bccf70b46b8f624bbafe0c329bfd88e /plugins/shorten_expanded
parent5c4223992fdd8d9046213ea9ed4b3c447a653031 (diff)
shorten_expanded: fix for posts without attachments
Diffstat (limited to 'plugins/shorten_expanded')
-rw-r--r--plugins/shorten_expanded/init.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js
index 181e426a4..873749c03 100644
--- a/plugins/shorten_expanded/init.js
+++ b/plugins/shorten_expanded/init.js
@@ -25,20 +25,23 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
if (row) {
const content = row.querySelector(".content-inner");
- const attachments = row.querySelector(".attachments-inline");
- if (content && attachments &&
- row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) {
+ //console.log('shorten', row.offsetHeight, 'vs', _shorten_expanded_threshold * window.innerHeight);
+
+ if (content && row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) {
+
+ const attachments = row.querySelector(".attachments-inline"); // optional
content.innerHTML = `
<div class="content-shrink-wrap">
${content.innerHTML}
- ${attachments.innerHTML}
+ ${attachments ? attachments.innerHTML : ''}
</div>
<button dojoType="dijit.form.Button" class="alt-info expand-prompt" onclick="return Plugins.Shorten_Expanded.expand('${row.id}')" href="#">
${__("Click to expand article")}</button>`;
- attachments.innerHTML = "";
+ if (attachments)
+ attachments.innerHTML = "";
dojo.parser.parse(content);
}