@@ -58,21 +58,25 @@ if (toggleContentNav !== null) {
5858 });
5959}*/
6060
61−function initToggleMenu() {
62− var toggleContentNav = document.getElementById('js-search-window-toggle');
63− if (toggleContentNav !== null) {
64− toggleContentNav.onclick = function() {
65− document.body.classList.toggle('has-active-search-window');
61+function initToggleSearchWindow() {
62+ var toggleSearchWindow = document.getElementById('js-search-window-toggle');
63+ var bodyEl = document.body;
64+ var searchOverlay = document.getElementById('search-overlay');
65+ var searchWindow = document.getElementById('search-window');
66+ var searchActive = bodyEl.classList.contains('has-active-search-window');
67+ if (toggleSearchWindow !== null) {
68+ toggleSearchWindow.onclick = function() {
69+ bodyEl.classList.toggle('has-active-search-window');
6670 }
71+ searchOverlay.addEventListener('click', function(e){
72+ if (!searchWindow.contains(e.target)){
73+ bodyEl.classList.toggle('has-active-search-window');
74+ }
75+ })
6776 }
6877}
6978
70−var toggleContentNav = document.getElementById('js-search-window-toggle');
71−if (toggleContentNav !== null) {
72− toggleContentNav.onclick = function() {
73− document.body.classList.toggle('has-active-search-window');
74− }
75−}
79+
7680
7781//
7882 // search functionality
@@ -218,7 +222,7 @@ function initSearch() {
218222 var searchResults = document.querySelector(".search-results");
219223 var searchResultsHeader = document.querySelector(".search-results__header");
220224 var searchResultsItems = document.querySelector(".search-results__items");
221− var MAX_ITEMS = 10;
225+ var MAX_ITEMS = 200;
222226
223227 var options = {
224228 bool: "AND",
@@ -255,9 +259,6 @@ function initSearch() {
255259 if (!results[i].doc.body) {
256260 continue;
257261 }
258− // var item = document.createElement("li");
259− // item.innerHTML = formatSearchResultItem(results[i], term.split(" "));
260− console.log(results[i]);
261262 searchResultsItems.appendChild(formatSearchResultItem(results[i], term.split(" ")));
262263 }
263264 }, 150));
@@ -266,10 +267,10 @@ function initSearch() {
266267if (document.readyState === "complete" ||
267268 (document.readyState !== "loading" && !document.documentElement.doScroll)
268269) {
269− initToggleMenu();
270+ initToggleSearchWindow();
270271} else {
271272 document.addEventListener("DOMContentLoaded", function () {
272− initToggleMenu();
273+ initToggleSearchWindow();
273274 initSearch();
274275 });
275276}