Prtksxna has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/160234

Change subject: core: Refactor selectPopupElements
......................................................................

core: Refactor selectPopupElements

The 'removeTooltips' method was adding another filter over
the selected $elements. This caused some tooltips to be
unnecessarily removed. This change moves all the selection
to a single function.

Change-Id: I0a91ba5198eceaba5de9eb1b47df4b815f4d259a
---
M resources/ext.popups.core.js
1 file changed, 22 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/34/160234/1

diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index 653b9aa..20d2a3f 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -97,25 +97,6 @@
        };
 
        /**
-        * Temorarily remove tooltips from links on hover
-        *
-        * @method removeTooltips
-        */
-       mw.popups.removeTooltips = function ( $elements ) {
-               $elements
-                       .filter( '[title]:not([title=""])' )
-                       .on( 'mouseenter focus', function () {
-                               $( this )
-                                       .data( 'title', $( this ).attr( 'title' 
) )
-                                       .attr( 'title', '' );
-                       } )
-                       .on( 'mouseleave blur', function () {
-                               $( this )
-                                       .attr( 'title', $( this ).data( 'title' 
) );
-                       } );
-       };
-
-       /**
         * Checks if the user is scrolling, sets to false on mousemove
         *
         * @method checkScroll
@@ -128,6 +109,24 @@
                $( window ).on( 'mousemove', function () {
                        mw.popups.scrolled = false;
                } );
+       };
+
+       /**
+        * Temorarily remove tooltips from links on hover
+        *
+        * @method removeTooltips
+        */
+       mw.popups.removeTooltips = function ( $elements ) {
+               $elements
+                       .on( 'mouseenter focus', function () {
+                               $( this )
+                                       .data( 'title', $( this ).attr( 'title' 
) )
+                                       .attr( 'title', '' );
+                       } )
+                       .on( 'mouseleave blur', function () {
+                               $( this )
+                                       .attr( 'title', $( this ).data( 'title' 
) );
+                       } );
        };
 
        /**
@@ -148,7 +147,6 @@
                                href.indexOf( 'javascript:' ) === 0 || // 
jshint ignore:line
                                href.indexOf( location.origin + 
location.pathname + '#' ) === 0
                        ) {
-                               // TODO No popup for this, but removeTooltips() 
has already blanked the title.
                                return;
                        }
 
@@ -162,7 +160,10 @@
         * @method selectPopupElements
         */
        mw.popups.selectPopupElements = function () {
-               return mw.popups.$content.find( 'a:not(' + 
mw.popups.IGNORE_CLASSES.join(', ') + ')' );
+               return mw.popups.$content
+                       .find( 'a' )
+                       .not( mw.popups.IGNORE_CLASSES.join( ', ' ) )
+                       .filter( '[title]:not([title=""])' );
        };
 
        mw.hook( 'wikipage.content').add( function ( $content ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/160234
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a91ba5198eceaba5de9eb1b47df4b815f4d259a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <psax...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to