diff --git a/website_search_header/README.rst b/website_search_header/README.rst index afd743c3e4..2a0c36af18 100644 --- a/website_search_header/README.rst +++ b/website_search_header/README.rst @@ -65,6 +65,7 @@ Contributors ------------ - ForgeFlow +- Kencove Maintainers ----------- diff --git a/website_search_header/__manifest__.py b/website_search_header/__manifest__.py index 8d4cb5c0fd..4912a25e43 100644 --- a/website_search_header/__manifest__.py +++ b/website_search_header/__manifest__.py @@ -4,21 +4,19 @@ { "name": "Website Search in Header", "category": "Website", - "version": "16.0.1.1.0", + "version": "17.0.1.1.0", "author": "ForgeFlow, Ooops, Odoo Community Association (OCA)", "website": "https://github.com/OCA/website", "license": "LGPL-3", "depends": [ "website", - "web", ], "data": [ "views/templates.xml", ], "assets": { - "web.assets_frontend": [ + "website_search_header.assets_frontend": [ "website_search_header/static/src/js/website.js", - "website_search_header/static/src/scss/website_search_header.scss", ], }, "installable": True, diff --git a/website_search_header/readme/CONTRIBUTORS.md b/website_search_header/readme/CONTRIBUTORS.md index 06f5bff395..9651e0b4ff 100644 --- a/website_search_header/readme/CONTRIBUTORS.md +++ b/website_search_header/readme/CONTRIBUTORS.md @@ -1 +1,2 @@ - ForgeFlow \<\> +- Kencove \<\> diff --git a/website_search_header/static/description/index.html b/website_search_header/static/description/index.html index 792eaf86f5..2a6c001b07 100644 --- a/website_search_header/static/description/index.html +++ b/website_search_header/static/description/index.html @@ -411,6 +411,7 @@

Authors

Contributors

diff --git a/website_search_header/static/src/js/website.js b/website_search_header/static/src/js/website.js index 9a3d223733..9eedbe717e 100644 --- a/website_search_header/static/src/js/website.js +++ b/website_search_header/static/src/js/website.js @@ -1,62 +1,43 @@ -odoo.define("website_search_header.search_header", function (require) { +(function () { "use strict"; - - const publicWidget = require("web.public.widget"); - - publicWidget.registry.SearchHeader = publicWidget.Widget.extend({ - selector: "#div_search_button", - - events: { - "click #search_btn_toggle_search": "_onClickSearchBtn", - }, - - start: function () { - const def = this._super.apply(this, arguments); - this.$boxInput = this.$el.find(".o_search_header"); - return def; - }, - - mobileSearch: function () { - if (!this.$boxInput.hasClass("d-none")) { - this.$boxInput.addClass("d-none"); - } - var searchQuery = document.querySelector("input[name='search']").value; - var encodedQuery = encodeURIComponent(searchQuery); - var searchURL = this._getSearchUrl(encodedQuery); - window.location.href = searchURL; - }, - - desktopSearch: function () { - if (!$(".o_search_header").hasClass("d-lg-none")) { - $(".o_search_header").addClass("d-lg-none"); - $("#search_btn_toggle_search i").removeClass("oi-close"); - $("#search_btn_toggle_search i").addClass("oi-search"); - $("#div_search_header").addClass("ms-lg-0"); - $("#div_search_button").addClass("ms-lg-2"); - } else { - $(".o_search_header").removeClass("d-lg-none"); - $("#search_btn_toggle_search i").removeClass("oi-search"); - $("#search_btn_toggle_search i").addClass("oi-close"); - $("#div_search_header").removeClass("ms-lg-0"); - $("#div_search_button").removeClass("ms-lg-2"); - $("input.oe_search_box").focus(); - } - }, - - _onClickSearchBtn: function () { - var screenWidth = - window.innerWidth || - document.documentElement.clientWidth || - document.body.clientWidth; - if (screenWidth < 992) { - this.mobileSearch(); - } else { - this.desktopSearch(); - } - }, - - _getSearchUrl: function (encodedQuery) { - return "/website/search?search=" + encodedQuery + "&order=name+asc"; - }, - }); -}); + function mobileSearch() { + if (!this.$boxInput.hasClass("d-none")) { + this.$boxInput.addClass("d-none"); + } + var searchQuery = document.querySelector("input[name='search']").value; + var encodedQuery = encodeURIComponent(searchQuery); + var searchURL = this._getSearchUrl(encodedQuery); + window.location.href = searchURL; + } + + function desktopSearch() { + if ($(".o_search_header").hasClass("d-lg-none")) { + $(".o_search_header").removeClass("d-lg-none"); + $("#search_btn_toggle_search i").removeClass("oi-search"); + $("#search_btn_toggle_search i").addClass("oi-close"); + $("#div_search_header").removeClass("ms-lg-0"); + $("#div_search_button").removeClass("ms-lg-2"); + $("input.oe_search_box").focus(); + } else { + $(".o_search_header").addClass("d-lg-none"); + $("#search_btn_toggle_search i").removeClass("oi-close"); + $("#search_btn_toggle_search i").addClass("oi-search"); + $("#div_search_header").addClass("ms-lg-0"); + $("#div_search_button").addClass("ms-lg-2"); + } + } + + function searchHeader() { + var screenWidth = + window.innerWidth || + document.documentElement.clientWidth || + document.body.clientWidth; + if (screenWidth < 992) { + mobileSearch(); + } else { + desktopSearch(); + } + } + + window.searchHeader = searchHeader; +})(); diff --git a/website_search_header/views/templates.xml b/website_search_header/views/templates.xml index 973eecba23..80d8a39c02 100644 --- a/website_search_header/views/templates.xml +++ b/website_search_header/views/templates.xml @@ -32,13 +32,19 @@ aria-label="Search" t-attf-class="btn oe_search_button btn-primary" title="Search" + t-attf-onclick="searchHeader()" >
+ + -