PageSourceSearch

https://nazk.gov.ua/js/nice-select2.js?v=1709297956

js nazk.gov.ua collected 2026-10-01 09:07:04 UTC 14,361 bytes, 402 lines download raw bytes

1!(function (e, t) {
2  "object" == typeof exports && "object" == typeof module
3    ? (module.exports = t())
4    : "function" == typeof define && define.amd
5    ? define([], t)
6    : "object" == typeof exports
7    ? (exports.NiceSelect = t())
8    : (e.NiceSelect = t());
9})(self, () =>
10  (() => {
11    "use strict";
12    var e = {
13        d: (t, i) => {
14          for (var s in i)
15            e.o(i, s) &&
16              !e.o(t, s) &&
17              Object.defineProperty(t, s, { enumerable: !0, get: i[s] });
18        },
19        o: (e, t) => Object.prototype.hasOwnProperty.call(e, t),
20        r: (e) => {
21          "undefined" != typeof Symbol &&
22            Symbol.toStringTag &&
23            Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }),
24            Object.defineProperty(e, "__esModule", { value: !0 });
25        },
26      },
27      t = {};
28    function i(e) {
29      var t = document.createEvent("MouseEvents");
30      t.initEvent("click", !0, !1), e.dispatchEvent(t);
31    }
32    function s(e) {
33      var t = document.createEvent("HTMLEvents");
34      t.initEvent("change", !0, !1), e.dispatchEvent(t);
35    }
36    function o(e) {
37      var t = document.createEvent("FocusEvent");
38      t.initEvent("focusin", !0, !1), e.dispatchEvent(t);
39    }
40    function n(e) {
41      var t = document.createEvent("FocusEvent");
42      t.initEvent("focusout", !0, !1), e.dispatchEvent(t);
43    }
44    function d(e) {
45      var t = document.createEvent("UIEvent");
46      t.initEvent("modalclose", !0, !1), e.dispatchEvent(t);
47    }
48    function l(e, t) {
49      "invalid" == t
50        ? (c(this.dropdown, "invalid"), h(this.dropdown, "valid"))
51        : (c(this.dropdown, "valid"), h(this.dropdown, "invalid"));
52    }
53    function r(e, t) {
54      return null != e[t] ? e[t] : e.getAttribute(t);
55    }
56    function a(e, t) {
57      return !!e && e.classList.contains(t);
58    }
59    function c(e, t) {
60      if (e) return e.classList.add(t);
61    }
62    function h(e, t) {
63      if (e) return e.classList.remove(t);
64    }
65    e.r(t), e.d(t, { bind: () => f, default: () => u });
66    var p = { data: null, searchable: !1, showSelectedItems: !1 };
67    function u(e, t) {
68      (this.el = e),
69        (this.config = Object.assign({}, p, t || {})),
70        (this.data = this.config.data),
71        (this.selectedOptions = []),
72        (this.placeholder =
73          r(this.el, "placeholder") ||
74          this.config.placeholder ||
75          "Select an option"),
76        (this.searchtext =
77          r(this.el, "searchtext") || this.config.searchtext || "Search"),
78        (this.selectedtext =
79          r(this.el, "selectedtext") || this.config.selectedtext || "selected"),
80        (this.dropdown = null),
81        (this.multiple = r(this.el, "multiple")),
82        (this.disabled = r(this.el, "disabled")),
83        this.create();
84    }
85    function f(e, t) {
86      return new u(e, t);
87    }
88    return (
89      (u.prototype.create = function () {
90        (this.el.style.opacity = "0"),
91          (this.el.style.width = "0"),
92          (this.el.style.padding = "0"),
93          (this.el.style.height = "0"),
94          this.data ? this.processData(this.data) : this.extractData(),
95          this.renderDropdown(),
96          this.bindEvent();
97      }),
98      (u.prototype.processData = function (e) {
99        var t = [];
100        e.forEach((e) => {
101          t.push({
102            data: e,
103            attributes: {
104              selected: !!e.selected,
105              disabled: !!e.disabled,
106              optgroup: "optgroup" == e.value,
107            },
108          });
109        }),
110          (this.options = t);
111      }),
112      (u.prototype.extractData = function () {
113        var e = this.el.querySelectorAll("option,optgroup"),
114          t = [],
115          i = [],
116          s = [];
117        e.forEach((e) => {
118          if ("OPTGROUP" == e.tagName)
119            var s = { text: e.label, value: "optgroup" };
120          else
121            s = {
122              text: e.innerText,
123              value: e.value,
124              selected:
125                null != e.getAttribute("selected") || this.el.value == e.value,
126              disabled: null != e.getAttribute("disabled"),
127            };
128          var o = {
129            selected: e.selected,
130            disabled: e.disabled,
131            optgroup: "OPTGROUP" == e.tagName,
132          };
133          t.push(s), i.push({ data: s, attributes: o });
134        }),
135          (this.data = t),
136          (this.options = i),
137          this.options.forEach((e) => {
138            e.attributes.selected && s.push(e);
139          }),
140          (this.selectedOptions = s);
141      }),
142      (u.prototype.renderDropdown = function () {
143        var e = [
144          "nice-select",
145          r(this.el, "class") || "",
146          this.disabled ? "disabled" : "",
147          this.multiple ? "has-multiple" : "",
148        ];
149        let t = '<div class="nice-select-search-box">';
150        (t += `<input type="text" class="nice-select-search" placeholder="${this.searchtext}..." title="search"/>`),
151          (t += "</div>");
152        var i = `<div class="${e.join(" ")}" tabindex="${
153          this.disabled ? null : 0
154        }">`;
155        (i += `<span class="${
156          this.multiple ? "multiple-options" : "current"
157        }"></span>`),
158          (i += '<div class="nice-select-dropdown">'),
159          (i += `${this.config.searchable ? t : ""}`),
160          (i += '<ul class="list"></ul>'),
161          (i += "</div>"),
162          (i += "</div>"),
163          this.el.insertAdjacentHTML("afterend", i),
164          (this.dropdown = this.el.nextElementSibling),
165          this._renderSelectedItems(),
166          this._renderItems();
167      }),
168      (u.prototype._renderSelectedItems = function () {
169        if (this.multiple) {
170          var e = "";
171          this.config.showSelectedItems ||
172          this.config.showSelectedItems ||
173          "auto" == window.getComputedStyle(this.dropdown).width ||
174          this.selectedOptions.length < 2
175            ? (this.selectedOptions.forEach(function (t) {
176                e += `<span class="current">${t.data.text}</span>`;
177              }),
178              (e = "" == e ? this.placeholder : e))
179            : (e = this.selectedOptions.length + " " + this.selectedtext),
180            (this.dropdown.querySelector(".multiple-options").innerHTML = e);
181        } else {
182          var t =
183            this.selectedOptions.length > 0 && this.selectedOptions[0].data.value
184              ? this.selectedOptions[0].data.text
185              : this.placeholder;
186          this.dropdown.querySelector(".current").innerHTML = t;
187        }
188      }),
189      (u.prototype._renderItems = function () {
190        var e = this.dropdown.querySelector("ul");
191        this.options.forEach((t) => {
192          e.appendChild(this._renderItem(t));
193        });
194      }),
195      (u.prototype._renderItem = function (e) {
196        var t = document.createElement("li");
197        if (((t.innerHTML = e.data.text), e.attributes.optgroup))
198          c(t, "optgroup");
199        else {
200          t.setAttribute("data-value", e.data.value);
201          var i = [
202            "option",
203            e.attributes.selected ? "selected" : null,
204            e.attributes.disabled ? "disabled" : null,
205          ];
206          t.addEventListener("click", this._onItemClicked.bind(this, e)),
207            t.classList.add(...i);
208        }
209        return (e.element = t), t;
210      }),
211      (u.prototype.update = function () {
212        if ((this.extractData(), this.dropdown)) {
213          var e = a(this.dropdown, "open");
214          this.dropdown.parentNode.removeChild(this.dropdown),
215            this.create(),
216            e && i(this.dropdown);
217        }
218        r(this.el, "disabled") ? this.disable() : this.enable();
219      }),
220      (u.prototype.disable = function () {
221        this.disabled || ((this.disabled = !0), c(this.dropdown, "disabled"));
222      }),
223      (u.prototype.enable = function () {
224        this.disabled && ((this.disabled = !1), h(this.dropdown, "disabled"));
225      }),
226      (u.prototype.clear = function () {
227        this.resetSelectValue(),
228          (this.selectedOptions = []),
229          this._renderSelectedItems(),
230          this.update(),
231          s(this.el);
232      }),
233      (u.prototype.destroy = function () {
234        this.dropdown &&
235          (this.dropdown.parentNode.removeChild(this.dropdown),
236          (this.el.style.display = ""));
237      }),
238      (u.prototype.bindEvent = function () {
239        this.dropdown.addEventListener("click", this._onClicked.bind(this)),
240          this.dropdown.addEventListener(
241            "keydown",
242            this._onKeyPressed.bind(this)
243          ),
244          this.dropdown.addEventListener("focusin", o.bind(this, this.el)),
245          this.dropdown.addEventListener("focusout", n.bind(this, this.el)),
246          this.el.addEventListener("invalid", l.bind(this, this.el, "invalid")),
247          window.addEventListener("click", this._onClickedOutside.bind(this)),
248          this.config.searchable && this._bindSearchEvent();
249      }),
250      (u.prototype._bindSearchEvent = function () {
251        var e = this.dropdown.querySelector(".nice-select-search");
252        e &&
253          e.addEventListener("click", function (e) {
254            return e.stopPropagation(), !1;
255          }),
256          e.addEventListener("input", this._onSearchChanged.bind(this));
257      }),
258      (u.prototype._onClicked = function (e) {
259        var t, i;
260        if (
261          (e.preventDefault(),
262          a(this.dropdown, "open")
263            ? this.multiple || (h(this.dropdown, "open"), d(this.el))
264            : (c(this.dropdown, "open"),
265              (t = this.el),
266              (i = document.createEvent("UIEvent")).initEvent(
267                "modalopen",
268                !0,
269                !1
270              ),
271              t.dispatchEvent(i)),
272          a(this.dropdown, "open"))
273        ) {
274          var s = this.dropdown.querySelector(".nice-select-search");
275          s && ((s.value = ""), s.focus());
276          var o = this.dropdown.querySelector(".focus");
277          h(o, "focus"),
278            c((o = this.dropdown.querySelector(".selected")), "focus"),
279            this.dropdown.querySelectorAll("ul li").forEach(function (e) {
280              e.style.display = "";
281            });
282        } else this.dropdown.focus();
283      }),
284      (u.prototype._onItemClicked = function (e, t) {
285        var i = t.target;
286        a(i, "disabled") ||
287          (this.multiple
288            ? a(i, "selected")
289              ? (h(i, "selected"),
290                this.selectedOptions.splice(this.selectedOptions.indexOf(e), 1),
291                this.el
292                  .querySelector(`option[value="${i.dataset.value}"]`)
293                  .removeAttribute("selected"))
294              : (c(i, "selected"), this.selectedOptions.push(e))
295            : (this.selectedOptions.forEach(function (e) {
296                h(e.element, "selected");
297              }),
298              c(i, "selected"),
299              (this.selectedOptions = [e])),
300          this._renderSelectedItems(),
301          this.updateSelectValue());
302      }),
303      (u.prototype.updateSelectValue = function () {
304        if (this.multiple) {
305          var e = this.el;
306          this.selectedOptions.forEach(function (t) {
307            var i = e.querySelector(`option[value="${t.data.value}"]`);
308            i && i.setAttribute("selected", !0);
309          });
310        } else
311          this.selectedOptions.length > 0 &&
312            (this.el.value = this.selectedOptions[0].data.value);
313        s(this.el);
314      }),
315      (u.prototype.resetSelectValue = function () {
316        if (this.multiple) {
317          var e = this.el;
318          this.selectedOptions.forEach(function (t) {
319            var i = e.querySelector(`option[value="${t.data.value}"]`);
320            i && i.removeAttribute("selected");
321          });
322        } else this.selectedOptions.length > 0 && (this.el.selectedIndex = -1);
323        s(this.el);
324      }),
325      (u.prototype._onClickedOutside = function (e) {
326        this.dropdown.contains(e.target) ||
327          (h(this.dropdown, "open"), d(this.el));
328      }),
329      (u.prototype._onKeyPressed = function (e) {
330        var t = this.dropdown.querySelector(".focus"),
331          s = a(this.dropdown, "open");
332        if (13 == e.keyCode) i(s ? t : this.dropdown);
333        else if (40 == e.keyCode) {
334          if (s) {
335            var o = this._findNext(t);
336            o &&
337              (h(this.dropdown.querySelector(".focus"), "focus"),
338              c(o, "focus"));
339          } else i(this.dropdown);
340          e.preventDefault();
341        } else if (38 == e.keyCode) {
342          if (s) {
343            var n = this._findPrev(t);
344            n &&
345              (h(this.dropdown.querySelector(".focus"), "focus"),
346              c(n, "focus"));
347          } else i(this.dropdown);
348          e.preventDefault();
349        } else if (27 == e.keyCode && s) i(this.dropdown);
350        else if (32 === e.keyCode && s) return !1;
351        return !1;
352      }),
353      (u.prototype._findNext = function (e) {
354        for (
355          e = e
356            ? e.nextElementSibling
357            : this.dropdown.querySelector(".list .option");
358          e;
359
360        ) {
361          if (!a(e, "disabled") && "none" != e.style.display) return e;
362          e = e.nextElementSibling;
363        }
364        return null;
365      }),
366      (u.prototype._findPrev = function (e) {
367        for (
368          e = e
369            ? e.previousElementSibling
370            : this.dropdown.querySelector(".list .option:last-child");
371          e;
372
373        ) {
374          if (!a(e, "disabled") && "none" != e.style.display) return e;
375          e = e.previousElementSibling;
376        }
377        return null;
378      }),
379      (u.prototype._onSearchChanged = function (e) {
380        var t = a(this.dropdown, "open"),
381          i = e.target.value;
382        if ("" == (i = i.toLowerCase()))
383          this.options.forEach(function (e) {
384            e.element.style.display = "";
385          });
386        else if (t) {
387          var s = new RegExp(i);
388          this.options.forEach(function (e) {
389            var t = e.data.text.toLowerCase(),
390              i = s.test(t);
391            e.element.style.display = i ? "" : "none";
392          });
393        }
394        this.dropdown.querySelectorAll(".focus").forEach(function (e) {
395          h(e, "focus");
396        }),
397          c(this._findNext(null), "focus");
398      }),
399      t
400    );
401  })()
402);

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.