feat: caching, optimization, legal pages & footer
- WP Super Cache enabled (PHP mode, gzip, Nginx compatible) - Autoptimize: CSS/HTML minification + deferred JS + Google Fonts optimization - Cookie Notice: GDPR/LOPD banner styled with brand colors (navy/burgundy/gold) - Legal pages: Aviso Legal, Política de Privacidad, Política de Cookies (ES) - MU-plugin: custom footer with legal links + Cloud Host credit - Footer: copyright, legal nav, Hosted & Maintained by Cloud Host (cloudhost.es) - Security: X-Frame-Options, X-Content-Type, Referrer-Policy headers - Security: XML-RPC disabled, REST user enumeration blocked - Performance: emoji scripts removed, post revisions limited to 3
This commit is contained in:
19
wp-content/plugins/cookie-notice/js/admin-dashboard.js
Normal file
19
wp-content/plugins/cookie-notice/js/admin-dashboard.js
Normal file
@@ -0,0 +1,19 @@
|
||||
( function( $ ) {
|
||||
|
||||
// ready event
|
||||
$( function() {
|
||||
// get charts
|
||||
var charts = cnDashboardArgs.charts;
|
||||
|
||||
if ( Object.entries( charts ).length > 0 ) {
|
||||
for ( const [key, config] of Object.entries( charts ) ) {
|
||||
// create canvas
|
||||
var canvas = document.getElementById( 'cn-' + key + '-chart' );
|
||||
|
||||
if ( canvas )
|
||||
new Chart( canvas, config );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
149
wp-content/plugins/cookie-notice/js/admin-notice.js
Normal file
149
wp-content/plugins/cookie-notice/js/admin-notice.js
Normal file
@@ -0,0 +1,149 @@
|
||||
( function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Build a form-encoded payload and send it without relying on jQuery.
|
||||
*
|
||||
* @param {string} action
|
||||
* @param {Object} data
|
||||
* @returns {void}
|
||||
*/
|
||||
const postNoticeAction = function( action, data ) {
|
||||
if ( ! window.cnArgsNotice || ! cnArgsNotice.ajaxURL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bodyParams = {
|
||||
action: action,
|
||||
notice_action: data.noticeAction,
|
||||
nonce: data.nonce,
|
||||
cn_network: cnArgsNotice.network ? 1 : 0
|
||||
};
|
||||
|
||||
if ( typeof data.param !== 'undefined' ) {
|
||||
bodyParams.param = data.param;
|
||||
}
|
||||
|
||||
const encodeBody = function( params ) {
|
||||
return Object.keys( params )
|
||||
.map( function( key ) {
|
||||
return encodeURIComponent( key ) + '=' + encodeURIComponent( params[ key ] );
|
||||
} )
|
||||
.join( '&' );
|
||||
};
|
||||
|
||||
const body = encodeBody( bodyParams );
|
||||
|
||||
if ( window.fetch ) {
|
||||
fetch( cnArgsNotice.ajaxURL, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
},
|
||||
body: body
|
||||
} ).catch( function() {
|
||||
// fail silently – notice still closes
|
||||
} );
|
||||
} else {
|
||||
// XHR fallback for older browsers.
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open( 'POST', cnArgsNotice.ajaxURL, true );
|
||||
xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8' );
|
||||
xhr.send( body );
|
||||
}
|
||||
};
|
||||
|
||||
const hideNotice = function( notice ) {
|
||||
if ( notice ) {
|
||||
notice.style.display = 'none';
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener( 'DOMContentLoaded', function() {
|
||||
// No cookie compliance notice.
|
||||
document.addEventListener( 'click', function( event ) {
|
||||
const target = event.target;
|
||||
|
||||
if ( ! target || typeof target.closest !== 'function' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dismissButton = target.closest( '.cn-notice .cn-no-compliance .cn-notice-dismiss' );
|
||||
|
||||
if ( ! dismissButton ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const notice = dismissButton.closest( '.cn-notice' );
|
||||
|
||||
if ( ! notice ) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
let noticeAction = 'dismiss';
|
||||
let param = '';
|
||||
|
||||
if ( dismissButton.classList.contains( 'cn-approve' ) ) {
|
||||
noticeAction = 'approve';
|
||||
} else if ( dismissButton.classList.contains( 'cn-delay' ) ) {
|
||||
noticeAction = 'delay';
|
||||
} else if ( notice.classList.contains( 'cn-threshold' ) ) {
|
||||
noticeAction = 'threshold';
|
||||
|
||||
const noticeText = notice.querySelector( '.cn-notice-text' );
|
||||
const delay = noticeText && noticeText.dataset ? parseInt( noticeText.dataset.delay, 10 ) : NaN;
|
||||
|
||||
param = ! isNaN( delay ) && isFinite( delay ) ? delay : '';
|
||||
}
|
||||
|
||||
postNoticeAction( 'cn_dismiss_notice', {
|
||||
noticeAction: noticeAction,
|
||||
nonce: cnArgsNotice.nonce,
|
||||
param: param
|
||||
} );
|
||||
|
||||
hideNotice( notice );
|
||||
} );
|
||||
|
||||
// Review notice.
|
||||
document.addEventListener( 'click', function( event ) {
|
||||
const target = event.target;
|
||||
|
||||
if ( ! target || typeof target.closest !== 'function' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const link = target.closest( '.cn-notice .cn-review .button-link' );
|
||||
|
||||
if ( ! link ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const notice = link.closest( '.cn-notice' );
|
||||
|
||||
if ( ! notice ) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
let noticeAction = 'dismiss';
|
||||
|
||||
if ( link.classList.contains( 'cn-notice-review' ) ) {
|
||||
noticeAction = 'review';
|
||||
} else if ( link.classList.contains( 'cn-notice-delay' ) ) {
|
||||
noticeAction = 'delay';
|
||||
}
|
||||
|
||||
postNoticeAction( 'cn_review_notice', {
|
||||
noticeAction: noticeAction,
|
||||
nonce: cnArgsNotice.reviewNonce
|
||||
} );
|
||||
|
||||
hideNotice( notice );
|
||||
} );
|
||||
} );
|
||||
} )();
|
||||
71
wp-content/plugins/cookie-notice/js/admin-plugins.js
Normal file
71
wp-content/plugins/cookie-notice/js/admin-plugins.js
Normal file
@@ -0,0 +1,71 @@
|
||||
( function( $ ) {
|
||||
|
||||
// ready event
|
||||
$( function() {
|
||||
// cancel deactivation
|
||||
$( document ).on( 'click', '.cn-deactivate-plugin-cancel', function( e ) {
|
||||
tb_remove();
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
// simple deactivation
|
||||
$( document ).on( 'click', '.cn-deactivate-plugin-simple', function( e ) {
|
||||
// display spinner
|
||||
$( '#cn-deactivation-footer .spinner' ).addClass( 'is-active' );
|
||||
} );
|
||||
|
||||
// deactivation with sending data
|
||||
$( document ).on( 'click', '.cn-deactivate-plugin-data', function( e ) {
|
||||
var spinner = $( '#cn-deactivation-footer .spinner' );
|
||||
var url = $( this ).attr( 'href' );
|
||||
|
||||
// display spinner
|
||||
spinner.addClass( 'is-active' );
|
||||
|
||||
// submit data
|
||||
$.post( ajaxurl, {
|
||||
action: 'cn-deactivate-plugin',
|
||||
option_id: $( 'input[name="cn_deactivation_option"]:checked' ).val(),
|
||||
other: $( 'textarea[name="cn_deactivation_other"]' ).val(),
|
||||
nonce: cnArgsPlugins.nonce
|
||||
} ).done( function( response ) {
|
||||
// deactivate plugin
|
||||
window.location.href = url;
|
||||
} ).fail( function() {
|
||||
// deactivate plugin
|
||||
window.location.href = url;
|
||||
} );
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
// click on deactivation link
|
||||
$( document ).on( 'click', '.cn-deactivate-plugin-modal', function( e ) {
|
||||
tb_show( cnArgsPlugins.deactivate, '#TB_inline?inlineId=cn-deactivation-modal&modal=false' );
|
||||
|
||||
setTimeout( function() {
|
||||
var modalBox = $( '#cn-deactivation-container' ).closest( '#TB_window' );
|
||||
|
||||
if ( modalBox.length > 0 ) {
|
||||
$( modalBox ).addClass( 'cn-deactivation-modal' );
|
||||
|
||||
}
|
||||
}, 0 );
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
// change radio
|
||||
$( document ).on( 'change', 'input[name="cn_deactivation_option"]', function( e ) {
|
||||
var last = $( 'input[name="cn_deactivation_option"]' ).last().get( 0 );
|
||||
|
||||
// last element?
|
||||
if ( $( this ).get( 0 ) === last )
|
||||
$( '.cn-deactivation-textarea textarea' ).prop( 'disabled', false );
|
||||
else
|
||||
$( '.cn-deactivation-textarea textarea' ).prop( 'disabled', true );
|
||||
} );
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
986
wp-content/plugins/cookie-notice/js/admin-welcome.js
Normal file
986
wp-content/plugins/cookie-notice/js/admin-welcome.js
Normal file
@@ -0,0 +1,986 @@
|
||||
( function( $ ) {
|
||||
|
||||
// ready event
|
||||
$( function() {
|
||||
var btClient = false;
|
||||
var btCreditCardsInitialized = false;
|
||||
var btPayPalInitialized = false;
|
||||
|
||||
var btInit = function() {
|
||||
var result = btInitToken();
|
||||
|
||||
if ( result !== false && btCreditCardsInitialized === false ) {
|
||||
// ajax was successful
|
||||
result.done( function( response ) {
|
||||
// token received
|
||||
try {
|
||||
// parse response
|
||||
data = JSON.parse( response );
|
||||
|
||||
// first step, init braintree client
|
||||
btClient = braintree.client.create( {
|
||||
authorization: data.token
|
||||
} );
|
||||
|
||||
btInitPaymentMethod( 'credit_card' );
|
||||
// token failed
|
||||
} catch ( e ) {
|
||||
btGatewayFail( 'btInit catch' );
|
||||
}
|
||||
// ajax failed
|
||||
} ).fail( function() {
|
||||
btGatewayFail( 'btInit AJAX failed' );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
var btInitToken = function() {
|
||||
// payment screen?
|
||||
var paymentEl = $( '.cn-sidebar form[data-action="payment"]' );
|
||||
|
||||
// init braintree
|
||||
if ( paymentEl.length ) {
|
||||
paymentEl.addClass( 'cn-form-disabled' );
|
||||
|
||||
if ( typeof braintree !== 'undefined' ) {
|
||||
var ajaxArgs = {
|
||||
action: 'cn_api_request',
|
||||
request: 'get_bt_init_token',
|
||||
nonce: cnWelcomeArgs.nonce
|
||||
};
|
||||
|
||||
// network area?
|
||||
if ( cnWelcomeArgs.network === '1' )
|
||||
ajaxArgs.cn_network = 1;
|
||||
|
||||
return $.ajax( {
|
||||
url: cnWelcomeArgs.ajaxURL,
|
||||
type: 'POST',
|
||||
dataType: 'html',
|
||||
data: ajaxArgs
|
||||
} );
|
||||
} else
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
var btInitPaymentMethod = function( type ) {
|
||||
if ( btClient !== false ) {
|
||||
if ( type === 'credit_card' && btCreditCardsInitialized === false ) {
|
||||
$( 'form.cn-form[data-action="payment"]' ).addClass( 'cn-form-disabled' );
|
||||
|
||||
btClient.then( btCreditCardsInit ).then( btHostedFieldsInstance ).catch( btGatewayFail );
|
||||
} else if ( type === 'paypal' && btPayPalInitialized === false ) {
|
||||
$( 'form.cn-form[data-action="payment"]' ).addClass( 'cn-form-disabled' );
|
||||
|
||||
btClient.then( btPaypalCheckoutInit ).then( btPaypalCheckoutSDK ).then( btPaypalCheckoutInstance ).then( btPaypalCheckoutButton ).catch( btGatewayFail );
|
||||
}
|
||||
} else
|
||||
btGatewayFail( 'btInitPaymentMethod btClient is false' );
|
||||
}
|
||||
|
||||
var btCreditCardsInit = function( clientInstance ) {
|
||||
return braintree.hostedFields.create( {
|
||||
client: clientInstance,
|
||||
styles: {
|
||||
'input': {
|
||||
'font-size': '14px',
|
||||
'font-family': '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif',
|
||||
'color': '#fff'
|
||||
},
|
||||
':focus': {
|
||||
'color': '#fff'
|
||||
},
|
||||
"::placeholder": {
|
||||
'color': '#aaa'
|
||||
}
|
||||
},
|
||||
fields: {
|
||||
number: {
|
||||
'selector': '#cn_card_number',
|
||||
'placeholder': '0000 0000 0000 0000'
|
||||
},
|
||||
expirationDate: {
|
||||
'selector': '#cn_expiration_date',
|
||||
'placeholder': 'MM / YY'
|
||||
},
|
||||
cvv: {
|
||||
'selector': '#cn_cvv',
|
||||
'placeholder': '123'
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
var btHostedFieldsInstance = function( hostedFieldsInstance ) {
|
||||
btCreditCardsInitialized = true;
|
||||
|
||||
var form = $( 'form.cn-form[data-action="payment"]' );
|
||||
|
||||
form.removeClass( 'cn-form-disabled' );
|
||||
|
||||
form.on( 'submit', function() {
|
||||
if ( form.hasClass( 'cn-payment-in-progress' ) )
|
||||
return false;
|
||||
|
||||
form.find( '.cn-form-feedback' ).addClass( 'cn-hidden' );
|
||||
|
||||
// spin the spinner, if exists
|
||||
if ( form.find( '.cn-spinner' ).length )
|
||||
form.find( '.cn-spinner' ).addClass( 'spin' );
|
||||
|
||||
var invalidForm = false;
|
||||
var state = hostedFieldsInstance.getState();
|
||||
|
||||
// check hosted fields
|
||||
Object.keys( state.fields ).forEach( function( field ) {
|
||||
if ( ! state.fields[field].isValid ) {
|
||||
$( state.fields[field].container ).addClass( 'braintree-hosted-fields-invalid' );
|
||||
|
||||
invalidForm = true;
|
||||
}
|
||||
} );
|
||||
|
||||
if ( invalidForm ) {
|
||||
setTimeout( function() {
|
||||
cnDisplayError( cnWelcomeArgs.invalidFields, form );
|
||||
|
||||
// spin the spinner, if exists
|
||||
if ( form.find( '.cn-spinner' ).length )
|
||||
form.find( '.cn-spinner' ).removeClass( 'spin' );
|
||||
}, 500 );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
hostedFieldsInstance.tokenize( function( err, payload ) {
|
||||
if ( err ) {
|
||||
cnDisplayError( cnWelcomeArgs.error );
|
||||
|
||||
return false;
|
||||
} else {
|
||||
form.addClass( 'cn-payment-in-progress' );
|
||||
form.find( 'input[name="payment_nonce"]' ).val( payload.nonce );
|
||||
form.find( 'input[name="cn_payment_identifier"]' ).val( payload.details.lastFour );
|
||||
|
||||
$( '#cn_submit_pro' ).find( '.cn-screen-button[data-screen="4"]' ).trigger( 'click' );
|
||||
}
|
||||
} );
|
||||
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
|
||||
var btPaypalCheckoutInit = function( clientInstance ) {
|
||||
return braintree.paypalCheckout.create( {
|
||||
client: clientInstance
|
||||
} );
|
||||
}
|
||||
|
||||
var btPaypalCheckoutSDK = function( paypalCheckoutInstance ) {
|
||||
return paypalCheckoutInstance.loadPayPalSDK( {
|
||||
vault: true,
|
||||
intent: 'tokenize'
|
||||
} );
|
||||
}
|
||||
|
||||
var btPaypalCheckoutInstance = function( paypalCheckoutInstance ) {
|
||||
var form = $( 'form.cn-form[data-action="payment"]' );
|
||||
|
||||
return paypal.Buttons( {
|
||||
fundingSource: paypal.FUNDING.PAYPAL,
|
||||
createBillingAgreement: function() {
|
||||
form.addClass( 'cn-form-disabled' );
|
||||
|
||||
return paypalCheckoutInstance.createPayment( {
|
||||
flow: 'vault',
|
||||
intent: 'tokenize',
|
||||
currency: 'EUR'
|
||||
} );
|
||||
},
|
||||
onApprove: function( data, actions ) {
|
||||
return paypalCheckoutInstance.tokenizePayment( data ).then( function( payload ) {
|
||||
form.addClass( 'cn-payment-in-progress' );
|
||||
form.find( 'input[name="payment_nonce"]' ).val( payload.nonce );
|
||||
form.find( 'input[name="cn_payment_identifier"]' ).val( payload.details.email );
|
||||
|
||||
$( '#cn_submit_pro' ).find( '.cn-screen-button[data-screen="4"]' ).trigger( 'click' );
|
||||
} );
|
||||
},
|
||||
onCancel: function( data ) {
|
||||
form.removeClass( 'cn-form-disabled' );
|
||||
},
|
||||
onError: function( err ) {
|
||||
form.removeClass( 'cn-form-disabled' );
|
||||
}
|
||||
} ).render( '#cn_paypal_button' );
|
||||
}
|
||||
|
||||
var btPaypalCheckoutButton = function() {
|
||||
btPayPalInitialized = true;
|
||||
|
||||
$( 'form.cn-form[data-action="payment"]' ).removeClass( 'cn-form-disabled' );
|
||||
}
|
||||
|
||||
var btGatewayFail = function( error ) {
|
||||
if ( typeof error !== 'undefined' )
|
||||
console.log( error );
|
||||
|
||||
cnDisplayError( cnWelcomeArgs.error );
|
||||
}
|
||||
|
||||
var cnDisplayError = function( message, form ) {
|
||||
if ( typeof form === 'undefined' )
|
||||
form = $( 'form.cn-form[data-action="payment"]' );
|
||||
|
||||
form.find( '.cn-form-feedback' ).html( '<p class="cn-error">' + message + '</p>' ).removeClass( 'cn-hidden' );
|
||||
}
|
||||
|
||||
var cnWelcomeScreen = function( target ) {
|
||||
var screen = $( target ).data( 'screen' );
|
||||
var steps = [1, 2, 3, 4];
|
||||
var sidebars = ['login', 'register', 'configure', 'payment'];
|
||||
|
||||
// continue with screen loading
|
||||
var requestData = {
|
||||
action: 'cn_welcome_screen',
|
||||
nonce: cnWelcomeArgs.nonce
|
||||
};
|
||||
|
||||
if ( $.inArray( screen, steps ) !== -1 ) {
|
||||
var container = $( '.cn-welcome-wrap' );
|
||||
|
||||
requestData.screen = screen;
|
||||
} else if ( $.inArray( screen, sidebars ) !== -1 ) {
|
||||
var container = $( '.cn-sidebar' );
|
||||
|
||||
requestData.screen = screen;
|
||||
} else
|
||||
return false;
|
||||
|
||||
// network area?
|
||||
if ( cnWelcomeArgs.network === '1' )
|
||||
requestData.cn_network = 1;
|
||||
|
||||
// add loading overlay
|
||||
$( container ).addClass( 'cn-loading' );
|
||||
|
||||
$.ajax( {
|
||||
url: cnWelcomeArgs.ajaxURL,
|
||||
type: 'POST',
|
||||
dataType: 'html',
|
||||
data: requestData
|
||||
} ).done( function( response ) {
|
||||
$( container ).replaceWith( response );
|
||||
} ).fail( function( jqXHR, textStatus, errorThrown ) {
|
||||
//
|
||||
} ).always( function( response ) {
|
||||
// remove spinner
|
||||
$( container ).removeClass( 'cn-loading' );
|
||||
|
||||
// trigger event
|
||||
var event = $.Event( 'screen-loaded' );
|
||||
|
||||
$( document ).trigger( event );
|
||||
} );
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
var cnWelcomeForm = function( form ) {
|
||||
var formAction = $( form[0] ).data( 'action' );
|
||||
var formResult = null;
|
||||
var formData = {
|
||||
action: 'cn_api_request',
|
||||
nonce: cnWelcomeArgs.nonce
|
||||
};
|
||||
|
||||
// clear feedback
|
||||
$( form[0] ).find( '.cn-form-feedback' ).addClass( 'cn-hidden' );
|
||||
|
||||
// build request data
|
||||
formData.request = formAction;
|
||||
|
||||
// convert form data to object
|
||||
$( form[0] ).serializeArray().map( function( x ) {
|
||||
// exception for checkboxes
|
||||
if ( x.name === 'cn_laws' ) {
|
||||
var arrayVal = typeof formData[x.name] !== 'undefined' ? formData[x.name] : [];
|
||||
|
||||
arrayVal.push( x.value );
|
||||
|
||||
formData[x.name] = arrayVal;
|
||||
} else
|
||||
formData[x.name] = x.value;
|
||||
} );
|
||||
|
||||
// network area?
|
||||
if ( cnWelcomeArgs.network === '1' )
|
||||
formData.cn_network = 1;
|
||||
|
||||
formResult = $.ajax( {
|
||||
url: cnWelcomeArgs.ajaxURL,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: formData
|
||||
} );
|
||||
|
||||
return formResult;
|
||||
};
|
||||
|
||||
// handle screen loading
|
||||
$( document ).on( 'click', '.cn-screen-button', function( e ) {
|
||||
var form = $( e.target ).closest( 'form' );
|
||||
var result = false;
|
||||
|
||||
// spin the spinner, if exists
|
||||
if ( $( e.target ).find( '.cn-spinner' ).length )
|
||||
$( e.target ).find( '.cn-spinner' ).addClass( 'spin' );
|
||||
|
||||
// no form?
|
||||
if ( form.length === 0 )
|
||||
return cnWelcomeScreen( e.target );
|
||||
|
||||
var formData = {};
|
||||
var formDataset = $( form[0] ).data();
|
||||
var formAction = formDataset.hasOwnProperty( 'action' ) ? formDataset.action : '';
|
||||
|
||||
// get form data
|
||||
$( form[0] ).serializeArray().map( function( x ) {
|
||||
// exception for checkboxes
|
||||
if ( x.name === 'cn_laws' ) {
|
||||
var arrayVal = typeof formData[x.name] !== 'undefined' ? formData[x.name] : [];
|
||||
|
||||
arrayVal.push( x.value );
|
||||
|
||||
formData[x.name] = arrayVal;
|
||||
} else
|
||||
formData[x.name] = x.value;
|
||||
} );
|
||||
|
||||
// payment?
|
||||
if ( formAction === 'payment' ) {
|
||||
// free
|
||||
if ( formData.plan === 'free' ) {
|
||||
// load screen
|
||||
cnWelcomeScreen( e.target );
|
||||
|
||||
return false;
|
||||
// licesne
|
||||
} else if ( formData.plan === 'license' ) {
|
||||
// payment screen?
|
||||
var paymentEl = $( '.cn-sidebar form[data-action="payment"]' );
|
||||
|
||||
// disable form
|
||||
if ( paymentEl.length )
|
||||
paymentEl.addClass( 'cn-form-disabled' );
|
||||
|
||||
// get subscription ID
|
||||
var subscriptionID = formData.hasOwnProperty( 'cn_subscription_id' ) ? parseInt( formData.cn_subscription_id ) : 0;
|
||||
|
||||
var ajaxArgs = {
|
||||
action: 'cn_api_request',
|
||||
request: 'use_license',
|
||||
subscriptionID: subscriptionID,
|
||||
nonce: cnWelcomeArgs.nonce
|
||||
};
|
||||
|
||||
// network area?
|
||||
if ( cnWelcomeArgs.network === '1' )
|
||||
ajaxArgs.cn_network = 1;
|
||||
|
||||
// assign license request
|
||||
result = $.ajax( {
|
||||
url: cnWelcomeArgs.ajaxURL,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: ajaxArgs
|
||||
} );
|
||||
|
||||
// process license
|
||||
result.done( function( response ) {
|
||||
// error
|
||||
if ( response.hasOwnProperty( 'error' ) ) {
|
||||
cnDisplayError( response.error, $( form[0] ) );
|
||||
|
||||
return false;
|
||||
// message
|
||||
} else {
|
||||
var targetEl = $( '#cn_submit_license' ).find( '.cn-screen-button[data-screen="4"]' );
|
||||
|
||||
// open next screen
|
||||
cnWelcomeScreen( targetEl );
|
||||
|
||||
return result;
|
||||
}
|
||||
} );
|
||||
|
||||
// remove spinner
|
||||
result.always( function( response ) {
|
||||
if ( $( e.target ).find( '.cn-spinner' ).length )
|
||||
$( e.target ).find( '.cn-spinner' ).removeClass( 'spin' );
|
||||
|
||||
// enable form
|
||||
if ( paymentEl.length )
|
||||
paymentEl.removeClass( 'cn-form-disabled' );
|
||||
} );
|
||||
// pro
|
||||
} else {
|
||||
// only credit cards
|
||||
if ( $( form[0] ).find( 'input[name="payment_nonce"]' ).val() === '' ) {
|
||||
form.trigger( 'submit' );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// other forms
|
||||
} else
|
||||
e.preventDefault();
|
||||
|
||||
// break here on license payment
|
||||
if ( formAction === 'payment' && formData.plan === 'license' )
|
||||
return result;
|
||||
|
||||
// get form and process it
|
||||
result = cnWelcomeForm( form );
|
||||
|
||||
result.done( function( response ) {
|
||||
// error
|
||||
if ( response.hasOwnProperty( 'error' ) ) {
|
||||
cnDisplayError( response.error, $( form[0] ) );
|
||||
|
||||
return false;
|
||||
// message
|
||||
} else if ( response.hasOwnProperty( 'message' ) ) {
|
||||
cnDisplayError( response.message, $( form[0] ) );
|
||||
|
||||
return false;
|
||||
// all good
|
||||
} else {
|
||||
switch ( formAction ) {
|
||||
// logged in, go to success or billing
|
||||
case 'login':
|
||||
// register complete, go to success or billing
|
||||
case 'register':
|
||||
// if there are any subscriptions
|
||||
if ( response.hasOwnProperty( 'subscriptions' ) ) {
|
||||
var subscriptions = response.subscriptions;
|
||||
|
||||
if ( subscriptions.length > 0 ) {
|
||||
var available = 0;
|
||||
|
||||
for ( i = 0; i < subscriptions.length; i ++ ) {
|
||||
var subscriptionID = subscriptions[i].subscriptionid;
|
||||
var licensesAvailable = parseInt( subscriptions[i].availablelicense );
|
||||
var subscriptionText = subscriptions[i].VendorSubscriptionID + ' - ' + licensesAvailable + ' ' + cnWelcomeArgs.licensesAvailable;
|
||||
|
||||
var subscriptionOption = $( '<option value="' + subscriptionID + '">' + subscriptionText + '</option>' );
|
||||
|
||||
if ( licensesAvailable == 0 ) {
|
||||
$( subscriptionOption ).attr( 'disabled', 'true');
|
||||
}
|
||||
|
||||
$( '#cn-subscription-select' ).append( subscriptionOption );
|
||||
|
||||
available += licensesAvailable;
|
||||
}
|
||||
|
||||
if ( available > 0 ) {
|
||||
$( '.cn-pricing-plan-license' ).removeClass( 'cn-disabled' );
|
||||
$( '.cn-pricing-plan-license' ).find( '.cn-plan-amount' ).text( available );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var accountPlan = formData.hasOwnProperty( 'plan' ) ? formData.plan : 'free';
|
||||
|
||||
// trigger payment
|
||||
var accordionItem = $( form[0] ).closest( '.cn-accordion-item' );
|
||||
|
||||
// collapse account
|
||||
$( accordionItem ).addClass( 'cn-collapsed cn-disabled' );
|
||||
|
||||
// show billing
|
||||
$( accordionItem ).next().removeClass( 'cn-disabled' ).removeClass( 'cn-collapsed' );
|
||||
$( accordionItem ).find( 'form' ).removeClass( 'cn-form-disabled' );
|
||||
|
||||
// init braintree after payment screen is loaded via AJAX
|
||||
btInit();
|
||||
break;
|
||||
|
||||
case 'configure':
|
||||
default:
|
||||
// load screen
|
||||
cnWelcomeScreen( e.target );
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
result.always( function( response ) {
|
||||
if ( $( e.target ).find( '.cn-spinner' ).length )
|
||||
$( e.target ).find( '.cn-spinner' ).removeClass( 'spin' );
|
||||
|
||||
// after invalid payment?
|
||||
if ( formAction === 'payment' ) {
|
||||
$( form[0] ).removeClass( 'cn-payment-in-progress' );
|
||||
$( form[0] ).find( 'input[name="payment_nonce"]' ).val( '' );
|
||||
}
|
||||
} );
|
||||
|
||||
return result;
|
||||
} );
|
||||
|
||||
//
|
||||
$( document ).on( 'screen-loaded', function() {
|
||||
var configureFields = $( '#cn-form-configure' ).serializeArray() || [];
|
||||
var frame = window.frames[ 'cn_iframe_id' ];
|
||||
|
||||
if ( configureFields.length > 0 ) {
|
||||
$( configureFields ).each( function( index, field ) {
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
// change payment method
|
||||
$( document ).on( 'change', 'input[name="method"]', function() {
|
||||
var input = $( this );
|
||||
|
||||
$( '#cn_payment_method_credit_card, #cn_payment_method_paypal' ).toggle();
|
||||
|
||||
input.closest( 'form' ).find( '.cn-form-feedback' ).addClass( 'cn-hidden' );
|
||||
|
||||
// init payment method if needed
|
||||
btInitPaymentMethod( input.val() );
|
||||
} );
|
||||
|
||||
//
|
||||
$( document ).on( 'click', '.cn-accordion > .cn-accordion-item .cn-accordion-button', function() {
|
||||
var accordionItem = $( this ).closest( '.cn-accordion-item' );
|
||||
var activeItem = $( this ).closest( '.cn-accordion' ).find( '.cn-accordion-item:not(.cn-collapsed)' );
|
||||
|
||||
if ( $( accordionItem ).hasClass( 'cn-collapsed' ) ) {
|
||||
$( activeItem ).addClass( 'cn-collapsed' );
|
||||
$( accordionItem ).removeClass( 'cn-collapsed' );
|
||||
}
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
// live preview
|
||||
$( document ).on( 'change', 'input[name="cn_position"]', function() {
|
||||
var val = $( this ).val();
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'position', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_laws"]', function() {
|
||||
var val = [];
|
||||
|
||||
$( 'input[name="cn_laws"]:checked' ).each( function() {
|
||||
val.push( $( this ).val() );
|
||||
} );
|
||||
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'laws', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_naming"]', function() {
|
||||
var val = [];
|
||||
|
||||
$( 'input[name="cn_naming"]:checked' ).each( function() {
|
||||
val.push( $( this ).val() );
|
||||
} );
|
||||
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'naming', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_on_scroll"]', function() {
|
||||
var val = $( this ).prop( 'checked' );
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'on_scroll', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_on_click"]', function() {
|
||||
var val = $( this ).prop( 'checked' );
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'on_click', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_ui_blocking"]', function() {
|
||||
var val = $( this ).prop( 'checked' );
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'ui_blocking', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_revoke_consent"]', function() {
|
||||
var val = $( this ).prop( 'checked' );
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'revoke_consent', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_color_primary"]', function() {
|
||||
var val = $( this ).val();
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'color_primary', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_color_background"]', function() {
|
||||
var val = $( this ).val();
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'color_background', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_color_border"]', function() {
|
||||
var val = $( this ).val();
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'color_border', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_color_text"]', function() {
|
||||
var val = $( this ).val();
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'color_text', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_color_heading"]', function() {
|
||||
var val = $( this ).val();
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'color_heading', value: val} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'change', 'input[name="cn_color_button_text"]', function() {
|
||||
var val = $( this ).val();
|
||||
var frame = window.frames['cn_iframe_id'];
|
||||
|
||||
frame.contentWindow.postMessage( {call: 'color_button_text', value: val} );
|
||||
} );
|
||||
|
||||
// handle monthly / yearly payment plan
|
||||
$( document ).on( 'change', 'input[name="cn_pricing_type"]', function() {
|
||||
// pricing plans
|
||||
var plansMonthly = cnWelcomeArgs.pricingMonthly;
|
||||
var plansYearly = cnWelcomeArgs.pricingYearly;
|
||||
|
||||
var pricingOptions = $( '#cn-pricing-plans option' );
|
||||
var checked = $( 'input[name="cn_pricing_type"]:checked' ).val();
|
||||
|
||||
var names = Object.keys( checked === 'yearly' ? plansYearly : plansMonthly );
|
||||
var pricing = Object.values( checked === 'yearly' ? plansYearly : plansMonthly );
|
||||
|
||||
if ( checked === 'yearly' )
|
||||
$( '.cn-plan-period' ).text( cnWelcomeArgs.paidYear );
|
||||
else
|
||||
$( '.cn-plan-period' ).text( cnWelcomeArgs.paidMonth );
|
||||
|
||||
// replace options
|
||||
var i = 0;
|
||||
|
||||
for ( var property in pricing ) {
|
||||
var option = pricingOptions[i];
|
||||
|
||||
$( option ).val( names[i] );
|
||||
$( option ).attr( 'data-price', pricing[i] );
|
||||
i++;
|
||||
}
|
||||
|
||||
// trigger plan selection
|
||||
$( 'select[name="cn_pricing_plan"]' ).trigger( 'change' );
|
||||
} );
|
||||
|
||||
// handle pro plan selection
|
||||
$( document ).on( 'change', 'select[name="cn_pricing_plan"]', function() {
|
||||
var el = $( '#cn-pricing-plans' );
|
||||
var selected = $( el ).find( 'option:selected' );
|
||||
|
||||
// update price
|
||||
$( '.cn-pricing-plan-pro .cn-plan-amount' ).text( $( selected ).attr( 'data-price' ) );
|
||||
|
||||
var availablePlans = ['free'];
|
||||
|
||||
// merge with pro plans
|
||||
availablePlans = availablePlans.concat( Object.keys( cnWelcomeArgs.pricingMonthly ) );
|
||||
availablePlans = availablePlans.concat( Object.keys( cnWelcomeArgs.pricingYearly ) );
|
||||
|
||||
var input = $( this );
|
||||
var inputVal = input.val();
|
||||
|
||||
inputVal = availablePlans.indexOf( inputVal ) !== -1 ? inputVal : 'free';
|
||||
|
||||
if ( inputVal === 'free' ) {
|
||||
$( '#cn_submit_free' ).removeClass( 'cn-hidden' );
|
||||
$( '#cn_submit_pro' ).addClass( 'cn-hidden' );
|
||||
|
||||
$( document ).find( '#cn-field-plan-free' ).prop( 'checked', true );
|
||||
$( document ).find( '#cn-pricing-plan-free' ).prop( 'checked', true );
|
||||
} else {
|
||||
$( '#cn_submit_free' ).addClass( 'cn-hidden' );
|
||||
$( '#cn_submit_pro' ).removeClass( 'cn-hidden' );
|
||||
|
||||
$( document ).find( '#cn-field-plan-pro' ).val( inputVal ).prop( 'checked', true );
|
||||
$( document ).find( '#cn-pricing-plan-pro' ).prop( 'checked', true );
|
||||
}
|
||||
} );
|
||||
|
||||
// handle free / pro / license selection
|
||||
$( document ).on( 'change', 'input[name="plan"]', function() {
|
||||
var input = $( this ),
|
||||
inputVal = input.val();
|
||||
|
||||
if ( inputVal === 'free' ) {
|
||||
$( '#cn_submit_free' ).removeClass( 'cn-hidden' );
|
||||
$( '#cn_submit_pro' ).addClass( 'cn-hidden' );
|
||||
$( '#cn_submit_license' ).addClass( 'cn-hidden' );
|
||||
|
||||
$( document ).find( '#cn-pricing-plan-free' ).prop( 'checked', true );
|
||||
} else if ( inputVal === 'license' ) {
|
||||
$( '#cn_submit_free' ).addClass( 'cn-hidden' );
|
||||
$( '#cn_submit_pro' ).addClass( 'cn-hidden' );
|
||||
$( '#cn_submit_license' ).removeClass( 'cn-hidden' );
|
||||
|
||||
$( document ).find( '#cn-pricing-plan-free' ).prop( 'checked', false );
|
||||
$( document ).find( '#cn-pricing-plan-pro' ).prop( 'checked', false );
|
||||
} else {
|
||||
$( '#cn_submit_free' ).addClass( 'cn-hidden' );
|
||||
$( '#cn_submit_pro' ).removeClass( 'cn-hidden' );
|
||||
$( '#cn_submit_license' ).addClass( 'cn-hidden' );
|
||||
|
||||
$( document ).find( '#cn-pricing-plan-pro' ).prop( 'checked', true );
|
||||
}
|
||||
} );
|
||||
|
||||
// highlight form
|
||||
$( document ).on( 'click', 'input[name="cn_pricing"]', function() {
|
||||
$( '.cn-accordion .cn-accordion-item:first-child:not(.cn-collapsed)' ).focus();
|
||||
} );
|
||||
|
||||
// select plan payment
|
||||
$( document ).on( 'change', 'input[name="cn_pricing"]', function() {
|
||||
var input = $( this ),
|
||||
inputVal = input.val();
|
||||
|
||||
if ( inputVal === 'free' ) {
|
||||
$( '#cn_submit_free' ).removeClass( 'cn-hidden' );
|
||||
$( '#cn_submit_pro' ).addClass( 'cn-hidden' );
|
||||
|
||||
$( document ).find( '#cn-field-plan-free' ).prop( 'checked', true );
|
||||
} else {
|
||||
$( '#cn_submit_free' ).addClass( 'cn-hidden' );
|
||||
$( '#cn_submit_pro' ).removeClass( 'cn-hidden' );
|
||||
|
||||
$( document ).find( '#cn-field-plan-pro' ).prop( 'checked', true );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
// color picker
|
||||
initSpectrum();
|
||||
|
||||
// init welcome modal
|
||||
if ( cnWelcomeArgs.initModal == true )
|
||||
initModal();
|
||||
|
||||
} );
|
||||
|
||||
$( document ).on( 'ajaxComplete', function() {
|
||||
// color picker
|
||||
initSpectrum();
|
||||
} );
|
||||
|
||||
function initSpectrum() {
|
||||
$( '.cn-color-picker' ).spectrum( {
|
||||
showInput: true,
|
||||
showInitial: true,
|
||||
allowEmpty: false,
|
||||
showAlpha: false
|
||||
} );
|
||||
}
|
||||
|
||||
function initModal() {
|
||||
var progressbar,
|
||||
timerId,
|
||||
modal = $( "#cn-modal-trigger" );
|
||||
|
||||
if ( modal ) {
|
||||
$( "#cn-modal-trigger" ).modaal( {
|
||||
content_source: cnWelcomeArgs.ajaxURL + '?action=cn_welcome_screen' + '&nonce=' + cnWelcomeArgs.nonce + '&screen=1',
|
||||
type: 'ajax',
|
||||
width: 1600,
|
||||
custom_class: 'cn-modal',
|
||||
// is_locked: true
|
||||
ajax_success: function() {
|
||||
progressbar = $( document ).find( '.cn-progressbar' );
|
||||
|
||||
if ( progressbar ) {
|
||||
timerId = initProgressBar( progressbar );
|
||||
}
|
||||
},
|
||||
before_close: function() {
|
||||
clearInterval( timerId );
|
||||
|
||||
var currentStep = $( '.cn-welcome-wrap' );
|
||||
|
||||
// reload on success screen; set dismissed flag on early close
|
||||
if ( currentStep.length > 0 ) {
|
||||
if ( $( currentStep[0] ).hasClass( 'cn-welcome-step-4' ) === true ) {
|
||||
window.location.reload( true );
|
||||
} else {
|
||||
// user dismissed without completing — suppress future auto-open via ?welcome=1
|
||||
$.post( cnWelcomeArgs.ajaxURL, {
|
||||
action: 'cn_dismiss_welcome',
|
||||
nonce: cnWelcomeArgs.nonce
|
||||
} );
|
||||
}
|
||||
}
|
||||
},
|
||||
after_close: function() {
|
||||
progressbar = $( document ).find( '.cn-progressbar' );
|
||||
|
||||
$( progressbar ).progressbar( "destroy" );
|
||||
}
|
||||
} );
|
||||
|
||||
$( modal ).trigger( 'click' );
|
||||
|
||||
$( document ).on( 'click', '.cn-skip-button', function( e ) {
|
||||
$( '#modaal-close' ).trigger( 'click' );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
function initProgressBar( progressbar ) {
|
||||
var progressbarObj,
|
||||
progressLabel = $( document ).find( '.cn-progress-label' ),
|
||||
complianceResults = $( document ).find( '.cn-compliance-results' ),
|
||||
currentProgress = 0,
|
||||
timerId;
|
||||
|
||||
if ( progressbar ) {
|
||||
$( document ).on( 'click', '.cn-screen-button', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
clearInterval( timerId );
|
||||
} );
|
||||
|
||||
$( progressbar ).progressbar( {
|
||||
value: 5,
|
||||
max: 100,
|
||||
create: function( event, ui ) {
|
||||
timerId = setInterval( function() {
|
||||
// increment progress bar
|
||||
currentProgress += 5;
|
||||
|
||||
// update progressbar
|
||||
progressbar.progressbar( 'value', currentProgress );
|
||||
|
||||
var lastItem = $( complianceResults ).find( 'div:visible' ).last(),
|
||||
lastItemText = $( lastItem ).find( '.cn-compliance-status' ).text();
|
||||
|
||||
$( lastItem ).find( '.cn-compliance-status' ).text( lastItemText + ' .' );
|
||||
|
||||
switch ( currentProgress ) {
|
||||
case 15:
|
||||
$( lastItem ).find( '.cn-compliance-status' ).addClass( 'cn-passed' ).text( cnWelcomeArgs.statusPassed );
|
||||
|
||||
$( lastItem ).next().slideDown( 200 );
|
||||
break;
|
||||
case 35:
|
||||
case 55:
|
||||
case 75:
|
||||
case 95:
|
||||
if ( cnWelcomeArgs.complianceStatus === 'active' ) {
|
||||
$( lastItem ).find( '.cn-compliance-status' ).addClass( 'cn-passed' ).text( cnWelcomeArgs.statusPassed );
|
||||
} else {
|
||||
$( lastItem ).find( '.cn-compliance-status' ).addClass( 'cn-failed' ).text( cnWelcomeArgs.statusFailed );
|
||||
}
|
||||
|
||||
$( lastItem ).next().slideDown( 200 );
|
||||
break;
|
||||
case 100:
|
||||
if ( cnWelcomeArgs.complianceStatus === 'active' ) {
|
||||
$( lastItem ).find( '.cn-compliance-status' ).addClass( 'cn-passed' ).text( cnWelcomeArgs.statusPassed );
|
||||
} else {
|
||||
$( lastItem ).find( '.cn-compliance-status' ).addClass( 'cn-failed' ).text( cnWelcomeArgs.statusFailed );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// complete
|
||||
if ( currentProgress >= 100 )
|
||||
clearInterval( timerId );
|
||||
}, 300 );
|
||||
},
|
||||
change: function( event, ui ) {
|
||||
progressLabel.text( progressbar.progressbar( 'value' ) + '%' );
|
||||
},
|
||||
complete: function( event, ui ) {
|
||||
setTimeout( function() {
|
||||
if ( cnWelcomeArgs.complianceStatus )
|
||||
$( '.cn-compliance-check' ).find( '.cn-compliance-feedback' ).html( '<p class="cn-message">' + cnWelcomeArgs.compliancePassed + '</p>' ).removeClass( 'cn-hidden' );
|
||||
else
|
||||
$( '.cn-compliance-check' ).find( '.cn-compliance-feedback' ).html( '<p class="cn-error">' + cnWelcomeArgs.complianceFailed + '</p>' ).removeClass( 'cn-hidden' );
|
||||
}, 500 );
|
||||
}
|
||||
} );
|
||||
|
||||
progressbarObj = $( progressbar ).progressbar( "instance" );
|
||||
|
||||
return timerId;
|
||||
}
|
||||
}
|
||||
|
||||
$( document ).on( 'click', '.cn-run-upgrade, .cn-run-welcome', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// modal
|
||||
initModal();
|
||||
} );
|
||||
|
||||
$( document ).ready( function() {
|
||||
var welcome = false;
|
||||
|
||||
welcome = cnGetUrlParam( 'welcome' );
|
||||
|
||||
if ( welcome && ! cnWelcomeArgs.dismissed ) {
|
||||
// modal — suppressed if user previously dismissed without completing
|
||||
initModal();
|
||||
}
|
||||
} );
|
||||
|
||||
$( document ).on( 'click', '.cn-sign-up', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '.cn-screen-button' ).trigger( 'click' );
|
||||
} );
|
||||
|
||||
var cnGetUrlParam = function cnGetUrlParam( parameter ) {
|
||||
var pageURL = window.location.search.substring( 1 ),
|
||||
urlVars = pageURL.split( '&' ),
|
||||
parameterName,
|
||||
i;
|
||||
|
||||
for ( i = 0; i < urlVars.length; i ++ ) {
|
||||
parameterName = urlVars[i].split( '=' );
|
||||
|
||||
if ( parameterName[0] === parameter )
|
||||
return typeof parameterName[1] === undefined ? true : decodeURIComponent( parameterName[1] );
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
} )( jQuery );
|
||||
760
wp-content/plugins/cookie-notice/js/admin.js
Normal file
760
wp-content/plugins/cookie-notice/js/admin.js
Normal file
@@ -0,0 +1,760 @@
|
||||
( function( $ ) {
|
||||
|
||||
// ready event
|
||||
$( function() {
|
||||
// initialize color picker
|
||||
$( '.cn_color' ).wpColorPicker();
|
||||
|
||||
$( document ).on( 'click', 'input.cn-reset-settings', function() {
|
||||
return confirm( cnArgs.resetToDefaults );
|
||||
} );
|
||||
|
||||
if ( cnArgs.settingsTab === 'privacy-consent' ) {
|
||||
var cnListTable = {
|
||||
displayedSources: [],
|
||||
sourceContainers: {},
|
||||
tableContainers: {},
|
||||
|
||||
/**
|
||||
* Initialize list tables.
|
||||
*
|
||||
* @param object sources
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
init: function( sources ) {
|
||||
for ( const source in sources ) {
|
||||
let mainContainter = $( '#cn_privacy_consent_' + source );
|
||||
|
||||
// update duplicated ids
|
||||
mainContainter.find( '#the-list' ).attr( 'id', 'the-list-' + source );
|
||||
mainContainter.find( '#table-paging' ).attr( 'id', 'table-paging-' + source );
|
||||
|
||||
if ( sources[source].type === 'dynamic' ) {
|
||||
// add containers
|
||||
this.sourceContainers[source] = mainContainter;
|
||||
this.tableContainers[source] = mainContainter.find( '.cn-privacy-consent-list-table-container' );
|
||||
|
||||
// load list table only for active (checked) sources
|
||||
if ( !! sources[source].status && !! sources[source].availability )
|
||||
this.display( source );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle clicking functional links.
|
||||
*
|
||||
* @param string sourceId
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
start: function( sourceId ) {
|
||||
var that = this;
|
||||
|
||||
this.tableContainers[sourceId].find( '.tablenav-pages a, .manage-column.sortable a, .manage-column.sorted a' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// remove question mark
|
||||
var query = this.search.substring( 1 );
|
||||
|
||||
// prepare data
|
||||
var data = {
|
||||
paged: that.query( query, 'paged' ) || 1,
|
||||
order: that.query( query, 'order' ) || 'asc',
|
||||
orderby: that.query( query, 'orderby' ) || 'title',
|
||||
search: that.query( query, 'search' ) || ''
|
||||
};
|
||||
|
||||
that.update( sourceId, data );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Display data for the first time.
|
||||
*
|
||||
* @param string sourceId
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
display: function( sourceId ) {
|
||||
// already displayed?
|
||||
if ( this.displayedSources.includes( sourceId ) )
|
||||
return;
|
||||
|
||||
this.displayedSources.push( sourceId );
|
||||
|
||||
let that = this;
|
||||
let spinner = this.sourceContainers[sourceId].find( '.tablenav .spinner' );
|
||||
|
||||
$.ajax( {
|
||||
url: ajaxurl,
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
nonce: $( '#cn_privacy_consent_nonce' ).val(),
|
||||
action: 'cn_privacy_consent_display_table',
|
||||
source: sourceId
|
||||
}
|
||||
} ).done( function( response ) {
|
||||
try {
|
||||
if ( response.success ) {
|
||||
// update list table
|
||||
that.tableContainers[sourceId].html( response.data );
|
||||
|
||||
// update duplicated ids
|
||||
that.tableContainers[sourceId].find( '#the-list' ).attr( 'id', 'the-list-' + sourceId );
|
||||
that.tableContainers[sourceId].find( '#table-paging' ).attr( 'id', 'table-paging-' + sourceId );
|
||||
|
||||
// bind form status handling
|
||||
that.tableContainers[sourceId].find( 'input.cn-privacy-consent-form-status' ).on( 'change', handleFormStatus );
|
||||
|
||||
let searchInput = $( '#' + sourceId + '-search-input' );
|
||||
let searchButton = $( '#' + sourceId + '-search-submit' );
|
||||
|
||||
// disallow enter key form submission
|
||||
searchInput.on( 'keydown', function( e ) {
|
||||
if ( e.key === 'Enter' ) {
|
||||
e.preventDefault();
|
||||
|
||||
searchButton.click();
|
||||
// return false;
|
||||
}
|
||||
} );
|
||||
|
||||
// handle searching
|
||||
searchButton.on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// remove question mark
|
||||
var query = this.search.substring( 1 );
|
||||
|
||||
// prepare data
|
||||
var data = {
|
||||
paged: that.query( query, 'paged' ) || 1,
|
||||
order: that.query( query, 'order' ) || 'asc',
|
||||
orderby: that.query( query, 'orderby' ) || 'title',
|
||||
search: searchInput.val() || ''
|
||||
};
|
||||
|
||||
that.update( sourceId, data );
|
||||
} );
|
||||
|
||||
that.start( sourceId );
|
||||
} else {
|
||||
console.log( 'Loading source "' + sourceId + '" failed.' );
|
||||
}
|
||||
} catch ( e ) {
|
||||
console.log( 'Loading source "' + sourceId + '" failed.' );
|
||||
}
|
||||
} ).always( function() {
|
||||
// hide spinner
|
||||
spinner.removeClass( 'is-active' );
|
||||
|
||||
// enable list table
|
||||
that.tableContainers[sourceId].find( 'table' ).removeClass( 'loading' );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* AJAX request to get source data.
|
||||
*
|
||||
* @param string sourceId
|
||||
* @param object data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
update: function( sourceId, data ) {
|
||||
let that = this;
|
||||
let spinner = this.sourceContainers[sourceId].find( '.tablenav .spinner' );
|
||||
|
||||
// display spinner
|
||||
spinner.addClass( 'is-active' );
|
||||
|
||||
// disable list table
|
||||
this.tableContainers[sourceId].find( 'table' ).addClass( 'loading' );
|
||||
|
||||
$.ajax( {
|
||||
url: ajaxurl,
|
||||
type: 'GET',
|
||||
data: {
|
||||
nonce: $( '#cn_privacy_consent_nonce' ).val(),
|
||||
action: 'cn_privacy_consent_get_forms',
|
||||
source: sourceId,
|
||||
paged: data.paged,
|
||||
order: data.order,
|
||||
orderby: data.orderby,
|
||||
search: data.search
|
||||
}
|
||||
} ).done( function( response ) {
|
||||
try {
|
||||
if ( response.success ) {
|
||||
if ( response.data.rows.length )
|
||||
that.sourceContainers[sourceId].find( 'tbody' ).html( response.data.rows );
|
||||
|
||||
if ( response.data.column_headers.length )
|
||||
that.sourceContainers[sourceId].find( 'thead tr, tfoot tr' ).html( response.data.column_headers );
|
||||
|
||||
if ( response.data.pagination.length ) {
|
||||
that.sourceContainers[sourceId].find( '.tablenav.bottom .tablenav-pages' ).html( $( response.data.pagination ).html() );
|
||||
that.sourceContainers[sourceId].find( '#table-paging' ).attr( 'id', 'table-paging-' + sourceId );
|
||||
}
|
||||
|
||||
// bind form status handling
|
||||
that.tableContainers[sourceId].find( 'input.cn-privacy-consent-form-status' ).on( 'change', handleFormStatus );
|
||||
|
||||
that.start( sourceId );
|
||||
} else {
|
||||
console.log( 'FAILED' );
|
||||
}
|
||||
} catch ( e ) {
|
||||
console.log( 'FAILED' );
|
||||
}
|
||||
} ).always( function() {
|
||||
// hide spinner
|
||||
spinner.removeClass( 'is-active' );
|
||||
|
||||
// enable list table
|
||||
that.tableContainers[sourceId].find( 'table' ).removeClass( 'loading' );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Filter the URL Query to extract variables.
|
||||
*
|
||||
* @param string query
|
||||
* @param string variable
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
query: function( query, variable ) {
|
||||
var vars = query.split( '&' );
|
||||
|
||||
for ( var i = 0; i < vars.length; i++ ) {
|
||||
var pair = vars[i].split( '=' );
|
||||
|
||||
if ( pair[0] === variable )
|
||||
return pair[1];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// any privacy consent sources?
|
||||
if ( cnArgs.privacyConsentSources ) {
|
||||
// initialize list tables
|
||||
cnListTable.init( cnArgs.privacyConsentSources );
|
||||
|
||||
// handle every single static form status
|
||||
for ( const source in cnArgs.privacyConsentSources ) {
|
||||
if ( cnArgs.privacyConsentSources[source].type === 'static' ) {
|
||||
$( '#cn_privacy_consent_' + cnArgs.privacyConsentSources[source].id ).find( 'input.cn-privacy-consent-form-status' ).on( 'change', handleFormStatus );
|
||||
}
|
||||
}
|
||||
|
||||
// privacy consent source status
|
||||
$( 'input.cn-privacy-consent-status' ).on( 'change', function() {
|
||||
let checkbox = $( this );
|
||||
|
||||
if ( checkbox.is( ':checked' ) ) {
|
||||
let source = checkbox.data( 'source' );
|
||||
|
||||
checkbox.closest( 'fieldset' ).find( '.cn-privacy-consent-options-container' ).slideDown( 'fast' );
|
||||
|
||||
// dynamic source?
|
||||
if ( cnArgs.privacyConsentSources[source].type === 'dynamic' )
|
||||
cnListTable.display( source );
|
||||
} else
|
||||
checkbox.closest( 'fieldset' ).find( '.cn-privacy-consent-options-container' ).slideUp( 'fast' );
|
||||
} );
|
||||
|
||||
// privacy consent active type
|
||||
$( 'input.cn-privacy-consent-active-type' ).on( 'change', function( e ) {
|
||||
let radio = $( e.target );
|
||||
let target = radio.closest( 'fieldset' ).find( '.cn-privacy-consent-list-table-container' );
|
||||
let value = $( '[name="' + $( radio ).attr('name') + '"]:checked' ).val();
|
||||
|
||||
if ( target.length > 0 ) {
|
||||
if ( value === 'all' ) {
|
||||
target.addClass( 'apply-all' );
|
||||
target.removeClass( 'apply-selected' );
|
||||
} else {
|
||||
target.addClass( 'apply-selected' );
|
||||
target.removeClass( 'apply-all' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function handleFormStatus() {
|
||||
let el = $( this );
|
||||
|
||||
// disable list table
|
||||
el.closest( 'table' ).addClass( 'loading' );
|
||||
|
||||
$.post( ajaxurl, {
|
||||
action: 'cn_privacy_consent_form_status',
|
||||
form_id: el.data( 'form_id' ),
|
||||
source: el.data( 'source' ),
|
||||
status: el.is( ':checked' ) ? 1 : 0,
|
||||
nonce: cnArgs.noncePrivacyConsent
|
||||
} ).done( function( data ) {
|
||||
//
|
||||
} ).always( function() {
|
||||
// enable list table
|
||||
el.closest( 'table' ).removeClass( 'loading' );
|
||||
} );
|
||||
}
|
||||
} else if ( cnArgs.settingsTab === 'consent-logs' ) {
|
||||
function handleListTablePagination( container, perPage ) {
|
||||
let paginationLinks = container.find( '.pagination-links' );
|
||||
let firstPageButton = paginationLinks.find( '.first-page' );
|
||||
let lastPageButton = paginationLinks.find( '.last-page' );
|
||||
let nextPageButton = paginationLinks.find( '.next-page' );
|
||||
let prevPageButton = paginationLinks.find( '.prev-page' );
|
||||
let currentPageEl = paginationLinks.find( '.current-page' );
|
||||
let totalNumberofPages = parseInt( paginationLinks.data( 'total' ) ) || 1;
|
||||
|
||||
// get table body
|
||||
var tableBody = container.find( 'table tbody' );
|
||||
|
||||
// prepare array with table rows
|
||||
var dataRows = container.find( 'table' ).find( 'tbody tr' ).toArray();
|
||||
|
||||
// set flag
|
||||
var firstTime = true;
|
||||
|
||||
// add pagination
|
||||
container.pagination( {
|
||||
dataSource: dataRows,
|
||||
pageSize: perPage,
|
||||
showNavigator: false,
|
||||
showPrevious: false,
|
||||
showNext: false,
|
||||
showPageNumbers: false,
|
||||
callback: function( data, pagination ) {
|
||||
// skip showing/hiding table rows on init
|
||||
if ( firstTime ) {
|
||||
firstTime = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// hide all table rows
|
||||
tableBody.find( 'tr' ).hide();
|
||||
|
||||
// display table rows
|
||||
for ( const el of data ) {
|
||||
$( el ).show();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// handle first page
|
||||
firstPageButton.on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
firstPageButton.addClass( 'disabled' );
|
||||
lastPageButton.removeClass( 'disabled' );
|
||||
nextPageButton.removeClass( 'disabled' );
|
||||
prevPageButton.addClass( 'disabled' );
|
||||
|
||||
container.pagination( 'go', 1 );
|
||||
|
||||
currentPageEl.html( 1 );
|
||||
} );
|
||||
|
||||
// handle last page
|
||||
lastPageButton.on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
firstPageButton.removeClass( 'disabled' );
|
||||
lastPageButton.addClass( 'disabled' );
|
||||
nextPageButton.addClass( 'disabled' );
|
||||
prevPageButton.removeClass( 'disabled' );
|
||||
|
||||
container.pagination( 'go', totalNumberofPages );
|
||||
|
||||
currentPageEl.html( totalNumberofPages );
|
||||
} );
|
||||
|
||||
// handle next page
|
||||
nextPageButton.on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
firstPageButton.removeClass( 'disabled' );
|
||||
prevPageButton.removeClass( 'disabled' );
|
||||
|
||||
container.pagination( 'next' );
|
||||
|
||||
let currentPage = container.pagination( 'getCurrentPageNum' );
|
||||
|
||||
currentPageEl.html( currentPage );
|
||||
|
||||
if ( currentPage === totalNumberofPages ) {
|
||||
lastPageButton.addClass( 'disabled' );
|
||||
nextPageButton.addClass( 'disabled' );
|
||||
}
|
||||
} );
|
||||
|
||||
// handle previous page
|
||||
prevPageButton.on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
lastPageButton.removeClass( 'disabled' );
|
||||
nextPageButton.removeClass( 'disabled' );
|
||||
|
||||
container.pagination( 'previous' );
|
||||
|
||||
let currentPage = container.pagination( 'getCurrentPageNum' );
|
||||
|
||||
currentPageEl.html( currentPage );
|
||||
|
||||
if ( currentPage === 1 ) {
|
||||
firstPageButton.addClass( 'disabled' );
|
||||
prevPageButton.addClass( 'disabled' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
if ( cnArgs.settingsSection === 'cookie' ) {
|
||||
// consent logs
|
||||
$( '.cn-consent-log-item input[type="checkbox"]' ).on( 'change', function() {
|
||||
var el = $( this );
|
||||
var trEl = el.closest( 'tr' );
|
||||
var trDetailsId = trEl.attr( 'id' ) + '_details';
|
||||
var trDetailsIdHash = '#' + trDetailsId;
|
||||
var trDetailsRow = trEl.attr( 'id' ) + '_row';
|
||||
|
||||
if ( el.is( ':checked' ) ) {
|
||||
// remove fake row
|
||||
$( '#' + trDetailsRow ).remove();
|
||||
|
||||
// valid data already downloaded?
|
||||
if ( $( trDetailsIdHash ).length && $( trDetailsIdHash ).data( 'status' ) === 1 ) {
|
||||
$( trDetailsIdHash ).show();
|
||||
} else {
|
||||
var trDetailsDataEl = null;
|
||||
|
||||
if ( $( trDetailsIdHash ).length ) {
|
||||
$( trDetailsIdHash ).show();
|
||||
|
||||
trDetailsDataEl = $( trDetailsIdHash + ' .cn-consent-logs-data' );
|
||||
|
||||
trDetailsDataEl.addClass( 'loading' );
|
||||
trDetailsDataEl.html( '<span class="spinner is-active"></span>' );
|
||||
} else {
|
||||
trEl.after( cnArgs.consentLogsTemplate );
|
||||
trEl.next().attr( 'id', trDetailsId );
|
||||
|
||||
trDetailsDataEl = $( trDetailsIdHash + ' .cn-consent-logs-data' );
|
||||
}
|
||||
|
||||
$.ajax( {
|
||||
url: cnArgs.ajaxURL,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'cn_get_cookie_consent_logs',
|
||||
nonce: cnArgs.nonceCookieConsentLogs,
|
||||
date: el.closest( 'tr' ).data( 'date' )
|
||||
}
|
||||
} ).done( function( result ) {
|
||||
if ( result.success ) {
|
||||
// set success status
|
||||
$( trDetailsIdHash ).data( 'status', 1 );
|
||||
|
||||
// add table rows or display error
|
||||
trDetailsDataEl.find( '.spinner' ).replaceWith( result.data );
|
||||
|
||||
// update duplicated ids
|
||||
trDetailsDataEl.find( '#the-list' ).attr( 'id', 'the-list-' + trEl.data( 'date' ) );
|
||||
|
||||
// bind pagination script
|
||||
handleListTablePagination( trDetailsDataEl, 10 );
|
||||
} else {
|
||||
// set failed status
|
||||
$( trDetailsIdHash ).data( 'status', 0 );
|
||||
|
||||
// display error
|
||||
trDetailsDataEl.find( '.spinner' ).replaceWith( cnArgs.consentLogsError );
|
||||
}
|
||||
} ).fail( function( result ) {
|
||||
// set failed status
|
||||
$( trDetailsIdHash ).data( 'status', 0 );
|
||||
|
||||
// display error
|
||||
trDetailsDataEl.find( '.spinner' ).replaceWith( cnArgs.consentLogsError );
|
||||
} ).always( function( result ) {
|
||||
// hide spinner
|
||||
trDetailsDataEl.removeClass( 'loading' );
|
||||
} );
|
||||
}
|
||||
} else {
|
||||
$( trDetailsIdHash ).hide();
|
||||
$( trDetailsIdHash ).after( '<tr id="' + trDetailsRow + '" class="cn-consent-logs-row"><td colspan="6"></td></tr>' );
|
||||
}
|
||||
} );
|
||||
} else if ( cnArgs.settingsSection === 'privacy' ) {
|
||||
let container = $( '.cn-privacy-consent-logs-data' );
|
||||
|
||||
$.ajax( {
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
nonce: cnArgs.noncePrivacyConsentLogs,
|
||||
action: 'cn_get_privacy_consent_logs'
|
||||
}
|
||||
} ).done( function( result ) {
|
||||
if ( result.success ) {
|
||||
// update list table
|
||||
container.html( result.data );
|
||||
|
||||
// bind pagination script
|
||||
handleListTablePagination( container, 20 );
|
||||
} else {
|
||||
// display error
|
||||
container.find( '.spinner' ).replaceWith( cnArgs.consentLogsError );
|
||||
}
|
||||
} ).fail( function() {
|
||||
// display error
|
||||
container.find( '.spinner' ).replaceWith( cnArgs.consentLogsError );
|
||||
} ).always( function() {
|
||||
// hide spinner
|
||||
container.find( 'table' ).removeClass( 'loading' );
|
||||
} );
|
||||
}
|
||||
} else if ( cnArgs.settingsTab === 'settings' ) {
|
||||
// purge cache
|
||||
$( '#cn_app_purge_cache a' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var el = this;
|
||||
|
||||
$( el ).parent().addClass( 'loading' ).append( '<span class="spinner is-active" style="float: none"></span>' );
|
||||
|
||||
var ajaxArgs = {
|
||||
action: 'cn_purge_cache',
|
||||
nonce: cnArgs.nonce
|
||||
};
|
||||
|
||||
// network area?
|
||||
if ( cnArgs.network )
|
||||
ajaxArgs.cn_network = 1;
|
||||
|
||||
$.ajax( {
|
||||
url: cnArgs.ajaxURL,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: ajaxArgs
|
||||
} ).always( function( result ) {
|
||||
$( el ).parent().find( '.spinner' ).remove();
|
||||
} );
|
||||
} );
|
||||
|
||||
// global override
|
||||
$( 'input[name="cookie_notice_options[global_override]"]' ).on( 'change', function() {
|
||||
$( '.cookie-notice-settings form' ).toggleClass( 'cn-options-disabled' );
|
||||
} );
|
||||
|
||||
// refuse option
|
||||
$( '#cn_refuse_opt' ).on( 'change', function() {
|
||||
if ( $( this ).is( ':checked' ) )
|
||||
$( '#cn_refuse_opt_container' ).slideDown( 'fast' );
|
||||
else
|
||||
$( '#cn_refuse_opt_container' ).slideUp( 'fast' );
|
||||
} );
|
||||
|
||||
// revoke option
|
||||
$( '#cn_revoke_cookies' ).on( 'change', function() {
|
||||
if ( $( this ).is( ':checked' ) )
|
||||
$( '#cn_revoke_opt_container' ).slideDown( 'fast' );
|
||||
else
|
||||
$( '#cn_revoke_opt_container' ).slideUp( 'fast' );
|
||||
} );
|
||||
|
||||
// privacy policy option
|
||||
$( '#cn_see_more' ).on( 'change', function() {
|
||||
if ( $( this ).is( ':checked' ) )
|
||||
$( '#cn_see_more_opt' ).slideDown( 'fast' );
|
||||
else
|
||||
$( '#cn_see_more_opt' ).slideUp( 'fast' );
|
||||
} );
|
||||
|
||||
// on scroll option
|
||||
$( '#cn_on_scroll' ).on( 'change', function() {
|
||||
if ( $( this ).is( ':checked' ) )
|
||||
$( '#cn_on_scroll_offset' ).slideDown( 'fast' );
|
||||
else
|
||||
$( '#cn_on_scroll_offset' ).slideUp( 'fast' );
|
||||
} );
|
||||
|
||||
// conditional display option
|
||||
$( '#cn_conditional_display_opt' ).on( 'change', function() {
|
||||
if ( $( this ).is( ':checked' ) )
|
||||
$( '#cn_conditional_display_opt_container' ).slideDown( 'fast' );
|
||||
else
|
||||
$( '#cn_conditional_display_opt_container' ).slideUp( 'fast' );
|
||||
} );
|
||||
|
||||
// privacy policy link
|
||||
$( '#cn_see_more_link-custom, #cn_see_more_link-page' ).on( 'change', function() {
|
||||
if ( $( '#cn_see_more_link-custom:checked' ).val() === 'custom' ) {
|
||||
$( '#cn_see_more_opt_page' ).slideUp( 'fast', function() {
|
||||
$( '#cn_see_more_opt_link' ).slideDown( 'fast' );
|
||||
} );
|
||||
} else if ( $( '#cn_see_more_link-page:checked' ).val() === 'page' ) {
|
||||
$( '#cn_see_more_opt_link' ).slideUp( 'fast', function() {
|
||||
$( '#cn_see_more_opt_page' ).slideDown( 'fast' );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
// script blocking
|
||||
$( '#cn_refuse_code_fields' ).find( 'a' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '#cn_refuse_code_fields' ).find( 'a' ).removeClass( 'nav-tab-active' );
|
||||
$( '.refuse-code-tab' ).removeClass( 'active' );
|
||||
|
||||
var id = $( this ).attr( 'id' ).replace( '-tab', '' );
|
||||
|
||||
$( '#' + id ).addClass( 'active' );
|
||||
$( this ).addClass( 'nav-tab-active' );
|
||||
} );
|
||||
|
||||
// add new group of rules
|
||||
$( document ).on( 'click', '.add-rule-group', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var html = $( '#rules-group-template' ).html();
|
||||
var group = $( '#rules-groups' );
|
||||
var groups = group.find( '.rules-group' );
|
||||
var groupID = ( groups.length > 0 ? parseInt( groups.last().attr( 'id' ).split( '-' )[2] ) + 1 : 1 );
|
||||
|
||||
html = html.replace( /__GROUP_ID__/g, groupID );
|
||||
html = html.replace( /__RULE_ID__/g, 1 );
|
||||
|
||||
group.append( '<div class="rules-group" id="rules-group-' + groupID + '">' + html + '</div>' );
|
||||
group.find( '.rules-group' ).last().fadeIn( 'fast' );
|
||||
} );
|
||||
|
||||
// remove single rule or group
|
||||
$( document ).on( 'click', '.remove-rule', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var number = $( this ).closest( 'tbody' ).find( 'tr' ).length;
|
||||
|
||||
if ( number === 1 ) {
|
||||
$( this ).closest( '.rules-group' ).fadeOut( 'fast', function() {
|
||||
$( this ).remove();
|
||||
} );
|
||||
} else {
|
||||
$( this ).closest( 'tr' ).fadeOut( 'fast', function() {
|
||||
$( this ).remove();
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
// handle changing values for specified type of rules
|
||||
$( document ).on( 'change', '.rule-type', function() {
|
||||
var el = $( this );
|
||||
var td = el.closest( 'tr' ).find( 'td.value' );
|
||||
var select = td.find( 'select' );
|
||||
var spinner = td.find( '.spinner' );
|
||||
|
||||
select.hide();
|
||||
spinner.fadeIn( 'fast' ).css( 'visibility', 'visible' );
|
||||
|
||||
$.post( ajaxurl, {
|
||||
action: 'cn-get-group-rules-values',
|
||||
cn_param: el.val(),
|
||||
cn_nonce: cnArgs.nonceConditional
|
||||
} ).done( function( data ) {
|
||||
spinner.hide().css( 'visibility', 'hidden' );
|
||||
|
||||
try {
|
||||
var response = $.parseJSON( data );
|
||||
|
||||
// remove potential optgroups
|
||||
select.find( 'optgroup' ).remove();
|
||||
|
||||
// replace old select options with new ones
|
||||
select.fadeIn( 'fast' ).find( 'option' ).remove().end().append( response.select );
|
||||
} catch( e ) {
|
||||
//
|
||||
}
|
||||
} ).fail( function() {
|
||||
//
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
// sync configuration button
|
||||
$( document ).on( 'click', '.cn-sync-config-btn', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $( this );
|
||||
var container = $( '#cn_sync_config' );
|
||||
var spinner = container.find( '.cn-sync-spinner' );
|
||||
var statusEl = container.find( '.cn-sync-status' );
|
||||
var messageEl = container.find( '.cn-sync-message' );
|
||||
|
||||
// disable button and show spinner
|
||||
button.prop( 'disabled', true );
|
||||
spinner.addClass( 'is-active' );
|
||||
messageEl.hide().removeClass( 'notice notice-success notice-error' );
|
||||
|
||||
// make AJAX request
|
||||
$.ajax( {
|
||||
url: cnArgs.ajaxURL,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'cn_api_request',
|
||||
request: 'sync_config',
|
||||
nonce: cnArgs.nonceSyncConfig,
|
||||
cn_network: cnArgs.network ? 1 : 0
|
||||
}
|
||||
} ).done( function( response ) {
|
||||
if ( response && response.success ) {
|
||||
// update last synced timestamp
|
||||
if ( response.timestamp ) {
|
||||
var date = new Date( response.timestamp.replace( /-/g, '/' ) );
|
||||
var dateOptions = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit' };
|
||||
var formattedDate = date.toLocaleString( undefined, dateOptions );
|
||||
statusEl.text( 'Last synced: ' + formattedDate );
|
||||
}
|
||||
|
||||
// show success message
|
||||
messageEl.html( '<p>' + ( response.message || 'Configuration synced successfully.' ) + '</p>' )
|
||||
.addClass( 'notice notice-success' )
|
||||
.fadeIn( 'fast' );
|
||||
|
||||
// hide message after 5 seconds
|
||||
setTimeout( function() {
|
||||
messageEl.fadeOut( 'slow' );
|
||||
}, 5000 );
|
||||
} else {
|
||||
// show error message
|
||||
var errorMsg = response && response.error ? response.error : 'Failed to sync configuration. Please try again.';
|
||||
messageEl.html( '<p>' + errorMsg + '</p>' )
|
||||
.addClass( 'notice notice-error' )
|
||||
.fadeIn( 'fast' );
|
||||
}
|
||||
} ).fail( function( jqXHR, textStatus, errorThrown ) {
|
||||
// show error message
|
||||
messageEl.html( '<p>An error occurred while syncing configuration. Please try again.</p>' )
|
||||
.addClass( 'notice notice-error' )
|
||||
.fadeIn( 'fast' );
|
||||
} ).always( function() {
|
||||
// re-enable button and hide spinner
|
||||
button.prop( 'disabled', false );
|
||||
spinner.removeClass( 'is-active' );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
1
wp-content/plugins/cookie-notice/js/admin.min.js
vendored
Normal file
1
wp-content/plugins/cookie-notice/js/admin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
475
wp-content/plugins/cookie-notice/js/front-welcome.js
Normal file
475
wp-content/plugins/cookie-notice/js/front-welcome.js
Normal file
@@ -0,0 +1,475 @@
|
||||
( function ( $ ) {
|
||||
|
||||
// ready event
|
||||
$( function () {
|
||||
var huObject = null;
|
||||
var cnHiddenElements = {};
|
||||
|
||||
// listen for the load
|
||||
document.addEventListener( 'load.hu', function ( e ) {
|
||||
// get valid hu object
|
||||
for ( const object of ['__hu', 'hu'] ) {
|
||||
// check global variable
|
||||
if ( typeof window[object] !== 'undefined' && window[object].hasOwnProperty( 'earlyInit' ) && typeof window[object].earlyInit === 'function' ) {
|
||||
huObject = window[object];
|
||||
// no need to check again
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// set widget text strings
|
||||
huObject.setTexts( cnFrontWelcome.textStrings );
|
||||
} );
|
||||
|
||||
// listen for the destroy
|
||||
document.addEventListener( 'destroy.hu', function ( e ) {
|
||||
var customOptions = {};
|
||||
|
||||
var revoke_option = $( parent.document ).find( 'input[name="cn_revoke_consent"]' );
|
||||
|
||||
if ( revoke_option.length > 0 ) {
|
||||
var value = $( revoke_option[0] ).is( ':checked' );
|
||||
|
||||
if ( value === false ) {
|
||||
// reload with a delay
|
||||
setTimeout(
|
||||
function () {
|
||||
huObject.reload();
|
||||
}, 2000
|
||||
);
|
||||
}
|
||||
$.extend( customOptions.config, {revokeConsent: value} );
|
||||
};
|
||||
|
||||
// set widget options
|
||||
huObject.setOptions( customOptions );
|
||||
} );
|
||||
|
||||
// listen for the reload
|
||||
document.addEventListener( 'reload.hu', function ( e ) {
|
||||
var container = $( '#hu' );
|
||||
var customOptions = {config: {
|
||||
dontSellLink: true,
|
||||
privacyPolicyLink: true
|
||||
}};
|
||||
|
||||
// loop through checkbox options
|
||||
var checkboxFields = {
|
||||
onScroll: $( parent.document ).find( 'input[name="cn_on_scroll"]' ),
|
||||
onClick: $( parent.document ).find( 'input[name="cn_on_click"]' ),
|
||||
uiBlocking: $( parent.document ).find( 'input[name="cn_ui_blocking"]' ),
|
||||
revokeConsent: $( parent.document ).find( 'input[name="cn_revoke_consent"]' )
|
||||
};
|
||||
|
||||
$.each( checkboxFields, function ( key, items ) {
|
||||
var value = false;
|
||||
|
||||
if ( items.length > 0 ) {
|
||||
value = $( items[0] ).is( ':checked' );
|
||||
}
|
||||
|
||||
$.extend( customOptions.config, {[key]: value} );
|
||||
} );
|
||||
|
||||
// set widget options
|
||||
huObject.setOptions( customOptions );
|
||||
} );
|
||||
|
||||
// listen for the display
|
||||
document.addEventListener( 'display.hu', function ( e ) {
|
||||
var val = [];
|
||||
var container = $( '#hu' );
|
||||
var customOptions = {config: {
|
||||
// make it empty
|
||||
}};
|
||||
|
||||
$( parent.document ).find( 'input[name="cn_laws"]:checked' ).each( function () {
|
||||
val.push( $( this ).val() );
|
||||
} );
|
||||
|
||||
if ( $.inArray( 'ccpa', val ) !== - 1 || $.inArray( 'otherus', val ) !== - 1 ) {
|
||||
var htmlElement = $( $( container ).find( '#hu-cookies-notice-dontsell-btn' ).parent() );
|
||||
|
||||
if ( htmlElement.length === 0 ) {
|
||||
$( '#hu-policy-links' ).append( cnHiddenElements.ccpa );
|
||||
|
||||
delete cnHiddenElements.ccpa;
|
||||
}
|
||||
|
||||
$.extend( customOptions.config, {dontSellLink: true} );
|
||||
} else {
|
||||
var htmlElement = $( $( container ).find( '#hu-cookies-notice-dontsell-btn' ).parent() );
|
||||
|
||||
// add to hidden elements
|
||||
if ( htmlElement ) {
|
||||
cnHiddenElements['ccpa'] = htmlElement;
|
||||
|
||||
// remove el
|
||||
$( htmlElement ).remove();
|
||||
}
|
||||
|
||||
$.extend( customOptions.config, {dontSellLink: false} );
|
||||
}
|
||||
|
||||
// loop through checkbox options
|
||||
var checkboxFields = {
|
||||
onScroll: $( parent.document ).find( 'input[name="cn_on_scroll"]' ),
|
||||
onClick: $( parent.document ).find( 'input[name="cn_on_click"]' ),
|
||||
uiBlocking: $( parent.document ).find( 'input[name="cn_ui_blocking"]' ),
|
||||
revokeConsent: $( parent.document ).find( 'input[name="cn_revoke_consent"]' )
|
||||
};
|
||||
|
||||
$.each( checkboxFields, function ( key, items ) {
|
||||
var value = false;
|
||||
|
||||
if ( items.length > 0 ) {
|
||||
value = $( items[0] ).is( ':checked' );
|
||||
}
|
||||
|
||||
$.extend( customOptions.config, {[key]: value} );
|
||||
} );
|
||||
|
||||
// set widget options
|
||||
huObject.setOptions( customOptions );
|
||||
} );
|
||||
|
||||
// listen for the parent
|
||||
window.addEventListener( 'message', function ( event ) {
|
||||
var iframe = $( parent.document ).find( '#cn_iframe_id' );
|
||||
var form = $( parent.document ).find( '#cn-form-configure' );
|
||||
|
||||
// add spinner
|
||||
$( iframe ).closest( '.has-loader' ).addClass( 'cn-loading' ).append( '<span class="cn-spinner"></span>' );
|
||||
|
||||
// lock options
|
||||
$( form ).addClass( 'cn-form-disabled' );
|
||||
|
||||
// emit loader
|
||||
window.setTimeout( function () {
|
||||
if ( typeof event.data == 'object' ) {
|
||||
var container = $( '#hu' );
|
||||
var option = event.data.call;
|
||||
var customOptions = {};
|
||||
var customTexts = {};
|
||||
var reload = false;
|
||||
|
||||
switch ( option ) {
|
||||
case 'position':
|
||||
$( container ).removeClass( 'hu-position-bottom hu-position-top hu-position-left hu-position-right hu-position-center' );
|
||||
$( container ).addClass( 'hu-position-' + event.data.value );
|
||||
|
||||
customOptions = {design: {position: event.data.value}}
|
||||
break;
|
||||
|
||||
case 'naming':
|
||||
var level1 = $( '.hu-cookies-notice-consent-choices-1' );
|
||||
var level2 = $( '.hu-cookies-notice-consent-choices-2' );
|
||||
var level3 = $( '.hu-cookies-notice-consent-choices-3' );
|
||||
var text1 = cnFrontWelcome.levelNames[event.data.value][1];
|
||||
var text2 = cnFrontWelcome.levelNames[event.data.value][2];
|
||||
var text3 = cnFrontWelcome.levelNames[event.data.value][3];
|
||||
|
||||
// apply text to dom elements
|
||||
$( level1 ).find( '.hu-toggle-label' ).text( text1 );
|
||||
$( level2 ).find( '.hu-toggle-label' ).text( text2 );
|
||||
$( level3 ).find( '.hu-toggle-label' ).text( text3 );
|
||||
|
||||
// apply text to text strings
|
||||
customTexts = {
|
||||
levelNameText_1: text1,
|
||||
levelNameText_2: text2,
|
||||
levelNameText_3: text3
|
||||
}
|
||||
break;
|
||||
|
||||
case 'laws':
|
||||
customOptions.config = {}
|
||||
|
||||
if ( $.inArray( 'ccpa', event.data.value ) !== - 1 || $.inArray( 'otherus', event.data.value ) !== - 1 ) {
|
||||
var htmlElement = $( container ).find( '#hu-cookies-notice-dontsell-btn' ).parent();
|
||||
|
||||
if ( htmlElement.length === 0 ) {
|
||||
$( '#hu-policy-links' ).append( cnHiddenElements.ccpa );
|
||||
|
||||
delete cnHiddenElements.ccpa;
|
||||
}
|
||||
|
||||
$.extend( customOptions.config, {dontSellLink: true} );
|
||||
} else {
|
||||
var htmlElement = $( container ).find( '#hu-cookies-notice-dontsell-btn' ).parent();
|
||||
|
||||
// add to hidden elements
|
||||
if ( htmlElement && ! cnHiddenElements.hasOwnProperty( 'ccpa' ) ) {
|
||||
cnHiddenElements['ccpa'] = htmlElement;
|
||||
|
||||
// remove el
|
||||
$( htmlElement ).remove();
|
||||
}
|
||||
|
||||
$.extend( customOptions.config, {dontSellLink: false} );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'on_scroll':
|
||||
var value = event.data.value === true;
|
||||
reload = true;
|
||||
|
||||
$.extend( customOptions.config, {onScroll: value} );
|
||||
break;
|
||||
|
||||
case 'on_click':
|
||||
var value = event.data.value === true;
|
||||
reload = true;
|
||||
|
||||
$.extend( customOptions.config, {onClick: value} );
|
||||
break;
|
||||
|
||||
case 'ui_blocking':
|
||||
var value = event.data.value === true;
|
||||
reload = true;
|
||||
|
||||
$.extend( customOptions.config, {uiBlocking: value} );
|
||||
break;
|
||||
|
||||
case 'revoke_consent':
|
||||
var value = event.data.value === true;
|
||||
reload = true;
|
||||
|
||||
$.extend( customOptions.config, {revokeConsent: value} );
|
||||
break;
|
||||
|
||||
case 'color_primary':
|
||||
var iframeContents = $( iframe ).contents()[0];
|
||||
|
||||
iframeContents.documentElement.style.setProperty( '--hu-primaryColor', event.data.value );
|
||||
customOptions = {design: {primaryColor: event.data.value}}
|
||||
break;
|
||||
|
||||
case 'color_background':
|
||||
var iframeContents = $( iframe ).contents()[0];
|
||||
|
||||
iframeContents.documentElement.style.setProperty( '--hu-bannerColor', event.data.value );
|
||||
customOptions = {design: {bannerColor: event.data.value}}
|
||||
break;
|
||||
|
||||
case 'color_border':
|
||||
var iframeContents = $( iframe ).contents()[0];
|
||||
|
||||
iframeContents.documentElement.style.setProperty( '--hu-borderColor', event.data.value );
|
||||
customOptions = {design: {borderColor: event.data.value}}
|
||||
break;
|
||||
|
||||
case 'color_text':
|
||||
var iframeContents = $( iframe ).contents()[0];
|
||||
|
||||
iframeContents.documentElement.style.setProperty( '--hu-textColor', event.data.value );
|
||||
customOptions = {design: {textColor: event.data.value}}
|
||||
break;
|
||||
|
||||
case 'color_heading':
|
||||
var iframeContents = $( iframe ).contents()[0];
|
||||
|
||||
iframeContents.documentElement.style.setProperty( '--hu-headingColor', event.data.value );
|
||||
customOptions = {design: {headingColor: event.data.value}}
|
||||
break;
|
||||
|
||||
case 'color_button_text':
|
||||
var iframeContents = $( iframe ).contents()[0];
|
||||
|
||||
iframeContents.documentElement.style.setProperty( '--hu-btnTextColor', event.data.value );
|
||||
customOptions = {design: {btnTextColor: event.data.value}}
|
||||
break;
|
||||
}
|
||||
|
||||
// set widget options
|
||||
huObject.setOptions( customOptions );
|
||||
|
||||
// set widget texts
|
||||
huObject.setTexts( customTexts );
|
||||
|
||||
// reload if needed
|
||||
if ( reload ) {
|
||||
huObject.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// remove spinner
|
||||
$( iframe ).closest( '.has-loader' ).find( '.cn-spinner' ).remove();
|
||||
$( iframe ).closest( '.has-loader' ).removeClass( 'cn-loading' );
|
||||
|
||||
// unlock options
|
||||
$( form ).removeClass( 'cn-form-disabled' );
|
||||
}, 500 );
|
||||
}, false );
|
||||
|
||||
// is it iframe?
|
||||
if ( document !== parent.document && typeof cnFrontWelcome !== 'undefined' && cnFrontWelcome.previewMode ) {
|
||||
var iframe = $( parent.document ).find( '#cn_iframe_id' );
|
||||
|
||||
// inject links into initial document
|
||||
$( document.body ).find( 'a[href], area[href]' ).each( function () {
|
||||
cnAddPreviewModeToLink( this, iframe );
|
||||
} );
|
||||
|
||||
// inject links into initial document
|
||||
$( document.body ).find( 'form' ).each( function () {
|
||||
cnAddPreviewModeToForm( this, iframe );
|
||||
} );
|
||||
|
||||
// inject links for new elements added to the page
|
||||
if ( typeof MutationObserver !== 'undefined' ) {
|
||||
var observer = new MutationObserver( function ( mutations ) {
|
||||
_.each( mutations, function ( mutation ) {
|
||||
$( mutation.target ).find( 'a[href], area[href]' ).each( function () {
|
||||
cnAddPreviewModeToLink( this, iframe );
|
||||
} );
|
||||
|
||||
$( mutation.target ).find( 'form' ).each( function () {
|
||||
cnAddPreviewModeToForm( this, iframe );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
observer.observe( document.documentElement, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
} );
|
||||
} else {
|
||||
// If mutation observers aren't available, fallback to just-in-time injection.
|
||||
$( document.documentElement ).on( 'click focus mouseover', 'a[href], area[href]', function () {
|
||||
cnAddPreviewModeToLink( this, iframe );
|
||||
} );
|
||||
}
|
||||
|
||||
// remove spinner
|
||||
$( iframe ).closest( '.has-loader' ).find( '.cn-spinner' ).remove();
|
||||
$( iframe ).closest( '.has-loader' ).removeClass( 'cn-loading' );
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Inject preview mode parameter into specific links on the frontend.
|
||||
*/
|
||||
function cnAddPreviewModeToLink( element, iframe ) {
|
||||
var params, $element = $( element );
|
||||
|
||||
// skip elements with no href attribute
|
||||
if ( ! element.hasAttribute( 'href' ) )
|
||||
return;
|
||||
|
||||
// skip links in admin bar
|
||||
if ( $element.closest( '#wpadminbar' ).length )
|
||||
return;
|
||||
|
||||
// ignore links with href="#", href="#id", or non-HTTP protocols (e.g. javascript: and mailto:)
|
||||
if ( '#' === $element.attr( 'href' ).substr( 0, 1 ) || ! /^https?:$/.test( element.protocol ) )
|
||||
return;
|
||||
|
||||
// make sure links in preview use HTTPS if parent frame uses HTTPS.
|
||||
// if ( api.settings.channel && 'https' === api.preview.scheme.get() && 'http:' === element.protocol && -1 !== api.settings.url.allowedHosts.indexOf( element.host ) )
|
||||
// element.protocol = 'https:';
|
||||
|
||||
// ignore links with special class
|
||||
if ( $element.hasClass( 'wp-playlist-caption' ) )
|
||||
return;
|
||||
|
||||
// check special links
|
||||
if ( ! cnIsLinkPreviewable( element ) )
|
||||
return;
|
||||
|
||||
$( element ).on( 'click', function () {
|
||||
$( iframe ).closest( '.has-loader' ).addClass( 'cn-loading' );
|
||||
} );
|
||||
|
||||
// parse query string
|
||||
params = cnParseQueryString( element.search.substring( 1 ) );
|
||||
|
||||
// set preview mode
|
||||
params.cn_preview_mode = 1;
|
||||
|
||||
element.search = $.param( params );
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject preview mode parameter into specific forms on the frontend.
|
||||
*/
|
||||
function cnAddPreviewModeToForm( element, iframe ) {
|
||||
var input = document.createElement( 'input' );
|
||||
|
||||
input.setAttribute( 'type', 'hidden' );
|
||||
input.setAttribute( 'name', 'cn_preview_mode' );
|
||||
input.setAttribute( 'value', 1 );
|
||||
|
||||
element.appendChild( input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse query string.
|
||||
*/
|
||||
function cnParseQueryString( string ) {
|
||||
var params = {};
|
||||
|
||||
_.each( string.split( '&' ), function ( pair ) {
|
||||
var parts, key, value;
|
||||
|
||||
parts = pair.split( '=', 2 );
|
||||
|
||||
if ( ! parts[0] )
|
||||
return;
|
||||
|
||||
key = decodeURIComponent( parts[0].replace( /\+/g, ' ' ) );
|
||||
key = key.replace( / /g, '_' );
|
||||
|
||||
if ( _.isUndefined( parts[1] ) )
|
||||
value = null;
|
||||
else
|
||||
value = decodeURIComponent( parts[1].replace( /\+/g, ' ' ) );
|
||||
|
||||
params[ key ] = value;
|
||||
} );
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the supplied link is previewable.
|
||||
*/
|
||||
function cnIsLinkPreviewable( element ) {
|
||||
var matchesAllowedUrl, parsedAllowedUrl, elementHost;
|
||||
|
||||
if ( 'javascript:' === element.protocol )
|
||||
return true;
|
||||
|
||||
// only web urls can be previewed
|
||||
if ( element.protocol !== 'https:' && element.protocol !== 'http:' )
|
||||
return false;
|
||||
|
||||
elementHost = element.host.replace( /:(80|443)$/, '' );
|
||||
parsedAllowedUrl = document.createElement( 'a' );
|
||||
matchesAllowedUrl = ! _.isUndefined( _.find( cnFrontWelcome.allowedURLs, function ( allowedUrl ) {
|
||||
parsedAllowedUrl.href = allowedUrl;
|
||||
|
||||
return parsedAllowedUrl.protocol === element.protocol && parsedAllowedUrl.host.replace( /:(80|443)$/, '' ) === elementHost && 0 === element.pathname.indexOf( parsedAllowedUrl.pathname.replace( /\/$/, '' ) );
|
||||
} ) );
|
||||
|
||||
if ( ! matchesAllowedUrl )
|
||||
return false;
|
||||
|
||||
// skip wp login and signup pages
|
||||
if ( /\/wp-(login|signup)\.php$/.test( element.pathname ) )
|
||||
return false;
|
||||
|
||||
// allow links to admin ajax as faux frontend URLs
|
||||
if ( /\/wp-admin\/admin-ajax\.php$/.test( element.pathname ) )
|
||||
return false;
|
||||
|
||||
// disallow links to admin, includes, and content
|
||||
if ( /\/wp-(admin|includes|content)(\/|$)/.test( element.pathname ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
;
|
||||
|
||||
} )( jQuery );
|
||||
528
wp-content/plugins/cookie-notice/js/front.js
Normal file
528
wp-content/plugins/cookie-notice/js/front.js
Normal file
@@ -0,0 +1,528 @@
|
||||
// CustomEvent polyfil for IE support
|
||||
( function() {
|
||||
|
||||
if ( typeof window.CustomEvent === "function" )
|
||||
return false;
|
||||
|
||||
function CustomEvent( event, params ) {
|
||||
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
||||
|
||||
var evt = document.createEvent( 'CustomEvent' );
|
||||
|
||||
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
|
||||
|
||||
return evt;
|
||||
}
|
||||
|
||||
CustomEvent.prototype = window.Event.prototype;
|
||||
|
||||
window.CustomEvent = CustomEvent;
|
||||
} )();
|
||||
|
||||
// ClassList polyfil for IE/Safari support
|
||||
( function() {
|
||||
var regExp = function ( name ) {
|
||||
return new RegExp( '(^| )' + name + '( |$)' );
|
||||
};
|
||||
|
||||
var forEach = function ( list, fn, scope ) {
|
||||
for ( var i = 0; i < list.length; i++ ) {
|
||||
fn.call( scope, list[i] );
|
||||
}
|
||||
};
|
||||
|
||||
function ClassList( element ) {
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
ClassList.prototype = {
|
||||
add: function() {
|
||||
forEach( arguments, function ( name ) {
|
||||
if ( !this.contains( name ) ) {
|
||||
this.element.className += this.element.className.length > 0 ? ' ' + name : name;
|
||||
}
|
||||
}, this );
|
||||
},
|
||||
remove: function() {
|
||||
forEach( arguments, function ( name ) {
|
||||
this.element.className =
|
||||
this.element.className.replace( regExp( name ), '' );
|
||||
}, this );
|
||||
},
|
||||
toggle: function ( name ) {
|
||||
return this.contains( name )
|
||||
? ( this.remove( name ), false ) : ( this.add( name ), true );
|
||||
},
|
||||
contains: function ( name ) {
|
||||
return regExp( name ).test( this.element.className );
|
||||
},
|
||||
// bonus..
|
||||
replace: function ( oldName, newName ) {
|
||||
this.remove( oldName ), this.add( newName );
|
||||
}
|
||||
};
|
||||
|
||||
// IE8/9, Safari
|
||||
if ( !( 'classList' in Element.prototype ) ) {
|
||||
Object.defineProperty( Element.prototype, 'classList', {
|
||||
get: function() {
|
||||
return new ClassList( this );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
if ( window.DOMTokenList && DOMTokenList.prototype.replace == null )
|
||||
DOMTokenList.prototype.replace = ClassList.prototype.replace;
|
||||
} )();
|
||||
|
||||
// cookieNotice
|
||||
( function ( window, document, undefined ) {
|
||||
|
||||
var cookieNotice = new function() {
|
||||
// cookie status
|
||||
this.cookiesAccepted = null;
|
||||
|
||||
// notice container
|
||||
this.noticeContainer = null;
|
||||
|
||||
// set cookie value
|
||||
this.setStatus = function ( cookieValue ) {
|
||||
var _this = this;
|
||||
var cookieDomain = '';
|
||||
var cookiePath = '';
|
||||
var date = new Date();
|
||||
var laterDate = new Date();
|
||||
|
||||
// remove listening to scroll event
|
||||
if ( cnArgs.onScroll )
|
||||
window.removeEventListener( 'scroll', this.handleScroll );
|
||||
|
||||
// set cookie type and expiry time in seconds
|
||||
if ( cookieValue === 'accept' ) {
|
||||
cookieValue = 'true';
|
||||
laterDate.setTime( parseInt( date.getTime() ) + parseInt( cnArgs.cookieTime ) * 1000 );
|
||||
} else {
|
||||
cookieValue = 'false';
|
||||
laterDate.setTime( parseInt( date.getTime() ) + parseInt( cnArgs.cookieTimeRejected ) * 1000 );
|
||||
}
|
||||
|
||||
if ( cnArgs.globalCookie )
|
||||
cookieDomain = this.getDomain( document.location.hostname );
|
||||
|
||||
// get domain path in localhost
|
||||
if ( document.location.hostname === 'localhost' )
|
||||
cookiePath = document.location.pathname.split( '/' )[1];
|
||||
|
||||
var secureValue = '';
|
||||
|
||||
if ( document.location.protocol === 'https:' )
|
||||
secureValue = ';secure';
|
||||
|
||||
// set cookie
|
||||
document.cookie = cnArgs.cookieName + '=' + cookieValue + ';expires=' + laterDate.toUTCString() + ';path=/' + cookiePath + ';domain=' + cookieDomain + secureValue;
|
||||
|
||||
// update global status
|
||||
this.cookiesAccepted = cookieValue === 'true';
|
||||
|
||||
// trigger custom event
|
||||
var event = new CustomEvent(
|
||||
'setCookieNotice',
|
||||
{
|
||||
detail: {
|
||||
value: cookieValue,
|
||||
time: date,
|
||||
expires: laterDate,
|
||||
data: cnArgs
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
document.dispatchEvent( event );
|
||||
|
||||
this.setBodyClass( [ 'cookies-set', cookieValue === 'true' ? 'cookies-accepted' : 'cookies-refused' ] );
|
||||
|
||||
this.hideCookieNotice();
|
||||
|
||||
// show revoke notice if enabled
|
||||
if ( cnArgs.revokeCookiesOpt === 'automatic' ) {
|
||||
// show cookie notice after the revoke is hidden
|
||||
this.noticeContainer.addEventListener( 'animationend', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'animationend', handler );
|
||||
_this.showRevokeNotice();
|
||||
} );
|
||||
this.noticeContainer.addEventListener( 'webkitAnimationEnd', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'webkitAnimationEnd', handler );
|
||||
_this.showRevokeNotice();
|
||||
} );
|
||||
}
|
||||
|
||||
// redirect?
|
||||
if ( cnArgs.redirection && ( ( cookieValue === 'true' && this.cookiesAccepted === null ) || ( cookieValue !== this.cookiesAccepted && this.cookiesAccepted !== null ) ) ) {
|
||||
var url = window.location.protocol + '//',
|
||||
hostname = window.location.host + '/' + window.location.pathname;
|
||||
|
||||
// is cache enabled?
|
||||
if ( cnArgs.cache ) {
|
||||
url = url + hostname.replace( '//', '/' ) + ( window.location.search === '' ? '?' : window.location.search + '&' ) + 'cn-reloaded=1' + window.location.hash;
|
||||
|
||||
window.location.href = url;
|
||||
} else {
|
||||
url = url + hostname.replace( '//', '/' ) + window.location.search + window.location.hash;
|
||||
|
||||
window.location.reload( true );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// get domain
|
||||
this.getDomain = function( url ) {
|
||||
var regex = new RegExp( /https?:\/\// );
|
||||
|
||||
if ( ! regex.test( url ) )
|
||||
url = 'http://' + url;
|
||||
|
||||
var parts = new URL( url ).hostname.split( '.' );
|
||||
|
||||
return parts.slice( 0 ).slice( -( parts.length === 4 ? 3 : 2 ) ).join( '.' );
|
||||
}
|
||||
|
||||
// get cookie value
|
||||
this.getStatus = function ( bool ) {
|
||||
var value = "; " + document.cookie,
|
||||
parts = value.split( '; cookie_notice_accepted=' );
|
||||
|
||||
if ( parts.length === 2 ) {
|
||||
var val = parts.pop().split( ';' ).shift();
|
||||
|
||||
if ( bool )
|
||||
return val === 'true';
|
||||
else
|
||||
return val;
|
||||
} else
|
||||
return null;
|
||||
};
|
||||
|
||||
// display cookie notice
|
||||
this.showCookieNotice = function() {
|
||||
var _this = this;
|
||||
|
||||
// trigger custom event
|
||||
var event = new CustomEvent(
|
||||
'showCookieNotice',
|
||||
{
|
||||
detail: {
|
||||
data: cnArgs
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
document.dispatchEvent( event );
|
||||
|
||||
this.noticeContainer.classList.remove( 'cookie-notice-hidden' );
|
||||
this.noticeContainer.classList.add( 'cn-animated' );
|
||||
this.noticeContainer.classList.add( 'cookie-notice-visible' );
|
||||
|
||||
// detect animation
|
||||
this.noticeContainer.addEventListener( 'animationend', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'animationend', handler );
|
||||
_this.noticeContainer.classList.remove( 'cn-animated' );
|
||||
} );
|
||||
this.noticeContainer.addEventListener( 'webkitAnimationEnd', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'webkitAnimationEnd', handler );
|
||||
_this.noticeContainer.classList.remove( 'cn-animated' );
|
||||
} );
|
||||
};
|
||||
|
||||
// hide cookie notice
|
||||
this.hideCookieNotice = function() {
|
||||
var _this = this;
|
||||
|
||||
// trigger custom event
|
||||
var event = new CustomEvent(
|
||||
'hideCookieNotice',
|
||||
{
|
||||
detail: {
|
||||
data: cnArgs
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
document.dispatchEvent( event );
|
||||
|
||||
this.noticeContainer.classList.add( 'cn-animated' );
|
||||
this.noticeContainer.classList.remove( 'cookie-notice-visible' );
|
||||
|
||||
// detect animation
|
||||
this.noticeContainer.addEventListener( 'animationend', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'animationend', handler );
|
||||
_this.noticeContainer.classList.remove( 'cn-animated' );
|
||||
_this.noticeContainer.classList.add( 'cookie-notice-hidden' );
|
||||
} );
|
||||
this.noticeContainer.addEventListener( 'webkitAnimationEnd', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'webkitAnimationEnd', handler );
|
||||
_this.noticeContainer.classList.remove( 'cn-animated' );
|
||||
_this.noticeContainer.classList.add( 'cookie-notice-hidden' );
|
||||
} );
|
||||
};
|
||||
|
||||
// display revoke notice
|
||||
this.showRevokeNotice = function() {
|
||||
var _this = this;
|
||||
|
||||
// trigger custom event
|
||||
var event = new CustomEvent(
|
||||
'showRevokeNotice',
|
||||
{
|
||||
detail: {
|
||||
data: cnArgs
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
document.dispatchEvent( event );
|
||||
|
||||
this.noticeContainer.classList.remove( 'cookie-revoke-hidden' );
|
||||
this.noticeContainer.classList.add( 'cn-animated' );
|
||||
this.noticeContainer.classList.add( 'cookie-revoke-visible' );
|
||||
|
||||
// detect animation
|
||||
this.noticeContainer.addEventListener( 'animationend', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'animationend', handler );
|
||||
_this.noticeContainer.classList.remove( 'cn-animated' );
|
||||
} );
|
||||
this.noticeContainer.addEventListener( 'webkitAnimationEnd', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'webkitAnimationEnd', handler );
|
||||
_this.noticeContainer.classList.remove( 'cn-animated' );
|
||||
} );
|
||||
};
|
||||
|
||||
// hide revoke notice
|
||||
this.hideRevokeNotice = function() {
|
||||
var _this = this;
|
||||
|
||||
// trigger custom event
|
||||
var event = new CustomEvent(
|
||||
'hideRevokeNotice',
|
||||
{
|
||||
detail: {
|
||||
data: cnArgs
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
document.dispatchEvent( event );
|
||||
|
||||
this.noticeContainer.classList.add( 'cn-animated' );
|
||||
this.noticeContainer.classList.remove( 'cookie-revoke-visible' );
|
||||
|
||||
// detect animation
|
||||
this.noticeContainer.addEventListener( 'animationend', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'animationend', handler );
|
||||
_this.noticeContainer.classList.remove( 'cn-animated' );
|
||||
_this.noticeContainer.classList.add( 'cookie-revoke-hidden' );
|
||||
} );
|
||||
this.noticeContainer.addEventListener( 'webkitAnimationEnd', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'webkitAnimationEnd', handler );
|
||||
_this.noticeContainer.classList.remove( 'cn-animated' );
|
||||
_this.noticeContainer.classList.add( 'cookie-revoke-hidden' );
|
||||
} );
|
||||
};
|
||||
|
||||
// change body classes
|
||||
this.setBodyClass = function ( classes ) {
|
||||
// remove body classes
|
||||
document.body.classList.remove( 'cookies-revoke' );
|
||||
document.body.classList.remove( 'cookies-accepted' );
|
||||
document.body.classList.remove( 'cookies-refused' );
|
||||
document.body.classList.remove( 'cookies-set' );
|
||||
document.body.classList.remove( 'cookies-not-set' );
|
||||
|
||||
// add body classes
|
||||
for ( var i = 0; i < classes.length; i++ ) {
|
||||
document.body.classList.add( classes[i] );
|
||||
}
|
||||
};
|
||||
|
||||
// handle mouse scrolling
|
||||
this.handleScroll = function() {
|
||||
var scrollTop = window.pageYOffset || ( document.documentElement || document.body.parentNode || document.body ).scrollTop
|
||||
|
||||
// accept cookie
|
||||
if ( scrollTop > parseInt( cnArgs.onScrollOffset ) )
|
||||
this.setStatus( 'accept' );
|
||||
};
|
||||
|
||||
// cross browser compatible closest function
|
||||
this.getClosest = function ( elem, selector ) {
|
||||
// element.matches() polyfill
|
||||
if ( !Element.prototype.matches ) {
|
||||
Element.prototype.matches =
|
||||
Element.prototype.matchesSelector ||
|
||||
Element.prototype.mozMatchesSelector ||
|
||||
Element.prototype.msMatchesSelector ||
|
||||
Element.prototype.oMatchesSelector ||
|
||||
Element.prototype.webkitMatchesSelector ||
|
||||
function ( s ) {
|
||||
var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ),
|
||||
i = matches.length;
|
||||
while ( --i >= 0 && matches.item( i ) !== this ) {
|
||||
}
|
||||
return i > -1;
|
||||
};
|
||||
}
|
||||
|
||||
// get the closest matching element
|
||||
for ( ; elem && elem !== document; elem = elem.parentNode ) {
|
||||
if ( elem.matches( selector ) )
|
||||
return elem;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
// check if displaye in an iframe
|
||||
this.inIframe = function() {
|
||||
try {
|
||||
return window.self !== window.top;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// initialize
|
||||
this.init = function() {
|
||||
var _this = this;
|
||||
|
||||
// bail if in iframe
|
||||
if ( this.inIframe() === true )
|
||||
return;
|
||||
|
||||
this.cookiesAccepted = this.getStatus( true );
|
||||
this.noticeContainer = document.getElementById( 'cookie-notice' );
|
||||
|
||||
// no container?
|
||||
if ( ! this.noticeContainer )
|
||||
return;
|
||||
|
||||
var cookieButtons = document.getElementsByClassName( 'cn-set-cookie' ),
|
||||
revokeButtons = document.getElementsByClassName( 'cn-revoke-cookie' ),
|
||||
linkButton = document.getElementById( 'cn-more-info' ),
|
||||
closeButton = document.getElementById( 'cn-close-notice' );
|
||||
|
||||
// add effect class
|
||||
this.noticeContainer.classList.add( 'cn-effect-' + cnArgs.hideEffect );
|
||||
|
||||
// check cookies status
|
||||
if ( this.cookiesAccepted === null ) {
|
||||
// handle on scroll
|
||||
if ( cnArgs.onScroll )
|
||||
window.addEventListener( 'scroll', function ( e ) {
|
||||
_this.handleScroll();
|
||||
} );
|
||||
|
||||
// handle on click
|
||||
if ( cnArgs.onClick )
|
||||
window.addEventListener( 'click', function ( e ) {
|
||||
var outerContainer = _this.getClosest( e.target, '#cookie-notice' );
|
||||
|
||||
// accept notice if clicked element is not inside the container
|
||||
if ( outerContainer === null )
|
||||
_this.setStatus( 'accept' );
|
||||
}, true );
|
||||
|
||||
this.setBodyClass( [ 'cookies-not-set' ] );
|
||||
|
||||
// show cookie notice
|
||||
this.showCookieNotice();
|
||||
} else {
|
||||
this.setBodyClass( [ 'cookies-set', this.cookiesAccepted === true ? 'cookies-accepted' : 'cookies-refused' ] );
|
||||
|
||||
// show revoke notice if enabled
|
||||
if ( cnArgs.revokeCookies && cnArgs.revokeCookiesOpt === 'automatic' )
|
||||
this.showRevokeNotice();
|
||||
}
|
||||
|
||||
// handle cookie buttons click
|
||||
for ( var i = 0; i < cookieButtons.length; i++ ) {
|
||||
cookieButtons[i].addEventListener( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
// Chrome double click event fix
|
||||
e.stopPropagation();
|
||||
|
||||
_this.setStatus( this.dataset.cookieSet );
|
||||
} );
|
||||
}
|
||||
|
||||
// handle link button
|
||||
if ( linkButton !== null ) {
|
||||
linkButton.addEventListener( 'click', function ( e ) {
|
||||
var linkUrl = this.dataset.linkUrl || this.getAttribute( 'href' );
|
||||
var linkTarget = this.dataset.linkTarget || this.getAttribute( 'target' ) || '_self';
|
||||
|
||||
// only intercept when we have a destination
|
||||
if ( ! linkUrl )
|
||||
return;
|
||||
|
||||
e.preventDefault();
|
||||
// Chrome double click event fix
|
||||
e.stopPropagation();
|
||||
|
||||
window.open( linkUrl, linkTarget );
|
||||
} );
|
||||
}
|
||||
|
||||
// handle close button
|
||||
if ( closeButton !== null ) {
|
||||
closeButton.addEventListener( 'keydown', function ( e ) {
|
||||
if ( e.key === 'Enter' || e.key === ' ' || e.key === 'Spacebar' || e.keyCode === 13 || e.keyCode === 32 ) {
|
||||
e.preventDefault();
|
||||
// Chrome double click event fix
|
||||
e.stopPropagation();
|
||||
|
||||
_this.setStatus( 'reject' );
|
||||
}
|
||||
} );
|
||||
|
||||
closeButton.addEventListener( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
// Chrome double click event fix
|
||||
e.stopPropagation();
|
||||
|
||||
_this.setStatus( 'reject' );
|
||||
} );
|
||||
}
|
||||
|
||||
// handle revoke buttons click
|
||||
for ( var i = 0; i < revokeButtons.length; i++ ) {
|
||||
revokeButtons[i].addEventListener( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// hide revoke notice
|
||||
if ( _this.noticeContainer.classList.contains( 'cookie-revoke-visible' ) ) {
|
||||
_this.hideRevokeNotice();
|
||||
|
||||
// show cookie notice after the revoke is hidden
|
||||
_this.noticeContainer.addEventListener( 'animationend', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'animationend', handler );
|
||||
_this.showCookieNotice();
|
||||
} );
|
||||
_this.noticeContainer.addEventListener( 'webkitAnimationEnd', function handler() {
|
||||
_this.noticeContainer.removeEventListener( 'webkitAnimationEnd', handler );
|
||||
_this.showCookieNotice();
|
||||
} );
|
||||
// show cookie notice
|
||||
} else if ( _this.noticeContainer.classList.contains( 'cookie-notice-hidden' ) && _this.noticeContainer.classList.contains( 'cookie-revoke-hidden' ) )
|
||||
_this.showCookieNotice();
|
||||
} );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// initialize plugin
|
||||
window.addEventListener( 'load', function() {
|
||||
cookieNotice.init();
|
||||
}, false );
|
||||
|
||||
} )( window, document, undefined );
|
||||
1
wp-content/plugins/cookie-notice/js/front.min.js
vendored
Normal file
1
wp-content/plugins/cookie-notice/js/front.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user