1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Separating the FloatVideo functions and CSS into the plugin

This commit is contained in:
DanielnetoDotCom 2020-09-14 10:41:17 -03:00
parent 9d50a85169
commit fd6cf8841c
6 changed files with 176 additions and 153 deletions

View file

@ -9,7 +9,6 @@ var floatClosed = 0;
var fullDuration = 0;
var isPlayingAd = false;
var mainVideoHeight = 0;
var doNotFloatVideo = false;
var mouseX;
var mouseY;
var videoContainerDragged = false;
@ -138,57 +137,8 @@ try {
}
} catch (e) {
}
function setFloatVideo() {
if (!videoContainerDragged) {
if (!floatLeft || parseInt(floatLeft) < 10 || parseInt(floatLeft) === 310) {
floatLeft = "10px";
}
if (parseInt(floatLeft) === 10 && youTubeMenuIsOpened) {
floatLeft = "310px";
}
$("#videoContainer").css({"left": floatLeft});
}
if (!$('#videoContainer').hasClass("floatVideo") && !floatClosed) {
$('#videoContainer').hide();
$('#videoContainer').addClass('floatVideo');
$('#videoContainer').parent().css('height', mainVideoHeight);
if (parseInt(floatTop) < 70) {
floatTop = "70px";
}
$("#videoContainer").css({"top": floatTop});
$("#videoContainer").css({"height": floatHeight});
$("#videoContainer").css({"width": floatWidth});
$("#videoContainer").resizable({
aspectRatio: 16 / 9,
minHeight: 150,
minWidth: 266
});
$("#videoContainer").draggable({
handle: ".move",
containment: ".principalContainer",
drag: function () {
videoContainerDragged = true;
}
});
changingVideoFloat = 0;
$('#videoContainer').fadeIn();
$('#floatButtons').fadeIn();
} else {
changingVideoFloat = 0;
}
}
var pleaseWaitIsINUse = false;
var setFloatVideoYouTubeMenuIsOpened;
$(document).ready(function () {
setInterval(function () {
if (setFloatVideoYouTubeMenuIsOpened === youTubeMenuIsOpened || !$('#videoContainer').hasClass("floatVideo")) {
return false;
}
setFloatVideoYouTubeMenuIsOpened = youTubeMenuIsOpened;
setFloatVideo();
}, 1000);
modal = modal || (function () {
var pleaseWaitDiv = $("#pleaseWaitDialog");
if (pleaseWaitDiv.length === 0) {
@ -255,29 +205,7 @@ $(document).ready(function () {
}
});
}
mainVideoHeight = $('#videoContainer').innerHeight();
$(window).resize(function () {
mainVideoHeight = $('#videoContainer').innerHeight();
});
$(window).scroll(function () {
if (changingVideoFloat || doNotFloatVideo) {
return false;
}
changingVideoFloat = 1;
var s = $(window).scrollTop();
//console.log("$(window).scrollTop()= " + s);
//console.log("mainVideoHeight = $('#videoContainer').innerHeight()= " + mainVideoHeight);
if (s > mainVideoHeight) {
setFloatVideo();
} else {
floatClosed = 0;
if ($('#videoContainer').hasClass("floatVideo")) {
closeFloatVideo();
} else {
changingVideoFloat = 0;
}
}
});
$("a").each(function () {
var location = window.location.toString()
var res = location.split("?");
@ -493,29 +421,6 @@ function subscribeNotify(email, user_id) {
}
});
}
function closeFloatVideo() {
$('#videoContainer').fadeOut('fast', function () {
// this is to remove the dragable and resize
floatLeft = $("#videoContainer").css("left");
floatTop = $("#videoContainer").css("top");
floatWidth = $("#videoContainer").css("width");
floatHeight = $("#videoContainer").css("height");
$("#videoContainer").css({"top": ""});
$("#videoContainer").css({"left": ""});
$("#videoContainer").css({"height": ""});
$("#videoContainer").css({"width": ""});
$('#videoContainer').parent().css('height', '');
$('#videoContainer').removeClass('floatVideo');
$("#videoContainer").resizable('destroy');
$("#videoContainer").draggable('destroy');
$('#floatButtons').hide();
changingVideoFloat = 0;
});
$('#videoContainer').fadeIn();
}
function mouseEffect() {
$(".thumbsImage").on("mouseenter", function () {