Plumbing | Klauke
' + ''; } var customEventObj = { EventType: 'User Clicked Show All Results From Dropdown', LastSearchQueryUid: data.search_query_uid, OriginContext: proxyWindowLocation.href }; var stringifiedCustomEventObj = stringifyObject(customEventObj); searchResultsDropdownHtml += '' + 'Show all results' + ''; searchAsYouTypeResults.html(searchResultsDropdownHtml); searchAsYouTypeResults[0].style.display = "block"; } else { searchAsYouTypeResults[0].style.display = "none"; } }) .fail(function (e) { console.log(e); }) } else { searchAsYouTypeResults[0].style.display = "none"; } }); function openSearchBox() { if (searchModal.hasClass("closed")) { $(".locale-selector-modal:visible").trigger("closeLocalModal"); searchToggle.addClass("hidden"); searchModal.removeClass("closed"); searchContainer.css("display", "block"); mobileSearchToggle.toggleClass("opened"); mobileSearchToggle.attr("aria-expanded", true); searchToggle.attr("aria-expanded", true); if (!($(".alert").is(":visible"))) { /* On mobile, giveaway banner alert is below the header. The search box will cover over it since it has the same height, but if alert does not exist padding needs to fill the area behind the search box so the top of the main content doesn't get covered. */ $("#search-padding").show(); } setTimeout(function () { textBox.focus(); }, 400); } }; function closeSearchBox() { if (!searchModal.hasClass("closed")) { var wasFocused = searchContainer.has(":focus").length > 0; mobileSearchToggle.toggleClass("opened"); mobileSearchToggle.attr("aria-expanded", false); searchToggle.attr("aria-expanded", false); searchToggle.removeClass("hidden"); searchModal.addClass("closed"); searchContainer.css("display", "none"); $("#search-padding").hide(); setTimeout(function () { if (wasFocused) { if (mobileSearchToggle.is(":visible")) mobileSearchToggle.focus(); else if (searchToggle.is(":visible")) searchToggle.focus(); } }, 200); } }; $(document) .on("click", function (e) { if ($(e.target).parents("#search").length === 0 && $(e.target).attr("id") !== mobileSearchToggle.attr("id") && $(e.target).parents("#" + mobileSearchToggle.attr("id")).length === 0) closeSearchBox(); }); searchContainer .on("blur", closeSearchBox) .on("focus", openSearchBox) .on("keydown", function (e) { if (e.key === "Escape" || e.key === "ArrowUp") { e.stopPropagation(); //stop event going to window listeners in layout.js closeSearchBox(); } }); mobileSearchToggle .on("click", function () { // Toggles the search bar and closes the locale selector if it"s open since only one should be open at a time if (searchModal.is(":visible")) closeSearchBox(); else openSearchBox(); return false; }) .on("keydown", function (e) { if (e.key === "Escape") $("a.img-logo").focus(); else if (e.key === "ArrowUp") e.preventDefault(); else if (e.key === "Enter" || e.key === "ArrowDown") { e.preventDefault(); openSearchBox(); } }); searchToggle .on("click", openSearchBox) .on("keydown", function (e) { if (e.key === "Escape") $("#brands-control-id").focus(); else if (e.key === "ArrowUp") e.preventDefault(); else if (e.key === "Enter" || e.key === "ArrowDown") { e.preventDefault(); openSearchBox(); } }); textBox .on("keydown", function (e) { if (e.key === "Tab" && e.shiftKey) { e.preventDefault(); closeSearchBox(); } }); $(".bigSearchButton").on("keydown", function (e) { if (e.key === "Tab" && !e.shiftKey) { e.preventDefault(); closeSearchBox(); } }); closeButton .on("click", closeSearchBox) .on("keydown", function (e) { if (e.key === "Enter" || (e.key === "Tab" && !e.shiftKey) || e.key === "ArrowRight" || e.key === "ArrowDown") { e.preventDefault(); closeSearchBox(); } }); });