Introduce ContentHandler::getSecondaryDataUpdates.
[lhc/web/wiklou.git] / resources / src / mediawiki.special.preferences.ooui / editfont.js
1 /*!
2 * JavaScript for Special:Preferences: editfont field enhancements.
3 */
4 ( function ( mw, $ ) {
5 $( function () {
6 var widget, lastValue;
7
8 try {
9 widget = OO.ui.infuse( $( '#mw-input-wpeditfont' ) );
10 } catch ( err ) {
11 // This preference could theoretically be disabled ($wgHiddenPrefs)
12 return;
13 }
14
15 // Style options
16 widget.dropdownWidget.menu.items.forEach( function ( item ) {
17 item.$label.addClass( 'mw-editfont-' + item.getData() );
18 } );
19
20 function updateLabel( value ) {
21 // Style selected item label
22 widget.dropdownWidget.$label
23 .removeClass( 'mw-editfont-' + lastValue )
24 .addClass( 'mw-editfont-' + value );
25 lastValue = value;
26 }
27
28 widget.on( 'change', updateLabel );
29 updateLabel( widget.getValue() );
30
31 } );
32 }( mediaWiki, jQuery ) );