Skip to content

Commit

Permalink
Merge pull request #1706 from NuGet/anurse/1683-fixexpandingsearchbox
Browse files Browse the repository at this point in the history
Fixed #1683 by making expanding search opt-in
  • Loading branch information
analogrelay committed Nov 4, 2013
2 parents 29d37d9 + 3bad9dc commit 8d8f15e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/NuGetGallery/Scripts/nugetgallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
/// <reference path="jquery-1.6.4.js" />
(function (window, $, undefined) {
function attachSearchBoxBehavior($input, $menu) {
if ($input.length == 0 || $menu.length == 0) {
// If we were given nothing, just return.
return;
}

// Remember the previous state in order to perform smooth animation transforms
var prevstate = false;
function popit(assumeFocused) {
Expand Down Expand Up @@ -72,7 +77,7 @@
// Get the service status
checkServiceStatus();

attachSearchBoxBehavior($('#searchBoxInput'), $('#menu'));
attachSearchBoxBehavior($('#searchBoxInput.expanding-search'), $('#menu.expanding-search'));
});

// Add validator that ensures provided value is NOT equal to a specified value.
Expand Down
4 changes: 2 additions & 2 deletions src/NuGetGallery/Views/Shared/Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@Html.Partial(MVC.Shared.Views.UserDisplay)
</header>
<nav class="main">
<ul id="menu">
<ul id="menu" class="expanding-search">
@{
var homeClass = ViewBag.Tab == "Home" ? "current" : "";
var packagesClass = ViewBag.Tab == "Packages" ? "current" : "";
Expand All @@ -45,7 +45,7 @@
</ul>
<div id="searchBox" role="search">
<form action="@Url.PackageList()" method="get">
<input name="q" id="searchBoxInput" placeholder="Search Packages" value="@(String.IsNullOrEmpty(ViewBag.SearchTerm) ? "" : ViewBag.SearchTerm)" />
<input name="q" id="searchBoxInput" class="expanding-search" placeholder="Search Packages" value="@(String.IsNullOrEmpty(ViewBag.SearchTerm) ? "" : ViewBag.SearchTerm)" />
<input id="searchBoxSubmit" type="submit" value=" " />
</form>
</div>
Expand Down

0 comments on commit 8d8f15e

Please sign in to comment.