PageSourceSearch

https://www.golfshopen.no/static/version1790852184/frontend/Bluemi…nt_AddToCartAnimation/js/popup-animation.js

js golfshopen.no collected 2026-10-06 07:19:29 UTC 2,840 bytes, 84 lines download raw bytes

1/**
2 * Copyright © Bluemint. All rights reserved.
3 * See COPYING.txt for license details.
4 *
5 * Manages the Svgator animation lifecycle for the add-to-cart popup.
6 *
7 * KEY TIMING DETAIL:
8 * animation.js runs deferred. Its registration IIFE sets a stub player:
9 *   el.svgatorPlayer = { ready: fn }   ← stub, no play/stop yet
10 * Then ce.init() builds the real player, flushing ready() callbacks.
11 * After ce.init(), el.svgatorPlayer has play/stop/etc.
12 *
13 * If mount() is called BEFORE ce.init() → use ready(cb) to queue play.
14 * If mount() is called AFTER  ce.init() → call play() directly.
15 * Detect which case by checking if svgatorPlayer.play exists.
16 */
17(function () {
18    'use strict';
19
20    var HOST_ID = 'bm-popup-animation-host';
21    var SVG_ID  = 'eotJEj9F7Q61';
22    var WRAPPER = '.animation-wrapper';
23
24    function host()  { return document.getElementById(HOST_ID); }
25    function svgEl() { return document.getElementById(SVG_ID); }
26
27    function playerIsBuilt() {
28        var el = svgEl();
29        return !!(el && el.svgatorPlayer && typeof el.svgatorPlayer.play === 'function');
30    }
31
32    function callPlayer(method) {
33        var el = svgEl();
34        var p  = el && el.svgatorPlayer;
35        if (p && typeof p[method] === 'function') { p[method](); return true; }
36        return false;
37    }
38
39    function playAnimation() {
40        if (playerIsBuilt()) {
41            // Player already fully initialised — call directly.
42            callPlayer('stop');
43            callPlayer('play');
44        } else {
45            // Player stub exists but ce.init() hasn't run yet.
46            // ready() queues the callback until ce.init() flushes it.
47            var el = svgEl();
48            if (el && el.svgatorPlayer && typeof el.svgatorPlayer.ready === 'function') {
49                el.svgatorPlayer.ready(function () {
50                    callPlayer('stop');
51                    callPlayer('play');
52                });
53            }
54        }
55    }
56
57    window.BluemintPopupAnimation = {
58        isAvailable: function () { return !!host(); },
59
60        mount: function (target) {
61            var h = host();
62            if (!h || !target) return false;
63            var wrapper = h.querySelector(WRAPPER);
64            if (!wrapper) return false;
65            target.appendChild(wrapper);
66            playAnimation();
67            return true;
68        },
69
70        unmount: function () {
71            var h = host();
72            if (!h) return false;
73            var wrapper = null;
74            var all = document.querySelectorAll(WRAPPER);
75            for (var i = 0; i < all.length; i++) {
76                if (!h.contains(all[i])) { wrapper = all[i]; break; }
77            }
78            if (!wrapper) return false;
79            callPlayer('stop');
80            h.appendChild(wrapper);
81            return true;
82        }
83    };
84})();

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.