mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
deminify sections of the navbar code and fix logout button
This commit is contained in:
parent
1b95ca7d14
commit
5ed8dbe9c3
2 changed files with 31 additions and 12 deletions
|
@ -2,19 +2,22 @@ define(["browser", "dom", "css!./navdrawer", "scrollStyles"], function(browser,
|
||||||
"use strict";
|
"use strict";
|
||||||
return function(options) {
|
return function(options) {
|
||||||
function getTouches(e) {
|
function getTouches(e) {
|
||||||
return e.changedTouches || e.targetTouches || e.touches
|
return e.changedTouches || e.targetTouches || e.touches;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMenuTouchStart(e) {
|
function onMenuTouchStart(e) {
|
||||||
options.target.classList.remove("transition");
|
options.target.classList.remove("transition");
|
||||||
var touches = getTouches(e),
|
var touches = getTouches(e);
|
||||||
touch = touches[0] || {};
|
var touch = touches[0] || {};
|
||||||
menuTouchStartX = touch.clientX, menuTouchStartY = touch.clientY, menuTouchStartTime = (new Date).getTime()
|
|
||||||
|
menuTouchStartX = touch.clientX;
|
||||||
|
menuTouchStartY = touch.clientY;
|
||||||
|
menuTouchStartTime = (new Date).getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVelocity(deltaX) {
|
function setVelocity(deltaX) {
|
||||||
var time = (new Date).getTime() - (menuTouchStartTime || 0);
|
var time = (new Date).getTime() - (menuTouchStartTime || 0);
|
||||||
velocity = Math.abs(deltaX) / time
|
velocity = Math.abs(deltaX) / time;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMenuTouchMove(e) {
|
function onMenuTouchMove(e) {
|
||||||
|
@ -29,25 +32,41 @@ define(["browser", "dom", "css!./navdrawer", "scrollStyles"], function(browser,
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMenuTouchEnd(e) {
|
function onMenuTouchEnd(e) {
|
||||||
options.target.classList.add("transition"), scrollContainer.removeEventListener("scroll", disableEvent), dragMode = 0;
|
options.target.classList.add("transition");
|
||||||
|
scrollContainer.removeEventListener("scroll", disableEvent);
|
||||||
|
dragMode = 0;
|
||||||
|
|
||||||
var touches = getTouches(e),
|
var touches = getTouches(e),
|
||||||
touch = touches[0] || {},
|
touch = touches[0] || {},
|
||||||
endX = touch.clientX || 0,
|
endX = touch.clientX || 0,
|
||||||
endY = touch.clientY || 0,
|
endY = touch.clientY || 0,
|
||||||
deltaX = endX - (menuTouchStartX || 0),
|
deltaX = endX - (menuTouchStartX || 0),
|
||||||
deltaY = endY - (menuTouchStartY || 0);
|
deltaY = endY - (menuTouchStartY || 0);
|
||||||
currentPos = deltaX, self.checkMenuState(deltaX, deltaY)
|
|
||||||
|
currentPos = deltaX;
|
||||||
|
self.checkMenuState(deltaX, deltaY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEdgeTouchStart(e) {
|
function onEdgeTouchStart(e) {
|
||||||
if (isPeeking) onMenuTouchMove(e);
|
if (isPeeking) {
|
||||||
else {
|
onMenuTouchMove(e);
|
||||||
((getTouches(e)[0] || {}).clientX || 0) <= options.handleSize && (isPeeking = !0, "touchstart" === e.type && (dom.removeEventListener(edgeContainer, "touchmove", onEdgeTouchMove, {}), dom.addEventListener(edgeContainer, "touchmove", onEdgeTouchMove, {})), onMenuTouchStart(e))
|
} else {
|
||||||
|
if (((getTouches(e)[0] || {}).clientX || 0) <= options.handleSize) {
|
||||||
|
isPeeking = true;
|
||||||
|
if (e.type === "touchstart") {
|
||||||
|
dom.removeEventListener(edgeContainer, "touchmove", onEdgeTouchMove, {});
|
||||||
|
dom.addEventListener(edgeContainer, "touchmove", onEdgeTouchMove, {});
|
||||||
|
}
|
||||||
|
onMenuTouchStart(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEdgeTouchMove(e) {
|
function onEdgeTouchMove(e) {
|
||||||
onEdgeTouchStart(e), e.preventDefault(), e.stopPropagation()
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
onEdgeTouchStart(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEdgeTouchEnd(e) {
|
function onEdgeTouchEnd(e) {
|
||||||
|
|
|
@ -117,7 +117,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
|
||||||
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" data-itemid="selectserver" href="selectserver.html?showuser=1"><i class="md-icon navMenuOptionIcon"></i><span class="navMenuOptionText">' + globalize.translate("ButtonSelectServer") + "</span></a>";
|
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" data-itemid="selectserver" href="selectserver.html?showuser=1"><i class="md-icon navMenuOptionIcon"></i><span class="navMenuOptionText">' + globalize.translate("ButtonSelectServer") + "</span></a>";
|
||||||
}
|
}
|
||||||
// null check for local user might not be required
|
// null check for local user might not be required
|
||||||
if (user.localUser && user.localUser.EnableAutoLogin) {
|
if (user.localUser && !user.localUser.EnableAutoLogin) {
|
||||||
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder btnLogout" data-itemid="logout" href="#"><i class="md-icon navMenuOptionIcon"></i><span class="navMenuOptionText">' + globalize.translate("ButtonSignOut") + "</span></a>";
|
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder btnLogout" data-itemid="logout" href="#"><i class="md-icon navMenuOptionIcon"></i><span class="navMenuOptionText">' + globalize.translate("ButtonSignOut") + "</span></a>";
|
||||||
}
|
}
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue