gutenberg
3 years ago
cookiebot-admin-script.js
3 years ago
debug-page.js
3 years ago
jquery.tipTip.js
3 years ago
multiple-page.js
3 years ago
network-settings-page.js
3 years ago
prior-consent-settings.js
3 years ago
settings-page.js
3 years ago
support-page.js
3 years ago
cookiebot-admin-script.js
79 lines
| 1 | /** |
| 2 | * Load init function when the page is ready |
| 3 | * |
| 4 | * @since 4.2.10 |
| 5 | */ |
| 6 | jQuery( document ).ready( cbInit ); |
| 7 | |
| 8 | function cbInit() { |
| 9 | jQuery( document ).on( 'click', 'tr[data-slug="cookiebot"] .cb-deactivate-action', event => deactivateCookiebot( event ) ); |
| 10 | jQuery( document ).on( 'click', '#cb-review__close', event => closeSurveyPopup( event ) ); |
| 11 | jQuery( document ).on( 'submit', '#cb-review__form', event => submitSurveyPopup( event ) ); |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Displays popup form. |
| 16 | */ |
| 17 | function deactivateCookiebot( e ) { |
| 18 | e.preventDefault(); |
| 19 | |
| 20 | let deactivationLink = e.target.href; |
| 21 | |
| 22 | jQuery( '#cb-review__skip' ).attr( 'href', deactivationLink ); |
| 23 | jQuery( '.cookiebot-popup-container' ).addClass( 'cb-opened' ); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Close popup form. |
| 28 | */ |
| 29 | |
| 30 | function closeSurveyPopup(e) { |
| 31 | const popup = jQuery(e.target).closest('.cookiebot-popup-container'); |
| 32 | popup.removeClass('cb-opened'); |
| 33 | jQuery('#cb-review__alert').removeClass('show-alert'); |
| 34 | document.getElementById('cb-review__form').reset(); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Popup submit |
| 39 | */ |
| 40 | function submitSurveyPopup(e){ |
| 41 | e.preventDefault(); |
| 42 | const deactivateLink = jQuery( '#cb-review__skip' ).attr( 'href' ); |
| 43 | const button = jQuery('#cb-review__submit', '#cb-review__form'); |
| 44 | if (button.hasClass('disabled')) { |
| 45 | return; |
| 46 | } |
| 47 | const option = jQuery('input[type="radio"]:checked', '#cb-review__form'); |
| 48 | if(0 === option.length){ |
| 49 | jQuery('#cb-review__alert').addClass('show-alert'); |
| 50 | return; |
| 51 | } |
| 52 | const otherReason = jQuery('#cb-review__other-description'); |
| 53 | jQuery.ajax({ |
| 54 | url: cb_ajax.ajax_url, |
| 55 | type: 'POST', |
| 56 | data: { |
| 57 | action: 'cb_submit_survey', |
| 58 | reason_id: (0 === option.length) ? null : option.val(), |
| 59 | reason_text: (0 === option.length) ? 'none' : option.closest('label').text(), |
| 60 | reason_info: (0 !== otherReason.length) ? otherReason.val().trim() : '', |
| 61 | survey_nonce: cb_ajax.survey_nonce, |
| 62 | survey_check: 'ODUwODA1' |
| 63 | }, |
| 64 | beforeSend: function() { |
| 65 | button.addClass('disabled'); |
| 66 | }, |
| 67 | complete: function(response) { |
| 68 | const code = JSON.parse(response.responseText).code; |
| 69 | const msg = JSON.parse(response.responseText).data; |
| 70 | |
| 71 | if(code===400||code===401){ |
| 72 | jQuery('#cb-review__alert').text(msg).addClass('show-alert'); |
| 73 | button.removeClass('disabled'); |
| 74 | }else{ |
| 75 | window.location.href = deactivateLink; |
| 76 | } |
| 77 | } |
| 78 | }); |
| 79 | } |