From 8b8287a4d268a4dd5b7353986bb71aba1e2060ae Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 3 Apr 2025 16:13:15 +0300 Subject: [PATCH] Replace .ssb-icon with [data-share-type] .ssb-icon wasn't on icons but rather on links. --- app/assets/javascripts/social_share_button.js | 9 +++------ app/helpers/social_share_button_helper.rb | 7 ++++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/social_share_button.js b/app/assets/javascripts/social_share_button.js index 173194521..4ea11128c 100644 --- a/app/assets/javascripts/social_share_button.js +++ b/app/assets/javascripts/social_share_button.js @@ -10,11 +10,8 @@ $(function () { window.open(url, "popup", opts); } - $(".ssb-icon").on("click", function (e) { - const shareUrl = $(this).attr("href"); - if (!shareUrl.startsWith("mailto:")) { - e.preventDefault(); - openShareUrl(shareUrl); - } + $(".social-share-buttons [data-share-type='site']").on("click", function (e) { + e.preventDefault(); + openShareUrl(this.href); }); }); diff --git a/app/helpers/social_share_button_helper.rb b/app/helpers/social_share_button_helper.rb index 2d39ad372..f9ffa88bc 100644 --- a/app/helpers/social_share_button_helper.rb +++ b/app/helpers/social_share_button_helper.rb @@ -14,14 +14,15 @@ module SocialShareButtonHelper # Generates a set of social share buttons based on the specified options. def social_share_buttons(title:, url:) tag.div( - :class => "social-share-button d-flex gap-1 align-items-end flex-wrap mb-3" + :class => "social-share-buttons d-flex gap-1 align-items-end flex-wrap mb-3" ) do safe_join(SOCIAL_SHARE_CONFIG.map do |site, icon| link_options = { :rel => "nofollow", - :class => "ssb-icon rounded-circle focus-ring", + :class => "rounded-circle focus-ring", :title => I18n.t("application.share.#{site}.title"), - :target => "_blank" + :target => "_blank", + :data => { :share_type => site == :email ? "email" : "site" } } link_to generate_share_url(site, title, url), link_options do -- 2.39.5