2 * JavaScript for Special:Search
4 jQuery( function( $ ) {
6 // Emulate HTML5 autofocus behavior in non HTML5 compliant browsers
7 if ( !( 'autofocus' in document
.createElement( 'input' ) ) ) {
8 $( 'input[autofocus]:first' ).focus();
11 // Bind check all/none button
12 var $checkboxes
= $('#powersearch input[id^=mw-search-ns]');
13 $('#mw-search-toggleall').click( function() {
14 $checkboxes
.prop("checked", true);
16 $('#mw-search-togglenone').click( function() {
17 $checkboxes
.prop("checked", false);
20 // Change the header search links to what user entered
21 var headerLinks
= $('.search-types a');
22 $('#searchText, #powerSearchText').change(function() {
23 var searchterm
= $(this).val();
24 headerLinks
.each( function() {
25 var parts
= this.href
.split( 'search=' );
27 var prefix
= 'search=';
28 if( parts
.length
> 1 && parts
[1].indexOf('&') >= 0 ) {
29 lastpart
= parts
[1].substring( parts
[1].indexOf('&') );
33 this.href
= parts
[0] + prefix
+ encodeURIComponent( searchterm
) + lastpart
;