aboutsummaryrefslogtreecommitdiffstats
path: root/res/client.js
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-05-23 20:31:40 +0300
committerRblSb <msrblsb@gmail.com>2020-05-23 21:15:02 +0300
commita45d0bef0dccb5472bec095d8e00af8647173a56 (patch)
tree356402681516062441c5a61cf9d0cf979ae63ee1 /res/client.js
parent306b5f4194ae40e80f3be00fcfea8614792649a5 (diff)
Restore mobile view
Diffstat (limited to 'res/client.js')
-rw-r--r--res/client.js56
1 files changed, 34 insertions, 22 deletions
diff --git a/res/client.js b/res/client.js
index 20d7eeb..978a7aa 100644
--- a/res/client.js
+++ b/res/client.js
@@ -509,8 +509,13 @@ client_Buttons.init = function(main) {
main.refreshPlayer();
};
window.document.querySelector("#fullscreenbtn").onclick = function(e) {
- return client_Utils.toggleFullScreen(window.document.querySelector("#ytapiplayer"));
+ if(client_Utils.isTouch() && !client_Utils.hasFullscreen()) {
+ return client_Utils.requestFullscreen(window.document.documentElement);
+ } else {
+ return client_Utils.requestFullscreen(window.document.querySelector("#ytapiplayer"));
+ }
};
+ client_Buttons.initPageFullscreen();
var getPlaylist = window.document.querySelector("#getplaylist");
getPlaylist.onclick = function(e) {
client_Utils.copyToClipboard(main.getPlaylistLinks().join(","));
@@ -726,6 +731,18 @@ client_Buttons.initChatInput = function(main) {
return true;
});
};
+client_Buttons.initPageFullscreen = function() {
+ window.document.onfullscreenchange = function(e) {
+ var el = window.document.documentElement;
+ if(client_Utils.hasFullscreen()) {
+ if(e.target == el) {
+ el.classList.add("mobile-view");
+ }
+ } else {
+ el.classList.remove("mobile-view");
+ }
+ };
+};
var client_InputWithHistory = function(element,history,maxItems,onEnter) {
this.historyId = -1;
this.element = element;
@@ -2078,31 +2095,26 @@ client_Utils.getIndex = function(parent,child) {
}
return i;
};
-client_Utils.toggleFullScreen = function(el) {
- var state = true;
+client_Utils.hasFullscreen = function() {
var doc = window.document;
+ if(!(window.document.fullscreenElement != null || doc.mozFullScreenElement != null)) {
+ return doc.webkitFullscreenElement != null;
+ } else {
+ return true;
+ }
+};
+client_Utils.requestFullscreen = function(el) {
var el2 = el;
- if(window.document.fullscreenElement == null && doc.mozFullScreenElement == null && doc.webkitFullscreenElement == null) {
- if(el.requestFullscreen != null) {
- el.requestFullscreen();
- } else if(el2.mozRequestFullScreen != null) {
- el2.mozRequestFullScreen();
- } else if(el2.webkitRequestFullscreen != null) {
- el2.webkitRequestFullscreen(HTMLElement.ALLOW_KEYBOARD_INPUT);
- } else {
- state = false;
- }
+ if(el.requestFullscreen != null) {
+ el.requestFullscreen();
+ } else if(el2.mozRequestFullScreen != null) {
+ el2.mozRequestFullScreen();
+ } else if(el2.webkitRequestFullscreen != null) {
+ el2.webkitRequestFullscreen(HTMLElement.ALLOW_KEYBOARD_INPUT);
} else {
- if(doc.cancelFullScreen != null) {
- doc.cancelFullScreen();
- } else if(doc.mozCancelFullScreen != null) {
- doc.mozCancelFullScreen();
- } else if(doc.webkitCancelFullScreen != null) {
- doc.webkitCancelFullScreen();
- }
- state = false;
+ return false;
}
- return state;
+ return true;
};
client_Utils.copyToClipboard = function(text) {
var clipboardData = window.clipboardData;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage