Index: trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.php |
— | — | @@ -8,7 +8,8 @@ |
9 | 9 | * This file contains the include file for the SimpleSearch portion of the |
10 | 10 | * UsabilityInitiative extension of MediaWiki. |
11 | 11 | * |
12 | | - * This extension requires $wgEnableOpenSearchSuggest = true; (default) |
| 12 | + * This extension requires $wgVectorUseSimpleSearch = true; (false by default) |
| 13 | + * and $wgEnableOpenSearchSuggest = true; (default) |
13 | 14 | * and recommends $wgEnableMWSuggest = false; (default) |
14 | 15 | * |
15 | 16 | * Usage: Include the following line in your LocalSettings.php |
Index: trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.js |
— | — | @@ -41,79 +41,84 @@ |
42 | 42 | $j(this).parent().find( 'label' ).show(); |
43 | 43 | } |
44 | 44 | }); |
45 | | - $j( '#searchInput, #searchInput2, #powerSearchText, #searchText' ).suggestions( { |
46 | | - fetch: function( query ) { |
47 | | - var $this = $j(this); |
48 | | - var request = $j.ajax( { |
49 | | - url: wgScriptPath + '/api.php', |
50 | | - data: { |
51 | | - 'action': 'opensearch', |
52 | | - 'search': query, |
53 | | - 'namespace': 0, |
54 | | - 'suggest': '' |
55 | | - }, |
56 | | - dataType: 'json', |
57 | | - success: function( data ) { |
58 | | - $this.suggestions( 'suggestions', data[1] ); |
| 45 | + $j( '#searchInput, #searchInput2, #powerSearchText, #searchText' ).suggestions( { |
| 46 | + fetch: function( query ) { |
| 47 | + var $this = $j(this); |
| 48 | + var request = $j.ajax( { |
| 49 | + url: wgScriptPath + '/api.php', |
| 50 | + data: { |
| 51 | + 'action': 'opensearch', |
| 52 | + 'search': query, |
| 53 | + 'namespace': 0, |
| 54 | + 'suggest': '' |
| 55 | + }, |
| 56 | + dataType: 'json', |
| 57 | + success: function( data ) { |
| 58 | + $this.suggestions( 'suggestions', data[1] ); |
| 59 | + } |
| 60 | + }); |
| 61 | + $j(this).data( 'request', request ); |
| 62 | + }, |
| 63 | + cancel: function () { |
| 64 | + var request = $j(this).data( 'request' ); |
| 65 | + // If the delay setting has caused the fetch to have not even happend yet, the request object will |
| 66 | + // have never been set |
| 67 | + if ( request && typeof request.abort == 'function' ) { |
| 68 | + request.abort(); |
| 69 | + $j(this).removeData( 'request' ); |
| 70 | + } |
| 71 | + }, |
| 72 | + result: { |
| 73 | + select: function( $textbox ) { |
| 74 | + $textbox.closest( 'form' ).submit(); |
| 75 | + } |
| 76 | + }, |
| 77 | + delay: 120 |
| 78 | + } ); |
| 79 | + $j( '#searchInput' ).suggestions( { |
| 80 | + result: { |
| 81 | + select: function( $textbox ) { |
| 82 | + $textbox.closest( 'form' ).submit(); |
| 83 | + } |
| 84 | + }, |
| 85 | + special: { |
| 86 | + render: function( query ) { |
| 87 | + var perfectMatch = false; |
| 88 | + $j(this).closest( '.suggestions' ).find( '.suggestions-results div' ).each( function() { |
| 89 | + if ( $j(this).data( 'text' ) == query ) { |
| 90 | + perfectMatch = true; |
59 | 91 | } |
60 | | - }); |
61 | | - $j(this).data( 'request', request ); |
62 | | - }, |
63 | | - cancel: function () { |
64 | | - var request = $j(this).data( 'request' ); |
65 | | - // If the delay setting has caused the fetch to have not even happend yet, the request object will |
66 | | - // have never been set |
67 | | - if ( request && typeof request.abort == 'function' ) { |
68 | | - request.abort(); |
69 | | - $j(this).removeData( 'request' ); |
70 | | - } |
71 | | - }, |
72 | | - result: { |
73 | | - select: function( $textbox ) { |
74 | | - $textbox.closest( 'form' ).submit(); |
75 | | - } |
76 | | - }, |
77 | | - delay: 120 |
78 | | - } ); |
79 | | - $j( '#searchInput' ).suggestions( { |
80 | | - special: { |
81 | | - render: function( query ) { |
82 | | - var perfectMatch = false; |
83 | | - $j(this).closest( '.suggestions' ).find( '.suggestions-results div' ).each( function() { |
84 | | - if ( $j(this).data( 'text' ) == query ) { |
85 | | - perfectMatch = true; |
86 | | - } |
87 | | - } ); |
88 | | - if ( perfectMatch ) { |
89 | | - if ( $j(this).children().size() == 0 ) { |
90 | | - $j(this).show(); |
91 | | - $label = $j( '<div />' ) |
92 | | - .addClass( 'special-label' ) |
93 | | - .text( gM( 'simplesearch-containing' ) ) |
94 | | - .appendTo( $j(this) ); |
95 | | - $query = $j( '<div />' ) |
96 | | - .addClass( 'special-query' ) |
97 | | - .text( query ) |
98 | | - .appendTo( $j(this) ); |
99 | | - $query.autoEllipse(); |
100 | | - } else { |
101 | | - $j(this).find( '.special-query' ) |
102 | | - .empty() |
103 | | - .text( query ) |
104 | | - .autoEllipse(); |
105 | | - } |
| 92 | + } ); |
| 93 | + if ( perfectMatch ) { |
| 94 | + if ( $j(this).children().size() == 0 ) { |
| 95 | + $j(this).show(); |
| 96 | + $label = $j( '<div />' ) |
| 97 | + .addClass( 'special-label' ) |
| 98 | + .text( gM( 'simplesearch-containing' ) ) |
| 99 | + .appendTo( $j(this) ); |
| 100 | + $query = $j( '<div />' ) |
| 101 | + .addClass( 'special-query' ) |
| 102 | + .text( query ) |
| 103 | + .appendTo( $j(this) ); |
| 104 | + $query.autoEllipse(); |
106 | 105 | } else { |
107 | | - $j(this).hide(); |
108 | | - $j(this).empty(); |
| 106 | + $j(this).find( '.special-query' ) |
| 107 | + .empty() |
| 108 | + .text( query ) |
| 109 | + .autoEllipse(); |
109 | 110 | } |
110 | | - }, |
111 | | - select: function( $textbox ) { |
112 | | - $textbox.closest( 'form' ).append( |
113 | | - $j( '<input />' ).attr( { 'type': 'hidden', 'name': 'fulltext', 'value': 1 } ) |
114 | | - ); |
115 | | - $textbox.closest( 'form' ).submit(); |
| 111 | + } else { |
| 112 | + $j(this).hide(); |
| 113 | + $j(this).empty(); |
116 | 114 | } |
117 | 115 | }, |
118 | | - $region: $j( '#simpleSearch') |
119 | | - } ); |
| 116 | + select: function( $textbox ) { |
| 117 | + $textbox.closest( 'form' ).append( |
| 118 | + $j( '<input />' ).attr( { 'type': 'hidden', 'name': 'fulltext', 'value': 1 } ) |
| 119 | + ); |
| 120 | + $textbox.closest( 'form' ).submit(); |
| 121 | + } |
| 122 | + }, |
| 123 | + $region: $j( '#simpleSearch' ) |
| 124 | + } ); |
120 | 125 | }); |
\ No newline at end of file |