jenkins-bot has submitted this change and it was merged.
Change subject: Show "Cancel" instead of "Skip" at the last message
......................................................................
Show "Cancel" instead of "Skip" at the last message
Bug: 46099
Change-Id: If71d03f6d4ae123899edf2b2ed00c167069900eb
---
M Resources.php
M Translate.i18n.php
M resources/css/ext.translate.editor.css
M resources/js/ext.translate.editor.js
M resources/js/ext.translate.messagetable.js
M resources/js/ext.translate.special.searchtranslations.js
6 files changed, 93 insertions(+), 35 deletions(-)
Approvals:
Siebrand: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Resources.php b/Resources.php
index 06679c8..01b94dd 100644
--- a/Resources.php
+++ b/Resources.php
@@ -64,6 +64,7 @@
'tux-editor-discard-changes-button-label',
'tux-editor-save-button-label',
'tux-editor-skip-button-label',
+ 'tux-editor-cancel-button-label',
'tux-editor-confirm-button-label',
'tux-editor-shortcut-info',
'tux-editor-edit-desc',
diff --git a/Translate.i18n.php b/Translate.i18n.php
index 90f6793..07d5731 100644
--- a/Translate.i18n.php
+++ b/Translate.i18n.php
@@ -456,6 +456,7 @@
'tux-editor-discard-changes-button-label' => 'Discard changes',
'tux-editor-save-button-label' => 'Save translation',
'tux-editor-skip-button-label' => 'Skip to next',
+ 'tux-editor-cancel-button-label' => 'Cancel',
'tux-editor-confirm-button-label' => 'Confirm translation',
'tux-editor-shortcut-info' => 'Press "$1" to save or "$2" to skip to
next message',
'tux-editor-edit-desc' => 'Edit description',
@@ -1087,6 +1088,9 @@
'tux-editor-discard-changes-button-label' => 'Label for a button that
discards the changes made to a translation and restores the saved version.',
'tux-editor-save-button-label' => 'Label for save translation button',
'tux-editor-skip-button-label' => 'Label for skip button',
+ 'tux-editor-cancel-button-label' => 'Label for cancel button.
+Pressing the button hides the message editor without saving and marks the
message internally as "hard".
+{{Identical|Cancel}}',
'tux-editor-confirm-button-label' => 'Label for confirm button',
'tux-editor-shortcut-info' => 'A help text for the keyboard shortcuts
* $1 is shortcut key for save button
diff --git a/resources/css/ext.translate.editor.css
b/resources/css/ext.translate.editor.css
index d96726c..22e2b68 100644
--- a/resources/css/ext.translate.editor.css
+++ b/resources/css/ext.translate.editor.css
@@ -379,3 +379,19 @@
background: url(../images/label-tick.png) right no-repeat;
color: #252525;
}
+
+/*
+ * Hide the cancel button by default, but show it in the last message.
+ * !important is used to override the button styling in ULS.
+*/
+.tux-editor-cancel-button {
+ display: none !important;
+}
+
+.last-message .tux-editor-cancel-button {
+ display: inline-block !important;
+}
+
+.last-message .tux-editor-skip-button {
+ display: none;
+}
diff --git a/resources/js/ext.translate.editor.js
b/resources/js/ext.translate.editor.js
index 155a42a..3748c36 100644
--- a/resources/js/ext.translate.editor.js
+++ b/resources/js/ext.translate.editor.js
@@ -315,6 +315,7 @@
$saveButton,
$requestRight,
$skipButton,
+ $cancelButton,
$sourceString,
$closeIcon,
$layoutActions,
@@ -337,7 +338,6 @@
$messageTools.toggleClass( 'hide' );
e.stopPropagation();
} );
-
$closeIcon = $( '<span>' )
.addClass( 'one column close' )
@@ -594,9 +594,18 @@
e.stopPropagation();
} );
+ $cancelButton = $( '<button>' )
+ .addClass( 'button tux-editor-cancel-button' )
+ .text( mw.msg( 'tux-editor-cancel-button-label'
) )
+ .on( 'click', function ( e ) {
+ translateEditor.skip();
+ translateEditor.hide();
+ e.stopPropagation();
+ } );
+
$controlButtonBlock = $( '<div>' )
.addClass( 'twelve columns
tux-editor-control-buttons' )
- .append( $requestRight, $saveButton,
$skipButton );
+ .append( $requestRight, $saveButton,
$skipButton, $cancelButton );
$editorColumn.append( $( '<div>' )
.addClass( 'row tux-editor-actions-block' )
@@ -829,6 +838,7 @@
$( '.tux-editor-save-button, .tux-editor-save-button'
).removeAttr( 'accesskey' );
this.$editor.find( '.tux-editor-save-button' ).attr(
'accesskey', 's' );
this.$editor.find( '.tux-editor-skip-button' ).attr(
'accesskey', 'd' );
+ // @todo access key for the cancel button
this.$messageItem.addClass( 'hide' );
this.$editor.removeClass( 'hide' );
diff --git a/resources/js/ext.translate.messagetable.js
b/resources/js/ext.translate.messagetable.js
index 431ede8..56d42fd 100644
--- a/resources/js/ext.translate.messagetable.js
+++ b/resources/js/ext.translate.messagetable.js
@@ -3,6 +3,23 @@
mw.translate = mw.translate || {};
+ var delay, itemsClass;
+
+ delay = ( function () {
+ var timer = 0;
+
+ return function ( callback, milliseconds ) {
+ clearTimeout( timer );
+ timer = setTimeout( callback, milliseconds );
+ };
+ } () );
+
+ itemsClass = {
+ proofread: '.tux-message-proofread',
+ page: '.tux-message-pagemode',
+ translate: '.tux-message'
+ };
+
mw.translate = $.extend( mw.translate, {
getMessages: function ( messageGroup, language, offset, limit,
filter ) {
var api = new mw.Api();
@@ -297,12 +314,7 @@
search: function ( query ) {
var resultCount = 0,
$result,
- matcher = new RegExp( '(^|\\s|\\b)' +
escapeRegex( query ), 'gi' ),
- itemsClass = {
- proofread: '.tux-message-proofread',
- page: '.tux-message-pagemode',
- translate: '.tux-message'
- };
+ matcher = new RegExp( '(^|\\s|\\b)' +
escapeRegex( query ), 'gi' );
this.$container.find( itemsClass[ this.mode ] ).each(
function () {
var $message = $( this ),
@@ -346,6 +358,7 @@
}
this.$loader.trigger( 'appear' );
+ this.updateLastMessage();
// Trigger a scroll event for the window to make sure
all floating toolbars
// are in their position.
@@ -439,23 +452,26 @@
if ( result['query-continue'] ===
undefined ) {
// End of messages
- messageTable.$loader.data(
'offset', -1 ).addClass( 'hide' );
- return;
+ messageTable.$loader.data(
'offset', -1 )
+ .addClass( 'hide' );
+ } else {
+ messageTable.$loader.data(
'offset', result['query-continue'].messagecollection.mcoffset );
+
+ remaining =
result.query.metadata.remaining;
+
+ $(
'.tux-messagetable-loader-count' ).text(
+ mw.msg(
'tux-messagetable-more-messages', remaining )
+ );
+
+ $(
'.tux-messagetable-loader-more' ).text(
+ mw.msg(
'tux-messagetable-loading-messages', Math.min( remaining, pageSize ) )
+ );
+
+ // Make sure the floating
toolbars are visible without the need for scroll
+ $( window ).trigger( 'scroll' );
}
- messageTable.$loader.data( 'offset',
result['query-continue'].messagecollection.mcoffset );
-
- remaining =
result.query.metadata.remaining;
-
- $( '.tux-messagetable-loader-count'
).text(
- mw.msg(
'tux-messagetable-more-messages', remaining )
- );
-
- $( '.tux-messagetable-loader-more'
).text(
- mw.msg(
'tux-messagetable-loading-messages', Math.min( remaining, pageSize ) )
- );
- // Make sure the floating toolbars are
visible without the need for scroll
- $( window ).trigger( 'scroll' );
+ messageTable.updateLastMessage();
} )
.fail( function ( errorCode, response ) {
if ( response.error.code ===
'mctranslate-language-disabled' ) {
@@ -466,6 +482,19 @@
messageTable.$loader.data( 'offset', -1
).addClass( 'hide' );
messageTable.loading = false;
} );
+ },
+
+ updateLastMessage: function () {
+ var $messages = this.$container.find( itemsClass[
this.mode ] );
+
+ // If a message was previously marked as "last",
restore it to normal state
+ $messages.filter( '.last-message' ).removeClass(
'last-message' );
+
+ // At the class to the current last shown message
+ $messages
+ .not( '.hide' )
+ .last()
+ .addClass( 'last-message' );
},
/**
@@ -604,7 +633,7 @@
messageTable.$actionBar.find(
'.page-mode-button' ).addClass( 'down' );
}
- this.firstProofreadTipShown = false;
+ messageTable.firstProofreadTipShown = false;
// "Accept message" tipsies may still be shown
if ( messageTable.mode === 'proofread' ) {
@@ -616,7 +645,7 @@
}
messageTable.mode = mode;
- mw.translate.changeUrl( { action: this.mode } );
+ mw.translate.changeUrl( { action: messageTable.mode } );
messageTable.$container.empty();
@@ -665,6 +694,8 @@
} else if ( messageTable.initialized ) {
messageTable.displayEmptyListHelp();
}
+
+ messageTable.updateLastMessage();
},
/**
@@ -779,15 +810,6 @@
$.post( mw.util.wikiScript( 'api' ), params,
successFunction ).fail( failFunction );
} );
} );
-
- var delay = ( function () {
- var timer = 0;
-
- return function ( callback, milliseconds ) {
- clearTimeout( timer );
- timer = setTimeout( callback, milliseconds );
- };
- } () );
/**
* Escape the search query for regex match
diff --git a/resources/js/ext.translate.special.searchtranslations.js
b/resources/js/ext.translate.special.searchtranslations.js
index d67bd64..1d61a07 100644
--- a/resources/js/ext.translate.special.searchtranslations.js
+++ b/resources/js/ext.translate.special.searchtranslations.js
@@ -2,12 +2,15 @@
'use strict';
$( document ).ready( function () {
+ var $messages = $( '.tux-message' );
+
// Make the whole rows clickable
$( '.facet-item' ).click( function () {
window.location = $( this ).find( 'a' ).attr( 'href' );
} );
- $( '.tux-message' ).each( function () {
+
+ $messages.each( function () {
var $this = $( this );
$this.translateeditor( {
@@ -20,6 +23,8 @@
} );
} );
+ $messages.last().addClass( 'last-message' );
+
showLanguages();
showMessageGroups();
} );
--
To view, visit https://gerrit.wikimedia.org/r/59132
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If71d03f6d4ae123899edf2b2ed00c167069900eb
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
Gerrit-Reviewer: Amire80 <[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