Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix translation events display #222

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions includes/class-gp-translation-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,20 @@ public function register_comment_feedback_js( $template, $translation_set ) {
);
gp_enqueue_scripts( array( 'gp-translation-helpers-editor' ) );

$vars = array(
'translation_helper_url' => gp_url_project( $translation_set['project']->path, gp_url_join( $translation_set['locale_slug'], $translation_set['translation_set']->slug, '-get-translation-helpers' ) ),
'reply_text' => esc_attr__( 'Reply' ),
'cancel_reply_text' => esc_html__( 'Cancel reply' ),
);
wp_localize_script(
'gp-translation-helpers-editor',
'$gp_translation_helpers_editor',
array(
'translation_helper_url' => gp_url_project( $translation_set['project']->path, gp_url_join( $translation_set['locale_slug'], $translation_set['translation_set']->slug, '-get-translation-helpers' ) ),
'reply_text' => esc_attr__( 'Reply' ),
'cancel_reply_text' => esc_html__( 'Cancel reply' ),
)
$vars
);
wp_localize_script(
'gp-translation-helpers-editor',
'$gp_translation_helpers_editor_' . $translation_set['translation_set']->id,
$vars
);
wp_localize_script(
'gp-translation-helpers-editor',
Expand Down
12 changes: 6 additions & 6 deletions js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jQuery( function( $ ) {

let focusedRowId = '';
// When a user clicks on a sidebar tab, the visible tab and div changes.
$gp.editor.table.on( 'click', '.sidebar-tabs li', function() {
$( document ).on( 'click', '.sidebar-tabs li', function() {
const tab = $( this );
const tabId = tab.attr( 'data-tab' );
const divId = tabId.replace( 'tab', 'div' );
Expand All @@ -23,7 +23,7 @@ jQuery( function( $ ) {
// When a new translation row is opened (with double click, clicking in the "Details" button,
// or with the hotkeys), the translation textarea is focused, so the tabs (header tabs and
// divs with the content) for the right sidebar are updated.
$gp.editor.table.on( 'focus', 'tr.editor textarea.foreign-text', function() {
$( document ).on( 'focus', 'tr.editor textarea.foreign-text', function() {
const tr = $( this ).closest( 'tr.editor' );
const rowId = tr.attr( 'row' );
const translation_status = tr.find( '.panel-header' ).find( 'span' ).html();
Expand All @@ -48,7 +48,7 @@ jQuery( function( $ ) {
}
} );

$gp.editor.table.on( 'click', 'a.retry-auto-review', function( event ) {
$( document ).on( 'click', 'a.retry-auto-review', function( event ) {
const tr = $( this ).closest( 'tr.editor' );
const rowId = tr.attr( 'row' );
event.preventDefault();
Expand All @@ -74,7 +74,7 @@ jQuery( function( $ ) {
} );

// Shows/hides the reply form for a comment in the discussion.
$gp.editor.table.on( 'click', 'a.comment-reply-link', function( event ) {
$( document ).on( 'click', 'a.comment-reply-link', function( event ) {
const commentId = $( this ).attr( 'data-commentid' );
event.preventDefault();
$( '#comment-reply-' + commentId ).toggle().find( 'textarea' ).focus();
Expand Down Expand Up @@ -110,7 +110,7 @@ jQuery( function( $ ) {
}

// Sends the new comment or the reply to an existing comment.
$gp.editor.table.on( 'submit', '.meta.discussion .comment-form', function( e ) {
$( document ).on( 'submit', '.meta.discussion .comment-form', function( e ) {
const $commentform = $( e.target );
const postId = $commentform.attr( 'id' ).split( '-' )[ 1 ];
const divDiscussion = $commentform.closest( '.meta.discussion' );
Expand Down Expand Up @@ -178,7 +178,7 @@ jQuery( function( $ ) {
} );

// Copies the translation from another language to the current translation.
$gp.editor.table.on( 'click', 'button.sidebar-other-locales', function() {
$( document ).on( 'click', 'button.sidebar-other-locales', function() {
const textToCopy = $( this ).closest( 'li' ).find( 'a' ).text();
const textareaToPaste = $( this ).closest( '.editor' ).find( 'textarea.foreign-text' );
let selectionStart = textareaToPaste.get( 0 ).selectionStart;
Expand Down
Loading