mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Add search bar to side bar
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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: '<button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i></button>',
 | 
			
		||||
						}),
 | 
			
		||||
					]
 | 
			
		||||
				})
 | 
			
		||||
			]
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		searchForm.addEventListener("submit", function(e){
 | 
			
		||||
			e.preventDefault();
 | 
			
		||||
 | 
			
		||||
			openPage("search?q=" + searchForm.getElementsByTagName("input")[0].value);
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user