Skip to content

Commit

Permalink
Fix appearance of "Discard Comment" modal
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwach committed Oct 20, 2024
1 parent 082ede1 commit 7892110
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
63 changes: 37 additions & 26 deletions includes/core/assets/js/jquery.texthighlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1455,45 +1455,59 @@ CommentPress.texthighlighter.commentform = new function() {
};

/**
* Selection active handler - test for clicks outside the comment form.
* Selection active handler - test for clicks outside the Comment Form.
*
* @since 3.8
*/
this.focus_active_handler = function( event ) {

// If the event target is not the comment form container.
if ( !$(event.target).closest( '#respond' ).length ) {
// Define vars.
var wp_modal_link, wp_modal_autocomplete, wp_modal_media,
comment_form, comment;

// Check for clicks on WordPress modals.
wp_modal_link = $(event.target).closest( '.mce-panel' ).length;
wp_modal_link_options = $(event.target).closest( '#wp-link' ).length;
wp_modal_autocomplete = $(event.target).closest( '.wplink-autocomplete' ).length;
wp_modal_media = $(event.target).closest( '.media-modal' ).length;

// Bail for clicks on WordPress modals.
if ( wp_modal_link || wp_modal_link_options || wp_modal_autocomplete || wp_modal_media ) {
return;
}

// If the event target is not a comment.
if ( !$(event.target).closest( '.comment-content' ).length ) {
// Check for clicks inside the Comment Form and on other Comments.
comment_form = $(event.target).closest( '#respond' ).length;
comment = $(event.target).closest( '.comment-content' ).length;

// Do we have a current selection?
if ( me.current_selection_exists() ) {
// Bail for clicks on the Comment Form or other Comments.
if ( comment_form || comment ) {
return;
}

// Do we have any content?
if ( me.comment_content_exists() ) {
// Do we have a current selection?
if ( me.current_selection_exists() ) {

// Show modal.
me.modal();
// Do we have any content?
if ( me.comment_content_exists() ) {

// Unbind document click handler.
$(document).off( 'click', me.focus_active_handler );
// Show modal.
me.modal();

} else {
// Unbind document click handler.
$(document).off( 'click', me.focus_active_handler );

// Do modal yes.
me.modal_yes();
} else {

}
// Do modal yes.
me.modal_yes();

} else {

// Do modal yes.
me.modal_yes();
}

}
} else {

}
// Do modal yes.
me.modal_yes();

}

Expand Down Expand Up @@ -2412,6 +2426,3 @@ jQuery(document).ready(function($) {
);

}); // End document.ready()



Loading

0 comments on commit 7892110

Please sign in to comment.