sclass HDivWithVerticalExpandButton { int initialHeight; S expandButtonText = "Read more"; O contents; S btnID = aGlobalID(); *(int *initialHeight, O *contents) {} S html() { ret div(contents, class := "expandable", style := "padding: 20px 10px; max-height: " + initialHeight + "px; overflow: hidden;") + "\n" + hbutton(expandButtonText, onclick := [[ $(this).prev('.expandable').css('max-height', 'none'); $(this).hide(); ]], style := "display: none", id := btnID) + "\n" + hjs(replaceDollarVars([[ { let btn = $('#$btnID'); window.check_$btnID = function() { $(btn).toggle($(btn).prev('.expandable').outerHeight() >= $initialHeight); setTimeout(check_$btnID, 5000); }; check_$btnID(); setTimeout(check_$btnID, 1000); } ]], +btnID); } bool needsJQuery() { true; } }