Index: trunk/extensions/Vector/modules/ext.vector.simpleSearch.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /* JavaScript for SimpleSearch extension */ |
3 | 3 | |
4 | 4 | $( document ).ready( function() { |
5 | | - |
| 5 | + |
6 | 6 | // Compatibility map |
7 | 7 | var map = { |
8 | 8 | 'browsers': { |
— | — | @@ -27,33 +27,33 @@ |
28 | 28 | if ( !$.client.test( map ) ) { |
29 | 29 | return true; |
30 | 30 | } |
31 | | - |
| 31 | + |
32 | 32 | // Disable MWSuggest if loaded |
33 | 33 | if ( window.os_MWSuggestDisable ) { |
34 | 34 | window.os_MWSuggestDisable(); |
35 | 35 | } |
36 | | - |
| 36 | + |
37 | 37 | // Placeholder text for SimpleSearch box |
38 | | - $( 'div#simpleSearch > input#searchInput' ) |
39 | | - .attr( 'placeholder', mediaWiki.msg( 'vector-simplesearch-search' ) ) |
| 38 | + $( '#simpleSearch > input#searchInput' ) |
| 39 | + .attr( 'placeholder', mw.msg( 'vector-simplesearch-search' ) ) |
40 | 40 | .placeholder(); |
41 | | - |
| 41 | + |
42 | 42 | // General suggestions functionality for all search boxes |
43 | 43 | $( '#searchInput, #searchInput2, #powerSearchText, #searchText' ) |
44 | 44 | .suggestions( { |
45 | 45 | fetch: function( query ) { |
46 | 46 | var $this = $(this); |
47 | 47 | var request = $.ajax( { |
48 | | - url: wgScriptPath + '/api.php', |
| 48 | + url: mw.config.get( 'wgScriptPath' ) + '/api.php', |
49 | 49 | data: { |
50 | | - 'action': 'opensearch', |
51 | | - 'search': query, |
52 | | - 'namespace': 0, |
53 | | - 'suggest': '' |
| 50 | + action: 'opensearch', |
| 51 | + search: query, |
| 52 | + namespace: 0, |
| 53 | + suggest: '' |
54 | 54 | }, |
55 | 55 | dataType: 'json', |
56 | 56 | success: function( data ) { |
57 | | - if ( data && 1 in data ) { |
| 57 | + if ( $.isArray( data ) && 1 in data ) { |
58 | 58 | $this.suggestions( 'suggestions', data[1] ); |
59 | 59 | } |
60 | 60 | } |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | var request = $(this).data( 'request' ); |
66 | 66 | // If the delay setting has caused the fetch to have not even happend yet, the request object will |
67 | 67 | // have never been set |
68 | | - if ( request && typeof request.abort == 'function' ) { |
| 68 | + if ( request && $.isFunction( request.abort ) ) { |
69 | 69 | request.abort(); |
70 | 70 | $(this).removeData( 'request' ); |
71 | 71 | } |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | } |
77 | 77 | }, |
78 | 78 | delay: 120, |
79 | | - positionFromLeft: $( 'body' ).is( '.rtl' ), |
| 79 | + positionFromLeft: $( 'body' ).hasClass( 'rtl' ), |
80 | 80 | highlightInput: true |
81 | 81 | } ) |
82 | 82 | .bind( 'paste cut drop', function( e ) { |
— | — | @@ -92,15 +92,17 @@ |
93 | 93 | }, |
94 | 94 | special: { |
95 | 95 | render: function( query ) { |
96 | | - if ( $(this).children().size() == 0 ) { |
| 96 | + if ( $(this).children().size() === 0 ) { |
97 | 97 | $(this).show(); |
98 | | - $label = $( '<div />' ) |
99 | | - .addClass( 'special-label' ) |
100 | | - .text( mediaWiki.msg( 'vector-simplesearch-containing' ) ) |
| 98 | + var $label = $( '<div></div>', { |
| 99 | + 'class': 'special-label', |
| 100 | + text: mw.msg( 'vector-simplesearch-containing' ) |
| 101 | + }) |
101 | 102 | .appendTo( $(this) ); |
102 | | - $query = $( '<div />' ) |
103 | | - .addClass( 'special-query' ) |
104 | | - .text( query ) |
| 103 | + var $query = $( '<div></div>', { |
| 104 | + 'class': 'special-query', |
| 105 | + text: query |
| 106 | + }) |
105 | 107 | .appendTo( $(this) ); |
106 | 108 | $query.autoEllipsis(); |
107 | 109 | } else { |
— | — | @@ -112,11 +114,15 @@ |
113 | 115 | }, |
114 | 116 | select: function( $input ) { |
115 | 117 | $input.closest( 'form' ).append( |
116 | | - $( '<input />' ).attr( { 'type': 'hidden', 'name': 'fulltext', 'value': 1 } ) |
| 118 | + $( '<input>', { |
| 119 | + type: 'hidden', |
| 120 | + name: 'fulltext', |
| 121 | + val: '1' |
| 122 | + }) |
117 | 123 | ); |
118 | 124 | $input.closest( 'form' ).submit(); |
119 | 125 | } |
120 | 126 | }, |
121 | 127 | $region: $( '#simpleSearch' ) |
122 | 128 | } ); |
123 | | -}); |
| 129 | +}); |
\ No newline at end of file |