Separate comment reply script
This commit is contained in:
parent
da2495e88f
commit
f808ff33cb
3 changed files with 36 additions and 17 deletions
|
@ -18,20 +18,4 @@ jQuery( function( $ ) {
|
||||||
}, 1200 );
|
}, 1200 );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
//Reply Comment-edit screen
|
|
||||||
if ( $('body').hasClass('edit-comments-php') || $('body').hasClass('index-php') ) {
|
|
||||||
//Insert Mentions into comment content on reply
|
|
||||||
$( '.comment-inline.button-link' ).on( 'click', function( event ) {
|
|
||||||
var recipients = $(this).attr('data-recipients') ? $(this).attr('data-recipients') + ' ' : '';
|
|
||||||
setTimeout(function() {
|
|
||||||
if ( recipients ){
|
|
||||||
$('#replycontent').val( recipients )
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
})
|
|
||||||
//Clear Mentions from content on cancel
|
|
||||||
$('.cancel.button').on('click', function(){
|
|
||||||
$('#replycontent').val('');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
|
|
32
assets/js/activitypub-reply.js
Normal file
32
assets/js/activitypub-reply.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
jQuery( function( $ ) {
|
||||||
|
// Reply from Comment-edit screen & Dashboard.
|
||||||
|
if ( $('body').hasClass('edit-comments-php') || $('body').hasClass('index-php') ) {
|
||||||
|
//Insert @mentions into comment content on reply
|
||||||
|
$( '.comment-inline.button-link' ).on( 'click', function( event ) {
|
||||||
|
var recipients = $(this).attr('data-recipients') ? $(this).attr('data-recipients') + ' ' : '';
|
||||||
|
setTimeout(function() {
|
||||||
|
if ( recipients ){
|
||||||
|
$('#replycontent').val( recipients )
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
})
|
||||||
|
//Clear @mentions from content on cancel
|
||||||
|
$('.cancel.button').on('click', function(){
|
||||||
|
$('#replycontent').val('');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Reply from frontend.
|
||||||
|
if ( $('body').hasClass('logged-in') && $('body').hasClass('single') ) {
|
||||||
|
//Insert @mentions into comment content on reply
|
||||||
|
$( '.comment-reply-link' ).on( 'click', function( event ) {
|
||||||
|
console.log( 'comment-reply-link', $(this) )
|
||||||
|
var recipients = $(this).attr('data-recipients') ? $(this).attr('data-recipients') + ' ' : '';
|
||||||
|
console.log( 'recipients', recipients )
|
||||||
|
setTimeout(function() {
|
||||||
|
if ( recipients ){
|
||||||
|
$('#respond #comment').val( recipients )
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} );
|
|
@ -290,9 +290,12 @@ class Admin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function enqueue_scripts( $hook_suffix ) {
|
public static function enqueue_scripts( $hook_suffix ) {
|
||||||
if ( false !== strpos( $hook_suffix, 'activitypub' ) || ( 'edit-comments.php' === $hook_suffix ) || ( 'index.php' === $hook_suffix ) ) {
|
if ( false !== strpos( $hook_suffix, 'activitypub' ) ) {
|
||||||
wp_enqueue_style( 'activitypub-admin-styles', plugins_url( 'assets/css/activitypub-admin.css', ACTIVITYPUB_PLUGIN_FILE ), array(), '1.0.0' );
|
wp_enqueue_style( 'activitypub-admin-styles', plugins_url( 'assets/css/activitypub-admin.css', ACTIVITYPUB_PLUGIN_FILE ), array(), '1.0.0' );
|
||||||
wp_enqueue_script( 'activitypub-admin-styles', plugins_url( 'assets/js/activitypub-admin.js', ACTIVITYPUB_PLUGIN_FILE ), array( 'jquery' ), '1.0.0', false );
|
wp_enqueue_script( 'activitypub-admin-styles', plugins_url( 'assets/js/activitypub-admin.js', ACTIVITYPUB_PLUGIN_FILE ), array( 'jquery' ), '1.0.0', false );
|
||||||
}
|
}
|
||||||
|
if ( ( 'edit-comments.php' === $hook_suffix ) || ( 'index.php' === $hook_suffix ) ) {
|
||||||
|
wp_enqueue_script( 'activitypub-reply', plugins_url( 'assets/js/activitypub-reply.js', ACTIVITYPUB_PLUGIN_FILE ), array( 'jquery' ), '1.0.0', false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue