Ensure module 'jquery.tipsy' is loaded before using
Move the showTipsy calls into the callback. Move the declaration of the functions hideTipsy and showTipsy before the new call position. Also change the order of the declaration of the functions hideTipsy and showTipsy to avoid a forward reference in showTipsy. Spotted by JSLint. Bug: T118507 Change-Id: I338a78cde249405459be14948b78cf59d715145a
This commit is contained in:
@@ -214,50 +214,9 @@
|
|||||||
$( '.uls-settings-trigger' ) :
|
$( '.uls-settings-trigger' ) :
|
||||||
$( '.uls-trigger' );
|
$( '.uls-trigger' );
|
||||||
|
|
||||||
previousLanguages = mw.uls.getPreviousLanguages();
|
function hideTipsy() {
|
||||||
previousLang = previousLanguages.slice( -1 )[0];
|
$ulsTrigger.tipsy( 'hide' );
|
||||||
|
}
|
||||||
previousLanguages.push( currentLang );
|
|
||||||
mw.uls.setPreviousLanguages( previousLanguages );
|
|
||||||
|
|
||||||
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 link;
|
|
||||||
|
|
||||||
link = $( '<a>' ).text( autonym )
|
|
||||||
.attr( {
|
|
||||||
href: '#',
|
|
||||||
'class': 'uls-prevlang-link',
|
|
||||||
lang: previousLang,
|
|
||||||
// We could get dir from uls.data,
|
|
||||||
// but we are trying to avoid loading it
|
|
||||||
// and 'auto' is safe enough in this context
|
|
||||||
dir: 'auto'
|
|
||||||
} );
|
|
||||||
|
|
||||||
// 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 );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
// Now that we set the previous languages,
|
|
||||||
// we can set the cookie of the previous autonym.
|
|
||||||
// TODO: Refactor this, because it doesn't directly belong
|
|
||||||
// to the tooltip.
|
|
||||||
$.cookie( mw.uls.previousLanguageAutonymCookie,
|
|
||||||
mw.config.get( 'wgULSCurrentAutonym' ),
|
|
||||||
{ path: '/' }
|
|
||||||
);
|
|
||||||
|
|
||||||
function showTipsy( timeout ) {
|
function showTipsy( timeout ) {
|
||||||
var tipsyTimer = 0;
|
var tipsyTimer = 0;
|
||||||
@@ -295,23 +254,64 @@
|
|||||||
tipsyTimer = window.setTimeout( hideTipsy, timeout );
|
tipsyTimer = window.setTimeout( hideTipsy, timeout );
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideTipsy() {
|
previousLanguages = mw.uls.getPreviousLanguages();
|
||||||
$ulsTrigger.tipsy( 'hide' );
|
previousLang = previousLanguages.slice( -1 )[0];
|
||||||
}
|
|
||||||
|
|
||||||
// The interlanguage position needs some time to settle down
|
previousLanguages.push( currentLang );
|
||||||
window.setTimeout( function () {
|
mw.uls.setPreviousLanguages( previousLanguages );
|
||||||
// Show the tipsy tooltip on page load.
|
|
||||||
showTipsy( 6000 );
|
|
||||||
}, 700 );
|
|
||||||
|
|
||||||
// manually show the tooltip
|
getUndoAutonym( previousLang ).done( function( autonym ) {
|
||||||
$ulsTrigger.on( 'mouseover', function () {
|
// Attach a tipsy tooltip to the trigger
|
||||||
// show only if the ULS panel is not shown
|
$ulsTrigger.tipsy( {
|
||||||
if ( !$( '.uls-menu:visible' ).length ) {
|
gravity: tipsyGravity[ulsPosition],
|
||||||
showTipsy( 3000 );
|
delayOut: 3000,
|
||||||
}
|
html: true,
|
||||||
|
fade: true,
|
||||||
|
trigger: 'manual',
|
||||||
|
title: function () {
|
||||||
|
var link;
|
||||||
|
|
||||||
|
link = $( '<a>' ).text( autonym )
|
||||||
|
.attr( {
|
||||||
|
href: '#',
|
||||||
|
'class': 'uls-prevlang-link',
|
||||||
|
lang: previousLang,
|
||||||
|
// We could get dir from uls.data,
|
||||||
|
// but we are trying to avoid loading it
|
||||||
|
// and 'auto' is safe enough in this context
|
||||||
|
dir: 'auto'
|
||||||
|
} );
|
||||||
|
|
||||||
|
// 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 );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
// The interlanguage position needs some time to settle down
|
||||||
|
window.setTimeout( function () {
|
||||||
|
// Show the tipsy tooltip on page load.
|
||||||
|
showTipsy( 6000 );
|
||||||
|
}, 700 );
|
||||||
|
|
||||||
|
// manually show the tooltip
|
||||||
|
$ulsTrigger.on( 'mouseover', function () {
|
||||||
|
// show only if the ULS panel is not shown
|
||||||
|
if ( !$( '.uls-menu:visible' ).length ) {
|
||||||
|
showTipsy( 3000 );
|
||||||
|
}
|
||||||
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
// Now that we set the previous languages,
|
||||||
|
// we can set the cookie of the previous autonym.
|
||||||
|
// TODO: Refactor this, because it doesn't directly belong
|
||||||
|
// to the tooltip.
|
||||||
|
$.cookie( mw.uls.previousLanguageAutonymCookie,
|
||||||
|
mw.config.get( 'wgULSCurrentAutonym' ),
|
||||||
|
{ path: '/' }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$( document ).ready( function () {
|
$( document ).ready( function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user