revised search form to not be an actual form
This commit is contained in:
parent
d844dc3598
commit
df137150ae
@ -26,6 +26,10 @@ namespace VideoGameQuotes.Api.Search.Lucene {
|
|||||||
|
|
||||||
[UnitOfWork]
|
[UnitOfWork]
|
||||||
public IEnumerable<SearchResult> Search(string searchString) {
|
public IEnumerable<SearchResult> Search(string searchString) {
|
||||||
|
if (string.IsNullOrWhiteSpace(searchString)) {
|
||||||
|
return Enumerable.Empty<SearchResult>();
|
||||||
|
}
|
||||||
|
|
||||||
var query = queryParser.Parse(QueryParser.Escape(searchString));
|
var query = queryParser.Parse(QueryParser.Escape(searchString));
|
||||||
var searcher = new IndexSearcher(indexLocator.IndexDirectory);
|
var searcher = new IndexSearcher(indexLocator.IndexDirectory);
|
||||||
return searcher
|
return searcher
|
||||||
|
@ -29,12 +29,8 @@
|
|||||||
<li><%= Html.ActionLink("Submit", "submit", "Quote", null, new { title = "Submit a new quote" }) %></li>
|
<li><%= Html.ActionLink("Submit", "submit", "Quote", null, new { title = "Submit a new quote" }) %></li>
|
||||||
<li><%= Html.ActionLink("About", "about", "Home", null, new { title = "About the site" })%></li>
|
<li><%= Html.ActionLink("About", "about", "Home", null, new { title = "About the site" })%></li>
|
||||||
<li class="searchbox">
|
<li class="searchbox">
|
||||||
<% using (Html.BeginForm("search", "quote", FormMethod.Get, new { id = "search-form" })) { %>
|
<%= Html.TextBox("searchQuery", null, new { id = "search-query" })%>
|
||||||
<div>
|
<img src="/media/images/search.png" alt="search" title="search quotes" id="search-submit" />
|
||||||
<%= Html.TextBox("searchQuery", null, new { id = "search-query" })%>
|
|
||||||
<input type="image" src="/media/images/search.png" alt="search" title="search quotes, games, systems" />
|
|
||||||
</div>
|
|
||||||
<% } %>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -129,6 +129,10 @@ ul.menu li {
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#search-submit {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
#header {
|
#header {
|
||||||
background-color: #669966;
|
background-color: #669966;
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#search-form").submit(function() {
|
(function(){
|
||||||
var searchQuery = $.trim($("#search-query").val());
|
var submitSearch = function() {
|
||||||
if (searchQuery.length > 0) {
|
var searchQuery = $.trim($("#search-query").val());
|
||||||
window.location = "/search/" + searchQuery;
|
if (searchQuery.length > 0) {
|
||||||
}
|
window.location = "/search/" + searchQuery;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
};
|
||||||
|
|
||||||
|
$("#search-query").keypress(function(e) {
|
||||||
|
if (e.which === 13) {
|
||||||
|
submitSearch();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#search-submit").click(submitSearch);
|
||||||
|
}());
|
||||||
|
|
||||||
var getQuoteId = function($container) {
|
var getQuoteId = function($container) {
|
||||||
return $container.find("input.quote-id").val();
|
return $container.find("input.quote-id").val();
|
||||||
|
Loading…
Reference in New Issue
Block a user