Prtksxna has uploaded a new change for review. https://gerrit.wikimedia.org/r/199828
Change subject: Implement the new schema for when the popups are disabled ...................................................................... Implement the new schema for when the popups are disabled Bug: T88167 Change-Id: If8f1c97379bd37958ec6064242bdebf5fde14b47 --- M resources/ext.popups.core.js M resources/ext.popups.logger.js 2 files changed, 34 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups refs/changes/28/199828/1 diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js index dbb454f..fa4a26e 100644 --- a/resources/ext.popups.core.js +++ b/resources/ext.popups.core.js @@ -164,12 +164,39 @@ }; mw.hook( 'wikipage.content').add( function ( $content ) { - if ( mw.popups.enabled ) { - mw.popups.$content = $content; + mw.popups.$content = $content; + var $elements = mw.popups.selectPopupElements(); - var $elements = mw.popups.selectPopupElements(); + if ( mw.popups.enabled ) { mw.popups.removeTooltips( $elements ); mw.popups.setupTriggers( $elements ); + } else { + // Events are logged even when Hovercards are disabled + // See T88166 for details + $elements.on( 'click', function ( event ) { + if ( mw.popups.logger === undefined ) { + return true; + } + + var + $this = $( this ), + href = $this.attr( 'href' ), + action = mw.popups.logger.getAction( event ), + logEvent = { + pageTitleHover: $this.attr( 'title' ), + pageTitleSource: mw.config.get( 'wgTitle' ), + popupEnabled: mw.popups.enabled, + action: action + }, + logPromise = mw.popups.logger.log( logEvent ); + + if ( action === 'opened in same tab' ) { + event.preventDefault(); + logPromise.then( function () { + window.location.href = href; + } ); + } + } ); } } ); diff --git a/resources/ext.popups.logger.js b/resources/ext.popups.logger.js index e2b3ef2..c24fce4 100644 --- a/resources/ext.popups.logger.js +++ b/resources/ext.popups.logger.js @@ -40,8 +40,10 @@ } // Get duration from time - event.duration = Math.floor( mw.now() - event.time ); - delete event.time; + if ( event.time !== undefined ) { + event.duration = Math.floor( mw.now() - event.time ); + delete event.time; + } return mw.eventLog.logEvent( 'Popups', event ); }; -- To view, visit https://gerrit.wikimedia.org/r/199828 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If8f1c97379bd37958ec6064242bdebf5fde14b47 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