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).

1  
// see JSPanel.de
2  
3  
sclass JSPanel {
4  
  new LS headStuff;
5  
  LS defaultIconFont;
6  
  
7  
  sclass HeaderControls {
8  
    Map add;
9  
    S smallify; // e.g. "remove"
10  
    
11  
    Map asMap() {
12  
      ret mapValues_withoutNulls nullIfEmpty_gen(litorderedmap(
13  
        +add,
14  
        +smallify
15  
      ));
16  
    }
17  
  }
18  
  
19  
  class Options {
20  
    S headerTitle = null;
21  
    new LS contents; // HTML content
22  
    S theme; // e.g. "info"
23  
    S overflow; // e.g. "hidden"
24  
    S border; // e.g. "thick dashed orange"
25  
    HeaderControls headerControls;
26  
    LS iconfont = defaultIconFont;
27  
    
28  
    Map asMap() {
29  
      ret mapValues_withoutNulls nullIfEmpty_gen(litorderedmap(
30  
        +headerTitle,
31  
        content := lines_rtrim(contents),
32  
        +theme,
33  
        +overflow,
34  
        +border,
35  
        headerControls := headerControls?.asMap(),
36  
        +iconfont,
37  
      ));
38  
    }
39  
    
40  
    HeaderControls headerControls() {
41  
      ret headerControls == null ? (headerControls = new HeaderControls) : headerControls;
42  
    }
43  
  }
44  
  
45  
  Options newOptions() { ret new Options; }
46  
  
47  
  *() {
48  
    smallerControls();
49  
  }
50  
  
51  
  void smallerControls() {
52  
    setAdd(headStuff, hcss([[
53  
      /* CSS for custom controls */
54  
      .custom-control-icon.custom-smallify::before{
55  
          content: "\025B4";
56  
          /*content: url(../../images/close16x16.png);*/
57  
      }
58  
      .custom-control-icon.custom-minimize::before { content: "\0268A"; }
59  
      .custom-control-icon.custom-normalize::before{ content: "\02750"; }
60  
      .custom-control-icon.custom-maximize::before{ content: "\02610"; }
61  
      .custom-control-icon.custom-close::before{ content: "\02715"; }
62  
    ]]));
63  
    defaultIconFont = splitAtSpace("custom-smallify custom-minimize custom-normalize custom-maximize custom-close");
64  
  }
65  
  
66  
  // expression to create this panel
67  
  JS createPanel(Options options default null) {
68  
    ret JS("jsPanel.create($options)", options := or(options, newOptions()).asMap());
69  
  }
70  
  
71  
  S headStuff() {
72  
    ret nemptyLines_flattenLists(
73  
      hlink("https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/jspanel.css"),
74  
      hlink("https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/jspanel.js"),
75  
      headStuff);
76  
  }
77  
  
78  
ifdef guggida
79  
/*<!-- optional jsPanel extensions -->
80  
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/modal/jspanel.modal.js"></script>
81  
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/tooltip/jspanel.tooltip.js"></script>
82  
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/hint/jspanel.hint.js"></script>
83  
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/layout/jspanel.layout.js"></script>
84  
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/contextmenu/jspanel.contextmenu.js"></script>
85  
<script src="https://cdn.jsdelivr.net/npm/jspanel4@4.12.0/dist/extensions/dock/jspanel.dock.js"></script>*/
86  
endifdef
87  
88  
}

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: 225 / 418
Version history: 28 change(s)
Referenced in: [show references]