Replace inline onclick obfuscation handler
This commit is contained in:
parent
40c65a89a5
commit
09ca5ebfe5
2
js/application.min.js
vendored
2
js/application.min.js
vendored
File diff suppressed because one or more lines are too long
@ -108,7 +108,7 @@ $entries = new WP_Query( $query_args );
|
||||
?></a></h3>
|
||||
|
||||
<div class="card__content _small cell-desc">
|
||||
<div class="truncate _3-3 <?php if ( ! $args['spoiler'] ) echo '_obfuscated'; ?>">
|
||||
<div class="truncate _3-3 <?php if ( ! $args['spoiler'] ) echo '_obfuscated'; ?>" data-obfuscation-target>
|
||||
<?php if ( get_option( 'fictioneer_show_authors' ) && $args['source'] ) : ?>
|
||||
<span class="card__by-author"><?php
|
||||
printf( _x( 'by %s', 'Small card: by {Author}.', 'fictioneer' ), fictioneer_get_author_node() );
|
||||
@ -127,7 +127,7 @@ $entries = new WP_Query( $query_args );
|
||||
$spoiler_note = str_repeat( _x( '· ', 'Chapter preview obfuscation character.', 'fictioneer' ), intval( strlen( $excerpt ) ) );
|
||||
?>
|
||||
<?php if ( ! $args['spoiler'] ) : ?>
|
||||
<span onclick="this.parentElement.classList.toggle('_obfuscated');" tabindex="0">
|
||||
<span data-toggle-obfuscation tabindex="0">
|
||||
<span class="obfuscated"> <?php echo $spoiler_note; ?></span>
|
||||
<span class="clean">— <?php echo $excerpt; ?></span>
|
||||
</span>
|
||||
|
@ -366,6 +366,14 @@ fcn_theBody.addEventListener('click', e => {
|
||||
if (typeof fct_spoiler === 'function') fct_spoiler(spoilerTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle obfuscation
|
||||
const obfuscationTarget = e.target.closest('[data-toggle-obfuscation]');
|
||||
|
||||
if (obfuscationTarget) {
|
||||
obfuscationTarget.closest('[data-obfuscation-target]').classList.toggle('_obfuscated');
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
// =============================================================================
|
||||
|
Loading…
x
Reference in New Issue
Block a user