Mattflaschen has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/379466 )
Change subject: Simplify link logging for target=_blank
......................................................................
Simplify link logging for target=_blank
We still use the promises (it doesn't hurt anything), but we just
let the link navigation proceed normally if they are using a new
window.
Bug: T169613
Change-Id: I9d1e1ad3b2597e9a1af7e43ce9a14df05bcdbded
---
M modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js
1 file changed, 17 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GuidedTour
refs/changes/66/379466/1
diff --git a/modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js
b/modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js
index a7d085b..cab663b 100644
--- a/modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js
+++ b/modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js
@@ -709,11 +709,18 @@
*/
Step.prototype.handleLinkClick = function ( jQueryEvent ) {
var activationEvent, buttonEvent, isExternal, labelKey,
loggingOverDfd,
- logPromises = [], $link = $( jQueryEvent.currentTarget
),
+ isNewWindow, logPromises = [],
+ $link = $( jQueryEvent.currentTarget ),
url = $link.attr( 'href' ), label = $link.text(),
LOGGING_TIMEOUT_MS = 500;
- jQueryEvent.preventDefault();
+ // If it's a new window, we don't need to delay the user,
+ // or worry about delaying them too much.
+ isNewWindow = ( $link.attr( 'target' ) === '_blank' );
+
+ if ( !isNewWindow ) {
+ jQueryEvent.preventDefault();
+ }
activationEvent = {
label: label
@@ -728,7 +735,9 @@
// https://bugzilla.wikimedia.org/show_bug.cgi?id=52287
loggingOverDfd = $.Deferred();
- window.setTimeout( loggingOverDfd.reject, LOGGING_TIMEOUT_MS );
+ if ( !isNewWindow ) {
+ window.setTimeout( loggingOverDfd.reject,
LOGGING_TIMEOUT_MS );
+ }
if ( isExternal ) {
activationEvent.href = url;
@@ -761,9 +770,11 @@
$.when.apply( $, logPromises ).then( loggingOverDfd.resolve,
loggingOverDfd.reject );
- loggingOverDfd.always( function () {
- window.location = url;
- } );
+ if ( !isNewWindow ) {
+ loggingOverDfd.always( function () {
+ window.location = url;
+ } );
+ }
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/379466
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d1e1ad3b2597e9a1af7e43ce9a14df05bcdbded
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GuidedTour
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits