Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/91591
Change subject: Editor: do not show "Suggestions" when no suggestions
......................................................................
Editor: do not show "Suggestions" when no suggestions
If the only suggestion was the current translation of the
message, which is filtered out, the heading would be shown
but no suggestions were visible.
Change-Id: I5f7bceaf05dbaee00d93215bec4735f017a32428
---
M resources/js/ext.translate.editor.helpers.js
1 file changed, 12 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate
refs/changes/91/91591/1
diff --git a/resources/js/ext.translate.editor.helpers.js
b/resources/js/ext.translate.editor.helpers.js
index af739c7..deea609 100644
--- a/resources/js/ext.translate.editor.helpers.js
+++ b/resources/js/ext.translate.editor.helpers.js
@@ -255,18 +255,19 @@
* @param {array} suggestions A ttmserver array as returned by
API.
*/
showTranslationMemory: function ( suggestions ) {
- var $tmSuggestions, $translationTextarea,
+ var $heading, $tmSuggestions, $translationTextarea,
translateEditor = this;
if ( !suggestions.length ) {
return;
}
- $tmSuggestions = $( '<div>' )
- .addClass( 'tm-suggestions' );
- this.$editor.find( '.tm-suggestions-title' )
- .removeClass( 'hide' )
- .after( $tmSuggestions );
+ // Container for the suggestions
+ $tmSuggestions = $( '<div>' ).addClass(
'tm-suggestions' );
+
+ $heading = this.$editor.find( '.tm-suggestions-title' );
+ $heading.after( $tmSuggestions );
+
$translationTextarea = this.$editor.find(
'.tux-textarea-translation' );
$.each( suggestions, function ( index, translation ) {
@@ -326,6 +327,11 @@
$tmSuggestions.append( $translation );
} );
+
+ // Show the heading only if we actually have suggestions
+ if ( $tmSuggestions.length ) {
+ $heading.removeClass( 'hide' );
+ }
},
/**
--
To view, visit https://gerrit.wikimedia.org/r/91591
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f7bceaf05dbaee00d93215bec4735f017a32428
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits