PageSourceSearch

https://platform.uno/app/themes/hello-elementor-child/assets/js-alt/credits-alert-scroll.js?ver=1.0.0

js platform.uno collected 2026-09-24 18:19:38 UTC 2,142 bytes, 64 lines download raw bytes

1/**
2 * Plan & Credits — alert CTA smooth scroll + highlight (#1759).
3 *
4 * When the user clicks a credits alert CTA ("Get more Credits"), scroll the
5 * target section into view and flash a highlight, so it's clear where to act
6 * even when the section is already on screen.
7 *
8 * The target is read from the clicked link's own href fragment, so the same
9 * handler works for both destinations:
10 *   - paid users  -> #ctt-pc-topup   (buy top-ups)
11 *   - trial users -> #ctt-pc-upgrade (upgrade plan; no top-up block exists)
12 *
13 * Progressive enhancement: if JS is off, the anchor href still jumps normally.
14 * If the target isn't on the page, the click is left alone.
15 */
16(function () {
17    'use strict';
18
19    function flashHighlight(el) {
20        el.classList.remove('ctt-pc-highlight');
21        void el.offsetWidth; // force reflow so the animation can re-trigger
22        el.classList.add('ctt-pc-highlight');
23
24        if (typeof el.focus === 'function') {
25            el.focus({ preventScroll: true });
26        }
27
28        window.setTimeout(function () {
29            el.classList.remove('ctt-pc-highlight');
30        }, 2000);
31    }
32
33    function onCtaClick(e, cta) {
34        // Pull the fragment from the link's href (e.g. ".../#ctt-pc-topup").
35        var href = cta.getAttribute('href') || '';
36        var hashIndex = href.indexOf('#');
37        if (hashIndex === -1) {
38            return; // no anchor -> let the link behave normally
39        }
40
41        var id = href.slice(hashIndex + 1);
42        var target = id ? document.getElementById(id) : null;
43
44        // Target not on this page -> don't hijack; let the href navigate.
45        if (!target) {
46            return;
47        }
48
49        e.preventDefault();
50        target.scrollIntoView({ behavior: 'smooth', block: 'start' });
51        flashHighlight(target);
52
53        if (window.history && window.history.replaceState) {
54            window.history.replaceState(null, '', '#' + id);
55        }
56    }
57
58    document.addEventListener('click', function (e) {
59        var cta = e.target.closest('.ctt-pc-alert-cta');
60        if (cta) {
61            onCtaClick(e, cta);
62        }
63    });
64})();

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.