Jdlrobson has uploaded a new change for review.

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

Change subject: Hygiene: Not necessary for private methods to be globally 
available
......................................................................

Hygiene: Not necessary for private methods to be globally available

These can be private methods.
They are not used by anything outside this method and should never be
allowed to.

Change-Id: I347d2ef4fd42c3bb139d5f1d30f64c9d1c45a47b
---
M resources/ext.popups.renderer/desktopRenderer.js
1 file changed, 32 insertions(+), 23 deletions(-)


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

diff --git a/resources/ext.popups.renderer/desktopRenderer.js 
b/resources/ext.popups.renderer/desktopRenderer.js
index 6def177..16a8ae1 100644
--- a/resources/ext.popups.renderer/desktopRenderer.js
+++ b/resources/ext.popups.renderer/desktopRenderer.js
@@ -141,13 +141,13 @@
                        .off( 'click', logClickAction ).on( 'click', 
logClickAction );
 
                if ( mw.popups.render.cache[ $link.attr( 'href' ) ] ) {
-                       openTimer = mw.popups.render.wait( 
mw.popups.render.POPUP_DELAY )
+                       openTimer = wait( mw.popups.render.POPUP_DELAY )
                                .done( function () {
                                        mw.popups.render.openPopup( $link, 
event );
                                } );
                } else {
                        // Wait for timer before making API queries and showing 
hovercard
-                       openTimer = mw.popups.render.wait( 
mw.popups.render.API_DELAY )
+                       openTimer = wait( mw.popups.render.API_DELAY )
                                .done( function () {
                                        var cachePopup, key,
                                                renderers = 
mw.popups.render.renderers;
@@ -166,7 +166,7 @@
                                                cachePopup = 
mw.popups.render.renderers.article.init( $link, $.extend( {}, logData ) );
                                        }
 
-                                       openTimer = mw.popups.render.wait( 
mw.popups.render.POPUP_DELAY - mw.popups.render.API_DELAY );
+                                       openTimer = wait( 
mw.popups.render.POPUP_DELAY - mw.popups.render.API_DELAY );
 
                                        $.when( openTimer, cachePopup ).done( 
function () {
                                                mw.popups.render.openPopup( 
$link, event );
@@ -200,7 +200,7 @@
                        .append( popup.clone() )
                        .show()
                        .attr( 'aria-hidden', 'false' )
-                       .on( 'mouseleave', mw.popups.render.leaveActive )
+                       .on( 'mouseleave', leaveActive )
                        .on( 'mouseenter', function () {
                                if ( closeTimer ) {
                                        closeTimer.abort();
@@ -221,24 +221,26 @@
 
                cache.process( link, $.extend( {}, logData ) );
 
-               mw.popups.$popup.find( 'a.mwe-popups-extract, 
a.mwe-popups-discreet' ).click( mw.popups.render.clickHandler );
+               mw.popups.$popup.find( 'a.mwe-popups-extract, 
a.mwe-popups-discreet' ).click( clickHandler );
 
                link
-                       .off( 'mouseleave blur', mw.popups.render.leaveInactive 
)
-                       .on( 'mouseleave blur', mw.popups.render.leaveActive );
+                       .off( 'mouseleave blur', leaveInactive )
+                       .on( 'mouseleave blur', leaveActive );
 
-               $( document ).on( 'keydown', mw.popups.render.closeOnEsc );
+               $( document ).on( 'keydown', closeOnEsc );
 
                mw.popups.incrementPreviewCount();
        };
 
        /**
+        * Event handler.
         * Click handler for the hovercard
         *
         * @method clickHandler
+        * @ignore
         * @param {Object} event
         */
-       mw.popups.render.clickHandler = function ( event ) {
+       function clickHandler( event ) {
                var action = mw.popups.getAction( event ),
                        $activeLink = getActiveLink();
 
@@ -247,7 +249,7 @@
                if ( action === 'opened in same tab' ) {
                        window.location.href = $activeLink.attr( 'href' );
                }
-       };
+       }
 
        /**
         * Removes the hover class from the link and unbinds events
@@ -259,7 +261,7 @@
                var fadeInClass, fadeOutClass,
                        $activeLink = getActiveLink();
 
-               $activeLink.off( 'mouseleave blur', 
mw.popups.render.leaveActive );
+               $activeLink.off( 'mouseleave blur', leaveActive );
 
                fadeInClass = ( mw.popups.$popup.hasClass( 
'mwe-popups-fade-in-up' ) ) ?
                        'mwe-popups-fade-in-up' :
@@ -270,11 +272,11 @@
                        'mwe-popups-fade-out-up';
 
                mw.popups.$popup
-                       .off( 'mouseleave', mw.popups.render.leaveActive )
+                       .off( 'mouseleave', leaveActive )
                        .removeClass( fadeInClass )
                        .addClass( fadeOutClass );
 
-               mw.popups.render.wait( 150 ).done( function () {
+               wait( 150 ).done( function () {
                        if ( mw.popups.$popup.hasClass( fadeOutClass ) ) {
                                mw.popups.$popup
                                        .attr( 'aria-hidden', 'true' )
@@ -301,10 +303,11 @@
         * to perform the equivalent of `clearTimeout()`
         *
         * @method wait
+        * @ignore
         * @param {number} ms Milliseconds to wait
         * @return {jQuery.Promise}
         */
-       mw.popups.render.wait = function ( ms ) {
+       function wait( ms ) {
                var deferred, promise, timeout;
 
                deferred = $.Deferred();
@@ -319,42 +322,48 @@
                } } );
 
                return promise;
-       };
+       }
 
        /**
+        * Event handler.
         * Use escape to close popup
         *
+        * @ignore
         * @method closeOnEsc
         */
-       mw.popups.render.closeOnEsc = function ( event ) {
+       function closeOnEsc( event ) {
                var $activeLink = getActiveLink();
                if ( event.keyCode === 27 && $activeLink ) {
                        mw.popups.render.closePopup();
                }
-       };
+       }
 
        /**
+        * Event handler.
         * Closes the box after a delay
         * Delay to give enough time for the user to move the pointer from
         * the link to the popup box. Also avoids closing the popup by accident
         *
+        * @ignore
         * @method leaveActive
         */
-       mw.popups.render.leaveActive = function () {
-               closeTimer = mw.popups.render.wait( 
mw.popups.render.POPUP_CLOSE_DELAY ).done( function () {
+       function leaveActive() {
+               closeTimer = wait( mw.popups.render.POPUP_CLOSE_DELAY ).done( 
function () {
                        var $activeLink = getActiveLink();
                        if ( $activeLink ) {
                                mw.popups.render.closePopup();
                        }
                } );
-       };
+       }
 
        /**
+        * Event handler.
         * Unbinds events on the anchor tag and aborts AJAX request.
         *
+        * @ignore
         * @method leaveInactive
         */
-       mw.popups.render.leaveInactive = function () {
+       function leaveInactive() {
                var $activeLink = getActiveLink();
 
                if ( logData.dwellStartTime &&
@@ -367,14 +376,14 @@
                        } ) );
                }
                // TODO: should `blur` also be here?
-               $activeLink.off( 'mouseleave', mw.popups.render.leaveInactive );
+               $activeLink.off( 'mouseleave', leaveInactive );
                if ( openTimer ) {
                        openTimer.abort();
                }
                mw.popups.render.abortCurrentRequest();
 
                mw.popups.render.reset();
-       };
+       }
 
        /**
         * Resets the renderer

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I347d2ef4fd42c3bb139d5f1d30f64c9d1c45a47b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

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

Reply via email to