Libraryless. Click here for Pure Java version (3574L/21K).
1 | sclass HDivWithVerticalExpandButton {
|
2 | int initialHeight; |
3 | S expandButtonText = "MORE"; |
4 | O contents; |
5 | S btnID = aGlobalID(); |
6 | |
7 | *(int *initialHeight, O *contents) {}
|
8 | *(int *initialHeight, O *contents, S *expandButtonText) {}
|
9 | |
10 | S html() {
|
11 | ret hjs(expandVars("var pressed_$btnID = false;"))
|
12 | + div(contents, class := "expandable", |
13 | style := "max-height: " + initialHeight + "px; overflow: hidden;") + "\n" |
14 | + hbuttonOnClick_noSubmit(expandButtonText, expandVars([[ |
15 | pressed_$btnID = true; |
16 | $(this).prev('.expandable').css('max-height', 'none');
|
17 | $(this).hide(); |
18 | ]]), style := "display: none", id := btnID) + "\n" |
19 | + hjs(expandVars([[ |
20 | {
|
21 | let btn = $('#$btnID');
|
22 | window.check_$btnID = function() {
|
23 | if (pressed_$btnID) return; |
24 | $(btn).toggle($(btn).prev('.expandable').outerHeight() >= $initialHeight);
|
25 | setTimeout(check_$btnID, 5000); |
26 | }; |
27 | check_$btnID(); setTimeout(check_$btnID, 1000); |
28 | } |
29 | ]])); |
30 | } |
31 | |
32 | S expandVars(S js) { ret replaceDollarVars(js, +btnID, +initialHeight); }
|
33 | |
34 | bool needsJQuery() { true; }
|
35 | } |
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: | 479 / 753 |
| Version history: | 24 change(s) |
| Referenced in: | [show references] |