ui_init: Extract embedded video preview mouse handler.

This commit extracts the logic used to ensure that the play icon is
correctly positioned over the video preview for embedded videos, with
the intention that we can use this to fix a regression in the play
icon positioning for youtube video previews.
This commit is contained in:
YashRE42 2022-03-24 18:26:34 +05:30 committed by Tim Abbott
parent d006b6cc3d
commit 58184fc2a9
1 changed files with 13 additions and 10 deletions

View File

@ -317,16 +317,7 @@ export function initialize_kitchen_sink_stuff() {
$row.removeClass("sender_name_hovered");
});
$("#main_div").on("mouseenter", ".youtube-video a", function () {
$(this).addClass("fa fa-play");
});
$("#main_div").on("mouseleave", ".youtube-video a", function () {
$(this).removeClass("fa fa-play");
});
$("#main_div").on("mouseenter", ".embed-video a", function () {
const $elem = $(this);
function handle_video_preview_mouseenter($elem) {
// Set image height and css vars for play button position, if not done already
const setPosition = !$elem.data("entered-before");
if (setPosition) {
@ -341,6 +332,18 @@ export function initialize_kitchen_sink_stuff() {
$elem.data("entered-before", true);
}
$elem.addClass("fa fa-play");
}
$("#main_div").on("mouseenter", ".youtube-video a", function () {
$(this).addClass("fa fa-play");
});
$("#main_div").on("mouseleave", ".youtube-video a", function () {
$(this).removeClass("fa fa-play");
});
$("#main_div").on("mouseenter", ".embed-video a", function () {
handle_video_preview_mouseenter($(this));
});
$("#main_div").on("mouseleave", ".embed-video a", function () {