diff --git a/app/assets/javascripts/initializers/initializeSponsorshipVisibility.js b/app/assets/javascripts/initializers/initializeSponsorshipVisibility.js index 5be875f6c..3c6a4ea17 100644 --- a/app/assets/javascripts/initializers/initializeSponsorshipVisibility.js +++ b/app/assets/javascripts/initializers/initializeSponsorshipVisibility.js @@ -1,36 +1,42 @@ function initializeSponsorshipVisibility() { - var el = document.getElementById("sponsorship-widget") || document.getElementById("partner-content-display"); + var el = + document.getElementById('sponsorship-widget') || + document.getElementById('partner-content-display'); var user = userData(); if (el) { - setTimeout(function(){ + setTimeout(function() { if (window.ga) { if (document.querySelectorAll('[data-partner-seen]').length === 0) { ga('send', 'event', 'view', 'sponsor displayed on page', el.dataset.details, null); - el.dataset.partnerSeen = "true"; + el.dataset.partnerSeen = 'true'; } } - }, 400) + }, 400); } - if (el && user && user.display_sponsors){ - el.classList.add("showing"); + if (el && user && user.display_sponsors) { + el.classList.add('showing'); listenForSponsorClick(); } else if (el && user) { - el.classList.remove("showing"); + el.classList.remove('showing'); } else if (el) { - el.classList.add("showing"); + el.classList.add('showing'); listenForSponsorClick(); } } function listenForSponsorClick() { - setTimeout(function(){ + setTimeout(function() { if (window.ga) { - var links = document.getElementsByClassName("partner-link"); - for(var i = 0; i < links.length; i++) { - links[i].onclick = function(event){ + var links = document.getElementsByClassName('partner-link'); + for (var i = 0; i < links.length; i++) { + links[i].onclick = function(event) { + if (event.target.classList.contains('follow-action-button')) { + handleOptimisticButtRender(event.target); + handleFollowButtPress(event.target); + } ga('send', 'event', 'click', 'click sponsor link', event.target.dataset.details, null); - } + }; } } - },400) -} \ No newline at end of file + }, 400); +} diff --git a/app/controllers/additional_content_boxes_controller.rb b/app/controllers/additional_content_boxes_controller.rb index 3edcfe7fc..f994980a9 100644 --- a/app/controllers/additional_content_boxes_controller.rb +++ b/app/controllers/additional_content_boxes_controller.rb @@ -1,18 +1,17 @@ class AdditionalContentBoxesController < ApplicationController def index - articles_ids = params[:article_id].split(",") - @article = Article.find(articles_ids[0]) + article_ids = params[:article_id].split(",") + @article = Article.find(article_ids[0]) @for_user_article = ClassicArticle. - new(current_user || @article, not_ids: articles_ids).get + new(current_user || @article, not_ids: article_ids).get if (!user_signed_in? || current_user&.display_sponsors) && @article.user.permit_adjacent_sponsors && rand(2) == 1 @boosted_article = BoostedArticle. - new(current_user, @article, not_ids: (articles_ids + [@for_user_article])).get - end - unless @boosted_article + new(current_user, @article, not_ids: (article_ids + [@for_user_article])).get + else @alt_classic = ClassicArticle. - new(@article, not_ids: (articles_ids + [@for_user_article])).get + new(@article, not_ids: (article_ids + [@for_user_article])).get end render "boxes", layout: false end diff --git a/app/decorators/article_decorator.rb b/app/decorators/article_decorator.rb index d5430a86a..934dba010 100644 --- a/app/decorators/article_decorator.rb +++ b/app/decorators/article_decorator.rb @@ -44,11 +44,11 @@ class ArticleDecorator < ApplicationDecorator end def internal_utm_params(place="additional_box") - campaign = if boosted_additional_articles - "#{organization&.slug}_boosted" - else - "regular" - end - "?utm_source=#{place}&utm_medium=internal&utm_campaign=#{ campaign }&booster_org=#{organization&.slug}" + campaign = if boosted_additional_articles + "#{organization&.slug}_boosted" + else + "regular" + end + "?utm_source=#{place}&utm_medium=internal&utm_campaign=#{campaign}&booster_org=#{organization&.slug}" end end diff --git a/app/models/article.rb b/app/models/article.rb index fe2883ad3..3cb5ac44f 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -158,7 +158,6 @@ class Article < ApplicationRecord boosted_dev_digest_email Boolean, default: false end - def self.filter_excluded_tags(tag = nil) if tag == "hiring" tagged_with("hiring") @@ -187,10 +186,9 @@ class Article < ApplicationRecord stories.pluck(:path, :title, :comments_count, :created_at) end - + def self.active_eli5(time_ago) - stories = where(published:true). - tagged_with("explainlikeimfive") + stories = where(published: true).tagged_with("explainlikeimfive") if time_ago == "latest" stories = stories.order("published_at DESC").limit(3) diff --git a/app/views/additional_content_boxes/_article_followable_area.html.erb b/app/views/additional_content_boxes/_article_followable_area.html.erb index cf969f6db..2fea6e8f8 100644 --- a/app/views/additional_content_boxes/_article_followable_area.html.erb +++ b/app/views/additional_content_boxes/_article_followable_area.html.erb @@ -14,7 +14,7 @@ <% else %>