Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/69974
Change subject: Make the proofread tooltip get stuck less in wrong places
......................................................................
Make the proofread tooltip get stuck less in wrong places
* Added a class so that all tooltips can easily be removed
* Delay the showing of the automatically shown tooltip by
few seconds to avoid mispositionings caused by page still
rendering.
* Hide the tooltip after some time to avoid it staying
forever in wrong place if DOM is changed (tipsy uses
absolute positioning and adds the tipsy element to body)
in a way that causes the element to move on the page. It
is not end of the world if the user does not see this
tooltip, given that it is shown every time a proofread
view is opened.
Bug: 46875
Change-Id: Ic1fdd0e02251857329303f90e5e156312ee9cf60
---
M resources/js/ext.translate.messagetable.js
M resources/js/ext.translate.proofread.js
2 files changed, 35 insertions(+), 38 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate
refs/changes/74/69974/1
diff --git a/resources/js/ext.translate.messagetable.js
b/resources/js/ext.translate.messagetable.js
index 70671e7..f643c50 100644
--- a/resources/js/ext.translate.messagetable.js
+++ b/resources/js/ext.translate.messagetable.js
@@ -151,7 +151,8 @@
* Clear the message table
*/
clear: function () {
- $( '.tux-messagelist' ).empty();
+ this.$container.empty();
+ $( '.translate-tipsy' ).remove();
this.messages = [];
// Any ongoing loading process will notice this and
will reject results.
this.loading = false;
@@ -165,24 +166,9 @@
if ( this.mode === 'translate' ) {
this.addTranslate( message );
-
- return;
- }
-
- if ( this.mode === 'proofread' ) {
- $message = this.addProofread( message );
-
- if ( !this.firstProofreadTipShown ) {
- if ( $message.find(
'.tux-proofread-action' ).length ) {
- $message.find(
'.tux-proofread-action' ).tipsy( 'show' );
- this.firstProofreadTipShown =
true;
- }
- }
-
- return;
- }
-
- if ( this.mode === 'page' ) {
+ } else if ( this.mode === 'proofread' ) {
+ this.addProofread( message );
+ } else if ( this.mode === 'page' ) {
this.addPageModeMessage( message );
}
},
@@ -287,8 +273,9 @@
* Add a message to the message table for proofreading.
*/
addProofread: function ( message ) {
- var $message = $( '<div>' )
- .addClass( 'row tux-message-proofread' );
+ var icon, $message;
+
+ $message = $( '<div>' ).addClass( 'row
tux-message-proofread' );
this.$container.append( $message );
$message.proofread( {
@@ -297,7 +284,28 @@
targetlangcode: this.$container.data(
'targetlangcode' )
} );
- return $message;
+ // Add autotipsy to first available proofread action
icon
+ if ( this.firstProofreadTipShown ) {
+ return;
+ }
+
+ icon = $message.find( '.tux-proofread-action' );
+ if ( icon.length === 0 ) {
+ return;
+ }
+
+ this.firstProofreadTipShown = true;
+ icon.addClass( 'autotipsy' );
+
+ // Selectors are not cached in case the element no
longer exists
+ setTimeout( function () {
+ var icon = $( '.autotipsy' );
+ if ( icon.length ) { icon.tipsy( 'show' ); }
+ }, 1000 );
+ setTimeout( function () {
+ var icon = $( '.autotipsy' );
+ if ( icon.length ) { icon.tipsy( 'hide' ); }
+ }, 4000 );
},
addPageModeMessage: function ( message ) {
@@ -641,19 +649,12 @@
messageTable.firstProofreadTipShown = false;
- // "Accept message" tipsies may still be shown
- if ( messageTable.mode === 'proofread' ) {
- $proofreadAction =
messageTable.$container.find( '.tux-proofread-action' );
-
- if ( $proofreadAction.length ) {
- $proofreadAction.tipsy( 'hide' );
- }
- }
-
messageTable.mode = mode;
mw.translate.changeUrl( { action: messageTable.mode } );
+ // Emulate clear without clearing loaded messages
messageTable.$container.empty();
+ $( '.translate-tipsy' ).remove();
$tuxTabUntranslated = $( '.tux-message-selector >
.tux-tab-untranslated' );
$tuxTabUnproofread = $( '.tux-message-selector >
.tux-tab-unproofread' );
diff --git a/resources/js/ext.translate.proofread.js
b/resources/js/ext.translate.proofread.js
index e9c81b9..b165850 100644
--- a/resources/js/ext.translate.proofread.js
+++ b/resources/js/ext.translate.proofread.js
@@ -184,7 +184,7 @@
.addClass(
'tux-proofread-action ' +
this.message.properties.status + ' ' + ( proofreadBySelf ? 'accepted' : '' )
)
- .tipsy( { gravity: 's', delayIn: 2000 } );
+ .tipsy( { gravity: 's', delayIn: 1000,
className: 'translate-tipsy' } );
$proofreadEdit = $( '<div>' )
.addClass( 'tux-proofread-edit' )
@@ -263,7 +263,7 @@
.append( $( '<div>' )
.addClass( 'translated-by-self'
)
.attr( 'title', mw.msg(
'tux-proofread-translated-by-self' ) )
- .tipsy( { gravity: 'e' } )
+ .tipsy( { gravity: 'e',
className: 'translate-tipsy' } )
);
}
},
@@ -306,11 +306,7 @@
this.$message.find( '.tux-proofread-edit' ).on(
'click', function () {
// Make sure that the tipsy is hidden when
going to the editor
- var $tuxProofreadAction = $( this ).siblings(
'.tux-proofread-action' );
- if ( $tuxProofreadAction.length ) {
- $tuxProofreadAction.tipsy( 'hide' );
- }
-
+ $( '.translate-tipsy' ).remove();
proofread.$message.data( 'translateeditor'
).show();
return false;
--
To view, visit https://gerrit.wikimedia.org/r/69974
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1fdd0e02251857329303f90e5e156312ee9cf60
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