feat: Allow addition of custom search box
- allow passing custom search box class to bind search actions on - this allows users to inject and get a custom search box running on any page
This commit is contained in:
parent
7bc087ed44
commit
f63f250630
@ -1,7 +1,10 @@
|
||||
erpnext.ProductSearch = class {
|
||||
constructor() {
|
||||
constructor(opts) {
|
||||
/* Options: search_box_class (for custom search box) */
|
||||
$.extend(this, opts);
|
||||
this.MAX_RECENT_SEARCHES = 4;
|
||||
this.searchBox = $("#search-box");
|
||||
this.search_box_class = this.search_box_class || "#search-box"
|
||||
this.searchBox = $(this.search_box_class);
|
||||
|
||||
this.setupSearchDropDown();
|
||||
this.bindSearchAction();
|
||||
@ -24,7 +27,7 @@ erpnext.ProductSearch = class {
|
||||
// If click occurs outside search input/results, hide results.
|
||||
// Click can happen anywhere on the page
|
||||
$("body").on("click", (e) => {
|
||||
let searchEvent = $(e.target).closest('#search-box').length;
|
||||
let searchEvent = $(e.target).closest(this.search_box_class).length;
|
||||
let resultsEvent = $(e.target).closest('#search-results-container').length;
|
||||
let isResultHidden = this.search_dropdown.hasClass("hidden");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user