Skip to content

Commit aeb98ab

Browse files
committed
Refactor search placeholder
HTML supports the placeholder attribute, so we should use it instead of implementing it ourselves. The placeholder attribute is not available prior IE10 (not including IE10). However: 1. In non-supporting browsers (e.g., IE9), the search functionality should still work correctly. 2. Non-supporting browsers don't qualify for the "full support" level detailed in racket#240 IE9 for instance is released in 2011, and Microsoft announced its end of support in 2016.
1 parent 0c93db9 commit aeb98ab

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

scribble-lib/scribble/html-render.rkt

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,26 +221,16 @@
221221
(string->symbol (alt-tag-name s)))))
222222

223223
(define (make-search-box top-path) ; appears on every page
224-
(let ([sa string-append]
225-
[emptylabel "...search manuals..."]
226-
[dimcolor "#888"])
224+
(let ([emptylabel "...search manuals..."])
227225
`(form ([class "searchform"])
228226
(input
229227
([class "searchbox"]
230-
[style ,(sa "color: "dimcolor";")]
231228
[type "text"]
232229
[tabindex "1"]
233-
[value ,emptylabel]
230+
[placeholder ,emptylabel]
234231
[title "Enter a search string to search the manuals"]
235232
[onkeypress ,(format "return DoSearchKey(event, this, ~s, ~s);"
236-
(version) top-path)]
237-
[onfocus ,(sa "this.style.color=\"black\"; "
238-
"this.style.textAlign=\"left\"; "
239-
"if (this.value == \""emptylabel"\") this.value=\"\";")]
240-
[onblur ,(sa "if (this.value.match(/^ *$/)) {"
241-
" this.style.color=\""dimcolor"\";"
242-
" this.style.textAlign=\"center\";"
243-
" this.value=\""emptylabel"\"; }")])))))
233+
(version) top-path)])))))
244234
(define search-box (make-search-box "../"))
245235
(define top-search-box (make-search-box ""))
246236

scribble-lib/scribble/scribble.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,13 @@ table td {
152152
padding: 0px;
153153
background-color: #eee;
154154
border: 1px solid #ddd;
155-
text-align: center;
156155
vertical-align: middle;
157156
}
158157

158+
.searchbox::placeholder {
159+
text-align: center;
160+
}
161+
159162
#contextindicator {
160163
position: fixed;
161164
background-color: #c6f;

0 commit comments

Comments
 (0)