()
| 357 | } |
| 358 | |
| 359 | function initVisor() { |
| 360 | if (state.isVisorInitiated) { |
| 361 | return; |
| 362 | } |
| 363 | state.isVisorInitiated = true; |
| 364 | |
| 365 | // Bind an event to visor's 'Maximize/Minimize' button. |
| 366 | const visorFullScreenButton = |
| 367 | tfvis.visor().el.getElementsByTagName('button')[0]; |
| 368 | const guiCloseButton = document.getElementsByClassName('close-button')[0]; |
| 369 | const originalGuiWidth = gui.domElement.style.width; |
| 370 | |
| 371 | // The following two bound events are to implemet: |
| 372 | // - When the visor is minimized, the controlled panel is hidden; |
| 373 | // - When the visor is maximized, the controlled panel appears; |
| 374 | gui.domElement.style.width = originalGuiWidth; |
| 375 | visorFullScreenButton.onclick = () => { |
| 376 | if (state.isDatGuiHidden) { |
| 377 | // When opening the controll panel, recover the size. |
| 378 | gui.open(); |
| 379 | gui.domElement.style.width = originalGuiWidth; |
| 380 | } else { |
| 381 | // When closing the controll panel, narrow the size. |
| 382 | gui.close(); |
| 383 | gui.domElement.style.width = '10%'; |
| 384 | } |
| 385 | state.isDatGuiHidden = !state.isDatGuiHidden; |
| 386 | }; |
| 387 | guiCloseButton.onclick = () => { |
| 388 | if (state.isDatGuiHidden) { |
| 389 | // When opening the controll panel, recover the size. |
| 390 | gui.domElement.style.width = originalGuiWidth; |
| 391 | } else { |
| 392 | // When closing the controll panel, narrow the size. |
| 393 | gui.domElement.style.width = '10%'; |
| 394 | } |
| 395 | tfvis.visor().toggleFullScreen(); |
| 396 | state.isDatGuiHidden = !state.isDatGuiHidden; |
| 397 | }; |
| 398 | |
| 399 | // If this button (hide visor) is exposed, then too much extra logics will be |
| 400 | // needed to tell the full story. |
| 401 | const visorHideButton = tfvis.visor().el.getElementsByTagName('button')[1]; |
| 402 | visorHideButton.style.display = 'none'; |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * Generate a unique id/name for the given setting. tfvis uses tab name as the |
no test coverage detected
searching dependent graphs…