From 9974a75b509cbf707537dafc201358af5ef48b6d Mon Sep 17 00:00:00 2001 From: se4598 Date: Tue, 24 Feb 2015 18:19:43 +0100 Subject: [PATCH] Improve mw.popups.selectPopupElements Use proven technology to create and compare URLs. This will display popups also on anchored links again. Change-Id: Ic010ca027017435f666782e709e641cf3bbb8767 --- Popups.hooks.php | 1 + resources/ext.popups.core.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Popups.hooks.php b/Popups.hooks.php index 669922d06..5880f34a8 100644 --- a/Popups.hooks.php +++ b/Popups.hooks.php @@ -53,6 +53,7 @@ class PopupsHooks { $moduleDependencies = array( 'mediawiki.api', 'mediawiki.jqueryMsg', + 'mediawiki.Uri', 'moment', 'jquery.jStorage', 'jquery.client', diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js index fbb5b6bcf..dbb454f2d 100644 --- a/resources/ext.popups.core.js +++ b/resources/ext.popups.core.js @@ -154,7 +154,12 @@ return mw.popups.$content .find( 'a[href][title]:not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')' ) .filter( function () { - return ( this.href.replace(/^https?:\/\//,'//') === ( mw.config.get( 'wgServer' ) + mw.util.getUrl( this.title ) ).replace(/^https?:\/\//,'//') ); + var linkHref = new mw.Uri( this.href ), + expectedHref = new mw.Uri( mw.util.getUrl( this.title ) ); + + // don't compare fragment to display popups on anchored page links + linkHref.fragment = undefined; + return linkHref.toString() === expectedHref.toString(); } ); };