PageSourceSearch

https://karstso.org.tr/tema/genel/assets/js/karstso-header.js

js karstso.org.tr collected 2026-09-29 11:56:45 UTC 4,820 bytes, 149 lines download raw bytes

1(function (window) {
2    "use strict";
3
4    var mainContainer = document.querySelector(".main-wrap");
5    var openCtrl = document.getElementById("btn-search");
6    var openCtrl2 = document.getElementById("btn-search2");
7    var closeCtrl = document.getElementById("btn-search-close");
8    var searchContainer = document.querySelector(".search");
9
10    if (mainContainer && searchContainer && closeCtrl && (openCtrl || openCtrl2)) {
11        var inputSearch = searchContainer.querySelector(".search__input");
12
13        function openSearch() {
14            mainContainer.classList.add("main-wrap--move");
15            searchContainer.classList.add("search--open");
16            setTimeout(function () {
17                if (inputSearch) {
18                    inputSearch.focus();
19                }
20            }, 600);
21        }
22
23        function closeSearch() {
24            mainContainer.classList.remove("main-wrap--move");
25            searchContainer.classList.remove("search--open");
26            if (inputSearch) {
27                inputSearch.blur();
28                inputSearch.value = "";
29            }
30        }
31
32        if (openCtrl) {
33            openCtrl.addEventListener("click", openSearch);
34        }
35        if (openCtrl2) {
36            openCtrl2.addEventListener("click", openSearch);
37        }
38        closeCtrl.addEventListener("click", closeSearch);
39        document.addEventListener("keyup", function (ev) {
40            if (ev.keyCode === 27) {
41                closeSearch();
42            }
43        });
44    }
45})(window);
46
47$(document).ready(function () {
48    $(".hamburger-box > .icon").on("click", function () {
49        $(this).toggleClass("active");
50    });
51
52    $("#dismiss, .overlay").on("click", function () {
53        $("#mobile-menu").removeClass("active");
54        $("#sidebarCollapse").removeClass("active");
55        $(".overlay").removeClass("active");
56    });
57
58    $("#sidebarCollapse").on("click", function () {
59        $("#mobile-menu").addClass("active");
60        $(".overlay").addClass("active");
61    });
62
63    $(".drp-mobile-link").on("click", function (e) {
64        e.preventDefault();
65        $(this).next(".drp-mobile").toggleClass("active");
66    });
67
68    $(".header-dropdown .tab-link").on("click", function () {
69        var target = $(this).attr("datatarget");
70        $(this).closest(".row").find(".tab-panel").removeClass("active");
71        $(target).addClass("active");
72        $(this).parent().children(".tab-link").removeClass("active");
73        $(this).addClass("active");
74    });
75
76    /* Masaüstü mega menü: tıklama + hover gecikmesi (Kurumsal vb. kapanma sorunu) */
77    (function initDesktopHeaderDropdowns() {
78        var closeTimer = null;
79        var CLOSE_DELAY = 380;
80
81        function isDesktop() {
82            return window.matchMedia("(min-width: 1200px)").matches;
83        }
84
85        function setExpanded($item, open) {
86            $item.toggleClass("is-open", open);
87            $item.children("a.hover-bar").attr("aria-expanded", open ? "true" : "false");
88        }
89
90        function closeAll(except) {
91            $(".header-bottom .header-item.has-header-dropdown.is-open").each(function () {
92                if (!except || this !== except[0]) {
93                    setExpanded($(this), false);
94                }
95            });
96        }
97
98        function openItem($item) {
99            clearTimeout(closeTimer);
100            closeAll($item);
101            setExpanded($item, true);
102        }
103
104        function scheduleClose($item) {
105            clearTimeout(closeTimer);
106            closeTimer = setTimeout(function () {
107                setExpanded($item, false);
108            }, CLOSE_DELAY);
109        }
110
111        $(".header-bottom .header-item.has-header-dropdown").each(function () {
112            var $item = $(this);
113            var $trigger = $item.children("a.hover-bar");
114
115            $item.on("mouseenter", function () {
116                if (!isDesktop()) return;
117                openItem($item);
118            });
119
120            $item.on("mouseleave", function () {
121                if (!isDesktop()) return;
122                scheduleClose($item);
123            });
124
125            $trigger.on("click", function (e) {
126                if (!isDesktop()) return;
127                e.preventDefault();
128                if ($item.hasClass("is-open")) {
129                    setExpanded($item, false);
130                } else {
131                    openItem($item);
132                }
133            });
134        });
135
136        $(document).on("click", function (e) {
137            if (!isDesktop()) return;
138            if (!$(e.target).closest(".header-item.has-header-dropdown").length) {
139                closeAll();
140            }
141        });
142
143        $(document).on("keyup", function (e) {
144            if (e.key === "Escape") {
145                closeAll();
146            }
147        });
148    })();
149});

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.