Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/305195
Change subject: Replace jquery.tipsy with OO.ui.PopupWidget
......................................................................
Replace jquery.tipsy with OO.ui.PopupWidget
Bug: T102922
Change-Id: I833f79b772911e2e92148778717066554e677121
---
M .jshintrc
M Resources.php
M resources/js/ext.translate.messagetable.js
M resources/js/ext.translate.proofread.js
4 files changed, 43 insertions(+), 27 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate
refs/changes/95/305195/1
diff --git a/.jshintrc b/.jshintrc
index 4fbb8fe..8b924e5 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -16,6 +16,7 @@
"mediaWiki",
"jQuery",
"QUnit",
- "autosize"
+ "autosize",
+ "OO"
]
}
diff --git a/Resources.php b/Resources.php
index b2b1a5d..fdb62ca 100644
--- a/Resources.php
+++ b/Resources.php
@@ -58,7 +58,6 @@
'jquery.makeCollapsible',
'jquery.textSelection',
'jquery.textchange',
- 'jquery.tipsy',
'mediawiki.Uri',
'mediawiki.api',
'mediawiki.api.parse',
diff --git a/resources/js/ext.translate.messagetable.js
b/resources/js/ext.translate.messagetable.js
index 47bfd96..cbaeec8 100644
--- a/resources/js/ext.translate.messagetable.js
+++ b/resources/js/ext.translate.messagetable.js
@@ -161,7 +161,7 @@
*/
clear: function () {
this.$container.empty();
- $( '.translate-tipsy' ).remove();
+ $( '.translate-tooltip' ).remove();
this.messages = [];
// Any ongoing loading process will notice this and
will reject results.
this.loading = false;
@@ -282,7 +282,7 @@
* Add a message to the message table for proofreading.
*/
addProofread: function ( message ) {
- var icon, $message;
+ var $message, $icon, module;
$message = $( '<div>' ).addClass( 'row
tux-message-proofread' );
@@ -293,28 +293,46 @@
targetlangcode: this.$container.data(
'targetlangcode' )
} );
- // Add autotipsy to first available proofread action
icon
+ $icon = $message.find( '.tux-proofread-action' );
+ if ( $icon.length === 0 ) {
+ return;
+ }
+
+ // Add autotooltip 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' );
+ $icon.addClass( 'autotooltip' );
- // 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 );
+ // Use oojs-ui-core only after MediaWiki 1.26 is no
longer supported
+ module = mw.loader.getState( 'oojs-ui-core' ) === null
? 'oojs-ui' : 'oojs-ui-core';
+ mw.loader.using( module ).done( function () {
+ var tooltip = new OO.ui.PopupWidget( {
+ padded: true,
+ align: 'center',
+ classes: [ 'translate-tooltip' ],
+ $content: $( '<p>' ).text( $icon.prop(
'title' ) )
+ } );
+
+ setTimeout( function () {
+ var offset, $icon = $(
'.autotooltip:visible' );
+ if ( !$icon.length ) {
+ return;
+ }
+
+ offset = $icon.offset();
+ tooltip.$element.css( {
+ top: offset.top +
$icon.outerHeight() + 5,
+ left: offset.left +
$icon.outerWidth() - 20
+ } ).appendTo( 'body' );
+ tooltip.toggleClipping( false ).toggle(
true );
+
+ setTimeout( function () {
+ tooltip.$element.remove();
+ }, 4000 );
+ }, 1000 );
+ } );
},
addPageModeMessage: function ( message ) {
@@ -662,7 +680,7 @@
// Emulate clear without clearing loaded messages
messageTable.$container.empty();
- $( '.translate-tipsy' ).remove();
+ $( '.translate-tooltip' ).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 45ea21c..cdeef25 100644
--- a/resources/js/ext.translate.proofread.js
+++ b/resources/js/ext.translate.proofread.js
@@ -90,8 +90,7 @@
.attr( 'title', mw.msg(
'tux-proofread-action-tooltip' ) )
.addClass(
'tux-proofread-action ' +
this.message.properties.status + ' ' + ( proofreadBySelf ? 'accepted' : '' )
- )
- .tipsy( { gravity: 's', delayIn: 1000,
className: 'translate-tipsy' } );
+ );
$proofreadEdit = $( '<div>' )
.addClass( 'tux-proofread-edit' )
@@ -184,7 +183,6 @@
.append( $( '<div>' )
.addClass( 'translated-by-self'
)
.attr( 'title', mw.msg(
'tux-proofread-translated-by-self' ) )
- .tipsy( { gravity: 'e',
className: 'translate-tipsy' } )
);
}
},
@@ -248,8 +246,8 @@
} );
this.$message.find( '.tux-proofread-edit' ).on(
'click', function () {
- // Make sure that the tipsy is hidden when
going to the editor
- $( '.translate-tipsy' ).remove();
+ // Make sure that the tooltip is hidden when
going to the editor
+ $( '.translate-tooltip' ).remove();
proofread.$message.data( 'translateeditor'
).show();
return false;
--
To view, visit https://gerrit.wikimedia.org/r/305195
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I833f79b772911e2e92148778717066554e677121
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