From d934830a64b915af0b7e8031cb5ef927534c5e86 Mon Sep 17 00:00:00 2001 From: RblSb Date: Tue, 25 Feb 2020 07:47:29 +0300 Subject: Improve login/exit and mob view --- src/client/Buttons.hx | 11 ++++++----- src/client/Main.hx | 6 ++++++ src/client/MobileView.hx | 21 ++++++++++----------- 3 files changed, 22 insertions(+), 16 deletions(-) (limited to 'src/client') diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx index 69928a5..51ba75d 100644 --- a/src/client/Buttons.hx +++ b/src/client/Buttons.hx @@ -172,19 +172,20 @@ class Buttons { final exitBtn = ge("#exitBtn"); exitBtn.onclick = e -> { - main.send({type: Logout}); + if (main.isUser()) main.send({type: Logout}); + else ge("#guestname").focus(); exitBtn.blur(); hideMenus(); } final swapLayoutBtn = ge("#swapLayoutBtn"); swapLayoutBtn.onclick = e -> { final p = ge("#main"); - p.insertBefore(p.children.item(2), p.children.item(0)); - p.insertBefore(p.children.item(2), p.children.item(1)); + p.insertBefore(p.children[2], p.children[0]); + p.insertBefore(p.children[2], p.children[1]); final p = ge("#controlsrow"); - p.insertBefore(p.children.item(1), p.children.item(0)); + p.insertBefore(p.children[1], p.children[0]); final p = ge("#playlistrow"); - p.insertBefore(p.children.item(1), p.children.item(0)); + p.insertBefore(p.children[1], p.children[0]); final swapped = ge("#main").firstElementChild == ge("#videowrap"); initSplit(swapped); swapLayoutBtn.blur(); diff --git a/src/client/Main.hx b/src/client/Main.hx index 70cc270..bfcc877 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -98,6 +98,10 @@ class Main { } } + public inline function isUser():Bool { + return personal.isUser; + } + public inline function isLeader():Bool { return personal.isLeader; } @@ -366,12 +370,14 @@ class Main { function showGuestLoginPanel():Void { ge("#guestlogin").style.display = "block"; ge("#chatline").style.display = "none"; + ge("#exitBtn").textContent = Lang.get("login"); Browser.window.dispatchEvent(new Event("resize")); } function hideGuestLoginPanel():Void { ge("#guestlogin").style.display = "none"; ge("#chatline").style.display = "block"; + ge("#exitBtn").textContent = Lang.get("exit"); if (isAdmin()) ge("#clearchatbtn").style.display = "inline-block"; Browser.window.dispatchEvent(new Event("resize")); } diff --git a/src/client/MobileView.hx b/src/client/MobileView.hx index ad788df..52d06f9 100644 --- a/src/client/MobileView.hx +++ b/src/client/MobileView.hx @@ -8,20 +8,19 @@ class MobileView { public static function init():Void { final mvbtn = ge("#mv_btn"); mvbtn.onclick = e -> { - final mobileView = Utils.toggleFullScreen(document.documentElement); - if (mobileView) { - document.body.classList.add('mobile-view'); - mvbtn.classList.add('active'); - final vwrap = ge("#videowrap"); - if (vwrap.children[0] == ge("currenttitle")) { + final hasMobileView = Utils.toggleFullScreen(document.documentElement); + final vwrap = ge("#videowrap"); + if (hasMobileView) { + document.body.classList.add("mobile-view"); + mvbtn.classList.add("active"); + if (vwrap.children[0].id == "currenttitle") { vwrap.appendChild(vwrap.children[0]); } } else { - document.body.classList.remove('mobile-view'); - mvbtn.classList.remove('active'); - final vwrap = ge("videowrap"); - if (vwrap.children[0] != ge("currenttitle")) { - vwrap.insertBefore(vwrap.children[1],vwrap.children[0]); + document.body.classList.remove("mobile-view"); + mvbtn.classList.remove("active"); + if (vwrap.children[0].id != "currenttitle") { + vwrap.insertBefore(vwrap.children[1], vwrap.children[0]); } } } -- cgit v1.2.3