1
0
mirror of https://github.com/golang/go synced 2024-11-24 23:57:57 -07:00

godoc: use "search" input type for search box.

Uses placeholder attribute instead of changing the value of search
field on browsers that support it.  On other browsers, the fake
placeholder text is restored when the empty box loses focus.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4441041
This commit is contained in:
Dmitry Chestnykh 2011-04-15 10:48:45 -07:00 committed by Robert Griesemer
parent 07dc26f88d
commit 84c7e83b4c
3 changed files with 13 additions and 2 deletions

View File

@ -96,7 +96,7 @@ h1#title {
color: #999;
}
#search {
width: 100px;
width: 120px;
margin-left: 0.5em;
}
#search.inactive {

View File

@ -34,7 +34,18 @@ function godocs_bindSearchEvents() {
search.className = "";
}
}
function restoreInactive() {
if (search.value != "") {
return;
}
if (search.type != "search") {
search.value = search.getAttribute("placeholder");
}
search.className = "inactive";
}
restoreInactive();
bindEvent(search, 'focus', clearInactive);
bindEvent(search, 'blur', restoreInactive);
}
/* Generates a table of contents: looks for h2 and h3 elements and generates

View File

@ -33,7 +33,7 @@
<a href="/pkg/">Packages</a> <span class="sep">|</span>
<a href="/cmd/">Commands</a> <span class="sep">|</span>
<a href="/doc/go_spec.html">Specification</a>
<input id="search" type="text" name="q" value="{.section Query}{Query|html-esc}{.or}code search{.end}" class="{.section Query}{.or}inactive{.end}" />
<input id="search" type="search" name="q" value="{.section Query}{Query|html-esc}{.end}" class="{.section Query}{.or}inactive{.end}" placeholder="code search" results="0" />
</form>
</div>
</div>