| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
( function () { |
| 5 |
mw.hook( 'htmlform.enhance' ).add( ( $root ) => { |
| 6 |
const $target = $root.find( '#mw-input-wpeditfont' ); |
| 7 |
|
| 8 |
if ( |
| 9 |
|
| 10 |
!$target.length || |
| 11 |
$target.closest( '.mw-htmlform-autoinfuse-lazy' ).length |
| 12 |
) { |
| 13 |
return; |
| 14 |
} |
| 15 |
|
| 16 |
const widget = OO.ui.infuse( $target ); |
| 17 |
|
| 18 |
|
| 19 |
widget.dropdownWidget.menu.items.forEach( ( item ) => { |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
item.$label.addClass( 'mw-editfont-' + item.getData() ); |
| 25 |
} ); |
| 26 |
|
| 27 |
let lastValue; |
| 28 |
|
| 29 |
function updateLabel( value ) { |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
widget.dropdownWidget.$label |
| 36 |
.removeClass( 'mw-editfont-' + lastValue ) |
| 37 |
.addClass( 'mw-editfont-' + value ); |
| 38 |
lastValue = value; |
| 39 |
} |
| 40 |
|
| 41 |
widget.on( 'change', updateLabel ); |
| 42 |
updateLabel( widget.getValue() ); |
| 43 |
|
| 44 |
} ); |
| 45 |
}() ); |