[MediaWiki-commits] [Gerrit] Images: Make the image tool self contained - change (mediawiki...ContentTranslation)
Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/150185 Change subject: Images: Make the image tool self contained .. Images: Make the image tool self contained * Now the module has no connection to other modules except the hook Helps us to load the module on demand Change-Id: I3fc0dd8b2eddc45027640f1e762dbdc4a95eba9b --- M modules/tools/ext.cx.tools.images.js M modules/translation/ext.cx.translation.js 2 files changed, 9 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/85/150185/1 diff --git a/modules/tools/ext.cx.tools.images.js b/modules/tools/ext.cx.tools.images.js index a68b58c..2b2d79a 100644 --- a/modules/tools/ext.cx.tools.images.js +++ b/modules/tools/ext.cx.tools.images.js @@ -61,13 +61,10 @@ return deferred.promise(); } - /** -* jQuery plugin to adapt images so that parsoid can translate it to -* proper wiki text. -* @param {string} targetLanguage -*/ - $.fn.adaptImage = function ( targetLanguage ) { - return this.each( function () { + function adaptImage( $section ) { + var targetLanguage = mw.cx.targetLanguage; + + $section.find( 'img' ).each( function () { var $image = $( this ); getImageNamespaceTranslation( targetLanguage ) @@ -84,5 +81,9 @@ $image.parent( 'a' ).attr( 'href', resource ); } ); } ); - }; + } + + $( function () { + mw.hook( 'mw.cx.translation.postMT' ).add( adaptImage ); + } ); }( jQuery, mediaWiki ) ); diff --git a/modules/translation/ext.cx.translation.js b/modules/translation/ext.cx.translation.js index 049c5fc..5683b44 100644 --- a/modules/translation/ext.cx.translation.js +++ b/modules/translation/ext.cx.translation.js @@ -147,8 +147,6 @@ // Adapt links $section.adaptLinks( mw.cx.targetLanguage ); - // Adapt images - $section.find( 'img' ).adaptImage( mw.cx.targetLanguage ); // If the section is editable, initiate an editor. // Otherwise make it non-editable. Example: templates -- To view, visit https://gerrit.wikimedia.org/r/150185 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3fc0dd8b2eddc45027640f1e762dbdc4a95eba9b 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
[MediaWiki-commits] [Gerrit] Images: Make the image tool self contained - change (mediawiki...ContentTranslation)
jenkins-bot has submitted this change and it was merged. Change subject: Images: Make the image tool self contained .. Images: Make the image tool self contained * Now the module has no connection to other modules except the hook Helps us to load the module on demand Change-Id: I3fc0dd8b2eddc45027640f1e762dbdc4a95eba9b --- M modules/tools/ext.cx.tools.images.js M modules/translation/ext.cx.translation.js 2 files changed, 9 insertions(+), 10 deletions(-) Approvals: Amire80: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/tools/ext.cx.tools.images.js b/modules/tools/ext.cx.tools.images.js index a68b58c..2b2d79a 100644 --- a/modules/tools/ext.cx.tools.images.js +++ b/modules/tools/ext.cx.tools.images.js @@ -61,13 +61,10 @@ return deferred.promise(); } - /** -* jQuery plugin to adapt images so that parsoid can translate it to -* proper wiki text. -* @param {string} targetLanguage -*/ - $.fn.adaptImage = function ( targetLanguage ) { - return this.each( function () { + function adaptImage( $section ) { + var targetLanguage = mw.cx.targetLanguage; + + $section.find( 'img' ).each( function () { var $image = $( this ); getImageNamespaceTranslation( targetLanguage ) @@ -84,5 +81,9 @@ $image.parent( 'a' ).attr( 'href', resource ); } ); } ); - }; + } + + $( function () { + mw.hook( 'mw.cx.translation.postMT' ).add( adaptImage ); + } ); }( jQuery, mediaWiki ) ); diff --git a/modules/translation/ext.cx.translation.js b/modules/translation/ext.cx.translation.js index 049c5fc..5683b44 100644 --- a/modules/translation/ext.cx.translation.js +++ b/modules/translation/ext.cx.translation.js @@ -147,8 +147,6 @@ // Adapt links $section.adaptLinks( mw.cx.targetLanguage ); - // Adapt images - $section.find( 'img' ).adaptImage( mw.cx.targetLanguage ); // If the section is editable, initiate an editor. // Otherwise make it non-editable. Example: templates -- To view, visit https://gerrit.wikimedia.org/r/150185 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3fc0dd8b2eddc45027640f1e762dbdc4a95eba9b Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com Gerrit-Reviewer: Amire80 amir.ahar...@mail.huji.ac.il Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits