Right now the feed has 6 items and it looks good with a limit of 4. If I set the limit to 5, the 5th item will be partially displayed.
Sometimes the feed will contain an item with a very long description, and there will only be room for the first 2 items, and a 3rd item would be cut off.
Is there a way to get it to either show the entire <p> (if it will fit) or not show it at all (if it won’t fit)? If so, I wouldn’t need to limit the number of items shown.
Unfortunately, I don’t think there is an option that would calculate the string length and then adjust the number of items or to hide ‘too long’ items.
Hmm. It looks like there’s a way to use JavaScript to detect whether a given <p> is overflowing, and I’m sure there’s a way to use JavaScript to set those elements to use the style “display: none”. I guess I’ll have to learn how to use JavaScript to actually go through those elements one by one and hide those that overflow.
Well, I’m not sure I’m doing this right, but so far I haven’t even been able to get ‘hello world’ to show up in the console log. My ‘Optional JavaScript’ for this ticker is:
function EmbedInit()
{
console.log('Hello world');
return;
}
and the console log on the layout preview (http://hostname/layout/preview/layoutnumber) has plenty of cheerful debug messages but no ‘Hello world’. I’m using Google Chrome on Windows 10, if that matters.
function EmbedInit()
{
console.log('Hello world');
var x = $('div.previewContent div.item p');
var i;
var total = 0;
var maxheight = 400;
// once I have a proof of concept I'll figure out how to calculate the correct height
for (i = 0; i < x.length; i++) {
console.log('div ' + i + ' height: ' + x.elements[i].height);
total += x.elements[i].height;
console.log('New total height: ' + total);
if (total > maxheight) { x.elements[i].css({display: "none"}) }
}
return;
}