blob: cdc56b8c812023fc46ff5ad075f7309b8c48f38a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*!
* @license GNU GPL v2+
* @since 3.0
*
* @author mwjames
*/
( function( $, mw, smw ) {
'use strict';
/**
* Support text input on Special:Search
*
* @since 3.0
*/
var search = function() {
var context = $( '#searchText > input' ),
isHidden = false;
if ( context.length ) {
// Disable the standard autocompleter as no meaningfull help can be
// expected on a [[ ... ]] input
context.on( 'keyup keypres mouseenter', function( e ) {
// MW 1.27 - MW 1.31
var highlighter = context.parent().find( '.oo-ui-widget' );
// MW 1.32+
if ( highlighter.length == 0 ) {
highlighter = $( '.oo-ui-defaultOverlay > .oo-ui-widget' );
};
// Disable (hide) the MW's search input highlighter
if ( context.val().search( /\[|\[\[|in:|not:|has:|phrase:|::/gi ) > -1 ) {
highlighter.hide();
isHidden = true;
} else if( isHidden ) {
isHidden = false;
highlighter.show();
};
} );
}
};
// Only load when it is Special:Search and the search type supports
// https://www.semantic-mediawiki.org/wiki/Help:SMWSearch
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Search' && mw.config.get( 'wgSearchType' ) == 'SMWSearch' ) {
smw.load( search );
};
} )( jQuery, mediaWiki, semanticMediaWiki );
|