TheDJ has uploaded a new change for review. https://gerrit.wikimedia.org/r/134266
Change subject: Popups: Only run the selector for the a elements once ...................................................................... Popups: Only run the selector for the a elements once It's a complicated query, we should not repeat it if not necessary Change-Id: I71d47de088afa7dab0a6eaed214c61db699fcd0c --- M resources/ext.popups.core.js 1 file changed, 14 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups refs/changes/66/134266/1 diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js index a209cc2..873ec2e 100644 --- a/resources/ext.popups.core.js +++ b/resources/ext.popups.core.js @@ -89,9 +89,8 @@ * * @method removeTooltips */ - mw.popups.removeTooltips = function () { - var notSelector = ':not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')'; - mw.popups.$content.find( 'a' + notSelector + ':not([title=""])' ) + mw.popups.removeTooltips = function ( $elements ) { + $elements .on( 'mouseenter focus', function () { $( this ) .data( 'title', $( this ).attr( 'title' ) ) @@ -123,10 +122,8 @@ * * @method setupTriggers */ - mw.popups.setupTriggers = function () { - var notSelector = ':not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')'; - - mw.popups.$content.find( 'a' + notSelector + ':not([title=""])' ).on( 'mouseenter focus', function ( event ) { + mw.popups.setupTriggers = function ( $elements ) { + $elements.on( 'mouseenter focus', function ( event ) { var $this = $( this ), href = $this.attr( 'href' ); @@ -143,10 +140,18 @@ } ); }; + function selectPopupElements() { + var notSelector = ':not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')'; + + return mw.popups.$content.find( 'a' + notSelector + ':not([title=""])' ); + } + mw.hook( 'wikipage.content').add( function ( $content ) { mw.popups.$content = $content; - mw.popups.removeTooltips(); - mw.popups.setupTriggers(); + + var $elements = selectPopupElements(); + mw.popups.removeTooltips( $elements ); + mw.popups.setupTriggers( $elements ); } ); $( function () { -- To view, visit https://gerrit.wikimedia.org/r/134266 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I71d47de088afa7dab0a6eaed214c61db699fcd0c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Popups Gerrit-Branch: master Gerrit-Owner: TheDJ <hartman.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits