mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2025-01-07 19:54:13 +00:00
089ee014ad
Supporting changes: * Remove the preview.previousActiveLink property from the state tree as it's unnecessary. Change-Id: I657decf9425a7a9e2b27a798ed60b162569661d8
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 ) );
|