refactoring

This commit is contained in:
Devaev Maxim 2021-04-13 10:14:27 +03:00
parent 6de0ee0017
commit 5dc123e186
6 changed files with 11 additions and 9 deletions

View File

@ -456,7 +456,7 @@
</div>
</li>
</ul>
<div class="window window-resizable" id="stream-window" data-close-confirm="Do you want to close the stream? This action will temporarily stop&lt;br&gt;the video transmission until you open the broadcast again.&lt;br&gt;This can be useful for saving traffic.">
<div class="window window-resizable" id="stream-window" data-close-confirm="Do you want to close the stream? This action will temporarily stop&lt;br&gt;the video transmission until you open the broadcast again.&lt;br&gt;This can be useful for saving traffic." data-show-by-button="show-stream-button">
<div class="window-header" id="stream-window-header">
<div class="window-grab">Stream</div>
<button class="window-button-close">&times;</button>
@ -494,7 +494,7 @@
</div>
</div>
</div>
<div class="window" id="keyboard-window">
<div class="window" id="keyboard-window" data-show-by-button="show-keyboard-button">
<div class="window-header" id="keyboard-window-header">
<div class="window-grab">Virtual Keyboard</div>
<button class="window-button-close">&times;</button>
@ -1338,7 +1338,7 @@
</div>
</div>
</div>
<div class="window" id="about-window">
<div class="window" id="about-window" data-show-by-button="show-about-button">
<div class="window-header">
<div class="window-grab">About</div>
<button class="window-button-close">&times;</button>

View File

@ -9,7 +9,7 @@ mixin about_tab(name, title, checked=false)
else
span(class="code-comment") No data
div(id="about-window" class="window")
div(id="about-window" class="window" data-show-by-button="show-about-button")
div(class="window-header")
div(class="window-grab") About
button(class="window-button-close") &times;

View File

@ -15,7 +15,7 @@ mixin empty_key(width=0)
mixin lamp(cls)
img(class=`inline-lamp ${cls} led-gray` src=`${svg_dir}/led-square.svg`)
div(id="keyboard-window" class="window")
div(id="keyboard-window" class="window" data-show-by-button="show-keyboard-button")
div(id="keyboard-window-header" class="window-header")
div(class="window-grab") Virtual Keyboard
button(class="window-button-close") &times;

View File

@ -2,7 +2,7 @@
- confirm_msg += "the video transmission until you open the broadcast again.<br>";
- confirm_msg += "This can be useful for saving traffic.";
div(id="stream-window" class="window window-resizable" data-close-confirm=confirm_msg)
div(id="stream-window" class="window window-resizable" data-close-confirm=confirm_msg data-show-by-button="show-stream-button")
div(id="stream-window-header" class="window-header")
div(class="window-grab") Stream
button(class="window-button-close") &times;

View File

@ -40,9 +40,6 @@ export function main() {
initWindowManager();
tools.setOnClick($("show-about-button"), () => wm.showWindow($("about-window")));
tools.setOnClick($("show-keyboard-button"), () => wm.showWindow($("keyboard-window")));
tools.setOnClick($("show-stream-button"), () => wm.showWindow($("stream-window")));
tools.setOnClick($("open-log-button"), () => window.open("/api/log?seek=3600&follow=1", "_blank"));
wm.showWindow($("stream-window"));

View File

@ -63,6 +63,11 @@ function __WindowManager() {
__makeWindowMovable(el_window);
__windows.push(el_window);
if (el_window.hasAttribute("data-show-by-button")) {
let el_show_button = $(el_window.getAttribute("data-show-by-button"));
tools.setOnClick(el_show_button, () => self.showWindow(el_window));
}
if (el_window.classList.contains("window-resizable") && window.ResizeObserver) {
new ResizeObserver(function() {
// При переполнении рабочей области сократить размер окна по высоте.