Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1030832 // HTMLTree

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3342L/20K).

// super-simple HTML tree with expandable/collapsible nodes
sclass HTMLTree {
  S headStuff() {
    ret loadJQuery2() + hcss([[
      .tree-toggler {
        display: inline-block;
        height: 1.3em;
        width: 0.7em;
        background: cornflowerblue;
        padding-left: 0.5em;
        padding-right: 0.5em;
        /*line-height: 50px; */
        text-align: center;
      }
      
      .tree-toggler a {
        text-decoration: none;
      }
    ]]) + hjs([[
      function tree_expandCollapse(id) {
        var children = $("#" + id);
        children.toggle();
        var vis = children.is(':visible');
        $("#" + id + "_toggle a").html(vis ? "&ndash;" : "+");
      }
    ]]);
  }
  
  S root(S contents) {
    ret ul(contents);
  }
  
  S node(S nodeHTML, S... children) {
    S id = aGlobalID();
    ret div(
      ahref_javascript(
        "tree_expandCollapse(" + jsQuote(id) + ");",
        "+"),
        class := "tree-toggler", id := id + "_toggle")
      + " " + nodeHTML
      + ul(asList(children), +id, style := "display: none");
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030832
Snippet name: HTMLTree
Eternal ID of this version: #1030832/2
Text MD5: 43f27219935356f599911c87b33374c0
Transpilation MD5: cd2b2e0d0e6aab43f7440777bcd066e9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-01 16:06:49
Source code size: 1114 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 214 / 412
Version history: 1 change(s)
Referenced in: [show references]