revised search form to not be an actual form

This commit is contained in:
tmont 2011-02-17 07:52:56 +00:00
parent d844dc3598
commit df137150ae
4 changed files with 27 additions and 13 deletions

View File

@ -26,6 +26,10 @@ namespace VideoGameQuotes.Api.Search.Lucene {
[UnitOfWork]
public IEnumerable<SearchResult> Search(string searchString) {
if (string.IsNullOrWhiteSpace(searchString)) {
return Enumerable.Empty<SearchResult>();
}
var query = queryParser.Parse(QueryParser.Escape(searchString));
var searcher = new IndexSearcher(indexLocator.IndexDirectory);
return searcher

View File

@ -29,12 +29,8 @@
<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 class="searchbox">
<% using (Html.BeginForm("search", "quote", FormMethod.Get, new { id = "search-form" })) { %>
<div>
<%= Html.TextBox("searchQuery", null, new { id = "search-query" })%>
<input type="image" src="/media/images/search.png" alt="search" title="search quotes, games, systems" />
</div>
<% } %>
<%= Html.TextBox("searchQuery", null, new { id = "search-query" })%>
<img src="/media/images/search.png" alt="search" title="search quotes" id="search-submit" />
</li>
</ul>
</div>

View File

@ -129,6 +129,10 @@ ul.menu li {
padding: 5px;
}
#search-submit {
cursor: pointer;
}
#header {
background-color: #669966;
}

View File

@ -7,14 +7,24 @@
}
$(document).ready(function() {
$("#search-form").submit(function() {
var searchQuery = $.trim($("#search-query").val());
if (searchQuery.length > 0) {
window.location = "/search/" + searchQuery;
}
(function(){
var submitSearch = function() {
var searchQuery = $.trim($("#search-query").val());
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) {
return $container.find("input.quote-id").val();