diff --git a/setup/website_search_header/odoo/addons/website_search_header b/setup/website_search_header/odoo/addons/website_search_header new file mode 120000 index 0000000000..6231049881 --- /dev/null +++ b/setup/website_search_header/odoo/addons/website_search_header @@ -0,0 +1 @@ +../../../../website_search_header \ No newline at end of file diff --git a/setup/website_search_header/setup.py b/setup/website_search_header/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/website_search_header/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_search_header/README.rst b/website_search_header/README.rst new file mode 100644 index 0000000000..5d037ddc9d --- /dev/null +++ b/website_search_header/README.rst @@ -0,0 +1,83 @@ +======================== +Website Search in Header +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0190640b3113a806206eba0406254bfdb594eb50e99f4f870b3815401ff7621f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwebsite-lightgray.png?logo=github + :target: https://github.com/OCA/website/tree/16.0/website_search_header + :alt: OCA/website +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/website-16-0/website-16-0-website_search_header + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/website&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a search bar in the header of your website + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +On desktop, the user will be able to show and hide the search input in the website header. While on mobile our searchbox will behave by default. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + + +* Jordi Ballester +* Elmer GarcĂ­a + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/website `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_search_header/__init__.py b/website_search_header/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/website_search_header/__manifest__.py b/website_search_header/__manifest__.py new file mode 100644 index 0000000000..8d4cb5c0fd --- /dev/null +++ b/website_search_header/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2023 ForgeFlow, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0). + +{ + "name": "Website Search in Header", + "category": "Website", + "version": "16.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/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.rst b/website_search_header/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..7b25f3c80f --- /dev/null +++ b/website_search_header/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ + +* ForgeFlow diff --git a/website_search_header/readme/DESCRIPTION.rst b/website_search_header/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..fcd13a9805 --- /dev/null +++ b/website_search_header/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds a search bar in the header of your website diff --git a/website_search_header/readme/USAGE.rst b/website_search_header/readme/USAGE.rst new file mode 100644 index 0000000000..202d13188f --- /dev/null +++ b/website_search_header/readme/USAGE.rst @@ -0,0 +1 @@ +On desktop, the user will be able to show and hide the search input in the website header. While on mobile our searchbox will behave by default. diff --git a/website_search_header/static/description/icon.png b/website_search_header/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/website_search_header/static/description/icon.png differ diff --git a/website_search_header/static/description/index.html b/website_search_header/static/description/index.html new file mode 100644 index 0000000000..36f95548c4 --- /dev/null +++ b/website_search_header/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Website Search in Header + + + +
+

Website Search in Header

+ + +

Beta License: LGPL-3 OCA/website Translate me on Weblate Try me on Runboat

+

This module adds a search bar in the header of your website

+

Table of contents

+ +
+

Usage

+

On desktop, the user will be able to show and hide the search input in the website header. While on mobile our searchbox will behave by default.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
  • Ooops
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/website project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/website_search_header/static/src/js/website.js b/website_search_header/static/src/js/website.js new file mode 100644 index 0000000000..9a3d223733 --- /dev/null +++ b/website_search_header/static/src/js/website.js @@ -0,0 +1,62 @@ +odoo.define("website_search_header.search_header", function (require) { + "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"; + }, + }); +}); diff --git a/website_search_header/static/src/scss/website_search_header.scss b/website_search_header/static/src/scss/website_search_header.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/website_search_header/views/templates.xml b/website_search_header/views/templates.xml new file mode 100644 index 0000000000..973eecba23 --- /dev/null +++ b/website_search_header/views/templates.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +