Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

ui_init: Extract embedded video preview mouse handler.

YashRE4258184fc2a989
diff --git a/static/js/ui_init.js b/static/js/ui_init.js
index 3ec04bfdd80..fc3cd42a5c0 100644
--- a/static/js/ui_init.js
+++ b/static/js/ui_init.js
@@ -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 () {