jenkins-bot has submitted this change and it was merged. Change subject: Save button in proofreading could be more context sensitive ......................................................................
Save button in proofreading could be more context sensitive Bug: T50100 Change-Id: Ie7c3899181513d031d4761d0d46491d00a658df9 --- M i18n/core/en.json M i18n/core/qqq.json M resources/js/ext.translate.editor.js M resources/js/ext.translate.proofread.js 4 files changed, 63 insertions(+), 9 deletions(-) Approvals: Siebrand: Looks good to me, approved jenkins-bot: Verified diff --git a/i18n/core/en.json b/i18n/core/en.json index 255267f..ea9d23e 100644 --- a/i18n/core/en.json +++ b/i18n/core/en.json @@ -312,6 +312,7 @@ "tux-editor-skip-button-label": "Skip to next", "tux-editor-cancel-button-label": "Cancel", "tux-editor-confirm-button-label": "Confirm translation", + "tux-editor-proofread-button-label": "Mark as reviewed", "tux-editor-shortcut-info": "Press \"$1\" to save or \"$2\" to skip to next message or \"$3\" for other shortcuts.", "tux-editor-edit-desc": "Edit documentation", "tux-editor-add-desc": "Add documentation", diff --git a/i18n/core/qqq.json b/i18n/core/qqq.json index 88eb394..06baeae 100644 --- a/i18n/core/qqq.json +++ b/i18n/core/qqq.json @@ -343,6 +343,7 @@ "tux-editor-skip-button-label": "Label for skip button", "tux-editor-cancel-button-label": "Label for cancel button.\nPressing the button hides the message editor without saving and marks the message internally as \"hard\".\n{{Identical|Cancel}}", "tux-editor-confirm-button-label": "Label for confirm button", + "tux-editor-proofread-button-label": "Label for review button", "tux-editor-shortcut-info": "A help text for the keyboard shortcuts. Parameters:\n* $1 - shortcut key for save button\n* $2 - shortcut key for skip button\n* $3 - \"ALT\"", "tux-editor-edit-desc": "Text for the link to edit message documentation.\n{{Identical|Edit description}}", "tux-editor-add-desc": "Text for the link to add message documentation when it doesn't exist", diff --git a/resources/js/ext.translate.editor.js b/resources/js/ext.translate.editor.js index 25506c2..6e285c6 100644 --- a/resources/js/ext.translate.editor.js +++ b/resources/js/ext.translate.editor.js @@ -600,7 +600,8 @@ mw.translate.dirty = true; } - $saveButton.text( mw.msg( 'tux-editor-save-button-label' ) ); + translateEditor.makeSaveButtonJustSave( $saveButton ); + // When there is content in the editor enable the button. // But do not enable when some saving is not finished yet. if ( $.trim( current ) && !translateEditor.saving ) { @@ -655,8 +656,10 @@ // and go back to hiding. $discardChangesButton.addClass( 'hide' ); - // There's nothing new to save + // There's nothing new to save... $saveButton.prop( 'disabled', true ); + // ...unless there is other action + translateEditor.makeSaveButtonContextSensitive( $saveButton ); translateEditor.markUnunsaved(); } ); @@ -684,13 +687,7 @@ e.stopPropagation(); } ); - // When the user opens an outdated translation, the main button should be enabled - // and display a "confirm translation" label. - if ( this.$messageItem.hasClass( 'fuzzy' ) ) { - $saveButton - .prop( 'disabled', false ) - .text( mw.msg( 'tux-editor-confirm-button-label' ) ); - } + this.makeSaveButtonContextSensitive( $saveButton, this.$messageItem ); } else { $editingButtonBlock = $( [] ); @@ -777,6 +774,53 @@ }, /** + * Modifies the save button to provide suitable default action for *unchanged* + * message. It will revert back to normal save button if the text is changed. + * + * @param {jQuery} $button The save button. + */ + makeSaveButtonContextSensitive: function ( $button ) { + var self = this; + + if ( this.message.properties.status === 'fuzzy' ) { + $button.prop( 'disabled', false ); + $button.text( mw.msg( 'tux-editor-confirm-button-label' ) ); + $button.off( 'click' ); + $button.on( 'click', function ( e ) { + self.save(); + e.stopPropagation(); + } ); + } else if ( this.message.proofreadable ) { + $button.prop( 'disabled', false ); + $button.text( mw.msg( 'tux-editor-proofread-button-label' ) ); + $button.off( 'click' ); + $button.on( 'click', function ( e ) { + $button.prop( 'disabled', true ); + self.message.proofreadAction(); + self.next(); + e.stopPropagation(); + } ); + } + }, + + /** + * Modifies the save button to just save the translation as usual. Whether the + * button is enabled or not is controlled elsewhere. + * + * @param {jQuery} $button The save button. + */ + makeSaveButtonJustSave: function ( $button ) { + var self = this; + + $button.text( mw.msg( 'tux-editor-save-button-label' ) ); + $button.off( 'click' ); + $button.on( 'click', function ( e ) { + self.save(); + e.stopPropagation(); + } ); + }, + + /** * Validate the current translation using the API * and show the warnings if necessary. */ diff --git a/resources/js/ext.translate.proofread.js b/resources/js/ext.translate.proofread.js index 76e276e..c615bf3 100644 --- a/resources/js/ext.translate.proofread.js +++ b/resources/js/ext.translate.proofread.js @@ -33,6 +33,7 @@ var proofread = this; this.render(); + // No review before translating. if ( !this.message.translation ) { this.disableProofread(); @@ -150,6 +151,12 @@ ) .addClass( this.message.properties.status ); + if ( !translatedBySelf && !proofreadBySelf ) { + // This will get removed later if any of various other reasons prevent it + this.message.proofreadable = true; + this.message.proofreadAction = this.proofread.bind( this ); + } + if ( translatedBySelf ) { this.markSelfTranslation(); } @@ -162,6 +169,7 @@ }, disableProofread: function () { + this.message.proofreadable = false; this.$message.find( '.tux-proofread-action' ) .remove(); }, -- To view, visit https://gerrit.wikimedia.org/r/132642 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie7c3899181513d031d4761d0d46491d00a658df9 Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Harshkothari410 <harshkothari...@gmail.com> Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Ricordisamoa <ricordisa...@openmailbox.org> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits