shorten_expanded: fix for posts without attachments

This commit is contained in:
Andrew Dolgov 2021-02-16 08:31:24 +03:00
parent 5c4223992f
commit 6e06fe2885
1 changed files with 8 additions and 5 deletions

View File

@ -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);
}