website navbar search fix
This commit is contained in:
parent
c10e3ec75e
commit
889efae87b
4 changed files with 12 additions and 18 deletions
|
|
@ -37,5 +37,8 @@
|
|||
});
|
||||
</script>
|
||||
</div>
|
||||
{% include "templates/includes/blog/blog_common.html" %}
|
||||
|
||||
<script>
|
||||
frappe.set_search_path("/blog");
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
{% include "templates/includes/list/list.html" %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "templates/includes/blog/blog_common.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}{% include "templates/includes/list/list.js" %}{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
<script>
|
||||
frappe.ready(function() {
|
||||
frappe.get_navbar_search().on("keypress", function(e) {
|
||||
if(e.which===13) {
|
||||
var txt = $(this).val();
|
||||
if(txt) {
|
||||
$(this).val("");
|
||||
frappe.load_via_ajax("/blog?txt=" + encodeURIComponent(txt));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
// MIT License. See license.txt
|
||||
|
||||
frappe.provide("website");
|
||||
frappe.provide("frappe.search_path");
|
||||
|
||||
$.extend(frappe, {
|
||||
_assets_loaded: [],
|
||||
|
|
@ -266,7 +267,7 @@ $.extend(frappe, {
|
|||
|
||||
},
|
||||
load_via_ajax: function(href) {
|
||||
// console.log("calling ajax");
|
||||
// console.log("calling ajax", href);
|
||||
window.previous_href = href;
|
||||
history.pushState(null, null, href);
|
||||
|
||||
|
|
@ -438,11 +439,16 @@ $.extend(frappe, {
|
|||
$(".navbar .search").on("keypress", function(e) {
|
||||
var val = $(this).val();
|
||||
if(e.which===13 && val) {
|
||||
frappe.load_via_ajax(location.pathname + "?txt=" + encodeURIComponent(val));
|
||||
$(this).val("").blur();
|
||||
var path = (frappe.search_path && frappe.search_path[location.pathname] || location.pathname);
|
||||
frappe.load_via_ajax(path + "?txt=" + encodeURIComponent(val));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
set_search_path: function(path) {
|
||||
frappe.search_path[location.pathname] = path;
|
||||
},
|
||||
make_navbar_active: function() {
|
||||
var pathname = window.location.pathname;
|
||||
$(".navbar-nav a.active").removeClass("active");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue