Files
avatar-privacy/public/js/wpdiscuz/src/use-gravatar.js
2023-09-01 00:37:57 -07:00

32 lines
765 B
JavaScript

/**
* Compatibility functions for the wpDiscuz plugin.
*
* This file is part of Avatar Privacy.
*
* @file This file handles the use_gravatar checkbox for wpDiscuz.
* @author Peter Putzer <github@mundschenk.at>
* @license GPL-2.0-or-later
* @since 2.2.0
*/
/**
* Resets the use_gravatar checkbox after posting a new comment in wpDiscuz.
*/
jQuery( function ( $ ) {
'use strict';
const $useGravatarCheckbox = $( '#' + avatarPrivacy.checkbox );
function resetUseGravatar() {
const useGravatar =
Cookies.get( avatarPrivacy.cookie ) !== undefined &&
'' !== Cookies.get( avatarPrivacy.cookie )
? 'checked'
: '';
$useGravatarCheckbox.prop( 'checked', useGravatar );
}
$( document ).on( 'ajaxComplete', resetUseGravatar );
} );