PageSourceSearch

https://paradromics.com/wp-content/themes/paradromics/js/blog.js?cache=1790912417

js paradromics.com collected 2026-10-02 04:06:21 UTC 5,099 bytes, 160 lines download raw bytes

1jQuery(function ($) {
2  // BLOG Filter - Start
3
4  const state = {
5    sort:    "date-desc",
6    topic:   "all",
7    search:  "",
8    page:    1,
9    loading: false,
10  };
11
12  // ── View switcher ──────────────────────────────────────────────────────
13  $(".view-btn").on("click", function () {
14    $(".view-btn").removeClass("active");
15    $(this).addClass("active");
16    const view = $(this).data("view");
17    $(".blog-list")
18      .toggleClass("list-view", view === "list")
19      .toggleClass("grid-view", view === "grid");
20  });
21
22  // ── Filter dropdowns ───────────────────────────────────────────────────
23  $(".filter-toggle").on("click", function (e) {
24    e.stopPropagation();
25    $(".search-wrap").removeClass("active");
26    $(".filter-dropdown-menu").not($(this).next()).slideUp(200);
27    $(this).next(".filter-dropdown-menu").slideToggle(200);
28  });
29
30  $(document).on("click", function (e) {
31    if (!$(e.target).closest(".search-wrap, .filter-dropdown").length) {
32      $(".filter-dropdown-menu").slideUp(200);
33      $(".search-wrap").removeClass("active");
34    }
35  });
36
37  $(".filter-dropdown-menu li").on("click", function () {
38    const $dropdown = $(this).closest(".filter-dropdown");
39    const target    = $dropdown.find(".filter-toggle").data("target");
40    const value     = $(this).data("value");
41    const text      = $(this).text().trim();
42
43    $(target).text(text);
44    $dropdown.find(".filter-dropdown-menu").slideUp(200);
45
46    if ($dropdown.find(".current-sort").length) {
47      state.sort = value;
48    } else {
49      state.topic = value;
50    }
51
52    state.page = 1;
53    fetchPosts(false);
54  });
55
56  // ── Search ─────────────────────────────────────────────────────────────
57  $(".search-toggle").on("click", function (e) {
58    e.stopPropagation();
59    $(".filter-dropdown-menu").slideUp(200);
60    $(".search-wrap").toggleClass("active");
61    setTimeout(function () { $(".blog-search").focus(); }, 200);
62  });
63
64  let searchTimer;
65  $(".blog-search").on("keyup", function () {
66    clearTimeout(searchTimer);
67    const val = $(this).val().trim();
68    searchTimer = setTimeout(function () {
69      state.search = val;
70      state.page   = 1;
71      fetchPosts(false);
72    }, 400);
73  });
74
75  // ── Load More ──────────────────────────────────────────────────────────
76  $(document).on("click", "#blog-load-more a", function (e) {
77    e.preventDefault();
78    if (state.loading) return;
79    state.page++;
80    fetchPosts(true);
81  });
82
83  // ── AJAX fetch ─────────────────────────────────────────────────────────
84  function fetchPosts(append) {
85    if (state.loading) return;
86    state.loading = true;
87
88    const $list     = $(".blog-list");
89    const $loadMore = $("#blog-load-more");
90    const $btn      = $loadMore.find("a");
91
92    if (append) {
93      $btn.text("Loading...");
94    } else {
95      $list.css("opacity", 0.4);
96    }
97
98    $.ajax({
99      url:  blogAjax.url,
100      type: "POST",
101      data: {
102        action: "load_blog_posts",
103        nonce:  blogAjax.nonce,
104        sort:   state.sort,
105        topic:  state.topic,
106        search: state.search,
107        page:   state.page,
108      },
109      success: function (res) {
110        if (!res.success) return;
111        if (append) {
112          $list.append(res.data.html);
113        } else {
114          $list.html(res.data.html).css("opacity", 1);
115        }
116        if (state.page < res.data.max_pages) {
117          $loadMore.removeClass("d-none");
118        } else {
119          $loadMore.addClass("d-none");
120        }
121      },
122      error: function () {
123        if (!append) $list.css("opacity", 1);
124      },
125      complete: function () {
126        state.loading = false;
127        $btn.text("Load More");
128      },
129    });
130  }
131
132  // BLOG Filter - END
133
134  // Share BLOG - Start
135  $(".share-linkedin").on("click", function (e) {
136    e.preventDefault();
137
138    const url = encodeURIComponent(window.location.href);
139
140    window.open(
141      `https://www.linkedin.com/sharing/share-offsite/?url=${url}`,
142      "_blank",
143      "width=600,height=600",
144    );
145  });
146
147  $(".share-twitter").on("click", function (e) {
148    e.preventDefault();
149
150    const url = encodeURIComponent(window.location.href);
151    const title = encodeURIComponent(document.title);
152
153    window.open(
154      `https://twitter.com/intent/tweet?url=${url}&text=${title}`,
155      "_blank",
156      "width=600,height=600",
157    );
158  });
159  // Share BLOG - End
160});

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.