jQuery(document).ready(function ($){
$('ul.tabs li a').on('click', function (){
var $tab=$(this);
var tabId=$tab.attr('href');
if(tabId==='#tab-sigurnosne_informacije'){
var $contentDiv=$('.sigurnosne-informacije-content');
var $filesDiv=$('.sigurnosne-informacije-files');
var productID=$contentDiv.data('productid');
var nonce=$contentDiv.data('nonce');
var docTitle=$contentDiv.data('title');
if(!productID){
return;
}
$.ajax({
url: safetyInfoAjax.ajax_url,
method: 'POST',
data: {
action: 'load_brand_info',
security: nonce,
product_id: productID
},
success: function (response){
if(response.success){
$contentDiv.html(response.data.html).slideDown();
$('.sigurnosne-informacije-content').css('background-image', 'none');
}else{
$('.sigurnosne-informacije-content').css('background-image', 'none');
}},
error: function (jqXHR, textStatus, errorThrown){
$('.sigurnosne-informacije-content').css('background-image', 'none');
}});
$.ajax({
url: safetyInfoAjax.rest_url,
type: 'GET',
data: {product_id: productID},
success: function (response){
if(!response||response.length===0){
}else{
var listHtml='<hr><h3>' + docTitle + '</h3><ul>';
response.forEach(function (file){
listHtml +='<li><a class="' + file.type + '" href="' + file.url + '" target="_blank">' + file.name + '</a></li>';
});
listHtml +='</ul>';
$filesDiv.html(listHtml).slideDown();
}},
error: function (){
$filesDiv.html('<p>Greška pri dohvaćanju dokumenata.</p>').slideDown();
}});
}});
});
document.addEventListener("DOMContentLoaded",function(){let a=document.getElementById("site-navigation");if(a){let n=a.querySelector("button");if(n){let t=a.querySelector("ul");if(t){n.setAttribute("aria-expanded","false"),t.setAttribute("aria-expanded","false"),t.classList.add("nav-menu"),n.addEventListener("click",function(){a.classList.toggle("toggled");var e=a.classList.contains("toggled")?"true":"false";n.setAttribute("aria-expanded",e),t.setAttribute("aria-expanded",e)});var e=document.getElementsByClassName("handheld-navigation");if(0<e.length&&[].forEach.call(e[0].querySelectorAll(".menu-item-has-children > a, .page_item_has_children > a"),function(e){let t=document.createElement("button"),n=(t.setAttribute("aria-expanded","false"),t.classList.add("dropdown-toggle"),document.createElement("span"));n.classList.add("screen-reader-text"),n.appendChild(document.createTextNode(storefrontScreenReaderText.expand)),t.appendChild(n),e.parentNode.insertBefore(t,e.nextSibling),e.parentNode.classList.contains("current-menu-ancestor")&&(t.setAttribute("aria-expanded","true"),t.classList.add("toggled-on"),t.nextElementSibling.classList.add("toggled-on")),t.addEventListener("click",function(){for(t.classList.toggle("toggled-on");n.firstChild;)n.removeChild(n.firstChild);var e=t.classList.contains("toggled-on");t.setAttribute("aria-expanded",e),n.appendChild(document.createTextNode(e?storefrontScreenReaderText.collapse:storefrontScreenReaderText.expand)),t.nextElementSibling.classList.toggle("toggled-on")})}),[].forEach.call(document.querySelectorAll(".site-header .menu-item > a, .site-header .page_item > a, .site-header-cart a"),function(t){t.addEventListener("focus",function(){var e=document.querySelectorAll(".focus");[].forEach.call(e,function(e){e.contains(t)||(e.classList.remove("focus"),e.firstChild&&e.firstChild.classList&&e.firstChild.classList.remove("blocked"))}),t.parentNode.classList.add("focus")})}),[].forEach.call(document.querySelectorAll("body #page > :not(.site-header)"),function(e){e.addEventListener("click",function(){[].forEach.call(document.querySelectorAll(".focus, .blocked"),function(e){e.classList.remove("focus"),e.classList.remove("blocked")})})}),("ontouchstart"in window||window.navigator.maxTouchPoints)&&767<window.innerWidth){[].forEach.call(document.querySelectorAll(".site-header ul ul, .site-header-cart .widget_shopping_cart"),function(e){e.classList.add("sub-menu--is-touch-device")});let n=!1;[].forEach.call(document.querySelectorAll(".site-header .menu-item > a, .site-header .page_item > a, .site-header-cart a"),function(t){t.addEventListener("click",function(e){t.classList.contains("blocked")&&!1===n&&e.preventDefault(),n=!1}),t.addEventListener("pointerup",function(e){!t.classList.contains("blocked")&&"mouse"!==e.pointerType&&("cart-contents"===t.className&&t.parentNode.nextElementSibling&&""!==t.parentNode.nextElementSibling.textContent.trim()||t.nextElementSibling)?t.classList.add("blocked"):n=!0})})}}else n.style.display="none"}}});