1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // copied from $GOROOT/doc/godocs.js
7 function bindEvent(el, e, fn) {
8 if (el.addEventListener) {
9 el.addEventListener(e, fn, false);
10 } else if (el.attachEvent) {
11 el.attachEvent('on' + e, fn);
15 function godocs_bindSearchEvents() {
16 var search = document.getElementById('search');
18 // no search box (index disabled)
21 function clearInactive() {
22 if (search.className == 'inactive') {
24 search.className = '';
27 function restoreInactive() {
28 if (search.value !== '') {
31 if (search.type != 'search') {
32 search.value = search.getAttribute('placeholder');
34 search.className = 'inactive';
37 bindEvent(search, 'focus', clearInactive);
38 bindEvent(search, 'blur', restoreInactive);
41 bindEvent(window, 'load', godocs_bindSearchEvents);