Index: trunk/phase3/skins/common/search.js |
— | — | @@ -1,50 +0,0 @@ |
2 | | -// JS specific to Special:Search |
3 | | - |
4 | | -// change the search link to what user entered |
5 | | -window.mwSearchHeaderClick = function( obj ) { |
6 | | - var searchbox = document.getElementById( 'searchText' ); |
7 | | - if( searchbox === null ) { |
8 | | - searchbox = document.getElementById( 'powerSearchText' ); |
9 | | - } |
10 | | - if( searchbox === null ) { |
11 | | - return; // should always have either normal or advanced search |
12 | | - } |
13 | | - |
14 | | - var searchterm = searchbox.value; |
15 | | - var parts = obj.getAttribute( 'href', 2).split( 'search=' ); |
16 | | - var lastpart = ''; |
17 | | - var prefix = 'search='; |
18 | | - if( parts.length > 1 && parts[1].indexOf('&') >= 0 ) { |
19 | | - lastpart = parts[1].substring( parts[1].indexOf('&') ); |
20 | | - } else { |
21 | | - prefix = '&search='; |
22 | | - } |
23 | | - obj.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart; |
24 | | -}; |
25 | | - |
26 | | -window.mwToggleSearchCheckboxes = function( btn ) { |
27 | | - if( !document.getElementById ) { |
28 | | - return; |
29 | | - } |
30 | | - |
31 | | - var nsInputs = document.getElementById( 'powersearch' ).getElementsByTagName( 'input' ); |
32 | | - var isChecked = false; |
33 | | - |
34 | | - for ( var i = 0; i < nsInputs.length; i++ ) { |
35 | | - var pattern = /^ns/; |
36 | | - if ( ( nsInputs[i].type == 'checkbox' ) && ( pattern.test( nsInputs[i].name ) ) ) { |
37 | | - switch ( btn ) { |
38 | | - case 'none': |
39 | | - if ( nsInputs[i].checked ) { |
40 | | - nsInputs[i].checked = false; |
41 | | - } |
42 | | - break; |
43 | | - case 'all': |
44 | | - if ( !nsInputs[i].checked ) { |
45 | | - nsInputs[i].checked = true; |
46 | | - } |
47 | | - break; |
48 | | - } |
49 | | - } |
50 | | - } |
51 | | -}; |
Index: trunk/phase3/includes/specials/SpecialSearch.php |
— | — | @@ -863,7 +863,6 @@ |
864 | 864 | array( |
865 | 865 | 'type'=>'button', |
866 | 866 | 'id' => 'mw-search-toggleall', |
867 | | - 'onclick' => 'mwToggleSearchCheckboxes("all");', |
868 | 867 | 'value' => wfMsg( 'powersearch-toggleall' ) |
869 | 868 | ) |
870 | 869 | ) . |
— | — | @@ -872,7 +871,6 @@ |
873 | 872 | array( |
874 | 873 | 'type'=>'button', |
875 | 874 | 'id' => 'mw-search-togglenone', |
876 | | - 'onclick' => 'mwToggleSearchCheckboxes("none");', |
877 | 875 | 'value' => wfMsg( 'powersearch-togglenone' ) |
878 | 876 | ) |
879 | 877 | ) |
— | — | @@ -1045,9 +1043,7 @@ |
1046 | 1044 | 'a', |
1047 | 1045 | array( |
1048 | 1046 | 'href' => $this->getTitle()->getLocalURL( $stParams ), |
1049 | | - 'title' => $tooltip, |
1050 | | - 'onmousedown' => 'mwSearchHeaderClick(this);', |
1051 | | - 'onkeydown' => 'mwSearchHeaderClick(this);'), |
| 1047 | + 'title' => $tooltip), |
1052 | 1048 | $label |
1053 | 1049 | ); |
1054 | 1050 | } |
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.search.js |
— | — | @@ -8,4 +8,30 @@ |
9 | 9 | $( 'input[autofocus]:first' ).focus(); |
10 | 10 | } |
11 | 11 | |
| 12 | +// Bind check all/none button |
| 13 | +var $checkboxes = $('#powersearch input[id^=mw-search-ns]'); |
| 14 | +$('#mw-search-toggleall').click( function() { |
| 15 | + $checkboxes.prop("checked", true); |
| 16 | +} ); |
| 17 | +$('#mw-search-togglenone').click( function() { |
| 18 | + $checkboxes.prop("checked", false); |
| 19 | +} ); |
| 20 | + |
| 21 | +// Change the header search links to what user entered |
| 22 | +var headerLinks = $('.search-types a'); |
| 23 | +$('#searchText, #powerSearchText').change(function() { |
| 24 | + var searchterm = $(this).val(); |
| 25 | + headerLinks.each( function() { |
| 26 | + var parts = this.href.split( 'search=' ); |
| 27 | + var lastpart = ''; |
| 28 | + var prefix = 'search='; |
| 29 | + if( parts.length > 1 && parts[1].indexOf('&') >= 0 ) { |
| 30 | + lastpart = parts[1].substring( parts[1].indexOf('&') ); |
| 31 | + } else { |
| 32 | + prefix = '&search='; |
| 33 | + } |
| 34 | + this.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart; |
| 35 | + }); |
| 36 | +}).trigger('change'); |
| 37 | + |
12 | 38 | } )( jQuery ); |
\ No newline at end of file |