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" })) { %>
|
|
||||||
<div>
|
|
||||||
<%= Html.TextBox("searchQuery", null, new { id = "search-query" })%>
|
<%= Html.TextBox("searchQuery", null, new { id = "search-query" })%>
|
||||||
<input type="image" src="/media/images/search.png" alt="search" title="search quotes, games, systems" />
|
<img src="/media/images/search.png" alt="search" title="search quotes" id="search-submit" />
|
||||||
</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,15 +7,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#search-form").submit(function() {
|
(function(){
|
||||||
|
var submitSearch = function() {
|
||||||
var searchQuery = $.trim($("#search-query").val());
|
var searchQuery = $.trim($("#search-query").val());
|
||||||
if (searchQuery.length > 0) {
|
if (searchQuery.length > 0) {
|
||||||
window.location = "/search/" + searchQuery;
|
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