Skip to content
(function () {
"use strict";
var PLACEHOLDER_VALUE = "fara valoare";
function qs(sel, root) {
return (root || document).querySelector(sel);
}
function qsa(sel, root) {
return Array.prototype.slice.call(
(root || document).querySelectorAll(sel)
);
}
function setGroupState(groupClass, shouldShow) {
var wrappers = qsa("." + groupClass);
wrappers.forEach(function (wrap) {
wrap.style.display = shouldShow ? "" : "none";
wrap.setAttribute("aria-hidden", shouldShow ? "false" : "true");
var inputs = qsa("input, select, textarea", wrap);
inputs.forEach(function (el) {
el.disabled = !shouldShow;
el.readOnly = !shouldShow;
if (!shouldShow) {
el.value = PLACEHOLDER_VALUE;
el.removeAttribute("required");
el.setAttribute("aria-required", "false");
} else {
if (el.value === PLACEHOLDER_VALUE) {
el.value = "";
}
}
});
});
}
function applySelection() {
var sel = qs("#selectie");
if (!sel) return;
var value = (sel.value || "").trim().toLowerCase();
var isFirma = value === "firma";
setGroupState("firma", isFirma);
setGroupState("persoana", !isFirma);
}
function init() {
var sel = qs("#selectie");
if (!sel) return;
applySelection();
sel.addEventListener("change", applySelection);
var obs = new MutationObserver(function () {
applySelection();
});
obs.observe(document.body, {
childList: true,
subtree: true
});
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", init);
} else {
init();
}
})();