Merge "Make the previous language link work"

This commit is contained in:
Nikerabbit
2012-10-02 07:28:34 +00:00
committed by Gerrit Code Review

View File

@@ -160,7 +160,6 @@
return true; return true;
} }
var tipsyTimer;
previousLanguages.push( currentLang ); previousLanguages.push( currentLang );
mw.uls.setPreviousLanguages( previousLanguages ); mw.uls.setPreviousLanguages( previousLanguages );
// Attach a tipsy tooltip to the trigger // Attach a tipsy tooltip to the trigger
@@ -172,7 +171,7 @@
trigger: 'manual', trigger: 'manual',
title: function () { title: function () {
var prevLangName = $.uls.data.autonym( previousLang ); var prevLangName = $.uls.data.autonym( previousLang );
var linkClass = 'uls-lang-link'; var linkClass = 'uls-prevlang-link';
var prevLangLink = "<a href='#' lang = '" + var prevLangLink = "<a href='#' lang = '" +
previousLang + "' class = '" + linkClass + "' >" + previousLang + "' class = '" + linkClass + "' >" +
prevLangName + "</a>"; prevLangName + "</a>";
@@ -180,37 +179,42 @@
return title; return title;
} }
} ); } );
// Show the tipsy tooltip on page load.
$ulsTrigger.tipsy( 'show' );
tipsyTimer = window.setTimeout( function () {
$ulsTrigger.tipsy( 'hide' );
},
// The timeout after page reloading is longer,
// to give the user a better chance to see it.
6000
);
// manually show the tooltip function showTipsy( timeout ) {
$ulsTrigger.on( 'mouseover', function ( e ) { var tipsyTimer;
$( this ).tipsy( 'show' ); $ulsTrigger.tipsy( 'show' );
// if the mouse is over the tooltip, do not hide // if the mouse is over the tooltip, do not hide
$( '.tipsy' ).on( 'mouseover', function ( e ) { $( '.tipsy' ).on( 'mouseover', function ( e ) {
window.clearTimeout( tipsyTimer ); window.clearTimeout( tipsyTimer );
} ); } );
$( '.tipsy' ).on( 'mouseout', function ( e ) { $( '.tipsy' ).on( 'mouseout', function ( e ) {
tipsyTimer = window.setTimeout( function () { tipsyTimer = window.setTimeout( function () {
$ulsTrigger.tipsy( 'hide' ); hideTipsy();
}, 3000 // hide the link in 3 seconds }, timeout );
);
} ); } );
// Event handler for links in the tooltip
$( 'a.uls-prevlang-link' ).on( 'click', function () {
mw.uls.changeLanguage( $( this ).attr( 'lang' ) );
} );
tipsyTimer = window.setTimeout( function () {
hideTipsy();
}, timeout );
}
function hideTipsy() {
$ulsTrigger.tipsy( 'hide' );
}
// Show the tipsy tooltip on page load.
showTipsy( 6000 );
// manually show the tooltip
$ulsTrigger.on( 'mouseover', function ( e ) {
showTipsy( 3000 );
} ); } );
// hide the tooltip when clicked on uls trigger // hide the tooltip when clicked on uls trigger
$ulsTrigger.on( 'click', function ( e ) { $ulsTrigger.on( 'click', function ( e ) {
$( this ).tipsy( 'hide' ); hideTipsy();
} );
// Event handler for links in the tooltip
$( 'a.uls-lang-link' ).on( 'click', function () {
mw.uls.changeLanguage( $( this ).attr( 'lang' ) );
} ); } );
} ); } );
}( jQuery, mediaWiki, window, document ) ); }( jQuery, mediaWiki, window, document ) );