blob: 88631cf988a79bff5d6c2393fe265987714a05d5 (
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
53
54
55
56
57
58
59
60
61
62
63
|
/*!
*
* @author Niklas Laxström
* @license GPL-2.0-or-later
*/
( function ( $, mw ) {
'use strict';
function useULS( $trigger ) {
var update, $selected, $clear, $button = $( '<span>' );
$button
.addClass( 'ext-cc-language-selector__trigger' );
$clear = $( '<span>' )
.text( 'X' )
.addClass( 'ext-cc-language-selector__clear' );
$trigger.hide().after(
$( '<span>' )
.addClass( 'ext-cc-language-selector' )
.append( $button, $clear )
);
update = function ( value ) {
$selected = $trigger.children( ':selected' );
if ( value === '' ) {
$button.text( $selected.text() );
$clear.hide();
} else {
$button.text( $.uls.data.getAutonym( value ) );
$clear.show();
}
};
update( $trigger.val().replace( '/', '' ) );
$clear.on( 'click', function () {
$trigger.val( '' );
update( '' );
$( this ).hide();
} );
$button.uls( {
onSelect: function ( language ) {
$trigger.val( '/' + language );
update( language );
},
ulsPurpose: 'clean-changes',
quickList: mw.uls.getFrequentLanguageList
} );
}
$( function () {
var $trigger = $( '#sp-rc-language' );
if ( $trigger.length ) {
mw.loader.using( 'ext.uls.mediawiki', function () {
useULS( $trigger );
} );
}
} );
}( jQuery, mediaWiki ) );
|