Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/241613
Change subject: Set absolute URLs for source links ...................................................................... Set absolute URLs for source links Set absolute URLs for source link's href attributes so that the links point to correct wiki instead of relative URL to current wiki. Bug: T113880 Change-Id: I860a239a0c49d2f98acfc86acbc64e1d3d9e9005 --- M modules/source/ext.cx.source.js 1 file changed, 14 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/13/241613/1 diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js index 3ce0ec3..7c5e479 100644 --- a/modules/source/ext.cx.source.js +++ b/modules/source/ext.cx.source.js @@ -153,12 +153,12 @@ this.$content = $( '<div>' ) .addClass( 'cx-column__content' ); - this.$container.append( this.$title, $subHeading, this.$content ); this.showLoadingIndicator(); }; ContentTranslationSource.prototype.load = function ( content ) { + var self = this; this.$content.html( content.segmentedContent ); // @todo figure out what should be done here @@ -171,6 +171,17 @@ } catch ( e ) { mw.log( 'Could not load ext.cite.style, References will fallback to default style' ); } + + // Set absolute URLs for source links href attributes so that the links + // point to correct wiki instead of relative URL to current wiki. + this.$content.find( 'a[rel="mw:WikiLink"]' ).each( function () { + var url, $link = $( this ); + + url = self.siteMapper.getPageUrl( + mw.cx.sourceLanguage, cleanupLinkHref( $link.attr( 'href' ) ) + ); + $link.attr( 'href', url ); + } ); }; /** @@ -224,8 +235,6 @@ }; ContentTranslationSource.prototype.listen = function () { - var self = this; - mw.hook( 'mw.cx.source.loaded' ).add( $.proxy( this.load, this ) ); // Apply source filter plugin to the content this.$content.cxFilterSource(); @@ -237,17 +246,11 @@ } ); this.$content.on( 'click', 'a', function ( e ) { - var url, - $link = $( this ); + var $link = $( this ); // Allow link exploration if ( e.shiftKey || e.ctrlKey ) { - url = self.siteMapper.getPageUrl( - mw.cx.sourceLanguage, cleanupLinkHref( $link.attr( 'href' ) ) - ); - window.open( url, '_blank' ); - - return false; + return true; } // Avoid all reference links -- To view, visit https://gerrit.wikimedia.org/r/241613 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I860a239a0c49d2f98acfc86acbc64e1d3d9e9005 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits