From ec0aa08c3fe2c47b57f641f9321d37406e3caede Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Fri, 13 Apr 2018 18:42:09 +0530 Subject: [PATCH] added the search toggle functionality in the navbar --- foundation/public/css/erpnext-org-theme.css | 7 ++++-- foundation/public/js/index.js | 23 +++++++++++++++++++ foundation/templates/base.html | 6 ++++- .../templates/includes/navbar/navbar.html | 8 +++---- 4 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 foundation/public/js/index.js diff --git a/foundation/public/css/erpnext-org-theme.css b/foundation/public/css/erpnext-org-theme.css index cab403b1..29958090 100644 --- a/foundation/public/css/erpnext-org-theme.css +++ b/foundation/public/css/erpnext-org-theme.css @@ -6,15 +6,18 @@ a { color: var(--dark-grey); /* */ } + .js-search-form { - position: relative; + right: 0.75rem; } + .js-search-input-icon { position: absolute; - right: 1.5rem; + right: 1.75rem; top: 50%; transform: translateY(-50%); } + .js-search-icon { cursor: pointer; } diff --git a/foundation/public/js/index.js b/foundation/public/js/index.js new file mode 100644 index 00000000..5042c2bf --- /dev/null +++ b/foundation/public/js/index.js @@ -0,0 +1,23 @@ +// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ready(function(){ + + var searchButton = document.querySelector(".js-search-icon"); + var searchForm = document.querySelector(".js-search-form"); + var searchInput = document.querySelector(".js-search-input"); + var searchInputButton = document.querySelector(".js-search-input-icon"); + + searchButton.addEventListener("click", function(){ + searchForm.classList.remove("display-none"); + }); + + searchInput.addEventListener("blur", function(){ + // this is not working... todo_fn + searchForm.classList.add("display-none"); + }, false) + + searchInputButton.addEventListener("click", function(){ + searchForm.classList.add("display-none"); + }) +}) \ No newline at end of file diff --git a/foundation/templates/base.html b/foundation/templates/base.html index cb299903..0054b8da 100644 --- a/foundation/templates/base.html +++ b/foundation/templates/base.html @@ -26,7 +26,11 @@ {%- endfor -%} - {%- block script %}{%- endblock %} + {%- block script %} + + {%- endblock %} diff --git a/foundation/templates/includes/navbar/navbar.html b/foundation/templates/includes/navbar/navbar.html index c826baab..80a5e3e4 100644 --- a/foundation/templates/includes/navbar/navbar.html +++ b/foundation/templates/includes/navbar/navbar.html @@ -24,8 +24,8 @@ {% endif %} -
- +