mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-28 01:50:09 +00:00
Merge "Remove delay when logging link clicks"
This commit is contained in:
commit
fcd2317bf4
|
@ -73,15 +73,13 @@
|
||||||
* @param {jQuery} $container
|
* @param {jQuery} $container
|
||||||
*/
|
*/
|
||||||
DP.createDownloadButton = function ( $container ) {
|
DP.createDownloadButton = function ( $container ) {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
// TODO: Use oojs-ui constructive button widget instead
|
// TODO: Use oojs-ui constructive button widget instead
|
||||||
this.$downloadButton = $( '<a>' )
|
this.$downloadButton = $( '<a>' )
|
||||||
.attr( 'target', '_blank' )
|
.attr( 'target', '_blank' )
|
||||||
.attr( 'download', '' )
|
.attr( 'download', '' )
|
||||||
.addClass( 'mw-ui-button mw-ui-constructive mw-mmv-download-go-button' )
|
.addClass( 'mw-ui-button mw-ui-constructive mw-mmv-download-go-button' )
|
||||||
.click( function ( e ) {
|
.click( function () {
|
||||||
self.trackLinkClick.call( this, 'download', e );
|
mw.mmv.actionLogger.log( 'download' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
this.$selectionArrow = $( '<span>' )
|
this.$selectionArrow = $( '<span>' )
|
||||||
|
@ -127,15 +125,13 @@
|
||||||
* @param {jQuery} $container
|
* @param {jQuery} $container
|
||||||
*/
|
*/
|
||||||
DP.createPreviewLink = function ( $container ) {
|
DP.createPreviewLink = function ( $container ) {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.$previewLink = $( '<a>' )
|
this.$previewLink = $( '<a>' )
|
||||||
.attr( 'target', '_blank' )
|
.attr( 'target', '_blank' )
|
||||||
.addClass( 'mw-mmv-download-preview-link' )
|
.addClass( 'mw-mmv-download-preview-link' )
|
||||||
.text( mw.message( 'multimediaviewer-download-preview-link-title' ).text() )
|
.text( mw.message( 'multimediaviewer-download-preview-link-title' ).text() )
|
||||||
.appendTo( $container )
|
.appendTo( $container )
|
||||||
.click( function ( e ) {
|
.click( function () {
|
||||||
self.trackLinkClick.call( this, 'download-view-in-browser', e );
|
mw.mmv.actionLogger.log( 'download-view-in-browser' );
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -195,30 +195,6 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Tracks a click on a link and lets the user navigate to it
|
|
||||||
* @param {string} action The action label to log.
|
|
||||||
* @param {jQuery.Event} e Click event object
|
|
||||||
*/
|
|
||||||
EP.trackLinkClick = function ( action, e ) {
|
|
||||||
var $link = $( this );
|
|
||||||
|
|
||||||
if ( e.altKey || e.shiftKey || e.ctrlKey || e.metaKey || e.button === 1 ) {
|
|
||||||
// They are likely opening the link in a new window or tab
|
|
||||||
mw.mmv.actionLogger.log( action );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it's a plain click, we need to wait for the logging to
|
|
||||||
// be done before navigating to the desired page
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
// We want to redirect anyway, whether logging worked or not
|
|
||||||
mw.mmv.actionLogger.log( action ).always( function () {
|
|
||||||
window.location.href = $link.prop( 'href' );
|
|
||||||
} );
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the entire input/textarea selected when focused.
|
* Makes the entire input/textarea selected when focused.
|
||||||
* Invoked with that input/textarea as context.
|
* Invoked with that input/textarea as context.
|
||||||
|
|
|
@ -253,23 +253,21 @@
|
||||||
* Initializes the credit elements.
|
* Initializes the credit elements.
|
||||||
*/
|
*/
|
||||||
MPP.initializeCredit = function () {
|
MPP.initializeCredit = function () {
|
||||||
var panel = this;
|
|
||||||
|
|
||||||
this.$credit = $( '<p>' )
|
this.$credit = $( '<p>' )
|
||||||
.addClass( 'mw-mmv-credit empty' )
|
.addClass( 'mw-mmv-credit empty' )
|
||||||
.appendTo( this.$imageMetadataLeft )
|
.appendTo( this.$imageMetadataLeft )
|
||||||
.on( 'click.mmv-mp', '.mw-mmv-credit-fallback', function ( e ) {
|
.on( 'click.mmv-mp', '.mw-mmv-credit-fallback', function () {
|
||||||
panel.trackLinkClick( this, 'author-page', e );
|
mw.mmv.actionLogger.log( 'author-page' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// we need an inline container for tipsy, otherwise it would be centered weirdly
|
// we need an inline container for tipsy, otherwise it would be centered weirdly
|
||||||
this.$authorAndSource = $( '<span>' )
|
this.$authorAndSource = $( '<span>' )
|
||||||
.addClass( 'mw-mmv-source-author' )
|
.addClass( 'mw-mmv-source-author' )
|
||||||
.on( 'click', '.mw-mmv-author a', function ( e ) {
|
.on( 'click', '.mw-mmv-author a', function () {
|
||||||
panel.trackLinkClick.call( this, 'author-page', e );
|
mw.mmv.actionLogger.log( 'author-page' );
|
||||||
} )
|
} )
|
||||||
.on( 'click', '.mw-mmv-source a', function ( e ) {
|
.on( 'click', '.mw-mmv-source a', function () {
|
||||||
panel.trackLinkClick.call( this, 'source-page', e );
|
mw.mmv.actionLogger.log( 'source-page' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
@ -323,8 +321,8 @@
|
||||||
.addClass( 'mw-mmv-license' )
|
.addClass( 'mw-mmv-license' )
|
||||||
.prop( 'href', '#' )
|
.prop( 'href', '#' )
|
||||||
.appendTo( this.$licenseLi )
|
.appendTo( this.$licenseLi )
|
||||||
.on( 'click', function ( e ) {
|
.on( 'click', function () {
|
||||||
panel.trackLinkClick.call( this, 'license-page', e );
|
mw.mmv.actionLogger.log( 'license-page' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
this.$restrictions = $( '<span>' )
|
this.$restrictions = $( '<span>' )
|
||||||
|
@ -391,8 +389,6 @@
|
||||||
* Initializes the link to the uploader's file page.
|
* Initializes the link to the uploader's file page.
|
||||||
*/
|
*/
|
||||||
MPP.initializeUploader = function () {
|
MPP.initializeUploader = function () {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.$usernameLi = $( '<li>' )
|
this.$usernameLi = $( '<li>' )
|
||||||
.addClass( 'mw-mmv-username-li empty' )
|
.addClass( 'mw-mmv-username-li empty' )
|
||||||
.appendTo( this.$imageLinks );
|
.appendTo( this.$imageLinks );
|
||||||
|
@ -401,15 +397,13 @@
|
||||||
.addClass( 'mw-mmv-username' )
|
.addClass( 'mw-mmv-username' )
|
||||||
.prop( 'href', '#' )
|
.prop( 'href', '#' )
|
||||||
.appendTo( this.$usernameLi )
|
.appendTo( this.$usernameLi )
|
||||||
.click( function ( e ) { self.trackLinkClick.call( this, 'uploader-page', e ); } );
|
.click( function () { mw.mmv.actionLogger.log( 'uploader-page' ); } );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the geolocation element.
|
* Initializes the geolocation element.
|
||||||
*/
|
*/
|
||||||
MPP.initializeLocation = function () {
|
MPP.initializeLocation = function () {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.$locationLi = $( '<li>' )
|
this.$locationLi = $( '<li>' )
|
||||||
.addClass( 'mw-mmv-location-li empty' )
|
.addClass( 'mw-mmv-location-li empty' )
|
||||||
.appendTo( this.$imageLinks );
|
.appendTo( this.$imageLinks );
|
||||||
|
@ -417,33 +411,32 @@
|
||||||
this.$location = $( '<a>' )
|
this.$location = $( '<a>' )
|
||||||
.addClass( 'mw-mmv-location' )
|
.addClass( 'mw-mmv-location' )
|
||||||
.appendTo( this.$locationLi )
|
.appendTo( this.$locationLi )
|
||||||
.click( function ( e ) { self.trackLinkClick.call( this, 'location-page', e ); } );
|
.click( function () { mw.mmv.actionLogger.log( 'location-page' ); } );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes two about links at the bottom of the panel.
|
* Initializes two about links at the bottom of the panel.
|
||||||
*/
|
*/
|
||||||
MPP.initializeAboutLinks = function () {
|
MPP.initializeAboutLinks = function () {
|
||||||
var separator = ' | ',
|
var separator = ' | ';
|
||||||
self = this;
|
|
||||||
|
|
||||||
this.$mmvAboutLink = $( '<a>' )
|
this.$mmvAboutLink = $( '<a>' )
|
||||||
.prop( 'href', mw.config.get( 'wgMultimediaViewer' ).infoLink )
|
.prop( 'href', mw.config.get( 'wgMultimediaViewer' ).infoLink )
|
||||||
.text( mw.message( 'multimediaviewer-about-mmv' ).text() )
|
.text( mw.message( 'multimediaviewer-about-mmv' ).text() )
|
||||||
.addClass( 'mw-mmv-about-link' )
|
.addClass( 'mw-mmv-about-link' )
|
||||||
.click( function ( e ) { self.trackLinkClick.call( this, 'about-page', e ); } );
|
.click( function () { mw.mmv.actionLogger.log( 'about-page' ); } );
|
||||||
|
|
||||||
this.$mmvDiscussLink = $( '<a>' )
|
this.$mmvDiscussLink = $( '<a>' )
|
||||||
.prop( 'href', mw.config.get( 'wgMultimediaViewer' ).discussionLink )
|
.prop( 'href', mw.config.get( 'wgMultimediaViewer' ).discussionLink )
|
||||||
.text( mw.message( 'multimediaviewer-discuss-mmv' ).text() )
|
.text( mw.message( 'multimediaviewer-discuss-mmv' ).text() )
|
||||||
.addClass( 'mw-mmv-discuss-link' )
|
.addClass( 'mw-mmv-discuss-link' )
|
||||||
.click( function ( e ) { self.trackLinkClick.call( this, 'discuss-page', e ); } );
|
.click( function () { mw.mmv.actionLogger.log( 'discuss-page' ); } );
|
||||||
|
|
||||||
this.$mmvHelpLink = $( '<a>' )
|
this.$mmvHelpLink = $( '<a>' )
|
||||||
.prop( 'href', mw.config.get( 'wgMultimediaViewer' ).helpLink )
|
.prop( 'href', mw.config.get( 'wgMultimediaViewer' ).helpLink )
|
||||||
.text( mw.message( 'multimediaviewer-help-mmv' ).text() )
|
.text( mw.message( 'multimediaviewer-help-mmv' ).text() )
|
||||||
.addClass( 'mw-mmv-help-link' )
|
.addClass( 'mw-mmv-help-link' )
|
||||||
.click( function ( e ) { self.trackLinkClick.call( this, 'help-page', e ); } );
|
.click( function () { mw.mmv.actionLogger.log( 'help-page' ); } );
|
||||||
|
|
||||||
this.$mmvAboutLinks = $( '<div>' )
|
this.$mmvAboutLinks = $( '<div>' )
|
||||||
.addClass( 'mw-mmv-about-links' )
|
.addClass( 'mw-mmv-about-links' )
|
||||||
|
|
|
@ -39,8 +39,6 @@
|
||||||
SP = Share.prototype;
|
SP = Share.prototype;
|
||||||
|
|
||||||
SP.init = function () {
|
SP.init = function () {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.$pane.addClass( 'mw-mmv-share-pane' )
|
this.$pane.addClass( 'mw-mmv-share-pane' )
|
||||||
.appendTo( this.$container );
|
.appendTo( this.$container );
|
||||||
|
|
||||||
|
@ -63,8 +61,8 @@
|
||||||
.prop( 'target', '_blank' )
|
.prop( 'target', '_blank' )
|
||||||
.html( ' ' )
|
.html( ' ' )
|
||||||
.appendTo( this.$pane )
|
.appendTo( this.$pane )
|
||||||
.click( function ( e ) {
|
.click( function () {
|
||||||
self.trackLinkClick.call( this, 'share-page', e );
|
mw.mmv.actionLogger.log( 'share-page' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
this.pageInput.$element.appendTo( this.$pane );
|
this.pageInput.$element.appendTo( this.$pane );
|
||||||
|
|
|
@ -363,13 +363,11 @@
|
||||||
* @param {jQuery} $div The panel to which we're adding the link.
|
* @param {jQuery} $div The panel to which we're adding the link.
|
||||||
*/
|
*/
|
||||||
ODP.addInfoLink = function ( $div, eventName ) {
|
ODP.addInfoLink = function ( $div, eventName ) {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
$( '<a>' )
|
$( '<a>' )
|
||||||
.addClass( 'mw-mmv-project-info-link' )
|
.addClass( 'mw-mmv-project-info-link' )
|
||||||
.prop( 'href', mw.config.get( 'wgMultimediaViewer' ).helpLink )
|
.prop( 'href', mw.config.get( 'wgMultimediaViewer' ).helpLink )
|
||||||
.text( mw.message( 'multimediaviewer-options-learn-more' ) )
|
.text( mw.message( 'multimediaviewer-options-learn-more' ) )
|
||||||
.click( function ( e ) { self.trackLinkClick.call( this, eventName, e ); } )
|
.click( function () { mw.mmv.actionLogger.log( eventName ); } )
|
||||||
.appendTo( $div.find( '.mw-mmv-options-text' ) );
|
.appendTo( $div.find( '.mw-mmv-options-text' ) );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue