Jhernandez has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/337824 )
Change subject: Hygiene: Remove unnecessary IIFE in changeListeners/linkTitle.js
......................................................................
Hygiene: Remove unnecessary IIFE in changeListeners/linkTitle.js
Change-Id: Ifc882875475d1bd5056879c59314030a6f616daa
---
M src/changeListeners/linkTitle.js
1 file changed, 50 insertions(+), 54 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups
refs/changes/24/337824/1
diff --git a/src/changeListeners/linkTitle.js b/src/changeListeners/linkTitle.js
index bcec814..813943a 100644
--- a/src/changeListeners/linkTitle.js
+++ b/src/changeListeners/linkTitle.js
@@ -1,65 +1,61 @@
-( function ( $ ) {
+/**
+ * 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}
+ */
+module.exports = function () {
+ var title;
/**
- * Creates an instance of the link title change listener.
+ * Destroys the title attribute of the element, storing its value in
local
+ * state so that it can be restored later (see `restoreTitleAttr`).
*
- * 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}
+ * @param {Element} el
*/
- module.exports = function () {
- var title;
+ function destroyTitleAttr( el ) {
+ var $el = $( el );
- /**
- * Destroys the title attribute of the element, storing its
value in local
- * state so that it can be restored later (see
`restoreTitleAttr`).
- *
- * @param {Element} el
- */
- function destroyTitleAttr( el ) {
- var $el = $( el );
-
- // Has the user dwelled on a link? If we've already
removed its title
- // attribute, then NOOP.
- if ( title ) {
- return;
- }
-
- title = $el.attr( 'title' );
-
- $el.attr( 'title', '' );
+ // Has the user dwelled on a link? If we've already removed its
title
+ // attribute, then NOOP.
+ if ( title ) {
+ return;
}
- /**
- * Restores the title attribute of the element.
- *
- * @param {Element} el
- */
- function restoreTitleAttr( el ) {
- $( el ).attr( 'title', title );
+ title = $el.attr( 'title' );
- title = undefined;
+ $el.attr( 'title', '' );
+ }
+
+ /**
+ * Restores the title attribute of the element.
+ *
+ * @param {Element} el
+ */
+ function restoreTitleAttr( el ) {
+ $( el ).attr( 'title', title );
+
+ title = undefined;
+ }
+
+ return function ( prevState, state ) {
+ var hasPrevActiveLink = prevState &&
prevState.preview.activeLink;
+
+ if ( hasPrevActiveLink ) {
+
+ // Has the user dwelled on a link immediately after
abandoning another
+ // (remembering that the ABANDON_END action is delayed
by
+ // ~10e2 ms).
+ if ( prevState.preview.activeLink !==
state.preview.activeLink ) {
+ restoreTitleAttr( prevState.preview.activeLink
);
+ }
}
- return function ( prevState, state ) {
- var hasPrevActiveLink = prevState &&
prevState.preview.activeLink;
-
- if ( hasPrevActiveLink ) {
-
- // Has the user dwelled on a link immediately
after abandoning another
- // (remembering that the ABANDON_END action is
delayed by
- // ~10e2 ms).
- if ( prevState.preview.activeLink !==
state.preview.activeLink ) {
- restoreTitleAttr(
prevState.preview.activeLink );
- }
- }
-
- if ( state.preview.activeLink ) {
- destroyTitleAttr( state.preview.activeLink );
- }
- };
+ if ( state.preview.activeLink ) {
+ destroyTitleAttr( state.preview.activeLink );
+ }
};
-
-}( jQuery ) );
+};
--
To view, visit https://gerrit.wikimedia.org/r/337824
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc882875475d1bd5056879c59314030a6f616daa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits