lingua = location.pathname.substring(0, 3); function hideModal() { $("#overlaySearch").hide(); $("#contenitoreModaleSearch").hide(); $(".navbar-default").css("z-index", "6"); $(".box-search ul li[data-clickcategory]").removeClass("active"); } function showModal() { var WidthColumnSx = $(".column-sx").width() + 15; var HeightSearchBox = $(".box-search").outerHeight(); var OffsetTopSearchHeightBox = $(".box-search").offset().top; var OffsetLeftSearchHeightBox = $(".box-search").offset().left; var WidthByBoxContainer = $("#contenitoreModaleSearch").width(); $("#overlaySearch").show(); $("#contenitoreModaleSearch").css("width", ongreening.isMobile ? (WidthColumnSx - 15) : WidthColumnSx); $("#contenitoreModaleSearch").css("height", HeightSearchBox); $("#contenitoreModaleSearch").css("top", OffsetTopSearchHeightBox); var isInverted = $('.column-dx-inverted')[0] !== null; var left = 0; if (ongreening.isMobile) { left = 10; } else { left = OffsetLeftSearchHeightBox - WidthByBoxContainer - 8; if (isInverted) { left = $('.box-search').position().left + WidthByBoxContainer; left = left - 337; } } $("#contenitoreModaleSearch").css("left", left); if (isInverted) { $('.box-search').addClass('box-search-inverted'); } $(".navbar-default").css("z-index", "4"); $("#contenitoreModaleSearch").css("z-index", "6"); $("#contenitoreModaleSearch").show(); $(".box-search ul li[data-clickcategory]").removeClass("active"); } function ReHeightAccordion() { $(".filterBy #elencoStandard").animate({ "height": "auto" }, 500, "linear"); $(".filterBy #elencoNazioni").animate({ "height": "auto" }, 500, "linear"); } function ResetFilterCategory(nome) { var html = " " + nome + " x"; $("#AccordionCategory .nameCategory").html(html); hideModal(); } $(document).ready(function () { $("
").appendTo("body"); $("
").appendTo("body").html("
"); $('.filterBy').accordion({ active: false, collapsible: true, beforeActivate: function (event, ui) { // The accordion believes a panel is being opened if (ui.newHeader[0]) { var currHeader = ui.newHeader; var currContent = currHeader.next('.ui-accordion-content'); // The accordion believes a panel is being closed } else { var currHeader = ui.oldHeader; var currContent = currHeader.next('.ui-accordion-content'); } // Since we've changed the default behavior, this detects the actual status var isPanelSelected = currHeader.attr('aria-selected') == 'true'; // Toggle the panel's header currHeader.toggleClass('ui-corner-all', isPanelSelected).toggleClass('accordion-header-active ui-state-active ui-corner-top', !isPanelSelected).attr('aria-selected', ((!isPanelSelected).toString())); // Toggle the panel's icon currHeader.children('.ui-icon').toggleClass('ui-icon-triangle-1-e', isPanelSelected).toggleClass('ui-icon-triangle-1-s', !isPanelSelected); // Toggle the panel's content currContent.toggleClass('accordion-content-active', !isPanelSelected) if (isPanelSelected) { currContent.slideUp(); } else { currContent.slideDown(); } return false; // Cancels the default action } }); var myTime; $("[data-clickcategory]", ".column-dx #AccordionCategory").on("click mouseenter", function (event) { $(".column-dx .box-search ul li[data-clickcategory]").removeClass("active"); var thisElement = $(this); var IdCategoria = thisElement.data("clickcategory"); clearTimeout(myTime); myTime = setTimeout(function () { $("#contenitoreModaleSearch").addClass("loading"); }, 500); showModal(); $("#contenitoreModaleSearchInner").load(lingua + "/Products/LoadTipologiaProdottoPage", { IdCategoria: IdCategoria }, function () { clearTimeout(myTime); $("#contenitoreModaleSearch").removeClass("loading"); showModal(); thisElement.addClass("active"); }); }); $("[data-clickcategory]", ".column-sx #AccordionCategory").on("click", function (event) { $(".column-sx .box-search ul li[data-clickcategory]").removeClass("active"); var thisElement = $(this); var IdCategoria = thisElement.data("clickcategory"); clearTimeout(myTime); myTime = setTimeout(function () { $("#contenitoreModaleSearch").addClass("loading"); }, 500); showModal(); $("#contenitoreModaleSearchInner").load(lingua + "/Products/LoadTipologiaProdottoPage", { IdCategoria: IdCategoria }, function () { clearTimeout(myTime); $("#contenitoreModaleSearch").removeClass("loading"); showModal(); thisElement.addClass("active"); }); }); $(window).resize(function () { if ($("#overlaySearch").is(':visible')) { showModal(); } }); $("#overlaySearch").click(function (event) { hideModal(); }); $("#elencoStandard span[data-nome-standard]").on("click", function () { $(this).parent().children("input[data-nome-standard='" + $(this).data("nome-standard") + "']").click(); }); $("#elencoNazioni span[data-nome-area]").on("click", function () { $(this).parent().children("input[data-nome-area='" + $(this).data("nome-area") + "']").click(); }); $(document).on("click", "[data-text-originale]", function () { var text_originale = $(this).data("text-originale"); $(this).parent().html(" " + text_originale); $(".TipologiaProdottoHidden").val(""); $(".SottoCategoriaProdottoHidden").val(""); }); $(document).on("click", "[data-click-sottocategoria-id]", function () { var idSottoCategoria = $(this).data("click-sottocategoria-id"); var nomeSottoCategoria = $(this).data("click-sottocategoria-nome"); $("#frmFiltri input[name=tx]").val(""); $(".TipologiaProdottoHidden").val(""); $(".SottoCategoriaProdottoHidden").val(idSottoCategoria); ResetFilterCategory(nomeSottoCategoria); $('#AccordionCategory .nameCategory').click(); categoryClicked($(this)); }); $(document).on("click", "[data-click-tipologia-id]", function () { var idTipologia = $(this).data("click-tipologia-id"); var nomeTipologia = $(this).data("click-tipologia-nome"); $("#frmFiltri input[name=tx]").val(""); $(".TipologiaProdottoHidden").val(idTipologia); $(".SottoCategoriaProdottoHidden").val(""); ResetFilterCategory(nomeTipologia); $('#AccordionCategory .nameCategory').click(); categoryClicked($(this)); }); function categoryClicked(el) { var url = $(el).data("category-url"); var action = $("#frmFiltri").attr('action').replace("Search", url); $("#frmFiltri").attr('action', action); $("#frmFiltri").submit(); } //Filtered By $("#elencoStandard").on("click", function () { ReHeightAccordion(); }); $("#elencoNazioni").on("click", function () { ReHeightAccordion(); }); $("#frmFiltri input[name=tx]").click(hideModal); $('.autocomplete-testo-ricerca').autocomplete({ search: function (request, response) { }, source: function (request, response) { $.get(lingua + '/Products/CercaProdotti', { Testo: request.term }, function (data) { response($.map(data, function (item) { return { label: item }; })); }); }, minLength: 3, open: function (event, ui) { $('#div .ui-menu').css("width", "auto"); var id = $(".autocomplete-testo-ricerca").autocomplete("widget")[0].id; ongreening.evidenzia(id, $(event.target).val()); } }); if ($(".box-search") != null && $(".box-search").length > 1 && ongreening.isMobile) { $(".column-dx #frmFiltri").detach(); } else { $(".column-sx #frmFiltri").detach(); } });