Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137869

Change subject: Allow exploring the links in source article as well.
......................................................................

Allow exploring the links in source article as well.

Change-Id: Ia6f3f0087f0cb4cfc2e3e773aa95c1c680827271
---
M modules/source/ext.cx.source.js
M modules/tools/ext.cx.tools.link.js
2 files changed, 22 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/69/137869/1

diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index 32cc7bf..20cc248 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -111,6 +111,12 @@
         */
        ContentTranslationSource.prototype.disableLinks = function () {
                this.$content.find( 'a' ).bind( 'click', function () {
+                       var $link = $( this );
+                       // avoid all reference links
+                       if ( !$link.parent().hasClass( 'reference' ) ) {
+                               mw.hook( 'mw.cx.select.link' ).fire( 
$link.text(), mw.cx.sourceLanguage );
+                       }
+                       // Disable link click
                        return false;
                } );
        };
diff --git a/modules/tools/ext.cx.tools.link.js 
b/modules/tools/ext.cx.tools.link.js
index d093746..1f2d4fb 100644
--- a/modules/tools/ext.cx.tools.link.js
+++ b/modules/tools/ext.cx.tools.link.js
@@ -51,7 +51,7 @@
                }
        };
 
-       function getLink( word ) {
+       function getLink( word, language ) {
                var api = new mw.Api();
 
                return api.get( {
@@ -63,8 +63,10 @@
                        redirects: true,
                        format: 'json'
                }, {
-                       url: '//' + mw.cx.targetLanguage + 
'.wikipedia.org/w/api.php',
-                       dataType: 'jsonp'
+                       url: '//' + language + '.wikipedia.org/w/api.php',
+                       dataType: 'jsonp',
+                       // This prevents warnings about the unrecognized 
parameter "_"
+                       cache: true
                } );
        }
 
@@ -158,9 +160,10 @@
                }
        }
 
-       LinkCard.prototype.start = function ( link ) {
+       LinkCard.prototype.start = function ( link, language ) {
                var word, linkCard = this;
 
+               language = language || mw.cx.targetLanguage;
                if ( typeof link === 'string' ) {
                        word = link;
                } else {
@@ -174,11 +177,18 @@
                this.$card.hide();
                if ( this.$link ) {
                        this.$card.show();
+                       // Since this is an existing link, we can show the link 
title early.
+                       this.$card.find( '.card__link-text' )
+                               .text( word )
+                               .attr( {
+                                       target: '_blank',
+                                       href: '//' + language + 
'.wikipedia.org/wiki/' + word
+                               } );
                        this.$addLink.hide();
                } else {
                        this.$removeLink.hide();
                }
-               getLink( word ).done( function ( response ) {
+               getLink( word, language ).done( function ( response ) {
                        var imgSrc, pageId, range, page;
 
                        pageId = Object.keys( response.query.pages )[ 0 ];
@@ -194,7 +204,7 @@
                                .text( page.title )
                                .attr( {
                                        target: '_blank',
-                                       href: '//' + mw.cx.targetLanguage + 
'.wikipedia.org/wiki/' + page.title
+                                       href: '//' + language + 
'.wikipedia.org/wiki/' + page.title
                                } );
                        linkCard.$addLink.click( function () {
                                restoreSelection( range );

-- 
To view, visit https://gerrit.wikimedia.org/r/137869
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia6f3f0087f0cb4cfc2e3e773aa95c1c680827271
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

Reply via email to