PageSourceSearch

https://haber.sol.org.tr/themes/custom/sol/components/article/related_news_inline.js?v=4

js sol.org.tr collected 2026-10-02 03:02:48 UTC 1,599 bytes, 55 lines download raw bytes

1(function (Drupal, once) {
2  "use strict";
3
4  var mobileQuery = window.matchMedia("(max-width: 991.98px)");
5
6  function eligibleParagraphs(body) {
7    return Array.prototype.filter.call(body.querySelectorAll("p"), function (paragraph) {
8      if (!paragraph.textContent.trim()) {
9        return false;
10      }
11
12      return !paragraph.closest(
13        ".ct-related-news, .no-dynamic-ads, .advert-temp, blockquote, figure, table"
14      );
15    });
16  }
17
18  function placeInsideArticle(block) {
19    if (!mobileQuery.matches || block.dataset.inlinePlacementComplete === "true") {
20      return;
21    }
22
23    var article = block.closest(".article");
24    var body = article && article.querySelector(".node-body");
25    if (!body) {
26      return;
27    }
28
29    var paragraphs = eligibleParagraphs(body);
30    if (paragraphs.length < 2) {
31      return;
32    }
33
34    // Prefer the third paragraph while always leaving body copy below the block.
35    var targetIndex = Math.min(2, paragraphs.length - 2);
36    paragraphs[targetIndex].insertAdjacentElement("afterend", block);
37    block.dataset.inlinePlacementComplete = "true";
38  }
39
40  Drupal.behaviors.relatedNewsInline = {
41    attach: function (context) {
42      once("related-news-inline", ".related-news-inline", context).forEach(function (block) {
43        placeInsideArticle(block);
44
45        if (typeof mobileQuery.addEventListener === "function") {
46          mobileQuery.addEventListener("change", function (event) {
47            if (event.matches) {
48              placeInsideArticle(block);
49            }
50          });
51        }
52      });
53    },
54  };
55})(Drupal, once);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.