Automatically assuming small player if in iframe

This commit is contained in:
Kasper Rynning-Tønnesen
2018-09-22 16:45:44 +02:00
parent 62ae1ee802
commit 0a7ea9f0b2
3 changed files with 15 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
var Channel = {
init: function() {
if(window.location.hash == "#small") {
if(window.location.hash == "#small" || inIframe()) {
small_player = true;
document.querySelector("footer").style.display = "none";
}

View File

@@ -354,6 +354,14 @@ function contextListener(that, event) {
}
}
function inIframe () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}
function mouseContext(left, top) {
var moveFunction = function( event ) {
if(event.pageX < left - 60 || event.pageX > left + document.querySelector(".context-menu-root").offsetWidth + 60 ||

View File

@@ -120,7 +120,9 @@ var Player = {
Helper.log(["video_id variable: " + video_id]);
switch(newState.data) {
case YT.PlayerState.UNSTARTED:
Helper.css("#player", "opacity", "1");
if(small_player) {
Helper.css("#player", "opacity", "1");
}
break;
case YT.PlayerState.ENDED:
playing = false;
@@ -221,7 +223,9 @@ var Player = {
case YT.PlayerState.BUFFERING:
//was_stopped = false;
buffering = true;
Helper.css("#player", "opacity", "1");
if(small_player) {
Helper.css("#player", "opacity", "1");
}
resizePlaylistPlaying(newState.data == YT.PlayerState.PLAYING || newState.data == YT.PlayerState.BUFFERING);
break;
}