|
69 | 69 | margin-left: 0.3em; |
70 | 70 | } |
71 | 71 | #cy-panel { |
| 72 | + margin-top: 2.5em; |
72 | 73 | width: 0.1em; |
73 | 74 | flex: 0 0 auto; |
74 | 75 | {% if full_or_widget == 'widget' %} |
|
78 | 79 | width: 20em; |
79 | 80 | {% endif %} |
80 | 81 | } |
| 82 | +#search-input { |
| 83 | + font-size: 105%; |
| 84 | +} |
81 | 85 | #cy-panel-contents { |
82 | 86 | display: block; |
83 | 87 | } |
|
86 | 90 | flex: 0 0 auto; |
87 | 91 | } |
88 | 92 | #node-details { |
89 | | - padding: 2em 0 0 0.2em; |
| 93 | + padding: 0.2em 0 0 0.2em; |
90 | 94 | {% if full_or_widget == 'widget' %} |
91 | 95 | height: 200px; |
92 | 96 | {% endif %} |
|
233 | 237 |
|
234 | 238 | delete elements['models']; |
235 | 239 |
|
| 240 | +const isSmallJoin = models.length <= 10; |
| 241 | + |
| 242 | +const nodes = elements['nodes']; |
| 243 | + |
236 | 244 | const geneInfoMap = elements['gene_info_map']; |
237 | 245 | delete elements['gene_info_map']; |
238 | 246 |
|
|
246 | 254 | let seenParentIds = new Set(); |
247 | 255 |
|
248 | 256 |
|
249 | | -elements['nodes'].map(node => { |
| 257 | +nodes.map(node => { |
250 | 258 | if (node.data.parent) { |
251 | 259 | seenParentIds.add(node.data.parent); |
252 | 260 | } |
|
606 | 614 | 'corner-radius': "10", |
607 | 615 | 'padding': "10px", |
608 | 616 | 'content': "data(title)", |
609 | | - 'border-width': '2px', |
| 617 | + 'border-width': function(el) { |
| 618 | + let width = 2; |
| 619 | + if (isSelected(el)) { |
| 620 | + width = 6; |
| 621 | + width += models.length / 8; |
| 622 | + } |
| 623 | + return width; |
| 624 | + }, |
| 625 | + |
610 | 626 | 'border-color': '#555', |
611 | 627 | }; |
612 | 628 |
|
|
974 | 990 | } |
975 | 991 | } |
976 | 992 |
|
977 | | - elements['nodes'].map(node => { |
| 993 | + nodes.map(node => { |
978 | 994 | if (node.data.enabler_id && |
979 | 995 | rawHighlightGeneIds.length == 1 && |
980 | 996 | rawHighlightGeneIds[0] == node.data.enabler_id.replace(/.*:/, '')) { |
|
1000 | 1016 | updateDetails(); |
1001 | 1017 | }); |
1002 | 1018 |
|
| 1019 | + const searchBoxDiv = document.getElementById('search-box'); |
| 1020 | + window.showSearch = function() { |
| 1021 | + if (searchBoxDiv.style.display == 'none') { |
| 1022 | + searchBoxDiv.style.display = 'block'; |
| 1023 | + } else { |
| 1024 | + searchBoxDiv.style.display = 'none'; |
| 1025 | + } |
| 1026 | + } |
| 1027 | + |
| 1028 | + const doSearch = (searchText) => { |
| 1029 | + for (const node of nodes) { |
| 1030 | + if (isSmallJoin && |
| 1031 | + (node.data.enabler_label && |
| 1032 | + node.data.enabler_label.toLowerCase().includes(searchText) || |
| 1033 | + node.data.enabler_id && |
| 1034 | + node.data.enabler_id.toLowerCase().includes(searchText) || |
| 1035 | + node.data.label && |
| 1036 | + node.data.label.toLowerCase().includes(searchText) || |
| 1037 | + node.data.node_id && |
| 1038 | + node.data.node_id.toLowerCase().includes(searchText)) || |
| 1039 | + node.data.type == 'model' && |
| 1040 | + (node.data.label.includes(searchText) || |
| 1041 | + node.data.id == 'gomodel:' + searchText)) { |
| 1042 | + currentData = node.data; |
| 1043 | + cy.getElementById(node.data.id).select(); |
| 1044 | + break; |
| 1045 | + } |
| 1046 | + } |
| 1047 | + updateDetails(); |
| 1048 | + }; |
| 1049 | + |
| 1050 | + const searchInput = document.getElementById('search-input'); |
| 1051 | + searchInput.addEventListener("input", (e) => { |
| 1052 | + const searchText = e.target.value.trim().toLowerCase(); |
| 1053 | + cy.$().unselect(); |
| 1054 | + currentData = undefined; |
| 1055 | + if (searchText.length >= 2) { |
| 1056 | + doSearch(searchText); |
| 1057 | + } |
| 1058 | + }); |
| 1059 | + |
1003 | 1060 | }); |
1004 | 1061 | </script> |
1005 | 1062 |
|
1006 | 1063 | <div id="cy-container"> |
1007 | 1064 | <div id="cy"></div> |
1008 | 1065 | <div id="panel-buttons"> |
| 1066 | +{% if full_or_widget == 'full' %} |
| 1067 | + <button id="show-search" title="Search" onclick="showSearch()"> |
| 1068 | + <img width="16px" height="16px" src='data:image/svg+xml;charset=utf-8,<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg fill="%23000000" height="10mm" width="10mm" viewBox="0 0 500 500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <g> <path d="M483.4,454.444l-121.3-121.4c28.7-35.2,46-80,46-128.9c0-112.5-91.5-204.1-204.1-204.1S0,91.644,0,204.144 s91.5,204,204.1,204c48.8,0,93.7-17.3,128.9-46l121.3,121.3c8.3,8.3,20.9,8.3,29.2,0S491.8,462.744,483.4,454.444z M40.7,204.144 c0-90.1,73.2-163.3,163.3-163.3s163.4,73.3,163.4,163.4s-73.3,163.4-163.4,163.4S40.7,294.244,40.7,204.144z"/> </g> </svg>'/> |
| 1069 | + </button> |
| 1070 | +{% endif %} |
1009 | 1071 | <button id="zoom-out" title="Zoom out" onclick="modelZoomOut()"> |
1010 | 1072 | {% if full_or_widget == 'widget' %} |
1011 | 1073 | - |
|
1029 | 1091 | <button id="save-svg-button" target="_blank" onclick="window.open(getSvgUrl(), '_blank')">View as SVG</button> |
1030 | 1092 | </div> |
1031 | 1093 | <div id="cy-panel"> |
| 1094 | +{% if full_or_widget == 'full' %} |
| 1095 | + <div id="search-box" style="display: none"> |
| 1096 | + <input id="search-input" placeholder="Search ..."/> |
| 1097 | + </div> |
| 1098 | +{% endif %} |
1032 | 1099 | <div id="cy-panel-contents"> |
1033 | 1100 | <div id="node-details"> |
1034 | 1101 |
|
|
0 commit comments