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

88
LINES

< > BotCompany Repo | #1032733 // JSPanel

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

Libraryless. Click here for Pure Java version (18935L/117K).

// see JSPanel.de

sclass JSPanel {
  new LS headStuff;
  LS defaultIconFont;
  
  sclass HeaderControls {
    Map add;
    S smallify; // e.g. "remove"
    
    Map asMap() {
      ret mapValues_withoutNulls nullIfEmpty_gen(litorderedmap(
        +add,
        +smallify
      ));
    }
  }
  
  class Options {
    S headerTitle = null;
    new LS contents; // HTML content
    S theme; // e.g. "info"
    S overflow; // e.g. "hidden"
    S border; // e.g. "thick dashed orange"
    HeaderControls headerControls;
    LS iconfont = defaultIconFont;
    
    Map asMap() {
      ret mapValues_withoutNulls nullIfEmpty_gen(litorderedmap(
        +headerTitle,
        content := lines_rtrim(contents),
        +theme,
        +overflow,
        +border,
        headerControls := headerControls?.asMap(),
        +iconfont,
      ));
    }
    
    HeaderControls headerControls() {
      ret headerControls == null ? (headerControls = new HeaderControls) : headerControls;
    }
  }
  
  Options newOptions() { ret new Options; }
  
  *() {
    smallerControls();
  }
  
  void smallerControls() {
    setAdd(headStuff, hcss([[
      /* CSS for custom controls */
      .custom-control-icon.custom-smallify::before{
          content: "\025B4";
          /*content: url(../../images/close16x16.png);*/
      }
      .custom-control-icon.custom-minimize::before { content: "\0268A"; }
      .custom-control-icon.custom-normalize::before{ content: "\02750"; }
      .custom-control-icon.custom-maximize::before{ content: "\02610"; }
      .custom-control-icon.custom-close::before{ content: "\02715"; }
    ]]));
    defaultIconFont = splitAtSpace("custom-smallify custom-minimize custom-normalize custom-maximize custom-close");
  }
  
  // expression to create this panel
  JS createPanel(Options options default null) {
    ret JS("jsPanel.create($options)", options := or(options, newOptions()).asMap());
  }
  
  S headStuff() {
    ret nemptyLines_flattenLists(
      hlink("https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/jspanel.css"),
      hlink("https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/jspanel.js"),
      headStuff);
  }
  
ifdef guggida
/*<!-- optional jsPanel extensions -->
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/modal/jspanel.modal.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/tooltip/jspanel.tooltip.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/hint/jspanel.hint.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/layout/jspanel.layout.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/contextmenu/jspanel.contextmenu.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/dock/jspanel.dock.js"></script>*/
endifdef

}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032733
Snippet name: JSPanel
Eternal ID of this version: #1032733/29
Text MD5: 080682e13a80d18186d5afd3029355b5
Transpilation MD5: 13da7b16ff82fcf917a9c7069619aae5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-04 04:49:07
Source code size: 2962 bytes / 88 lines
Pitched / IR pitched: No / No
Views / Downloads: 223 / 414
Version history: 28 change(s)
Referenced in: [show references]