1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:44:41 -07:00
go/cmd/present/static/dir.js
Andrew Gerrand ca18093fea go.tools/cmd/present: add present tool
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/97030045
2014-05-05 14:55:27 -07:00

42 lines
1.0 KiB
JavaScript

// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// copied from $GOROOT/doc/godocs.js
function bindEvent(el, e, fn) {
if (el.addEventListener){
el.addEventListener(e, fn, false);
} else if (el.attachEvent){
el.attachEvent('on'+e, fn);
}
}
function godocs_bindSearchEvents() {
var search = document.getElementById('search');
if (!search) {
// no search box (index disabled)
return;
}
function clearInactive() {
if (search.className == "inactive") {
search.value = "";
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);
}
bindEvent(window, 'load', godocs_bindSearchEvents);