| 1236 | |
| 1237 | class ModeBarView { |
| 1238 | constructor() { |
| 1239 | let modeBar = this.element = $("mode-bar"); |
| 1240 | |
| 1241 | function addMode(id, text, active) { |
| 1242 | let div = document.createElement("div"); |
| 1243 | div.classList = "mode-button" + (active ? " active-mode-button" : ""); |
| 1244 | div.id = "mode-" + id; |
| 1245 | div.textContent = text; |
| 1246 | div.onclick = () => { |
| 1247 | if (main.currentState.mode === id) return; |
| 1248 | let old = $("mode-" + main.currentState.mode); |
| 1249 | old.classList = "mode-button"; |
| 1250 | div.classList = "mode-button active-mode-button"; |
| 1251 | main.setMode(id); |
| 1252 | }; |
| 1253 | modeBar.appendChild(div); |
| 1254 | } |
| 1255 | |
| 1256 | addMode("summary", "Summary", true); |
| 1257 | addMode("bottom-up", "Bottom up"); |
| 1258 | addMode("top-down", "Top down"); |
| 1259 | addMode("function-list", "Functions"); |
| 1260 | } |
| 1261 | |
| 1262 | render(newState) { |
| 1263 | if (!newState.file) { |