From 889efae87bf02d933cfbe3fcb386fe97c3ec2e84 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Mar 2015 17:24:19 +0530 Subject: [PATCH] website navbar search fix --- frappe/templates/generators/blog_post.html | 5 ++++- frappe/templates/includes/blog/blog.html | 1 - frappe/templates/includes/blog/blog_common.html | 14 -------------- frappe/website/js/website.js | 10 ++++++++-- 4 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 frappe/templates/includes/blog/blog_common.html diff --git a/frappe/templates/generators/blog_post.html b/frappe/templates/generators/blog_post.html index 322d0be7ce..d0e202f053 100644 --- a/frappe/templates/generators/blog_post.html +++ b/frappe/templates/generators/blog_post.html @@ -37,5 +37,8 @@ }); -{% include "templates/includes/blog/blog_common.html" %} + + {% endblock %} diff --git a/frappe/templates/includes/blog/blog.html b/frappe/templates/includes/blog/blog.html index 60c17ccdf9..b23fbe6aa0 100644 --- a/frappe/templates/includes/blog/blog.html +++ b/frappe/templates/includes/blog/blog.html @@ -15,7 +15,6 @@ {% include "templates/includes/list/list.html" %} -{% include "templates/includes/blog/blog_common.html" %} {% endblock %} {% block script %}{% include "templates/includes/list/list.js" %}{% endblock %} diff --git a/frappe/templates/includes/blog/blog_common.html b/frappe/templates/includes/blog/blog_common.html deleted file mode 100644 index b507b99e21..0000000000 --- a/frappe/templates/includes/blog/blog_common.html +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/frappe/website/js/website.js b/frappe/website/js/website.js index db0f27191d..d893ca25e9 100644 --- a/frappe/website/js/website.js +++ b/frappe/website/js/website.js @@ -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");