added the search toggle functionality in the navbar

This commit is contained in:
Manas Solanki
2018-04-13 18:42:09 +05:30
parent 2f010aa64d
commit ec0aa08c3f
4 changed files with 37 additions and 7 deletions

View File

@@ -6,15 +6,18 @@ a {
color: var(--dark-grey); color: var(--dark-grey);
/* */ /* */
} }
.js-search-form { .js-search-form {
position: relative; right: 0.75rem;
} }
.js-search-input-icon { .js-search-input-icon {
position: absolute; position: absolute;
right: 1.5rem; right: 1.75rem;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
} }
.js-search-icon { .js-search-icon {
cursor: pointer; cursor: pointer;
} }

View File

@@ -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");
})
})

View File

@@ -26,7 +26,11 @@
<script type="text/javascript" src="{{ link|abs_url }}"></script> <script type="text/javascript" src="{{ link|abs_url }}"></script>
{%- endfor -%} {%- endfor -%}
{%- block script %}{%- endblock %} {%- block script %}
<script>
{% include 'public/js/index.js' %}
</script>
{%- endblock %}
<!-- csrf_token --> <!-- csrf_token -->
</body> </body>

View File

@@ -24,8 +24,8 @@
{% endif %} {% endif %}
<!-- breadcrumbs --> <!-- breadcrumbs -->
</div> </div>
<div class="right flex align-item-center"> <div class="right flex align-item-center display-rel">
<a class="hover-light-grey border-radius ml3" href="/login"> <a class="hover-light-grey border-radius ml3 display-none" href="/login">
Login Login
</a> </a>
<a class="hover-light-grey border-radius ml3" href=""> <a class="hover-light-grey border-radius ml3" href="">
@@ -40,8 +40,8 @@
</g> </g>
</svg> </svg>
<form class="js-search-form display-none"> <form class="js-search-form display-abs display-none">
<input type="text" class="js-search-input" aria-label="Search erpnext.org"></input> <input type="text" class="js-search-input ph1" aria-label="Search erpnext.org"></input>
<svg class="js-search-input-icon icon" viewBox="0 0 22.780561 22.145968" height="83.701294" width="86.099762"> <svg class="js-search-input-icon icon" viewBox="0 0 22.780561 22.145968" height="83.701294" width="86.099762">