Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/148599
Change subject: Highlight the link pairs when clicked on a link ...................................................................... Highlight the link pairs when clicked on a link Hide it when clicked somewhere else. Bug: 67655 Change-Id: I560b2e30d5d4eaf4d180f05778dd41aae91d21db --- M modules/source/ext.cx.source.js M modules/tools/ext.cx.tools.link.js M modules/translation/styles/ext.cx.translation.less 3 files changed, 38 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/99/148599/1 diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js index 0ca30e1..6abfe1b 100644 --- a/modules/source/ext.cx.source.js +++ b/modules/source/ext.cx.source.js @@ -196,9 +196,7 @@ $( '[data-linkid="' + linkid + '"]' ).addClass( 'cx-highlight' ); if ( e.shiftKey || e.ctrlKey ) { - $link - .addClass( 'cx-highlight--blue' ) - .attr( 'title', mw.msg( 'cx-tools-link-hover-tooltip' ) ); + $link.attr( 'title', mw.msg( 'cx-tools-link-hover-tooltip' ) ); } } ); @@ -207,7 +205,6 @@ linkid = $link.data( 'linkid' ); $( '[data-linkid="' + linkid + '"]' ).removeClass( 'cx-highlight' ); - $link.removeClass( 'cx-highlight--blue' ); } ); }; diff --git a/modules/tools/ext.cx.tools.link.js b/modules/tools/ext.cx.tools.link.js index ea0ee58..f6d2dff 100644 --- a/modules/tools/ext.cx.tools.link.js +++ b/modules/tools/ext.cx.tools.link.js @@ -445,6 +445,7 @@ } else { title = cleanupLinkHref( link.attr( 'href' ) ); this.$link = link; + this.$link.addClass( 'cx-highlight--blue' ); } // Do we have a valid title now? if ( !title || !title.trim() ) { @@ -452,6 +453,7 @@ return; } + this.highlightLink(); if ( this.$link && language === mw.cx.targetLanguage ) { this.$card.show(); // Since this is an existing link, we can show the link title early. @@ -487,11 +489,42 @@ } }; - LinkCard.prototype.stop = function () { + /** + * Remove the card + */ + LinkCard.prototype.removeCard = function () { + this.removeLinkHighlight(); this.$card.remove(); + }; + + LinkCard.prototype.stop = function () { + this.removeCard(); mw.hook( 'mw.cx.tools.shown' ).fire( false ); }; + /** + * Highlight the current link pairs. + */ + LinkCard.prototype.highlightLink = function () { + if ( this.$link ) { + $( '[data-linkid="' + this.$link.data( 'linkid' ) + '"]' ) + .addClass( 'cx-highlight--blue' ); + } + }; + + /** + * Remove highlight from the current link pairs. + */ + LinkCard.prototype.removeLinkHighlight = function () { + if ( this.$link ) { + $( '[data-linkid="' + this.$link.data( 'linkid' ) + '"]' ) + .removeClass( 'cx-highlight--blue' ); + // If the link exist only in translation, in the case of an added link, + // there will not be data-linkid. So remove it explicitly. + this.$link.removeClass( 'cx-highlight--blue' ); + } + }; + LinkCard.prototype.getTriggerEvents = function () { return [ 'mw.cx.select.link', // Select a link by clicking - in translation or source diff --git a/modules/translation/styles/ext.cx.translation.less b/modules/translation/styles/ext.cx.translation.less index cb188f4..eee3e70 100644 --- a/modules/translation/styles/ext.cx.translation.less +++ b/modules/translation/styles/ext.cx.translation.less @@ -12,6 +12,9 @@ .cx-highlight { background-color: #FFFEEC; } + .cx-highlight--blue { + background-color: #A9A9F5; + } } .placeholder { -- To view, visit https://gerrit.wikimedia.org/r/148599 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I560b2e30d5d4eaf4d180f05778dd41aae91d21db 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