PageSourceSearch

https://imacademy.cz/js/global-listeners.js

js imacademy.cz collected 2026-10-10 00:28:37 UTC 6,704 bytes, 149 lines download raw bytes

1import { initializeIMACheckbox, initializeIMARadio } from "./input.js";
2import { InitializeDynamicModalTrigger } from "./dynamic-modal.js";
3import { createImaSelect } from "./select.js";
4import { RegisterImaTableHide, RegisterImaTableShow } from "./table.js";
5import { toggle } from "./toggle.js";
6import Form from "./form.js";
7import Utils from "./utils.js";
8import { header } from "./header.js";
9import { initializeGallery } from "./gallery.js";
10export default class GlobalListeners {
11    static Initialize($parentElement) {
12        $parentElement.find("[data-bs-toggle='tooltip']").each(function () {
13            $(this).tooltip();
14        });
15        $parentElement.find(".dynamic-modal-trigger").each(function () {
16            InitializeDynamicModalTrigger($(this));
17        });
18        $parentElement.find(".imainput.checkbox").each(function () {
19            initializeIMACheckbox($(this));
20        });
21        $parentElement.find(".imainput.radio").each(function () {
22            initializeIMARadio($(this));
23        });
24        $parentElement.find(".ima-gallery").each(function () {
25            initializeGallery($(this));
26        });
27        $parentElement.find(".slide-info-toggler").each(function () {
28            $(this).on("click", function (e) {
29                var slideInfoId = $(this).data("slide-info-id");
30                var $slideInfo = $(`.slide-info-container[data-slide-info-id=${slideInfoId}]`);
31                // slideup all other slide infos
32                $(".slide-info-container").not($slideInfo).slideUp();
33                $slideInfo.slideToggle();
34            });
35        });
36        // offcanvas trigger
37        $parentElement.find(".offcanvas-trigger").each(function () {
38            Utils.BindOffcanvasTrigger($(this));
39        });
40        // fullcanvas trigger
41        $parentElement.find(".fullcanvas-trigger").each(function () {
42            Utils.BindFullcanvasTrigger($(this));
43        });
44        $parentElement.find(".dropdown-toggler").click(function () {
45            toggle($(this), $(this).closest(".dropdown-menu-container").find(".dropdown-menu"));
46        });
47        $parentElement.find(".imaselect").each(function () {
48            createImaSelect($(this));
49        });
50        // on page video click handler
51        $parentElement.find(".onpage-video").each(function () {
52            Utils.BindOnpageVideoTrigger($(this));
53        });
54        Utils.InitializeYoutubeIframes($parentElement);
55        $parentElement.find(".card-location-selection").click(function () {
56            const $gymSelection = $(this).closest(".card").find(".gym-selection");
57            $gymSelection.removeClass("hidden");
58        });
59        $parentElement.find(".card-location-close").click(function () {
60            const $gymSelection = $(this).closest(".card").find(".gym-selection");
61            $gymSelection.addClass("hidden");
62        });
63        $parentElement.find(".ima-table .collapse").on("show.bs.collapse", (event) => {
64            RegisterImaTableShow(event);
65        });
66        $parentElement.find(".ima-table .collapse").on("hide.bs.collapse", (event) => {
67            RegisterImaTableHide(event);
68        });
69        $parentElement.find(".scroll-trigger").click(function () {
70            var target = $(this).data("scroll-target");
71            Utils.ScrollTo($(target));
72        });
73        $parentElement.find("a[data-gym-href],button[data-gym-href]").each(function () {
74            let href = $(this).data("gym-href");
75            const location = localStorage.getItem("location");
76            const gymIdPlaceholderPresent = href.includes(Utils.GymIdPlaceholder);
77            if (location) {
78                // we are on location page
79                if (gymIdPlaceholderPresent) {
80                    href = href.replace(Utils.GymIdPlaceholder, location);
81                }
82                else {
83                    const splitted = href.split("/").filter(x => x != "");
84                    const langPresent = Utils.AllowedLangTwoLetterISONames.includes(splitted[0]);
85                    if (langPresent) {
86                        const lang = langPresent ? splitted[0] : null;
87                        const restOfHref = langPresent ? splitted.slice(1).join("/") : splitted.join("/");
88                        href = `/${lang}/${location}/${restOfHref}`;
89                    }
90                    else {
91                        href = `/${location}${href}`;
92                    }
93                }
94                if ($(this).is("button")) {
95                    $(this).on("click", function () {
96                        window.location.href = href;
97                    });
98                }
99            }
100            else {
101                // we are on location unspecified page
102                if (gymIdPlaceholderPresent) {
103                    // when gymId placeholder is present, that means gymId mandatory
104                    // and we can't redirect to the page without it
105                    const redirectUrl = href;
106                    $(this).on("click", function () {
107                        header.OpenLocationRedirectSelection(redirectUrl);
108                    });
109                    href = "javascript:void(0)";
110                }
111            }
112            $(this).attr("href", href);
113        });
114        $parentElement.find('a.ima-list-item-header').on("click", function () {
115            if ($(this).attr("aria-expanded") === "true") {
116                // hide this item
117                hide($(this));
118            }
119            else {
120                // close all other items
121                var $container = $(this).closest(".ima-table");
122                if ($container.data("has-group") === "True") {
123                    $container = $container.closest(".ima-table-group");
124                }
125                $container.find(".ima-list-item-header").each(function () {
126                    hide($(this));
127                });
128                // show this item
129                $(this).attr("aria-expanded", "true");
130                $(this).removeClass("collapsed");
131                $(this).closest(".ima-list-item").find(".collapse").collapse('show');
132            }
133            function hide($itemHeader) {
134                $itemHeader.attr("aria-expanded", "false");
135                $itemHeader.addClass("collapsed");
136                $itemHeader.closest(".ima-list-item").find(".collapse").collapse('hide');
137            }
138        });
139        $parentElement.find("form").each(function () {
140            new Form($(this));
141        });
142    }
143    static Dispose($parentElement) {
144        $parentElement.find(".media.video").each(function () {
145            Utils.RemoveVideo(this);
146        });
147    }
148}
149//# sourceMappingURL=global-listeners.js.map

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.