| 1 |
jQuery( function(){ |
| 2 |
|
| 3 |
/* Display custom redirect URL section if type of restriction is "Redirect" */ |
| 4 |
jQuery( 'input[type=radio][name=wppb-content-restrict-type]' ).on( "click", function() { |
| 5 |
if( jQuery( this ).is(':checked') && jQuery( this ).val() == 'redirect' ) |
| 6 |
jQuery( '#wppb-meta-box-fields-wrapper-restriction-redirect-url' ).addClass( 'wppb-content-restriction-enabled' ); |
| 7 |
else |
| 8 |
jQuery( '#wppb-meta-box-fields-wrapper-restriction-redirect-url' ).removeClass( 'wppb-content-restriction-enabled' ); |
| 9 |
} ); |
| 10 |
|
| 11 |
/* Display custom redirect URL field */ |
| 12 |
jQuery( '#wppb-content-restrict-custom-redirect-url-enabled' ).on( "click", function() { |
| 13 |
if( jQuery( this ).is( ':checked' ) ) |
| 14 |
jQuery( '.wppb-meta-box-field-wrapper-custom-redirect-url' ).addClass( 'wppb-content-restriction-enabled' ); |
| 15 |
else |
| 16 |
jQuery( '.wppb-meta-box-field-wrapper-custom-redirect-url' ).removeClass( 'wppb-content-restriction-enabled' ); |
| 17 |
} ); |
| 18 |
|
| 19 |
/* Display custom messages editors */ |
| 20 |
jQuery( '#wppb-content-restrict-messages-enabled' ).on( "click", function() { |
| 21 |
if( jQuery( this ).is( ':checked' ) ) |
| 22 |
jQuery( '.wppb-meta-box-field-wrapper-custom-messages' ).addClass( 'wppb-content-restriction-enabled' ); |
| 23 |
else |
| 24 |
jQuery( '.wppb-meta-box-field-wrapper-custom-messages' ).removeClass( 'wppb-content-restriction-enabled' ); |
| 25 |
} ); |
| 26 |
|
| 27 |
|
| 28 |
/* Disable / Enable the user roles from the "Display for" field if the "Logged in Users" option is checked or not */ |
| 29 |
jQuery( document ).on( 'click', 'input[name="wppb-content-restrict-user-status"]', function() { |
| 30 |
wppb_disable_enable_user_roles( jQuery( this ) ); |
| 31 |
} ); |
| 32 |
|
| 33 |
jQuery( 'input[name="wppb-content-restrict-user-status"]' ).each( function() { |
| 34 |
wppb_disable_enable_user_roles( jQuery( this ) ); |
| 35 |
} ); |
| 36 |
|
| 37 |
|
| 38 |
function wppb_disable_enable_user_roles( $element ) { |
| 39 |
$wrapper = $element.closest( '.wppb-meta-box-field-wrapper' ); |
| 40 |
|
| 41 |
if( $element.is( ':checked' ) ) { |
| 42 |
$wrapper.find( 'input[name="wppb-content-restrict-user-role[]"]' ).attr( 'disabled', false ); |
| 43 |
} else { |
| 44 |
$wrapper.find( 'input[name="wppb-content-restrict-user-role[]"]' ).attr( 'disabled', true ); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
} ); |