jenkins-bot has submitted this change and it was merged.

Change subject: (bug 45420) Make sure that the fuzzy warning is shown
......................................................................


(bug 45420) Make sure that the fuzzy warning is shown

Always show the fuzzy warning if the message is fuzzy, even
if the diff cannot be loaded.

Also changed addWarning to return the new warning element.

Change-Id: Ic54ea0c7178904b20fae7420e0fe0cc6ea8aeeca
---
M resources/js/ext.translate.editor.js
1 file changed, 21 insertions(+), 14 deletions(-)

Approvals:
  Siebrand: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/js/ext.translate.editor.js 
b/resources/js/ext.translate.editor.js
index 1e1f23a..2ae2e4b 100644
--- a/resources/js/ext.translate.editor.js
+++ b/resources/js/ext.translate.editor.js
@@ -37,6 +37,18 @@
                        this.expanded = false;
                        this.$editTrigger.append( this.$editor );
 
+                       if ( this.$editTrigger.data( 'message' 
).properties.status === 'fuzzy' ) {
+                               this.addWarning(
+                                       mw.msg( 'tux-editor-outdated-warning' ),
+                                       'diff'
+                               ).append( $( '<span>' )
+                                       // Hide initially.
+                                       // Will be shown if there's a valid 
diff available.
+                                       .addClass( 'show-diff-link hide' )
+                                       .text( mw.msg( 
'tux-editor-outdated-warning-diff-link' ) )
+                               );
+                       }
+
                        this.showTranslationHelpers();
                },
 
@@ -516,18 +528,19 @@
                 *
                 * @param {String} warning used as html for the warning display
                 * @param {String} type used to group the warnings.eg: 
validation, diff, error
+                * @return {jQuery} the new warning element
                 */
                addWarning: function ( warning, type ) {
                        var warningCount,
                                $warnings = this.$editor.find( '.tux-warning' ),
-                               $moreWarningsTab = this.$editor.find( 
'.tux-more-warnings' );
+                               $moreWarningsTab = this.$editor.find( 
'.tux-more-warnings' ),
+                               $newWarning = $( '<div>' )
+                                       .addClass( 'tux-warning-message hide ' 
+ type )
+                                       .html( warning );
 
                        $warnings
                                .removeClass( 'hide' )
-                               .append( $( '<div>' )
-                                       .addClass( 'tux-warning-message hide ' 
+ type )
-                                       .html( warning )
-                               );
+                               .append( $newWarning );
 
                        warningCount = $warnings.find( '.tux-warning-message' 
).length;
 
@@ -540,6 +553,8 @@
                        } else {
                                $moreWarningsTab.addClass( 'hide' );
                        }
+
+                       return $newWarning;
                },
 
                prepareInfoColumn: function () {
@@ -757,7 +772,6 @@
                 * @param {object} definitiondiff A definitiondiff object as 
returned by API.
                 */
                addDefinitionDiff: function ( definitiondiff ) {
-
                        if ( !definitiondiff || definitiondiff.error ) {
                                mw.log( 'Error loading translation diff ' + 
definitiondiff && definitiondiff.error );
                                return;
@@ -767,15 +781,8 @@
                        mw.loader.load( 'mediawiki.action.history.diff', 
undefined, true );
 
                        // TODO add an option to hide diff
-                       this.addWarning(
-                               mw.msg( 'tux-editor-outdated-warning' ) +
-                                       '<span class="show-diff-link">' +
-                                       mw.message( 
'tux-editor-outdated-warning-diff-link' ).escaped() +
-                                       '</span>',
-                               'diff'
-                       );
-
                        this.$editor.find( '.tux-warning .show-diff-link' )
+                               .removeClass( 'hide' )
                                .on( 'click', function () {
                                        $( this ).parent().html( 
definitiondiff.html );
                                } );

-- 
To view, visit https://gerrit.wikimedia.org/r/54218
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic54ea0c7178904b20fae7420e0fe0cc6ea8aeeca
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Pginer <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to