From c04ee45098ee6dd81b3c82b1cced0082a09ac197 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 11 May 2019 17:03:09 +0200 Subject: [PATCH] Add search bar to side bar --- assets/js/components/menuBar/authenticated.js | 2 +- assets/js/components/sidebar/main.js | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/assets/js/components/menuBar/authenticated.js b/assets/js/components/menuBar/authenticated.js index 54ca6bc6..1fd9c937 100644 --- a/assets/js/components/menuBar/authenticated.js +++ b/assets/js/components/menuBar/authenticated.js @@ -90,7 +90,7 @@ ComunicWeb.components.menuBar.authenticated = { navbarCollapseElemList.className = "nav navbar-nav"; //Add search form - this.addSearchForm(navbarCollapseElemList); + //this.addSearchForm(navbarCollapseElemList); //Navbar right elements var navbarRight = createElem("div", navBar); diff --git a/assets/js/components/sidebar/main.js b/assets/js/components/sidebar/main.js index 171766fc..0e697bd3 100644 --- a/assets/js/components/sidebar/main.js +++ b/assets/js/components/sidebar/main.js @@ -67,5 +67,40 @@ ComunicWeb.components.sideBar.main = { ] }); }); + + + + // Search form + var searchForm = createElem2({ + appendTo: section, + type: "form", + class: "sidebar-form", + children: [ + createElem2({ + type: "div", + class: "input-group", + children: [ + createElem2({ + type: "input", + class: "form-control", + elemType: "text", + placeholder: "Search...", + }), + + createElem2({ + type: "span", + class: "input-group-btn", + innerHTML: '', + }), + ] + }) + ] + }); + + searchForm.addEventListener("submit", function(e){ + e.preventDefault(); + + openPage("search?q=" + searchForm.getElementsByTagName("input")[0].value); + }); } } \ No newline at end of file