No Description

eu-cookie-law-admin.js 1.1KB

123456789101112131415161718192021222324252627282930313233
  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 ).closest( '.eu-cookie-law-widget-policy-url' );
  7. if ( $policyUrl.find( 'input[type="radio"][value="default"]' ).is( ':checked' ) ) {
  8. $policyUrl.find( '.notice.default-policy' ).css( 'display', 'block' );
  9. $policyUrl.find( '.notice.custom-policy' ).hide();
  10. } else {
  11. $policyUrl.find( '.notice.default-policy' ).hide();
  12. $policyUrl.find( '.notice.custom-policy' ).css( 'display', 'block' );
  13. }
  14. };
  15. $document.on(
  16. 'click',
  17. '.eu-cookie-law-widget-policy-url input[type="radio"]',
  18. maybeShowNotice
  19. );
  20. $document.on( 'widget-updated widget-added', function ( e, widget ) {
  21. var widgetId = $( widget ).attr( 'id' );
  22. if ( widgetId && widgetId.indexOf( 'eu_cookie_law_widget' ) !== -1 ) {
  23. maybeShowNotice( null, $( '#' + widgetId + ' .eu-cookie-law-widget-policy-url' ) );
  24. }
  25. } );
  26. $( '.eu-cookie-law-widget-policy-url' ).each( maybeShowNotice );
  27. } );
  28. } )( jQuery );