| 1 |
/* global jQuery */ |
| 2 |
|
| 3 |
( function ( $ ) { |
| 4 |
'use strict'; |
| 5 |
|
| 6 |
const $playerUiField = $( '#beyondwords-plugin-settings' ).find( |
| 7 |
'.beyondwords-setting__player--player-ui select' |
| 8 |
); |
| 9 |
|
| 10 |
const $playerSettingsFields = $( '#beyondwords-plugin-settings' ).find( |
| 11 |
'.beyondwords-settings__player-field-toggle' |
| 12 |
); |
| 13 |
|
| 14 |
$playerUiField.on( 'change', toggleFieldRow ); |
| 15 |
|
| 16 |
// Toggle on page load |
| 17 |
toggleFieldRow(); |
| 18 |
|
| 19 |
/** |
| 20 |
* Only show this field row when "Player UI" is "Enabled". |
| 21 |
*/ |
| 22 |
function toggleFieldRow() { |
| 23 |
const playerUi = $playerUiField.find( ':selected' ).val(); |
| 24 |
|
| 25 |
$playerSettingsFields.each( function () { |
| 26 |
if ( playerUi === 'enabled' ) { |
| 27 |
jQuery( this ).show(); |
| 28 |
} else { |
| 29 |
jQuery( this ).hide(); |
| 30 |
} |
| 31 |
} ); |
| 32 |
} |
| 33 |
} )( jQuery ); |
| 34 |
|