eu-cookie-law-admin.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. /* eslint no-var: 0 */
  2. ( function( $ ) {
  3. var $document = $( document );
  4. $document.on( 'ready', function() {
  5. var maybeShowNotice = function( e, policyUrl ) {
  6. var $policyUrl = $( policyUrl || this )
  7. .closest( '.eu-cookie-law-widget-policy-url' );
  8. if ( $policyUrl.find( 'input[type="radio"][value="default"]' ).is( ':checked' ) ) {
  9. $policyUrl.find( '.notice.default-policy' ).css( 'display', 'block' );
  10. $policyUrl.find( '.notice.custom-policy' ).hide();
  11. } else {
  12. $policyUrl.find( '.notice.default-policy' ).hide();
  13. $policyUrl.find( '.notice.custom-policy' ).css( 'display', 'block' );
  14. }
  15. };
  16. $document.on( 'click', '.eu-cookie-law-widget-policy-url input[type="radio"]', maybeShowNotice );
  17. $document.on( 'widget-updated widget-added', function( e, widget ) {
  18. var widgetId = $( widget ).attr( 'id' );
  19. if ( widgetId.indexOf( 'eu_cookie_law_widget' ) !== -1 ) {
  20. maybeShowNotice( null, $( '#' + widgetId + ' .eu-cookie-law-widget-policy-url' ) );
  21. }
  22. } );
  23. $( '.eu-cookie-law-widget-policy-url' ).each( maybeShowNotice );
  24. } );
  25. } )( jQuery );