From 97feea42a1f5e2c163a562b29a9ae4829a55054d Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 20 Jul 2020 12:55:26 -0700 Subject: [PATCH] js: Replace deprecated jQuery.fn.hover. Signed-off-by: Anders Kaseorg --- .../node_tests/settings_user_groups.js | 22 ++----------------- frontend_tests/node_tests/ui_init.js | 2 -- static/js/settings_user_groups.js | 9 +++----- static/js/stats/stats.js | 10 ++++++--- static/js/tab_bar.js | 11 +++++----- 5 files changed, 17 insertions(+), 37 deletions(-) diff --git a/frontend_tests/node_tests/settings_user_groups.js b/frontend_tests/node_tests/settings_user_groups.js index b677245342..508f484e33 100644 --- a/frontend_tests/node_tests/settings_user_groups.js +++ b/frontend_tests/node_tests/settings_user_groups.js @@ -430,17 +430,6 @@ run_test("with_external_user", () => { turned_off[event_name + "/" + sel] = true; }; - let pill_hover_called = false; - let callback; - let empty_fn; - pill_stub.hover = function (one, two) { - callback = one; - empty_fn = two; - pill_hover_called = true; - assert.equal(typeof one, "function"); - assert.equal(typeof two, "function"); - }; - const exit_button = $.create("fake-pill-exit"); pill_stub.set_find_results(".exit", exit_button); let exit_button_called = false; @@ -487,14 +476,9 @@ run_test("with_external_user", () => { const event = { stopPropagation: noop, }; - let pill_click_called = false; + const pill_mouseenter_handler = pill_stub.get_on_handler("mouseenter"); const pill_click_handler = pill_container_stub.get_on_handler("click"); - pill_click_called = true; - - assert(callback); - assert(empty_fn); - callback(); - empty_fn(); + pill_mouseenter_handler(event); pill_click_handler(event); assert.equal(delete_handler.call(fake_delete), undefined); assert.equal(name_update_handler(), undefined); @@ -506,8 +490,6 @@ run_test("with_external_user", () => { assert.equal(set_attributes_called, 1); assert.equal(can_edit_called, 9); assert(exit_button_called); - assert(pill_click_called); - assert(pill_hover_called); assert.equal(user_group_find_called, 2); assert.equal(pill_container_find_called, 4); assert.equal(turned_off["keydown/.pill"], true); diff --git a/frontend_tests/node_tests/ui_init.js b/frontend_tests/node_tests/ui_init.js index 3a7aff6bcd..d9698ce477 100644 --- a/frontend_tests/node_tests/ui_init.js +++ b/frontend_tests/node_tests/ui_init.js @@ -190,8 +190,6 @@ $tab_bar.find = () => false; compose.compute_show_video_chat_button = () => {}; $("#below-compose-content .video_link").toggle = () => {}; -$("#tab_bar .narrow_description > a").hover = () => {}; - run_test("initialize_everything", () => { ui_init.initialize_everything(); }); diff --git a/static/js/settings_user_groups.js b/static/js/settings_user_groups.js index 8c10d5b2d6..7ce34e6724 100644 --- a/static/js/settings_user_groups.js +++ b/static/js/settings_user_groups.js @@ -80,12 +80,9 @@ exports.populate_user_groups = function () { pill_container.on("click", (e) => { e.stopPropagation(); }); - pill_container.find(".pill").hover( - () => { - pill_container.find(".pill").find(".exit").css("opacity", "0.5"); - }, - () => {}, - ); + pill_container.find(".pill").on("mouseenter", () => { + pill_container.find(".pill").find(".exit").css("opacity", "0.5"); + }); } update_membership(data.id); diff --git a/static/js/stats/stats.js b/static/js/stats/stats.js index 3b1e549e8f..d944fcfb55 100644 --- a/static/js/stats/stats.js +++ b/static/js/stats/stats.js @@ -81,9 +81,13 @@ $(() => { placement: "top", trigger: "manual", }); - $("#id_last_update_question_sign").hover(() => { - $("span.last_update_tooltip").tooltip("toggle"); - }); + $("#id_last_update_question_sign") + .on("mouseenter", () => { + $("span.last_update_tooltip").tooltip("show"); + }) + .on("mouseleave", () => { + $("span.last_update_tooltip").tooltip("hide"); + }); // Add configuration for any additional tooltips here. }); diff --git a/static/js/tab_bar.js b/static/js/tab_bar.js index 0ae895c399..ce3467cb77 100644 --- a/static/js/tab_bar.js +++ b/static/js/tab_bar.js @@ -97,14 +97,13 @@ function bind_title_area_handlers() { // handler that makes sure that hover plays nicely // with whether search is being opened or not. - $("#tab_bar .narrow_description > a").hover( - () => { + $("#tab_bar .narrow_description > a") + .on("mouseenter", () => { $("#tab_bar .search_closed").addClass("search_icon_hover_highlight"); - }, - () => { + }) + .on("mouseleave", () => { $("#tab_bar .search_closed").removeClass("search_icon_hover_highlight"); - }, - ); + }); } function build_tab_bar(filter) {