mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2025-01-08 12:14:14 +00:00
37 lines
916 B
JavaScript
37 lines
916 B
JavaScript
|
( function ( mw, $ ) {
|
||
|
|
||
|
/**
|
||
|
* Creates an instance of the link title change listener.
|
||
|
*
|
||
|
* While the user dwells on a link, then it becomes the active link. The
|
||
|
* change listener will remove a link's `title` attribute while it's the
|
||
|
* active link.
|
||
|
*
|
||
|
* @return {ext.popups.ChangeListener}
|
||
|
*/
|
||
|
mw.popups.changeListeners.linkTitle = function () {
|
||
|
var title;
|
||
|
|
||
|
return function ( prevState, state ) {
|
||
|
var $link;
|
||
|
|
||
|
// Has the user dwelled on a link? If we've already removed its title
|
||
|
// attribute, then NOOP.
|
||
|
if ( state.preview.activeLink && !title ) {
|
||
|
$link = $( state.preview.activeLink );
|
||
|
|
||
|
title = $link.attr( 'title' );
|
||
|
|
||
|
$link.attr( 'title', '' );
|
||
|
|
||
|
// Has the user abandoned the link?
|
||
|
} else if ( prevState && prevState.preview.activeLink ) {
|
||
|
$( prevState.preview.activeLink ).attr( 'title', title );
|
||
|
|
||
|
title = undefined;
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
|
||
|
}( mediaWiki, jQuery ) );
|