Jdlrobson has uploaded a new change for review. https://gerrit.wikimedia.org/r/315582
Change subject: Event handlers should not be exposed globally ...................................................................... Event handlers should not be exposed globally Bug: T147306 Change-Id: Ib0bae3e7c2e420a4b717391d4a25473a3a9f9128 --- M resources/ext.popups.renderer/desktopRenderer.js 1 file changed, 24 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups refs/changes/82/315582/1 diff --git a/resources/ext.popups.renderer/desktopRenderer.js b/resources/ext.popups.renderer/desktopRenderer.js index c7e599a..0907d3e 100644 --- a/resources/ext.popups.renderer/desktopRenderer.js +++ b/resources/ext.popups.renderer/desktopRenderer.js @@ -148,9 +148,9 @@ }; $link - .on( 'mouseleave blur', mw.popups.render.leaveInactive ) - .off( 'click', mw.popups.render.clickHandler ) - .on( 'click', mw.popups.render.clickHandler ); + .on( 'mouseleave blur', leaveInactive ) + .off( 'click', clickHandler ) + .on( 'click', clickHandler ); if ( mw.popups.render.cache[ $link.attr( 'href' ) ] ) { openTimer = mw.popups.render.wait( mw.popups.render.POPUP_DELAY ) @@ -212,7 +212,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(); @@ -233,13 +233,13 @@ 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(); }; @@ -248,9 +248,10 @@ * 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(); @@ -262,7 +263,7 @@ // close the popup mw.popups.render.closePopup(); - }; + } /** * Removes the hover class from the link and unbinds events @@ -275,7 +276,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' : @@ -286,7 +287,7 @@ 'mwe-popups-fade-out-up'; mw.popups.$popup - .off( 'mouseleave', mw.popups.render.leaveActive ) + .off( 'mouseleave', leaveActive ) .removeClass( fadeInClass ) .addClass( fadeOutClass ); @@ -303,7 +304,7 @@ closeTimer.abort(); } - $( document ).off( 'keydown', mw.popups.render.closeOnEsc ); + $( document ).off( 'keydown', closeOnEsc ); if ( $.isFunction( logCallback ) ) { logCallback(); @@ -341,8 +342,10 @@ * Use escape to close popup * * @method closeOnEsc + * @ignore + * @param {jQuery.Event} event */ - mw.popups.render.closeOnEsc = function ( event ) { + function closeOnEsc( event ) { var $activeLink = getActiveLink(); if ( event.keyCode === 27 && $activeLink ) { mw.popups.render.closePopup( logDismissAction ); @@ -355,22 +358,24 @@ * the link to the popup box. Also avoids closing the popup by accident * * @method leaveActive + * @ignore */ - mw.popups.render.leaveActive = function () { + function leaveActive() { closeTimer = mw.popups.render.wait( mw.popups.render.POPUP_CLOSE_DELAY ).done( function () { var $activeLink = getActiveLink(); if ( $activeLink ) { mw.popups.render.closePopup( logDismissAction ); } } ); - }; + } /** * Unbinds events on the anchor tag and aborts AJAX request. * * @method leaveInactive + * @ignore */ - mw.popups.render.leaveInactive = function () { + function leaveInactive() { var $activeLink = getActiveLink(); if ( logData.dwellStartTime && @@ -383,14 +388,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/315582 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib0bae3e7c2e420a4b717391d4a25473a3a9f9128 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