//pre admimenu
(function() {
var activeAdminPath = window.location.pathname.split("/").pop();
$(".submenu li").each(function() {
var activeAdminLink = $(this).find("a").eq(0);
var activeAdminHref = activeAdminLink.attr("href");
if (
activeAdminLink.length > 0 &&
activeAdminHref &&
activeAdminPath == activeAdminHref.split("?")[0].split("&")[0]
) {
var activeAdminSubmenu = $(this).closest(".submenu");
var activeAdminMenuIndex = $(".submenu").index(activeAdminSubmenu);
if (activeAdminMenuIndex >= 0) {
ddaccordion.setCookie("headerbar", activeAdminMenuIndex + "c");
}
return false;
}
});
})();
ddaccordion.init({
headerclass: "headerbar", //Shared CSS class name of headers group
contentclass: "submenu", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc] [] denotes no content
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
animatedefault: true, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["menu_close", "menu_open"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
//do nothing
}
})
ddaccordion.init({ //2nd level headers initialization
headerclass: "subexpandable", //Shared CSS class name of sub headers group that are expandable
contentclass: "subcategoryitems", //Shared CSS class name of sub contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["opensubheader", "closedsubheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
//do nothing
}
});
(function() {
var ADMIN_MENU_HIDE_KEY = "dods_admin_menu_hidden";
var ADMIN_MENU_MIN_WIDTH = 801;
function getAdminMenuModuleKey() {
var page = (window.location.pathname.split("/").pop() || "").split("?")[0];
var m = page.match(/^(admin_[^_]+)/);
return m ? m[1] : page;
}
function readAdminMenuHiddenMap() {
try {
return JSON.parse(sessionStorage.getItem(ADMIN_MENU_HIDE_KEY) || "{}");
} catch (e) {
return {};
}
}
function writeAdminMenuHidden(collapsed) {
try {
var map = readAdminMenuHiddenMap();
var key = getAdminMenuModuleKey();
if (collapsed) {
map[key] = "1";
} else {
delete map[key];
}
sessionStorage.setItem(ADMIN_MENU_HIDE_KEY, JSON.stringify(map));
} catch (e) {}
}
function isAdminMenuHidden() {
return readAdminMenuHiddenMap()[getAdminMenuModuleKey()] === "1";
}
window.applyAdminMenuCollapsed = function(collapsed) {
document.body.classList.toggle("admin_menu_collapsed", !!collapsed);
if (typeof window.syncAdminContentHeight === "function") {
window.syncAdminContentHeight();
}
};
function initAdminMenuHideToggle() {
var left = document.querySelector(".screen_admin_1");
if (!left || window.innerWidth < ADMIN_MENU_MIN_WIDTH) {
document.body.classList.remove("admin_menu_collapsed");
var oldToggle = document.getElementById("admin_menu_hide_toggle");
if (oldToggle) {
oldToggle.remove();
}
return;
}
var toggle = document.getElementById("admin_menu_hide_toggle");
if (!toggle) {
toggle = document.createElement("button");
toggle.id = "admin_menu_hide_toggle";
toggle.type = "button";
toggle.title = "Skryť / zobraziť menu";
var toggleImg = document.createElement("img");
toggleImg.src = "obr/hide.png";
toggleImg.alt = "";
toggleImg.width = 16;
toggleImg.height = 16;
toggle.appendChild(toggleImg);
left.appendChild(toggle);
toggle.addEventListener("click", function(e) {
e.preventDefault();
e.stopPropagation();
var collapsed = !document.body.classList.contains("admin_menu_collapsed");
window.applyAdminMenuCollapsed(collapsed);
writeAdminMenuHidden(collapsed);
});
}
window.applyAdminMenuCollapsed(isAdminMenuHidden());
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initAdminMenuHideToggle);
} else {
initAdminMenuHideToggle();
}
window.addEventListener("resize", initAdminMenuHideToggle);
})();
// deaktivovanie F1 pre Chrome
function disableFunctionKeys(e) {
var functionKeys = new Array(112, 113); // F1
if (functionKeys.indexOf(e.keyCode) > -1 || functionKeys.indexOf(e.which) > -1) {
e.preventDefault();
}
};
//deaktivovanie F1 pre IE
if ("onhelp" in window)
window.onhelp = function () {
//showMyHelpInsteadOfTheUsualDefaultHelpWindow(true);
return false;
}
// Others
else {
document.onkeydown = function(evt) {
cancelKeypress = (evt.keyCode == 112);
if (cancelKeypress) { // F1 was pressed
//showMyHelpInsteadOfTheUsualDefaultHelpWindow(true);
return false;
}
}
// Additional step required for Opera
document.onkeypress = function(evt) {
if (cancelKeypress)
return false;
}
}
function convertNumToTime(number) {
// Check sign of given number
var sign = (number >= 0) ? 1 : -1;
// Set positive value of number of sign negative
number = number * sign;
// Separate the int from the decimal part
var hour = Math.floor(number);
var decpart = number - hour;
var min = 1 / 60;
// Round to nearest minute
decpart = min * Math.round(decpart / min);
var minute = Math.floor(decpart * 60) + '';
// Add padding if need
if (minute.length < 2) {
minute = '0' + minute;
}
// Add Sign in final result
sign = sign == 1 ? '' : '-';
// Concate hours and minutes
time = sign + hour + ':' + minute;
return time;
}
function parseDate(str) {
var mdy = str.split('.');
return new Date(mdy[2], mdy[1], mdy[0]-1);
}
function daydiff(first, second) {
return Math.floor((second-first)/(1000*60*60*24*365.25));
}
function zeroPad(num, numZeros) {
var n = Math.abs(num);
var zeros = Math.max(0, numZeros - Math.floor(n).toString().length );
var zeroString = Math.pow(10,zeros).toString().substr(1);
if( num < 0 ) {
zeroString = '-' + zeroString;
}
return zeroString+n;
}
function datafromrodcislo(rodcislo) {
/*
setdatnar='';
if (rodcislo.length<11) {
return "0||";
}
dd=parseInt(rodcislo.substr(4,2));
mm=parseInt(rodcislo.substr(2,2));
yy=parseInt(rodcislo.substr(0,2));
if (parseInt(rodcislo.substr(8,1))=='1' || parseInt(rodcislo.substr(8,1))=='3' || parseInt(rodcislo.substr(8,1))=='5' || parseInt(rodcislo.substr(8,1))=='7' || parseInt(rodcislo.substr(8,1))=='9') {
poh=1;
} else {
poh=0;
}
const d = new Date();
let year = parseInt(d.getFullYear().toString().substr(2,2));
if (yy < year) {
setdatnar=zeroPad(dd,2)+"."+zeroPad(mm,2)+"."+d.getFullYear().toString().substr(0,2)+yy;
} else {
setdatnar=zeroPad(dd,2)+"."+zeroPad(mm,2)+"."+(parseInt(d.getFullYear().toString().substr(0,2))-1)+yy;
}
return poh+"|"+setdatnar+"|"+daydiff(parseDate(setdatnar),parseDate("11.10.2026"));
// pohlavie (0-zena,1-muz) | datum narodenia DD.MM.YYYY | pocet rokov
*/
setdatnar='';
if (rodcislo.length<9) {
return "0||";
}
dd=parseInt(rodcislo.substr(4,2));
mm=parseInt(rodcislo.substr(2,2));
yy=parseInt(rodcislo.substr(0,2));
if (mm>50) {
poh=1; // zmenene
mm=mm-50;
} else {
poh=0; // zmenene
}
if (((rodcislo.indexOf("/")!='-1' && rodcislo.length==10) || (rodcislo.indexOf("/")=='-1' && rodcislo.length==9)) || yy>53) {
setdatnar=zeroPad(dd,2)+"."+zeroPad(mm,2)+".19"+rodcislo.substr(0,2);
} else {
setdatnar=zeroPad(dd,2)+"."+zeroPad(mm,2)+".20"+rodcislo.substr(0,2);
}
return poh+"|"+setdatnar+"|"+daydiff(parseDate(setdatnar),parseDate("11.10.2026"));
// pohlavie (0-zena,1-muz) | datum narodenia DD.MM.YYYY | pocet rokov
}
function centerintro_adminheight() { // hlavna farebna plocha v admine + loginobrazovka uvodu na stred
var biely_blok = ($(window).height() - $(".vrch").height() - $(".spodok").height());
var centro = (((biely_blok)/2) - $("#center-block").height()/2 - 15);
if (0>centro) { centro=0; }
$('#center-block').css("top",centro);
}
var def_thheight,def_tdheight,def_width;
function fixRowsHeight() {
const tables = Array.from(document.querySelectorAll(".filter_wrapper .fix_size"));
// reset len JS výšok
tables.forEach(function (table) {
table.style.height = "";
table.querySelectorAll("tr, th, td").forEach(function (el) {
el.style.height = "";
});
});
let rows = [];
// zoskupenie podľa stredu prvku, nie podľa top
// funguje aj keď flex používa align-items:center
tables.forEach(function (table) {
const rect = table.getBoundingClientRect();
const centerY = Math.round(rect.top + rect.height / 2);
let row = rows.find(function (r) {
return Math.abs(r.centerY - centerY) < 20;
});
if (!row) {
row = {
centerY: centerY,
items: []
};
rows.push(row);
}
row.items.push(table);
});
rows.forEach(function (row) {
let maxHeight = 0;
row.items.forEach(function (table) {
maxHeight = Math.max(
maxHeight,
table.getBoundingClientRect().height
);
});
row.items.forEach(function (table) {
table.style.setProperty("height", Math.ceil(maxHeight) + "px", "important");
});
});
}
function height_fixsizetable() {
// fixna vyska
def_thheight=0;
def_tdheight=0;
$(".fix_size tr:first-child").each(function() {
def_thheight = Math.max(def_thheight, $(this).outerHeight());
});
$(".fix_size tr td").each(function() {
if ($(this).height()>def_tdheight) { def_tdheight=$(this).height(); }
});
def_width=0;
$(".fix_size tr th").each(function() {
if ($(this).width()>def_width) { def_width=$(this).width(); }
});
$(".fix_size tr td").each(function() {
if ($(this).width()>def_width) { def_width=$(this).width(); }
});
$(".fix_size tr th, .fix_size tr td").css("width","100%");
//$(".fix_size tr:first-child").css("height", "72px");
$(".fix_size tr td").css("height",def_tdheight+ "px");
}
function width_fixsizetable() {
const $items = $(".filter_wrapper .fix_size");
def_thheight = 0;
def_tdheight = 0;
$items.find("tr th").each(function() {
if ($(this).height() > def_thheight) {
def_thheight = $(this).height();
}
});
$items.find("tr td").each(function() {
if ($(this).height() > def_tdheight) {
def_tdheight = $(this).height();
}
});
$items.find("tr th").css("height", def_thheight);
$items.find("tr td").css("height", def_tdheight);
}
function all_filtre_in_one_row( width ){
let all_width = 0;
$(".fix_size tr th").each(function() {
all_width += $(this).width();
});
return width >= all_width;
}
function normalizeFilterInlineWrappers() {
const wrapper = document.querySelector(".filter_wrapper_safe");
if (!wrapper) {
return;
}
function isInlineHidden(el) {
return /\bdisplay\s*:\s*none\b/i.test(el.getAttribute("style") || "");
}
function makeContents(el) {
if (!el || isInlineHidden(el)) {
return;
}
if (getComputedStyle(el).display !== "none") {
el.style.setProperty("display", "contents", "important");
}
}
wrapper
.querySelectorAll("#show_search, #show_zorad, #hiderok")
.forEach(function (block) {
makeContents(block);
Array.prototype.slice.call(block.children).forEach(function (child) {
if (
child.nodeType === 1 &&
!child.matches("table.niceborder.fix_size") &&
child.querySelector("table.niceborder.fix_size")
) {
makeContents(child);
}
});
});
}
function equalizeFilterRows() {
const wrapper = document.querySelector(".filter_wrapper_safe");
if (!wrapper) {
return;
}
const tables = Array.from(
wrapper.querySelectorAll("table.niceborder.fix_size")
).filter(function (table) {
return table.offsetParent !== null;
});
if (!tables.length) {
return;
}
/*
Submitová tabuľka nesmie vstupovať do maxima filtrov.
Jej bunka môže byť kvôli tlačidlu a checkboxu prirodzene vyššia
a pri opakovanom prepočte by nafúkla celý vizuálny riadok.
*/
const entries = tables.map(function (table) {
const th = table.querySelector("th");
const td = table.querySelector("td");
const hasSubmit = !!td?.querySelector(
'input[type="submit"], button[type="submit"]'
);
return {
table: table,
th: th,
td: td,
hasSubmit: hasSubmit
};
});
// Každý beh začína z rovnakého stavu.
entries.forEach(function (entry) {
const table = entry.table;
table.style.height = "";
table.style.minHeight = "";
table.querySelectorAll("tr, th, td").forEach(function (el) {
el.style.height = "";
el.style.minHeight = "";
});
if (entry.hasSubmit && entry.td) {
entry.td.classList.add("filter_submit_cell");
const allowDeleteCheckbox = entry.td.querySelector(
'input[type="checkbox"][name="candelete"]'
);
if (allowDeleteCheckbox && allowDeleteCheckbox.parentElement &&
allowDeleteCheckbox.parentElement.tagName === "SPAN") {
allowDeleteCheckbox.parentElement.classList.add("allowdel");
}
}
if (entry.hasSubmit && entry.th) {
// Prázdny header riadok nad Načítaj – schovať celý
, nielen | .
const headRow = entry.th.parentElement;
if (headRow && headRow.tagName === "TR") {
headRow.style.setProperty("display", "none", "important");
headRow.style.setProperty("height", "0", "important");
}
entry.th.style.setProperty("display", "none", "important");
entry.th.style.setProperty("height", "0", "important");
entry.th.style.setProperty("padding", "0", "important");
entry.th.style.setProperty("border", "0", "important");
}
});
// Vynútenie prepočtu layoutu po resete a skrytí submitových hlavičiek.
void wrapper.offsetHeight;
const rows = [];
// Rozdelenie tabuliek podľa vizuálneho riadku vo flex wrape.
entries.forEach(function (entry) {
const top = Math.round(entry.table.getBoundingClientRect().top);
let row = rows.find(function (r) {
return Math.abs(r.top - top) <= 10;
});
if (!row) {
row = {
top: top,
tables: []
};
rows.push(row);
}
row.tables.push(entry);
});
rows.forEach(function (row) {
const filterTables = row.tables.filter(function (entry) {
return !entry.hasSubmit;
});
const submitTables = row.tables.filter(function (entry) {
return entry.hasSubmit;
});
let maxThHeight = 0;
let maxTdHeight = 0;
filterTables.forEach(function (entry) {
if (entry.th) {
maxThHeight = Math.max(maxThHeight, entry.th.offsetHeight);
}
if (entry.td) {
maxTdHeight = Math.max(maxTdHeight, entry.td.offsetHeight);
}
});
filterTables.forEach(function (entry) {
if (entry.th && maxThHeight > 0) {
entry.th.style.height = maxThHeight + "px";
}
if (entry.td && maxTdHeight > 0) {
entry.td.style.height = maxTdHeight + "px";
}
});
// Po dorovnaní filtrov získame ich skutočnú výslednú výšku.
void wrapper.offsetHeight;
let targetTableHeight = 0;
filterTables.forEach(function (entry) {
targetTableHeight = Math.max(
targetTableHeight,
entry.table.getBoundingClientRect().height
);
});
/*
min-height na | prehliadače pri table layoute ignorujú (blikne a zmrští sa).
Dorovnanie musí ísť na , kde min-height platí.
*/
submitTables.forEach(function (entry) {
const ownTableHeight = entry.table.getBoundingClientRect().height;
const finalHeight = targetTableHeight > 0
? Math.max(ownTableHeight, targetTableHeight)
: ownTableHeight;
if (finalHeight > 0) {
entry.table.style.minHeight = Math.ceil(finalHeight) + "px";
}
});
});
}
let filterRowsEqualizeTimer = null;
let filterRowsEqualizeFrame = null;
let filterVisibilityObserver = null;
let observedFilterWrapper = null;
function scheduleEqualizeFilterRows(delay = 0) {
clearTimeout(filterRowsEqualizeTimer);
if (filterRowsEqualizeFrame !== null) {
cancelAnimationFrame(filterRowsEqualizeFrame);
filterRowsEqualizeFrame = null;
}
function queueEqualize() {
filterRowsEqualizeFrame = requestAnimationFrame(function () {
filterRowsEqualizeFrame = requestAnimationFrame(function () {
filterRowsEqualizeFrame = null;
equalizeFilterRows();
});
});
}
if (delay > 0) {
filterRowsEqualizeTimer = setTimeout(function () {
filterRowsEqualizeTimer = null;
queueEqualize();
}, delay);
} else {
filterRowsEqualizeTimer = null;
queueEqualize();
}
}
function getInlineDisplayValue(styleText) {
const match = (styleText || "").match(/(?:^|;)\s*display\s*:\s*([^;]+)/i);
return match ? match[1].trim().toLowerCase() : "";
}
function initFilterVisibilityObserver() {
const wrapper = document.querySelector(".filter_wrapper_safe");
if (!wrapper || wrapper === observedFilterWrapper) {
return;
}
if (filterVisibilityObserver !== null) {
filterVisibilityObserver.disconnect();
}
observedFilterWrapper = wrapper;
filterVisibilityObserver = new MutationObserver(function (mutations) {
const displayChanged = mutations.some(function (mutation) {
if (mutation.type !== "attributes" || mutation.attributeName !== "style") {
return false;
}
return getInlineDisplayValue(mutation.oldValue) !==
getInlineDisplayValue(mutation.target.getAttribute("style"));
});
if (!displayChanged) {
return;
}
requestAnimationFrame(function () {
normalizeFilterInlineWrappers();
scheduleEqualizeFilterRows();
});
});
filterVisibilityObserver.observe(wrapper, {
subtree: true,
attributes: true,
attributeFilter: ["style"],
attributeOldValue: true
});
}
document.addEventListener("change", function (event) {
if (!(event.target instanceof Element) || !event.target.closest(".fixheight")) {
return;
}
requestAnimationFrame(function () {
normalizeFilterInlineWrappers();
scheduleEqualizeFilterRows();
});
});
function patchtables() {
const root = document.getElementById("mainscreen") || document.body;
function isFilterTable(el) {
return el &&
el.nodeType === 1 &&
el.matches("table.niceborder.fix_size");
}
function isInlineFilterBlock(el) {
return el &&
el.nodeType === 1 &&
(el.id === "show_search" || el.id === "show_zorad" || el.id === "hiderok");
}
function countFilterTables(node) {
if (isFilterTable(node)) {
return 1;
}
if (node && node.querySelectorAll) {
return node.querySelectorAll("table.niceborder.fix_size").length;
}
return 0;
}
function parentHasDirectWrapper(parent) {
return Array.prototype.slice.call(parent.children).some(function (child) {
return child.classList && child.classList.contains("filter_wrapper_safe");
});
}
function wrapFilterChildren(parent) {
if (!parent || parentHasDirectWrapper(parent)) {
return false;
}
const children = Array.prototype.slice.call(parent.children);
const nodes = children.filter(function (child) {
return isFilterTable(child) || isInlineFilterBlock(child);
});
let tableCount = 0;
nodes.forEach(function (node) {
tableCount += countFilterTables(node);
});
if (tableCount < 2) {
return false;
}
const hasSubmit = nodes.some(function (node) {
return node.querySelector &&
node.querySelector('input[type="submit"], button[type="submit"]');
});
const hasShowSearch = nodes.some(function (node) {
return isInlineFilterBlock(node);
});
/*
Bez show_search obalíme iba formuláre, ktoré majú submit.
Tým sa vyhneme tomu, aby sa omylom obalili obyčajné dátové tabuľky.
*/
if (!hasSubmit && !hasShowSearch) {
return false;
}
const wrapper = document.createElement("div");
wrapper.className = "filter_wrapper_safe";
parent.insertBefore(wrapper, nodes[0]);
nodes.forEach(function (node) {
wrapper.appendChild(node);
});
return true;
}
/*
1. Starý režim:
Ak existuje #show_search alebo #show_zorad, obalí jeho rodiča.
*/
["show_search", "show_zorad"].forEach(function (id) {
const block = document.getElementById(id);
if (block && !block.closest(".filter_wrapper_safe")) {
wrapFilterChildren(block.parentNode);
}
});
/*
2. Nový režim:
Ak show_search neexistuje, hľadáme formulár s priamymi filter tabuľkami.
Toto rieši napr. Dochádzky > Prehľad.
*/
Array.prototype.slice.call(root.querySelectorAll("form")).forEach(function (form) {
if (!form.querySelector("table.niceborder.fix_size")) {
return;
}
if (form.querySelector(".filter_wrapper_safe")) {
return;
}
wrapFilterChildren(form);
});
initFilterVisibilityObserver();
requestAnimationFrame(function () {
if (typeof resethidden === "function") {
resethidden();
}
if (typeof normalizeFilterInlineWrappers === "function") {
normalizeFilterInlineWrappers();
}
scheduleEqualizeFilterRows();
});
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", function () {
patchtables();
});
} else {
patchtables();
}
window.addEventListener("resize", function () {
scheduleEqualizeFilterRows(120);
});
window.addEventListener("load", function () {
scheduleEqualizeFilterRows();
});
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(function () {
scheduleEqualizeFilterRows();
});
}
$(window).on("load", function(){
//pre back tlacitko
if ($('.return_page').length > 0) {
$('#go_back').show();
} else {
$('#go_back').hide();
}
//pre select2
$("select").each(function(){ // kvoli cervenemu background musime mat class='required' spolus parametrom required pri selectoch
if($(this).prop('required')){
$(this).addClass("required");
}
});
$("select").not(".nochosen").not(".chosen8").not(".chosen14").not(".chosen20").not(".chosen50").not(".chosen30").addClass("chosen-select");
$('.chosen-select').on("change",function() {
centerintro_adminheight();
});
// zobrazenie obsahu skôr – pri chybe/pomalom select2 init (napr. indikacie_uprav s desiatkami multi-selectov) inak zostane len nadpis
$("#loading").hide();
$("#mainscreen").show();
isloaded=1;
var config = {
'.chosen-select' : {dropdownAutoWidth : true, width: "100%"},
'.chosen8' : {dropdownAutoWidth : true, width: "100%",maximumSelectionLength:8},
'.chosen14' : {dropdownAutoWidth : true, width: "100%",maximumSelectionLength:14},
'.chosen20' : {dropdownAutoWidth : true, width: "100%",maximumSelectionLength:20},
'.chosen30' : {dropdownAutoWidth : true, width: "100%",maximumSelectionLength:30},
'.chosen50' : {dropdownAutoWidth : true, width: "100%",maximumSelectionLength:50}
}
try {
for (var selector in config) {
$(selector).select2(config[selector]);
$(selector).each(function() {
//$(this).find('option[value=""]').remove();
if($(this).prop('required')){
var selectedOptions = $(this).select2('val');
// Získaj počet vybraných položiek
if (selectedOptions !='' && selectedOptions !=null) {
$(this).next('.select2-container').find('.select2-selection').css('background-color', 'white');
} else {
$(this).next('.select2-container').find('.select2-selection').css('background-color', '#fdd');
}
}
});
$(selector).on('change, change.select2', function() {
if($(this).prop('required')){
var selectedOptions = $(this).select2('val');
// Získaj počet vybraných položiek
if (selectedOptions !='' && selectedOptions !=null) {
$(this).next('.select2-container').find('.select2-selection').css('background-color', 'white');
} else {
$(this).next('.select2-container').find('.select2-selection').css('background-color', '#fdd');
}
}
}); }
} catch (select2Err) {
console.error('select2 init:', select2Err);
}
// kalendar v tyzdni/dni skok na cas od 8:00
setTimeout("$('.scolltimeevent').scrollTop(330)", 1000);
autosize(document.querySelectorAll('textarea'));
//uprava tabuliek
centerintro_adminheight();
patchtables();
if (document.body.scrollHeight > document.body.clientHeight) {
$(".scrollbutton2").show();
}
function nativeFileClearSync(input) {
if (!input || input.type !== "file") { return; }
var button = input._nativeFileClearButton;
if (!button) {
button = document.createElement("button");
button.type = "button";
button.className = "native_file_clear";
button.textContent = "×";
button.title = "Odobrať vybraný súbor";
button.setAttribute("aria-label", "Odobrať vybraný súbor");
button._nativeFileInput = input;
input._nativeFileClearButton = button;
input.insertAdjacentElement("afterend", button);
}
button.hidden = !(input.files && input.files.length > 0);
}
$("input[type='file']").each(function() {
nativeFileClearSync(this);
});
$(document).on("change", "input[type='file']", function() {
nativeFileClearSync(this);
});
$(document).on("click", ".native_file_clear", function(event) {
event.preventDefault();
event.stopPropagation();
var input = this._nativeFileInput;
if (!input || input.disabled) { return; }
input.value = "";
$(input).trigger("input").trigger("change");
input.focus();
});
$(document).on("reset", "form", function() {
var form = this;
setTimeout(function() {
$(form).find("input[type='file']").each(function() {
nativeFileClearSync(this);
});
}, 0);
});
function syncAdminContentHeight() {
const left = document.querySelector(".screen_admin_1");
const right = document.querySelector(".screen_admin_2");
if (!left || !right) {
return;
}
// Na mobile necháme pôvodné správanie
if (window.innerWidth < 801) {
right.style.removeProperty("min-height");
return;
}
const windowHeight = window.innerHeight;
let finalHeight;
if (document.body.classList.contains("admin_menu_collapsed")) {
finalHeight = windowHeight - 20;
} else {
const leftHeight = Math.ceil(left.getBoundingClientRect().height);
finalHeight = Math.max(leftHeight, windowHeight) - 20;
}
right.style.setProperty("min-height", finalHeight + "px", "important");
}
window.syncAdminContentHeight = syncAdminContentHeight;
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", syncAdminContentHeight);
} else {
syncAdminContentHeight();
}
window.addEventListener("load", syncAdminContentHeight);
window.addEventListener("resize", syncAdminContentHeight);
document.addEventListener("click", function(e) {
if (
e.target.closest(".headerbar") ||
e.target.closest(".subexpandable") ||
e.target.closest(".urbangreymenu")
) {
setTimeout(syncAdminContentHeight, 100);
setTimeout(syncAdminContentHeight, 400);
setTimeout(syncAdminContentHeight, 800);
}
});
const adminMenuForHeight = document.querySelector(".screen_admin_1");
if (adminMenuForHeight) {
const adminMenuObserver = new MutationObserver(function () {
syncAdminContentHeight();
});
adminMenuObserver.observe(adminMenuForHeight, {
childList: true,
subtree: true,
attributes: true
});
}
});
reloadedcal=0;
isloaded=0;
if (document.getElementById('mainscreen')) { document.getElementById('mainscreen').insertAdjacentHTML('beforebegin',"
"); }
$(window).on("resize", function() {
centerintro_adminheight();
if (typeof loadcal == 'function') { loadcal(); }
patchtables();
$(document).scroll();
});
$(".ok, .err").hide();
(function () {
const SHOW_MS = 2500;
function initPdfNotice() {
const spinner = document.getElementById("pdf_spinner");
if (!spinner) return;
let timerId = null;
function showFor(ms) {
spinner.hidden = false;
clearTimeout(timerId);
timerId = setTimeout(() => {
spinner.hidden = true;
}, ms);
}
function isMyPdfLink(a) {
const href = a.getAttribute("href") || "";
return /(^|\/)box_pdf_.*\.php(\?|#|$)/i.test(href);
}
// capture=true aby to fungovalo aj pri iných click handleroch
document.addEventListener("click", (e) => {
const a = e.target.closest("a");
if (!a) return;
if (!isMyPdfLink(a)) return;
// nič neblokujeme -> download prebehne normálne
showFor(SHOW_MS);
}, true);
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initPdfNotice);
} else {
initPdfNotice();
}
})();
function customAlert(message,type='error'){
const iconSrc = {
warning: 'obr/warningbw.png',
error: 'obr/error.png',
info: 'obr/infobw.png'
};
const borderColor = {
warning: 'orange',
error: 'red',
info: 'blue'
}[type] || 'gray';
const overlay = document.createElement('div');
overlay.className = 'modal-overlay';
overlay.innerHTML = `
${message} Pre zatvorenie stlačte krížik alebo ESC.
`;
document.body.appendChild(overlay);
}
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
const modal = document.querySelector('.modal-overlay');
if (modal) {
modal.remove();
}
}
});
$(function() {
document.querySelectorAll("button").forEach(btn => {
if (btn.textContent.trim().includes("Vlož do systému") || btn.textContent.trim().includes("Rezervuj vozidlo")|| btn.textContent.trim().includes("Pridaj nový jedálny lístok")|| btn.textContent.trim().includes("Nový")|| btn.textContent.trim().includes("Pridaj novú nástenku")|| btn.textContent.trim().includes("Nová")|| btn.textContent.trim().includes("Vytvor novú skupinu")) {
btn.classList.add("btn_new");
const img = document.createElement("img");
img.src = "obr/upload_new.png";
img.className = "head_btn_icon";
btn.prepend(img);
}
if (btn.textContent.trim().includes("Prázdne tlačivo")) {
const img = document.createElement("img");
img.src = "obr/empty_file.png";
img.className = "head_btn_icon";
btn.prepend(img);
}
});
//on ctrl+n
$(document).on('keydown', function(e) {
if (e.altKey && e.key.toLowerCase() === 'n') {
$('.return_page').click();
}
});
//autosize(document.querySelectorAll('textarea'));
$(".inline").colorbox({inline:true, width:"50%"});
$(document).on("keypress", ":input:not(textarea):not(.loginfield)", function(event) {
return event.keyCode != 13;
});
$('.loginfield').on("keyup", function(e) {
if (e.keyCode == 13) {
$("#loginbox").click();
}
});
$(document).on("keyup", function(e) {
if (e.keyCode == 27) {
$("#ok-final").hide();
}
if (e.keyCode == 36 && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
//$("#go_home")[0].click(); lebo davalo home aj ked sa kliklo s home nechtiac nejake pismeno ci znak
}
});
$('form :input').attr('autocomplete', 'off'); // reset autofill na post pri navrate sipkou cez prehliadac
$(document).on('keydown', disableFunctionKeys);
$(document).on('scroll',function(e) {
if ($(document).scrollLeft()==0 && $(document).scrollTop()==0) {
$(".scrollbutton").hide();
if (document.body.scrollHeight > document.body.clientHeight) {
$(".scrollbutton2").show();
} else {
$(".scrollbutton2").hide();
}
} else {
$(".scrollbutton").show();
$(".scrollbutton2").hide();
}
});
$(".scrollbutton").on('click', function() {
$("html, body").animate({scrollTop:0}, { duration: 333, queue: false });
$("html, body").animate({scrollLeft:0}, { duration: 333, queue: false });
$(".scrollbutton").hide();
});
$(".scrollbutton2").on('click', function() {
var n = $(document).height();
$("html, body").animate({scrollTop:n}, { duration: 333, queue: false });
$("html, body").animate({scrollLeft:0}, { duration: 333, queue: false });
$(".scrollbutton").show();
$(".scrollbutton2").hide();
});
$("#go_back").on('click', function() {
$(".return_page").click();
});
$('input[type="checkbox"]').each(function() { // kvoli stylom na checkbox ktory nema label, taks a musi dogenerovat
var checkbox = $(this);
var checkboxId = checkbox.attr('id');
if (!checkboxId) {
checkboxId = checkbox.attr('name');
checkbox.attr('id', checkboxId);
}
var label = $('label[for="' + checkboxId + '"]');
if (label.length === 0) {
label = $(' |