Libraryless. Click here for Pure Java version (3574L/21K).
sclass HDivWithVerticalExpandButton { int initialHeight; S expandButtonText = "MORE"; O contents; S btnID = aGlobalID(); *(int *initialHeight, O *contents) {} *(int *initialHeight, O *contents, S *expandButtonText) {} S html() { ret hjs(expandVars("var pressed_$btnID = false;")) + div(contents, class := "expandable", style := "max-height: " + initialHeight + "px; overflow: hidden;") + "\n" + hbuttonOnClick_noSubmit(expandButtonText, expandVars([[ pressed_$btnID = true; $(this).prev('.expandable').css('max-height', 'none'); $(this).hide(); ]]), style := "display: none", id := btnID) + "\n" + hjs(expandVars([[ { let btn = $('#$btnID'); window.check_$btnID = function() { if (pressed_$btnID) return; $(btn).toggle($(btn).prev('.expandable').outerHeight() >= $initialHeight); setTimeout(check_$btnID, 5000); }; check_$btnID(); setTimeout(check_$btnID, 1000); } ]])); } S expandVars(S js) { ret replaceDollarVars(js, +btnID, +initialHeight); } bool needsJQuery() { true; } }
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031574 |
Snippet name: | HDivWithVerticalExpandButton |
Eternal ID of this version: | #1031574/25 |
Text MD5: | 0bc81eabcb1a454a81d86c9dd9e3327c |
Transpilation MD5: | a7653242da3d0f93b63dadc69df29c9a |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-22 07:04:58 |
Source code size: | 1200 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 242 / 475 |
Version history: | 24 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |