Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/292298
Change subject: Remove jquery.tipsy from UniversalLanguageSelector
......................................................................
Remove jquery.tipsy from UniversalLanguageSelector
This doesn't appear to be justified due to the one use case. This
will now be done via OOjs UI and given the future of jquery.tipsy
is under scrunity ( T117720) it would be unwise to enable this on
mobile.
It's unclear from 251911 what the objection to using this for the
undo popup but I would urge us to work through any perceived blockers
to make this happen.
Bug: T119417
Bug: T102922
Change-Id: I60cce248884308bf0728d153f6137a8d25e01300
---
M .jshintrc
M resources/js/ext.uls.interface.js
2 files changed, 27 insertions(+), 23 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector
refs/changes/98/292298/1
diff --git a/.jshintrc b/.jshintrc
index 93a54e8..f2fa9d3 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -20,6 +20,7 @@
"globals": {
"mediaWiki": false,
+ "OO": false,
"QUnit": false
}
}
diff --git a/resources/js/ext.uls.interface.js
b/resources/js/ext.uls.interface.js
index 7bd58ae..ec799f8 100644
--- a/resources/js/ext.uls.interface.js
+++ b/resources/js/ext.uls.interface.js
@@ -186,11 +186,11 @@
} catch ( e ) {}
if ( autonym ) {
- mw.loader.using( 'jquery.tipsy', function () {
+ mw.loader.using( 'oojs-ui', function () {
deferred.resolve( autonym );
} );
} else {
- mw.loader.using( [ 'jquery.uls.data', 'jquery.tipsy' ],
function () {
+ mw.loader.using( [ 'jquery.uls.data', 'oojs-ui' ],
function () {
deferred.resolve( $.uls.data.getAutonym( code )
);
} );
}
@@ -221,32 +221,27 @@
* It also allows to undo the language selection.
*/
function showUndoTooltip() {
- var previousLanguages, previousLang, $ulsTrigger,
+ var previousLanguages, previousLang, $ulsTrigger, ulsPopup,
ulsPosition = mw.config.get( 'wgULSPosition' ),
currentLang = mw.config.get( 'wgUserLanguage' ),
- rtlPage = $( 'body' ).hasClass( 'rtl' ),
- tipsyGravity = {
- personal: 'n',
- interlanguage: rtlPage ? 'e' : 'w'
- };
+ rtlPage = $( 'body' ).hasClass( 'rtl' );
$ulsTrigger = ( ulsPosition === 'interlanguage' ) ?
$( '.uls-settings-trigger' ) :
$( '.uls-trigger' );
function hideTipsy() {
- $ulsTrigger.tipsy( 'hide' );
+ ulsPopup.toggle( false );
}
function showTipsy( timeout ) {
var tipsyTimer = 0;
- $ulsTrigger.tipsy( 'show' );
+ ulsPopup.toggle( true );
// if the mouse is over the tooltip, do not hide
$( '.tipsy' ).on( 'mouseover', function () {
window.clearTimeout( tipsyTimer );
- } );
- $( '.tipsy' ).on( 'mouseout', function () {
+ } ).on( 'mouseout', function () {
tipsyTimer = window.setTimeout( hideTipsy,
timeout );
} );
@@ -280,14 +275,17 @@
mw.uls.addPreviousLanguage( currentLang );
getUndoAutonym( previousLang ).done( function ( autonym ) {
- // Attach a tipsy tooltip to the trigger
- $ulsTrigger.tipsy( {
- gravity: tipsyGravity[ ulsPosition ],
- delayOut: 3000,
- html: true,
- fade: true,
- trigger: 'manual',
- title: function () {
+ var offset = $( $ulsTrigger ).offset();
+ // remove any existing popups
+ if ( ulsPopup ) {
+ ulsPopup.$element.remove();
+ }
+ ulsPopup = new OO.ui.PopupWidget( {
+ padded: true,
+ width: 300,
+ align: 'force-right',
+ classes: [ 'tipsy' ],
+ $content: (function () {
var link;
link = $( '<a>' ).text( autonym )
@@ -305,9 +303,15 @@
// Get the html of the link by wrapping
it in div first
link = $( '<div>' ).html( link ).html();
- return mw.message(
'ext-uls-undo-language-tooltip-text', '$1' ).escaped().replace( '$1', link );
- }
+ return $( '<p>' ).html( mw.message(
'ext-uls-undo-language-tooltip-text', '$1' ).escaped().replace( '$1', link ) );
+ } () )
} );
+
+ // position popup
+ ulsPopup.$element.css( {
+ top: offset.top + 24,
+ left: offset.left + 6
+ } ).appendTo( 'body' );
// The interlanguage position needs some time to settle
down
window.setTimeout( function () {
@@ -339,7 +343,6 @@
var $triggers,
$pLang,
$ulsTrigger = $( '.uls-trigger' ),
- rtlPage = $( 'body' ).hasClass( 'rtl' ),
anonMode = ( mw.user.isAnon() &&
!mw.config.get( 'wgULSAnonCanChangeLanguage' )
),
imeSelector = mw.config.get( 'wgULSImeSelectors'
).join( ', ' ),
--
To view, visit https://gerrit.wikimedia.org/r/292298
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I60cce248884308bf0728d153f6137a8d25e01300
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits